// | 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_Inline.php,v 1.1 2003/07/31 14:58:19 thesaur Exp $ require_once 'HTML/CSS.php'; // generate a new class $css = new HTML_CSS(); // let's set some styles for <body> $css->setStyle('body', 'background-color', '#0c0c0c'); $css->setStyle('body', 'color', '#ffffff'); // now for <h1> $css->setStyle('h1', 'text-align', 'center'); $css->setStyle('h1', 'font', '16pt helvetica, arial, sans-serif'); // and finally for <p> $css->setStyle('p', 'font', '12pt helvetica, arial, sans-serif'); // let's make <body> inherit from <p> $css->setSameStyle('body', 'p'); // and let's put this into a tag: echo '<body style="' . $css->toInline('body') . '">'; // will output: // <body style="font:12pt helvetica, arial, sans-serif;background-color:#0c0c0c;color:#ffffff;"> // ideas for inline use: // * use in conjunction with HTML_Table to assign styles for cells // * integrates easily into existing classes
/** * 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; }
/** * 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; }