* improved - after adding a page, return to the calling url
[diogenes.git] / include / Barrel / Page.php
index baa9fcc..f35e739 100644 (file)
@@ -78,7 +78,14 @@ class Diogenes_Barrel_Page
   {     
     global $globals;
       
-    $caller->info(__("Deleting page"). " $dir");    
+    $loc = $barrel->getLocation($dir);
+    if (!$loc)
+    {
+      $caller->info("Error : not deleting page $dir\n");
+      return false;
+    }
+    
+    $caller->info(__("Deleting page"). " '$loc'");
     
     // check there are no child pages
     $res = $globals->db->query("select PID from {$barrel->table_page} where parent=$dir");
@@ -87,16 +94,17 @@ class Diogenes_Barrel_Page
     if ($num > 0)
     {
       $caller->info(__("Not deleting page, it has child pages!"));
-      return;
+      return false;
     }
     
     $rcs = $caller->getRcs();
     $globals->db->query("delete from {$barrel->table_page} where PID=$dir");
-    $caller->log("page_delete","{$barrel->alias}:$dir");
+    $caller->log("page_delete","{$barrel->alias}:$loc");
     system("rm -rf ". escapeshellarg($rcs->rcsPath($dir)));
     system("rm -rf ". escapeshellarg($rcs->spoolPath($dir)));
     $barrel->compileTree();
     $barrel->readTree();
+    return true;
   }
   
 
@@ -158,12 +166,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 +182,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 +210,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 +225,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 +241,6 @@ class Diogenes_Barrel_Page
         }
       }
     }
-
     
     // check that the location is valid
     if ($homepage) 
@@ -323,8 +331,11 @@ class Diogenes_Barrel_Page
     
     // recompile tree
     $this->barrel->compileTree(); 
-    $this->barrel->readTree();         
-  }  
+    $this->barrel->readTree();
+
+    return $props['PID'];
+  } 
+
 }
  
 ?>