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


PHP Parse类代码示例

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


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

示例1: run

 public static function run($line)
 {
     if (preg_match_all('/(?<start>.*)(?<statement>{{\\s*endif\\s*;\\s*}})(?<end>.*)/', $line, $matches)) {
         return Parse::run($matches);
     }
     return false;
 }
开发者ID:drroach,项目名称:templator,代码行数:7,代码来源:FindEndIf.php

示例2: render

 public function render()
 {
     $options = $this->getConfig();
     $field_options = array_get($this->field_config, 'options', array());
     $options = array_merge($options, $field_options);
     // File options
     if ($file_dir = array_get($this->field_config, 'file_dir', false)) {
         $file_dir = trim(array_get($this->field_config, 'file_dir'), '/') . '/';
         $options['fileUpload'] = Config::getSiteRoot() . 'TRIGGER/redactor/upload?path=' . $file_dir;
         $options['fileManagerJson'] = Config::getSiteRoot() . 'TRIGGER/redactor/fetch_files?path=' . $file_dir;
         $options['plugins'][] = 'filemanager';
     }
     // Image options
     if ($image_dir = array_get($this->field_config, 'image_dir', false)) {
         $image_dir = trim(array_get($this->field_config, 'image_dir'), '/') . '/';
         $options['imageUpload'] = Config::getSiteRoot() . 'TRIGGER/redactor/upload?path=' . $image_dir;
         $options['imageManagerJson'] = Config::getSiteRoot() . 'TRIGGER/redactor/fetch_images?path=' . $image_dir;
         $options['plugins'][] = 'imagemanager';
         if ($resize = array_get($this->field_config, 'resize')) {
             $options['imageUpload'] .= '&resize=1&' . http_build_query($resize);
         }
     }
     // Enable plugins
     $supported_plugins = array('table', 'video', 'fullscreen', 'fontcolor', 'fontsize', 'fontfamily');
     foreach ($options['buttons'] as $button) {
         if (in_array($button, $supported_plugins)) {
             $options['plugins'][] = $button;
         }
     }
     $vars = array('field_id' => $this->field_id, 'field_name' => $this->fieldname, 'tabindex' => $this->tabindex, 'field_data' => $this->field_data, 'field_config' => $this->field_config, 'options' => $options);
     $template = File::get($this->getAddonLocation() . 'views/fieldtype.html');
     return Parse::template($template, $vars);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:33,代码来源:ft.redactor.php

示例3: render

 public function render()
 {
     $data = $this->field_data ? $this->field_data : array(array('cells' => array('')));
     $vars = array('field_id' => $this->field_id, 'field_name' => $this->fieldname, 'height' => array_get($this->field_config, 'height'), 'rows' => json_encode($data));
     $template = File::get($this->getAddonLocation() . 'views/fieldtype.html');
     return Parse::template($template, $vars);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:7,代码来源:ft.table.php

示例4: getContent

 /**
  * Lists entries based on passed parameters
  *
  * @return array|string
  */
 public function getContent($variable)
 {
     $urls = array_get($this->context, $variable);
     if (!$urls) {
         return null;
     }
     // grab common parameters
     $settings = $this->parseCommonParameters();
     // grab content set based on the common parameters
     // $content_set = $this->getContentSet($settings);
     $content_set = ContentService::getContentByURL($urls);
     $content_set->filter(array('show_hidden' => $this->fetchParam('show_hidden', false, null, true, false), 'show_drafts' => $this->fetchParam('show_drafts', false, null, true, false), 'show_past' => $this->fetchParam('show_past', true, null, true), 'show_future' => $this->fetchParam('show_future', false, null, true), 'type' => 'all', 'conditions' => trim($this->fetchParam('conditions', null, false, false, false))));
     // limit
     $limit = $this->fetchParam('limit', null, 'is_numeric');
     $offset = $this->fetchParam('offset', 0, 'is_numeric');
     if ($limit || $offset) {
         $content_set->limit($limit, $offset);
     }
     // sort
     $sort_by = $this->fetchParam('sort_by');
     $sort_dir = $this->fetchParam('sort_dir');
     if ($sort_by || $sort_dir) {
         $content_set->sort($sort_by, $sort_dir);
     }
     // check for results
     if (!$content_set->count()) {
         return Parse::template($this->content, array('no_results' => true));
     }
     return Parse::tagLoop($this->content, $content_set->get(), false, $this->context);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:35,代码来源:pi.relate.php

示例5: __call

 public function __call($method, $arguments)
 {
     // Get all the parameter/filters
     $filters = $this->attributes;
     // Default content to context
     $content = $this->context;
     // Override content by a specific page if needed
     if ($from = $this->fetchParam('from')) {
         $content = current(ContentService::getContentByURL($from)->get());
         unset($filters['from']);
     }
     // Grab the field data
     $field_data = array_get($content, $method);
     // Filter down to what we're looking for
     $values = array_values(array_filter($field_data, function ($i) use($filters) {
         foreach ($filters as $key => $val) {
             $match = array_get($i, $key) == $val;
             if (!$match) {
                 break;
             }
         }
         return $match;
     }));
     // No results?
     if (empty($values)) {
         return array('no_results' => true);
     }
     // Got something. Yay. Return it.
     return Parse::tagLoop($this->content, $values, true);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:30,代码来源:pi.get_value.php

示例6: execute

 /**
  * Execute the argument parsing given the input from the command line
  *     in $_SERVER['argv']
  *
  * @param array $args Arguments list from the PHP input
  * @return array Parsed argument results
  */
 public function execute($args, array $config = array())
 {
     // Strip off the first item, it's the script name
     array_shift($args);
     $values = [];
     // Set any defaults we may have
     if (isset($config['default'])) {
         foreach ($config['default'] as $key => $value) {
             $values[$key] = $value;
         }
     }
     foreach ($args as $argument) {
         list($name, $value) = Parse::execute($argument);
         // see if we can find a matching option
         if ($name !== null) {
             $values[$name] = $value;
         } else {
             $values[] = $value;
         }
     }
     // See if we have ann required params
     if (isset($config['required'])) {
         $missing = [];
         foreach ($config['required'] as $index => $param) {
             if (!isset($values[$param])) {
                 $missing[] = $param;
             }
         }
         if (!empty($missing)) {
             throw new Exception\MissingRequiredException('Missing required params: ' . implode(', ', $missing));
         }
     }
     return $values;
 }
开发者ID:Stunt,项目名称:cmd,代码行数:41,代码来源:Command.php

示例7: __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

示例8: display

 public function display($file)
 {
     $this->tpl_file = TPL_DIR . $file . TPL_EXTENDTION;
     //设置模板文件路径
     if (!file_exists($this->tpl_file)) {
         exit(get_langage_message("template.lang.php", 'TEMPLATE_FILE_NOT_FOUND', array('TEMPLATE_FILE' => $this->tpl_file)));
     }
     $this->parse_file = TPL_C_DIR . md5($file) . '.php';
     //设置编译文件路径
     $parse = new Parse($this->tpl_file);
     //初始化模板解析类
     $parse->compile($this->parse_file, $this->tpl_file);
     //解析静态模板文件,生成编译文件
     //判断是否需要重新生成缓存文件
     $this->cache($file);
 }
开发者ID:pantingwen,项目名称:sanwenphp,代码行数:16,代码来源:Templates.class.php

示例9: listing

 public function listing()
 {
     $role = $this->fetchParam('role', false);
     $limit = $this->fetchParam('limit', null, 'is_numeric');
     // defaults to none
     $offset = $this->fetchParam('offset', 0, 'is_numeric');
     // defaults to zero
     $sort_by = $this->fetchParam('sort_by', 'title');
     // defaults to date
     $sort_dir = $this->fetchParam('sort_dir', 'desc');
     // defaults to desc
     $members = Statamic_Auth::get_user_list(false);
     if (is_array($members) && count($members) > 0) {
         $members = array_slice($members, $offset, $limit, true);
         if ($sort_by == 'random') {
             shuffle($list);
         } elseif ($sort_by != 'title' || $sort_by != 'username') {
             # sort by any other field
             usort($members, function ($a, $b) use($sort_by) {
                 if (isset($a[$sort_by]) && isset($b[$sort_by])) {
                     return strcmp($b[$sort_by], $a[$sort_by]);
                 }
             });
         }
         // default sort is asc
         if ($sort_dir == 'desc') {
             $members = array_reverse($members);
         }
         return Parse::tagLoop($this->content, $members);
     } else {
         return array('no_results' => true);
     }
 }
开发者ID:nob,项目名称:joi,代码行数:33,代码来源:pi.member.php

示例10: run

 public static function run($line)
 {
     if (preg_match('/(?<start>.*){{\\s*endforeach;\\s*}}(?<end>.*)/', $line, $match)) {
         return Parse::run($match);
     }
     return false;
 }
开发者ID:drroach,项目名称:templator,代码行数:7,代码来源:FindEndForeach.php

示例11: run

 public static function run($line)
 {
     if (preg_match_all('/(?<start>[^\\{]*)\\s*{{(?<startQuickEsc>{)?\\s*(?<echo>\\w+(\\.\\w+)*)(?<escape>[\\|!](e|escape))?\\s*}}(?<endQuickEsc>})?(?<end>.*)/', $line, $match)) {
         return Parse::run($match);
     }
     return false;
 }
开发者ID:drroach,项目名称:templator,代码行数:7,代码来源:FindEcho.php

示例12: index

 public function index()
 {
     $from = $this->fetchParam('from', false);
     if (!$from) {
         return null;
     }
     // account for subfolder
     if (strpos($from, Config::getSiteRoot()) !== 0) {
         $from = Path::tidy(Config::getSiteRoot() . $from);
     }
     $from = Path::addStartingSlash($from);
     $content_set = ContentService::getContentByURL($from);
     // filter
     $content_set->filter(array('show_hidden' => $this->fetchParam('show_hidden', false, null, true, false), 'show_drafts' => $this->fetchParam('show_drafts', false, null, true, false), 'show_past' => $this->fetchParam('show_past', true, null, true), 'show_future' => $this->fetchParam('show_future', false, null, true), 'type' => 'all', 'conditions' => trim($this->fetchParam('conditions', null, false, false, false))));
     // limit
     $limit = $this->fetchParam('limit', 1, 'is_numeric');
     $offset = $this->fetchParam('offset', 0, 'is_numeric');
     $content_set->limit($limit, $offset);
     // check for results
     if (!$content_set->count()) {
         return Parse::tagLoop($this->content, array(array('no_results' => true)));
     }
     // if content is used in this entries loop, parse it
     $parse_content = (bool) preg_match(Pattern::USING_CONTENT, $this->content);
     return Parse::tagLoop($this->content, $content_set->get($parse_content), false, $this->context);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:26,代码来源:pi.get_content.php

示例13: index

 /**
  * Get Instagram media
  * @return array parsed response from a public Instagram feed
  */
 public function index()
 {
     $username = $this->fetch('username');
     $limit = $this->fetch('limit', false, 'is_numeric');
     $offset = $this->fetch('offset', 0, 'is_numeric');
     $media = $this->tasks->getMedia($username, $limit, $offset);
     return Parse::tagLoop($this->content, $media);
 }
开发者ID:roobottom,项目名称:roobottom-statamic,代码行数:12,代码来源:pi.instagrizzle.php

示例14: execute

 /**
  * (non-PHPdoc)
  * @see \DasRed\Translation\Command\Executor\Log\Parse::execute()
  */
 public function execute()
 {
     $file = $this->getArguments()[1];
     if (file_exists($file) === true) {
         unlink($file);
     }
     $this->write('File', 'LineNumber', 'Key', 'Locale', 'Count of Matches');
     return parent::execute();
 }
开发者ID:dasred,项目名称:translation,代码行数:13,代码来源:ToCsv.php

示例15: setTemplates

 /**
  * Generate the set templates
  * 
  * @return string  JSON encoded string of templates
  */
 private function setTemplates()
 {
     $template = File::get($this->getAddonLocation() . 'views/templates.html');
     foreach ($this->set_types as $set) {
         $set['buttons'] = $this->buttons;
         $templates[] = array('type' => $set['name'], 'html' => Parse::template($template, $set));
     }
     return json_encode($templates);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:14,代码来源:ft.replicator.php


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