本文整理汇总了PHP中PageManager::edit方法的典型用法代码示例。如果您正苦于以下问题:PHP PageManager::edit方法的具体用法?PHP PageManager::edit怎么用?PHP PageManager::edit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageManager
的用法示例。
在下文中一共展示了PageManager::edit方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updatePagesOfPrototype
public static function updatePagesOfPrototype($prototype_id, $types)
{
if (empty($prototype_id)) {
return;
}
$prototype = PageManager::fetchPageByID($prototype_id);
$pages = self::fetchPagesOfPrototype($prototype_id);
$fields = array();
if (is_array($pages) && !empty($pages)) {
foreach ($pages as $page) {
$fields['params'] = $prototype['params'];
$fields['events'] = $prototype['events'];
$fields['data_sources'] = $prototype['data_sources'];
PageManager::edit($page['id'], $fields, true);
PageManager::addPageTypesToPage($page['id'], array_values(array_diff($types, array('prototype'))));
}
}
}
示例2: view
public function view()
{
$items = $_REQUEST['items'];
if (!is_array($items) || empty($items)) {
return;
}
$destination = self::kREORDER_UNKNOWN;
if ($this->_context[0] == 'blueprints' && $this->_context[1] == 'pages') {
$destination = self::kREORDER_PAGES;
} elseif ($this->_context[0] == 'blueprints' && $this->_context[1] == 'sections') {
$destination = self::kREORDER_SECTIONS;
} elseif ($this->_context[0] == 'extensions') {
$destination = self::kREORDER_EXTENSION;
}
switch ($destination) {
case self::kREORDER_PAGES:
foreach ($items as $id => $position) {
if (!PageManager::edit($id, array('sortorder' => $position))) {
$this->setHttpStatus(self::HTTP_STATUS_ERROR);
$this->_Result->setValue(__('A database error occurred while attempting to reorder.'));
break;
}
}
break;
case self::kREORDER_SECTIONS:
foreach ($items as $id => $position) {
if (!SectionManager::edit($id, array('sortorder' => $position))) {
$this->setHttpStatus(self::HTTP_STATUS_ERROR);
$this->_Result->setValue(__('A database error occurred while attempting to reorder.'));
break;
}
}
break;
case self::kREORDER_EXTENSION:
// TODO
break;
case self::kREORDER_UNKNOWN:
default:
$this->setHttpStatus(self::HTTP_STATUS_BAD_REQUEST);
break;
}
}
示例3: 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;
}
示例4: __formAction
public function __formAction()
{
$fields = $_POST['fields'];
$this->_errors = array();
$providers = Symphony::ExtensionManager()->getProvidersOf(iProvider::EVENT);
$providerClass = null;
if (trim($fields['name']) == '') {
$this->_errors['name'] = __('This is a required field');
}
if (trim($fields['source']) == '') {
$this->_errors['source'] = __('This is a required field');
}
$filters = isset($fields['filters']) ? $fields['filters'] : array();
// See if a Provided Datasource is saved
if (!empty($providers)) {
foreach ($providers as $providerClass => $provider) {
if ($fields['source'] == call_user_func(array($providerClass, 'getSource'))) {
call_user_func_array(array($providerClass, 'validate'), array(&$fields, &$this->_errors));
break;
}
unset($providerClass);
}
}
$classname = Lang::createHandle($fields['name'], 255, '_', false, true, array('@^[^a-z\\d]+@i' => '', '/[^\\w-\\.]/i' => ''));
$rootelement = str_replace('_', '-', $classname);
$extends = 'SectionEvent';
// Check to make sure the classname is not empty after handlisation.
if (empty($classname) && !isset($this->_errors['name'])) {
$this->_errors['name'] = __('Please ensure name contains at least one Latin-based character.', array($classname));
}
$file = EVENTS . '/event.' . $classname . '.php';
$isDuplicate = false;
$queueForDeletion = null;
if ($this->_context[0] == 'new' && is_file($file)) {
$isDuplicate = true;
} elseif ($this->_context[0] == 'edit') {
$existing_handle = $this->_context[1];
if ($classname != $existing_handle && is_file($file)) {
$isDuplicate = true;
} elseif ($classname != $existing_handle) {
$queueForDeletion = EVENTS . '/event.' . $existing_handle . '.php';
}
}
// Duplicate
if ($isDuplicate) {
$this->_errors['name'] = __('An Event with the name %s already exists', array('<code>' . $classname . '</code>'));
}
if (empty($this->_errors)) {
$multiple = in_array('expect-multiple', $filters);
$elements = null;
$placeholder = '<!-- GRAB -->';
$source = $fields['source'];
$params = array('rootelement' => $rootelement);
$about = array('name' => $fields['name'], 'version' => 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), 'release date' => DateTimeObj::getGMT('c'), 'author name' => Symphony::Author()->getFullName(), 'author website' => URL, 'author email' => Symphony::Author()->get('email'));
// If there is a provider, get their template
if ($providerClass) {
$eventShell = file_get_contents(call_user_func(array($providerClass, 'getTemplate')));
} else {
$eventShell = file_get_contents($this->getTemplate('blueprints.event'));
$about['trigger condition'] = $rootelement;
}
$this->__injectAboutInformation($eventShell, $about);
// Replace the name
$eventShell = str_replace('<!-- CLASS NAME -->', $classname, $eventShell);
// Build the templates
if ($providerClass) {
$eventShell = call_user_func(array($providerClass, 'prepare'), $fields, $params, $eventShell);
} else {
$this->__injectFilters($eventShell, $filters);
// Add Documentation
require_once CONTENT . '/content.ajaxeventdocumentation.php';
$ajaxEventDoc = new contentAjaxEventDocumentation();
$documentation = null;
$doc_parts = array();
// Add Documentation (Success/Failure)
$ajaxEventDoc->addEntrySuccessDoc($doc_parts, $rootelement, $fields['source'], $filters);
$ajaxEventDoc->addEntryFailureDoc($doc_parts, $rootelement, $fields['source'], $filters);
// Filters
$ajaxEventDoc->addDefaultFiltersDoc($doc_parts, $rootelement, $fields['source'], $filters);
// Frontend Markup
$ajaxEventDoc->addFrontendMarkupDoc($doc_parts, $rootelement, $fields['source'], $filters);
$ajaxEventDoc->addSendMailFilterDoc($doc_parts, $rootelement, $fields['source'], $filters);
/**
* Allows adding documentation for new filters. A reference to the $documentation
* array is provided, along with selected filters
* @delegate AppendEventFilterDocumentation
* @param string $context
* '/blueprints/events/(edit|new|info)/'
* @param array $selected
* An array of all the selected filters for this Event
* @param array $documentation
* An array of all the documentation XMLElements, passed by reference
*/
Symphony::ExtensionManager()->notifyMembers('AppendEventFilterDocumentation', '/blueprints/events/' . $rootelement . '/', array('selected' => $filters, 'documentation' => &$doc_parts));
$documentation = join(PHP_EOL, array_map(create_function('$x', 'return rtrim($x->generate(true, 4));'), $doc_parts));
$documentation = str_replace('\'', '\\\'', $documentation);
$eventShell = str_replace('<!-- CLASS EXTENDS -->', $extends, $eventShell);
$eventShell = str_replace('<!-- DOCUMENTATION -->', General::tabsToSpaces($documentation, 4), $eventShell);
}
$eventShell = str_replace('<!-- ROOT ELEMENT -->', $rootelement, $eventShell);
//.........这里部分代码省略.........
示例5: detach
/**
* Given a resource type, a handle and a page, this function detaches
* the given handle (which represents either a datasource or event) to that page.
*
* @param integer $type
* The resource type, either `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DS`
* @param string $r_handle
* The handle of the resource.
* @param integer $page_id
* The ID of the page.
*/
public static function detach($type, $r_handle, $page_id)
{
$col = self::getColumnFromType($type);
$pages = PageManager::fetch(false, array($col), array(sprintf('`id` = %d', $page_id)));
if (is_array($pages) && count($pages) == 1) {
$result = $pages[0][$col];
$values = explode(',', $result);
$idx = array_search($r_handle, $values, false);
if ($idx !== false) {
array_splice($values, $idx, 1);
$result = implode(',', $values);
return PageManager::edit($page_id, array($col => MySQL::cleanValue($result)));
}
}
return false;
}
示例6: __formAction
public function __formAction()
{
$fields = $_POST['fields'];
$this->_errors = array();
$providers = Symphony::ExtensionManager()->getProvidersOf(iProvider::DATASOURCE);
$providerClass = null;
if (trim($fields['name']) == '') {
$this->_errors['name'] = __('This is a required field');
}
if ($fields['source'] == 'static_xml') {
if (trim($fields['static_xml']) == '') {
$this->_errors['static_xml'] = __('This is a required field');
} else {
$xml_errors = null;
include_once TOOLKIT . '/class.xsltprocess.php';
General::validateXML($fields['static_xml'], $xml_errors, false, new XsltProcess());
if (!empty($xml_errors)) {
$this->_errors['static_xml'] = __('XML is invalid.');
}
}
} elseif (is_numeric($fields['source'])) {
if (strlen(trim($fields['max_records'])) == 0 || is_numeric($fields['max_records']) && $fields['max_records'] < 1) {
if ($fields['paginate_results'] === 'yes') {
$this->_errors['max_records'] = __('A result limit must be set');
}
} elseif (!self::__isValidPageString($fields['max_records'])) {
$this->_errors['max_records'] = __('Must be a valid number or parameter');
}
if (strlen(trim($fields['page_number'])) == 0 || is_numeric($fields['page_number']) && $fields['page_number'] < 1) {
if ($fields['paginate_results'] === 'yes') {
$this->_errors['page_number'] = __('A page number must be set');
}
} elseif (!self::__isValidPageString($fields['page_number'])) {
$this->_errors['page_number'] = __('Must be a valid number or parameter');
}
// See if a Provided Datasource is saved
} elseif (!empty($providers)) {
foreach ($providers as $providerClass => $provider) {
if ($fields['source'] == call_user_func(array($providerClass, 'getSource'))) {
call_user_func_array(array($providerClass, 'validate'), array(&$fields, &$this->_errors));
break;
}
unset($providerClass);
}
}
$classname = Lang::createHandle($fields['name'], 255, '_', false, true, array('@^[^a-z\\d]+@i' => '', '/[^\\w-\\.]/i' => ''));
$rootelement = str_replace('_', '-', $classname);
// Check to make sure the classname is not empty after handlisation.
if (empty($classname) && !isset($this->_errors['name'])) {
$this->_errors['name'] = __('Please ensure name contains at least one Latin-based character.', array($classname));
}
$file = DATASOURCES . '/data.' . $classname . '.php';
$isDuplicate = false;
$queueForDeletion = null;
if ($this->_context[0] == 'new' && is_file($file)) {
$isDuplicate = true;
} elseif ($this->_context[0] == 'edit') {
$existing_handle = $this->_context[1];
if ($classname != $existing_handle && is_file($file)) {
$isDuplicate = true;
} elseif ($classname != $existing_handle) {
$queueForDeletion = DATASOURCES . '/data.' . $existing_handle . '.php';
}
}
// Duplicate
if ($isDuplicate) {
$this->_errors['name'] = __('A Data source with the name %s already exists', array('<code>' . $classname . '</code>'));
}
if (empty($this->_errors)) {
$filters = array();
$elements = null;
$source = $fields['source'];
$params = array('rootelement' => $rootelement);
$about = array('name' => $fields['name'], 'version' => 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), 'release date' => DateTimeObj::getGMT('c'), 'author name' => Symphony::Author()->getFullName(), 'author website' => URL, 'author email' => Symphony::Author()->get('email'));
// If there is a provider, get their template
if ($providerClass) {
$dsShell = file_get_contents(call_user_func(array($providerClass, 'getTemplate')));
} else {
$dsShell = file_get_contents($this->getTemplate('blueprints.datasource'));
}
// Author metadata
self::injectAboutInformation($dsShell, $about);
// Do dependencies, the template file must have <!-- CLASS NAME -->
$dsShell = str_replace('<!-- CLASS NAME -->', $classname, $dsShell);
// If there is a provider, let them do the prepartion work
if ($providerClass) {
$dsShell = call_user_func(array($providerClass, 'prepare'), $fields, $params, $dsShell);
} else {
switch ($source) {
case 'authors':
$extends = 'AuthorDatasource';
if (isset($fields['filter']['author'])) {
$filters = $fields['filter']['author'];
}
$elements = $fields['xml_elements'];
$params['order'] = $fields['order'];
$params['redirectonempty'] = $fields['redirect_on_empty'];
$params['redirectonforbidden'] = $fields['redirect_on_forbidden'];
$params['redirectonrequired'] = $fields['redirect_on_required'];
$params['requiredparam'] = trim($fields['required_url_param']);
//.........这里部分代码省略.........
示例7: __actionEdit
//.........这里部分代码省略.........
return $this->pageAlert(__('Page Template could not be written to disk.') . ' ' . __('Please check permissions on %s.', array('<code>/workspace/pages</code>')), Alert::ERROR);
}
// Insert the new data:
if (empty($current)) {
/**
* Just prior to creating a new Page record in `tbl_pages`, provided
* with the `$fields` associative array. Use with caution, as no
* duplicate page checks are run after this delegate has fired
*
* @delegate PagePreCreate
* @since Symphony 2.2
* @param string $context
* '/blueprints/pages/'
* @param array $fields
* The `$_POST['fields']` array passed by reference
*/
Symphony::ExtensionManager()->notifyMembers('PagePreCreate', '/blueprints/pages/', array('fields' => &$fields));
if (!($page_id = PageManager::add($fields))) {
$this->pageAlert(__('Unknown errors occurred while attempting to save.') . '<a href="' . SYMPHONY_URL . '/system/log/">' . __('Check your activity log') . '</a>.', Alert::ERROR);
} else {
/**
* Just after the creation of a new page in `tbl_pages`
*
* @delegate PagePostCreate
* @since Symphony 2.2
* @param string $context
* '/blueprints/pages/'
* @param integer $page_id
* The ID of the newly created Page
* @param array $fields
* An associative array of data that was just saved for this page
*/
Symphony::ExtensionManager()->notifyMembers('PagePostCreate', '/blueprints/pages/', array('page_id' => $page_id, 'fields' => &$fields));
$redirect = "/blueprints/pages/edit/{$page_id}/created/{$parent_link_suffix}";
}
} else {
/**
* Just prior to updating a Page record in `tbl_pages`, provided
* with the `$fields` associative array. Use with caution, as no
* duplicate page checks are run after this delegate has fired
*
* @delegate PagePreEdit
* @since Symphony 2.2
* @param string $context
* '/blueprints/pages/'
* @param integer $page_id
* The ID of the Page that is about to be updated
* @param array $fields
* The `$_POST['fields']` array passed by reference
*/
Symphony::ExtensionManager()->notifyMembers('PagePreEdit', '/blueprints/pages/', array('page_id' => $page_id, 'fields' => &$fields));
if (!PageManager::edit($page_id, $fields, true)) {
return $this->pageAlert(__('Unknown errors occurred while attempting to save.') . '<a href="' . SYMPHONY_URL . '/system/log/">' . __('Check your activity log') . '</a>.', Alert::ERROR);
} else {
/**
* Just after updating a page in `tbl_pages`
*
* @delegate PagePostEdit
* @since Symphony 2.2
* @param string $context
* '/blueprints/pages/'
* @param integer $page_id
* The ID of the Page that was just updated
* @param array $fields
* An associative array of data that was just saved for this page
*/
示例8: __formAction
public function __formAction()
{
$fields = $_POST['fields'];
$this->_errors = array();
$providers = Symphony::ExtensionManager()->getProvidersOf(iProvider::EVENT);
$providerClass = null;
if (trim($fields['name']) == '') {
$this->_errors['name'] = __('This is a required field');
}
if (trim($fields['source']) == '') {
$this->_errors['source'] = __('This is a required field');
}
$filters = isset($fields['filters']) ? $fields['filters'] : array();
// See if a Provided Datasource is saved
if (!empty($providers)) {
foreach ($providers as $providerClass => $provider) {
if ($fields['source'] == call_user_func(array($providerClass, 'getSource'))) {
call_user_func_array(array($providerClass, 'validate'), array(&$fields, &$this->_errors));
break;
}
unset($providerClass);
}
}
$classname = Lang::createHandle($fields['name'], 255, '_', false, true, array('@^[^a-z\\d]+@i' => '', '/[^\\w-\\.]/i' => ''));
$rootelement = str_replace('_', '-', $classname);
$extends = 'SectionEvent';
// Check to make sure the classname is not empty after handlisation.
if (empty($classname) && !isset($this->_errors['name'])) {
$this->_errors['name'] = __('Please ensure name contains at least one Latin-based character.', array($classname));
}
$file = EVENTS . '/event.' . $classname . '.php';
$isDuplicate = false;
$queueForDeletion = NULL;
if ($this->_context[0] == 'new' && is_file($file)) {
$isDuplicate = true;
} else {
if ($this->_context[0] == 'edit') {
$existing_handle = $this->_context[1];
if ($classname != $existing_handle && is_file($file)) {
$isDuplicate = true;
} else {
if ($classname != $existing_handle) {
$queueForDeletion = EVENTS . '/event.' . $existing_handle . '.php';
}
}
}
}
// Duplicate
if ($isDuplicate) {
$this->_errors['name'] = __('An Event with the name %s already exists', array('<code>' . $classname . '</code>'));
}
if (empty($this->_errors)) {
$multiple = in_array('expect-multiple', $filters);
$elements = NULL;
$placeholder = '<!-- GRAB -->';
$source = $fields['source'];
$params = array('rootelement' => $rootelement);
$about = array('name' => $fields['name'], 'version' => 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), 'release date' => DateTimeObj::getGMT('c'), 'author name' => Administration::instance()->Author->getFullName(), 'author website' => URL, 'author email' => Administration::instance()->Author->get('email'));
// If there is a provider, get their template
if ($providerClass) {
$eventShell = file_get_contents(call_user_func(array($providerClass, 'getTemplate')));
} else {
$eventShell = file_get_contents($this->getTemplate('blueprints.event'));
$about['trigger condition'] = $rootelement;
}
$this->__injectAboutInformation($eventShell, $about);
// Replace the name
$eventShell = str_replace('<!-- CLASS NAME -->', $classname, $eventShell);
// Build the templates
if ($providerClass) {
$eventShell = call_user_func(array($providerClass, 'prepare'), $fields, $params, $eventShell);
} else {
$this->__injectFilters($eventShell, $filters);
// Add Documentation
$documentation = NULL;
$documentation_parts = array();
$documentation_parts[] = new XMLElement('h3', __('Success and Failure XML Examples'));
$documentation_parts[] = new XMLElement('p', __('When saved successfully, the following XML will be returned:'));
if ($multiple) {
$code = new XMLElement($rootelement);
$entry = new XMLElement('entry', NULL, array('index' => '0', 'result' => 'success', 'type' => 'create | edit'));
$entry->appendChild(new XMLElement('message', __('Entry [created | edited] successfully.')));
$code->appendChild($entry);
} else {
$code = new XMLElement($rootelement, NULL, array('result' => 'success', 'type' => 'create | edit'));
$code->appendChild(new XMLElement('message', __('Entry [created | edited] successfully.')));
}
$documentation_parts[] = self::processDocumentationCode($code);
$documentation_parts[] = new XMLElement('p', __('When an error occurs during saving, due to either missing or invalid fields, the following XML will be returned') . ($multiple ? ' (<strong> ' . __('Notice that it is possible to get mixtures of success and failure messages when using the ‘Allow Multiple’ option') . '</strong>)' : NULL) . ':');
if ($multiple) {
$code = new XMLElement($rootelement);
$entry = new XMLElement('entry', NULL, array('index' => '0', 'result' => 'error'));
$entry->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
$entry->appendChild(new XMLElement('field-name', NULL, array('type' => 'invalid | missing')));
$code->appendChild($entry);
$entry = new XMLElement('entry', NULL, array('index' => '1', 'result' => 'success', 'type' => 'create | edit'));
$entry->appendChild(new XMLElement('message', __('Entry [created | edited] successfully.')));
$code->appendChild($entry);
} else {
$code = new XMLElement($rootelement, NULL, array('result' => 'error'));
//.........这里部分代码省略.........
示例9: __formAction
public function __formAction()
{
$fields = $_POST['fields'];
$this->_errors = array();
$providers = Symphony::ExtensionManager()->getProvidersOf('data-sources');
$providerClass = null;
if (trim($fields['name']) == '') {
$this->_errors['name'] = __('This is a required field');
}
if ($fields['source'] == 'static_xml') {
if (trim($fields['static_xml']) == '') {
$this->_errors['static_xml'] = __('This is a required field');
} else {
$xml_errors = NULL;
include_once TOOLKIT . '/class.xsltprocess.php';
General::validateXML($fields['static_xml'], $xml_errors, false, new XsltProcess());
if (!empty($xml_errors)) {
$this->_errors['static_xml'] = __('XML is invalid');
}
}
} elseif ($fields['source'] == 'dynamic_xml') {
if (trim($fields['dynamic_xml']['url']) == '') {
$this->_errors['dynamic_xml']['url'] = __('This is a required field');
}
// Use the TIMEOUT that was specified by the user for a real world indication
$timeout = isset($fields['dynamic_xml']['timeout']) ? (int) $fields['dynamic_xml']['timeout'] : 6;
// If there is a parameter in the URL, we can't validate the existence of the URL
// as we don't have the environment details of where this datasource is going
// to be executed.
if (!preg_match('@{([^}]+)}@i', $fields['dynamic_xml']['url'])) {
$valid_url = self::__isValidURL($fields['dynamic_xml']['url'], $timeout, $error);
if ($valid_url) {
$data = $valid_url['data'];
} else {
$this->_errors['dynamic_xml']['url'] = $error;
}
}
if (trim($fields['dynamic_xml']['xpath']) == '') {
$this->_errors['dynamic_xml']['xpath'] = __('This is a required field');
}
if (!is_numeric($fields['dynamic_xml']['cache'])) {
$this->_errors['dynamic_xml']['cache'] = __('Must be a valid number');
} elseif ($fields['dynamic_xml']['cache'] < 1) {
$this->_errors['dynamic_xml']['cache'] = __('Must be greater than zero');
}
} elseif (is_numeric($fields['source'])) {
if (strlen(trim($fields['max_records'])) == 0 || is_numeric($fields['max_records']) && $fields['max_records'] < 1) {
if (isset($fields['paginate_results'])) {
$this->_errors['max_records'] = __('A result limit must be set');
}
} else {
if (!self::__isValidPageString($fields['max_records'])) {
$this->_errors['max_records'] = __('Must be a valid number or parameter');
}
}
if (strlen(trim($fields['page_number'])) == 0 || is_numeric($fields['page_number']) && $fields['page_number'] < 1) {
if (isset($fields['paginate_results'])) {
$this->_errors['page_number'] = __('A page number must be set');
}
} else {
if (!self::__isValidPageString($fields['page_number'])) {
$this->_errors['page_number'] = __('Must be a valid number or parameter');
}
}
} elseif (!empty($providers)) {
foreach ($providers as $providerClass => $provider) {
if ($fields['source'] == call_user_func(array($providerClass, 'getSource'))) {
call_user_func(array($providerClass, 'validate'), &$fields, &$this->_errors);
break;
}
unset($providerClass);
}
}
$classname = Lang::createHandle($fields['name'], 255, '_', false, true, array('@^[^a-z\\d]+@i' => '', '/[^\\w-\\.]/i' => ''));
$rootelement = str_replace('_', '-', $classname);
// Check to make sure the classname is not empty after handlisation.
if (empty($classname) && !isset($this->_errors['name'])) {
$this->_errors['name'] = __('Please ensure name contains at least one Latin-based character.', array($classname));
}
$file = DATASOURCES . '/data.' . $classname . '.php';
$isDuplicate = false;
$queueForDeletion = NULL;
if ($this->_context[0] == 'new' && is_file($file)) {
$isDuplicate = true;
} elseif ($this->_context[0] == 'edit') {
$existing_handle = $this->_context[1];
if ($classname != $existing_handle && is_file($file)) {
$isDuplicate = true;
} elseif ($classname != $existing_handle) {
$queueForDeletion = DATASOURCES . '/data.' . $existing_handle . '.php';
}
}
// Duplicate
if ($isDuplicate) {
$this->_errors['name'] = __('A Data source with the name %s already exists', array('<code>' . $classname . '</code>'));
}
if (empty($this->_errors)) {
$filters = array();
$elements = NULL;
$placeholder = '<!-- GRAB -->';
//.........这里部分代码省略.........