$vals['filename'] .= '.html'; } if (!preg_match('/\\.html$/', $vals['helpfile'])) { $vals['helpfile'] .= '.html'; } $vals['body'] = '<h1>' . $vals['title'] . '</h1>' . NEWLINEx2 . $vals['body']; if (!file_overwrite(site_docroot() . '/inc/app/' . $vals['appname'] . '/docs/' . $vals['lang'] . '/' . $vals['filename'], $vals['body'])) { echo '<p>Error: Unable to write to the file. Please verify your file and folder permissions.</p>'; return; } if ($vals['helpfile'] != $vals['filename']) { // erase old file, this is a rename $res = @unlink(site_docroot() . '/inc/app/' . $vals['appname'] . '/docs/' . $vals['lang'] . '/' . $vals['helpfile']); if (!$res) { echo '<p>Error: Unable to remove the old file. Please verify your file and folder permissions.</p>'; return; } } header('Location: ' . site_prefix() . '/index/appdoc-helpdoc-action?appname=' . $vals['appname'] . '&lang=' . $vals['lang']); exit; } } $GLOBALS['_helpdoc'] = new StdClass(); global $cgi, $_helpdoc; loader_import('help.Help'); $_helpdoc->body = @join('', @file('inc/app/' . $cgi->appname . '/docs/' . $cgi->lang . '/' . $cgi->helpfile . '.html')); $_helpdoc->title = help_get_title($_helpdoc->body, $cgi->helpfile); $_helpdoc->body = preg_replace('/<h[1-6][^>]*>([^<]+)<\\/h[1-6]>[\\r\\n]*/i', '', $_helpdoc->body, 1); page_title(intl_get('Editing Help File') . ': ' . $cgi->title); $form = new EditForm(); echo $form->run();
if (empty($cgi->appname) || strstr($cgi->appname, '..') || !@is_dir('inc/app/' . $cgi->appname)) { header('Location: ' . site_prefix() . '/index/appdoc-app'); exit; } if (empty($cgi->lang)) { $cgi->lang = 'en'; } $info = ini_parse(getcwd() . '/inc/app/' . $cgi->appname . '/conf/config.ini.php', false); page_title(intl_get('Help Files') . ': ' . $info['app_name']); if (!@is_dir('inc/app/' . $cgi->appname . '/docs/' . $cgi->lang)) { loader_import('saf.File.Directory'); $res = Dir::build('inc/app/' . $cgi->appname . '/docs/' . $cgi->lang, 0777); if (!$res) { echo '<p>' . intl_get('Failed to create directory') . ': docs/' . $cgi->lang . '</p>'; echo '<p><a href="javascript: history.go (-1)">' . intl_get('Back') . '</a></p>'; return; } } loader_import('help.Help'); $data = array('appname' => $cgi->appname, 'lang' => $cgi->lang, 'files' => array(), 'langs' => help_get_langs($cgi->appname)); $files = help_get_pages($cgi->appname, $cgi->lang); if (!is_array($files)) { $files = array(); } foreach ($files as $file) { $id = help_get_id($file); $body = @join('', @file($file)); $word_count = count(preg_split('/\\W+/s', strip_tags($body), -1, PREG_SPLIT_NO_EMPTY)); $data['files'][basename($file)] = array('id' => $id, 'title' => help_get_title($body, $id), 'words' => $word_count); } echo template_simple('helpdoc.spt', $data);
function help_get_next($appname, $lang, $current, $files) { // get rid of index.html $key = array_search('inc/app/' . $appname . '/docs/' . $lang . '/index.html', $files); if ($key !== false && $key !== null) { unset($files[$key]); } // find current file $fullname = 'inc/app/' . $appname . '/docs/' . $lang . '/' . $current . '.html'; $key = array_search($fullname, $files); if ($key !== false && $key !== null) { $key++; if (!isset($files[$key])) { return false; } // get id and title of next page $data = @join('', @file($files[$key])); $id = help_get_id($files[$key]); return array('id' => $id, 'title' => help_get_title($data, $id)); } return false; }
} else { $next_id = false; $next_title = false; } echo template_simple('nav-toc.spt', array('appname' => $parameters['appname'], 'fullname' => $fullname, 'next_id' => $next_id, 'next_title' => $next_title, 'lang' => $parameters['lang'])); echo '<h1>' . intl_get($fullname) . ' ' . intl_get('Help') . '</h1>'; echo '<h2>' . intl_get('Table of Contents') . '</h2>'; echo '<ol>'; loader_import('help.Help'); foreach ($pages as $file) { $id = help_get_id($file); if ($id == 'index') { continue; } $body = @join(@file($file)); $title = help_get_title($body, $id); echo '<li><a href="' . site_prefix() . '/index/help-app?appname=' . $parameters['appname'] . '&lang=' . $parameters['lang'] . '&helpfile=' . $id . '">' . $title . '</a></li>'; } echo '</ol>'; return; } $out = join('', file('inc/app/' . $parameters['appname'] . '/docs/' . $parameters['lang'] . '/' . $parameters['helpfile'] . '.html')); if (!empty($parameters['highlight'])) { loader_import('help.Help'); foreach (help_split_query($parameters['highlight']) as $item) { $out = preg_replace('/(' . preg_quote($item, '/') . ')/i', '<span style=\'background-color: #ff0\'>\\1</span>', $out); } $out = '<p style=\'background-color: #ff0; padding: 3px; margin-top: 20px\'><strong>' . intl_get('Highlighting Search Terms') . '</strong>: ' . htmlentities($parameters['highlight']) . '</p>' . $out; } // build navigation $pages = help_get_pages($parameters['appname'], $parameters['lang']);