1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
<?php
/**
* Help display script.
*
* Copyright 1999-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL-2). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl.
*
* @category Horde
* @license http://www.horde.org/licenses/lgpl LGPL-2
* @package Horde
*/
require_once __DIR__ . '/../../lib/Application.php';
Horde_Registry::appInit('horde', array('authentication' => 'none'));
$vars = $injector->getInstance('Horde_Variables');
$rtl = $registry->nlsconfig->curr_rtl;
$show = isset($vars->show)
? Horde_String::lower($vars->show)
: 'index';
$module = isset($vars->module)
? Horde_String::lower(preg_replace('/\W/', '', $vars->module))
: 'horde';
$topic = $vars->get('topic', 'overview');
$base_url = $registry->getServiceLink('help', $module);
$sidebar_url = Horde::url($base_url->copy()->add(array(
'show' => 'sidebar',
'topic' => $topic
)));
if ($show == 'index') {
$main_url = Horde::url($base_url->copy()->add(array(
'show' => 'entry',
'topic' => $topic
)));
$menu_url = Horde::url($base_url->copy()->add('show', 'menu'));
require HORDE_TEMPLATES . '/help/index.inc';
exit;
}
$help_app = $registry->get('name', ($module == 'admin') ? 'horde' : $module);
$fileroot = ($module == 'admin')
? $registry->get('fileroot') . '/admin'
: $registry->get('fileroot', $module);
$fileroots = array(
$fileroot . '/locale/' . $language . '/',
$fileroot . '/locale/' . substr($language, 0, 2) . '/',
$fileroot . '/locale/en/'
);
foreach ($fileroots as $val) {
$fname = $val . 'help.xml';
if (@is_file($fname)) {
break;
}
}
$views = array();
switch ($registry->getView()) {
case $registry::VIEW_BASIC:
$views[] = 'basic';
break;
case $registry::VIEW_DYNAMIC:
$views[] = 'dynamic';
break;
}
$help = new Horde_Help(Horde_Help::SOURCE_FILE, $fname, $views);
$page_output->sidebar = $page_output->topbar = false;
$page_output->header(array(
'body_class' => 'help help_' . urlencode($show),
'title' => _("Help")
));
switch ($show) {
case 'menu':
$version = Horde_String::ucfirst($module) . ' ' . $registry->getVersion($module);
require HORDE_TEMPLATES . '/help/menu.inc';
break;
case 'sidebar':
/* Generate Tabs */
if (!isset($vars->side_show)) {
$vars->side_show = 'index';
}
$tabs = new Horde_Core_Ui_Tabs('side_show', $vars);
$tabs->addTab(_("Help _Topics"), $sidebar_url, 'index');
$tabs->addTab(_("Sea_rch"), $sidebar_url, 'search');
/* Set up the tree. */
$tree = $injector->getInstance('Horde_Core_Factory_Tree')->create('horde_help', 'Javascript');
$tree->setOption(array('target' => 'help_main'));
$contents = '';
switch ($vars->get('side_show', 'index')) {
case 'index':
$topics = $help->topics();
$added_nodes = array();
$node_params_master = array(
'icon' => '',
'target' => 'help_main'
);
foreach ($topics as $id => $title) {
if (!$title) {
continue;
}
/* If the title doesn't begin with :: then replace all
* double colons with single colons. */
if (substr($title, 0, 2) != '::') {
$title = str_replace('::', ': ', $title);
}
/* Split title in multiple levels */
$levels = preg_split('/:\s/', $title);
$idx = '';
$lcount = count($levels) - 1;
$node_params = $node_params_master;
$parent = null;
foreach ($levels as $key => $name) {
$idx .= '|' . $name;
if (empty($added_nodes[$idx])) {
if ($key == $lcount) {
$node_params['url'] = $base_url->copy()->setRaw(true)->add(array(
'show' => 'entry',
'topic' => $id
));
$added_nodes[$idx] = true;
}
$tree->addNode(array(
'id' => $idx,
'parent' => $parent,
'label' => $name,
'expanded' => false,
'params' => $node_params
));
}
$parent .= '|' . $name;
}
}
break;
case 'search':
/* Create Form */
$searchForm = new Horde_Form($vars, null, 'search');
$searchForm->setButtons(_("Search"));
$searchForm->addHidden('sidebar', 'show', 'text', false);
$searchForm->addHidden('', 'module', 'text', false);
$searchForm->addHidden('', 'side_show', 'text', false);
$searchForm->addVariable(_("Keyword"), 'keyword', 'text', false, false, null, array(null, 20));
$renderer = new Horde_Form_Renderer();
$renderer->setAttrColumnWidth('50%');
Horde::startBuffer();
$searchForm->renderActive($renderer, $vars, $sidebar_url->copy()->setRaw(true), 'post');
$contents = Horde::endBuffer() . '<br />';
$keywords = $vars->get('keyword');
if (!empty($keywords)) {
$results = $help->search($keywords);
foreach ($results as $id => $title) {
if (empty($title)) {
continue;
}
$contents .= Horde::link($base_url->copy()->add(array('show' => 'entry', 'topic' => $id)), null, null, 'help_main') .
htmlspecialchars($title) . "</a><br />\n";
}
}
break;
}
require HORDE_TEMPLATES . '/help/sidebar.inc';
break;
case 'entry':
if ($topic) {
echo $help->lookup($topic);
}
break;
}
$page_output->footer();
|