streams/Zotlabs/Module/Help.php

104 lines
2.8 KiB
PHP
Raw Normal View History

2016-04-19 03:38:38 +00:00
<?php
namespace Zotlabs\Module;
require_once('include/help.php');
/**
* You can create local site resources in doc/Site.md and either link to doc/Home.md for the standard resources
* or use our include mechanism to include it on your local page.
*@code
2016-04-19 03:38:38 +00:00
* #include doc/Home.md;
*@endcode
2016-04-19 03:38:38 +00:00
*
* The syntax is somewhat strict.
2016-04-19 03:38:38 +00:00
*/
class Help extends \Zotlabs\Web\Controller {
function get() {
nav_set_selected('Help');
2016-04-19 03:38:38 +00:00
if($_REQUEST['search']) {
$o .= '<div id="help-content" class="generic-content-wrapper">';
$o .= '<div class="section-title-wrapper">';
$o .= '<h2>' . t('Documentation Search') . ' - ' . htmlspecialchars($_REQUEST['search']) . '</h2>';
$o .= '</div>';
$o .= '<div class="section-content-wrapper">';
2016-04-19 03:38:38 +00:00
$r = search_doc_files($_REQUEST['search']);
if($r) {
$o .= '<ul class="help-searchlist">';
foreach($r as $rr) {
2016-08-27 22:30:46 +00:00
$dirname = dirname($rr['v']);
$fname = basename($rr['v']);
$fname = substr($fname, 0, strrpos($fname, '.'));
$path = trim(substr($dirname, 4), '/');
$o .= '<li><a href="help/' . (($path) ? $path . '/' : '') . $fname . '" >' . ucwords(str_replace('_',' ',notags($fname))) . '</a><br>'
. '<b><i>' . 'help/' . (($path) ? $path . '/' : '') . $fname . '</i></b><br>'
. '...' . str_replace('$Projectname', \Zotlabs\Lib\System::get_platform_name(), $rr['text']) . '...<br><br></li>';
2016-04-19 03:38:38 +00:00
}
$o .= '</ul>';
$o .= '</div>';
$o .= '</div>';
}
2016-04-19 03:38:38 +00:00
return $o;
}
if(argc() > 2 && argv(argc()-2) === 'assets') {
$path = '';
for($x = 1; $x < argc(); $x ++) {
if(strlen($path))
$path .= '/';
$path .= argv($x);
}
$realpath = 'doc/' . $path;
//Set the content-type header as appropriate
$imageInfo = getimagesize($realpath);
switch ($imageInfo[2]) {
case IMAGETYPE_JPEG:
header("Content-Type: image/jpeg");
break;
case IMAGETYPE_GIF:
header("Content-Type: image/gif");
break;
case IMAGETYPE_PNG:
header("Content-Type: image/png");
break;
default:
break;
}
header("Content-Length: " . filesize($realpath));
// dump the picture and stop the script
readfile($realpath);
killme();
}
2016-12-11 20:43:27 +00:00
$headings = [
'about' => t('About'),
'member' => t('Members'),
'admin' => t('Administrators'),
2016-12-11 20:43:27 +00:00
'developer' => t('Developers'),
'tutorials' => t('Tutorials')
];
if(array_key_exists(argv(1), $headings))
$heading = $headings[argv(1)];
$content = get_help_content();
$language = determine_help_language()['language'];
return replace_macros(get_markup_template('help.tpl'), array(
'$title' => t('$Projectname Documentation'),
'$tocHeading' => t('Contents'),
'$content' => $content,
'$heading' => $heading,
'$language' => $language
2016-04-19 03:38:38 +00:00
));
}
2016-04-19 03:38:38 +00:00
}