本文整理汇总了PHP中Draft::setup_urls方法的典型用法代码示例。如果您正苦于以下问题:PHP Draft::setup_urls方法的具体用法?PHP Draft::setup_urls怎么用?PHP Draft::setup_urls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Draft
的用法示例。
在下文中一共展示了Draft::setup_urls方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: form_urls
public function form_urls()
{
if ($this->urls) {
return $this->urls;
}
$d = new Draft();
$context = defined('DRAFT_CONTEXT') ? DRAFT_CONTEXT : false;
$path = '';
if (!$context) {
$d->where('current', 1)->get();
$path = $d->path;
} else {
if (is_numeric(DRAFT_CONTEXT)) {
$d->get_by_id(DRAFT_CONTEXT);
$path = $d->path;
} else {
$path = DRAFT_CONTEXT;
}
}
list($this->urls, $this->url_data, , $this->segments) = $d->setup_urls(FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR);
return $this->urls;
}
示例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])) {
//.........这里部分代码省略.........