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; }
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; }
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);