當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Draft::get方法代碼示例

本文整理匯總了PHP中Draft::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP Draft::get方法的具體用法?PHP Draft::get怎麽用?PHP Draft::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Draft的用法示例。


在下文中一共展示了Draft::get方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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::get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。