本文整理汇总了PHP中PageManager::hasPageTypeBeenUsed方法的典型用法代码示例。如果您正苦于以下问题:PHP PageManager::hasPageTypeBeenUsed方法的具体用法?PHP PageManager::hasPageTypeBeenUsed怎么用?PHP PageManager::hasPageTypeBeenUsed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageManager
的用法示例。
在下文中一共展示了PageManager::hasPageTypeBeenUsed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: typeUsed
/**
* Returns boolean if a the given `$type` is set for
* the given `$page_id`.
*
* @deprecated This will be removed in Symphony 2.4.
* The preferred function is `PageManger::hasPageTypeBeenUsed`
* @see toolkit.PageManager#hasPageTypeBeenUsed
* @param integer $page_id
* The ID of the Page to check
* @param string $type
* @return boolean
* True if the type is used, false otherwise
*/
public static function typeUsed($page_id, $type)
{
return PageManager::hasPageTypeBeenUsed($page_id, $type);
}
示例2: __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');
}
// Create or move files:
} else {
// New page?
if (empty($current)) {
$file_created = PageManager::createPageFiles($fields['path'], $fields['handle']);
// Existing page, potentially rename files
} 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) {
//.........这里部分代码省略.........