/** * Returns the cascading style sheet (CSS). * * Get the CSS required to display the progress meter in a HTML document. * * @param boolean $raw (optional) html output with script tags or just raw data * * @return string * @since 2.0.0 * @access public * @throws HTML_PROGRESS2_ERROR_INVALID_INPUT */ function getStyle($raw = true) { if (!is_bool($raw)) { return $this->raiseError(HTML_PROGRESS2_ERROR_INVALID_INPUT, 'exception', array('var' => '$raw', 'was' => gettype($raw), 'expected' => 'boolean', 'paramnum' => 1)); } $progressAttr = $this->getProgressAttributes(); $borderAttr = $this->getBorderAttributes(); $cellAttr = $this->getCellAttributes(); $css = new HTML_CSS(); $borderCls = '.' . sprintf($borderAttr['class'], $this->ident); $css->setStyle($borderCls, 'width', $progressAttr['width'] . 'px'); $css->setStyle($borderCls, 'height', $progressAttr['height'] . 'px'); if ($this->isBorderPainted()) { $css->setStyle($borderCls, 'border-width', $borderAttr['width'] . 'px'); $css->setStyle($borderCls, 'border-style', $borderAttr['style']); $css->setStyle($borderCls, 'border-color', $borderAttr['color']); } if ($progressAttr['background-image'] !== 'none') { $css->setStyle($borderCls, 'background-image', 'url("' . $progressAttr['background-image'] . '")'); $css->setStyle($borderCls, 'background-repeat', $progressAttr['background-repeat']); $css->setStyle($borderCls, 'background-position', $progressAttr['background-position']); } if ($this->cellCount > 0) { $css->setStyle($borderCls, 'background-color', $progressAttr['background-color']); } else { $css->setStyle($borderCls, 'background-color', $cellAttr['inactive-color']); } foreach ($this->label as $name => $data) { $style = '.' . sprintf($data['class'], $name . $this->ident); if ($data['width'] > 0) { $css->setStyle($style, 'width', $data['width'] . 'px'); } if ($data['height'] > 0) { $css->setStyle($style, 'height', $data['height'] . 'px'); } $css->setStyle($style, 'text-align', $data['align']); $css->setStyle($style, 'background-color', $data['background-color']); $css->setStyle($style, 'font-size', $data['font-size'] . 'px'); $css->setStyle($style, 'font-family', $data['font-family']); $css->setStyle($style, 'font-weight', $data['font-weight']); $css->setStyle($style, 'color', $data['color']); } $cellClsI = '.' . sprintf($cellAttr['class'], $this->ident) . 'I'; $cellClsA = '.' . sprintf($cellAttr['class'], $this->ident) . 'A'; $css->setStyle($cellClsI, 'width', $cellAttr['width'] . 'px'); $css->setStyle($cellClsI, 'height', $cellAttr['height'] . 'px'); $css->setStyle($cellClsI, 'font-family', $cellAttr['font-family']); $css->setStyle($cellClsI, 'font-size', $cellAttr['font-size'] . 'px'); if ($this->orientation == HTML_PROGRESS2_BAR_HORIZONTAL) { $css->setStyle($cellClsI, 'float', 'left'); } if ($this->orientation == HTML_PROGRESS2_BAR_VERTICAL) { $css->setStyle($cellClsI, 'float', 'none'); } $css->setSameStyle($cellClsA, $cellClsI); if ($this->orientation !== HTML_PROGRESS2_CIRCLE) { $css->setStyle($cellClsI, 'background-color', $cellAttr['inactive-color']); } $css->setStyle($cellClsA, 'background-color', $cellAttr['active-color']); if ($cellAttr['background-image'] !== 'none') { $css->setStyle($cellClsA, 'background-image', 'url("' . $cellAttr['background-image'] . '")'); if ($this->orientation == HTML_PROGRESS2_CIRCLE) { $css->setStyle($cellClsA, 'background-repeat', 'no-repeat'); } else { $css->setStyle($cellClsA, 'background-repeat', $cellAttr['background-repeat']); $css->setStyle($cellClsA, 'background-position', $cellAttr['background-position']); } } if ($this->orientation == HTML_PROGRESS2_CIRCLE) { $css->setStyle($cellClsI, 'background-image', 'url("' . $cellAttr[0]['background-image'] . '")'); $css->setStyle($cellClsI, 'background-repeat', 'no-repeat'); } $styles = $css->toString(); if ($raw !== true) { $styles = '<style type="text/css">' . PHP_EOL . '<!--' . PHP_EOL . $styles . PHP_EOL . ' -->' . PHP_EOL . '</style>' . PHP_EOL; } return $styles; }
<?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997 - 2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Author: Klaus Guenther <*****@*****.**> | // +----------------------------------------------------------------------+ // // $Id: CSS_Stylesheet.php,v 1.1 2003/07/31 14:58:19 thesaur Exp $ require_once 'HTML/CSS.php'; $css = new HTML_CSS(); // define styles $css->setStyle('body', 'background-color', '#0c0c0c'); $css->setStyle('body', 'color', '#ffffff'); $css->setStyle('h1', 'text-align', 'center'); $css->setStyle('h1', 'font', '16pt helvetica, arial, sans-serif'); $css->setStyle('p', 'font', '12pt helvetica, arial, sans-serif'); // output the stylesheet directly to browser $css->display();
function _renderForm(&$page) { $pageName = $page->getAttribute('name'); $tabPreview = array_slice($page->controller->_tabs, -2, 1); $css = new HTML_CSS(); $css->setStyle('body', 'background-color', '#7B7B88'); $css->setStyle('body', 'font-family', 'Verdana, Arial, helvetica'); $css->setStyle('body', 'font-size', '10pt'); $css->setStyle('h1', 'color', '#FFC'); $css->setStyle('h1', 'text-align', 'center'); $css->setStyle('.maintable', 'width', '100%'); $css->setStyle('.maintable', 'border-width', '0'); $css->setStyle('.maintable', 'border-style', 'thin dashed'); $css->setStyle('.maintable', 'border-color', '#D0D0D0'); $css->setStyle('.maintable', 'background-color', '#EEE'); $css->setStyle('.maintable', 'cellspacing', '2'); $css->setStyle('.maintable', 'cellspadding', '3'); $css->setStyle('th', 'text-align', 'center'); $css->setStyle('th', 'color', '#FFC'); $css->setStyle('th', 'background-color', '#AAA'); $css->setStyle('th', 'white-space', 'nowrap'); $css->setStyle('input', 'font-family', 'Verdana, Arial, helvetica'); $css->setStyle('input.flat', 'border-style', 'solid'); $css->setStyle('input.flat', 'border-width', '2px 2px 0px 2px'); $css->setStyle('input.flat', 'border-color', '#996'); $header = ' <style type="text/css"> <!-- {%style%} // --> </style> '; // on preview tab, add progress bar javascript and stylesheet if ($pageName == $tabPreview[0][0]) { $bar = $page->controller->createProgressBar(); $header .= ' <script type="text/javascript"> <!-- {%javascript%} //--> </script> '; $header = str_replace('{%style%}', $css->toString() . $bar->getStyle(), $header); $header = str_replace('{%javascript%}', $bar->getScript(), $header); $barElement =& $page->getElement('progressBar'); $barElement->setText($bar->toHtml()); } else { $header = str_replace('{%style%}', $css->toString(), $header); } $renderer =& $page->defaultRenderer(); $renderer->setFormTemplate($header . '<table class="maintable"><form{attributes}>{content}</form></table>'); $renderer->setHeaderTemplate('<tr><th colspan="2">{header}</th></tr>'); $renderer->setGroupTemplate('<table><tr>{content}</tr></table>', 'name'); $renderer->setGroupElementTemplate('<td>{element}<br /><span class="qfLabel">{label}</span></td>', 'name'); $page->accept($renderer); echo $renderer->toHtml(); }
/** * Returns the custom style sheet * * Returns the custom style sheet to use for layout * * @param int $destination (optional) Destination of css content * @param mixed $extra (optional) Additional data depending of destination * * @return mixed * @access public * @since version 1.8.0b4 (2008-06-18) */ function getStyleSheet($destination = 1, $extra = null) { $css = new HTML_CSS(); $css->parseFile($this->css); $tdw = $this->conf['tdwidth']; $em = array_sum($tdw); $td = 'td'; $o = $this->args['output-level']; $css->setStyle('.outer td.dirname', 'width', $em . 'em'); if ($o & 16) { $td .= '+td'; $css->setStyle('.outer ' . $td, 'width', $tdw[1] . 'em'); $em = $em - $tdw[1]; } if ($o & 1) { $td .= '+td'; $css->setStyle('.outer ' . $td, 'width', $tdw[2] . 'em'); $em = $em - $tdw[2]; } if ($o & 2) { $td .= '+td'; $css->setStyle('.outer ' . $td, 'width', $tdw[3] . 'em'); $em = $em - $tdw[3]; } if ($o & 12) { $td .= '+td'; $css->setStyle('.outer ' . $td, 'width', $tdw[4] . 'em'); $em = $em - $tdw[4]; } $css->setStyle('.outer td', 'width', $em . 'em'); $styles = ''; switch ($destination) { case 1: // embedded styles $styles = $css->toString(); break; case 2: // save only to file $css->toFile($extra); $styles = $extra; break; case 3: // apply a user function if (is_callable($extra)) { $styles = call_user_func_array($extra, array($css)); } break; default: break; } return $styles; }
/** * Get the cascading style sheet to put inline on HTML document * * @return object HTML_CSS instance * @since 0.2 * @access public * @tutorial ui.getstyle.pkg * @author Stefan Neufeind <*****@*****.**> Contributor. * See details on thanks section of README file. */ function &getStyle() { include_once 'HTML/CSS.php'; $progressAttr = $this->getProgressAttributes(); $borderAttr = $this->getBorderAttributes(); $stringAttr = $this->getStringAttributes(); $cellAttr = $this->getCellAttributes(); $orient = $this->getOrientation(); $css = new HTML_CSS(); $css->setStyle('.' . $progressAttr['class'], 'background-color', $progressAttr['background-color']); $css->setStyle('.' . $progressAttr['class'], 'width', $progressAttr['width'] . 'px'); $css->setStyle('.' . $progressAttr['class'], 'height', $progressAttr['height'] . 'px'); $css->setStyle('.' . $progressAttr['class'], 'position', 'relative'); $css->setStyle('.' . $progressAttr['class'], 'left', '0px'); $css->setStyle('.' . $progressAttr['class'], 'top', '0px'); $css->setSameStyle('.' . $borderAttr['class'], '.' . $progressAttr['class']); $css->setStyle('.' . $borderAttr['class'], 'border-width', $borderAttr['width'] . 'px'); $css->setStyle('.' . $borderAttr['class'], 'border-style', $borderAttr['style']); $css->setStyle('.' . $borderAttr['class'], 'border-color', $borderAttr['color']); $css->setStyle('.' . $stringAttr['id'], 'width', $stringAttr['width'] . 'px'); if (isset($stringAttr['height'])) { $css->setStyle('.' . $stringAttr['id'], 'height', $stringAttr['height'] . 'px'); } $css->setStyle('.' . $stringAttr['id'], 'text-align', $stringAttr['align']); $css->setStyle('.' . $stringAttr['id'], 'font-family', $stringAttr['font-family']); $css->setStyle('.' . $stringAttr['id'], 'font-size', $stringAttr['font-size'] . 'px'); $css->setStyle('.' . $stringAttr['id'], 'color', $stringAttr['color']); $css->setStyle('.' . $stringAttr['id'], 'background-color', $stringAttr['background-color']); $css->setStyle('.' . $cellAttr['class'] . 'I', 'width', $cellAttr['width'] . 'px'); $css->setStyle('.' . $cellAttr['class'] . 'I', 'height', $cellAttr['height'] . 'px'); $css->setStyle('.' . $cellAttr['class'] . 'I', 'font-family', $cellAttr['font-family']); $css->setStyle('.' . $cellAttr['class'] . 'I', 'font-size', $cellAttr['font-size'] . 'px'); if ($orient == HTML_PROGRESS_BAR_HORIZONTAL) { $css->setStyle('.' . $cellAttr['class'] . 'I', 'float', 'left'); } if ($orient == HTML_PROGRESS_BAR_VERTICAL) { $css->setStyle('.' . $cellAttr['class'] . 'I', 'float', 'none'); } $css->setSameStyle('.' . $cellAttr['class'] . 'A', '.' . $cellAttr['class'] . 'I'); if ($orient !== HTML_PROGRESS_CIRCLE) { $css->setStyle('.' . $cellAttr['class'] . 'I', 'background-color', $cellAttr['inactive-color']); $css->setStyle('.' . $cellAttr['class'] . 'A', 'background-color', $cellAttr['active-color']); } $css->setStyle('.' . $cellAttr['class'] . 'A', 'visibility', 'hidden'); if (isset($cellAttr['background-image'])) { $css->setStyle('.' . $cellAttr['class'] . 'A', 'background-image', 'url("' . $cellAttr['background-image'] . '")'); $css->setStyle('.' . $cellAttr['class'] . 'A', 'background-repeat', 'no-repeat'); } if ($orient == HTML_PROGRESS_CIRCLE) { $css->setStyle('.' . $cellAttr['class'] . 'I', 'background-image', 'url("' . $cellAttr[0]['background-image'] . '")'); $css->setStyle('.' . $cellAttr['class'] . 'I', 'background-repeat', 'no-repeat'); } return $css; }
function _renderForm(&$page) { $pageName = $page->getAttribute('name'); $tabPreview = array_slice($page->controller->_tabs, -2, 1); $p = new HTML_Page(array('lineend' => OS_WINDOWS ? 'win' : 'unix', 'doctype' => "XHTML 1.0 Strict", 'language' => 'en', 'cache' => 'false')); $p->disableXmlProlog(); $p->setTitle("PEAR::HTML_Progress - Generator"); $p->setMetaData("author", "Laurent Laville"); $css = new HTML_CSS(); $css->setStyle('body', 'background-color', '#7B7B88'); $css->setStyle('body', 'font-family', 'Verdana, Arial, helvetica'); $css->setStyle('body', 'font-size', '10pt'); $css->setStyle('h1', 'color', '#FFC'); $css->setStyle('h1', 'text-align', 'center'); $css->setStyle('.maintable', 'width', '100%'); $css->setStyle('.maintable', 'border-width', '0'); $css->setStyle('.maintable', 'border-style', 'thin dashed'); $css->setStyle('.maintable', 'border-color', '#D0D0D0'); $css->setStyle('.maintable', 'background-color', '#EEE'); $css->setStyle('.maintable', 'cellspacing', '2'); $css->setStyle('.maintable', 'cellspadding', '3'); $css->setStyle('th', 'text-align', 'center'); $css->setStyle('th', 'color', '#FFC'); $css->setStyle('th', 'background-color', '#AAA'); $css->setStyle('th', 'white-space', 'nowrap'); $css->setStyle('input', 'font-family', 'Verdana, Arial, helvetica'); $css->setStyle('input.flat', 'border-style', 'solid'); $css->setStyle('input.flat', 'border-width', '2px 2px 0px 2px'); $css->setStyle('input.flat', 'border-color', '#996'); // on preview tab, add progress bar javascript and stylesheet if ($pageName == $tabPreview[0][0]) { $bar = $page->controller->createProgressBar(); $p->addStyleDeclaration($css->toString() . $bar->getStyle()); $p->addScriptDeclaration($bar->getScript()); $barElement =& $page->getElement('progressBar'); $barElement->setText($bar->toHtml()); } else { $p->addStyleDeclaration($css->toString()); } $renderer =& $page->defaultRenderer(); $renderer->setFormTemplate('<table class="maintable"><form{attributes}>{content}</form></table>'); $renderer->setHeaderTemplate('<tr><th colspan="2">{header}</th></tr>'); $renderer->setGroupTemplate('<table><tr>{content}</tr></table>', 'name'); $renderer->setGroupElementTemplate('<td>{element}<br /><span style="font-size:10px;"><span class="label">{label}</span></span></td>', 'name'); $page->accept($renderer); $p->addBodyContent($renderer->toHtml()); $p->display(); }