/** * Configures the test case. */ public function setUp() { $tpl = new Opt_Class(); $tpl->sourceDir = '/'; $tpl->sourceDir = 'php://memory'; $tpl->compileDir = dirname(__FILE__) . '/../../Cache/'; $tpl->escape = false; $tpl->allowArrays = true; $tpl->allowObjects = true; $tpl->allowObjectCreation = true; $tpl->register(Opt_Class::PHP_FUNCTION, '_', '_'); $tpl->register(Opt_Class::PHP_FUNCTION, 'foo', 'foo'); $tpl->register(Opt_Class::PHP_FUNCTION, 'bar', 'bar'); $tpl->register(Opt_Class::PHP_FUNCTION, 'joe', 'joe'); $tpl->register(Opt_Class::PHP_FUNCTION, 'lol', 'lol'); $tpl->register(Opt_Class::PHP_FUNCTION, 'funct', 'funct'); $tpl->register(Opt_Class::PHP_FUNCTION, 'rotfl', 'rotfl'); $tpl->register(Opt_Class::PHP_FUNCTION, 'lmao1', '#1#lmao'); $tpl->register(Opt_Class::PHP_FUNCTION, 'lmao2', '#2,1#lmao'); $tpl->register(Opt_Class::PHP_FUNCTION, 'lmao3', '#3,1,2:null#lmao'); $tpl->register(Opt_Class::PHP_CLASS, 'class', '_class'); $tpl->register(Opt_Class::PHP_CLASS, 'e', 'e'); $tpl->register(Opt_Class::PHP_CLASS, 'u', 'u'); $tpl->register(Opt_Class::PHP_CLASS, 'a', 'a'); Opl_Registry::register('opl_translate', $this->getMock('Opl_Translation_Interface')); $tpl->setup(); $this->tpl = $tpl; $this->cpl = new Opt_Compiler_Class($tpl); }
/** * The class constructor - registers the main object in the * OPL registry. */ public function __construct() { if (Opl_Registry::exists('opc')) { throw new Opc_CannotCreateAnotherInstance_Exception(); } Opl_Registry::register('opc', $this); }
protected function setUp() { $tpl = new Opt_Class(); $tpl->sourceDir = '/'; $tpl->sourceDir = './templates/'; $tpl->compileDir = './templates_c/'; $tpl->escape = false; $tpl->register(Opt_Class::PHP_FUNCTION, '_', '_'); $tpl->register(Opt_Class::PHP_FUNCTION, 'foo', 'foo'); $tpl->register(Opt_Class::PHP_FUNCTION, 'bar', 'bar'); $tpl->register(Opt_Class::PHP_FUNCTION, 'joe', 'joe'); $tpl->register(Opt_Class::PHP_FUNCTION, 'lol', 'lol'); $tpl->register(Opt_Class::PHP_FUNCTION, 'funct', 'funct'); $tpl->register(Opt_Class::PHP_FUNCTION, 'rotfl', 'rotfl'); $tpl->register(Opt_Class::PHP_FUNCTION, 'lmao1', '#1#lmao'); $tpl->register(Opt_Class::PHP_FUNCTION, 'lmao2', '#2,1#lmao'); $tpl->register(Opt_Class::PHP_FUNCTION, 'lmao3', '#3,1,2:null#lmao'); $tpl->register(Opt_Class::PHP_CLASS, 'class', '_class'); $tpl->register(Opt_Class::PHP_CLASS, 'e', 'e'); $tpl->register(Opt_Class::PHP_CLASS, 'u', 'u'); $tpl->register(Opt_Class::PHP_CLASS, 'a', 'a'); Opl_Registry::register('opl_translate', new tl()); $tpl->setup(); $this->tpl = $tpl; $this->cpl = new Opt_Compiler_Class($tpl); }
/** * Creates the new translation object. * * @param Opc_Translate_Adapter $adapter The default translation adapter. */ public function __construct(Opc_Translate_Adapter $adapter) { if (!Opl_Registry::exists('opc')) { throw new Opc_ClassInstanceNotExists_Exception(); } $this->_opc = Opl_Registry::get('opc'); $this->_defaultLanguage = $this->_opc->defaultLanugage; $this->_defaultAdapter = $adapter; }
/** * Returns the main OPL library class that threw the exception. * * @return Opl_Class The main class of the exception library. */ public function getLibrary() { $name = explode('_', get_class_name($this)); $name = strtolower($name[0]); if (Opl_Registry::exists($name)) { return Opl_Registry::get($name); } return null; }
/** * The informator that prints the basic OPT configuration to the error * output. * * @param Opc_Exception $exception The exception */ protected function _printBasicConfiguration($exception) { if (!Opl_Registry::exists('opc')) { return false; } $opc = Opl_Registry::get('opc'); echo '<p class="directive">Caching directory: <span>' . htmlspecialchars($opc->cacheDir) . "</span></p>\r\n"; echo '<p class="directive">Caching expiry time: <span>' . htmlspecialchars($opc->expiryTime) . "</span></p>\r\n"; }
/** * @covers Opf_Class::setTranslationInterface * @covers Opf_Class::getTranslationInterface */ public function testSettingTranslationInterface() { Opl_Registry::register('opt', $this->_optMock); $opf = new Opf_Class(); $this->assertEquals(null, $opf->getTranslationInterface()); $opf->setTranslationInterface($mock = $this->getMock('Opl_Translation_Interface')); $this->assertSame($mock, $opf->getTranslationInterface()); $opf->setTranslationInterface(null); $this->assertEquals(null, $opf->getTranslationInterface()); }
/** * @covers Opt_Class::setup */ public function testSetupEnablesDebugMode() { $this->_tpl->sourceDir = 'php://memory'; $this->_tpl->compileDir = 'php://memory'; $this->_tpl->debugConsole = false; Opl_Registry::setState('opl_debug_console', true); $this->_tpl->setup(); $this->assertTrue($this->_tpl->debugConsole); $this->_tpl->debugConsole = false; Opl_Registry::setState('opl_debug_console', false); }
/** * Processes the opt:form XML node. * * @param Opt_Xml_Node $node The recognized node. */ public function _processForm(Opt_Xml_Node $node) { $this->_nesting++; $params = array('name' => array(0 => self::OPTIONAL, self::EXPRESSION, null), 'from' => array(0 => self::OPTIONAL, self::EXPRESSION, null), '__UNKNOWN__' => array(0 => self::OPTIONAL, self::STRING)); $extra = $this->_extractAttributes($node, $params); if (!isset($params['name']) && !isset($params['from']) || isset($params['name']) && isset($params['from'])) { throw new Opf_Exception('Attributes "name" or "from" are not defined.'); } $attr = 'array(\'method\' => $_form->getMethod(), \'action\' => $_form->getAction(), \'class\' => Opf_Design::getClass(\'form\', $_form->isValid()), '; foreach ($extra as $name => $value) { $attr .= ' \'' . $name . '\' => ' . $value . ','; } $attr .= ')'; $opf = Opl_Registry::get('opf'); $node->addAfter(Opt_Xml_Buffer::TAG_BEFORE, 'if(($_formy = Opf_Form::topOfStack()) === null) { if(Opf_Class::hasForm(' . $params['name'] . ')) { $_formx = Opf_Class::getForm(' . $params['name'] . '); $_form = $_formx->fluent(); Opf_Form::pushToStack($_form); echo \'<form \'.Opt_Function::buildAttributes(' . $attr . ').\'>\'; } } else { $_formx = ' . (isset($params['from']) ? $params['from'] : '$_formy->getItemDisplay(' . $params['name'] . ')') . '; $_form = $_formx->fluent(); if(!$_form instanceof Opf_Form) { throw new Opf_Exception(\'Invalid form object type(\'.get_class($_formx).\'), should be Opf_Form\'); } Opf_Form::pushToStack($_form); } if(isset($_form)) { foreach($_formx->getInternals() as $n => $v){ echo \'<input type="hidden" name="' . $opf->formInternalId . '[\'.$n.\']" value="\'.htmlspecialchars($v).\'" />\'; } self::$_vars[\'form\'] = $_form; '); $node->addBefore(Opt_Xml_Buffer::TAG_AFTER, ' Opf_Form::popFromStack($_form); if((self::$_vars[\'form\'] = $_form = Opf_Form::topOfStack()) === null) { echo \'</form>\'; } }'); self::_setProcessedForm($params['name']); $this->_compiler->setConversion('##component', '$_form->_widgetFactory(\'%CLASS%\', \'%TAG%\', %ATTRIBUTES%)'); $node->set('postprocess', true); $this->_process($node); }
/** * Creates the adapter and applies the options. * * @param array $options The adapter options. */ public function __construct(array $options = array()) { if (!Opl_Registry::exists('opc')) { throw new Opc_ClassInstanceNotExists_Exception(); } $this->_opc = Opl_Registry::get('opc'); if (isset($options['directory'])) { $this->setDirectory($options['directory']); } if (isset($options['fileExistsCheck'])) { $this->_fileExistsCheck = (bool) $options['fileExistsCheck']; } }
/** * Sets the compiler instance. * * @param Opt_Compiler_Class $compiler The compiler object */ public function setCompiler(Opt_Compiler_Class $compiler) { $this->_compiler = $compiler; $this->_tpl = Opl_Registry::get('opt'); if ($this->_tpl->unicodeNames) { // Register unicode name regular expressions $this->_rOpeningChar = '(\\p{Lu}|\\p{Ll}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Nl}|\\_|\\:)'; $this->_rNameChar = '(\\p{Lu}|\\p{Ll}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Nl}|\\p{Mc}|\\p{Me}|\\p{Mn}|\\p{Lm}|\\p{Nd}|\\_|\\:|\\.|\\-)'; $this->_rModifiers = 'msiu'; } // Register the rest of the expressions $this->_rNameExpression = '/(' . $this->_rOpeningChar . '?' . $this->_rNameChar . '*)/' . $this->_rModifiers; $this->_rXmlTagExpression = '/(\\<((\\/)?(' . $this->_rOpeningChar . '?' . $this->_rNameChar . '*)( [^\\<\\>]*)?(\\/)?)\\>)/' . $this->_rModifiers; $this->_rTagExpandExpression = '/^(\\/)?(' . $this->_rOpeningChar . '?' . $this->_rNameChar . '*)( [^\\<\\>]*)?(\\/)?$/' . $this->_rModifiers; $this->_rQuirksTagExpression = '/(\\<((\\/)?((' . implode('|', $this->_tpl->_getList('_namespaces')) . ')\\:' . $this->_rNameChar . '*)( [^\\<\\>]+)?(\\/)?)\\>)/' . $this->_rModifiers; }
/** * Creates a new instance of OPF. * * @param Opt_Class $opt Open Power Template instance. */ public function __construct(Opt_Class $opt) { Opl_Registry::set('opf', $this); $opt->register(Opt_Class::OPT_NAMESPACE, 'opf'); $opt->register(Opt_Class::OPT_INSTRUCTION, 'Form', 'Opf_View_Instruction_Form'); $opt->register(Opt_Class::OPT_FORMAT, 'Form', 'Opf_View_Format_Form'); $opt->register(Opt_Class::OPT_FORMAT, 'Design', 'Opf_View_Format_Design'); $opt->register(Opt_Class::OPT_FORMAT, 'FormRepeater', 'Opf_View_Format_FormRepeater'); $opt->register(Opt_Class::OPT_COMPONENT, 'opf:input', 'Opf_Widget_Input'); $opt->register(Opt_Class::OPT_COMPONENT, 'opf:textarea', 'Opf_Widget_Textarea'); $opt->register(Opt_Class::OPT_COMPONENT, 'opf:password', 'Opf_Widget_Password'); $opt->register(Opt_Class::OPT_COMPONENT, 'opf:yesno', 'Opf_Widget_Yesno'); $opt->register(Opt_Class::OPT_COMPONENT, 'opf:select', 'Opf_Widget_Select'); $opt->register(Opt_Class::OPT_COMPONENT, 'opf:collection', 'Opf_Widget_Collection'); Opt_View::setFormatGlobal('design', 'Design', false); }
/** * TODO: To be documented. * * @param <type> $name * @return <type> */ public function display(Exception $exception) { $debug = false; if (Opl_Registry::getValue('opl_extended_errors')) { $debug = true; } $out = Opl_Registry::get('stdout'); // Match the port to the exception. foreach ($this->_ports as $port) { if ($port->match($exception)) { $libraryName = $port->getName(); if ($debug === true) { $context = $port->getContext($exception); } break; } } if (!isset($libraryName)) { return false; } $out->writeLine('= ' . $libraryName . ' ='); $out->writeLine('MESSAGE: ' . $exception->getMessage()); $out->writeLine('CODE: ' . get_class($exception)); if ($debug) { $out->writeLine('FILE: ' . $exception->getFile() . ' [LINE ' . $exception->getLine() . ']'); } else { $out->writeLine('Debug mode is disabled. No additional information provided.'); } if ($debug) { foreach ($context as $name => $params) { $informer = $this->getInformer($name); if ($informer !== null) { $informer->display($exception, $params); } else { $out->writeLine('Unknown informer: ' . $name); } } } return true; }
/** * Sets the compiler instance in the expression parser. * * @param Opt_Compiler_Class $compiler The compiler object */ public function setCompiler(Opt_Compiler_Class $compiler) { $this->_compiler = $compiler; $this->_manager = $compiler->getCdfManager(); $this->_tpl = Opl_Registry::get('opt'); $this->_tf = $this->_tpl->getTranslationInterface(); }
/** * Formats the input number to look nice in the text. If the extra arguments * are not present, they are taken from OPT configuration. * * @param Number $number The input number * @param Integer $d1 The number of decimals * @param String $d2 The decimal separator * @param String $d3 The thousand separator * @return String */ public static function number($number, $d1 = null, $d2 = null, $d3 = null) { if (self::isContainer($number)) { return self::processContainer(array('Opt_Function', 'number'), array($number, $d1, $d2, $d3)); } $opt = Opl_Registry::get('opt'); $d1 = $d1 === null ? $opt->numberDecimals : $d1; $d2 = $d2 === null ? $opt->numberDecPoint : $d2; $d3 = $d3 === null ? $opt->numberThousandSep : $d3; return number_format($number, $d1, $d2, $d3); }
/** * Creates a new view object. The optional argument, $template * may specify the template to be associated with this view. * Please note that if you do not specify the template here, * you have to do this manually later using Opt_View::setTemplate() * method. * * @param string $template The template file. */ public function __construct($template = '') { $this->_tpl = Opl_Registry::get('opt'); $this->_template = (string) $template; $this->_parser = $this->_tpl->parser; $this->_cache = $this->_tpl->getCache(); }
/** * The interface method of Opt_Caching_Interface. Finalizes * the caching of the view. * * @param Opt_View $view The cached view. */ public function templateCacheStop(Opt_View $view) { $header = array('timestamp' => time(), 'expire' => $this->getExpiryTime(), 'dynamic' => $view->hasDynamicContent() ? 'true' : 'false'); $header = '<' . '?php /* ' . serialize($header) . '*/ ?>' . "\n"; $tpl = Opl_Registry::get('opt'); $tpl->setBufferState('cache', false); if ($view->hasDynamicContent()) { $buffer = $view->getOutputBuffers(); $dyn = file_get_contents($tpl->compileDir . $view->_convert($view->getTemplate()) . '.dyn'); if ($dyn !== false) { $dynamic = unserialize($dyn); unset($dyn); } else { throw new Opc_View_Cache_InvalidDynamicContent_Exception($view->getTemplate()); return false; } $content = ''; for ($i = 0, $endI = count($buffer); $i < $endI; $i++) { $content .= $buffer[$i]; $content .= $dynamic[$i]; } if (file_put_contents($this->getDirectory() . $this->_getFilename($view), $header . $content . ob_get_flush()) === false) { throw new Opc_View_Cache_CannotSaveFile_Exception($this->getDirectory()); return false; } } else { if (file_put_contents($this->getDirectory() . $this->_getFileName($view), $header . ob_get_contents()) === false) { throw new Opc_View_Cache_CannotSaveFile_Exception($this->getDirectory()); return false; } } }
/** * The constructor that creates the new HTTP output object. */ public function __construct() { $this->_tpl = Opl_Registry::get('opt'); }
/** * Links the element attributes into a valid XML code and returns * the output code. * * @internal * @param Opt_Xml_Element $subitem The XML element. * @return String */ protected function _linkAttributes() { // Links the attributes into the PHP code if ($this->hasAttributes() || $this->bufferSize(Opt_Xml_Buffer::TAG_BEGINNING_ATTRIBUTES) > 0 || $this->bufferSize(Opt_Xml_Buffer::TAG_ENDING_ATTRIBUTES) > 0) { $code = $this->buildCode(Opt_Xml_Buffer::TAG_ATTRIBUTES_BEFORE, Opt_Xml_Buffer::TAG_BEGINNING_ATTRIBUTES); $attrList = $this->getAttributes(); // Link attributes into a string foreach ($attrList as $attribute) { $s = $attribute->bufferSize(Opt_Xml_Buffer::ATTRIBUTE_NAME); switch ($s) { case 0: $code .= $attribute->buildCode(Opt_Xml_Buffer::ATTRIBUTE_BEGIN) . ' ' . $attribute->getXmlName(); break; case 1: $code .= ($attribute->bufferSize(Opt_Xml_Buffer::ATTRIBUTE_BEGIN) == 0 ? ' ' : '') . $attribute->buildCode(Opt_Xml_Buffer::ATTRIBUTE_BEGIN, ' ', Opt_Xml_Buffer::ATTRIBUTE_NAME); break; default: throw new Opt_CompilerCodeBufferConflict_Exception(1, 'ATTRIBUTE_NAME', $this->getXmlName()); } if ($attribute->bufferSize(Opt_Xml_Buffer::ATTRIBUTE_VALUE) == 0) { // Static value $tpl = Opl_Registry::get('opt'); if (!($tpl->htmlAttributes && $attribute->getValue() == $attribute->getName())) { $code .= '="' . htmlspecialchars($attribute->getValue()) . '"'; } } else { $code .= '="' . $attribute->buildCode(Opt_Xml_Buffer::ATTRIBUTE_VALUE) . '"'; } $code .= $attribute->buildCode(Opt_Xml_Buffer::ATTRIBUTE_END); } return $code . $this->buildCode(Opt_Xml_Buffer::TAG_ENDING_ATTRIBUTES, Opt_Xml_Buffer::TAG_ATTRIBUTES_AFTER); } return ''; }
<?php // OPL Initialization $config = parse_ini_file('../paths.ini', true); require $config['libraries']['Opl'] . 'Base.php'; Opl_Loader::loadPaths($config); Opl_Loader::setCheckFileExists(false); Opl_Loader::register(); Opl_Registry::setState('opl_debug_console', false); Opl_Registry::setState('opl_extended_errors', true); try { Opl_Loader::setHandleUnknownLibraries(false); $viewSettings = array('sourceDir' => './templates/', 'compileDir' => './templates_c/', 'prologRequired' => true, 'stripWhitespaces' => false, 'gzipCompression' => true, 'contentType' => 0, 'charset' => 'utf-8'); $tpl = new Opt_Class(); $tpl->setup($viewSettings); $opc = new Opc_Class(); $viewCacheOptions = array('cacheDir' => './cache/', 'expiryTime' => 120, 'key' => null); $viewCache = new Opc_View_Cache($viewCacheOptions); $tpl->setCache($viewCache); $view = new Opt_View('caching_test_dynamic.tpl'); $view->pagetitle = 'Caching system test'; $view->dynamic = 'Dynamic3'; $out = new Opt_Output_Http(); $out->setContentType(); $out->render($view); } catch (Opc_Exception $exception) { $handler = new Opc_ErrorHandler(); $handler->display($exception); }
<?php // OPL Initialization error_reporting(E_ALL | E_DEPRECATED); $config = parse_ini_file('../paths.ini', true); require $config['libraries']['Opl'] . 'Base.php'; Opl_Loader::loadPaths($config); // Opl_Loader::setCheckFileExists(true); Opl_Loader::register(); // Opl_Registry::setValue('opl_debug_console', true); Opl_Registry::setValue('opl_extended_errors', true); function profile($dump = false) { $trace = debug_backtrace(); array_pop($trace); $k = reset($trace); Opl_Debug::writeErr($k['function'] . ',' . $k['file'] . ',' . $k['line']); } // end profile();
/** * Displays an exception error message. The returned value reports * if the error handler managed to handle the exception. * * @param Exception $exception The exception to be displayed. * @return boolean */ public function display(Exception $exception) { $debug = false; if (Opl_Registry::getValue('opl_extended_errors')) { $debug = true; } // Match the port to the exception. foreach ($this->_ports as $port) { if ($port->match($exception)) { $libraryName = $port->getName(); if ($debug === true) { $context = $port->getContext($exception); } break; } } if (!isset($libraryName)) { return false; } // Display the error. if (ob_get_level() > 0) { ob_end_clean(); } echo <<<EOF <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>{$libraryName} error</title> <style type="text/css"> /* <![CDATA[ */ html, body{ margin: 0; padding: 0; font-size: 10pt; background: #ffffff; } div#oplErrorFrame { font-family: Arial, Verdana, Tahoma, Helvetica, sans-serif; color: #222222; width: 700px; margin-top: 100px; margin-left: auto; margin-right: auto; padding: 2px; } div#oplErrorFrame h1{ font-size: 16pt; text-align: center; padding: 10px; margin: 2px 0; background: #ffffff; border-top: 4px solid #e60066; } div#oplErrorFrame div.object{ border: 1px solid #ffdecc; margin: 2px 0;background: #ffeeee; padding: 0; } div#oplErrorFrame div.object div{ /*border-left: 15px solid #e33a3a;*/ margin: 0; padding: 1px; } div#oplErrorFrame p{padding: 5px; margin: 5px 0;} div#oplErrorFrame p.message { font-size: 13pt; } div#oplErrorFrame p.code{ font-weight: bold; } div#oplErrorFrame p span{ margin-right: 6px; } div#oplErrorFrame p.call{ border-top: 1px solid #e33a3a; margin: 5px; padding: 5px 0; } div#oplErrorFrame p.call span{ float: none; margin-right: 0; font-family: 'Courier New', Courier, monospaced; font-size: 12px; } div#oplErrorFrame p.directive span{ font-weight: bold; } div#oplErrorFrame p.directive span.good{ color: #009900; } div#oplErrorFrame p.directive span.maybe{ color: #777700; } div#oplErrorFrame p.directive span.bad{ color: #770000; } div#oplErrorFrame p.important{ font-weight: bold; text-align: center; width:100%; } div#oplErrorFrame p.warning span{\tfloat: left; margin-right: 12px; font-weight: bold; } div#oplErrorFrame a {font-weight: bold; color: #000000} div#oplErrorFrame a:hover {} div#oplErrorFrame ul {list-style: none; margin: 5px 15px; padding: 0} div#oplErrorFrame ul li {margin: 0; padding: 0} div#oplErrorFrame ul li p {padding:0;} div#oplErrorFrame li { margin-top: 2px; margin-bottom: 2px; padding: 0; } div#oplErrorFrame li.value { font-weight: bold; } div#oplErrorFrame li span{ margin-right: 6px; } div#oplErrorFrame li.value span.good{ color: #009900; } div#oplErrorFrame li.value span.maybe{ color: #777700; } div#oplErrorFrame li.value span.bad{ color: #770000; } div#oplErrorFrame code{ font-family: 'Courier New', Courier, monospaced; background: #ffdddd; } /* ]]> */ </style> </head> <body> <div id="oplErrorFrame"> <h1>{$libraryName} error</h1> <div class="object"><div> EOF; echo ' <p class="message">' . htmlspecialchars($exception->getMessage()) . "</p>\r\n"; echo ' <p class="code">' . get_class($exception) . "</p>\r\n"; if ($debug) { echo ' <p class="call"><span>' . $exception->getFile() . '</span> [<span>' . $exception->getLine() . "</span>]</p>\r\n"; } else { echo " \t\t\t<p class=\"call\">Debug mode is disabled. No additional information provided.</p>\r\n"; } echo " \t\t</div></div>\r\n"; if ($debug) { echo "\t\t\t<div class=\"object\"><div>\r\n"; foreach ($context as $name => $params) { $informer = $this->getInformer($name); if ($informer !== null) { $informer->display($exception, $params); } else { echo "\t\t<p class=\"directive\"><strong>Unknown informer:</strong> " . $name . "</p>\r\n"; } } echo " \t\t</div></div>\r\n"; } echo <<<EOF </div> </body> </html> EOF; return true; }
/** * Creates a new instruction processor for the specified compiler. * * @param Opt_Compiler_Class $compiler The compiler object. */ public function __construct(Opt_Compiler_Class $compiler) { $this->_compiler = $compiler; $this->_tpl = Opl_Registry::get('opt'); $this->configure(); }
/** * Executes the form. The result is the overall result of the * form processing process. * * @return boolean */ public function execute() { $this->_executed = true; $opf = Opl_Registry::get('opf'); $this->invokeEvent('preInit'); $this->onInit(); $this->invokeEvent('postInit'); // Validate the input data. $data = $this->_retrieveData(); // Decide, if the form has been sent to us. if ($_SERVER['REQUEST_METHOD'] == $this->_method && isset($data[$opf->formInternalId])) { // Get the internal data and remove them from the "official" scope. $internals = $data[$opf->formInternalId]; unset($data[$opf->formInternalId]); // The names must match. if (isset($internals['name']) && $internals['name'] == $this->_name) { // The form has been sent! $state = $this->_validate($data); if (!$state) { $this->_state = self::ERROR; return $this->_state; } $this->_data = $data; $this->_state = self::ACCEPTED; $this->invokeEvent('preAccept'); $this->onAccept(); $this->invokeEvent('postAccept'); $this->clear(); return $this->_state; } } $this->_state = self::RENDER; return $this->_state; }
function modifyVariable($item, $value) { $data = Opl_Registry::get('data'); $data[$item] = $value; Opl_Registry::register('data', $data); }
/** * @covers Opc_View_Cache::__construct */ public function testConstructException() { Opl_Registry::register('opc', null); $this->setExpectedException('Opc_ClassInstanceNotExists_Exception'); $viewCache = new Opc_View_Cache(array('key' => 'bar', 'cacheDir' => './cache', 'expiryTime' => 100)); }
/** * Displays the help. */ public function showHelp() { $stdout = Opl_Registry::get('stdout'); $stdout->writeLine('Help'); foreach (self::$_actions as $action) { $stdout->writeLine($action->getName() . ' - ' . $action->getDescription()); } }
/** * Finalizes everything. */ protected function tearDown() { Opl_Registry::register('opt', null); Opt_View::clear(); unset($this->tpl); }
/** * Creates new paginator. * * @param integer $all The amout of all items * @param integer $limit Items per page * @return void */ public function __construct($all = null, $limit = null) { if (!Opl_Registry::exists('opc')) { throw new Opc_ClassInstanceNotExists_Exception(); } $opc = Opl_Registry::get('opc'); if (is_null($limit)) { $limit = $opc->itemsPerPage; } if (!is_null($opc->paginatorDecorator)) { $this->set('decorator', $opc->paginatorDecorator); } if (is_array($opc->paginatorDecoratorOptions)) { $this->decorator->loadConfig($opc->paginatorDecoratorOptions); } $this->set('all', $all); $this->set('limit', $limit); }
/** * Generates a help from the available options. * * @param Opl_Console_Stream $stdout The output stream used for rendering. */ public function printHelp() { $stdout = Opl_Registry::get('stdout'); $stdout->writeLine('Help'); foreach ($this->_availableOpts as $option) { $stdout->writeLine('-' . $option->getShortFlag() . ($option->getArgument() !== null ? ' ...' : '') . '/--' . $option->getLongFlag() . ($option->getArgument() !== null ? '=...' : '') . ' - ' . $option->getHelp()); } }