Commit e2e0ea6fc1d4c10005f7ffb21406bca4e9756bae
1 parent
4a79c7da
Allow help files to be edited via the admin interface and saved into the
database. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3457 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
8 changed files
with
257 additions
and
12 deletions
config/siteMap.inc
| ... | ... | @@ -134,6 +134,8 @@ $default->siteMap->addPage("browseAdministration", "/presentation/lookAndFeel/kn |
| 134 | 134 | |
| 135 | 135 | $default->siteMap->addPage("docLinkManagement", "/presentation/lookAndFeel/knowledgeTree/administration/doclinkmanagement/listLinkTypesBL.php", "Administration", SysAdmin, _("Link Type Management"), true, 16); |
| 136 | 136 | |
| 137 | +$default->siteMap->addPage("helpAdmin", "/presentation/lookAndFeel/knowledgeTree/administration/help/manageHelp.php", "Administration", SysAdmin, _("Help Administration"), true, 17); | |
| 138 | + | |
| 137 | 139 | $default->siteMap->addSectionColour("Administration", "th", "056DCE"); |
| 138 | 140 | $default->siteMap->addSectionColour("Administration", "td", "6699FF"); |
| 139 | 141 | ... | ... |
config/tableMappings.inc
| ... | ... | @@ -113,4 +113,5 @@ $default->status_table = "status_lookup"; |
| 113 | 113 | $default->search_permissions_table = "search_document_user_link"; |
| 114 | 114 | $default->document_link_types_table = "document_link_types"; |
| 115 | 115 | $default->upgrades_table = "upgrades"; |
| 116 | +$default->help_replacement_table = "help_replacement"; | |
| 116 | 117 | ?> | ... | ... |
lib/help/help.inc.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +class KTHelp { | |
| 4 | + function getHelpStringForSection($sSection) { | |
| 5 | + global $default; | |
| 6 | + $sQuery = "SELECT hlp.help_info AS helpinfo FROM | |
| 7 | + $default->help_table AS hlp WHERE hlp.fSection = ?"; | |
| 8 | + $aParams = array($sSection); | |
| 9 | + $sHelpFile = DBUtil::getOneResultKey(array($sQuery, $aParams), 'helpinfo'); | |
| 10 | + if (PEAR::isError($sHelpFile)) { | |
| 11 | + return $sHelpFile; | |
| 12 | + } | |
| 13 | + $sQuery = "SELECT hlprp.description AS contents FROM | |
| 14 | + $default->help_replacement_table AS hlprp WHERE | |
| 15 | + hlprp.name = ?"; | |
| 16 | + $aParams = array($sHelpFile); | |
| 17 | + $sHelpContents = DBUtil::getOneResultKey(array($sQuery, | |
| 18 | + $aParams), 'contents'); | |
| 19 | + if (PEAR::isError($sHelpContents)) { | |
| 20 | + return $sHelpContents; | |
| 21 | + } | |
| 22 | + if (!(is_null($sHelpContents) || trim($sHelpContents) === "")) { | |
| 23 | + return $sHelpContents; | |
| 24 | + } | |
| 25 | + return file_get_contents("$default->uiDirectory/help/" . $sHelpFile); | |
| 26 | + } | |
| 27 | +} | |
| 28 | + | |
| 29 | +?> | ... | ... |
lib/help/helpreplacement.inc.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once(KT_LIB_DIR . "/ktentity.inc"); | |
| 4 | + | |
| 5 | +class KTHelpReplacement extends KTEntity { | |
| 6 | + /** primary key */ | |
| 7 | + var $iId = -1; | |
| 8 | + /** help file name */ | |
| 9 | + var $sName; | |
| 10 | + /** replacement string */ | |
| 11 | + var $sDescription; | |
| 12 | + | |
| 13 | + var $_aFieldToSelect = array( | |
| 14 | + "iId" => "id", | |
| 15 | + "sName" => "name", | |
| 16 | + "sDescription" => "description", | |
| 17 | + ); | |
| 18 | + | |
| 19 | + var $_bUsePearError = true; | |
| 20 | + | |
| 21 | + function getID() { return $this->iId; } | |
| 22 | + function getName() { return $this->sName; } | |
| 23 | + function getDescription() { return $this->sDescription; } | |
| 24 | + function setID($iId) { $this->iId = $iId; } | |
| 25 | + function setName($sName) { $this->sName = $sName; } | |
| 26 | + function setDescription($sDescription) { $this->sDescription = $sDescription; } | |
| 27 | + | |
| 28 | + function _table () { | |
| 29 | + global $default; | |
| 30 | + return $default->help_replacement_table; | |
| 31 | + } | |
| 32 | + | |
| 33 | + // STATIC | |
| 34 | + function &get($iId) { | |
| 35 | + return KTEntityUtil::get('KTHelpReplacement', $iId); | |
| 36 | + } | |
| 37 | + | |
| 38 | + // STATIC | |
| 39 | + function &createFromArray($aOptions) { | |
| 40 | + return KTEntityUtil::createFromArray('KTHelpReplacement', $aOptions); | |
| 41 | + } | |
| 42 | + | |
| 43 | + function &getList($sWhereClause = null) { | |
| 44 | + global $default; | |
| 45 | + return KTEntityUtil::getList($default->help_replacement_table, 'KTHelpReplacement', $sWhereClause); | |
| 46 | + } | |
| 47 | +} | |
| 48 | + | |
| 49 | +?> | ... | ... |
presentation/lookAndFeel/knowledgeTree/administration/help/manageHelp.php
0 → 100644
| 1 | +<?php | |
| 2 | +require_once("../../../../../config/dmsDefaults.php"); | |
| 3 | + | |
| 4 | +require_once(KT_DIR . "/presentation/Html.inc"); | |
| 5 | + | |
| 6 | +require_once(KT_LIB_DIR . "/templating/templating.inc.php"); | |
| 7 | +require_once(KT_LIB_DIR . "/help/helpreplacement.inc.php"); | |
| 8 | +require_once(KT_LIB_DIR . "/help/help.inc.php"); | |
| 9 | + | |
| 10 | +// require_once(KT_DIR . "/FCKeditor/fckeditor.php"); | |
| 11 | + | |
| 12 | +function getItemData($iId) { | |
| 13 | + $oTemplating = new KTTemplating; | |
| 14 | + $oHelp =& KTHelpReplacement::get($iId); | |
| 15 | + if (PEAR::isError($oHelp)) { | |
| 16 | + $_SESSION['KTErrorMessage'][] = "Help for that item not found"; | |
| 17 | + exit(controllerRedirect('helpAdmin')); | |
| 18 | + } | |
| 19 | + | |
| 20 | + // $oEditor = new FCKEditor("description"); | |
| 21 | + // $oEditor->Value = $oHelp->getDescription(); | |
| 22 | + // $oEditor->Height = 400; | |
| 23 | + | |
| 24 | + $oTemplate = $oTemplating->loadTemplate("ktcore/manage_help_item"); | |
| 25 | + $aTemplateData = array( | |
| 26 | + "help" => $oHelp, | |
| 27 | + // "fck" => $oEditor, | |
| 28 | + ); | |
| 29 | + return $oTemplate->render($aTemplateData); | |
| 30 | +} | |
| 31 | + | |
| 32 | +function getData() { | |
| 33 | + $oTemplating = new KTTemplating; | |
| 34 | + $aHelps = KTHelpReplacement::getList(); | |
| 35 | + $oTemplate = $oTemplating->loadTemplate("ktcore/manage_help"); | |
| 36 | + $aTemplateData = array( | |
| 37 | + "helps" => $aHelps, | |
| 38 | + ); | |
| 39 | + | |
| 40 | + return $oTemplate->render($aTemplateData); | |
| 41 | +} | |
| 42 | + | |
| 43 | +$id = KTUtil::arrayGet($_REQUEST, 'id'); | |
| 44 | +if ($id) { | |
| 45 | + $action = KTUtil::arrayGet($_REQUEST, 'action'); | |
| 46 | + if ($action === "update") { | |
| 47 | + $oHelp =& KTHelpReplacement::get($id); | |
| 48 | + if (PEAR::isError($oHelp)) { | |
| 49 | + $_SESSION['KTErrorMessage'][] = "Help for that item not found"; | |
| 50 | + exit(controllerRedirect('helpAdmin')); | |
| 51 | + } | |
| 52 | + $description = KTUtil::arrayGet($_REQUEST, 'description'); | |
| 53 | + if ($description) { | |
| 54 | + $oHelp->setDescription($description); | |
| 55 | + $res = $oHelp->update(); | |
| 56 | + if (PEAR::isError($res)) { | |
| 57 | + $_SESSION['KTErrorMessage'][] = "Error updating | |
| 58 | + object"; | |
| 59 | + $data = getItemData($id); | |
| 60 | + } else { | |
| 61 | + $_SESSION['KTErrorMessage'][] = "Updated"; | |
| 62 | + exit(controllerRedirect('helpAdmin')); | |
| 63 | + } | |
| 64 | + } else { | |
| 65 | + $_SESSION['KTErrorMessage'][] = "No description given"; | |
| 66 | + var_dump($_REQUEST); | |
| 67 | + exit(0); | |
| 68 | + $data = getItemData($id); | |
| 69 | + } | |
| 70 | + } else { | |
| 71 | + $data = getItemData($id); | |
| 72 | + } | |
| 73 | +} else { | |
| 74 | + $data = getData(); | |
| 75 | +} | |
| 76 | + | |
| 77 | +$sectionName = "Administration"; | |
| 78 | + | |
| 79 | +require_once(KT_DIR . "/presentation/webpageTemplate.inc"); | |
| 80 | +$main->bFormDisabled = true; | |
| 81 | +$main->setCentralPayload($data); | |
| 82 | +$main->render(); | |
| 83 | + | |
| 84 | +?> | ... | ... |
presentation/lookAndFeel/knowledgeTree/help.php
| ... | ... | @@ -40,16 +40,6 @@ $headingBar .= "\t</tr>\n"; |
| 40 | 40 | $headingBar .= "</table>\n"; |
| 41 | 41 | echo $headingBar; |
| 42 | 42 | |
| 43 | -//Query the database for the helpURL based on the current action | |
| 44 | -/*ok*/ $sQuery = array("SELECT HLP.help_info as helpinfo ". | |
| 45 | - "FROM $default->help_table AS HLP WHERE HLP.fSection = ?", $_REQUEST['fAction']); | |
| 46 | - | |
| 47 | -$sql = $default->db; | |
| 48 | -$sql->query($sQuery); | |
| 49 | - | |
| 50 | -if ($sql->next_record()) { | |
| 51 | - require_once("$default->uiDirectory/help/" . $sql->f("helpinfo")); | |
| 52 | -} else { | |
| 53 | - echo "No help available for " . $_REQUEST['fAction']; | |
| 54 | -} | |
| 43 | +require_once(KT_LIB_DIR . '/help/help.inc.php'); | |
| 44 | +print KTHelp::getHelpStringForSection($_REQUEST['fAction']); | |
| 55 | 45 | ?> | ... | ... |
templates/ktcore/manage_help.smarty
0 → 100644
| 1 | +<h2>Existing permissions</h2> | |
| 2 | + | |
| 3 | +{literal} | |
| 4 | +<style> | |
| 5 | +table.pretty { | |
| 6 | + margin: 0; | |
| 7 | + padding: 0; | |
| 8 | + border: 0; | |
| 9 | + border-top: 1px solid #cccccc; | |
| 10 | + border-left: 1px solid #cccccc; | |
| 11 | +} | |
| 12 | + | |
| 13 | +table.pretty > thead > tr { | |
| 14 | + border: 0; | |
| 15 | + margin: 0; | |
| 16 | + padding: 0; | |
| 17 | + background-color: #feeeee; | |
| 18 | +} | |
| 19 | + | |
| 20 | +table.pretty > thead > tr > th { | |
| 21 | + border-right: 1px solid #cccccc; | |
| 22 | + border-bottom: 2px solid #000000; | |
| 23 | + border-left: 0; | |
| 24 | + border-right: 0; | |
| 25 | + padding-left: 5px; | |
| 26 | + padding-right: 5px; | |
| 27 | + padding-top: 2px; | |
| 28 | + padding-bottom: 2px; | |
| 29 | +} | |
| 30 | + | |
| 31 | +table.pretty > tbody > tr { | |
| 32 | + border: 0; | |
| 33 | + margin: 0; | |
| 34 | + padding: 0; | |
| 35 | + background-color: #eeeefe; | |
| 36 | +} | |
| 37 | + | |
| 38 | +table.pretty > tbody > tr.odd { | |
| 39 | + background-color: #eeeefe; | |
| 40 | +} | |
| 41 | +table.pretty > tbody > tr.odd { | |
| 42 | + background-color: #fafafe; | |
| 43 | +} | |
| 44 | + | |
| 45 | +table.pretty > tbody > tr > td { | |
| 46 | + border: 0; | |
| 47 | + border-right: 1px solid #cccccc; | |
| 48 | + border-bottom: 1px solid #cccccc; | |
| 49 | + margin: 0; | |
| 50 | + padding-top: 2px; | |
| 51 | + padding-bottom: 2px; | |
| 52 | + padding-left: 3px; | |
| 53 | + padding-right: 3px; | |
| 54 | +} | |
| 55 | + | |
| 56 | + | |
| 57 | +</style> | |
| 58 | +{/literal} | |
| 59 | + | |
| 60 | +<table class="pretty" cellspacing="0" cellpadding="0" border="0"> | |
| 61 | +<thead> | |
| 62 | +<tr> | |
| 63 | +<th>Name</th> | |
| 64 | +</tr> | |
| 65 | +</thead> | |
| 66 | +{ foreach item=oHelpReplacement from=$helps } | |
| 67 | +<tr class="{cycle values="odd,even"}"> | |
| 68 | +<td> | |
| 69 | +<a href="{$smarty.server.PHP_SELF}?id={$oHelpReplacement->iId}">{ $oHelpReplacement->sName }</a> | |
| 70 | +</td> | |
| 71 | +</tr> | |
| 72 | +{ /foreach } | |
| 73 | +</table> | |
| 74 | + | ... | ... |
templates/ktcore/manage_help_item.smarty
0 → 100644
| 1 | +<script language="javascript" type="text/javascript" src="/tinymce/jscripts/tiny_mce/tiny_mce.js"></script> | |
| 2 | +<script language="javascript" type="text/javascript"> | |
| 3 | +{literal} | |
| 4 | +tinyMCE.init({ | |
| 5 | + mode : "textareas", | |
| 6 | + theme : "simple", | |
| 7 | +}); | |
| 8 | +{/literal} | |
| 9 | +</script> | |
| 10 | + | |
| 11 | +<form method="POST" action="{$smarty.server.PHP_SELF}"> | |
| 12 | +<input type="hidden" name="id" value="{$help->iId}"> | |
| 13 | +<input type="hidden" name="action" value="update"> | |
| 14 | +<textarea cols="60" rows="20" name="description">{$help->sDescription|escape}</textarea> | |
| 15 | +<input type="submit" name="submit" value="Update"> | |
| 16 | +</form> | ... | ... |