本文整理汇总了PHP中PageManager::createPageFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP PageManager::createPageFiles方法的具体用法?PHP PageManager::createPageFiles怎么用?PHP PageManager::createPageFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageManager
的用法示例。
在下文中一共展示了PageManager::createPageFiles方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editPageChildren
/**
* This function will update all children of a particular page (if any)
* by renaming/moving all related files to their new path and updating
* their database information. This is a recursive function and will work
* to any depth.
*
* @param integer $page_id
* The ID of the Page whose children need to be updated
* @param string $page_path
* The path of the Page, which is the handles of the Page parents. If the
* page has multiple parents, they will be separated by a forward slash.
* eg. article/read. If a page has no parents, this parameter should be null.
* @return boolean
*/
public static function editPageChildren($page_id = null, $page_path = null)
{
if (!is_int($page_id)) {
return false;
}
$page_path = trim($page_path, '/');
$children = PageManager::fetchChildPages($page_id);
foreach ($children as $child) {
$child_id = $child['id'];
$fields = array('path' => $page_path);
if (!PageManager::createPageFiles($page_path, $child['handle'], $child['path'], $child['handle'])) {
$success = false;
}
if (!PageManager::edit($child_id, $fields)) {
$success = false;
}
self::editPageChildren($child_id, $page_path . '/' . $child['handle']);
}
return $success;
}
示例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');
}
} 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);
//.........这里部分代码省略.........