Exemplo n.º 1
0
/**
 * Sets encoding for using in morphos/* functions.
 */
function set_encoding($encoding)
{
    if (function_exists('mb_internal_encoding')) {
        mb_internal_encoding($encoding);
    } else {
        if (function_exists('iconv_set_encoding')) {
            iconv_set_encoding('internal_encoding', $encoding);
        } else {
            return false;
        }
    }
}
set_encoding('utf-8');
/**
 * Calcules count of characters in string.
 */
function length($string)
{
    if (function_exists('mb_strlen')) {
        return mb_strlen($string);
    } else {
        if (function_exists('iconv_strlen')) {
            return iconv_strlen($string);
        } else {
            return false;
        }
    }
}
Exemplo n.º 2
0
    // build pageinfo
    $fh = fopen($fname, 'r');
    $_SESSION['cms_preview_data'] = unserialize(fread($fh, filesize($fname)));
    fclose($fh);
    unset($_SESSION['cms_preview']);
    $pageinfo = PageInfoOperations::LoadPageInfoFromSerializedData($_SESSION['cms_preview_data']);
    $pageinfo->content_id = '__CMS_PREVIEW_PAGE__';
}
if (!is_object($pageinfo)) {
    $pageinfo = PageInfoOperations::LoadPageInfoByContentAlias($page);
}
// $page cannot be empty here
if (isset($pageinfo) && $pageinfo !== FALSE) {
    $gCms->variables['pageinfo'] =& $pageinfo;
    if (isset($pageinfo->template_encoding) && $pageinfo->template_encoding != '') {
        set_encoding($pageinfo->template_encoding);
    }
    if ($pageinfo->content_id > 0) {
        $manager =& $gCms->GetHierarchyManager();
        $node =& $manager->sureGetNodeById($pageinfo->content_id);
        if (is_object($node)) {
            $contentobj =& $node->GetContent(true, true, false);
            if (!$contentobj->IsViewable()) {
                $url = $contentobj->GetURL();
                if ($url != '' && $url != '#') {
                    redirect($url);
                }
            }
            if (is_object($contentobj)) {
                $smarty->assign('content_obj', $contentobj);
            }