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


PHP Draft::init_draft_nav方法代码示例

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


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

示例1: index

 function index()
 {
     list($params, $id) = $this->parse_params(func_get_args());
     $theme = new Theme();
     $themes = $theme->read(true);
     if ($this->method == 'post' && isset($_POST['theme'])) {
         $t = $_POST['theme'];
         if (isset($themes[$t])) {
             $d = new Draft();
             $d->where('draft', 1)->update('draft', 0);
             $d->where('path', $t)->get();
             $d->path = $t;
             $d->draft = 1;
             if (isset($_POST['refresh'])) {
                 $d->init_draft_nav($_POST['refresh']);
             }
             $d->save();
             $this->redirect('/drafts');
         } else {
             // error
         }
     } else {
         if ($this->method == 'delete' && isset($_POST['theme'])) {
             $d = new Draft();
             $d->where('path', $_POST['theme'])->get();
             if ($d->exists()) {
                 $d->delete();
             }
             exit;
         }
     }
     $final = array();
     $d = new Draft();
     $drafts = $d->get_iterated();
     foreach ($drafts as $d) {
         if (isset($themes[$d->path])) {
             $final[] = array('id' => $d->id, 'theme' => $themes[$d->path], 'published' => (bool) $d->current, 'active' => (bool) $d->draft, 'created_on' => (int) $d->created_on, 'modified_on' => (int) $d->modified_on);
         }
     }
     $this->set_response_data($final);
 }
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:41,代码来源:drafts.php

示例2: index

 function index()
 {
     list($params, $id) = $this->parse_params(func_get_args());
     $site = new Setting();
     $site->like('name', 'site_%')->or_like('name', 'image_%')->get_iterated();
     $draft = new Draft();
     $data = array();
     $ds = DIRECTORY_SEPARATOR;
     $template_path = FCPATH . 'storage' . $ds . 'themes' . $ds;
     $defaults = json_decode(file_get_contents(FCPATH . 'app' . $ds . 'site' . $ds . 'defaults.json'), true);
     $default_template_path = FCPATH . 'app' . $ds . 'site' . $ds . 'themes' . $ds;
     $pulse_base = FCPATH . 'app' . $ds . 'site' . $ds . 'themes' . $ds . 'common' . $ds . 'js' . $ds . 'pulse.json';
     $user = new User();
     $user->get();
     if (isset($params['preview'])) {
         $theme_root = $template_path . $params['preview'] . $ds;
         $template_info = json_decode(file_get_contents($theme_root . 'info.json'), true);
         if (!$template_info) {
             $this->set_response_data(array('error' => 'Unable to parse the info.json file for this theme.'));
             return;
         }
         $p = new Draft();
         $p->path = $params['preview'];
         $p->init_draft_nav();
         $draft->data = json_decode($p->data, true);
     } else {
         if (isset($params['draft'])) {
             $draft->where('draft', 1);
         } else {
             $draft->where('current', 1);
         }
         $draft->get();
         if ($draft->exists()) {
             $theme_root = $template_path . $draft->path . $ds;
             $template_info = json_decode(file_get_contents($theme_root . 'info.json'), true);
             if (!$template_info) {
                 $this->set_response_data(array('error' => 'Unable to parse the info.json file for this theme.'));
                 return;
             }
             $is_live = $draft->current && $draft->data === $draft->live_data;
             $template_info['published'] = $is_live;
             $draft->data = json_decode(isset($params['draft']) ? $draft->data : $draft->live_data, true);
         } else {
             $this->error('404', 'Draft not found.');
             return;
         }
     }
     foreach ($defaults['templates'] as $path => $info) {
         if (!file_exists($theme_root . $path . '.lens') && !file_exists($default_template_path . $path . '.lens')) {
             unset($defaults['templates'][$path]);
         }
     }
     foreach ($defaults['routes'] as $url => $info) {
         if (!isset($defaults['templates'][$info['template']])) {
             unset($defaults['routes'][$url]);
         }
     }
     if (isset($template_info['routes'])) {
         $template_info['routes'] = array_merge_custom($defaults['routes'], $template_info['routes']);
     } else {
         $template_info['routes'] = $defaults['routes'];
     }
     if (isset($template_info['templates'])) {
         $template_info['templates'] = array_merge_custom($defaults['templates'], $template_info['templates']);
     } else {
         $template_info['templates'] = $defaults['templates'];
     }
     $files = scandir($theme_root);
     foreach ($files as $file) {
         $info = pathinfo($file);
         if (isset($info['extension']) && $info['extension'] === 'lens' && $info['filename'] !== 'error' && !isset($template_info['templates'][$info['filename']])) {
             $template_info['templates'][$info['filename']] = array('name' => ucfirst(preg_replace('/[^a-z0-9]/', ' ', strtolower($info['filename']))));
         }
     }
     if (isset($template_info['styles'])) {
         if (isset($draft->data['settings']['__style']) && isset($template_info['styles'][$draft->data['settings']['__style']])) {
             $key = $draft->data['settings']['__style'];
         } else {
             $key = $draft->data['settings']['__style'] = array_shift(array_keys($template_info['styles']));
         }
         $template_info['style'] = array_merge(array('key' => $key), $template_info['styles'][$key]);
         $styles = array();
         foreach ($template_info['styles'] as $key => $opts) {
             $styles[] = array_merge(array('key' => $key), $opts);
         }
         $template_info['styles'] = $styles;
     } else {
         $template_info['styles'] = array();
     }
     if ($this->method == 'get') {
         list($data['urls'], $data['url_data'], $routes) = $draft->setup_urls($theme_root);
         if (isset($params['draft'])) {
             function get_live_updates($file, $draft, &$functions)
             {
                 if (file_exists($file)) {
                     // Strip comments so they don't confuse the parser
                     $contents = preg_replace('/\\/\\*.*?\\*\\//si', '', file_get_contents($file));
                     preg_match_all('/@import\\surl\\(.*\\[?\\$([a-z_0-9]+)\\]?.*\\);/', $contents, $imports);
                     foreach ($imports[1] as $setting) {
                         if (!isset($functions[$setting])) {
//.........这里部分代码省略.........
开发者ID:Caldis,项目名称:htdocs,代码行数:101,代码来源:sites.php


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