AVE.CMS v3.28
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.

182 lines
4.6 KiB

7 years ago
<?php
7 years ago
/**
* AVE.cms
*
* @package AVE.cms
* @version 3.x
* @filesource
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
*
* @license GPL v.2
*/
/**
* Постраничная навигация документа
*
* @param string $text текст многострочной части документа
* @return string
*/
5 years ago
function document_pagination ($text)
7 years ago
{
7 years ago
global $AVE_Core;
7 years ago
7 years ago
// IE8 <div style="page-break-after: always"><span style="display: none">&nbsp;</span></div>
// Chrome <div style="page-break-after: always; "><span style="DISPLAY:none">&nbsp;</span></div>
// FF <div style="page-break-after: always;"><span style="display: none;">&nbsp;</span></div>
$pages = preg_split('#<div style="page-break-after:[; ]*always[; ]*"><span style="display:[ ]*none[;]*">&nbsp;</span></div>#i', $text);
$total_page = @sizeof($pages);
7 years ago
7 years ago
if ($total_page > 1)
{
$text = @$pages[get_current_page('artpage')-1];
$page_nav = ' <a class="pnav" href="index.php?id=' . $AVE_Core->curentdoc->Id
. '&amp;doc=' . (empty($AVE_Core->curentdoc->document_alias) ? prepare_url($AVE_Core->curentdoc->document_title) : $AVE_Core->curentdoc->document_alias)
. '&amp;artpage={s}'
5 years ago
. ((isset($_REQUEST['apage']) && is_numeric($_REQUEST['apage'])) ? '&amp;apage=' . $_REQUEST['apage'] : '')
. ((isset($_REQUEST['page']) && is_numeric($_REQUEST['page'])) ? '&amp;page=' . $_REQUEST['page'] : '')
7 years ago
. '">{t}</a> ';
$page_nav = get_pagination($total_page, 'artpage', $page_nav, get_settings('navi_box'));
$text .= rewrite_link($page_nav);
}
$pages = '<?php $GLOBALS[\'page_id\'][' . $_REQUEST['id'] . '][\'artpage\']=' . $total_page . '; ?>';
return $pages . $text;
7 years ago
}
7 years ago
/**
* Получить идентификатор текущего документа
*
* @return int идентификатор текущего документа
*/
function get_current_document_id()
7 years ago
{
7 years ago
$_REQUEST['id'] = (isset($_REQUEST['id']) && is_numeric($_REQUEST['id']))
? $_REQUEST['id']
: 1;
7 years ago
7 years ago
return $_REQUEST['id'];
7 years ago
}
7 years ago
/**
* Получить идентификатор родительского документа
*
* @return int идентификатор родительского документа
*/
5 years ago
function get_parent_document_id ()
7 years ago
{
global $AVE_DB;
return $AVE_DB->Query("SELECT document_parent FROM " . PREFIX . "_documents WHERE Id = '".get_current_document_id()."' ")->GetCell();
}
/**
* Функция отдаёт основные параметры дока
*
* @param int $doc_id - номер id документа
* @param string $key - параметр документа
*
6 years ago
* @return string | bool | array
7 years ago
*/
function get_document ($doc_id , $key ='')
{
$doc_id = (int)$doc_id;
if ($doc_id < 1)
5 years ago
return [];
4 years ago
/*
5 years ago
if (defined('USE_STATIC_DATA') && USE_STATIC_DATA)
static $get_documents_data = [];
else
$get_documents_data = [];
4 years ago
*/
7 years ago
7 years ago
4 years ago
if (! (Registry::stored('documents', $doc_id)))
$documents_data = getDocument($doc_id);
else
$documents_data = Registry::get('documents', $doc_id);
7 years ago
4 years ago
if (! is_object($documents_data))
return false;
$documents_data = object2array($documents_data);
$documents_data['doc_title'] = $documents_data['document_title'] = htmlspecialchars_decode($documents_data['document_title'], ENT_QUOTES);
$documents_data['feld'] = [];
7 years ago
if (isset($key) && $key != '')
4 years ago
return $documents_data[$key];
7 years ago
else
4 years ago
return $documents_data;
7 years ago
}
7 years ago
/**
* Функция отдаёт основные параметры дока
*
* @param int $doc_id - номер id документа
*
6 years ago
* @return object | bool
7 years ago
*/
function getDocument ($doc_id)
{
global $AVE_DB;
4 years ago
if (! defined('USE_STATIC_DATA') || ! USE_STATIC_DATA)
Registry::clean();
7 years ago
$doc_id = (int)$doc_id;
if ($doc_id < 1)
return false;
4 years ago
$documents = Registry::get('documents');
7 years ago
$sql = "
SELECT
# DOCUMENT = $doc_id
4 years ago
doc.*
7 years ago
FROM
4 years ago
" . PREFIX . "_documents AS doc
LEFT JOIN
" . PREFIX . "_rubrics AS rub
ON rub.Id = doc.rubric_id
7 years ago
WHERE
4 years ago
doc.Id = '" . $doc_id . "'
7 years ago
";
$cache_time = (defined('CACHE_DOC_FILE') && CACHE_DOC_FILE)
? -1
: 0;
$data = $AVE_DB->Query($sql, $cache_time, 'dat_' . $doc_id, true, '.data')->FetchRow();
4 years ago
if (! is_object($data))
return false;
$documents[$data->Id] = $data;
Registry::set('documents', $documents);
unset ($documents);
return Registry::get('documents', $doc_id);
7 years ago
}
5 years ago
function DocumentBeforeSave ($data)
{
5 years ago
return $data;
5 years ago
}
function DocumentAfterSave ($data)
{
return $data;
}
7 years ago
?>