help.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 
00028 class help extends WebObject
00029 {
00031   function on_select($event_args)
00032   {
00033     $book_id = 'docbookwiki_guide';
00034 
00035     //get languages
00036     $arr_langs = $this->get_langs($book_id);
00037     $langs = implode(',', $arr_langs);
00038     $lng = $event_args['lng'];
00039     if ($lng=='') $lng = $arr_langs[0];
00040 
00041     //get node path from node id
00042     $node_id = $event_args['topic'];
00043     $xsl = XSLT.'edit/get_node_path.xsl';
00044     $index_xml = BOOKS."$book_id/$lng/index.xml";
00045     $param_id = "--stringparam id '$node_id'";
00046     $node_path = shell("xsltproc $param_id $xsl $index_xml");
00047     if ($node_path=='')  $node_path = './';
00048 
00049     //set the state variables of the docbook webbox
00050     WebApp::setSVar('docbook->book_id', $book_id);
00051     WebApp::setSVar('docbook->node_path', $node_path);
00052     WebApp::setSVar('docbook->languages', $langs);
00053     WebApp::setSVar('docbook->lng', $lng);
00054     WebApp::setSVar('docbook->mode', 'view');
00055 
00056     //set book_title
00057     $book_title = $this->get_book_title($book_id, $lng);
00058     WebApp::setSVar('book_title', $book_title);
00059   }
00060 
00061   function afterParse()
00062   {
00063     //disable webnotes
00064     WebApp::setSVar('webnotes->page_id', '');
00065 
00066     //don't show the logo 'Powered by phpWebApp'
00067     WebApp::addGlobalVar('hide_webapp_logo', 'true');
00068   }
00069 
00074   function get_langs($book_id)
00075   {
00076     $book_path = BOOKS.$book_id.'/';
00077     if (!file_exists($book_path))  return array();
00078 
00079     $langs = shell("ls $book_path");
00080     $arr_langs = explode("\n", chop($langs));
00081 
00082     return $arr_langs;
00083   }
00084 
00085   function get_book_title($book_id, $lng)
00086   {
00087     $book_list = CONTENT.'books/book_list';
00088     $title = shell("grep '^$book_id:$lng:' $book_list | cut -d: -f3");
00089     $title = trim($title);
00090     return $title;
00091   }
00092 }
00093 ?>

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