tighten return codes
[diogenes.git] / include / Barrel / Page.php
index baa9fcc..118effe 100644 (file)
@@ -87,7 +87,7 @@ class Diogenes_Barrel_Page
     if ($num > 0)
     {
       $caller->info(__("Not deleting page, it has child pages!"));
-      return;
+      return false;
     }
     
     $rcs = $caller->getRcs();
@@ -97,6 +97,7 @@ class Diogenes_Barrel_Page
     system("rm -rf ". escapeshellarg($rcs->spoolPath($dir)));
     $barrel->compileTree();
     $barrel->readTree();
+    return true;
   }
   
 
@@ -158,12 +159,13 @@ class Diogenes_Barrel_Page
   
   /** Build the 'Page' toolbar
    */
-  function make_toolbar()
+  function make_toolbar(&$caller)
   {
     global $globals;
     $props = $this->props;
     
     $topbar = array ();
+    $from = htmlentities($caller->script_uri());
     
     if ($props['PID']) {    
       $hp = $this->barrel->getPID('');
@@ -173,7 +175,7 @@ class Diogenes_Barrel_Page
       array_push($topbar, array( __("browse files"), "files?dir={$props['PID']}" ));
       array_push($topbar, array( __("page properties"), "pages?dir={$props['PID']}" ));
       array_push($topbar, array( __("view page"), "../". $this->getLocation()));
-      array_push($topbar, array(__("add a page"), "pages?action=edit&parent=".$props['PID']) );
+      array_push($topbar, array(__("add a page"), "pages?action=edit&parent=".$props['PID']."&from=$from") );
       if ($this->barrel->flags->hasFlag("plug")) {
         array_push($topbar, array( __("plugins"), "plugins?plug_page={$props['PID']}" ) );
       }
@@ -201,7 +203,7 @@ class Diogenes_Barrel_Page
   }
 
 
-  /** Write the page's properties to database
+  /** Write the page's properties to database and returns the PID of that page.
    *
    * @param $homepage
    * @param $caller
@@ -216,7 +218,7 @@ class Diogenes_Barrel_Page
     if ($props['PID'])
     {
       $cache = $globals->plugins->readCache($this->barrel->pluginsCacheFile, $this->barrel->alias);
-      $plugs_active = $globals->plugins->cacheGetActive($cache, $this->barrel->alias, $props['PID']);
+      $plugs_active = $globals->plugins->cachedActive($cache, $this->barrel->alias, $props['PID']);
       foreach($plugs_active as $plugentry)
       {
         $plug_h = $globals->plugins->load($plugentry);
@@ -232,7 +234,6 @@ class Diogenes_Barrel_Page
         }
       }
     }
-
     
     // check that the location is valid
     if ($homepage) 
@@ -323,8 +324,11 @@ class Diogenes_Barrel_Page
     
     // recompile tree
     $this->barrel->compileTree(); 
-    $this->barrel->readTree();         
-  }  
+    $this->barrel->readTree();
+
+    return $props['PID'];
+  } 
+
 }
  
 ?>