aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--install/INSTALL.txt8
-rw-r--r--mod/help.php48
2 files changed, 55 insertions, 1 deletions
diff --git a/install/INSTALL.txt b/install/INSTALL.txt
index 003defeed..65df17fdd 100644
--- a/install/INSTALL.txt
+++ b/install/INSTALL.txt
@@ -137,6 +137,14 @@ use SSL, your webserver must not listen on port 443 at all.
cd mywebsite
util/update_addon_repo matrix
+ - Create searchable represenations of the online documentation. You may do this any time
+ that the documentation is updated.
+
+ cd mywebsite
+ util/importdoc
+
+
+
3. Create an empty database and note the access details (hostname, username,
password, database name).
diff --git a/mod/help.php b/mod/help.php
index 7d024a725..2ced3d30a 100644
--- a/mod/help.php
+++ b/mod/help.php
@@ -12,6 +12,9 @@
+
+
+
function load_doc_file($s) {
$lang = get_app()->language;
if(! isset($lang))
@@ -49,6 +52,30 @@ function find_doc_file($s) {
return '';
}
+function search_doc_files($s) {
+
+ $a = get_app();
+
+ $itemspage = get_pconfig(local_channel(),'system','itemspage');
+ $a->set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
+ $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
+
+ // If the file was edited more recently than we've stored a copy in the database, use the file.
+ // The stored database item will be searchable, the file won't be.
+
+ $r = q("select item_id.sid, item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and
+ body regexp '%s' and item_type = %d order by created desc $pager_sql",
+ dbesc($s),
+ intval(ITEM_TYPE_DOC)
+ );
+
+ return $r;
+}
+
+
+
+
+
function store_doc_file($s) {
@@ -93,7 +120,7 @@ function store_doc_file($s) {
}
if($x['success']) {
- update_remote_id($sys['channel_id'],$x['item_id'],ITEM_TYPE_DOC,$s,'docfile',0,$item['mid']);
+ update_remote_id($sys,$x['item_id'],ITEM_TYPE_DOC,$s,'docfile',0,$item['mid']);
}
@@ -103,6 +130,25 @@ function store_doc_file($s) {
function help_content(&$a) {
nav_set_selected('help');
+ if($_REQUEST['search']) {
+ $r = search_doc_files($_REQUEST['search']);
+ if($r) {
+ $o .= '<ul>';
+ foreach($r as $rr) {
+ $dirname = dirname($rr['sid']);
+ $fname = basename($rr['sid']);
+ $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></li>';
+
+ }
+ $o .= '</ul>';
+ }
+ return $o;
+ }
+
+
global $lang;
$doctype = 'markdown';