Example #1
0
 /**
  * Generates a printer friendly version of a page
  *
  * @param	string	$content	The HTML content of the page
  * @param	string	$title		The title of the page
  * @param	string	$description	The description of the page
  * @param	string	$pagetitle
  * @param	int		$width		The width of the page, in pixels
  */
 public static function generate($content, $title = FALSE, $description = FALSE, $pagetitle = FALSE, $width = 680)
 {
     $PrintDataBuilder = new self($content, $title, $description);
     $PrintDataBuilder->setPageTitle($pagetitle);
     $PrintDataBuilder->setWidth($width);
     $PrintDataBuilder->render();
 }
Example #2
0
 /**
  *
  * @param unknown_type $template
  * @param unknown_type $data
  * @return string
  */
 protected function includeTemplate($template, $data = null)
 {
     $view = new self();
     $view->setTemplate($template);
     $view->copyAll($data);
     return $view->render();
 }
Example #3
0
 /**
  * Process partial render
  */
 public static function process($nodeList, $template)
 {
     $renderer = new self();
     // @todo: use getInstance() ?
     $renderer->addNodes($nodeList);
     $renderer->setTemplate($template);
     return $renderer->render();
 }
 /**
  * Wrap the content of the current template with the given template file.
  *
  * Esentially, this is clearing the output buffer and refilling it with a wrapped
  * version of what was previously in the output buffer.
  *
  * @param string $file_name
  * @param array  $data
  *
  * @return void
  */
 protected function wrap($file_name, array $data = array())
 {
     $data['wrapped_content'] = ob_get_contents();
     ob_end_clean();
     ob_start();
     $wrapper = new self();
     echo $wrapper->render($file_name, $data);
 }
 public static function metabox_callback($post)
 {
     $listing = WPBDP_Listing::get($post->ID);
     if (!$listing) {
         return '';
     }
     $instance = new self($listing);
     return $instance->render();
 }
Example #6
0
 /**
  * Helper function to render a string of HTML direct to BB code.
  *
  * @param string $html
  * @param array $options
  *
  * @return string BB code
  */
 public static function renderFromHtml($html, array $options = array())
 {
     //echo '<pre>' . htmlspecialchars($html) . '</pre>'; exit;
     $parser = new XenForo_Html_Parser($html);
     $renderer = new self($options);
     $parsed = $parser->parse();
     //$parser->printTags($parsed);
     $rendered = $renderer->render($parsed);
     //echo '<pre>' . htmlspecialchars($rendered) . '</pre>'; exit;
     return self::filterBbCode($rendered);
 }
Example #7
0
 public function partial($sViewScript, $mBind = null)
 {
     $partial = new self();
     if (null === $mBind) {
         $mBind = get_object_vars($this);
     }
     foreach ($mBind as $key => $val) {
         $partial->{$key} = $val;
     }
     $partial->setView($sViewScript);
     return $partial->render();
 }
Example #8
0
 public static function display($templateFile = "")
 {
     $view = new self();
     $view->templateFile = !empty($templateFile) ? $templateFile : $view->templateFile;
     $myfile_content = file_get_contents($view->viewFile);
     $myfile_content = $view->tag_replace($myfile_content);
     $view->create_template($view->templateFile_c, $myfile_content);
     $content = $view->fetch($view->templateFile_c . ".php");
     $view->create_template($view->templateFile, $content);
     // 输出模板内容
     $view->render($content);
 }
Example #9
0
File: Cli.php Project: schpill/thin
 public static function show($msg, $type = 'INFO')
 {
     $cli = new self(array('boot'));
     $cli->render($msg, $type);
 }
Example #10
0
 /**
  * Static function allows to quickly generarte tag
  * 
  * @param type $tag
  * @param type $attr
  * @param type $html
  * @return type
  */
 public static function build($tag, $attr = array(), $html = null)
 {
     $helper = new self($tag, $attr, $html);
     return $helper->render();
 }
Example #11
0
 /**
  * Send the stylesheet to the client
  *
  * Does not cache the stylesheet if the HTTP header Cache-Control or Pragma is set to no-cache.
  *
  * @param   bool    $minified   Whether to compress the stylesheet
  */
 public static function send($minified = false)
 {
     $styleSheet = new self();
     $request = $styleSheet->app->getRequest();
     $response = $styleSheet->app->getResponse();
     $noCache = $request->getHeader('Cache-Control') === 'no-cache' || $request->getHeader('Pragma') === 'no-cache';
     if (!$noCache && FileCache::etagMatchesFiles($styleSheet->lessCompiler->getLessFiles())) {
         $response->setHttpResponseCode(304)->sendHeaders();
         return;
     }
     $etag = FileCache::etagForFiles($styleSheet->lessCompiler->getLessFiles());
     $response->setHeader('Cache-Control', 'public', true)->setHeader('ETag', $etag, true)->setHeader('Content-Type', 'text/css', true);
     $cacheFile = 'icinga-' . $etag . ($minified ? '.min' : '') . '.css';
     $cache = FileCache::instance();
     if (!$noCache && $cache->has($cacheFile)) {
         $response->setBody($cache->get($cacheFile));
     } else {
         $css = $styleSheet->render($minified);
         $response->setBody($css);
         $cache->store($cacheFile, $css);
     }
     $response->sendResponse();
 }
Example #12
0
 /**
  * Given a template name, and a list of variable arrays, this method will
  * iterate through all the sets of variables, rendering the template with
  * each set, and concatenating them together. Could be used for looping
  * through a complex list, where each list element would be too much HTML
  * to cleanly place in the main template itself.
  *
  * @param  string $template Path to template file.
  * @param  array  $varArray Array of associative arrays containing
  *                          template variables.
  * @return string All rendered templates concatenated together.
  */
 public function partialLoop($template, array $varArray = array())
 {
     $t = new self($template);
     $s = '';
     foreach ($varArray as $index => $vars) {
         $t->clear();
         $t->set($vars);
         $t->set('loopIndex', $index);
         $s .= $t->render();
     }
     return $s;
 }
Example #13
0
 /**
  *	Returns Data Source Name String.
  *	@access		public
  *	@static
  *	@param		string		$driver			Database Driver (cubrid|dblib|firebird|informix|mysql|mssql|oci|odbc|pgsql|sqlite|sybase)
  *	@param		string		$database		Database Name
  *	@param		string		$host			Host Name or URI
  *	@param		int			$port			Host Port
  *	@param		string		$username		Username
  *	@param		string		$password		Password
  *	@return		string
  */
 public static function renderStatic($driver, $database, $host = NULL, $port = NULL, $username = NULL, $password = NULL)
 {
     $dsn = new self($driver, $database);
     $dsn->setHost($host);
     $dsn->setPort($port);
     $dsn->setUsername($username);
     $dsn->setPassword($password);
     return $dsn->render();
 }
 /**
  * Render the requested partial.
  *
  * @access protected
  * @param string $tag_name
  * @param array $context
  * @return string
  */
 protected function renderPartial($tag_name, &$context)
 {
     $view = new self($this->getPartial($tag_name), $context, $this->partials);
     $view->otag = $this->otag;
     $view->ctag = $this->ctag;
     return $view->render();
 }
Example #15
0
 /**
  * 快速render
  * 
  * @return 
  * @param string $template_file_or_string
  * @param array $context
  * @param boolean $cache
  * @param boolean $output
  */
 public static function simpleRender($template_file_or_string, $context, $cache = false, $output = true)
 {
     $result = null;
     if ($cache) {
         $cache_name = self::getCacheName($template_file_or_string, 'html');
         if (file_exists($cache_name)) {
             $result = file_get_contents($cache_name);
             if (!$result) {
                 $result = null;
             }
         }
     }
     if (null === $result) {
         $t = new self($template_file_or_string);
         $result = $t->render($context);
         if ($cache) {
             file_put_contents($cache_name, $result);
         }
     }
     if ($output) {
         echo $result;
     } else {
         return $result;
     }
 }
 /**
  * Build, setup and display a new breadcrumb trail.
  *
  * @static
  * @access public
  *
  * @param array $args Configuration options to modify the breadcrumb trail output.
  */
 public static function output($args = array())
 {
     $trail = new self($args);
     $trail->setup();
     $trail->render();
 }
 /**
  * @param Report $report
  * @return string
  */
 public static function generate(Report $report)
 {
     $generator = new self($report);
     return $generator->render();
 }
 /**
  * Build, configure and display a new pagination.
  *
  * @static
  * @param string $pagination The pagination type, can be one of the following:
  *    - Posts
  *    - Post
  *    - Comments
  *    - Custom
  * @param array $args Configuration options to modify the pagination settings.
  * @param bool $echo Whether to display or return the output. True will display, false will return.
  * @see Carbon_Pagination::__construct()
  */
 public static function display($pagination, $args = array(), $echo = true)
 {
     $pagination_classname = 'Carbon_Pagination_' . $pagination;
     // handle unexisting pagination types
     if (!class_exists($pagination_classname)) {
         return new WP_Error('carbon_pagination_unexisting_pagination_type', __('Unexisting pagination type class.', 'carbon_pagination'));
     }
     // initialize pagination
     $pagination = new $pagination_classname($args);
     $presenter = new self($pagination);
     $output = $presenter->render();
     if (!$echo) {
         return $output;
     }
     echo wp_kses($output, wp_kses_allowed_html('post'));
 }
Example #19
0
File: Vue.php Project: fzed51/vue
 /**
  * @param string $subTemplateName
  * @param array $data
  */
 protected function insert($subTemplateName, array $data = [])
 {
     $subTemplate = new self($this->templatePath, $this->attributes);
     echo $subTemplate->render($subTemplateName, $data);
 }
Example #20
0
 /**
  * Stop buffering, process and render
  */
 public static function stop()
 {
     $html = ob_get_clean();
     $compressor = new self($html);
     $compressor->render();
 }
Example #21
0
 /**
  * Act likes include and Simpie's render method. used in template file to include partial
  *
  * @param string $partial_path 	the partial to include
  * @param array  $params 		the param to extract
  *
  * @return mixed template's output or null
  */
 public static function include_partial($partial_path, $params = array(), $return = false, $file_type = null)
 {
     $partial = new self($partial_path, null, null, $file_type);
     return $partial->render($params, $return);
 }
 public static function test()
 {
     $pev = self::detect();
     $exe = is_executable(self::_getCMD());
     $fex = file_exists(self::_getCMD());
     $ecd = '';
     switch (WKPDF_DBG::os()) {
         case 'win':
             $ecd = self::_pipeExec('CD');
             break;
         case 'lin':
             $ecd = self::_pipeExec('PWD');
             break;
         case 'osx':
             $ecd = self::_pipeExec('PWD');
             break;
     }
     if (is_array($ecd)) {
         $ecd = $ecd['stdout'];
     }
     self::section_begin('System Info &amp; Settings');
     self::section_inspect('Detected OS:', self::_getOS(), self::_getOS() != '' ? self::CL_GREEN : self::CL_RED);
     self::section_inspect('Detected CPU:', self::_getCPU(), self::_getCPU() != '' ? self::CL_GREEN : self::CL_RED);
     self::section_inspect('Generated CMD:', self::_getCMD(), self::_getCMD() != '' ? self::CL_GREEN : self::CL_RED);
     self::section_inspect('Executable MD5:', $fex ? md5_file(self::_getCMD()) : 'File Not Found', $fex ? self::CL_GREEN : self::CL_RED);
     self::section_inspect('Executable:', $exe ? 'Yes' : 'No', $exe ? self::CL_GREEN : self::CL_RED);
     self::section_inspect('Base path: ', $GLOBALS['WKPDF_BASE_PATH']);
     self::section_inspect('Site path: ', $GLOBALS['WKPDF_BASE_SITE']);
     self::section_inspect('WinI path: ', $GLOBALS['WKPDF_WINI_PATH']);
     self::section_inspect('PHP Script CWD: ', getcwd(), getcwd() !== false ? self::CL_GREEN : self::CL_RED);
     self::section_inspect('PHP Exec CWD: ', $ecd == '' ? 'fail' : $ecd, $ecd != '' ? self::CL_GREEN : self::CL_RED);
     self::section_inspect('PHP Version: ', phpversion());
     self::section_inspect('Safe Mode: ', ini_get('safe_mode') ? 'On' : 'Off', ini_get('safe_mode') ? self::CL_RED : self::CL_GREEN);
     self::section_inspect('Wkhtmltopdf Version: ', $pev ? $pev : 'Not Recognized', $pev ? self::CL_GREEN : self::CL_RED);
     self::section_end();
     self::section_begin('Run Basic Commands');
     $cmd = 'dir';
     $out = self::_pipeExec($cmd);
     self::section_inspect('CMD: ', $cmd);
     self::section_inspect('STDOUT: ', $out['stdout']);
     self::section_inspect('STDERR: ', $out['stderr']);
     self::section_inspect('RETURN: ', $out['return']);
     self::section_end();
     self::section_begin('Test Run');
     try {
         $pdf = new self();
         self::section_inspect('CMD: ', $pdf->cmd);
         $pdf->set_url('http://google.com/');
         $pdf->render();
         self::section_inspect('Status: ', 'success', self::CL_GREEN);
         self::section_inspect('STDOUT: ', substr($pdf->pdf['stdout'], 0, 100));
         self::section_inspect('STDERR: ', $pdf->pdf['stderr']);
         self::section_inspect('RETURN: ', $pdf->pdf['return']);
     } catch (Exception $e) {
         self::section_inspect('Status: ', 'failure', self::CL_RED);
         self::section_inspect('Reason: ', $e->getMessage());
         self::section_inspect('In File: ', $e->getFile());
         self::section_inspect('On Line: ', $e->getLine());
         self::section_inspect('Stack Trace: ', $e->getTraceAsString());
     }
     self::section_end();
     self::section_begin('sTrace Run');
     $cmd = 'strace ' . self::_getCMD() . ' --version';
     $out = self::_pipeExec($cmd);
     self::section_inspect('CMD: ', $cmd);
     self::section_inspect('STDOUT: ', $out['stdout']);
     self::section_inspect('STDERR: ', $out['stderr']);
     self::section_inspect('RETURN: ', $out['return']);
     self::section_end();
     self::section_begin('CPU Info');
     $cmd = 'cat /proc/cpuinfo';
     $out = self::_pipeExec($cmd);
     self::section_inspect('CMD: ', $cmd);
     self::section_inspect('STDOUT: ', $out['stdout']);
     self::section_inspect('STDERR: ', $out['stderr']);
     self::section_inspect('RETURN: ', $out['return']);
     self::section_end();
 }
Example #23
0
 /**
  * Dumps a var
  * @param mixed $var var to dump
  * @param string $name [optional] var name
  * @param boolean $showStackTrace [optional] indicates whether to show the stack trace. Defaults to true.
  */
 public static function dump($var, $name = "unknown var name", $showStackTrace = true)
 {
     $dump = new self($var, $name, $showStackTrace);
     $dump->render();
 }
 public static function metabox_callback($post)
 {
     $instance = new self($post->ID);
     return $instance->render();
 }