'));
$row->setCssClass('tfoot');
$row->setStyle(array('text-align' => 'right'));
$table->addChild($row)
echo $table->paint();
}
}
// ###################################################################
/**
* Returns the value of a given descriptor and property by comparing
* the mater set and custom set then returning the right one
*
* @param string Descriptor
* @param string Property
*
* @return string Value of the given property
*/
private function _fetchValue($descriptor, $property)
{
if (!isset($this->customdata["$descriptor"]["$property"]))
{
return $this->masterdata["$descriptor"]["$property"];
}
else
{
return $this->customdata["$descriptor"]["$property"];
}
}
// ###################################################################
/**
* Returns the state modified state (false for untouched and true
* for modified) from the descriptor-property value between the master
* set and the custom set of data
*
* @param string Descriptor
* @param string Property
*
* @return bool Modified from the master value?
*/
private function _fetchModifiedStatus($descriptor, $property)
{
return ($this->masterdata["$descriptor"]["$property"] != $this->customdata["$descriptor"]["$property"] AND isset($this->customdata["$descriptor"]["$property"]));
}
// ###################################################################
/**
* Fetches a link that shows a revert link for a given property
* that uses AJAX to revert when clicked
*
* @param string Descriptor
* @param string Property
* @param string Nominalized text
*
* @return string Output HTML
*/
private function _fetchModifiedLink($descriptor, $property, $name)
{
$status = $this->_fetchModifiedStatus($descriptor, $property);
if ($status)
{
if (is_callable($this->modifiedLinkHook))
{
return call_user_func($this->modifiedLinkHook, $descriptor, $property, $name);
}
else
{
trigger_error('BSPrinterCss::_fetchModifiedLink() needs to have the fetchModifiedLinkHook( $descriptor , $property , $name ) defined');
}
}
else
{
return $name;
}
}
// ###################################################################
/**
* Generates an array of queries that should be run on your database to
* update CSS changes. All of the queries have sprintf() markers that
* need to be evaluated:
*
* %1$s - Database table
* %2$s - styleid field
* %3$s - descriptor field
* %4$s - property field
* %5$s - value field
* %6$d - Styleid value
*
* @param array Array of user-inputted information to be transformed into queries
*
* @return array Queries that need to be evaluated then ran
*/
public function fetchChangeQuery($data)
{
$queries[0] = '--- RESERVED FOR LATER USE ---';
$deletes = array();
foreach ($this->descriptors AS $descriptor => $opts)
{
$dolink = $opts['dolink'];
if ($dolink)
{
$loops = array('', ' a:link', ' a:visited', ' a:hover');
}
else
{
$loops = array('');
}
foreach ($loops AS $sel)
{
foreach ($data["$descriptor$sel"] AS $prop => $value)
{
// the given value matches the master -- no change
if ($this->masterdata["$descriptor$sel"]["$prop"] == $value)
{
continue;
}
// the given matches the custom -- no change
else if (isset($this->customdata["$descriptor$sel"]["$prop"]) AND $this->customdata["$descriptor$sel"]["$prop"] == $value)
{
continue;
}
// no matching, it's new
else
{
$value = str_replace('%', '%%', $value);
$deletes[] = "%3\$s = '" . $this->_escape($descriptor . $sel) . "' AND %4\$s = '" . $this->_escape($prop) . "'";
$queries[] = "INSERT INTO %1\$s (%2\$s, %3\$s, %4\$s, %5\$s) VALUES (%6\$d, '" . $this->_escape($descriptor . $sel) . "', '" . $this->_escape($prop) . "', '" . $this->_escape($value) . "')";
}
}
}
}
if (sizeof($deletes) < 1)
{
$queries[0] = '##';
}
else
{
$queries[0] = "DELETE FROM %1\$s WHERE styleid = %6\$d AND ((" . implode(') OR (', $deletes) . "))";
}
return $queries;
}
// ###################################################################
/**
* Wrapper for BSDb->escapeString()
*
* @param string Unprotected string
*
* @return string Sanitized string
*/
private function _escape($string)
{
return BSApp::GetType('Db')->escapeString($string);
}
// ###################################################################
/**
* Generates a linkable/usable CSS stylehseet content file; this can
* be outputted to the browser
*
* @return string CSS output
*/
public function fetchCssOutput()
{
$data = array();
foreach ($this->descriptors AS $descriptor => $opts)
{
$dolink = $opts['dolink'];
if ($dolink)
{
$loops = array('', ' a:link', ' a:visited', ' a:hover');
}
else
{
$loops = array('');
}
foreach ($loops AS $sel)
{
foreach ($this->masterdata["$descriptor$sel"] AS $prop => $value)
{
$data["$descriptor$sel"]["$prop"] = $value;
}
if (is_array($this->customdata["$descriptor$sel"]))
{
foreach ($this->customdata["$descriptor$sel"] AS $prop => $value)
{
$data["$descriptor$sel"]["$prop"] = $value;
}
}
}
}
$output = '/* CSS Style Sheet (generated by BSPrinterCss $Revision$) */';
foreach ($data AS $selector => $props)
{
$output .= "\n\n$selector\n{";
foreach ($props AS $name => $value)
{
if ($name != 'extra' AND $value != '')
{
$output .= str_replace('"', '"', "\n\t$name: $value;");
}
}
if ($props['extra'])
{
$extra = explode("\n", BSFunctions::ConvertLineBreaks($props['extra']));
foreach ($extra AS $prop)
{
$output .= "\n\t$prop";
}
}
$output .= "\n}";
}
return $output;
}
}
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>