⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 criteria.inc.svn-base

📁 PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
<?php/** * $Id$ * * Contains document browsing business logic. * * 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): ______________________________________ */require_once(KT_LIB_DIR . '/security/Permission.inc');require_once(KT_LIB_DIR . '/users/User.inc');require_once(KT_LIB_DIR . '/documentmanagement/Document.inc');require_once(KT_LIB_DIR . '/documentmanagement/DocumentField.inc');require_once(KT_LIB_DIR . '/documentmanagement/DocumentType.inc');require_once(KT_LIB_DIR . '/documentmanagement/MetaData.inc');require_once(KT_LIB_DIR . '/foldermanagement/Folder.inc');require_once(KT_LIB_DIR . '/workflow/workflowstate.inc.php');require_once(KT_LIB_DIR . '/workflow/workflow.inc.php');require_once(KT_LIB_DIR . '/browse/criteriaregistry.php');require_once(KT_LIB_DIR . "/util/sanitize.inc");class BrowseCriterion {    var $sDisplay;    var $aLookup = null;    var $bFolderCriterion = false;    var $aOptions = array();    var $iID;    var $bString = false;    var $sSearchTable = "D";    var $bVisible = true;    var $bContains = false;    var $bHandleNot = true;    var $sDocumentField = null;    var $sSortField = null;    var $sNamespace = null;    function BrowseCriterion() {        $this->sDisplay = '';    }    function headerDisplay () {        return $this->sDisplay;    }    // for final display    function documentDisplay ($oDocument) {        return $this->sDisplay;    }    function folderDisplay ($oDocument) {        return "&nbsp;";    }    // for parameter display    function baseParameterDisplay() {	$sDisp = sprintf("<b>%s</b>: ", $this->sDisplay);	$bNot = KTUtil::arrayGet($aData, $this->getWidgetBase().'_not', null);	if($bNot !== null) {	    if((bool)$bNot) { $sDisp .= _kt('NOT'); }	}	return $sDisp;    }    function parameterDisplay($aData) {	return sprintf("%s %s", $this->baseParameterDisplay(), htmlentities($aData[$this->getWidgetBase()],ENT_QUOTES, 'UTF-8'));    }    function folderQuery ($iParentID, $sSortDirection) {        global $default;        $sFolderQuery = "SELECT f.id FROM $default->folders_table AS f ";/*ok*/        if (!$this->bFolderCriterion) {            $sFolderQuery .= "WHERE parent_id = ? ORDER BY f.name asc";            $aParams = array($iParentID);            return array($sFolderQuery, $aParams);        }        if (!is_null($this->aLookup)) {            $sFolderQuery .= "INNER JOIN " . $this->aLookup["table"] . " lt ON f.$this->sDocumentField = lt.id WHERE parent_id = ?";            $sFolderQuery .= " ORDER BY lt." . $this->aLookup["field"] . " " . $sSortDirection;            $aParams = array($iParentID);            return array($sFolderQuery, $aParams);        }        $sFolderQuery .= "WHERE parent_id = ? ORDER BY " . $this->getFolderSortField() . " " . $sSortDirection;        $aParams = array($iParentID);        return array($sFolderQuery, $aParams);    }    function documentQuery ($iFolderID, $sSortDirection) {        global $default;        // create query to retrieve documents in this folder        $documentQuery  = "SELECT d.id as id FROM $default->documents_table AS d ";/*wc*/        if (!is_null($this->aLookup)) {            $sDocumentJoinField = $this->getDocumentField();            $documentQuery .= "INNER JOIN " . $this->aLookup["table"] . " lt ON ";            if (array_key_exists('joinColumn', $this->aLookup)) {                $documentQuery .= "d.$sDocumentJoinField" . " = lt." . $this->aLookup["joinColumn"];            } else {                $documentQuery .= "d.$sDocumentJoinField" . " = lt.id";            }        }        $documentQuery .= " WHERE d.folder_id = ? ";        $aParams = array($iFolderID);        if (!is_null($this->aLookup)) {            if (array_key_exists("whereClause", $this->aLookup)) {                $documentQuery .= "AND lt." . $this->aLookup["whereClause"] . " ";            }            $documentQuery .= "ORDER BY lt." . $this->aLookup["field"] . " " . $sSortDirection;        } else {            $sDocumentJoinField = $this->getDocumentField();            // $sSortField = $this->getSortField();            $documentQuery .= "ORDER BY " . $this->getSortField() . " " . $sSortDirection;        }        return array($documentQuery, $aParams);    }    function getDocumentField () {        return $this->sDocumentField;    }    function getSortField () {        return $this->sSortField;    }    function getFolderSortField () {        return $this->sSortField;    }    function getSearchField () {        return $this->sDocumentField;    }    function getLookup () {        return $this->aLookup;    }    function getName() {        return sanitizeForSQLtoHTML($this->sDocumentField);    }    function getID() {        return $this->iID;    }    function getNameSpace() {	return $this->sNamespace;    }    function setOptions($aOptions) {        $this->aOptions = $aOptions;    }    function searchDisplay($aRequest) {        return "<tr><td>" . $this->headerDisplay() . ": </td><td>" . $this->searchWidget($aRequest) . "</td></tr>\n";    }    function searchWidget ($aRequest, $aPreValue = null) {        if ($aPreValue != null) {            // !#@&)*( (*&!@# *(&@NOT (*&!@#            $k = array_keys($aPreValue);            $k = $this->getWidgetBase();	    if(array_key_exists($k, $aPreValue)) {		$preval = $aPreValue[$k];	    }            return $this->getNotWidget($aPreValue) . "<input type=\"text\" size=\"50\" name=\"" . $this->getWidgetBase() . "\" value=\"" . $preval . "\"/>";        } else {            return $this->getNotWidget($aPreValue) . "<input type=\"text\" size=\"50\" name=\"" . $this->getWidgetBase() . "\" />";        }    }    function getNotWidget($aPreValue=null) {        if (!$this->bHandleNot) { return ''; }        // not perfect, but acceptable.        $form_name = $this->getWidgetBase() . '_not';        $pos_select = '';        $neg_select = '';        if (is_null($aPreValue)) {            $is_positive = true;        } else {	    if(array_key_exists($form_name, $aPreValue)) {		$preval = KTUtil::arrayGet($aPreValue, $form_name, "0"); // by default, use "is" not "is not"	    }	    $is_positive = ($preval == "0"); // 0 or empty or similar.        }        if ($is_positive) {            $pos_select = ' selected="true"';        } else {            $neg_select = ' selected="true"';        }        if (!$this->bContains) {            $not_string = _kt('is not');            $is_string = _kt('is');        } else {            $not_string = _kt('does not contain');            $is_string = _kt('contains');        }        $widget = sprintf('<select name="%s"><option value="0"%s>%s</option><option value="1"%s>%s</option></select>&nbsp;', $form_name, $pos_select, $is_string, $neg_select, $not_string);        return $widget;    }    function getWidgetBase () {        //return strtr($this->getNamespace(), '-', '_');        return $this->getNamespace();    }    function getSearchTable() {        return $this->sSearchTable;    }    function searchSQL ($aRequest, $handle_not = true) {        $val = null;        if ($this->bString) {            $val = array($this->getSearchTable() . "." .  $this->getSearchField() . " LIKE '%!%'", array(DBUtil::escapeSimple($aRequest[$this->getWidgetBase()])));        } else {            $val = array($this->getSearchTable() . "." . $this->getSearchField() . " = ?", array($aRequest[$this->getWidgetBase()]));        }        // handle the boolean "not" stuff UNLESS our caller is doing so already.        if ($handle_not) {            $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not');            if (is_null($want_invert) || ($want_invert == "0")) { // use explicit "0" check                return $val;            } else {                $val[0] = '(NOT (' . $val[0] . '))';            }        }        return $val;    }    function searchJoinSQL () {        return null;    }}class NameCriterion extends BrowseCriterion {    var $bFolderCriterion = true;    var $bString = true;    var $sSearchTable = "DC";    var $bContains = true;    var $sDocumentField = 'filename';    var $sSortField = 'filename';    var $sNamespace = 'ktcore.criteria.name';    function NameCriterion() {        $this->sDisplay = _kt('Document Filename');    }    function documentDisplay ($oDocument) {        $aOptions = $this->aOptions;        if (array_key_exists('displayFullPath', $aOptions)) {            $bDisplayFullPath = $aOptions['displayFullPath'];        } else {            $bDisplayFullPath = false;        }        if (array_key_exists('templateBrowsing', $aOptions)) {            $bTemplateBrowsing = $aOptions['templateBrowsing'];        } else {            $bTemplateBrowsing = false;        }        if ($bTemplateBrowsing) {            return displayDocumentLinkForTemplateBrowsing($oDocument, $bDisplayFullPath);        } else {            return displayDocumentLink($oDocument, $bDisplayFullPath);        }    }    function folderDisplay($oFolder) {        return displayFolderLink($oFolder);    }    function getFolderSortField() {        return 'name';    }}class IDCriterion extends BrowseCriterion {    var $bFolderCriterion = true;    var $sDocumentField = 'id';    var $sSortField = 'id';    var $sNamespace = 'ktcore.criteria.id';    function IDCriterion() {        $this->sDisplay = _kt('Document ID');    }    function documentDisplay ($oDocument) {        return $oDocument->getID();    }

⌨️ 快捷键说明

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