kt3template.inc.php

来自「PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。」· PHP 代码 · 共 459 行 · 第 1/2 页

PHP
459
字号
<?php
/**
 * $Id: kt3template.inc.php 8759 2008-07-07 08:19:34Z megan_w $
 *
 * KnowledgeTree Community Edition
 * Document Management Made Simple
 * Copyright (C) 2008 KnowledgeTree Inc.
 * Portions copyright The Jam Warehouse Software (Pty) Limited
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License version 3 as published by the
 * Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
 * California 94120-7775, or email info@knowledgetree.com.
 *
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * KnowledgeTree" logo and retain the original copyright notice. If the display of the
 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
 * must display the words "Powered by KnowledgeTree" and retain the original
 * copyright notice.
 * Contributor( s): ______________________________________
 *
 *
 * -------------------------------------------------------------------------
 *
 * KT3 Template Base
 *
 * Represents core UI logic, including how sub-components interact with
 * the overall page.
 *
 * For the meaning of each of the variables and functions, see inline.
 *
 */

require_once(KT_LIB_DIR . "/plugins/pluginregistry.inc.php");
require_once(KT_LIB_DIR . "/templating/templating.inc.php");
require_once(KT_LIB_DIR . "/session/control.inc");
require_once(KT_DIR . '/search2/search/search.inc.php');

class KTPage {
    var $hide_section = false;
	var $secondary_title = null;

    /** resources are "filename"->1 to allow subcomponents to require items. */
    var $js_resources = Array();
    var $css_resources = Array();
    var $theme_css_resources = Array();
	var $ie_only_css = Array();
	var $theme_ie_only_css = Array();
    var $js_standalone = Array();
    var $css_standalone = Array();

	/** context-relevant information */
	var $errStack = Array();
	var $booleanLink = false;
    var $infoStack = Array();
	var $portlets = Array();
	var $show_portlets = true;

    /** miscellaneous items */
    var $title = '';
    var $systemName = APP_NAME;
    var $systemURL = 'http://www.knowledgetree.com/';
    var $breadcrumbs = false;
    var $breadcrumbDetails = false;
    var $breadcrumbSection = false;
    var $menu = null;
    var $userMenu = null;
    var $helpPage = null;

    /** the "component".  Used to set the page header (see documentation for explanation). */
    var $componentLabel = 'Browse Documents';
    var $componentClass = 'browse_collections';

    /** $contents is the center of the page.  In KT < 3, this was CentralPayload. */
    var $contents = '';

    var $template = "kt3/standard_page";

    var $contentType = 'text/html';
    var $charset = 'UTF-8';

    var $content_class;

    /* further initialisation */
    function KTPage() {
        global $default;
        $oConfig = KTConfig::getSingleton();

        /* default css files initialisation */
        $aCSS = Array(
           "thirdpartyjs/extjs/resources/css/ext-all.css",
           "resources/css/kt-framing.css",
           "resources/css/kt-contenttypes.css",
           "resources/css/kt-headings.css"
        );
        $this->requireCSSResources($aCSS);

        if($oConfig->get('ui/morphEnabled') == '1'){
        	$morphTheme = $oConfig->get('ui/morphTo');
        	$this->requireThemeCSSResource('skins/kts_'.$oConfig->get('ui/morphTo').'/kt-morph.css');
        	$this->requireThemeCSSResource('skins/kts_'.$oConfig->get('ui/morphTo').'/kt-ie-morph.css', true);
        }
        // IE only
        $this->requireCSSResource("resources/css/kt-ie-icons.css", true);

        /* default js files initialisation */
        $aJS = Array();

		$aJS[] = 'thirdpartyjs/MochiKit/MochiKitPacked.js';
        $aJS[] = 'resources/js/kt-utility.js';
        $aJS[] = 'presentation/i18nJavascript.php';
        $aJS[] = 'thirdpartyjs/curvycorners/rounded_corners.inc.js';
        $aJS[] = 'resources/js/loader.js';

        $aJS[] = 'thirdpartyjs/extjs/adapter/ext/ext-base.js';
        $aJS[] = 'thirdpartyjs/extjs/ext-all.js';
        $aJS[] = 'resources/js/search2widget.js';

        $this->requireJSResources($aJS);

        // this is horrid, but necessary.
		$this->requireJSStandalone('addLoadEvent(partial(initDeleteProtection, "' . _kt('Are you sure you wish to delete this item?') . '"));');

        /* menu initialisation*/
        // FIXME:  how do we want to handle the menu?
        $this->initMenu();

        /* portlet initialisation */
        $this->show_portlets = true;
        /* breadcrumbs */
    }

	// initiliase the menu.
    function initMenu() {
    	// FIXME:  we lost the getDefaultAction stuff - do we care?
    	// note that key == action. this is _important_, since we crossmatch the breadcrumbs against this for "active"
    	$sBaseUrl = KTUtil::kt_url();

    	$this->menu = array();
    	$this->menu['dashboard'] = array('label' => _kt("Dashboard"), 'url' => $sBaseUrl.'/dashboard.php');
		$this->menu['browse'] = array('label' => _kt("Browse Documents"), 'url' => $sBaseUrl.'/browse.php');
		$this->menu['administration'] = array('label' => _kt("DMS Administration"), 'url' => $sBaseUrl.'/admin.php');
    }


    function setTitle($sTitle) {
	$this->title = $sTitle;
    }

    /* javascript handling */
    // require that the specified JS file is referenced.
    function requireJSResource($sResourceURL) {
	$this->js_resources[$sResourceURL] = 1; // use the keys to prevent multiple copies.
    }

    // require that the specified JS files are referenced.
    function requireJSResources($aResourceURLs) {
        foreach ($aResourceURLs as $sResourceURL) {
            $this->js_resources[$sResourceURL] = 1;
        }
    }

    // list the distinct js resources.
    function getJSResources() {
        return array_keys($this->js_resources);
    }

    function requireJSStandalone($sJavascript) {
        $this->js_standalone[$sJavascript] = 1; // use the keys to prevent multiple copies.
    }
    // list the distinct js resources.
    function getJSStandalone() {
        return array_keys($this->js_standalone);
    }

    /* css handling */
    // require that the specified CSS file is referenced.
    function requireCSSResource($sResourceURL, $ieOnly = false) {
        if ($ieOnly !== true) {
            $this->css_resources[$sResourceURL] = 1; // use the keys to prevent multiple copies.
		} else {
		    $this->ie_only_css[$sResourceURL] = 1;
		}
    }

    // require that the specified CSS file is referenced.
    function requireThemeCSSResource($sResourceURL, $ieOnly = false) {
        if ($ieOnly !== true) {
            $this->theme_css_resources[$sResourceURL] = 1; // use the keys to prevent multiple copies.
		} else {
		    $this->theme_ie_only_css[$sResourceURL] = 1;
		}
    }

    // require that the specified CSS files are referenced.
    function requireCSSResources($aResourceURLs) {
        foreach ($aResourceURLs as $sResourceURL) {
            $this->css_resources[$sResourceURL] = 1;
        }
    }

    // list the distinct CSS resources.
    function getCSSResources() {
        return array_keys($this->css_resources);
    }

    // list the distinct CSS resources.
    function getThemeCSSResources() {
        return array_keys($this->theme_css_resources);
    }

	function getCSSResourcesForIE() {
        return array_keys($this->ie_only_css);
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?