browse.php.svn-base

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

SVN-BASE
442
字号
			$this->editable = false;			$doctype = KTUtil::arrayGet($_REQUEST, 'fType',null);			$oDocType = DocumentType::get($doctype);			if (PEAR::isError($oDocType) || ($oDocType == false)) {				$this->errorRedirectToMain('No Document Type selected.');				exit(0);			}			$this->oQuery =  new TypeBrowseQuery($oDocType);			// FIXME probably want to redirect to self + action=selectType			$this->aBreadcrumbs[] = array('name' => _kt('Document Types'), 'url' => KTUtil::addQueryString($_SERVER['PHP_SELF'], 'action=selectType'));			$this->aBreadcrumbs[] = array('name' => $oDocType->getName(), 'url' => KTUtil::addQueryString($_SERVER['PHP_SELF'], 'fBrowseMode=document_type&fType=' . $oDocType->getId()));			$this->resultURL = KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fType=%s&fBrowseMode=document_type', $doctype));;		} else {			// FIXME what should we do if we can't initiate the browse?  we "pretend" to have no perms.			return false;		}		return true;	}	function do_main() {		$oColumnRegistry =& KTColumnRegistry::getSingleton();		$collection = new AdvancedCollection;		$collection->addColumns($oColumnRegistry->getColumnsForView('ktcore.views.browse'));		$aOptions = $collection->getEnvironOptions(); // extract data from the environment		$aOptions['result_url'] = $this->resultURL;		$aOptions['is_browse'] = true;		$collection->setOptions($aOptions);		$collection->setQueryObject($this->oQuery);		$collection->setColumnOptions('ktcore.columns.selection', array(            'rangename' => 'selection',            'show_folders' => true,            'show_documents' => true,		));		// get bulk actions		$aBulkActions = KTBulkActionUtil::getAllBulkActions();		$oTemplating =& KTTemplating::getSingleton();		$oTemplate = $oTemplating->loadTemplate('kt3/browse');		$aTemplateData = array(              'context' => $this,              'collection' => $collection,              'browse_mode' => $this->browse_mode,              'isEditable' => $this->editable,              'bulkactions' => $aBulkActions,              'browseutil' => new KTBrowseUtil(),              'returnaction' => 'browse',		);		if ($this->oFolder) {			$aTemplateData['returndata'] = $this->oFolder->getId();		}		return $oTemplate->render($aTemplateData);	}	function do_selectField() {		$aFields = DocumentField::getList('has_lookup = 1');		if (empty($aFields)) {			$this->errorRedirectToMain(_kt('No lookup fields available.'));			exit(0);		}		$_REQUEST['fBrowseMode'] = 'lookup_value';		$oTemplating =& KTTemplating::getSingleton();		$oTemplate = $oTemplating->loadTemplate('kt3/browse_lookup_selection');		$aTemplateData = array(              'context' => $this,              'fields' => $aFields,		);		return $oTemplate->render($aTemplateData);	}	function do_selectLookup() {		$field = KTUtil::arrayGet($_REQUEST, 'fField', null);		$oField = DocumentField::get($field);		if (PEAR::isError($oField) || ($oField == false) || (!$oField->getHasLookup())) {			$this->errorRedirectToMain('No Field selected.');			exit(0);		}		$_REQUEST['fBrowseMode'] = 'lookup_value';		$aValues = MetaData::getByDocumentField($oField);		$oTemplating =& KTTemplating::getSingleton();		$oTemplate = $oTemplating->loadTemplate('kt3/browse_lookup_value');		$aTemplateData = array(              'context' => $this,              'oField' => $oField,              'values' => $aValues,		);		return $oTemplate->render($aTemplateData);	}	function do_selectType() {		$aTypes = DocumentType::getList();		// FIXME what is the error message?		$_REQUEST['fBrowseMode'] = 'document_type';		if (empty($aTypes)) {			$this->errorRedirectToMain('No document types available.');			exit(0);		}		$oTemplating =& KTTemplating::getSingleton();		$oTemplate = $oTemplating->loadTemplate('kt3/browse_types');		$aTemplateData = array(              'context' => $this,              'document_types' => $aTypes,		);		return $oTemplate->render($aTemplateData);	}	function do_enableAdminMode() {		$iDocumentId = KTUtil::arrayGet($_REQUEST, 'fDocumentId');		$iFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId');		if ($iDocumentId) {			$oDocument = Document::get($iDocumentId);			if (PEAR::isError($oDocument) || ($oDocument === false)) {				return null;			}			$iFolderId = $oDocument->getFolderId();		}		if (!Permission::userIsSystemAdministrator() && !Permission::isUnitAdministratorForFolder($this->oUser, $iFolderId)) {			$this->errorRedirectToMain(_kt('You are not an administrator'));		}		// log this entry		$oLogEntry =& KTUserHistory::createFromArray(array(            'userid' => $this->oUser->getId(),            'datetime' => date('Y-m-d H:i:s', time()),            'actionnamespace' => 'ktcore.user_history.enable_admin_mode',            'comments' => 'Admin Mode enabled',            'sessionid' => $_SESSION['sessionID'],		));		$aOpts = array(            'redirect_to' => 'main',            'message' => _kt('Unable to log admin mode entry.  Not activating admin mode.'),		);		$this->oValidator->notError($oLogEntry, $aOpts);		$_SESSION['adminmode'] = true;		if ($_REQUEST['fDocumentId']) {			$_SESSION['KTInfoMessage'][] = _kt('Administrator mode enabled');			redirect(KTBrowseUtil::getUrlForDocument($iDocumentId));			exit(0);		}		if ($_REQUEST['fFolderId']) {			$this->successRedirectToMain(_kt('Administrator mode enabled'), sprintf('fFolderId=%d', $_REQUEST['fFolderId']));		}		$this->successRedirectToMain(_kt('Administrator mode enabled'));	}	function do_disableAdminMode() {		$iDocumentId = KTUtil::arrayGet($_REQUEST, 'fDocumentId');		$iFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId');		if ($iDocumentId) {			$oDocument = Document::get($iDocumentId);			if (PEAR::isError($oDocument) || ($oDocument === false)) {				return null;			}			$iFolderId = $oDocument->getFolderId();		}		if (!Permission::userIsSystemAdministrator() && !Permission::isUnitAdministratorForFolder($this->oUser, $iFolderId)) {			$this->errorRedirectToMain(_kt('You are not an administrator'));		}		// log this entry		$oLogEntry =& KTUserHistory::createFromArray(array(            'userid' => $this->oUser->getId(),            'datetime' => date('Y-m-d H:i:s', time()),            'actionnamespace' => 'ktcore.user_history.disable_admin_mode',            'comments' => 'Admin Mode disabled',            'sessionid' => $_SESSION['sessionID'],		));		$aOpts = array(            'redirect_to' => 'main',            'message' => _kt('Unable to log admin mode exit.  Not de-activating admin mode.'),		);		$this->oValidator->notError($oLogEntry, $aOpts);		$_SESSION['adminmode'] = false;		if ($_REQUEST['fDocumentId']) {			$_SESSION['KTInfoMessage'][] = _kt('Administrator mode disabled');			redirect(KTBrowseUtil::getUrlForDocument($iDocumentId));			exit(0);		}		if ($_REQUEST['fFolderId']) {			$this->successRedirectToMain(_kt('Administrator mode disabled'), sprintf('fFolderId=%d', $_REQUEST['fFolderId']));		}		$this->successRedirectToMain(_kt('Administrator mode disabled'));	}}$oDispatcher = new BrowseDispatcher();$oDispatcher->dispatch();?>

⌨️ 快捷键说明

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