本文整理汇总了PHP中PageManager::resolvePagePath方法的典型用法代码示例。如果您正苦于以下问题:PHP PageManager::resolvePagePath方法的具体用法?PHP PageManager::resolvePagePath怎么用?PHP PageManager::resolvePagePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageManager
的用法示例。
在下文中一共展示了PageManager::resolvePagePath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __actionEdit
public function __actionEdit()
{
if ($this->_context[0] != 'new' && !($page_id = (int) $this->_context[1])) {
redirect(SYMPHONY_URL . '/blueprints/pages/');
}
$parent_link_suffix = NULL;
if (isset($_REQUEST['parent']) && is_numeric($_REQUEST['parent'])) {
$parent_link_suffix = '?parent=' . $_REQUEST['parent'];
}
if (@array_key_exists('delete', $_POST['action'])) {
$this->__actionDelete($page_id, SYMPHONY_URL . '/blueprints/pages/' . $parent_link_suffix);
}
if (@array_key_exists('save', $_POST['action'])) {
$fields = $_POST['fields'];
$this->_errors = array();
$autogenerated_handle = false;
if (!isset($fields['title']) || trim($fields['title']) == '') {
$this->_errors['title'] = __('This is a required field');
}
if (trim($fields['type']) != '' && preg_match('/(index|404|403)/i', $fields['type'])) {
$types = preg_split('/\\s*,\\s*/', strtolower($fields['type']), -1, PREG_SPLIT_NO_EMPTY);
if (in_array('index', $types) && PageManager::hasPageTypeBeenUsed($page_id, 'index')) {
$this->_errors['type'] = __('An index type page already exists.');
} elseif (in_array('404', $types) && PageManager::hasPageTypeBeenUsed($page_id, '404')) {
$this->_errors['type'] = __('A 404 type page already exists.');
} elseif (in_array('403', $types) && PageManager::hasPageTypeBeenUsed($page_id, '403')) {
$this->_errors['type'] = __('A 403 type page already exists.');
}
}
if (trim($fields['handle']) == '') {
$fields['handle'] = $fields['title'];
$autogenerated_handle = true;
}
$fields['handle'] = PageManager::createHandle($fields['handle']);
if (empty($fields['handle']) && !isset($this->_errors['title'])) {
$this->_errors['handle'] = __('Please ensure handle contains at least one Latin-based character.');
}
/**
* Just after the Symphony validation has run, allows Developers
* to run custom validation logic on a Page
*
* @delegate PagePostValidate
* @since Symphony 2.2
* @param string $context
* '/blueprints/pages/'
* @param array $fields
* The `$_POST['fields']` array. This should be read-only and not changed
* through this delegate.
* @param array $errors
* An associative array of errors, with the key matching a key in the
* `$fields` array, and the value being the string of the error. `$errors`
* is passed by reference.
*/
Symphony::ExtensionManager()->notifyMembers('PagePostValidate', '/blueprints/pages/', array('fields' => $fields, 'errors' => &$errors));
if (empty($this->_errors)) {
$autogenerated_handle = false;
if ($fields['params']) {
$fields['params'] = trim(preg_replace('@\\/{2,}@', '/', $fields['params']), '/');
}
// Clean up type list
$types = preg_split('/\\s*,\\s*/', $fields['type'], -1, PREG_SPLIT_NO_EMPTY);
$types = @array_map('trim', $types);
unset($fields['type']);
$fields['parent'] = $fields['parent'] != __('None') ? $fields['parent'] : null;
$fields['data_sources'] = is_array($fields['data_sources']) ? implode(',', $fields['data_sources']) : NULL;
$fields['events'] = is_array($fields['events']) ? implode(',', $fields['events']) : NULL;
$fields['path'] = null;
if ($fields['parent']) {
$fields['path'] = PageManager::resolvePagePath((int) $fields['parent']);
}
// Check for duplicates:
$current = PageManager::fetchPageByID($page_id);
if (empty($current)) {
$fields['sortorder'] = PageManager::fetchNextSortOrder();
}
$where = array();
if (!empty($current)) {
$where[] = "p.id != {$page_id}";
}
$where[] = "p.handle = '" . $fields['handle'] . "'";
$where[] = is_null($fields['path']) ? "p.path IS NULL" : "p.path = '" . $fields['path'] . "'";
$duplicate = PageManager::fetch(false, array('*'), $where);
// If duplicate
if (!empty($duplicate)) {
if ($autogenerated_handle) {
$this->_errors['title'] = __('A page with that title already exists');
} else {
$this->_errors['handle'] = __('A page with that handle already exists');
}
} else {
// New page?
if (empty($current)) {
$file_created = PageManager::createPageFiles($fields['path'], $fields['handle']);
} else {
$file_created = PageManager::createPageFiles($fields['path'], $fields['handle'], $current['path'], $current['handle']);
}
// If the file wasn't created, it's usually permissions related
if (!$file_created) {
$redirect = null;
return $this->pageAlert(__('Page Template could not be written to disk.') . ' ' . __('Please check permissions on %s.', array('<code>/workspace/pages</code>')), Alert::ERROR);
//.........这里部分代码省略.........
示例2: __viewIndexDSPages
public function __viewIndexDSPages($context)
{
$pages = PageManager::fetch(false, array(), array(), 'sortorder ASC');
$options = array();
foreach ($pages as $page) {
$selected = $this->driver->isDSPageSelected($page['id']);
$options[] = array($page['id'], $selected, '/' . PageManager::resolvePagePath($page['id']));
}
$section = Widget::Label(__('Excluded Pages'));
$section->setAttribute('class', 'column');
$section->appendChild(Widget::Select('settings[ds-pages][]', $options, array('multiple' => 'multiple')));
$context->appendChild($section);
}
示例3: render
/**
* The render function will take a `FrontendPageNotFoundException` Exception and
* output a HTML page. This function first checks to see if their is a page in Symphony
* that has been given the '404' page type, otherwise it will just use the default
* Symphony error page template to output the exception
*
* @param FrontendPageNotFoundException $e
* The Exception object
* @return string
* An HTML string
*/
public static function render(Exception $e)
{
$page = PageManager::fetchPageByType('404');
if (is_null($page['id'])) {
parent::render(new SymphonyErrorPage($e->getMessage(), __('Page Not Found'), 'generic', array('header' => 'HTTP/1.0 404 Not Found')));
} else {
$url = '/' . PageManager::resolvePagePath($page['id']) . '/';
$output = Frontend::instance()->display($url);
header(sprintf('Content-Length: %d', strlen($output)));
echo $output;
exit;
}
}
示例4: __viewEdit
public function __viewEdit()
{
$isNew = true;
$time = Widget::Time();
// Verify role exists
if ($this->_context[0] == 'edit') {
$isNew = false;
if (!($role_id = $this->_context[1])) {
redirect(extension_Members::baseURL() . 'roles/');
}
if (!($existing = RoleManager::fetch($role_id))) {
throw new SymphonyErrorPage(__('The role you requested to edit does not exist.'), __('Role not found'));
}
}
// Add in custom assets
Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/members/assets/members.roles.css', 'screen', 101);
Administration::instance()->Page->addScriptToHead(URL . '/extensions/members/assets/members.roles.js', 104);
// Append any Page Alerts from the form's
if (isset($this->_context[2])) {
switch ($this->_context[2]) {
case 'saved':
$this->pageAlert(__('Role updated at %s.', array($time->generate())) . ' <a href="' . extension_members::baseURL() . 'roles/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . extension_members::baseURL() . 'roles/" accesskey="a">' . __('View all Roles') . '</a>', Alert::SUCCESS);
break;
case 'created':
$this->pageAlert(__('Role created at %s.', array($time->generate())) . ' <a href="' . extension_members::baseURL() . 'roles/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . extension_members::baseURL() . 'roles/" accesskey="a">' . __('View all Roles') . '</a>', Alert::SUCCESS);
break;
}
}
// Has the form got any errors?
$formHasErrors = is_array($this->_errors) && !empty($this->_errors);
if ($formHasErrors) {
$this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR);
}
$this->setPageType('form');
if ($isNew) {
$this->setTitle(__('Symphony – Member Roles'));
$this->appendSubheading(__('Untitled'));
$fields = array('name' => null, 'permissions' => null, 'page_access' => null);
} else {
$this->setTitle(__('Symphony – Member Roles – ') . $existing->get('name'));
$this->appendSubheading($existing->get('name'));
if (isset($_POST['fields'])) {
$fields = $_POST['fields'];
} else {
$fields = array('name' => $existing->get('name'), 'permissions' => $existing->get('event_permissions'), 'page_access' => $existing->get('forbidden_pages'));
}
}
$this->insertBreadcrumbs(array(Widget::Anchor(__('Member Roles'), extension_members::baseURL() . 'roles/')));
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings type-file');
$fieldset->appendChild(new XMLElement('legend', __('Essentials')));
$label = Widget::Label(__('Name'));
$label->appendChild(Widget::Input('fields[name]', General::sanitize($fields['name'])));
if (isset($this->_errors['name'])) {
$fieldset->appendChild(Widget::Error($label, $this->_errors['name']));
} else {
$fieldset->appendChild($label);
}
$this->Form->appendChild($fieldset);
$events = EventManager::listAll();
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings type-file');
$fieldset->appendChild(new XMLElement('legend', __('Event Level Permissions')));
$aTableBody = array();
if (is_array($events) && !empty($events)) {
foreach ($events as $event_handle => $event) {
$permissions = $fields['permissions'][$event_handle];
$td_name = Widget::TableData($event['name'], 'name');
$td_permission_create = Widget::TableData(sprintf('<label title="%s">%s <span>%s</span></label>', __('User can create new entries'), Widget::Input("fields[permissions][{$event_handle}][create]", (string) EventPermissions::CREATE, 'checkbox', $permissions['create'] == EventPermissions::CREATE ? array('checked' => 'checked') : NULL)->generate(), 'Create'), 'create');
$td_permission_none = Widget::TableData(sprintf('<label title="%s">%s <span>%s</span></label>', __('User cannot edit existing entries'), Widget::Input("fields[permissions][{$event_handle}][edit]", (string) EventPermissions::NO_PERMISSIONS, 'radio', $permissions['edit'] == EventPermissions::NO_PERMISSIONS ? array('checked' => 'checked') : NULL)->generate(), 'None'));
$td_permission_own = Widget::TableData(sprintf('<label title="%s">%s <span>%s</span></label>', __('User can edit their own entries only'), Widget::Input("fields[permissions][{$event_handle}][edit]", (string) EventPermissions::OWN_ENTRIES, 'radio', $permissions['edit'] == EventPermissions::OWN_ENTRIES ? array('checked' => 'checked') : NULL)->generate(), 'Own'));
$td_permission_all = Widget::TableData(sprintf('<label title="%s">%s <span>%s</span></label>', __('User can edit all entries'), Widget::Input("fields[permissions][{$event_handle}][edit]", (string) EventPermissions::ALL_ENTRIES, 'radio', $permissions['edit'] == EventPermissions::ALL_ENTRIES ? array('checked' => 'checked') : NULL)->generate(), 'All'));
// Create an Event instance
$ev = EventManager::create($event_handle, array());
$aTableBody[] = Widget::TableRow(array($td_name, $td_permission_create, $td_permission_none, $td_permission_own, $td_permission_all), method_exists($ev, 'ignoreRolePermissions') && $ev->ignoreRolePermissions() == true ? 'inactive' : '');
unset($ev);
}
}
$thead = Widget::TableHead(array(array(__('Event'), 'col', array('class' => 'name')), array(__('Create New'), 'col', array('class' => 'new', 'title' => __('Toggle all'))), array(__('No Edit'), 'col', array('class' => 'edit', 'title' => __('Toggle all'))), array(__('Edit Own'), 'col', array('class' => 'edit', 'title' => __('Toggle all'))), array(__('Edit All'), 'col', array('class' => 'edit', 'title' => __('Toggle all')))));
$table = Widget::Table($thead, NULL, Widget::TableBody($aTableBody), 'role-permissions');
$fieldset->appendChild($table);
$this->Form->appendChild($fieldset);
// Add Page Permissions [simple Deny/Allow]
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings type-file');
$fieldset->appendChild(new XMLElement('legend', __('Page Level Permissions')));
$label = Widget::Label(__('Deny Access'));
if (!is_array($fields['page_access'])) {
$fields['page_access'] = array();
}
$options = array();
$pages = PageManager::fetch(false, array('id'));
if (!empty($pages)) {
foreach ($pages as $page) {
$options[] = array($page['id'], in_array($page['id'], $fields['page_access']), '/' . PageManager::resolvePagePath($page['id']));
}
}
$label->appendChild(Widget::Select('fields[page_access][]', $options, array('multiple' => 'multiple')));
$fieldset->appendChild($label);
$this->Form->appendChild($fieldset);
//.........这里部分代码省略.........
示例5: render
/**
* The render function will take a `FrontendPageNotFoundException` Exception and
* output a HTML page. This function first checks to see if their is a page in Symphony
* that has been given the '404' page type, otherwise it will just use the default
* Symphony error page template to output the exception
*
* @param Exception $e
* The Exception object
* @throws FrontendPageNotFoundException
* @throws SymphonyErrorPage
* @return string
* An HTML string
*/
public static function render(Exception $e)
{
$page = PageManager::fetchPageByType('404');
$previous_exception = Frontend::instance()->getException();
// No 404 detected, throw default Symphony error page
if (is_null($page['id'])) {
parent::render(new SymphonyErrorPage($e->getMessage(), __('Page Not Found'), 'generic', array(), Page::HTTP_STATUS_NOT_FOUND));
// Recursive 404
} elseif (isset($previous_exception)) {
parent::render(new SymphonyErrorPage(__('This error occurred whilst attempting to resolve the 404 page for the original request.') . ' ' . $e->getMessage(), __('Page Not Found'), 'generic', array(), Page::HTTP_STATUS_NOT_FOUND));
// Handle 404 page
} else {
$url = '/' . PageManager::resolvePagePath($page['id']) . '/';
Frontend::instance()->setException($e);
$output = Frontend::instance()->display($url);
echo $output;
exit;
}
}