/**
 * Returns all page tags for coTemplate
 *
 * @param mixed $page_data Page Info Array or ID
 * @param string $tag_prefix Prefix for tags
 * @param int $textlength Text truncate
 * @param bool $admin_rights Page Admin Rights
 * @param bool $pagepath_home Add home link for page path
 * @param string $emptytitle Page title text if page does not exist
 * @return array
 * @global CotDB $db
 */
function cot_generate_pagetags($page_data, $tag_prefix = '', $textlength = 0, $admin_rights = null, $pagepath_home = false, $emptytitle = '')
{
    global $db, $cot_extrafields, $cfg, $L, $Ls, $R, $db_pages, $usr, $sys, $cot_yesno, $structure, $db_structure;
    static $extp_first = null, $extp_main = null;
    static $pag_auth = array();
    if (is_null($extp_first)) {
        $extp_first = cot_getextplugins('pagetags.first');
        $extp_main = cot_getextplugins('pagetags.main');
    }
    /* === Hook === */
    foreach ($extp_first as $pl) {
        include $pl;
    }
    /* ===== */
    if (!is_array($page_data)) {
        $sql = $db->query("SELECT * FROM {$db_pages} WHERE page_id = '" . (int) $page_data . "' LIMIT 1");
        $page_data = $sql->fetch();
    }
    if ($page_data['page_id'] > 0 && !empty($page_data['page_title'])) {
        if (is_null($admin_rights)) {
            if (!isset($pag_auth[$page_data['page_cat']])) {
                $pag_auth[$page_data['page_cat']] = cot_auth('page', $page_data['page_cat'], 'RWA1');
            }
            $admin_rights = (bool) $pag_auth[$page_data['page_cat']][2];
        }
        $pagepath = cot_structure_buildpath('page', $page_data['page_cat']);
        $catpath = cot_breadcrumbs($pagepath, $pagepath_home);
        $page_data['page_pageurl'] = empty($page_data['page_alias']) ? cot_url('page', 'c=' . $page_data['page_cat'] . '&id=' . $page_data['page_id']) : cot_url('page', 'c=' . $page_data['page_cat'] . '&al=' . $page_data['page_alias']);
        $page_link[] = array($page_data['page_pageurl'], $page_data['page_title']);
        $page_data['page_fulltitle'] = cot_breadcrumbs(array_merge($pagepath, $page_link), $pagepath_home);
        if (!empty($page_data['page_url']) && $page_data['page_file']) {
            $dotpos = mb_strrpos($page_data['page_url'], ".") + 1;
            $type = mb_strtolower(mb_substr($page_data['page_url'], $dotpos, 5));
            $page_data['page_fileicon'] = cot_rc('page_icon_file_path', array('type' => $type));
            if (!file_exists($page_data['page_fileicon'])) {
                $page_data['page_fileicon'] = cot_rc('page_icon_file_default');
            }
            $page_data['page_fileicon'] = cot_rc('page_icon_file', array('icon' => $page_data['page_fileicon']));
        } else {
            $page_data['page_fileicon'] = '';
        }
        $date_format = 'datetime_medium';
        $text = cot_parse($page_data['page_text'], $cfg['page']['markup'], $page_data['page_parser']);
        $text_cut = cot_cut_more($text);
        if ($textlength > 0 && mb_strlen($text_cut) > $textlength) {
            $text_cut = cot_string_truncate($text_cut, $textlength);
        }
        $cutted = mb_strlen($text) > mb_strlen($text_cut) ? true : false;
        $cat_url = cot_url('page', 'c=' . $page_data['page_cat']);
        $validate_url = cot_url('admin', "m=page&a=validate&id={$page_data['page_id']}&x={$sys['xk']}");
        $unvalidate_url = cot_url('admin', "m=page&a=unvalidate&id={$page_data['page_id']}&x={$sys['xk']}");
        $edit_url = cot_url('page', "m=edit&id={$page_data['page_id']}");
        $delete_url = cot_url('page', "m=edit&a=update&delete=1&id={$page_data['page_id']}&x={$sys['xk']}");
        $page_data['page_status'] = cot_page_status($page_data['page_state'], $page_data['page_begin'], $page_data['page_expire']);
        $temp_array = array('URL' => $page_data['page_pageurl'], 'ID' => $page_data['page_id'], 'TITLE' => $page_data['page_fulltitle'], 'ALIAS' => $page_data['page_alias'], 'STATE' => $page_data['page_state'], 'STATUS' => $page_data['page_status'], 'LOCALSTATUS' => $L['page_status_' . $page_data['page_status']], 'SHORTTITLE' => htmlspecialchars($page_data['page_title'], ENT_COMPAT, 'UTF-8', false), 'CAT' => $page_data['page_cat'], 'CATURL' => $cat_url, 'CATTITLE' => htmlspecialchars($structure['page'][$page_data['page_cat']]['title']), 'CATPATH' => $catpath, 'CATPATH_SHORT' => cot_rc_link($cat_url, htmlspecialchars($structure['page'][$page_data['page_cat']]['title'])), 'CATDESC' => htmlspecialchars($structure['page'][$page_data['page_cat']]['desc']), 'CATICON' => $structure['page'][$page_data['page_cat']]['icon'], 'KEYWORDS' => htmlspecialchars($page_data['page_keywords']), 'DESC' => htmlspecialchars($page_data['page_desc']), 'TEXT' => $text, 'TEXT_CUT' => $text_cut, 'TEXT_IS_CUT' => $cutted, 'DESC_OR_TEXT' => !empty($page_data['page_desc']) ? htmlspecialchars($page_data['page_desc']) : $text, 'MORE' => $cutted ? cot_rc('list_more', array('page_url' => $page_data['page_pageurl'])) : '', 'AUTHOR' => htmlspecialchars($page_data['page_author']), 'OWNERID' => $page_data['page_ownerid'], 'OWNERNAME' => htmlspecialchars($page_data['user_name']), 'DATE' => cot_date($date_format, $page_data['page_date']), 'BEGIN' => cot_date($date_format, $page_data['page_begin']), 'EXPIRE' => cot_date($date_format, $page_data['page_expire']), 'UPDATED' => cot_date($date_format, $page_data['page_updated']), 'DATE_STAMP' => $page_data['page_date'], 'BEGIN_STAMP' => $page_data['page_begin'], 'EXPIRE_STAMP' => $page_data['page_expire'], 'UPDATED_STAMP' => $page_data['page_updated'], 'FILE' => $cot_yesno[$page_data['page_file']], 'FILE_URL' => empty($page_data['page_url']) ? '' : cot_url('page', 'c=' . $page_data['page_cat'] . '&id=' . $page_data['page_id'] . '&a=dl'), 'FILE_SIZE' => $page_data['page_size'] / 1024, 'FILE_SIZE_BYTES' => $page_data['page_size'], 'FILE_SIZE_READABLE' => cot_build_filesize($page_data['page_size'], 1), 'FILE_ICON' => $page_data['page_fileicon'], 'FILE_COUNT' => $page_data['page_filecount'], 'FILE_COUNTTIMES' => cot_declension($page_data['page_filecount'], $Ls['Times']), 'FILE_NAME' => basename($page_data['page_url']), 'COUNT' => $page_data['page_count'], 'ADMIN' => $admin_rights ? cot_rc('list_row_admin', array('unvalidate_url' => $unvalidate_url, 'edit_url' => $edit_url)) : '', 'NOTAVAILABLE' => $page_data['page_begin'] > $sys['now'] ? $L['page_notavailable'] . cot_build_timegap($sys['now'], $pag['page_begin']) : '');
        // Admin tags
        if ($admin_rights) {
            $validate_confirm_url = cot_confirm_url($validate_url, 'page', 'page_confirm_validate');
            $unvalidate_confirm_url = cot_confirm_url($unvalidate_url, 'page', 'page_confirm_unvalidate');
            $delete_confirm_url = cot_confirm_url($delete_url, 'page', 'page_confirm_delete');
            $temp_array['ADMIN_EDIT'] = cot_rc_link($edit_url, $L['Edit']);
            $temp_array['ADMIN_EDIT_URL'] = $edit_url;
            $temp_array['ADMIN_UNVALIDATE'] = $page_data['page_state'] == 1 ? cot_rc_link($validate_confirm_url, $L['Validate'], 'class="confirmLink"') : cot_rc_link($unvalidate_confirm_url, $L['Putinvalidationqueue'], 'class="confirmLink"');
            $temp_array['ADMIN_UNVALIDATE_URL'] = $page_data['page_state'] == 1 ? $validate_confirm_url : $unvalidate_confirm_url;
            $temp_array['ADMIN_DELETE'] = cot_rc_link($delete_confirm_url, $L['Delete'], 'class="confirmLink"');
            $temp_array['ADMIN_DELETE_URL'] = $delete_confirm_url;
        } else {
            if ($usr['id'] == $page_data['page_ownerid']) {
                $temp_array['ADMIN_EDIT'] = cot_rc_link($edit_url, $L['Edit']);
                $temp_array['ADMIN_EDIT_URL'] = $edit_url;
            }
        }
        if (cot_auth('page', 'any', 'W')) {
            $clone_url = cot_url('page', "m=add&c={$page_data['page_cat']}&clone={$page_data['page_id']}");
            $temp_array['ADMIN_CLONE'] = cot_rc_link($clone_url, $L['page_clone']);
            $temp_array['ADMIN_CLONE_URL'] = $clone_url;
        }
        // Extrafields
        if (isset($cot_extrafields[$db_pages])) {
            foreach ($cot_extrafields[$db_pages] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $temp_array[$tag . '_TITLE'] = isset($L['page_' . $exfld['field_name'] . '_title']) ? $L['page_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                $temp_array[$tag] = cot_build_extrafields_data('page', $exfld, $page_data['page_' . $exfld['field_name']], $page_data['page_parser']);
                $temp_array[$tag . '_VALUE'] = $page_data['page_' . $exfld['field_name']];
            }
        }
        // Extra fields for structure
        if (isset($cot_extrafields[$db_structure])) {
            foreach ($cot_extrafields[$db_structure] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $temp_array['CAT_' . $tag . '_TITLE'] = isset($L['structure_' . $exfld['field_name'] . '_title']) ? $L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                $temp_array['CAT_' . $tag] = cot_build_extrafields_data('structure', $exfld, $structure['page'][$page_data['page_cat']][$exfld['field_name']]);
                $temp_array['CAT_' . $tag . '_VALUE'] = $structure['page'][$page_data['page_cat']][$exfld['field_name']];
            }
        }
        /* === Hook === */
        foreach ($extp_main as $pl) {
            include $pl;
        }
        /* ===== */
    } else {
        $temp_array = array('TITLE' => !empty($emptytitle) ? $emptytitle : $L['Deleted'], 'SHORTTITLE' => !empty($emptytitle) ? $emptytitle : $L['Deleted']);
    }
    $return_array = array();
    foreach ($temp_array as $key => $val) {
        $return_array[$tag_prefix . $key] = $val;
    }
    return $return_array;
}
Beispiel #2
0
                break;
            case 1:
                $r_url = cot_url('message', 'msg=300', '', true);
                break;
            case 2:
                cot_message($L['page_savedasdraft']);
                $r_url = cot_url('page', 'm=edit&id=' . $id, '', true);
                break;
        }
        cot_redirect($r_url);
    } else {
        cot_redirect(cot_url('page', "m=edit&id={$id}", '', true));
    }
}
$pag = $row_page;
$pag['page_status'] = cot_page_status($pag['page_state'], $pag['page_begin'], $pag['page_expire']);
cot_block($usr['isadmin'] || $usr['auth_write'] && $usr['id'] == $pag['page_ownerid']);
$out['subtitle'] = $L['page_edittitle'];
$out['head'] .= $R['code_noindex'];
$sys['sublocation'] = $structure['page'][$pag['page_cat']]['title'];
$mskin = cot_tplfile(array('page', 'edit', $structure['page'][$pag['page_cat']]['tpl']));
/* === Hook === */
foreach (cot_getextplugins('page.edit.main') as $pl) {
    include $pl;
}
/* ===== */
require_once $cfg['system_dir'] . '/header.php';
$t = new XTemplate($mskin);
$pageedit_array = array('PAGEEDIT_PAGETITLE' => $L['page_edittitle'], 'PAGEEDIT_SUBTITLE' => $L['page_editsubtitle'], 'PAGEEDIT_FORM_SEND' => cot_url('page', "m=edit&a=update&id=" . $pag['page_id']), 'PAGEEDIT_FORM_ID' => $pag['page_id'], 'PAGEEDIT_FORM_STATE' => $pag['page_state'], 'PAGEEDIT_FORM_STATUS' => $pag['page_status'], 'PAGEEDIT_FORM_LOCALSTATUS' => $L['page_status_' . $pag['page_status']], 'PAGEEDIT_FORM_CAT' => cot_selectbox_structure('page', $pag['page_cat'], 'rpagecat'), 'PAGEEDIT_FORM_CAT_SHORT' => cot_selectbox_structure('page', $pag['page_cat'], 'rpagecat', $c), 'PAGEEDIT_FORM_KEYWORDS' => cot_inputbox('text', 'rpagekeywords', $pag['page_keywords'], array('size' => '32', 'maxlength' => '255')), 'PAGEEDIT_FORM_METATITLE' => cot_inputbox('text', 'rpagemetatitle', $pag['page_metatitle'], array('size' => '64', 'maxlength' => '255')), 'PAGEEDIT_FORM_METADESC' => cot_textarea('rpagemetadesc', $pag['page_metadesc'], 2, 64, array('maxlength' => '255')), 'PAGEEDIT_FORM_ALIAS' => cot_inputbox('text', 'rpagealias', $pag['page_alias'], array('size' => '32', 'maxlength' => '255')), 'PAGEEDIT_FORM_TITLE' => cot_inputbox('text', 'rpagetitle', $pag['page_title'], array('size' => '64', 'maxlength' => '255')), 'PAGEEDIT_FORM_DESC' => cot_textarea('rpagedesc', $pag['page_desc'], 2, 64, array('maxlength' => '255')), 'PAGEEDIT_FORM_AUTHOR' => cot_inputbox('text', 'rpageauthor', $pag['page_author'], array('size' => '24', 'maxlength' => '100')), 'PAGEEDIT_FORM_DATE' => cot_selectbox_date($pag['page_date'], 'long', 'rpagedate') . ' ' . $usr['timetext'], 'PAGEEDIT_FORM_DATENOW' => cot_checkbox(0, 'rpagedatenow'), 'PAGEEDIT_FORM_BEGIN' => cot_selectbox_date($pag['page_begin'], 'long', 'rpagebegin') . ' ' . $usr['timetext'], 'PAGEEDIT_FORM_EXPIRE' => cot_selectbox_date($pag['page_expire'], 'long', 'rpageexpire') . ' ' . $usr['timetext'], 'PAGEEDIT_FORM_UPDATED' => cot_date('datetime_full', $pag['page_updated']) . ' ' . $usr['timetext'], 'PAGEEDIT_FORM_FILE' => cot_selectbox($pag['page_file'], 'rpagefile', range(0, 2), array($L['No'], $L['Yes'], $L['Members_only']), false), 'PAGEEDIT_FORM_URL' => cot_inputbox('text', 'rpageurl', $pag['page_url'], array('size' => '56', 'maxlength' => '255')), 'PAGEEDIT_FORM_SIZE' => cot_inputbox('text', 'rpagesize', $pag['page_size'], array('size' => '56', 'maxlength' => '255')), 'PAGEEDIT_FORM_TEXT' => cot_textarea('rpagetext', $pag['page_text'], 24, 120, '', 'input_textarea_editor'), 'PAGEEDIT_FORM_DELETE' => cot_radiobox(0, 'rpagedelete', array(1, 0), array($L['Yes'], $L['No'])), 'PAGEEDIT_FORM_PARSER' => cot_selectbox($pag['page_parser'], 'rpageparser', cot_get_parsers(), cot_get_parsers(), false));
if ($usr['isadmin']) {
    $pageedit_array += array('PAGEEDIT_FORM_OWNERID' => cot_inputbox('text', 'rpageownerid', $pag['page_ownerid'], array('size' => '24', 'maxlength' => '24')), 'PAGEEDIT_FORM_PAGECOUNT' => cot_inputbox('text', 'rpagecount', $pag['page_count'], array('size' => '8', 'maxlength' => '8')), 'PAGEEDIT_FORM_FILECOUNT' => cot_inputbox('text', 'rpagefilecount', $pag['page_filecount'], array('size' => '8', 'maxlength' => '8')));