Example #1
0
 function getDisclaimer($sLocation)
 {
     $sDisclaimer = false;
     if ($this->isRegistered()) {
         $aHelp = KTHelp::getHelpInfo($sLocation);
         if (!PEAR::isError($aHelp) && strlen(trim($aHelp['body']))) {
             $sDisclaimer = str_replace('\\r\\n', '<br>', $aHelp['body']);
         }
     }
     return $sDisclaimer;
 }
Example #2
0
 * 
 * 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 "../../../config/dmsDefaults.php";
global $default;
$heading = "{$default->graphicsUrl}/heading.gif";
$hStretched = "{$default->graphicsUrl}/hrepeat.gif";
$row1 = "<img src = " . $heading . ">";
//Output a title bar
$headingBar = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"1\" width=\"100%\" height=\"10%\">\n";
$headingBar .= "\t<tr height=\"20%\">\n";
$headingBar .= "\t\t<td background=\"{$hStretched}\" width=\"100%\"><img src=\"{$heading}\"/></td>\n";
$headingBar .= "\t</tr>\n";
$headingBar .= "</table>\n";
echo $headingBar;
require_once KT_LIB_DIR . '/help/help.inc.php';
print KTHelp::getHelpStringForSection($_REQUEST['fAction']);
Example #3
0
 function do_main()
 {
     // store referer
     $sBackKey = KTUtil::arrayGet($_REQUEST, 'back_key', false);
     $sSubPath = KTUtil::arrayGet($_SERVER, 'PATH_INFO');
     // we want to be able to say "i left the system at point x.  go back there"
     if (!$sBackKey) {
         $sReferer = KTUtil::arrayGet($_SERVER, 'HTTP_REFERER');
         $sBackKey = KTUtil::randomString();
         $_SESSION[$sBackKey] = $sReferer;
     }
     // no path specified
     if (empty($sSubPath)) {
         $this->oPage->setTitle(_kt('No help page specified.'));
         $this->oPage->addError(_kt('No help page specified.'));
         return '&nbsp;';
     }
     // simple test to see if this user is active.
     $bCanEdit = Permission::userIsSystemAdministrator($_SESSION['userID']);
     global $default;
     $sLangCode = $default->defaultLanguage;
     /* 
       now we need to know a few things.  
          1. can we find this help file?
          2. if we can, display it
             2.1 images directly
             2.2 html wrapped.
          3. if now, fail out.
          
       this is essentially handled by asking help.inc.php for the 
       subpath we've been given, PLUS THE LANGUAGE, and checking for 
       a PEAR::raiseError.
       
       The "Correct" response we care about is a dictionary:
       
          {
              'is_image': string
              'title': string
              'body': string
          }
     */
     $aHelpData = KTHelp::getHelpInfo($sSubPath);
     if (PEAR::isError($aHelpData)) {
         $this->oPage->setTitle($aHelpData->getMessage());
         $this->oPage->addError($aHelpData->getMessage());
         return '&nbsp';
     }
     $aLocInfo = KTHelp::_getLocationInfo($sSubPath);
     if ($aHelpData['is_image']) {
         KTHelp::outputHelpImage($sSubPath);
         exit(0);
         // done.
     } else {
         $this->oPage->setTitle($aHelpData['title']);
         $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => $aHelpData['title']);
         $oTemplating =& KTTemplating::getSingleton();
         $oTemplate = $oTemplating->loadTemplate('ktcore/help_with_edit');
         $aTemplateData = array('context' => $this, 'help_body' => $aHelpData['body'], 'help_title' => $aHelpData['title'], 'target_name' => KTUtil::arrayGet($aLocInfo, 'subpath'), 'back_key' => $sBackKey, 'can_edit' => $bCanEdit);
         return $oTemplate->render($aTemplateData);
     }
     /*
             $help_path = KTHelp::getHelpSubPath($pathinfo);
     
             if ($help_path == false) {
                 $this->oPage->setTitle(_kt('Invalid help location specified.'));
                 $this->oPage->addError(_kt('Invalid help location specified.'));
                 return '&nbsp';
             }
     // We now check for substitute help files.  try to generate an error.
             $oReplacementHelp = KTHelpReplacement::getByName($help_path);
     
             if (KTHelp::isImageFile($help_path)) {
                 KTHelp::outputHelpImage($help_path);
             } else {
                 // not an image, so:
                 $aHelpInfo = KTHelp::getHelpFromFile($pathinfo)
             }
     
             // NORMAL users never see edit-option.
             if (!$can_edit) {
                 if (!PEAR::isError($oReplacementHelp)) {
                     $this->oPage->setTitle($oReplacementHelp->getTitle());
                     //return $oReplacementHelp->getDescription();
                 } elseif ($aHelpInfo != false) {
                     $this->oPage->setTitle($aHelpInfo['title']);
                     //return $aHelpInfo['body'];
                 } else {
                     $this->oPage->setTitle(_kt('Invalid help location specified.'));
                     $this->oPage->addError(_kt('Invalid help location specified.'));
                     return '&nbsp';
                 }
             } 
     if (!PEAR::isError($oReplacementHelp)) {
                 $aHelpInfo['title'] = $oReplacementHelp->getTitle();
                 $aHelpInfo['body'] = $oReplacementHelp->getDescription();
             }
             // we now _can_ edit.
     
     $this->oPage->setTitle($aHelpInfo['title']);
             $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => $aHelpInfo['title']);
     */
 }
<?php

require_once "../../config/dmsDefaults.php";
require_once KT_LIB_DIR . "/help/help.inc.php";
error_reporting(E_ALL);
var_dump(KTHelp::getHelpStringForSection('dashboard'));
Example #5
0
 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_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"));
 }
Example #7
0
 function is_active($oUser)
 {
     // FIXME help is a little too mixed.
     $aHelpInfo = array();
     $can_edit = Permission::userIsSystemAdministrator($_SESSION['userID']);
     $help_path = KTHelp::_getLocationInfo($this->helpLocation, null, true);
     //var_dump($help_path);
     if (PEAR::isError($help_path) || empty($help_path['external'])) {
         if ($can_edit) {
             // give it a go.
             $aHelpInfo = KTHelp::getHelpInfo($this->helpLocation);
             if (PEAR::isError($aHelpInfo)) {
                 // otherwise, fail out.
                 $aHelpInfo = array('title' => _kt('Welcome message'), 'body' => _kt('Since you are a system administrator, you can see this message. Please click "edit" below here to create some welcome content, since there is no welcome content available in your language.'));
             }
         } else {
             return false;
         }
     } else {
         // We now check for substitute help files.  try to generate an error.\
         // This function can return a PEAR Error object, we will need to check it
         $aHelpInfo = KTHelp::getHelpInfo($this->helpLocation);
         if (PEAR::isError($aHelpInfo)) {
             return false;
         }
     }
     // NORMAL users never see edit-option.
     if (!$can_edit) {
         if (empty($aHelpInfo)) {
             return false;
         }
     }
     $this->aHelpInfo = $aHelpInfo;
     $this->canEdit = $can_edit;
     $this->sTitle = str_replace('#APP_NAME#', APP_NAME, $this->aHelpInfo['title']);
     return true;
 }
Example #8
0
 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());
 }