cvs: pear /PEAR_PackageFileManager_Frontend_Web/Frontend/Web Default.php
| From: | Laurent Laville | Date: | Sat, 19 Aug 2006 10:01:56 +0000 |
| Subject: | cvs: pear /PEAR_PackageFileManager_Frontend_Web/Frontend/Web Default.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-41688@lists.php.net to get a copy of this message | ||
farell Sat Aug 19 10:01:56 2006 UTC
Modified files:
/pear/PEAR_PackageFileManager_Frontend_Web/Frontend/Web Default.php
Log:
new architechture (still compatible with old one) that allow to use an external stylesheet
http://cvs.php.net/viewvc.cgi/pear/PEAR_PackageFileManager_Frontend_Web/Frontend/Web/Default.php?r1=1.5&r2=1.6&diff_format=u
Index: pear/PEAR_PackageFileManager_Frontend_Web/Frontend/Web/Default.php
diff -u pear/PEAR_PackageFileManager_Frontend_Web/Frontend/Web/Default.php:1.5
pear/PEAR_PackageFileManager_Frontend_Web/Frontend/Web/Default.php:1.6
--- pear/PEAR_PackageFileManager_Frontend_Web/Frontend/Web/Default.php:1.5 Sun Jul 23 09:07:10 2006
+++ pear/PEAR_PackageFileManager_Frontend_Web/Frontend/Web/Default.php Sat Aug 19 10:01:55 2006
@@ -7,7 +7,7 @@
* @author Laurent Laville <pear@laurent-laville.org>
* @copyright 2005-2006 Laurent Laville
* @license http://www.php.net/license/3_01.txt PHP License 3.01
- * @version CVS: $Id: Default.php,v 1.5 2006/07/23 09:07:10 farell Exp $
+ * @version CVS: $Id: Default.php,v 1.6 2006/08/19 10:01:55 farell Exp $
* @since File available since Release 0.1.0
*/
@@ -25,15 +25,39 @@
class ActionDisplay extends HTML_QuickForm_Action_Display
{
/**
+ * Style sheet for the custom layout
*
- * @since 0.1.0
+ * @var string
+ * @access public
+ * @since 0.6.0
+ */
+ var $css;
+
+ /**
+ * class constructor
+ *
+ * @param string $css custom stylesheet to apply, or default if not set
+ * @access public
+ * @since 0.6.0
+ */
+ function ActionDisplay($css = null)
+ {
+ // when no user-styles defined, used the default values
+ $this->setStyleSheet($css);
+ }
+
+ /**
+ * Outputs the form.
+ *
+ * @param object HTML_QuickForm_Page the page being processed
* @access private
+ * @since 0.1.0
*/
function _renderForm(&$page)
{
-
$formTemplate = "\n<form{attributes}>"
. "\n<table class=\"maintable\">"
+ . "\n<caption>PEAR_PackageFileManager Web
Frontend</caption>"
. "\n{content}"
. "\n</table>"
. "\n</form>";
@@ -51,8 +75,8 @@
. "\n</tr>";
$elementTemplate = "\n<tr>"
- . "\n\t<td class=\"form-label\"><!-- BEGIN
required --><span style=\"color: #ff0000\">*</span> <!-- END
required --><!-- BEGIN label --><b>{label}</b><!-- END label
--></td>"
- . "\n\t<td class=\"form-input\">{element}<!--
BEGIN error --><br /><span style=\"color:
#ff0000\">{error}</span><!-- END error --></td>"
+ . "\n\t<td class=\"form-label\"><!-- BEGIN
required --><span class=\"required\">*</span> <!-- END required
--><!-- BEGIN label -->{label}<!-- END label --></td>"
+ . "\n\t<td class=\"form-input\">{element}<!--
BEGIN error --><br /><span class=\"error\">{error}</span><!-- END
error --></td>"
. "\n</tr>";
$groupTemplate = "\n\t\t<table cellspacing=\"0\">"
@@ -63,7 +87,7 @@
$groupElementTemplate = "<td valign=\"top\">{element}"
. "<!-- BEGIN label --><br />"
- . "<span style=\"font-size:90%;\">{label}<!--
BEGIN required --><span style=\"color: #ff0000\">*</span><!-- END
required --></span>"
+ . "<span class=\"qfLabel\">{label}<!-- BEGIN
required --><span class=\"required\">*</span><!-- END required
--></span>"
. "<!-- END label -->"
. "</td>";
@@ -93,9 +117,10 @@
$data_dir = '@data_dir@' . DIRECTORY_SEPARATOR
. '@package_name@' . DIRECTORY_SEPARATOR;
- $styles = file_get_contents(PEAR_PACKAGEFILEMANAGER_FRONTEND_DATADIR .
'pfmfe.css');
+ $styles = $this->getStyleSheet();
$js = file_get_contents($data_dir . 'doSelection.js');
- $body = $renderer->toHtml();
+
+ $body = $renderer->toHtml();
$html = <<<HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
@@ -115,12 +140,53 @@
</script>
</head>
<body>
-<h1>PEAR_PackageFileManager Web Frontend</h1>
$body
</body>
</html>
HTML;
echo $html;
}
+
+ /**
+ * Returns the custom style sheet to use for layout
+ *
+ * @param bool $content (optional) Either return css filename or string contents
+ * @return string
+ * @access public
+ * @since 0.6.0
+ */
+ function getStyleSheet($content = true)
+ {
+ if ($content) {
+ $styles = file_get_contents($this->css);
+ } else {
+ $styles = $this->css;
+ }
+ return $styles;
+ }
+
+ /**
+ * Set the custom style sheet to use your own styles
+ *
+ * @param string $css (optional) File to read user-defined styles from
+ * @return bool true if custom styles, false if default styles applied
+ * @access public
+ * @since 0.6.0
+ */
+ function setStyleSheet($css = null)
+ {
+ // default stylesheet is into package data directory
+ if (!isset($css)) {
+ $this->css = '@data_dir@' . DIRECTORY_SEPARATOR
+ . '@package_name@' . DIRECTORY_SEPARATOR
+ . 'default.css';
+ }
+
+ $res = isset($css) && file_exists($css);
+ if ($res) {
+ $this->css = $css;
+ }
+ return $res;
+ }
}
?>
\ No newline at end of file