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();
 }
 /**
  * @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();
 }
Example #3
0
 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";
     }
 }
Example #4
0
 /**
  * @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);
 }
 /**
  * @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();
 }
 /**
  * (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();
 }
Example #7
0
 /**
  * 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();
 }
Example #10
0
 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;
 }
Example #11
0
 /**
  * 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() . "]");
     }
 }
Example #12
0
 public function renderSlider()
 {
     $sliderView = new Renderer();
     $sliderView->render($this->imgArr);
 }
Example #13
0
 /**
  * Renders the HTML to PDF
  */
 function render()
 {
     $this->_process_html();
     $this->_css->apply_styles($this->_tree);
     $root = null;
     foreach ($this->_tree->get_frames() as $frame) {
         // Set up the root frame
         if (is_null($root)) {
             $root = Frame_Factory::decorate_root($this->_tree->get_root());
             continue;
         }
         // Create the appropriate decorators, reflowers & positioners.
         $deco = Frame_Factory::decorate_frame($frame, $this);
         $deco->set_root($root);
         // FIXME: handle generated content
         if ($frame->get_style()->display == "list-item" && in_array($frame->get_style()->list_style_type, List_Bullet_Frame_Decorator::$BULLET_TYPES)) {
             // Insert a list-bullet frame
             $node = $this->_xml->createElement("bullet");
             // arbitrary choice
             $b_f = new Frame($node);
             $style = $this->_css->create_style();
             $style->display = "-dompdf-list-bullet";
             $style->inherit($frame->get_style());
             $b_f->set_style($style);
             $deco->prepend_child(Frame_Factory::decorate_frame($b_f));
         }
     }
     $this->_pdf = Canvas_Factory::get_instance($this->_paper_size, $this->_orientation);
     $root->set_containing_block(0, 0, $this->_pdf->get_width(), $this->_pdf->get_height());
     // This is where the magic happens:
     $root->reflow();
     $renderer = new Renderer($this->_pdf);
     $renderer->render($root);
 }
Example #14
0
 /**
  * @param null|string $controllerName
  * @param null|string $actionName 
  * @return void
  * @throws RuntimeException
  */
 public function dispatch($controllerName = null, $actionName = null)
 {
     if ($this->isUrlRewritingEnabled && $this->router instanceof Router) {
         $this->getRouter()->route($this);
     } else {
         if ($this->isUrlRewritingEnabled) {
             $this->parseUrl();
         } else {
             $this->parseQueryString();
         }
     }
     $controllerName = isset($controllerName) ? $controllerName : $this->getController();
     $actionName = isset($actionName) ? $actionName : $this->getAction();
     $response = $this->handleRequest($controllerName, $actionName);
     $this->setResponse($response);
     $renderer = new Renderer();
     $renderer->render($this);
 }
Example #15
0
 /**
  * Renders the pagination.
  *
  * @param string $renderer The pagination renderer to use.
  * @param array  $options  Additional options. Optional.
  */
 public function render($renderer = null, $options = null)
 {
     $renderer = new Renderer($renderer, $options, $this);
     return $renderer->render();
 }
 /**
  * Artikel aus dem Warenkorb auslesen
  *
  * @param array [$hParams] Parameter fuer bbShopping::readCart
  * @return array
  */
 public static function getCart($hParams = array())
 {
     $bReturnCartOrder = false;
     if (array_key_exists('return_shop_cart_order', $hParams)) {
         $bReturnCartOrder = $hParams['return_shop_cart_order'];
         unset($hParams['return_shop_cart_order']);
     }
     $cart = shopShopping::getCartData($hParams);
     // Alle Artikel der abgefragten Produkttyps auslesen
     $hTypeItems = null;
     if (array_key_exists('return_norms', $hParams) && count($hParams['return_norms'])) {
         $hTypeItems = shopShopping::readStore(array('norm' => $hParams['return_norms'], 'return_array' => 1, 'return_orderable' => 1));
     }
     $hAssigns = array('count' => $cart['item_count'], 'items' => $cart['items'], 'norms' => $hTypeItems);
     Renderer::assign('cart', $cart);
     if ($bReturnCartOrder) {
         $sTemplate = Renderer::render('modules/order_cart_sidebar.tpl');
         // Haupt-Darstellung rendern
         $ahIntervals = shopProduct::readInterval(array('return_shopformat' => 1));
         $ahIntervals[0] = 'einmalig';
         $ahIntervals['descr'][0] = 'einmalig';
         Renderer::assign('interval', $ahIntervals);
         Renderer::assign('cart', $cart);
         Renderer::assign('cart_editable', true);
         $hAssigns['overview'] = Renderer::render('modules/cart_articles.tpl');
     } else {
         $sTemplate = Renderer::render('modules/cart_nav.tpl');
     }
     // Template rendern und Daten zurueck geben
     return array('template' => $sTemplate, 'assigns' => $hAssigns);
 }
 /**
  * Function generates password recovery email message content
  * May be used in the following way:
  * <pre>
  * $this->getMailContent(array(
  *     'user_name'=>'John Doe',
  *     'link'=>$this->getPasswordRecoveryLink($user)
  * ));
  * </pre>
  * 
  * @author Aleh Hutnikau <*****@*****.**>
  * @param array $messageData
  * @return string Message content
  */
 private function getMailContent($messageData)
 {
     $renderer = new \Renderer();
     $renderer->setTemplate(Template::getTemplate('passwordRecovery/password-recovery-message.tpl', 'tao'));
     foreach ($messageData as $key => $value) {
         $renderer->setData($key, $value);
     }
     return $renderer->render();
 }
Example #18
0
 private function renderContent()
 {
     if (common::LoggedIn()) {
         if ($this->settings['wysiwygEnabled']) {
             global $addonPathCode, $page;
             require_once $addonPathCode . "/Renderer.php";
             $renderer = new Renderer($this->settings, $addonPathCode . "/lib/parsedown");
             print $renderer->render($_REQUEST['content']);
             //haha, very secure. NOT!
             $nonce_str = 'EasyMark4Life!';
             //TODO: sanitize $config stuff
             //"getPostResponseEasyMark" is defined in edit.js
             print "<script>";
             print "var postNonce = '" . common::new_nonce('post', true) . "';";
             print "setTimeout(gp_editor.getPostResponseEasyMark, " . htmlspecialchars($this->settings['wysiwygDelay']) . "*1000);";
             print "</script>";
             // cleanup old page object
             unset($page);
         }
     } else {
         print "Have to be logged in to use this feature";
     }
 }
Example #19
0
 /**
  * Render a themable template identified by its id
  * 
  * @param string $templateId
  * @param array $data
  * @return string
  */
 public static function renderThemeTemplate($target, $templateId, $data = array())
 {
     //search in the registry to get the custom template to render
     $tpl = self::getThemeTemplate($target, $templateId);
     if (!is_null($tpl)) {
         //render the template
         $renderer = new \Renderer($tpl, $data);
         return $renderer->render();
     }
     return '';
 }
Example #20
0
namespace Boyhagemann\Html;

require_once 'config.php';
$builder = new Builder();
$builder->instance('table')->append('tr')->appendMany('td', 5, function ($td) {
    $td->text('Test');
});
$builder->instance('table')->prepend('thead', function ($thead) {
    $thead->append('td')->text('Title');
    $thead->append('td')->text('Body');
    $thead->append('td')->text('Test 3');
    $thead->append('td')->text('Test 4');
    $thead->append('td')->text('Test 5');
});
$renderer = new Renderer();
$html = $renderer->render($builder->resolve('table'));
?>


<html>
	<head>
		<style>
			table {
				margin: 20px 0;
			}
			table tr td {
				padding: 15px;
			}
		</style>
	</head>
	<body>
 /**
  * (non-PHPdoc)
  * @see Renderer::render()
  */
 public function render()
 {
     return parent::render();
 }
Example #22
0
 public function render(Renderer $renderer, $view)
 {
     /* Set values */
     foreach ($this->dataContainer as $name => $value) {
         $renderer->set($name, $value);
     }
     /* Set value arrays */
     foreach ($this->arrayContainer as $array) {
         $renderer->setValueArray($array);
     }
     /* Set objects */
     foreach ($this->objectContainer as $name => $object) {
         $renderer->setObject($name, $object);
     }
     /* Render */
     try {
         return $renderer->render($view);
     } catch (ViewNotFoundException $ex) {
         throw $ex;
     }
 }
 public function execute()
 {
     $module = $this->context->getModuleName();
     $action = $this->context->getActionName();
     // if module exist include the class
     if ($module !== null) {
         //    		//check if there is a specified context first
         //			$isSpecificContext = false;
         //    		if(count($this->context->getSpecifiers()) > 0){
         //				foreach($this->context->getSpecifiers() as $specifier){
         //
         //					$expectedPath = DIR_ACTIONS . $specifier . '/class.' . $module . '.php';
         //
         //					//if we find the view in the specialized context, we load it
         //					if (file_exists($expectedPath)){
         //						require_once ($expectedPath);
         //						$isSpecificContext = true;
         //						break;
         //					}
         //				}
         //			}
         //
         //			//if there is none, we look at the global context
         //			if(!$isSpecificContext){
         $exptectedPath = DIR_ACTIONS . 'class.' . $module . '.php';
         if (file_exists($exptectedPath)) {
             require_once $exptectedPath;
         } else {
             throw new ActionEnforcingException("Module '" . Camelizer::firstToUpper($module) . "' does not exist in {$exptectedPath}.", $this->context->getModuleName(), $this->context->getActionName());
         }
         //			}
         if (defined('ROOT_PATH')) {
             $root = realpath(ROOT_PATH);
         } else {
             $root = realpath($_SERVER['DOCUMENT_ROOT']);
         }
         if (preg_match("/^\\//", $root) && !preg_match("/\\/\$/", $root)) {
             $root .= '/';
         } else {
             if (!preg_match("/\\\$/", $root)) {
                 $root .= '\\';
             }
         }
         $relPath = str_replace($root, '', realpath(dirname($exptectedPath)));
         $relPath = str_replace('/', '_', $relPath);
         $relPath = str_replace('\\', '_', $relPath);
         $className = $relPath . '_' . $module;
         if (!class_exists($className)) {
             throw new ActionEnforcingException("Unable to load  {$className} in {$exptectedPath}", $this->context->getModuleName(), $this->context->getActionName());
         }
         // File gracefully loaded.
         $this->context->setModuleName($module);
         $this->context->setActionName($action);
         $moduleInstance = new $className();
     } else {
         throw new ActionEnforcingException("No Module file matching requested module.", $this->context->getModuleName(), $this->context->getActionName());
     }
     // if the method related to the specified action exists, call it
     if (method_exists($moduleInstance, $action)) {
         // search parameters method
         $reflect = new ReflectionMethod($className, $action);
         $parameters = $reflect->getParameters();
         $tabParam = array();
         foreach ($parameters as $param) {
             $tabParam[$param->getName()] = $this->context->getRequest()->getParameter($param->getName());
         }
         // Action method is invoked, passing request parameters as
         // method parameters.
         common_Logger::d('Invoking ' . get_class($moduleInstance) . '::' . $action, array('GENERIS', 'CLEARRFW'));
         call_user_func_array(array($moduleInstance, $action), $tabParam);
         // Render the view if selected.
         if ($view = $moduleInstance->getView()) {
             $renderer = new Renderer();
             $renderer->render($view);
         }
     } else {
         throw new ActionEnforcingException("Unable to find the appropriate action for Module '{$module}'.", $this->context->getModuleName(), $this->context->getActionName());
     }
 }
Example #24
0
 /**
  * Static method, wrapper for render() method
  *
  * @static
  *
  * @param            $template
  * @param XML\Writer $xmlWriter
  * @param array      $parameters
  *
  * @return string
  */
 public static function run($template, \XSLTemplate\XML\Writer $xmlWriter, array $parameters = array())
 {
     $renderer = new Renderer();
     return $renderer->render($template, $xmlWriter, $parameters);
 }
Example #25
0
 public function testRender()
 {
     $html = Renderer::render('test.html', ['name' => 'php']);
     $this->assertEquals("lang: php\n", $html);
 }
Example #26
0
 /**
  * read() should return true if the load succeeds
  */
 public function testRead_returnsTrue_ifLoadSucceeds()
 {
     $document = new Document();
     $group = (new Element\Group())->appendChild(new Element\Control\Word\B())->appendChild(new Element\Text('foo'))->appendChild((new Element\Control\Word\B(0))->setIsSpaceDelimited(false));
     $renderer = new Renderer();
     $root = $renderer->render($group);
     $this->assertTrue($document->read('{\\b foo\\b0}'));
     $this->assertEquals(3, $document->getRoot()->getLength());
     $this->assertEquals($root, $document->getRoot());
     return;
 }
Example #27
0
                        $renderer->addContent('login.tpl', array('user' => $user, 'error' => 'Uh-oh. Was that the right password? Do you have an account?'));
                    }
                } else {
                    $renderer->addContent('login.tpl', array('user' => $user));
                }
                break;
            case 'about':
                $renderer->setTitle('About');
                $renderer->setKeywords(array('store', 'files', 'upload', 'easy', 'fast', 'anywhere', 'ownership', 'licensing', 'responsibility'));
                $renderer->setDescription('What is stor.me? Why should I use it? What happens when I do use it?');
                $renderer->addContent('about.tpl');
                break;
            default:
                header('Location: ' . WEB_ROOT . '/login');
                exit;
        }
    }
} else {
    if ($hasUser) {
        header('Location: ' . WEB_ROOT . '/files');
        exit;
    } else {
        $renderer->setNav('nav/index.tpl');
        $renderer->setTitle('Put your stuff here');
        $renderer->setKeywords(array('store', 'files', 'upload', 'easy', 'fast', 'anywhere'));
        $renderer->setDescription('Easy, cloud-based storage for your stuff. Any file, any size, anywhere.');
        $renderer->addContent('index.tpl');
    }
}
$renderer->render();
Example #28
0
 /**
  * Creates the document
  *
  * If the stream has no tokens, I'll clear the document's root.
  *
  * @param  Jstewmc\Chunker\Chunker  $chunker  the document's file or text chunker
  * @return  bool
  */
 protected function create(\Jstewmc\Chunker\Chunker $chunker)
 {
     // create the document's stream
     $stream = new \Jstewmc\Stream\Stream($chunker);
     // lex the string into tokens
     $lexer = new Lexer();
     $tokens = $lexer->lex($stream);
     // if tokens exist
     if (!empty($tokens)) {
         // parse the tokens into the parse tree's root group
         $parser = new Parser();
         $group = $parser->parse($tokens);
         // if a root exists
         if ($group !== null) {
             // render the parse tree's root into the document root
             $renderer = new Renderer();
             $this->root = $renderer->render($group);
         } else {
             $this->root = null;
         }
     } else {
         $this->root = null;
     }
     return (bool) $this->root;
 }
Example #29
0
 /**
  * write() should return a string if format is text
  */
 public function testWrite_returnsString_ifFormatIsText()
 {
     $group = (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)));
     $renderer = new Renderer();
     $root = $renderer->render($group);
     $writer = new Writer();
     $expected = 'foo bar';
     $actual = $writer->write($root, 'text');
     $this->assertEquals($expected, $actual);
     return;
 }