コード例 #1
0
ファイル: ui.php プロジェクト: Blu2z/implsk
 /**
  *
  * @param string $query_string
  * @param string|array $area
  * @param string $params Параметры, через амперсанд
  *   - field - поле поиска. Допустимые значения: 'title'
  *   - interval - непустое значение, если включена фильтрация по дате
  *   - intervalvalue - значение интервала
  *   - intervalunit - тип интервала (hour, day, week, month)
  *   - sortby - сортировка. Если пустое значение - сортировка по релевантности.
  *     Допустимые значения: last_updated или имя поля, по которому разрешена сортировка
  *   - sortdirection - desc (по умолчанию), asc
  *   - language - язык результатов, по умолчанию определяется автоматически
  *   - curPos - текущая позиция (номер первого результата)
  *   - recNum - количество результатов на странице, по умолчанию 10 (берется из
  *     настроек компонента в разделе)
  *   - correct - пытаться исправить запросы, не давшие результатов (по умолчанию
  *     равно соответствующей настройки модуля)
  *   - nologging - не записывать запрос в журнал запросов (при просмотре
  *     результатов из админки, чтобы не искажать картину запросов)
  * @return nc_search_data_persistent_collection
  */
 public function get_results($query_string, $area = "", $params = "")
 {
     if (!nc_search::should('EnableSearch')) {
         return new nc_search_result();
     }
     // return empty collection
     $start_time = microtime(true);
     $query_string = (string) $query_string;
     global $nc_core;
     parse_str($params, $params);
     if (isset($params["field"]) && $params["field"] && nc_search::should('AllowFieldSearch')) {
         $query_string = "{$params['field']}:({$query_string})";
     }
     $query = new nc_search_query($query_string);
     $has_interval = isset($params["interval"]) && isset($params["intervalvalue"]) && isset($params["intervalunit"]) && $params["interval"] && $params["intervalvalue"] && $params["intervalunit"];
     if ($has_interval) {
         $timestamp = strtotime("-{$params['intervalvalue']} {$params['intervalunit']}");
         $query->set('modified_after', strftime("%Y%m%d%H%M%S", $timestamp));
     }
     $allow_sort = isset($params["sortby"]) && $params["sortby"] && nc_search::should('AllowFieldSearch');
     if ($allow_sort) {
         $query->set('sort_by', $params["sortby"]);
         if (isset($params["sortdirection"]) && strtoupper($params["sortdirection"]) == 'ASC') {
             $query->set('sort_direction', SORT_ASC);
         }
     }
     if (isset($params["curPos"]) && $params["curPos"]) {
         $query->set('offset', (int) $params["curPos"]);
     }
     if (isset($params["recNum"]) && $params["recNum"]) {
         $query->set('limit', (int) $params["recNum"]);
     }
     if ($area) {
         if (is_array($area)) {
             $area = join(" ", $area);
         }
         $query->set('area', $area);
     }
     $language = isset($params["language"]) && $params["language"] ? $params["language"] : $nc_core->lang->detect_lang(1);
     $query->set('language', $language);
     $shutdown_page_path = nc_folder_path($nc_core->subdivision->get_current('Subdivision_ID'));
     register_shutdown_function('nc_search_shutdown', $shutdown_page_path, $query_string);
     $query_error = false;
     try {
         $results = nc_search::find($query);
     } catch (Exception $e) {
         $query_error = true;
         $results = new nc_search_result();
         $results->set_query($query)->set_error_message($e->getMessage());
     }
     $results->set_output_encoding(nc_core('NC_CHARSET'));
     // попробуем исправить, если не было результатов?
     $try_to_correct = $results->get_total_count() == 0 && !$query_error && (isset($params["correct"]) && $params["correct"] || nc_search::should('TryToCorrectQueries')) && preg_match_all('/[\\pL\\pN\\?\\*]+/u', $query_string, $tmp) <= nc_search::get_setting('MaxQueryLengthForCorrection');
     if ($try_to_correct) {
         $context = new nc_search_context(array("language" => $language, "action" => "searching"));
         $correctors = nc_search_extension_manager::get('nc_search_language_corrector', $context)->get_all();
         if (sizeof($correctors)) {
             $phrase = new nc_search_language_corrector_phrase($query_string);
             $rewritten_query = clone $query;
             foreach ($correctors as $corrector) {
                 if ($corrector->correct($phrase)) {
                     // что-то подправили
                     // попробуем поискать!
                     $rewritten_query->set('query_string', $phrase->to_string());
                     try {
                         $corrected_results = nc_search::find($rewritten_query);
                         if (sizeof($corrected_results)) {
                             $results = $corrected_results;
                             $results->set_correction_suggestion($phrase->get_suggestion());
                             $results->set_output_encoding(nc_core('NC_CHARSET'));
                             break;
                             // exit "foreach corrector"
                         }
                     } catch (Exception $e) {
                         // может упасть, например, если у изменённого слова есть несколько базовых форм...
                     }
                 }
                 // of "something changed"
             }
             // of "foreach corrector"
         }
         // end of "has correctors"
     }
     // end of "if ($try_to_correct)"
     $will_log = true;
     if (isset($params['nologging']) && $params['nologging'] && strlen($query_string)) {
         // только очень крутым чувакам разрешается не оставлять следов
         if (isset($GLOBALS['AUTH_USER_ID']) && isset($GLOBALS['perm']) && $GLOBALS["perm"]->isAccess(NC_PERM_MODULE)) {
             $will_log = false;
         }
     }
     if ($will_log && nc_search::should('SaveQueryHistory') && $query->get('offset') == 0) {
         $ip = ip2long($_SERVER['REMOTE_ADDR']);
         // achtung! не будет работать с IPv6!
         if ($ip > 0x7fffffff) {
             $ip -= 0x100000000;
         }
         // produce a signed 4-byte integer on 64-bit systems
         $query->set('results_count', $results->get_total_count())->set('user_ip', $ip)->set('user_id', $GLOBALS['AUTH_USER_ID'])->set('site_id', $GLOBALS['catalogue'])->save();
     }
     $results->set_search_time(microtime(true) - $start_time);
     return $results;
 }
コード例 #2
0
ファイル: full.php プロジェクト: Blu2z/implsk
 }
 $subLink = nc_folder_path($cc_env['Subdivision_ID']);
 $ccLink = nc_infoblock_path($cc_env['Sub_Class_ID']);
 if (!$cc_env['File_Mode']) {
     // get component body
     $component_body = $cc_env['RecordTemplateFull'] . $cc_env['Settings'];
     // other forms
     $cc_env["AddTemplate"] = $cc_env["AddTemplate"] ? $cc_env["AddTemplate"] : $component->add_form($catalogue, $sub, $cc);
     $cc_env["FullSearchTemplate"] = $cc_env["FullSearchTemplate"] ? $cc_env["FullSearchTemplate"] : $component->search_form(1);
 } else {
     // get component body
     $component_body = nc_check_file($file_class->get_field_path('RecordTemplateFull')) ? nc_get_file($file_class->get_field_path('RecordTemplateFull')) : null;
     $component_body .= nc_check_file($file_class->get_field_path('Settings')) ? nc_get_file($file_class->get_field_path('Settings')) : null;
 }
 // FIXME: Сломано (не определены переменные-аргументы showSearchForm):
 $nc_search_form = "<form method='get' action='" . nc_folder_path($current_sub['Subdivision_ID']) . "'>" . showSearchForm($field_descript, $field_type, $field_search, $field_format) . "<input type='submit' value='" . NETCAT_SEARCH_FIND_IT . "' /></form>";
 $routing_object_parameters = !$routing_module_enabled ? null : array('site_id' => $catalogue, 'folder' => substr($f_Hidden_URL, strlen($SUB_FOLDER)), 'folder_id' => $f_Subdivision_ID, 'infoblock_id' => $f_Sub_Class_ID, 'infoblock_keyword' => $cc_env['EnglishName'], 'object_id' => $f_RowID, 'object_keyword' => $f_Keyword, 'action' => 'full', 'format' => 'html', 'date' => $date_field ? date("Y-m-d", strtotime(${"f_{$date_field}"})) : null);
 if ($admin_mode) {
     if ($nc_core->inside_admin) {
         $fullLink = $routing_module_enabled ? nc_routing::get_object_path($classID, $routing_object_parameters) : $subLink . ($f_Keyword ? $f_Keyword : $cc_env['EnglishName'] . "_" . $f_RowID) . ".html";
         $UI_CONFIG->replace_view_link_url($fullLink);
     }
     $addLink = $admin_url_prefix . "add.php?catalogue=" . $catalogue . "&amp;sub=" . $sub . "&amp;cc=" . $cc;
     // full link section
     $fullLink = $admin_url_prefix . "full.php?catalogue=" . $catalogue . "&sub=" . $sub . "&cc=" . $cc . "&message=" . $f_RowID;
     $fullDateLink = $fullLink . $dateLink;
     // ID объекта в шаблоне
     $f_AdminButtons_id = $f_RowID;
     // Приоритет объекта
     $f_AdminButtons_priority = $f_Priority;
     // ID добавившего пользователя
コード例 #3
0
ファイル: s_common.inc.php プロジェクト: Blu2z/implsk
/**
 * Возвращает полный (с доменными именем) URL раздела с указанным идентификатором.
 *
 * @param int $folder_id
 * @param null $date
 * @param array $variables
 * @return string|false
 */
function nc_folder_url($folder_id, $date = null, array $variables = null)
{
    $folder_path = nc_folder_path($folder_id, $date, $variables);
    if (!strlen($folder_path)) {
        return false;
    }
    if (strpos($folder_path, "://") || substr($folder_path, 0, 2) == "//") {
        // если у раздела есть абсолютная внешняя ссылка с доменом, до путь уже содержит домен
        return $folder_path;
    }
    $nc_core = nc_core::get_object();
    $site_id = $nc_core->subdivision->get_by_id($folder_id, 'Catalogue_ID');
    $domain = $nc_core->catalogue->get_by_id($site_id, 'Domain');
    return "//" . $domain . $folder_path;
}
コード例 #4
0
ファイル: SubClass.php プロジェクト: Blu2z/implsk
                        $SubClassID_list = array(array('ID' => $SubClass['ID'], 'name' => $SubClass['name']));
                        break;
                    }
                }
            }
            ActionForm_for_modal_prefix($SubClassID_list, +$_REQUEST['sub_class_id']);
            ActionForm_for_modal_suffix();
            foreach ($SubClassID_list as $SubClass) {
                ActionForm_for_modal($SubClass['ID']);
            }
            exit;
        } else {
            $UI_CONFIG = new ui_config_subdivision_subclass($SubdivisionID, 'list', $SubClassID);
            ShowList();
        }
    }
} catch (nc_Exception_DB_Error $e) {
    nc_print_status(sprintf(NETCAT_ERROR_SQL, $e->query(), $e->error()), 'error');
} catch (Exception $e) {
    nc_print_status($e->getMessage(), 'error');
}
if (isset($SubdivisionID) && $SubdivisionID && isset($subdivisionTreeChange) && $subdivisionTreeChange && isset($UI_CONFIG)) {
    $subdivision = nc_Core::get_object()->subdivision->get_by_id($SubdivisionID);
    $buttons = array();
    $buttons[] = array("label" => CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_A_VIEW, "action" => "window.open('http://" . nc_folder_path($SubdivisionID) . "');", 'icon' => 'arrow-right', 'sprite' => true);
    $buttons[] = array("label" => CONTROL_CONTENT_SUBDIVISION_FUNCS_MAINDATA_A_ADDSUBSECTION, "action" => "parent.location.hash = 'subdivision.add(" . $subdivision['Subdivision_ID'] . ")'", 'icon' => 'folder-add', 'sprite' => true);
    $buttons[] = array("label" => CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_A_KILL, "action" => "parent.location.hash = 'subdivision.delete(" . $subdivision['Subdivision_ID'] . ")'", 'icon' => 'remove', 'sprite' => true);
    $tree_image = "folder" . ($subdivision["Checked"] ? "" : " nc--disabled");
    $UI_CONFIG->treeChanges['addNode'][] = array("nodeId" => "sub-{$subdivision['Subdivision_ID']}", "parentNodeId" => $subdivision['Parent_Sub_ID'] ? "sub-{$subdivision['Parent_Sub_ID']}" : "site-{$subdivision['Catalogue_ID']}", "name" => $subdivision[Subdivision_ID] . ". " . strip_tags(str_replace(array("\r", "\n"), '', $subdivision["Subdivision_Name"])), "href" => "#subdivision.edit({$subdivision['Subdivision_ID']})", "sprite" => $tree_image, "dragEnabled" => true, "buttons" => $buttons, "acceptDropFn" => "treeSitemapAcceptDrop", "onDropFn" => "treeSitemapOnDrop", "className" => $subdivision["Checked"] ? "" : "disabled", "checked" => $subdivision["Checked"], "hasChildren" => $subdivision['hasChildren'] ? true : false, "subclasses" => array());
}
EndHtml();
コード例 #5
0
ファイル: function.inc.php プロジェクト: Blu2z/implsk
/**
 * Вывод календаря
 *
 * @param int $theme идентификатор темы календаря
 * @param int|int[] $cc идентификатор компонента в разделе
 * @param int|string $setDate дата для отображения
 * @param bool|string $DateField заполнить независимо от маски дней
 * @param bool $filled
 * @param bool $queryDate
 * @param bool $popup
 * @param array $calendar_fields
 * @param bool $cc_ignore
 * @return string html-код календаря
 */
function nc_show_calendar($theme = 0, $cc = 0, $setDate = 0, $DateField = "Date", $filled = false, $queryDate = false, $popup = false, $calendar_fields = array(), $cc_ignore = false)
{
    global $db, $DOCUMENT_ROOT, $SUB_FOLDER, $HTTP_ROOT_PATH, $action, $nc_core, $AUTH_USER_ID;
    # поле для выборки
    if ($DateField) {
        $DateField = $db->escape($DateField);
    }
    # переменные
    $antiJumper = true;
    $theme = intval($theme);
    $curr_year = date("Y");
    $imagesPath = $SUB_FOLDER . $HTTP_ROOT_PATH . "modules/calendar/images/";
    $lines = 0;
    $first_folder_id = null;
    $mirror_data = array();
    if (!$popup) {
        # если нет параметра $cc, получаем глобальные значения
        if (!$cc) {
            $cc = $nc_core->sub_class->get_current('Sub_Class_ID');
        }
        if (!is_array($cc)) {
            $cc = array($cc);
        }
        $cc_ids = array_map('intval', $cc);
        while (list($k, $v) = each($cc_ids)) {
            $cc_data[$v] = $nc_core->sub_class->get_by_id($v);
            if (!$cc_data[$v]) {
                trigger_error("<b>nc_show_calendar()</b>: Incorrect \$cc (" . $v . ")", E_USER_WARNING);
                return false;
            }
            if ($cc_data[$v]['SrcMirror'] > 0) {
                $cc_ids[] = $cc_data[$v]['SrcMirror'];
                $mirror_data[$cc_data[$v]['SrcMirror']] = $cc_data[$v];
            }
            if (!$first_folder_id) {
                $first_folder_id = $cc_data[$v]['Subdivision_ID'];
            }
            if (!is_array($DateField)) {
                $cc_date_field[$v] = $DateField;
            } else {
                $cc_date_field[$v] = $DateField[$v] ? $DateField[$v] : 'Date';
            }
            // проверка прав
            $read_access = false;
            switch ($cc_data[$v]['Read_Access_ID']) {
                case 1:
                    $read_access = true;
                    break;
                case 2:
                    if ($AUTH_USER_ID) {
                        $read_access = true;
                    }
                    break;
                case 3:
                    $read_access = nc_calendar_read_permission($cc_data[$v]['Catalogue_ID'], $cc_data[$v]['Subdivision_ID'], $v);
                    break;
            }
            if (!$read_access) {
                unset($cc_ids[$k]);
            }
        }
        if (empty($cc_ids)) {
            return false;
        }
    }
    // date from address line
    if ($queryDate || preg_match("/\\/(\\d{4})\\/(?:(\\d{2})\\/)?(?:(\\d{2})\\/)?/s", $_SERVER['REQUEST_URI'], $matches)) {
        if (!$queryDate) {
            array_shift($matches);
            $query_date_year = $matches[0];
            $query_date_month = $matches[1] ? $matches[1] : 0;
            $query_date_day = $matches[2] ? $matches[2] : 0;
            $queryDate = join("-", $matches);
        } else {
            // query date
            list($query_date_year, $query_date_month, $query_date_day) = explode("-", $queryDate);
            if (!$query_date_month) {
                $query_date_month = 0;
            }
            if (!$query_date_day) {
                $query_date_day = 0;
            }
        }
    } else {
        $queryDate = false;
    }
    # проверим входную дату
    $date = $setDate ? $setDate : (isset($GLOBALS['date']) && $GLOBALS['date'] ? $GLOBALS['date'] : false);
    if ($date && preg_match("/^([0-9]{1,4}-?){1,3}\$/", $date)) {
        // simply date value in script
        list($year, $month, $day) = explode("-", $date);
        if (!$month) {
            $month = 1;
        }
        if (!$day) {
            $day = 1;
        }
    } else {
        list($year, $month, $day) = explode("-", date("Y-m-d"));
    }
    # данные календаря
    $settings = $db->get_row("SELECT * FROM `Calendar_Settings`\n\t\tWHERE " . ($theme ? "`ID` = '" . $theme . "'" : "`DefaultTheme` = 1"), ARRAY_A);
    if (empty($settings)) {
        trigger_error("<b>nc_show_calendar()</b>: No calendar theme found (" . $theme . ")", E_USER_WARNING);
        return false;
    }
    # идентификатор темы календаря
    ###_BEGIN: вывод блока дней
    $calendarBody = $settings['dayTemplatePrefix'];
    ###_BEGIN: отображение названий дней
    $calendarBody .= $settings['dayTemplateBegin'];
    # названия дней, если есть
    if ($settings['DaysName']) {
        $DaysNameArray = explode(",", $settings['DaysName']);
        # дополняем массив пустышкой в начале, не из романа братьев Стругацких :)
        if (!empty($DaysNameArray) && is_array($DaysNameArray)) {
            $DaysNameArray = array_map("trim", $DaysNameArray);
            $DaysNameArray = array_pad($DaysNameArray, -8, "");
        }
    }
    # заменяем на названия дней из массива
    for ($i = 1; $i <= 7; $i++) {
        $DayName = $DaysNameArray[$i];
        if ($i % 7 == 6) {
            $calendarBody .= str_replace("%NAME_DAY", $DayName, $settings['daySETTemplateHeader']);
        } elseif (!($i % 7)) {
            $calendarBody .= str_replace("%NAME_DAY", $DayName, $settings['daySUNTemplateHeader']);
        } else {
            $calendarBody .= str_replace("%NAME_DAY", $DayName, $settings['dayTemplateHeader']);
        }
    }
    $calendarBody .= $settings['dayTemplateEnd'];
    ###_END: отображение названий дней
    ###_BEGIN: отображение дней
    $calendarBody .= $settings['dayTemplateBegin'];
    # номер дня недели за первое число
    $weekDayBehind = date("w", mktime(0, 0, 0, $month, 1, $year));
    # 0 - воскресенье
    if ($weekDayBehind == 0) {
        $weekDayBehind = 7;
    }
    # вставляем пустые дни в начало
    for ($i = 1; $i < $weekDayBehind; $i++) {
        # суббота
        if ($i % 7 == 6) {
            $calendarBody .= $settings['nodaySETTemplate'];
        } elseif (!($i % 7)) {
            $calendarBody .= $settings['nodaySUNTemplate'];
        } else {
            $calendarBody .= $settings['nodayTemplate'];
        }
    }
    if ($weekDayBehind != 1) {
        $lines = $lines + 1;
    }
    # дней в месяце $month
    $daysInMonth = date("t", mktime(0, 0, 0, $month, 1, $year));
    # маска дней, массив "0", в количестве равным дням в месяце $month
    $daysMask = array_fill(0, $daysInMonth, $filled ? 1 : 0);
    # получаем данные о "событиях" из базы
    if (!$filled) {
        # проверим, есть ли такое поле
        //$DateFieldExist = nc_calendar_possibility_check($classID, $DateField);
        $query = array();
        foreach ($cc_ids as $cc_id) {
            $query[] = "SELECT DAYOFMONTH(`" . $cc_date_field[$cc_id] . "`) as `d`, `Sub_Class_ID` as `cc`\n                FROM `Message" . $cc_data[$cc_id]['Class_ID'] . "`\n                WHERE " . (!$cc_ignore ? "`Sub_Class_ID` = '" . intval($cc_id) . "'\n                AND" : null) . " MONTH(`" . $cc_date_field[$cc_id] . "`) = '" . $month . "'\n\t\t\t\t\t      AND YEAR(`" . $cc_date_field[$cc_id] . "`) = '" . $year . "'\n\t\t\t\t\t      AND Checked = '1'\n                GROUP BY DAYOFMONTH(`" . $cc_date_field[$cc_id] . "`) ";
        }
        $res = $db->get_results(join(' UNION ', $query), ARRAY_A);
        # заполненяем маску, все дни месяца без событий - "0", с событиями - "1"
        if (!empty($res)) {
            foreach ($res as $value) {
                $daysMask[$value['d'] - 1] = !$cc_ignore ? $value['cc'] : $cc[0];
            }
        }
    }
    ###_BEGIN: даты календаря
    for ($i = 1; $i <= $daysInMonth; $i++) {
        # шаблон для отрисовки ссылок, если понадобится (если есть событие)
        if ($daysMask[$i - 1]) {
            $dayLinkEnd = "</a>";
            if ($popup) {
                $dayLinkBegin = "<a href='#' onclick='nc_calendar_popup_callback(" . $i . ", " . $month . ", " . $year . ", \"" . $calendar_fields[0] . "\", \"" . $calendar_fields[1] . "\",\"" . $calendar_fields[2] . "\"); return false;'>";
            } else {
                if (isset($mirror_data[$daysMask[$i - 1]]) && !empty($mirror_data[$daysMask[$i - 1]])) {
                    $_cc_id = $mirror_data[$daysMask[$i - 1]]['Sub_Class_ID'];
                    $_sub_id = $mirror_data[$daysMask[$i - 1]]['Subdivision_ID'];
                } else {
                    $_cc_id = $daysMask[$i - 1];
                    $_sub_id = $cc_data[$daysMask[$i - 1]]['Subdivision_ID'];
                }
                if ($nc_core->admin_mode) {
                    $path = $nc_core->SUB_FOLDER . $nc_core->HTTP_ROOT_PATH . '?sub=' . $_sub_id . '&amp;cc=' . $_cc_id;
                    $dayLinkBegin = "<a href='" . $path . '&amp;date=' . $year . "-" . sprintf("%02d", $month) . "-" . sprintf("%02d", $i) . "'>";
                } else {
                    $path = nc_folder_path($_sub_id, sprintf("%d-%02d-%02d", $year, $month, $i));
                    $dayLinkBegin = "<a href='{$path}'>";
                }
            }
        } else {
            $dayLinkBegin = $dayLinkEnd = "";
        }
        # конец строки с днями
        if (($weekDayBehind + $i - 1) % 7 == 1) {
            if ($lines) {
                $calendarBody .= $settings['dayTemplateEnd'] . $settings['dayTemplateBegin'];
            }
            $lines = $lines + 1;
        }
        switch (true) {
            case ($weekDayBehind + $i - 1) % 7 == 6 && $i != $day:
                # суббота
                $calendarBody .= str_replace("%DAY", $dayLinkBegin . $i . $dayLinkEnd, $settings['daySETTemplate']);
                break;
            case ($weekDayBehind + $i - 1) % 7 == 0 && $i != $day:
                # воскресенье
                $calendarBody .= str_replace("%DAY", $dayLinkBegin . $i . $dayLinkEnd, $settings['daySUNTemplate']);
                break;
            case $queryDate && $i == $query_date_day && $query_date_month == $month && $query_date_year == $year:
                # текущий день
                $calendarBody .= str_replace("%DAY", $action == "full" || $popup ? $dayLinkBegin . $i . $dayLinkEnd : $i, $settings['dayCurTemplate']);
                break;
            case !$queryDate && $i == $day && date("m") == $month && date("Y") == $year:
                # текущий день + ссылка
                $calendarBody .= str_replace("%DAY", $dayLinkBegin . $i . $dayLinkEnd, $settings['dayCurTemplate']);
                break;
            default:
                # дни с понедельника по пятницу
                $calendarBody .= str_replace("%DAY", $dayLinkBegin . $i . $dayLinkEnd, $settings['dayTemplate']);
        }
    }
    ###_END: даты календаря
    # номер дня недели за последнее число
    $weekDayAfter = date("w", mktime(0, 0, 0, $month, $daysInMonth, $year));
    # 0 - воскресенье
    if ($weekDayAfter == 0) {
        $weekDayAfter = 7;
    }
    # система антиджампера, чтобы календарь не "прыгал", прорисовываем пустые строки
    $daysEnd = $antiJumper ? 7 * ($lines < 6 ? 7 - $lines : 1) : 7;
    #  вставляем пустые дни в конец
    for ($i = $weekDayAfter; $i < $daysEnd; $i++) {
        # конец строки с днями
        if (($i + 1) % 7 == 1 && $daysEnd > 7) {
            $calendarBody .= $settings['dayTemplateEnd'] . $settings['dayTemplateBegin'];
        }
        # суббота
        if (($i + 1) % 7 == 6) {
            $calendarBody .= $settings['nodaySETTemplate'];
        } else {
            if (!(($i + 1) % 7)) {
                $calendarBody .= $settings['nodaySUNTemplate'];
            } else {
                $calendarBody .= $settings['nodayTemplate'];
            }
        }
    }
    $calendarBody .= $settings['dayTemplateEnd'];
    ###_END: отображение дней
    $calendarBody .= $settings['dayTemplateSuffix'];
    ###_END: вывод блока дней
    # массив с названиями месяцев из языкового файла
    eval("\$MonthArray = " . NETCAT_MODULE_CALENDAR_MONTH_NAME_ARRAY . ";");
    # дополним одним пустым элементом в начале, для удобства
    if (is_array($MonthArray)) {
        $MonthArray = array_pad($MonthArray, -13, "");
    }
    # выпадающий список "месяц"
    if ($popup) {
        $month_select = "<select onchange='nc_calendar_generate_popup(" . $day . ", this.value, " . $year . ", \"" . $calendar_fields[0] . "\", \"" . $calendar_fields[1] . "\",\"" . $calendar_fields[2] . "\",\"" . $theme . "\"); return false;'>";
    } else {
        $month_select = "<select onchange='nc_calendar_generate(" . $day . ", this.value, " . $year . "" . ($cc_ignore ? ", true " : null) . "); return false;'>";
    }
    for ($monthCount = 1; $monthCount <= 12; $monthCount++) {
        $month_select .= "<option value='" . $monthCount . "'" . ($month == $monthCount ? " selected" : "") . ">" . $MonthArray[$monthCount] . "</option>";
    }
    $month_select .= "</select>";
    # выпадающий список "год"
    if ($popup) {
        $year_select = "<select onchange='nc_calendar_generate_popup(" . $day . ", " . $month . ", this.value, \"" . $calendar_fields[0] . "\", \"" . $calendar_fields[1] . "\",\"" . $calendar_fields[2] . "\", \"" . $theme . "\"); return false;'>";
    } else {
        $year_select = "<select onchange='nc_calendar_generate(" . $day . ", " . $month . ", this.value" . ($cc_ignore ? ", true " : null) . "); return false;'>";
    }
    $parallax_year_forward = intval($settings['parallax_year_forward']);
    $parallax_year_backward = intval($settings['parallax_year_backward']);
    $parallax_year_forward = $parallax_year_forward > 0 ? $parallax_year_forward : 10;
    $parallax_year_backward = $parallax_year_backward > 0 ? $parallax_year_backward : 10;
    $limit = $curr_year + $parallax_year_forward;
    for ($yearCount = $curr_year - $parallax_year_backward; $yearCount <= $limit; $yearCount++) {
        $year_select .= "<option value='" . $yearCount . "'" . ($year == $yearCount ? " selected" : "") . ">" . $yearCount . "</option>";
    }
    $year_select .= "</select>";
    if ($settings['StatusImage'] && file_exists($DOCUMENT_ROOT . $imagesPath . $settings['StatusImage'])) {
        $IMG_STATUS = true;
    } else {
        $IMG_STATUS = false;
    }
    if ($settings['PrevImage'] && file_exists($DOCUMENT_ROOT . $imagesPath . $settings['PrevImage'])) {
        $IMG_PREV_MONTH = true;
    } else {
        $IMG_PREV_MONTH = false;
    }
    if ($settings['NextImage'] && file_exists($DOCUMENT_ROOT . $imagesPath . $settings['NextImage'])) {
        $IMG_NEXT_MONTH = true;
    } else {
        $IMG_NEXT_MONTH = false;
    }
    if ($settings['CloseImage'] && file_exists($DOCUMENT_ROOT . $imagesPath . $settings['CloseImage'])) {
        $IMG_CLOSE = true;
    } else {
        $IMG_CLOSE = false;
    }
    $CalendarHeader = str_replace("%SELECT_MONTH", $month_select, $settings['CalendarHeader']);
    $CalendarHeader = str_replace("%SELECT_YEAR", $year_select, $CalendarHeader);
    $CalendarHeader = str_replace("%MONTH_NAME", $MonthArray[(int) $month], $CalendarHeader);
    $CalendarHeader = str_replace("%MONTH_DIGIT", $month, $CalendarHeader);
    $CalendarHeader = str_replace("%YEAR_DIGIT", $year, $CalendarHeader);
    if ($popup) {
        $CalendarHeader = str_replace("%IMG_STATUS", $IMG_CLOSE ? "<img onclick='document.getElementById(\"nc_calendar_popup_" . $calendar_fields[0] . "\").style.display=\"none\"; return false;' src='" . $imagesPath . $settings['CloseImage'] . "' style='display:block; cursor: pointer;' id='ImgClose' alt='" . NETCAT_MODULE_CALENDAR_CLOSE . "' title='" . NETCAT_MODULE_CALENDAR_CLOSE . "' />" : "", $CalendarHeader);
    } else {
        $CalendarHeader = str_replace("%IMG_STATUS", $IMG_STATUS ? "<img src='" . $imagesPath . $settings['StatusImage'] . "' style='display:none;' id='ImgWaiting' alt='waiting' title='waiting' />" : "", $CalendarHeader);
    }
    if ($popup) {
        $CalendarHeader = str_replace("%IMG_PREV_MONTH", $IMG_PREV_MONTH ? "<img src='" . $imagesPath . $settings['PrevImage'] . "' onclick='nc_calendar_generate_popup(" . ($day ? $day : 1) . ", " . ($month == 1 ? 12 : $month - 1) . ", " . ($month == 1 ? $year - 1 : $year) . ",  \"" . $calendar_fields[0] . "\", \"" . $calendar_fields[1] . "\",\"" . $calendar_fields[2] . "\", \"" . $theme . "\"); return false;' alt='" . $MonthArray[$month == 1 ? 12 : $month - 1] . "' title='" . $MonthArray[$month == 1 ? 12 : $month - 1] . "' />" : "&lt;", $CalendarHeader);
        $CalendarHeader = str_replace("%IMG_NEXT_MONTH", $IMG_NEXT_MONTH ? "<img src='" . $imagesPath . $settings['NextImage'] . "' onclick='nc_calendar_generate_popup(" . ($day ? $day : 1) . ", " . ($month == 12 ? 1 : $month + 1) . ", " . ($month == 12 ? $year + 1 : $year) . ",  \"" . $calendar_fields[0] . "\", \"" . $calendar_fields[1] . "\",\"" . $calendar_fields[2] . "\", \"" . $theme . "\"); return false;' alt='" . $MonthArray[$month == 12 ? 1 : $month + 1] . "' title='" . $MonthArray[$month == 12 ? 1 : $month + 1] . "' />" : "&gt;", $CalendarHeader);
    } else {
        $CalendarHeader = str_replace("%IMG_PREV_MONTH", $IMG_PREV_MONTH ? "<img src='" . $imagesPath . $settings['PrevImage'] . "' onclick='nc_calendar_generate(" . ($day ? $day : 1) . ", " . ($month == 1 ? 12 : $month - 1) . ", " . ($month == 1 ? $year - 1 : $year) . " " . ($cc_ignore ? ", true " : null) . "); return false;' alt='" . $MonthArray[$month == 1 ? 12 : $month - 1] . "' title='" . $MonthArray[$month == 1 ? 12 : $month - 1] . "' />" : "&lt;", $CalendarHeader);
        $CalendarHeader = str_replace("%IMG_NEXT_MONTH", $IMG_NEXT_MONTH ? "<img src='" . $imagesPath . $settings['NextImage'] . "' onclick='nc_calendar_generate(" . ($day ? $day : 1) . ", " . ($month == 12 ? 1 : $month + 1) . ", " . ($month == 12 ? $year + 1 : $year) . " " . ($cc_ignore ? ", true " : null) . "); return false;' alt='" . $MonthArray[$month == 12 ? 1 : $month + 1] . "' title='" . $MonthArray[$month == 12 ? 1 : $month + 1] . "' />" : "&gt;", $CalendarHeader);
        $CalendarHeader = str_replace("%LINK_PREV_MONTH", $IMG_PREV_MONTH ? "<a href='#' onclick='nc_calendar_generate(" . ($day ? $day : 1) . ", " . ($month == 1 ? 12 : $month - 1) . ", " . ($month == 1 ? $year - 1 : $year) . " " . ($cc_ignore ? ", true " : null) . "); return false;' alt='" . $MonthArray[$month == 1 ? 12 : $month - 1] . "' title='" . $MonthArray[$month == 1 ? 12 : $month - 1] . "' ></a>" : "&lt;", $CalendarHeader);
        $CalendarHeader = str_replace("%LINK_NEXT_MONTH", $IMG_NEXT_MONTH ? "<a href='#' onclick='nc_calendar_generate(" . ($day ? $day : 1) . ", " . ($month == 12 ? 1 : $month + 1) . ", " . ($month == 12 ? $year + 1 : $year) . " " . ($cc_ignore ? ", true " : null) . "); return false;' alt='" . $MonthArray[$month == 12 ? 1 : $month + 1] . "' title='" . $MonthArray[$month == 12 ? 1 : $month + 1] . "' ></a>" : "&gt;", $CalendarHeader);
    }
    $DateFieldExist = true;
    $CalendarHeader = str_replace("%MONTH_LINK", ($DateFieldExist && !$popup ? "<a href='" . nc_folder_path($first_folder_id, sprintf("%d-%02d", $year, $month)) . "'>" : "") . $MonthArray[(int) $month] . ($DateFieldExist ? "</a>" : ""), $CalendarHeader);
    $CalendarHeader = str_replace("%YEAR_LINK", ($DateFieldExist && !$popup ? "<a href='" . nc_folder_path($first_folder_id, $year) . "'></a>" : "") . sprintf("%04d", $year) . ($DateFieldExist ? "</a>" : ""), $CalendarHeader);
    if (!$setDate) {
        $calendarBlockBegin = "<div id='nc_calendar_block'>";
        $calendarBlockEnd = "</div>\r\n<input type='hidden' id='calendar_cc' value='" . join(',', $cc_ids) . "' />\r\n";
        $calendarBlockEnd .= "<input type='hidden' id='calendar_theme' value='" . $theme . "' />\r\n<input type='hidden' id='calendar_field' value='" . $DateField . "' />\r\n<input type='hidden' id='calendar_filled' value='" . $filled . "' />\r\n<input type='hidden' id='calendar_querydate' value='" . $queryDate . "' />\r\n";
    }
    # результат, html-код календаря
    $result = $calendarBlockBegin . $settings['CalendarPrefix'] . $CalendarHeader . $calendarBody . $settings['CalendarSuffix'] . $calendarBlockEnd;
    return $result;
}
コード例 #6
0
ファイル: sub.php プロジェクト: Blu2z/implsk
 /**
  *
  * @throws nc_search_exception
  * @return string
  */
 protected function get_path()
 {
     if (!$this->path) {
         if ($this->url) {
             if (strpos($this->url, "://")) {
                 $this->path = parse_url($this->url, PHP_URL_PATH);
             } else {
                 $this->path = $this->url;
             }
         } elseif ($this->id) {
             $this->path = nc_folder_path($this->id);
         } else {
             throw new nc_search_exception("Wrong subdivision area: neither ID nor URL specified");
         }
     }
     return $this->path;
 }
コード例 #7
0
ファイル: function.inc.php プロジェクト: Blu2z/implsk
function nc_subdivision_form_seo_save()
{
    $nc_core = nc_Core::get_object();
    $sub_id = intval($nc_core->input->fetch_get_post('SubdivisionID'));
    // метатэги
    $metatags = array('title', 'keywords', 'description');
    foreach ($metatags as $v) {
        $user_value[$v] = $nc_core->input->fetch_get_post($v);
        $fields[$nc_core->page->get_field_name($v)] = $user_value[$v];
    }
    // запрет индексации и настройки sitemap'a
    $fields['DisallowIndexing'] = intval($nc_core->input->fetch_get_post('DisallowIndexing'));
    $fields[$nc_core->page->get_field_name('last_modified_type')] = $nc_core->input->fetch_get_post('last_modified_type');
    if ($nc_core->modules->get_by_keyword('search')) {
        foreach (array('sitemap_include', 'sitemap_changefreq', 'sitemap_priority') as $v) {
            $fields[$nc_core->page->get_field_name($v)] = $nc_core->input->fetch_get_post($v);
        }
    }
    $nc_core->subdivision->update($sub_id, $fields);
    // проверка
    $real_value = $nc_core->page->get_meta_tags("http://" . $nc_core->DOMAIN_NAME . nc_folder_path($sub_id));
    foreach ($metatags as $v) {
        if ($real_value[$v] && $user_value[$v] && $user_value[$v] != $real_value[$v]) {
            nc_print_status(sprintf(CONTROL_CONTENT_SUBDIVISION_SEO_VALUE_NOT_SETTINGS, $v, $v), 'info');
        }
    }
    return true;
}