/** * @dataProvider renderChangeDataProvider * @param $expectedDiff * @param $oldValue * @param $newValue * @param array|null $renderOptions */ public function testRender_ChangeValueHasStringType($expectedDiff, $oldValue, $newValue, array $renderOptions = null) { $expectedDiff = implode(PHP_EOL, $expectedDiff); $diffRenderer = new Renderer($renderOptions); $actualDiff = $diffRenderer->render(new Change(implode(PHP_EOL, $oldValue), implode(PHP_EOL, $newValue))); $this->assertEquals($expectedDiff, $actualDiff); }
/** * Render request * * @param array $data * @param string|null $template * @param string|null $blockClass * @return $this */ protected function _render(array $data = array(), $template = null, $blockClass = null) { //create block if ($blockClass) { $blockClass = '\\App\\Block' . '\\' . $blockClass; $block = new $blockClass($data); } else { $block = new Renderer($data); } if (!$template) { //set template $template = $this->getControllerName() . DIRECTORY_SEPARATOR . $this->getActionName() . '.phtml'; } $block->setTemplate($template); //get action HTML $actionHtml = $block->toHtml(); if (!$this->isAjax()) { $block = new Renderer(array('content' => $actionHtml)); $block->setTemplate('index.phtml'); //add system messages block $message = new Message(); $message->setTemplate('index/messages.phtml'); $block->setChild('message', $message); echo $block->toHtml(); } else { echo $actionHtml; } return $this; }
public static function getFinishedSniplet() { $taoExt = common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); $tpl = $taoExt->getConstant('DIR_VIEWS') . 'templates' . DIRECTORY_SEPARATOR . 'snippet' . DIRECTORY_SEPARATOR . 'finishService.tpl'; $renderer = new Renderer($tpl); return $renderer->render(); }
public static function getStuff() { $config = self::getConfig(); if (common::LoggedIn()) { if ($config['wysiwygEnabled']) { global $addonPathCode, $page; require_once $addonPathCode . "/Renderer.php"; $renderer = new Renderer($config, $addonPathCode . "/lib/parsedown"); print $renderer->render($_REQUEST['content']); //haha, very secure. NOT! $nonce_str = 'EasyMark4Life!'; //TODO: sanitize $config stuff //"stuff" is defined in edit.js print "<script>"; print "var nonceStr = '" . $nonce_str . "';"; print "var postNonce = '" . common::new_nonce('post', true) . "';"; print "setTimeout(stuff, " . htmlspecialchars($config['wysiwygDelay']) . "*1000);"; print "</script>"; // cleanup old page object unset($page); } } else { print "Have to be logged in to use this feature"; } }
public function renderInit() { $js = $this->renderer->getClientJs(); if ($js) { return '<script>' . $js . '</script>' . PHP_EOL; } return ''; }
/** * @deprecated * @see taoTests_models_classes_TestModel::getAuthoring() */ public function getAuthoring(core_kernel_classes_Resource $test) { $process = $test->getUniquePropertyValue(new core_kernel_classes_Property(TEST_TESTCONTENT_PROP)); $ext = common_ext_ExtensionsManager::singleton()->getExtensionById('taoWfAdvTest'); $widget = new Renderer($ext->getConstant('DIR_VIEWS') . 'templates' . DIRECTORY_SEPARATOR . 'authoring.tpl'); $widget->setData('processUri', $process->getUri()); $widget->setData('label', __('Authoring %s', $test->getLabel())); return $widget->render(); }
/** * @covers \Magento\Checkout\Block\Cart\Item\Renderer::getProductPriceHtml * @covers \Magento\Checkout\Block\Cart\Item\Renderer::getPriceRender */ public function testGetProductPriceHtml() { $priceHtml = 'some price html'; $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock(); $priceRender = $this->getMockBuilder('Magento\\Framework\\Pricing\\Render')->disableOriginalConstructor()->getMock(); $this->layout->expects($this->atLeastOnce())->method('getBlock')->with('product.price.render.default')->will($this->returnValue($priceRender)); $priceRender->expects($this->once())->method('render')->with(\Magento\Catalog\Pricing\Price\ConfiguredPriceInterface::CONFIGURED_PRICE_CODE, $product, ['include_container' => true, 'display_minimal_price' => true, 'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST])->will($this->returnValue($priceHtml)); $this->assertEquals($priceHtml, $this->_renderer->getProductPriceHtml($product)); }
public function Render(Renderer $renderer) { $superGlobals = GetApplication()->GetSuperGlobals(); if ($superGlobals->GetGetValueDef(ModalOperation::Param) == ModalOperation::OpenModalEditDialog || $superGlobals->GetGetValueDef(ModalOperation::Param) == ModalOperation::OpenModalInsertDialog) { $this->grid->GetGrid()->GetPage()->UpdateValuesFromUrl(); } $this->grid->ProcessMessages(); echo $renderer->Render($this->grid); }
/** * (non-PHPdoc) * * @see taoTests_models_classes_TestModel::getAuthoring() */ public function getAuthoring(core_kernel_classes_Resource $content) { common_Logger::i('Generating form for delivery content ' . $content->getUri()); $widget = new Renderer($this->extension->getConstant('DIR_VIEWS') . 'templates' . DIRECTORY_SEPARATOR . 'authoring.tpl'); $form = new taoSimpleDelivery_actions_form_ContentForm($this->getClass(), $content); $widget->setData('formContent', $form->getForm()->render()); $widget->setData('saveUrl', _url('save', 'Authoring', 'taoSimpleDelivery')); $widget->setData('formId', $form->getForm()->getName()); return $widget->render(); }
/** * @deprecated * @see taoTests_models_classes_TestModel::getAuthoring() */ public function getAuthoring(core_kernel_classes_Resource $test) { $ext = common_ext_ExtensionsManager::singleton()->getExtensionById('taoWfTest'); $testService = taoTests_models_classes_TestsService::singleton(); $itemSequence = array(); $itemUris = array(); $i = 1; foreach ($testService->getTestItems($test) as $item) { $itemUris[] = $item->getUri(); $itemSequence[$i] = array('uri' => tao_helpers_Uri::encode($item->getUri()), 'label' => $item->getLabel()); $i++; } // data for item sequence, terrible solution // @todo implement an ajax request for labels or pass from tree to sequence $allItems = array(); foreach ($testService->getAllItems() as $itemUri => $itemLabel) { $allItems['item_' . tao_helpers_Uri::encode($itemUri)] = $itemLabel; } $widget = new Renderer($ext->getConstant('DIR_VIEWS') . 'templates' . DIRECTORY_SEPARATOR . 'authoring.tpl'); $widget->setData('uri', $test->getUri()); $widget->setData('allItems', json_encode($allItems)); $widget->setData('itemSequence', $itemSequence); // data for generis tree form $widget->setData('relatedItems', json_encode(tao_helpers_Uri::encodeArray($itemUris))); $openNodes = tao_models_classes_GenerisTreeFactory::getNodesToOpen($itemUris, new core_kernel_classes_Class(TAO_ITEM_CLASS)); $widget->setData('itemRootNode', TAO_ITEM_CLASS); $widget->setData('itemOpenNodes', $openNodes); $widget->setData('saveUrl', _url('saveItems', 'Authoring', 'taoWfTest')); return $widget->render(); }
/** * render() should recursively render each group */ public function testRender() { $root = (new Element\Group())->appendChild(new Element\Text('foo '))->appendChild((new Element\Group())->appendChild(new Element\Control\Word\B())->appendChild(new Element\Text('bar'))->appendChild(new Element\Control\Word\B(0))); $this->assertFalse($root->getIsRendered()); $renderer = new Renderer(); $root = $renderer->render($root); $this->assertTrue($root instanceof Element\Group); $this->assertTrue($root->getIsRendered()); $this->assertTrue($root->getLastChild()->getChild(1)->getStyle()->getCharacter()->getIsBold()); return; }
function __construct($get) { $this->php_fixes(); // it's easier to handle some redirection through php rather than relying on a more complex .htaccess file to do all the work if ($this->handle_redirects()) { return; } // parse get request $r = new Renderer($get); // handle rendering of the page $r->render(); }
/** * @deprecated * @see taoTests_models_classes_TestModel::getAuthoring() */ public function getAuthoring(core_kernel_classes_Resource $test) { $testService = taoTests_models_classes_TestsService::singleton(); $class = new core_kernel_classes_Class(CLASS_LTI_TESTCONTENT); $content = $test->getOnePropertyValue(new core_kernel_classes_Property(TEST_TESTCONTENT_PROP)); common_Logger::i('Generating form for ' . $content->getUri()); $form = new ltiTestConsumer_actions_form_LtiLinkForm($content); $form->getForm()->setActions(array()); $widget = new Renderer($this->extension->getConstant('DIR_VIEWS') . 'templates' . DIRECTORY_SEPARATOR . 'authoring.tpl'); $widget->setData('formContent', $form->getForm()->render()); $widget->setData('saveUrl', _url('save', 'Authoring', 'ltiTestConsumer')); $widget->setData('formName', $form->getForm()->getName()); return $widget->render(); }
function SectionToContent($section_data) { global $addonPathCode, $addonPathData; if ($section_data['type'] == self::$sectionType) { $config = array(); $conf = $addonPathData . '/config.php'; if (file_exists($conf)) { include $conf; $config = $settings; } require_once $addonPathCode . "/Renderer.php"; $renderer = new Renderer($config, $addonPathCode . "/lib/parsedown/"); $section_data['content'] = $renderer->render($section_data['content']); } return $section_data; }
/** * Sets the FO o HTML transformation StyleSheet. It gets it from the config * file sfExportGlobals.yml in: * step3: {HTML: {xslt_output: sheet: ~}}. * * @see %sf_plugins_dir%/NeatReports/config/sfExportGlobals.yml */ public function __construct() { parent::__construct(); $toHtml = $this->_conf['step3']['HTML']['xslt_output']['sheet']; $toHtml && ($this->_toHtml = simplexml_load_file($this->_pluginDir . $toHtml)); $this->_structure = $this->_toHtml; }
/** * Sets the FO o FO transformation StyleSheet. In case you might want to add * it to the config file sfExportGlobals.yml in * step3: {XSLFO: {xslt_output: sheet: ~}}. * * @see %sf_plugins_dir%/NeatReports/config/sfExportGlobals.yml */ public function __construct() { parent::__construct(); $toFo = $this->_conf['step3']['XSLFO']['xslt_output']['sheet']; $toFo && ($this->_toFo = simplexml_load_file($this->_pluginDir . $toFo)); $this->_structure = $this->_toFo; }
public function __construct() { $this->baseDirectory = 'renders/' . Season::getInstance()->nefub_id . '/' . date('Y') . '_wk' . date('W'); parent::__construct(); if (isset($_GET['clear']) && $_GET['clear'] == 1 && (isset($_GET['clearall']) && $_GET['clearall'] == 1)) { recursive_remove_directory($this->baseDirectory); } }
public function getAdd($parentModel, $relation, $idParentModel) { $parentList = $parentModel::find($idParentModel); $relation = $parentList->{$relation}(); $sonModel = $relation->getRelated(); $sonList = new $sonModel(); $fk = $relation->getForeignKey(); $sonList->{$fk} = $idParentModel; $sonList->save(); $renderer = new Renderer(); if (!($tableParams = Session::get($renderer::PREFIX_SESSION_AJAX_LIST . $_GET["listToken"]))) { $result = "<span>Error al actualizar tabla, por favor, recargue la página</span>"; } else { $result = $renderer->generateAjaxListFromRelation($tableParams[0], $tableParams[1], $tableParams[2], $tableParams[3], $tableParams[4], $tableParams[5]); } return json_encode($result); }
public function testAddGlobal() { $this->assertFalse(isset($globals['test-key'])); Renderer::addGlobal('test-key', 'test-value'); $globals = Renderer::getGlobals(); $this->assertTrue(isset($globals['test-key'])); $this->assertEquals('test-value', $globals['test-key']); }
public function __construct(array $arguments) { parent::__construct(); $this->arguments = $arguments; $this->subject = $arguments[1]; $this->mode = $arguments[2]; $this->editId = $arguments[3]; $this->templateBaseDir = '/beheer'; $this->assign('loggedIn', Account::getLoggedIn()); }
/** * @param \Exception $exception * @throws Exception\ConfigParameterNotFound */ public function renderException(\Exception $exception) { $templatePath = join(DIRECTORY_SEPARATOR, [Renderer::getUserViewDirectory(), 'errors', 'error.php']); if (!file_exists($templatePath)) { $templatePath = join(DIRECTORY_SEPARATOR, [self::VIEW_PATH, 'error.php']); } extract(['exception' => $exception]); $this->sendHeadersWithHttpCode($exception->getCode()); require_once $templatePath; }
/** * This is the "soft" error handler as well as a general "Hey Link!" notifier. * Will cancel execution, wipe the buffer and display a message instead (Eg. "You have watched Username"). * * @param string $msg The message to be displayed * @param string $return An URL. Page will autoredirect (and offer a clickable link) to the url specified. * @return void */ function SysMessage($msg, $return) { require_once $_SERVER['DOCUMENT_ROOT'] . '/sys/Render.php'; // Just incase it hasn't already been included. ob_clean(); // Remove whatever output already present, we won't need it. echo Renderer::GetSysMessageHTML(); //Ask the renderer to render a complete SysMessage HTML template, and output it. exit; // This should boot us directly to FatalErrorHandler which will output everything. }
/** * Document this if implementing. * * @param DOMDocument $xslFo The FO * @param sfWebResponse $response The Response. * * @return string The output * @see Renderer::renderReport() */ public function renderReport(DOMDocument $xslFo, sfWebResponse $response = null) { $out = parent::renderReport($xslFo); self::$_xPath = new DOMXPath($xslFo); $fileName = self::$_xPath->query('//fo:title'); $fileName = 'Report' . (string) $fileName->item(0) . '-' . date('Y-m-d'); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename={$fileName}.xls"); header("Pragma: no-cache"); header("Expires: 0"); return $out; }
/** * @param array $data * @param string $template_file * * @return $this */ public function outputXml($data, $template_file) { $this->outputHeader(); $renderer = $this->renderer->getRenderer(); if (is_array($data) or is_object($data)) { foreach ($data as $k => $v) { $renderer->set($k, $v); } } $xml = $renderer->setTemplate($template_file)->render(); $this->Xml->set(XmlOutput::CONTENT, $xml)->flush(); $this->flushBuffer(); return $this; }
function update($show, $arg) { if ($arg == 'done') { $page = $this->getcurrentPage(); Renderer::getinstance()->setoption('plugin_trackback_pingurlrdf', $this->getpingurlrdf($page)); $list = $this->getlist($page); if (count($list) > 0) { $smarty = $this->getSmarty(); $smarty->assign('pagename', $page->getpagename()); $smarty->assign('trackback', $list); $this->setbody($smarty->fetch('list.tpl.htm')); } } }
/** * Dispatch */ public function run() { $config = Service::get('config'); $request = Service::get('request'); $route = Service::get('router')->find($request->getUrl()); $user = Service::get('user')->getUser(); if (empty($user) & !empty(Cookie::get($config->getVal('remember/cookie_name')))) { $user = Service::get('user'); $user = $user->find(); } if (empty($user)) { if (!in_array($request->getUrl(), array('/login', '/auth', '/gate', '/register', '/reg'))) { $response = new RedirectResponse('/gate'); $response->send(); } } if (!empty($route)) { $controller_class = $route['controller'] . 'Controller'; if (!class_exists($controller_class)) { throw new \Exception("Controller class [" . $route['controller'] . "] doesn't exist"); } $controller = new $controller_class(); if (!method_exists($controller, $route['action'] . 'Action')) { throw new \Exception("Method [" . $route['action'] . "Action ] doesn't exist in [" . $route['controller'] . "]"); } $action = $route['action'] . 'Action'; $response = call_user_func_array(array($controller, $action), $route['params']); if ($response->type == 'html') { $renderer = new Renderer(URL . '/src/template.php'); $renderer->setVars(array('content' => $response->content)); $response->content = $renderer->render(); } $response->send(); } else { throw new \Exception("Wrong route [" . $request->getUrl() . "]"); } }
/** * Create a new Renderer, configuring its template directories * @param string|array $template_dirs A template directory or an array of potential directories */ public function __construct($template_dirs, \Microsite\App $app) { parent::__construct($template_dirs, $app); # # Constructor function. Initialize appropriate member variables. # $this->_initDetab(); $this->prepareItalicsAndBold(); $this->nested_brackets_re = str_repeat('(?>[^\\[\\]]+|\\[', $this->nested_brackets_depth) . str_repeat('\\])*', $this->nested_brackets_depth); $this->nested_url_parenthesis_re = str_repeat('(?>[^()\\s]+|\\(', $this->nested_url_parenthesis_depth) . str_repeat('(?>\\)))*', $this->nested_url_parenthesis_depth); $this->escape_chars_re = '[' . preg_quote($this->escape_chars) . ']'; # Sort document, block, and span gamut in ascendant priority order. asort($this->document_gamut); asort($this->block_gamut); asort($this->span_gamut); }
function route($method, $uri) { if (substr($uri, 0, strlen("/public/")) == "/public/") { // serve static files $this->serve_static($uri); } else { // dynamic content header('Content-Type: text/html; charset=utf-8'); $route = Router::route($method, $uri); if (is_numeric($route) and $route == 404) { echo 404; } else { // if it's in format "controller#action" if (is_string($route)) { Router::extract_params($method, $uri); $parts = explode('#', $route); $controller = $parts[0] . "Controller"; $action = $parts[1]; // create a new controller instance $instance = new $controller(); // inject some config variables $instance->url_prefix = self::$url_prefix; $instance->public_folder = $this->public_folder; // execute before callback $instance->before_action(); $result = $instance->{$action}(); if ($result === null) { // render template echo Renderer::render_view($instance, $parts[0], $action); } else { // render what returned echo $result; } // execute after callback $instance->after_action(); } } } }
public function GetValue(Renderer $renderer) { $result = ''; $primaryKeyValues = array(); ExtractPrimaryKeyValues($primaryKeyValues, METHOD_GET); $this->dataset->SetSingleRecordState($primaryKeyValues); $this->dataset->Open(); if ($this->dataset->Next()) { if ($this->column == null) { } else { $result = $renderer->Render($this->column); } } $this->dataset->Close(); return $result; }
/** * Start a new page by resetting the full flag. */ function next_page() { $this->_floating_frames = array(); $this->_renderer->new_page(); $this->_page_full = false; }