本文整理汇总了PHP中seo::createSection方法的典型用法代码示例。如果您正苦于以下问题:PHP seo::createSection方法的具体用法?PHP seo::createSection怎么用?PHP seo::createSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类seo
的用法示例。
在下文中一共展示了seo::createSection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createSection
/**
* Создание раздела/подраздела
*
* @param array $info Данные создания
* @return object xajaxResponse
*/
function createSection($info, $action = 'create')
{
global $GLOBALS;
session_start();
if (!hasPermissions('seo')) {
return false;
}
$objResponse = new xajaxResponse();
$info['id'] = intval($info['id']);
$info['bind'] = intval($info['bind']);
$info['subdomain'] = intval($info['subdomain']);
$info['parent'] = intval($info['parent']);
$info['old_position'] = intval($info['old_position']);
$info['new_position'] = intval($info['new_position']);
$info['direct_id'] = $direct_id = intval($info['direction']);
$info['old_direction'] = intval($info['old_direction']);
$saved_disable_link_processing = $GLOBALS['disable_link_processing'];
$GLOBALS['disable_link_processing'] = TRUE;
$section = array("bind" => 0, "parent" => (int) $info['parent'], "name_section" => (string) change_q_x($info['name_section'], true), "name_section_link" => (string) change_q_x($info['name_section_link'], true), "meta_description" => (string) change_q_x($info['meta_description'], true), "meta_keywords" => (string) change_q_x($info['meta_keywords'], true), "content_before" => (string) __paramValue('ckeditor', $info['content_before']), "content_after" => (string) __paramValue('ckeditor', $info['content_after']), "date_create" => "NOW();");
$GLOBALS['disable_link_processing'] = $saved_disable_link_processing;
$seo = new seo($_SESSION['subdomain']);
if ($info['direct_id']) {
$section['direct_id'] = $info['direct_id'];
} else {
$objResponse->script("alert('Не указано направление');");
$objResponse->script("\$('s_direction').focus();");
return $objResponse;
}
if ($info['is_subcategory'] && $info['subdomain'] == 0) {
$objResponse->script("alert('Не указан регион');");
return $objResponse;
}
if (trim($info['name_section']) == "") {
$objResponse->script("alert('Введите название раздела');");
$objResponse->script("\$('name_section').focus();");
return $objResponse;
}
if (preg_match('/[^A-Za-z0-9_\\-]/', $info['name_section_link'])) {
$objResponse->script("alert('Название ссылки раздела должно содержать только латинские буквы, цифры, нижнее подчеркивание или тире');");
$objResponse->script("\$('name_section_link').focus();");
return $objResponse;
}
if ($seo->checkLink('section', $section['name_section_link'], $info['direct_id'], $info['parent'], $info['id'], $info['subdomain'])) {
$objResponse->script("alert('В выбранном разделе уже есть элемент с такой ссылкой');");
$objResponse->script("\$('name_section_link').focus();");
return $objResponse;
}
switch ($action) {
default:
case 'create':
$section['name_section'] = stripslashes($section['name_section']);
$section['meta_description'] = stripslashes($section['meta_description']);
$section['meta_keywords'] = stripslashes($section['meta_keywords']);
$section['content_before'] = stripslashes($section['content_before']);
$section['content_after'] = stripslashes($section['content_after']);
$new_section = $seo->createSection($section, $info['subdomain'], (int) $info['is_draft']);
$section['id'] = $new_section['id'];
$pos_old = $new_section['pos'];
$section['pos_num'] = (int) $info['new_position'];
if ($section['pos_num'] != -1) {
$seo->updatePosition($pos_old, $info['new_position'], $info['parent'], $direct_id);
$seo->updateSection($section['id'], $section, $info['bind'], $info['subdomain'], (int) $info['is_draft']);
}
if ($info['is_subcategory']) {
$success_text = "Подраздел успешно добавлен";
$url['msgok'] = 5;
} else {
$success_text = "Раздел успешно добавлен";
$url['msgok'] = 1;
}
break;
case 'update':
if ($info['old_parent'] == $info['parent']) {
$section['pos_num'] = (int) $info['new_position'];
if ($info['old_direction'] != $direct_id) {
$seo->updatePosition($info['old_position'], null, $info['parent'], $info['old_direction']);
$section['pos_num'] = intval($seo->getPositions($section['parent'], $direct_id)) + 1;
} else {
if ($info['new_position'] == -1) {
$section['pos_num'] = intval($seo->getPositions($section['parent'], $direct_id));
$info['new_position'] = $section['pos_num'];
}
$seo->updatePosition($info['old_position'], $info['new_position'], $info['parent'], $direct_id);
}
$seo->updateSection($info['id'], $section, $info['bind'], $info['subdomain'], (int) $info['is_draft']);
} else {
$new_position = $seo->getPositions($info['parent'], $direct_id) + 1;
$section['pos_num'] = (int) $new_position;
$seo->updatePositionsByParent($info['old_parent'], $info['old_position'], $direct_id);
$seo->updateSection($info['id'], $section, $info['bind'], $info['subdomain'], (int) $info['is_draft']);
if ($info['new_position'] != -1) {
$pos_old = $section['pos_num'];
$pos_new = $info['new_position'];
$seo->updatePosition($pos_old, $pos_new, $info['parent'], $direct_id);
//.........这里部分代码省略.........