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


PHP Parse::contextualTemplate方法代码示例

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


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

示例1: __call

 public function __call($method, $arguments)
 {
     $extensions = array(".html", ".md", ".markdown", ".textile");
     $html = null;
     foreach ($extensions as $extension) {
         $full_src = Path::assemble(BASE_PATH, Config::getCurrentThemePath(), 'partials', ltrim($method . $extension, '/'));
         if (File::exists($full_src)) {
             // Merge additional variables passed as parameters
             Statamic_View::$_dataStore = $arguments + Statamic_View::$_dataStore;
             if ($this->fetchParam('use_context', false, false, true, false)) {
                 $html = Parse::contextualTemplate(File::get($full_src), Statamic_View::$_dataStore, $this->context, 'Statamic_View::callback');
             } else {
                 $html = Parse::template(File::get($full_src), Statamic_View::$_dataStore, 'Statamic_View::callback');
             }
             // parse contents if needed
             if ($extension == ".md" || $extension == ".markdown") {
                 $html = Parse::markdown($html);
             } elseif ($extension == ".textile") {
                 $html = Parse::textile($html);
             }
         }
     }
     if (Config::get('enable_smartypants', TRUE)) {
         $html = Parse::smartypants($html);
     }
     return $html;
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:27,代码来源:pi.partial.php

示例2: words

 public function words()
 {
     $limit = $this->fetchParam('limit', NULL);
     $ending = $this->fetchParam('ending', '...', null, false, false);
     $this->content = Parse::contextualTemplate($this->content, array(), $this->context);
     $words = preg_split("/[\n\r\t ]+/", $this->content, $limit + 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);
     if (count($words) > $limit) {
         end($words);
         $last_word = prev($words);
         $this->content = substr($this->content, 0, $last_word[1] + strlen($last_word[0])) . $ending;
     }
     return $this->content;
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:13,代码来源:pi.truncate.php

示例3: index

 public function index()
 {
     // if disabled, do nothing
     if (!$this->core->isEnabled()) {
         return Parse::contextualTemplate($this->content, array(), $this->context);
     }
     // grab and prepare parameters
     $key = $this->fetchParam('key', null, null, false, false);
     $age = time() - Date::resolve('-' . $this->fetch(array('for', 'default_cache_length'), '12 hours', null, false, false));
     $hash = $this->fetch(array('scope', 'default_scope'), 'site') === 'page' ? Helper::makeHash(URL::getCurrent(), $this->content) : Helper::makeHash($this->content);
     $path = 'troves/' . $hash;
     // deal with keys
     if ($key) {
         // split on pipes
         $keys = explode('|', $key);
         // loop through keys, storing this hash to this key
         foreach ($keys as $key) {
             $key_path = 'keys/' . trim($key);
             // get existing keys
             $hashes = $this->cache->getYAML($key_path, array());
             $new_hashes = array();
             // check that the hashes are all still valid
             foreach ($hashes as $new_hash) {
                 if ($this->cache->exists('troves/' . $new_hash)) {
                     $new_hashes[] = $new_hash;
                 }
             }
             // add this one
             $new_hashes[] = $hash;
             // append new ones
             $this->cache->putYAML($key_path, array_unique($new_hashes));
         }
     }
     // check for pre-existing cache
     if (!$this->cache->exists($path) || $this->cache->getAge($path) > $age) {
         // cache doesn't exist or has expired, so parse this contextually...
         $html = Parse::contextualTemplate($this->content, array(), $this->context);
         // ...and store the HTML
         $this->cache->put($path, $html);
     }
     // garbage collection
     $this->core->collectGarbage();
     // return what we know
     return $this->cache->get($path);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:45,代码来源:pi.cache.php

示例4: partial

 public function partial()
 {
     $start = time();
     $src = $this->fetchParam('src', null, null, false, false);
     $extensions = array(".html", ".md", ".markdown", ".textile");
     $html = null;
     // measurement
     $hash = Debug::markStart('partials', $src, $start);
     Debug::increment('partials', $src);
     if ($src) {
         foreach ($extensions as $extension) {
             $full_src = Path::assemble(BASE_PATH, $this->theme_root, 'partials', ltrim($src . $extension, '/'));
             if (File::exists($full_src)) {
                 Statamic_View::$_dataStore = $this->attributes + Statamic_View::$_dataStore;
                 if ($this->fetchParam('use_context', false, false, true, false)) {
                     // to use context, we only want to pass the attributes as
                     // the current data, as those will override into the context
                     // set of data; if we were to include all of ::$_dataStore,
                     // we run into the issue where all of the global-level variables
                     // are overriding variables in context, when the variables in
                     // context are more accurate scope-wise at this point in the parse
                     $html = Parse::contextualTemplate(file_get_contents($full_src), $this->attributes, $this->context, array('statamic_view', 'callback'), true);
                 } else {
                     $html = Parse::template(file_get_contents($full_src), Statamic_View::$_dataStore);
                 }
                 // parse contents if needed
                 if ($extension == ".md" || $extension == ".markdown") {
                     $html = Parse::markdown($html);
                 } elseif ($extension == ".textile") {
                     $html = Parse::textile($html);
                 }
             }
         }
         if (Config::get('enable_smartypants', TRUE)) {
             $html = Parse::smartypants($html);
         }
     }
     Debug::markEnd($hash);
     return $html;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:40,代码来源:pi.theme.php

示例5: submission

	/**
	 * Allows you to output data from the submission
	 *
	 * @return string
	 **/
	public function submission()
	{
		if ( ! $this->flash->exists('submission')) {
			return;
		}

		return Parse::contextualTemplate($this->content, $this->flash->get('submission'), $this->context);
	}
开发者ID:jalmelb,项目名称:24hl2015,代码行数:13,代码来源:pi.raven.php

示例6: tagLoop

 /**
  * Parses a tag loop, replacing template variables with each array in a list of arrays
  *
  * @param string  $content  Template for replacing
  * @param array  $data  Array of arrays containing values
  * @param bool  $supplement  Supplement each loop with contextual information?
  * @param array  $context  Contextual data to add into loop
  * @return string
  */
 public static function tagLoop($content, $data, $supplement = false, $context = array())
 {
     $output = '';
     if ($supplement) {
         // loop through each record of $data
         $i = 1;
         $count = count($data);
         foreach ($data as $item) {
             $item['first'] = $i === 1;
             $item['last'] = $i === $count;
             $item['index'] = $i;
             $item['zero_index'] = $i - 1;
             $item['total_results'] = $count;
             $output .= Parse::contextualTemplate($content, $item, $context);
             $i++;
         }
     } else {
         foreach ($data as $item) {
             $output .= Parse::contextualTemplate($content, $item, $context, array('statamic_view', 'callback'));
         }
     }
     return $output;
 }
开发者ID:Bferreira5,项目名称:Theme-Example,代码行数:32,代码来源:parse.php

示例7: generateModal

 public function generateModal($files, $destination)
 {
     $vars = array('server_files' => $files, 'destination' => $destination, 'secure_destination' => urlencode(Helper::encrypt($destination)), 'cp_url' => URL::assemble(Config::getSiteRoot(), Config::get('admin_path') . '.php'), 'default_thumbnail' => $this->defaultFileThumbnail(), 'allow_delete' => (bool) Config::get('allow_file_field_deletions'));
     $template = File::get($this->getAddonLocation() . 'views/modal.html');
     return Parse::contextualTemplate($template, $vars, Config::getAll());
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:6,代码来源:tasks.file.php

示例8: send

 /**
  * Send a notification/response email
  *
  * @param array $submission Array of submitted values
  * @param array $email Array of email config values
  * @param array $config Array of config values
  */
 private function send($submission, $email, $config)
 {
     $attributes = array_intersect_key($email, array_flip(Email::$allowed));
     if (array_get($email, 'automagic') || array_get($email, 'automatic')) {
         $automagic_email = $this->buildAutomagicEmail($submission);
         $attributes['html'] = $automagic_email['html'];
         $attributes['text'] = $automagic_email['text'];
     }
     if ($html_template = array_get($email, 'html_template', false)) {
         $attributes['html'] = Theme::getTemplate($html_template);
     }
     if ($text_template = array_get($email, 'text_template', false)) {
         $attributes['text'] = Theme::getTemplate($text_template);
     }
     /*
     |--------------------------------------------------------------------------
     | Parse all fields
     |--------------------------------------------------------------------------
     |
     | All email settings are parsed with the form data, allowing you, for
     | example, to send an email to a submitted email address.
     |
     |
     */
     $globals = Config::getAll();
     array_walk_recursive($attributes, function (&$value, $key) use($submission, $globals) {
         $value = Parse::contextualTemplate($value, $submission, $globals);
     });
     $attributes['email_handler'] = array_get($config, 'email_handler', null);
     $attributes['email_handler_key'] = array_get($config, 'email_handler_key', null);
     $attributes['smtp'] = array_get($config, 'smtp', null);
     Email::send($attributes);
 }
开发者ID:Synergy23,项目名称:RealEstate,代码行数:40,代码来源:hooks.raven.php

示例9: index

 function index()
 {
     $content = Parse::contextualTemplate($this->content, array(), $this->context);
     return trim(preg_replace('/\\s+/', ' ', $content), " \t\n");
 }
开发者ID:jeffreyDcreative,项目名称:gkp,代码行数:5,代码来源:pi.killwhite.php

示例10: getMessage

 private function getMessage()
 {
     $this->what = $this->fetchParam('what', 'log', null, false, false);
     $this->specifically = $this->fetchParam('specifically', 'message', null, false, false);
     $this->message = Parse::contextualTemplate(trim($this->fetchParam('message', $this->content, null, false, false)), array(), $this->context);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:6,代码来源:pi.log.php


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