php8
[web.mtrack] / MTrackWeb / Wiki.php
index fb89a8a..3f02a18 100644 (file)
@@ -27,6 +27,7 @@ class MTrackWeb_Wiki extends MTrackWeb
     var $conflicted = 0;
     var $message = false;
     var $hasHistory = false;
+    var $title;
     
     function getAuth()
     {
@@ -36,20 +37,44 @@ class MTrackWeb_Wiki extends MTrackWeb
     function get($pi='')
     {
         // non 'json' request...
+      
         if (!isset($_REQUEST['ajax_body'])) {
             $this->title = "Browse: " . $pi;
             return;
         }
-        //DB_DataObject::debugLevel(1);
+        
         $p = DB_DataObject::Factory('Mtrack_wiki');
         $p->project_id =  $this->currentProject();
+         
 
         $p->path = $pi;
-        
+       
+        // we add stuff on the end..
+        if (empty($pi)) {
+            $px = DB_DataObject::Factory('Mtrack_wiki');
+            $px->project_id =  $this->currentProject();
+            $px->orderBy('path');
+            
+            $pr = DB_DataObject::factory('core_project');
+            $pr->get($px->project_id);
+            
+            $ar = $px->fetchAll('path');
+            $wikidata = "## Index of pages in Wiki - {$pr->name} \n\n";
+            foreach($ar as $pp) {
+                $wikidata .= " * [$pp](wiki:$pp)\n";
+            }
+            $p->wikidata = $wikidata;
+            $this->jdata($p->toArray());
+            
+            
+            
+            
+        }
         
         //var_dump($p);
         if (!$p->find(true)) {
-            $this->returnNotFound($pi);
+            $p->id = 0;
+            $this->jdata($p->toArray());
         }
         $this->jdata($p->toArray());
  
@@ -57,21 +82,18 @@ class MTrackWeb_Wiki extends MTrackWeb
     }
  
  
-    function returnNotFound($pi) {
-        $this->jdata(array(
-            'id' => 0,
-            'path' => $pi,
-            'wikidata' => ''
+    function returnNotFound($p) {
+        
         
-        ));
         
         
         
     }
  
-    function post()
+    function post($request)
     {
-        
+        //DB_DataObject::debugLevel(1);
+  
         $au = $this->getAuthUser();
         if (!$au) {
             // autherr?
@@ -104,7 +126,7 @@ class MTrackWeb_Wiki extends MTrackWeb
         }
         
         
-        call_user_method($o->id ? 'update' : 'insert', $p, $o);
+        call_user_func(array($p, $o->id ? 'update' : 'insert'),  $o);
         
         $this->jok($p->toArray());