function onSubmit($vals) { loader_import('saf.File'); loader_import('saf.File.Directory'); loader_import('saf.Misc.Ini'); $info = help_get_langs($vals['appname']); $info[$vals['lang_code']] = $vals['lang_name']; if (!@mkdir(site_docroot() . '/inc/app/' . $vals['appname'] . '/docs/' . $vals['lang_code'], 0777)) { echo '<p>Error: Unable to create language folder. Please verify your folder permissions.</p>'; return; } if (!file_overwrite(site_docroot() . '/inc/app/' . $vals['appname'] . '/docs/languages.php', ini_write($info))) { echo '<p>Error: Unable to write to the file. Please verify your folder permissions.</p>'; return; } if (!empty($vals['copy_from'])) { // copy help files from specified lang to new dir $pages = help_get_pages($vals['appname'], $vals['lang']); foreach ($pages as $page) { $id = help_get_id($page); $res = copy(site_docroot() . '/inc/app/' . $vals['appname'] . '/docs/' . $vals['lang'] . '/' . $id . '.html', site_docroot() . '/inc/app/' . $vals['appname'] . '/docs/' . $vals['lang_code'] . '/' . $id . '.html'); if (!$res) { echo '<p>Error: Unable to duplicate help files. Please verify your folder permissions.</p>'; return; } } } // go to new language header('Location: ' . site_prefix() . '/index/appdoc-helpdoc-action?appname=' . $vals['appname'] . '&lang=' . $vals['lang_code']); exit; }
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);
$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']); $previous = help_get_previous($parameters['appname'], $parameters['lang'], $parameters['helpfile'], $pages); if ($previous) { $data['previous_id'] = $previous['id']; $data['previous_title'] = $previous['title']; } else { $data['previous_id'] = false; } $next = help_get_next($parameters['appname'], $parameters['lang'], $parameters['helpfile'], $pages); if ($next) { $data['next_id'] = $next['id']; $data['next_title'] = $next['title']; } else { $data['next_id'] = false; } echo template_simple('nav.spt', $data);