Модуль Быстрый переход v1.26.1
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
5.5 KiB

<style type="text/css">
.level_1:before {content: "\203a\a0";}
.level_2:before {margin-left: 10px; content: "\21b3\a0";}
.level_3:before {margin-left: 25px; content: "\21b3\a0";}
</style>
<?php
/**
* AVE.cms - Модуль Быстрый переход
*
* @package AVE.cms
* @subpackage module_QuickFinder
* @filesource
*/
if(!defined('BASE_DIR')) exit;
if (defined('ACP'))
{
$modul['ModuleName'] = 'Быстрый переход';
$modul['ModuleSysName'] = 'quickfinder';
$modul['ModuleVersion'] = '1.2.1';
$modul['ModuleDescription'] = 'Данный модуль является альтернативным способом организации меню навигации на сайте. Он представлен в виде выпадающего списка разделов и подразделов вашего сайта. Для использования модуля, разместите системный тег <strong>[mod_quickfinder:XXX]</strong> в нужном месте вашего шаблона, где XXX - идентификаторы меню навигации указанные через запятую.';
$modul['ModuleAutor'] = 'Arcanum, UPD Repellent ';
$modul['ModuleCopyright'] = '&copy; 2007-2016 AVE.CMS';
$modul['ModuleIsFunction'] = 1;
$modul['ModuleAdminEdit'] = 0;
$modul['ModuleFunction'] = 'mod_quickfinder';
$modul['ModuleTag'] = '[mod_quickfinder:XXX]';
$modul['ModuleTagLink'] = null;
$modul['ModuleAveTag'] = '#\\\[mod_quickfinder:([\\\d,]*)]#';
$modul['ModulePHPTag'] = "<?php mod_quickfinder(''$1''); ?>";
}
function mod_quickfinder($navi_ids = '')
{
global $AVE_DB, $AVE_Core, $navigations;
if (!empty($navi_ids))
{
$sql = array();
$navi_ids = explode(',', $navi_ids);
foreach ($navi_ids as $navi_id)
{
if (is_numeric($navi_id) && check_navi_permission($navi_id))
{
$sql[] = "(
SELECT
navigation_item_id,
parent_id,
title,
document_id,
target,
level,
alias,
0 AS active
FROM " . PREFIX . "_navigation_items
WHERE status = '1'
AND navigation_id = " . $navi_id . "
ORDER BY position ASC
)";
}
}
$sql = implode(' UNION ', $sql);
if (empty($sql)) return;
}
else
{
$navigations = get_navigations();
if (empty($navigations)) return;
$navi_in = array();
foreach ($navigations as $navigation)
{
if (in_array(UGROUP, $navigation->user_group))
{
array_push($navi_in, $navigation->navigation_id);
}
}
if (sizeof($navi_in)) {
$sql = "
SELECT
navigation_item_id,
parent_id,
title,
document_id,
target,
level,
alias,
0 AS active
FROM " . PREFIX . "_navigation_items
WHERE status = '1'
AND navigation_id IN(" . implode(',', $navi_in) . ")
ORDER BY navigation_id ASC, position ASC
";
}
else
{
return;
}
}
$nav_items = array();
$sql = $AVE_DB->Query($sql);
while ($row_nav_item = $sql->FetchAssocArray())
{
if (empty($_REQUEST['module']))
{
$curent_doc_id = (isset($_GET['id']) && is_numeric($_GET['id'])) ? $_GET['id'] : 1;
if ($row_nav_item['alias'] == $AVE_Core->curentdoc->document_alias ||
'index.php?id=' . $row_nav_item['document_id'] == 'index.php?id=' . $curent_doc_id)
{
$row_nav_item['active'] = 1;
}
}
else
{
if ('index.php?id=' . $row_nav_item['document_id'] == 'index.php?module=' . $_REQUEST['module'])
{
$row_nav_item['active'] = 1;
}
}
$nav_items[$row_nav_item['parent_id']][] = $row_nav_item;
}
if (sizeof($nav_items))
{
$quickfinder = '<select class="form-control" name="quickfinder" onchange="eval(this.options[this.selectedIndex].value);">';
$quickfinder .= '<option></option>';
printQuickfinder($nav_items, $quickfinder);
echo $quickfinder . '</select>';
}
$sql->Close();
}
function printQuickfinder(&$nav_items, &$quickfinder = '', $parent = '0')
{
foreach ($nav_items[$parent] as $row)
{
if (strpos('index.php?id=' . $row['document_id'], 'module=') === false && start_with('index.php?', 'index.php?id=' . $row['document_id']))
{
'index.php?id=' . $row['document_id'] .= '&amp;doc=' . (empty($row['alias']) ? prepare_url($row['title']) : $row['alias']);
}
if (start_with('www.', 'index.php?id=' . $row['document_id']))
{
'index.php?id=' . $row['document_id'] = str_replace('www.', 'http://www.', 'index.php?id=' . $row['document_id']);
}
'index.php?id=' . $row['document_id'] = rewrite_link('index.php?id=' . $row['document_id']);
if($row['alias']=='/') {
if (!start_with('javascript:', 'index.php?id=' . $row['document_id']))
{
if ($row['target'] == '_blank')
{
$row['alias'] = "javascript:window.open('" . $row['alias'] . "', '', '')";
}
else
{
$row['alias'] = "window.location.href = '" . $row['alias'] . "'";
}
}
} else {
if (!start_with('javascript:', 'index.php?id=' . $row['document_id']))
{
if ($row['target'] == '_blank')
{
$row['alias'] = "javascript:window.open('". ABS_PATH. $row['alias'] . "', '', '')";
}
else
{
$row['alias'] = "window.location.href = '". ABS_PATH. $row['alias'] . "'";
}
}
}
$quickfinder .= '<option class="level_' . $row['level'] . '" value="' . $row['alias'] . '"' . ($row['active'] == 1 ? ' selected="selected"' : '') . '>' . pretty_chars($row['title']) . '</option>';
if (isset($nav_items[$row['navigation_item_id']]))
{
printQuickfinder($nav_items, $quickfinder, $row['navigation_item_id']);
}
}
}
?>