/** * Class constructor * * @return void * @see Woops_Xhtml_Tag::__construct */ public function __construct($text) { // Sets the comment text $this->_comment = $text; // Calls the parent constructor parent::__construct(''); }
/** * */ function process(stdClass $options) { $content = new Woops_Xhtml_Tag('div'); $content['class'] = str_replace('.', '-', $options->name); $content->comment('Start of CMS block: ' . $options->name); try { $block = self::$_modManager->getBlock('cms', $options->name); $blockOptions = clone $options; unset($blockOptions->name); $block->getBlockContent($content, $blockOptions); } catch (Woops_Core_Module_Manager_Exception $e) { $code = $e->getCode(); if ($code === Woops_Core_Module_Manager_Exception::EXCEPTION_NO_BLOCK || $code === Woops_Core_Module_Manager_Exception::EXCEPTION_NO_BLOCK_TYPE || $code === Woops_Core_Module_Manager_Exception::EXCEPTION_MODULE_NOT_LOADED) { $error = $content->div->strong; $error['style'] = 'color: #FF0000;'; $error->addTextData('[BLOCK ERROR: ' . $options->name . ']'); $content->div = $e->getMessage(); } else { throw $e; } } $content->comment('End of CMS block: ' . $options->name); return $content; }
/** * Sets the needed static variables * * @return void */ private static function _setStaticVars() { // Gets the instance of the string utilities self::$_str = Woops_String_Utils::getInstance(); // Gets the instance of the configuration object self::$_conf = Woops_Core_Config_Getter::getInstance(); // Sets the XHTML formatting option self::$_formattedOutput = (bool) self::$_conf->getVar('xhtml', 'format'); // Static variables are set self::$_hasStatic = true; }
/** * */ public function addHeadNode(Woops_Xhtml_Tag $node) { $tagName = $node->getTagName(); switch ($tagName) { case 'title': $this->_headerParts['title'] = $node; break; case 'meta': if (isset($node['http-equiv'])) { $this->_headerParts['meta-http'][] = $node; } elseif (isset($node['name'])) { $this->_headerParts['meta-name'][] = $node; } break; case 'base': $this->_headerParts['base'] = $node; break; case 'link': $this->_headerParts['link'][] = $node; break; case 'style': $this->_headerParts['style'][] = $node; break; case 'script': $this->_headerParts['script'][] = $node; break; } }
/** * Gets an HTML representation of a PHP variable * * @param mixed The variable to display * @param boolean Whether the result must be returned, or directly printed * @param string An optionnal header to display * @return mixed If the $return parameter is set, this method will return a Woops_Xhtml_Tag instance, otherwise NULL * @see viewArray * @see _getVarType */ public static function debug($var, $return = false, $header = 'Debug informations') { // Common CSS styles $commonStyle = 'font-family: Verdana, sans-serif; font-size: 10px; color: #898989; '; // Creates the container DIV $container = new Woops_Xhtml_Tag('div'); $container['style'] = $commonStyle . 'background-color: #EDF5FA; border: solid 1px #D3E7F4; margin: 2px; padding: 2px;'; // Adds an HTML comment $container->comment('PHP variable debug - start'); // Creates the header $headerSection = $container->div; $headerSection['style'] = $commonStyle . 'text-align: center; background-color: #FFFFFF; border: solid 1px #D3E7F4; margin: 2px; padding: 2px;'; $headerText = $headerSection->strong; $headerText['style'] = 'color: #0062A0; font-size: 15px'; $headerText->addTextData($header); // Adds the variable type $typeSection = $container->div; $typeSection['style'] = $commonStyle . 'background-color: #FFFFFF; border: solid 1px #D3E7F4; margin: 2px; padding: 2px;'; $typeText = $typeSection->strong; $typeText['style'] = 'color: #0062A0;'; $typeSection->span = self::_getVarType($var); $typeText->addTextData('Variable type:'); // Adds an HTML comment $container->comment('PHP variable debug - end'); // Creates a DIV for the data $dataDiv = $container->div; $dataDiv['style'] = $commonStyle . 'background-color: #FFFFFF; border: solid 1px #D3E7F4; margin: 2px; padding: 2px;'; // Checks the variable type if (is_array($var)) { // Displays an array $dataDiv->addChildNode(self::viewArray($var, true)); } elseif (is_object($var)) { // Displays an object $dataDiv->pre = print_r($var, true); } elseif (is_bool($var)) { // Boolean value $value = $var ? 'true' : 'false'; $dataDiv->addTextData($value); } else { // Other kind of data $dataDiv->addTextData($var); } // Checks if we have to return the variable representation if ($return) { // Returns the XHTML tag object return $container; } // Prints the variable representation print (string) $container; }