00001 <?php
00002
00015
00016
00017
00018 define('HELP_DEFAULT_TOPIC', 'index/topic/000000');
00019 define('HELP_DEFAULT_TOC', 'index/toc/000000');
00020
00021 import('help.HelpToc');
00022 import('help.HelpTocDAO');
00023 import('help.HelpTopic');
00024 import('help.HelpTopicDAO');
00025 import('help.HelpTopicSection');
00026
00027 class HelpHandler extends Handler {
00028
00032 function index() {
00033 HelpHandler::view(array('index', 'topic', '000000'));
00034 }
00035
00036 function toc() {
00037 parent::validate();
00038 HelpHandler::setupTemplate();
00039
00040 $templateMgr = &TemplateManager::getManager();
00041 $help =& Help::getHelp();
00042 $templateMgr->assign_by_ref('helpToc', $help->getTableOfContents());
00043 $templateMgr->display('help/helpToc.tpl');
00044 }
00045
00050 function view($args) {
00051 parent::validate();
00052 HelpHandler::setupTemplate();
00053
00054 $topicId = implode("/",$args);
00055 $keyword = trim(String::regexp_replace('/[^\w\s\.\-]/', '', strip_tags(Request::getUserVar('keyword'))));
00056 $result = (int) Request::getUserVar('result');
00057
00058 $topicDao = &DAORegistry::getDAO('HelpTopicDAO');
00059 $topic = $topicDao->getTopic($topicId);
00060
00061 if ($topic === false) {
00062
00063 $topicId = HELP_DEFAULT_TOPIC;
00064 $topic = $topicDao->getTopic($topicId);
00065 }
00066
00067 $tocDao = &DAORegistry::getDAO('HelpTocDAO');
00068 $toc = $tocDao->getToc($topic->getTocId());
00069
00070 if ($toc === false) {
00071
00072 $toc = $tocDao->getToc(HELP_DEFAULT_TOC);
00073 }
00074
00075 if ($topic->getSubTocId() != null) {
00076 $subToc = $tocDao->getToc($topic->getSubTocId());
00077 } else {
00078 $subToc = null;
00079 }
00080
00081 $relatedTopics = $topic->getRelatedTopics();
00082
00083 $topics = $toc->getTopics();
00084
00085 $templateMgr = &TemplateManager::getManager();
00086 $templateMgr->assign('currentTopicId', $topic->getId());
00087 $templateMgr->assign_by_ref('topic', $topic);
00088 $templateMgr->assign('toc', $toc);
00089 $templateMgr->assign('subToc', $subToc);
00090 $templateMgr->assign('relatedTopics', $relatedTopics);
00091 $templateMgr->assign('locale', Locale::getLocale());
00092 $templateMgr->assign('breadcrumbs', $toc->getBreadcrumbs());
00093 if (!empty($keyword)) {
00094 $templateMgr->assign('helpSearchKeyword', $keyword);
00095 }
00096 if (!empty($result)) {
00097 $templateMgr->assign('helpSearchResult', $result);
00098 }
00099 $templateMgr->display('help/view.tpl');
00100 }
00101
00105 function search() {
00106 parent::validate();
00107 HelpHandler::setupTemplate();
00108
00109 $searchResults = array();
00110
00111 $keyword = trim(String::regexp_replace('/[^\w\s\.\-]/', '', strip_tags(Request::getUserVar('keyword'))));
00112
00113 if (!empty($keyword)) {
00114 $topicDao = &DAORegistry::getDAO('HelpTopicDAO');
00115 $topics = $topicDao->getTopicsByKeyword($keyword);
00116
00117 $tocDao = &DAORegistry::getDAO('HelpTocDAO');
00118 foreach ($topics as $topic) {
00119 $searchResults[] = array('topic' => $topic, 'toc' => $tocDao->getToc($topic->getTocId()));
00120 }
00121 }
00122
00123 $templateMgr = &TemplateManager::getManager();
00124 $templateMgr->assign('showSearch', true);
00125 $templateMgr->assign('pageTitle', Locale::translate('help.searchResults'));
00126 $templateMgr->assign('helpSearchKeyword', $keyword);
00127 $templateMgr->assign('searchResults', $searchResults);
00128 $templateMgr->display('help/searchResults.tpl');
00129 }
00130
00134 function setupTemplate() {
00135 $templateMgr =& TemplateManager::getManager();
00136 $templateMgr->setCacheability(CACHEABILITY_PUBLIC);
00137 }
00138 }
00139
00140 ?>