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.
143 lines
4.2 KiB
143 lines
4.2 KiB
<?php |
|
|
|
/** |
|
* AVE.cms - Модуль Навигация по документам рубрики |
|
* |
|
* @package AVE.cms |
|
* @subpackage module_Rubnav |
|
* @filesource |
|
*/ |
|
|
|
if(!defined('BASE_DIR')) exit; |
|
|
|
if (defined('ACP')) |
|
{ |
|
$modul['ModuleName'] = 'Навигация по рубрике'; |
|
$modul['ModuleSysName'] = 'rubnav'; |
|
$modul['ModuleVersion'] = '1.1.2'; |
|
$modul['ModuleDescription'] = 'Навигация по документам в пределах рубрики (следущая-предыдущая)<br />Инструкция:<br />[mod_rubnav:next] - следущая<br />[mod_rubnav:prev] - предыдущая'; |
|
$modul['ModuleAutor'] = 'AVE.CMS Team'; |
|
$modul['ModuleCopyright'] = '© 2007-2014 AVE.cms'; |
|
$modul['ModuleIsFunction'] = 1; |
|
$modul['ModuleAdminEdit'] = 1; |
|
$modul['ModuleFunction'] = 'mod_rubnav'; |
|
$modul['ModuleTag'] = '[mod_rubnav:XXX]'; |
|
$modul['ModuleTagLink'] = null; |
|
$modul['ModuleAveTag'] = '#\\\[mod_rubnav:([a-zA-Z0-9]+)]#'; |
|
$modul['ModulePHPTag'] = "<?php mod_rubnav(''$1''); ?>"; |
|
} |
|
|
|
/** |
|
* Обработка тэга модуля |
|
* |
|
*/ |
|
function mod_rubnav($data) |
|
{ |
|
global $AVE_DB, $AVE_Core; |
|
|
|
$row_templ = $AVE_DB->Query(" |
|
SELECT * |
|
FROM " . PREFIX . "_module_rubnav |
|
WHERE Id = 1 |
|
")->FetchRow(); |
|
|
|
if ($data == "next") |
|
{ |
|
$next_link = ''; |
|
$row = $AVE_DB->Query(" |
|
SELECT |
|
Id, |
|
document_alias, |
|
document_title |
|
FROM " . PREFIX . "_documents |
|
WHERE |
|
Id != '1' |
|
AND Id != '" . PAGE_NOT_FOUND_ID . "' |
|
AND Id != '" . $AVE_Core->curentdoc->Id . "' |
|
AND rubric_id = '" . $AVE_Core->curentdoc->rubric_id . "' |
|
AND document_published >= '" . $AVE_Core->curentdoc->document_published . "' |
|
AND (document_expire = 0 || document_expire > UNIX_TIMESTAMP()) |
|
AND (document_published = 0 || document_published < UNIX_TIMESTAMP()) |
|
AND document_deleted = '0' |
|
AND document_status = '1' |
|
ORDER BY document_published ASC |
|
LIMIT 0,1 |
|
") |
|
->fetchRow(); |
|
if ($row) |
|
{ |
|
|
|
$search = array('[tag:link]','[tag:linkname]'); |
|
$replace = array( |
|
rewrite_link('index.php?id=' . $row->Id . '&doc=' . (empty($row->document_alias) ? prepare_url($row->document_title) : $row->document_alias)), |
|
stripslashes(htmlspecialchars_decode($row->document_title)) |
|
); |
|
|
|
$next_link = str_replace($search, $replace, $row_templ->rubnav_tmpl_next); |
|
} |
|
echo $next_link; |
|
} |
|
else if ($data == "prev") |
|
{ |
|
//Функция перехода на предыдущую страницу в данной рубрике |
|
$prev_link = ''; |
|
$row = $AVE_DB->Query(" |
|
SELECT |
|
Id, |
|
document_alias, |
|
document_title |
|
FROM " . PREFIX . "_documents |
|
WHERE |
|
Id != '1' |
|
AND Id != '" . PAGE_NOT_FOUND_ID . "' |
|
AND Id != '" . $AVE_Core->curentdoc->Id . "' |
|
AND rubric_id = '" . $AVE_Core->curentdoc->rubric_id . "' |
|
AND document_published <= '" . $AVE_Core->curentdoc->document_published . "' |
|
AND (document_expire = 0 || document_expire > UNIX_TIMESTAMP()) |
|
AND (document_published = 0 || document_published < UNIX_TIMESTAMP()) |
|
AND document_deleted = '0' |
|
AND document_status = '1' |
|
ORDER BY document_published DESC |
|
LIMIT 0,1 |
|
") |
|
->fetchRow(); |
|
if ($row) |
|
{ |
|
$search = array('[tag:link]','[tag:linkname]'); |
|
$replace = array( |
|
rewrite_link('index.php?id=' . $row->Id . '&doc=' . (empty($row->document_alias) ? prepare_url($row->document_title) : $row->document_alias)), |
|
stripslashes(htmlspecialchars_decode($row->document_title)) |
|
); |
|
|
|
$prev_link = str_replace($search, $replace, $row_templ->rubnav_tmpl_prev); |
|
} |
|
echo $prev_link; |
|
} |
|
} |
|
|
|
/** |
|
* Администрирование |
|
*/ |
|
if (defined('ACP') && !empty($_REQUEST['moduleaction'])) |
|
{ |
|
global $rubric_list; |
|
|
|
$tpl_dir = BASE_DIR . '/modules/rubnav/templates/'; |
|
$lang_file = BASE_DIR . '/modules/rubnav/lang/' . $_SESSION['admin_language'] . '.txt'; |
|
|
|
if (! @require(BASE_DIR . '/modules/rubnav/class.rubnav.php')) module_error(); |
|
|
|
$rubric_list = new RubNav($tpl_dir, $lang_file); |
|
|
|
$AVE_Template->config_load($lang_file); |
|
$config_vars = $AVE_Template->get_config_vars(); |
|
$AVE_Template->assign('config_vars', $config_vars); |
|
|
|
switch($_REQUEST['moduleaction']) |
|
{ |
|
case '1': |
|
$rubric_list->rubnavSettingsEdit(); |
|
break; |
|
} |
|
} |
|
?>
|