getTag();
return substr($tag, 0, strpos($tag, '-'));
}
public function getTopics($file)
{
$result = '';
if (file_exists($file)) {
// load xml
$xml = simplexml_load_file($file);
if ($xml) {
foreach ($xml->help->children() as $topic) {
$subtopics = $topic->subtopic;
$class = count($subtopics) ? 'subtopics' : '';
$key = (string) $topic->attributes()->key;
$title = (string) $topic->attributes()->title;
$file = (string) $topic->attributes()->file;
// if file attribute load file
if ($file) {
$result .= $this->getTopics(JPATH_SITE . '/components/com_jce/editor/' . $file);
} else {
$result .= '
' . trim(JText::_($title)) . '';
}
if (count($subtopics)) {
$result .= '';
foreach ($subtopics as $subtopic) {
$sub_subtopics = $subtopic->subtopic;
// if a file is set load it as sub-subtopics
if ($file = (string) $subtopic->attributes()->file) {
$result .= '- ' . trim(JText::_((string) $subtopic->attributes()->title)) . '';
$result .= '
';
$result .= $this->getTopics(JPATH_SITE . '/components/com_jce/editor/' . $file);
$result .= '
';
$result .= ' ';
} else {
$id = $subtopic->attributes()->key ? ' id="' . (string) $subtopic->attributes()->key . '"' : '';
$class = count($sub_subtopics) ? ' class="nav-item subtopics"' : '';
$result .= '- ' . trim(JText::_((string) $subtopic->attributes()->title)) . '';
if (count($sub_subtopics)) {
$result .= '';
}
$result .= '
';
}
}
$result .= '
';
}
}
}
}
return $result;
}
/**
* Returns a formatted list of help topics.
*
* @return string
*
* @since 1.5
*/
public function renderTopics()
{
$app = JFactory::getApplication();
$section = $app->input->getWord('section', 'admin');
$category = $app->input->getWord('category', 'cpanel');
$document = JFactory::getDocument();
$language = JFactory::getLanguage();
$language->load('com_jce', JPATH_SITE);
$language->load('com_jce_pro', JPATH_SITE);
$document->setTitle(JText::_('WF_HELP') . ' : ' . JText::_('WF_' . strtoupper($category) . '_TITLE'));
switch ($section) {
case 'admin':
$file = __DIR__ . '/' . $category . '.xml';
break;
case 'editor':
$file = JPATH_SITE . '/components/com_jce/editor/tiny_mce/plugins/' . $category . '/' . $category . '.xml';
// check for installed plugin
$plugin = JPluginHelper::getPlugin('jce', 'editor-' . $category);
if ($plugin) {
$file = JPATH_PLUGINS . '/jce/editor-' . $category . '/editor-' . $category . '.xml';
$language->load('plg_jce_editor_' . $category, JPATH_ADMINISTRATOR);
}
if (!is_file($file)) {
$file = JPATH_SITE . '/components/com_jce/editor/libraries/xml/help/editor.xml';
} else {
$language->load('WF_' . $category, JPATH_SITE);
}
break;
}
$result = '';
$result .= '';
return $result;
}
}