protected function process() { global $core; $record = null; $oldurl = null; if ($this->record) { $record = $this->record; $pattern = $record->url_pattern; if (!Pattern::is_pattern($pattern)) { $oldurl = $pattern; } } $rc = parent::process(); $nid = $rc['key']; # # update contents # /* var $contents_model ContentModel */ $preserve = array(); $contents_model = $this->module->model('contents'); $contents = $this->request['contents']; $editor_ids = $this->request['editors']; if ($contents && $editor_ids) { foreach ($contents as $content_id => $unserialized_content) { if (!$unserialized_content) { continue; } $editor_id = $editor_ids[$content_id]; $editor = $core->editors[$editor_id]; $content = $editor->serialize($unserialized_content); if (!$content) { continue; } $preserve[$content_id] = $content_id; $values = array('content' => $content, 'editor' => $editor_id); $contents_model->insert(array('pageid' => $nid, 'contentid' => $content_id) + $values, array('on duplicate' => $values)); } } # # we delete possible remaining content for the page # $arr = $contents_model->filter_by_pageid($nid); if ($preserve) { $arr->where(array('!contentid' => $preserve)); } $arr->delete(); if ($record && $oldurl) { $record = $this->module->model[$nid]; $newurl = $record->url; if ($newurl && $newurl != $oldurl) { new Page\MoveEvent($record, $oldurl, $newurl); } } return $rc; }
/** * Returns the URL of a view. * * @param Site $site * @param string $view_id The identifier of the view. * @param array|null $args The arguments to format the URL, if the URL uses a pattern. * * @return string * @throws \Exception */ public static function resolve_view_url(Site $site, $view_id, $args = null) { if (isset(self::$view_url_cache[$view_id])) { return self::$view_url_cache[$view_id]; } $target = $site->resolve_view_target($view_id); if (!$target) { return '#unknown-target-for-view-' . $view_id; } $url_pattern = $target->url_pattern; if (!Pattern::is_pattern($url_pattern)) { return self::$view_url_cache[$view_id] = $target->url; } return Pattern::from($url_pattern)->format($args); }
/** * Returns the URL of the page. * * @return string */ protected function get_url() { global $core; if ($this->location) { return $this->location->url; } $url_pattern = $this->url_pattern; if ($this->is_home) { return $url_pattern; } $url = null; if (Pattern::is_pattern($url_pattern)) { if ($this->url_variables) { $url = Pattern::from($url_pattern)->format($this->url_variables); // \ICanBoogie\log('URL %pattern rescued using URL variables', array('%pattern' => $pattern)); } else { $page = isset($core->request->context->page) ? $core->request->context->page : null; if ($page && $page->url_variables) { $url = Pattern::from($url_pattern)->format($page->url_variables); // \ICanBoogie\log("URL pattern %pattern was resolved using current page's variables", array('%pattern' => $pattern)); } else { $url = '#url-pattern-could-not-be-resolved'; } } } else { $url = $url_pattern; } return $url; }
public function render_cell($record) { global $core; $t = $this->manager->t; $options = $this->manager->options; $pattern = $record->url_pattern; if ($options->search || $options->filters) { if (Pattern::is_pattern($pattern)) { return; } $url = $record->url; // DIRTY-20100507 if ($record->location) { $location = $record->location; $title = $t('This page is redirected to: !title (!url)', array('!title' => $location->title, '!url' => $location->url)); return <<<EOT <span class="small"> <i class="icon-mail-forward" title="{$title}"></i> <a href="{$url}">{$url}</a> </span> EOT; } return <<<EOT <span class="small"><a href="{$url}">{$url}</a></span> EOT; } $rc = ''; $location = $record->location; if ($location) { $rc .= '<span class="icon-mail-forward" title="' . $t('This page is redirected to: !title (!url)', array('!title' => $location->title, '!url' => $location->url)) . '"></span>'; } else { if (!Pattern::is_pattern($pattern)) { $url = $core->site_id == $record->siteid ? $record->url : $record->absolute_url; $title = $t('Go to the page: !url', array('!url' => $url)); $rc .= '<a href="' . $url . '" title="' . $title . '" target="_blank"><i class="icon-external-link"></i></a>'; } } return $rc; }