<?php require_once "../../config/dmsDefaults.php"; require_once KT_LIB_DIR . "/help/helpreplacement.inc.php"; error_reporting(E_ALL); $oObject = KTHelpReplacement::getByName('dashboardHelp.html'); var_dump($oObject);
function checkReplacement() { $oHelpReplacement = KTHelpReplacement::getByName($this->sFilename); if (PEAR::isError($oHelpReplacement)) { return false; } return $oHelpReplacement; }
function do_clear() { $name = KTUtil::arrayGet($_REQUEST, 'name'); $subname = KTHelp::_getLocationInfo($name); $oHelpReplacement = KTHelpReplacement::getByName($subname['internal']); if (PEAR::isError($oHelpReplacement)) { return $this->errorRedirectToMain(_kt("Could not find specified item")); } $res = $oHelpReplacement->delete(); if (PEAR::isError($res)) { return $this->errorRedirectToMain(_kt("Could not delete specified item")); } return $this->successRedirectToMain(_kt("Item deleted")); }
function getHelpInfo($sSubPath, $sLangCode = null) { $aInfo = array('is_image' => false, 'title' => null, 'body' => null, 'help_id' => null, 'name' => null); $aPathInfo = KTHelp::_getLocationInfo($sSubPath, $sLangCode); if (PEAR::isError($aPathInfo)) { return $aPathInfo; } // first, check the extension to see if its an image. // failing that, check the DB for an entry (+ return if found) // failing that, check the FS for the entry (+ return if found) // failing that, through an exception. if (!empty($aPathInfo['external'])) { if (KTHelp::isImageFile($aPathInfo['external'])) { $aInfo['is_image'] = true; return $aInfo; } } // check DB $oReplacement =& KTHelpReplacement::getByName($aPathInfo['internal']); if (!PEAR::isError($oReplacement)) { $aInfo['title'] = $oReplacement->getTitle(); $aInfo['body'] = $oReplacement->getDescription(); $aInfo['help_id'] = $oReplacement->getID(); $aInfo['name'] = $oReplacement->getName(); return $aInfo; } // if we don't have an external address at this point, return an error. if (empty($aPathInfo['external'])) { return PEAR::raiseError(_kt("Unable to locate the requested help file for this language.")); } // check FS if (!file_exists($aPathInfo['external'])) { return PEAR::raiseError(_kt("Unable to locate the requested help file for this language.")); } // so it might exist in some form. $contents = file_get_contents($aPathInfo['external']); $aData = KTHelp::_parseHTML($contents); $aInfo['body'] = KTUtil::arrayGet($aData, 'body'); if (empty($aInfo['body'])) { return PEAR::raiseError(_kt("The requested help language has no contents.")); } $aInfo['title'] = KTUtil::arrayGet($aData, 'title', _kt("Untitled Help File")); $aInfo['name'] = $aPathInfo['internal']; return $aInfo; }
function do_customise() { $name = KTUtil::arrayGet($_REQUEST, 'name'); $aPathInfo = KTHelp::_getLocationInfo($name); $oHelpReplacement = KTHelpReplacement::getByName($aPathInfo['internal']); // XXX: Check against "already exists" //var_dump($name); if (!PEAR::isError($oHelpReplacement)) { // Already exists... return $this->successRedirectTo('editReplacement', _kt('Replacement already exists. Editing the existing copy instead of replacing.'), 'id=' . $oHelpReplacement->getId()); } $info = KTHelp::getHelpInfo($name); if (PEAR::isError($info)) { $info = array('name' => $aPathInfo['internal']); $info['title'] = _kt('New Help File'); $info['body'] = _kt('New Help File'); } $oHelpReplacement = KTHelpReplacement::createFromArray(array('name' => $aPathInfo['internal'], 'description' => $info['body'], 'title' => $info['title'])); if (PEAR::isError($oHelpReplacement)) { return $this->errorRedirectToMain(_kt("Unable to create replacement")); } return $this->successRedirectTo('editReplacement', _kt('Created replacement.'), 'id=' . $oHelpReplacement->getId()); }