當前位置: 首頁>>代碼示例>>PHP>>正文


PHP seo::getPositions方法代碼示例

本文整理匯總了PHP中seo::getPositions方法的典型用法代碼示例。如果您正苦於以下問題:PHP seo::getPositions方法的具體用法?PHP seo::getPositions怎麽用?PHP seo::getPositions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在seo的用法示例。


在下文中一共展示了seo::getPositions方法的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);
//.........這裏部分代碼省略.........
開發者ID:Nikitian,項目名稱:fl-ru-damp,代碼行數:101,代碼來源:seo.server.php


注:本文中的seo::getPositions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。