templates/docbook/admin/admin.php

Go to the documentation of this file.
00001 <?php
00002   /*
00003    This file is part of DocBookWiki.  DocBookWiki is a web application
00004    that displays and edits DocBook documents.
00005 
00006    Copyright (C) 2004, 2005, 2006, 2007
00007    Dashamir Hoxha, dashohoxha@users.sourceforge.net
00008 
00009    DocBookWiki is free software; you can redistribute it and/or modify
00010    it under the  terms of the GNU General  Public License as published
00011    by the Free  Software Foundation; either version 2  of the License,
00012    or (at your option) any later version.
00013 
00014    DocBookWiki is distributed in the  hope that it will be useful, but
00015    WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
00016    MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
00017    General Public License for more details.
00018 
00019    You should have  received a copy of the  GNU General Public License
00020    along  with  DocBookWiki;  if  not,  write  to  the  Free  Software
00021    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022    USA
00023   */
00024 
00032 class admin extends WebObject
00033 {
00034   function on_update_search_index($event_args)
00035   {
00036     //running the script may take a long time
00037     set_time_limit(0);
00038 
00039     //get the current book parameters
00040     $book_id = WebApp::getSVar('docbook->book_id');
00041     $lng = WebApp::getSVar('docbook->lng');
00042 
00043     //open the html document and print a title
00044     $title = T_("Updating Search Indexes");
00045     print "<html><title>$title</title><body><h3>$title</h3><xmp>\n";
00046     flush();
00047 
00048     //run the script and send the output
00049     $data_owner = DATA_OWNER;
00050     passthru("sudo -u $data_owner search/make_index.sh 2>&1");
00051 
00052     //close the html document
00053     print "\n</xmp></body></html>";
00054 
00055     //stop proccessing
00056     exit;
00057   }
00058 
00059   function on_update_downloadables($event_args)
00060   {
00061     //running the script may take a long time
00062     set_time_limit(0);
00063 
00064     //get the current book parameters
00065     $book_id = WebApp::getSVar('docbook->book_id');
00066     $lng = WebApp::getSVar('docbook->lng');
00067 
00068     //open the html document and print a title
00069     $title = T_("Generating Downloadables For v_book_lng");
00070     $title = str_replace('v_book_lng', "'$book_id/$lng'", $title);
00071     print "<html><title>$title</title><body><h3>$title</h3><xmp>\n";
00072     flush();
00073 
00074     //run the script and send the output
00075     $data_owner = DATA_OWNER;
00076     $update_downloads_sh = 'content/downloads/update_downloads.sh';
00077     passthru("sudo -u $data_owner $update_downloads_sh $book_id $lng 2>&1");
00078 
00079     //close the html document
00080     print "\n</xmp></body></html>";
00081 
00082     //stop proccessing
00083     exit;
00084   }
00085 
00086   function on_update_booklist($event_args)
00087   {
00088     shell("content/book_list.sh");
00089   }
00090 
00091   function onRender()
00092   {
00093     $this->add_rs_modified_nodes();
00094   }
00095 
00097   function add_rs_modified_nodes()
00098   {
00099     $rs = new EditableRS('modified_nodes');
00100 
00101     $book_id = WebApp::getSVar('docbook->book_id');
00102     $lng = WebApp::getSVar('docbook->lng');
00103     $filename = WS_BOOKS."$book_id/$lng/modified_nodes.txt";
00104 
00105     if (file_exists($filename))
00106       {
00107         $arr_modified_nodes = file($filename);
00108         for ($i=0; $i < sizeof($arr_modified_nodes); $i++)
00109           {
00110             $node_path = $arr_modified_nodes[$i];
00111             $node_path = trim($node_path);
00112             $node_title = $this->get_title($book_id, $lng, $node_path);
00113             $rec = compact('node_path', 'node_title');
00114             $rs->addRec($rec);          
00115           }
00116       }
00117 
00118     global $webPage;
00119     $webPage->addRecordset($rs);
00120   }
00121 
00122   function get_title($book_id, $lng, $node_path)
00123   {
00124     $cache_path = WS_CACHE."$book_id/$lng/";
00125     $navigation_file = $cache_path.$node_path."navigation.txt";
00126     $line = shell("grep full_title $navigation_file");
00127     $arr = split('=', chop($line), 2);
00128     $title = $arr[1];
00129     if ($title=='')  $title = 'Table Of Contents';
00130     return $title;
00131   }
00132 }
00133 ?>

Generated on Wed Jan 9 08:27:32 2008 for DokBookWiki by  doxygen 1.5.2