当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPTAL::setOutputMode方法代码示例

本文整理汇总了PHP中PHPTAL::setOutputMode方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPTAL::setOutputMode方法的具体用法?PHP PHPTAL::setOutputMode怎么用?PHP PHPTAL::setOutputMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPTAL的用法示例。


在下文中一共展示了PHPTAL::setOutputMode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processViewData

 /**
  * This method is used to process the data into the view and than return it to the main method that will handle what to do.
  * It also uses buffer to handle that content.
  *
  * @author Klederson Bueno <klederson@klederson.com>
  * @version 0.1a
  *
  * @param String $___phpBurnFilePath
  * @param Array $__phpBurnData
  * @return String
  */
 public function processViewData($___phpBurnFilePath, $__phpBurnData)
 {
     $tpl = new PHPTAL($___phpBurnFilePath);
     $tpl->setOutputMode(PHPTAL::HTML5);
     $tr = new PHPTAL_GetTextTranslator();
     // set language to use for this session (first valid language will
     // be used)
     $tr->setLanguage('pt_BR.utf8', 'pt_BR');
     // register gettext domain to use
     $tr->addDomain('system', SYS_BASE_PATH . 'locale');
     // specify current domain
     $tr->useDomain('system');
     // tell PHPTAL to use our translator
     $tpl->setTranslator($tr);
     foreach ($__phpBurnData as $index => $value) {
         if (is_string($value)) {
             $value = PhpBURN_Views::lazyTranslate($value, $_SESSION['lang']);
         }
         $tpl->{$index} = $value;
     }
     ob_start();
     try {
         echo $tpl->execute();
     } catch (Exception $e) {
         echo $e;
     }
     $___phpBurnBufferStored = ob_get_contents();
     //
     //        //Cleaning the buffer for new sessions
     ob_clean();
     return $___phpBurnBufferStored;
 }
开发者ID:phpburn,项目名称:phpburn,代码行数:43,代码来源:dcampos.php

示例2: __invoke

 /**
  * @param ContainerInterface $container
  * @return PhptalEngine
  */
 public function __invoke(ContainerInterface $container)
 {
     $config = $container->has('config') ? $container->get('config') : [];
     if (!is_array($config) && !$config instanceof ArrayObject) {
         throw new Exception\InvalidConfigException(sprintf('"config" service must be an array or ArrayObject for the %s to be able to consume it; received %s', __CLASS__, is_object($config) ? get_class($config) : gettype($config)));
     }
     // Set debug mode
     $debug = array_key_exists('debug', $config) ? (bool) $config['debug'] : false;
     $config = $this->mergeConfig($config);
     // Create the engine instance:
     $engine = new PhptalEngine();
     // Change the compiled code destination if set in the config
     if (isset($config['cache_dir'])) {
         $engine->setPhpCodeDestination($config['cache_dir']);
     }
     // Configure the encoding
     if (isset($config['encoding'])) {
         $engine->setEncoding($config['encoding']);
     }
     // Configure the output mode
     $outputMode = isset($config['output_mode']) ? $config['output_mode'] : PHPTAL::HTML5;
     $engine->setOutputMode($outputMode);
     // Set template repositories
     if (isset($config['paths'])) {
         $engine->setTemplateRepository($config['paths']);
     }
     // Configure cache lifetime
     if (isset($config['cache_lifetime'])) {
         $engine->setCacheLifetime($config['cache_lifetime']);
     }
     // If purging of the tal template cache is enabled
     // find all template cache files and delete them
     $cachePurgeMode = isset($config['cache_purge_mode']) ? (bool) $config['cache_purge_mode'] : false;
     if ($cachePurgeMode) {
         $cacheFolder = $engine->getPhpCodeDestination();
         if (is_dir($cacheFolder)) {
             foreach (new DirectoryIterator($cacheFolder) as $cacheItem) {
                 if (strncmp($cacheItem->getFilename(), 'tpl_', 4) != 0 || $cacheItem->isdir()) {
                     continue;
                 }
                 @unlink($cacheItem->getPathname());
             }
         }
     }
     // Configure the whitespace compression mode
     $compressWhitespace = isset($config['compress_whitespace']) ? (bool) $config['compress_whitespace'] : false;
     if ($compressWhitespace) {
         $engine->addPreFilter(new PHPTAL_PreFilter_Compress());
     }
     // Strip html comments and compress un-needed whitespace
     $stripComments = isset($config['strip_comments']) ? (bool) $config['strip_comments'] : false;
     if ($stripComments) {
         $engine->addPreFilter(new PHPTAL_PreFilter_StripComments());
     }
     if ($debug) {
         $engine->setForceReparse(true);
     }
     $this->injectHelpers($engine, $container);
     return $engine;
 }
开发者ID:xorock,项目名称:zend-expressive-phptalrenderer,代码行数:64,代码来源:PhptalEngineFactory.php

示例3: generate

 public function generate()
 {
     // getting view file contents, and stripping from <?php die?\>
     $viewContent = file_get_contents($this->_viewPath);
     $viewContent = str_replace('<?php die?>', '', $viewContent);
     $viewContent = '<tal:block>' . $viewContent . '</tal:block>';
     // PHPTAL configuration
     $view = new PHPTAL();
     $view->setSource($viewContent, $this->_viewPath);
     foreach ($this->_params as $key => $value) {
         $view->set($key, $value);
     }
     $view->setOutputMode(PHPTAL::HTML5);
     // PHPTAL filters
     $view->addPreFilter(new ViewPreFilter());
     // <?  -->  <?php, <?=  -->  <?php echo
     $view->addPreFilter(new PHPTAL_PreFilter_StripComments());
     if (!defined('WM_Debug')) {
         $view->addPreFilter(new PHPTAL_PreFilter_Normalize());
         // strips whitespaces etc.
     }
     // predefined parameters
     // (NOTE: when changed, change also array in ->__set())
     if (class_exists('Users')) {
         $view->set('isAdmin', Users::isLogged());
     }
     // executing
     return $view->execute();
 }
开发者ID:radex,项目名称:Watermelon,代码行数:29,代码来源:View.php

示例4: __construct

 /**
  * Prep the PHPTAL object
  *
  * @param
  *            $app
  */
 public function __construct($app)
 {
     $this->app = $app;
     $this->config = $app['config'];
     $this->phptal = new \PHPTAL();
     // Override the defaults with information from config file
     $preFilters = $this->config->get('phptal.preFilters', []);
     $postFilters = $this->config->get('phptal.postFilters', []);
     $encoding = $this->config->get('phptal.translationEncoding', 'UTF-8');
     $outputMode = $this->config->get('phptal.outputMode', \PHPTAL::HTML5);
     $phpCodeDestination = $this->config->get('phptal.phpCodeDestination', $app['path.storage'] . '/framework/views');
     $forceReparse = $this->config->get('phptal.forceParse', true);
     $templateRepositories = $this->config->get('phptal.templateRepositories', $app['path.base'] . '/resources/views' . (TEMPLATE_ID ? '/' . TEMPLATE_ID : ''));
     $translationClass = $this->config->get('phptal.translationClass');
     $translationDomain = $this->config->get('phptal.translationDomain', 'messages');
     $translationLanguage = [$this->app->getLocale()];
     // Setting up translation settings
     $this->translationSettings['encoding'] = $encoding;
     if (!empty($translationClass)) {
         $this->setTranslator($translationLanguage, $translationDomain, $translationClass);
     }
     // Setting up all the filters
     if (!empty($preFilters)) {
         foreach ($preFilters as $filter) {
             $this->phptal->addPreFilter($filter);
         }
     }
     if (!empty($postFilters)) {
         $filterChain = new PHPTALFilterChain();
         foreach ($postFilters as $filter) {
             $filterChain->add($filter);
         }
         $this->phptal->setPostFilter($filterChain);
     }
     $this->phptal->setForceReparse($forceReparse);
     $this->phptal->setOutputMode($outputMode);
     $this->phptal->setTemplateRepository($templateRepositories);
     $this->phptal->setPhpCodeDestination($phpCodeDestination);
 }
开发者ID:marcoshoo,项目名称:phptal-laravel,代码行数:45,代码来源:PHPTALEngine.php

示例5: makeTemplate

 /**
  * Create an instance of skeleton PHPTAL template
  *
  * @param $skeleton_file
  *
  */
 protected function makeTemplate($skeleton_file)
 {
     try {
         $this->template = new PHPTAL(INIT::$TEMPLATE_ROOT . "/{$skeleton_file}");
         // create a new template object
         $this->template->basepath = INIT::$BASEURL;
         $this->template->hostpath = INIT::$HTTPHOST;
         $this->template->supportedBrowser = $this->supportedBrowser;
         $this->template->enabledBrowsers = INIT::$ENABLED_BROWSERS;
         $this->template->setOutputMode(PHPTAL::HTML5);
     } catch (Exception $e) {
         echo "<pre>";
         print_r($e);
         echo "\n\n\n";
         print_r($this->template);
         echo "</pre>";
         exit;
     }
 }
开发者ID:indynagpal,项目名称:MateCat,代码行数:25,代码来源:viewController.php

示例6: processViewData

 /**
  * This method is used to process the data into the view and than return it to the main method that will handle what to do.
  * It also uses buffer to handle that content.
  *
  * @author Klederson Bueno <klederson@klederson.com>
  * @version 0.1a
  *
  * @param String $___phpBurnFilePath
  * @param Array $__phpBurnData
  * @return String
  */
 public function processViewData($___phpBurnFilePath, $__phpBurnData)
 {
     $tpl = new PHPTAL($___phpBurnFilePath);
     $tpl->setOutputMode(PHPTAL::HTML5);
     foreach ($__phpBurnData as $index => $value) {
         $tpl->{$index} = $value;
     }
     ob_start();
     try {
         echo $tpl->execute();
     } catch (Exception $e) {
         echo $e;
     }
     $___phpBurnBufferStored = ob_get_contents();
     //
     //        //Cleaning the buffer for new sessions
     ob_clean();
     return $___phpBurnBufferStored;
 }
开发者ID:bellthoven,项目名称:phpburn,代码行数:30,代码来源:phptal.php

示例7: makeTemplate

 /**
  * Create an instance of skeleton PHPTAL template
  *
  * @param $skeleton_file
  *
  */
 protected function makeTemplate($skeleton_file)
 {
     try {
         $this->template = new PHPTAL(INIT::$TEMPLATE_ROOT . "/{$skeleton_file}");
         // create a new template object
         $this->template->basepath = INIT::$BASEURL;
         $this->template->hostpath = INIT::$HTTPHOST;
         $this->template->supportedBrowser = $this->supportedBrowser;
         $this->template->enabledBrowsers = INIT::$ENABLED_BROWSERS;
         $this->template->build_number = INIT::$BUILD_NUMBER;
         $this->template->use_compiled_assets = INIT::$USE_COMPILED_ASSETS;
         $this->template->maxFileSize = INIT::$MAX_UPLOAD_FILE_SIZE;
         $this->template->maxTMXFileSize = INIT::$MAX_UPLOAD_TMX_FILE_SIZE;
         INIT::$VOLUME_ANALYSIS_ENABLED ? $this->template->analysis_enabled = true : null;
         $this->template->setOutputMode(PHPTAL::HTML5);
     } catch (Exception $e) {
         echo "<pre>";
         print_r($e);
         echo "\n\n\n";
         print_r($this->template);
         echo "</pre>";
         exit;
     }
 }
开发者ID:bcrazvan,项目名称:MateCat,代码行数:30,代码来源:viewController.php

示例8: PHPTAL

<?php

require_once './lib/PHPTAL-1.3.0/PHPTAL.php';
// render the whole page using PHPTAL
// finally, create a new template object
$template = new PHPTAL('cart.php');
$template->setOutputMode(PHPTAL::HTML5);
// now add the variables for processing and that you created from above:
$template->page_title = "Fresh 'n Healthy: Online Farmers' Market";
// execute the template
try {
    echo $template->execute();
} catch (Exception $e) {
    // not much else we can do here if the template engine barfs
    echo $e;
}
开发者ID:yinghuaho,项目名称:online-market-produce,代码行数:16,代码来源:cartphptal.php

示例9: render

    /**
     * Renders a template.
     * @param string $name       A template name
     * @param array  $parameters An array of parameters to pass to the template
     *                           the default options engine can be override by $parameters['_engine_'][option]
     * @return string The evaluated template as a string
     *
     * @throws \InvalidArgumentException if the template does not exist
     * @throws \RuntimeException         if the template cannot be rendered
     */
    public function render($name, array $parameters = array() )
    {

        $template = new \PHPTAL();


        // engine options by parameters to relpace configuration
        if(isset($parameters['_engine_'])&&(is_array($parameters['_engine_']))){
            $options = $parameters['_engine_'];
        }else{
            $options = array();
        }

        // code cache destination
        $tmpdir = (isset($options['cache_dir']))?$options['cache_dir']:$this->options['cache_dir'];
        if(!is_dir($tmpdir)){mkdir($tmpdir);}
        $template->setPhpCodeDestination($tmpdir);

        // code cache durration
        $template->setCacheLifetime( (isset($options['cache_dir']))?$options['cache_lifetime']:$this->options['cache_lifetime'] );

        // encoding
        $template->setEncoding( (isset($options['charset']))?$options['charset']:$this->options['charset'] );
  
        // output mod
        if(!isset($options['output_format'])){
            $options['output_format'] = $this->options['output_mode'];
        }
        if($options['output_format']=='XHTML'){
            $template->setOutputMode( \PHPTAL::XHTML );
        }elseif($options['output_format']=='HTML5'){
            $template->setOutputMode( \PHPTAL::HTML5 );
        }elseif($options['output_format']=='XML'){
            $template->setOutputMode( \PHPTAL::XML );
        }else{
            throw new \InvalidArgumentException('Unsupported output mode ' . $options['output_format']);
        }

        // force reparse (for debug prefilter)
        $template->setForceReparse( (isset($options['force_reparse']))?$options['force_reparse']:$this->options['force_reparse'] );


        // pre filters
        $filtres = $this->options['pre_filters'];
        foreach($filtres as $filtre){
            $template->addPreFilter( new $filtre['class']($filtre['params']) );
        }

        // post filters
        $filtres = $this->options['post_filters'];
        if($filtres){
            $template->setPostFilter(new PhptalPostFilters($filtres));
        }

        // set SourceResolver
        if(!isset($options['resolver'])){
            $template->addSourceResolver($this->resolver);
        }else{
            if($this->container->has($options['resolver'])){
                $resolver = $this->container->get($options['resolver']);
                $r = new \ReflectionClass( get_class($resolver) );
                if (!$r->implementsInterface('Neni\\PhptalBundle\\Phptal\\PhptalResolverInterface')) {
                    throw new \InvalidArgumentException(sprintf('The service "%s" does implements PhptalResolverInterface.', $options['resolver']));
                }else{
                    $template->addSourceResolver( $resolver );
                }
            }else{
                throw new \InvalidArgumentException(sprintf('The service "%s" does not exist.', $options['resolver']));
            }
        }

        // set source template
        $template->setTemplate($name);


        // set data
        if(!isset($options['populater'])){
            unset($parameters['_engine_']);
            $this->populater->populate($template, $parameters);
        }else{
            if($this->container->has($options['populater'])){
                $populater = $this->container->get($options['populater']);
                $r = new \ReflectionClass( get_class($populater) );
                if (!$r->implementsInterface('Neni\\PhptalBundle\\Phptal\\PhptalPopulaterInterface')) {
                    throw new \InvalidArgumentException(sprintf('The service "%s" does implements PhptalPopulaterInterface.', $options['populater']));
                }else{
                    unset($parameters['_engine_']);
                    $populater->populate($template, $parameters);
                }
            }else{
//.........这里部分代码省略.........
开发者ID:neni,项目名称:NeniPhptalBundle,代码行数:101,代码来源:PhptalEngine.php


注:本文中的PHPTAL::setOutputMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。