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.

159 lines
4.2 KiB

8 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)
8 years ago
{
7 years ago
global $AVE_Core;
8 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);
8 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;
8 years ago
}
7 years ago
/**
* Получить идентификатор текущего документа
*
* @return int идентификатор текущего документа
*/
function get_current_document_id()
8 years ago
{
7 years ago
$_REQUEST['id'] = (isset($_REQUEST['id']) && is_numeric($_REQUEST['id']))
? $_REQUEST['id']
: 1;
8 years ago
7 years ago
return $_REQUEST['id'];
8 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 [];
7 years ago
5 years ago
if (defined('USE_STATIC_DATA') && USE_STATIC_DATA)
static $get_documents_data = [];
else
$get_documents_data = [];
7 years ago
if (! isset ($get_documents_data[$doc_id]))
{
7 years ago
$get_documents_data[$doc_id] = getDocument($doc_id);
$get_documents_data[$doc_id] = object2array($get_documents_data[$doc_id]);
7 years ago
5 years ago
$get_documents_data[$doc_id]['doc_title'] = $get_documents_data[$doc_id]['document_title'] = htmlspecialchars_decode($get_documents_data[$doc_id]['document_title'], ENT_QUOTES);
5 years ago
$get_documents_data[$doc_id]['feld'] = [];
7 years ago
}
if (isset($key) && $key != '')
return $get_documents_data[$doc_id][$key];
else
return $get_documents_data[$doc_id];
8 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;
$doc_id = (int)$doc_id;
if ($doc_id < 1)
return false;
$sql = "
SELECT
# DOCUMENT = $doc_id
*
FROM
" . PREFIX . "_documents
WHERE
Id = '" . $doc_id . "'
";
$cache_time = (defined('CACHE_DOC_FILE') && CACHE_DOC_FILE)
? -1
: 0;
$data = $AVE_DB->Query($sql, $cache_time, 'dat_' . $doc_id, true, '.data')->FetchRow();
return $data;
}
5 years ago
function DocumentBeforeSave ($data)
{
5 years ago
return $data;
5 years ago
}
function DocumentAfterSave ($data)
{
return $data;
}
8 years ago
?>