Release diogenes-0.9.22
[diogenes.git] / include / Barrel / Page.php
index b27101d..75ffe9c 100644 (file)
@@ -18,7 +18,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  
-require_once 'diogenes.icons.inc.php';
 require_once 'Barrel/File.php';
 
 
@@ -78,7 +77,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");
@@ -92,7 +98,7 @@ class Diogenes_Barrel_Page
     
     $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();
@@ -159,12 +165,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(), ENT_COMPAT | ENT_HTML401, "ISO-8859-1");
     
     if ($props['PID']) {    
       $hp = $this->barrel->getPID('');
@@ -174,7 +181,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']}" ) );
       }
@@ -202,7 +209,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
@@ -233,7 +240,6 @@ class Diogenes_Barrel_Page
         }
       }
     }
-
     
     // check that the location is valid
     if ($homepage) 
@@ -324,8 +330,11 @@ class Diogenes_Barrel_Page
     
     // recompile tree
     $this->barrel->compileTree(); 
-    $this->barrel->readTree();         
-  }  
+    $this->barrel->readTree();
+
+    return $props['PID'];
+  } 
+
 }
  
 ?>