[phpwebapp-commits] CVS: web_app/boxes/webnotes webnotes.txt,NONE,1.1 webnotes.php,NONE,1.1 webnotes
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2005-10-26 14:32:29
|
Update of /cvsroot/phpwebapp/web_app/boxes/webnotes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1019/boxes/webnotes Added Files: webnotes.txt webnotes.php webnotes.js webnotes.html webnotes.db webnotes.css footer.html DB.php Log Message: The webbox 'webnotes' can be used to append comments or notes to documentation pages or to other web pages. --- NEW FILE: webnotes.txt --- The webbox 'webnotes' can be used to append comments or notes to documentation pages or to other web pages. It can be included like this: <include src="{{WEBNOTES_PATH}}webnotes.html" /> WEBNOTES_PATH is defined by the framework. This component uses the database, and, if not already installed (e.g. by another application), it should be installed like this: --scr bash$ cd webnotes/db/ bash$ mysql -p -u username < webnotes.sql ---- The database connection parameters at 'templates/docbook/view/webnotes/DB.php' need to be modified as well. The application or the webbox that includes it should also give a value to the state variable 'webnotes->page_id', which is used to select from the database the notes that will be displayed. --- NEW FILE: webnotes.php --- <?php /* This file is part of DocBookWiki. DocBookWiki is a web application that displays and edits DocBook documents. Copyright (C) 2004, 2005 Dashamir Hoxha, das...@us... DocBookWiki is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. DocBookWiki is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with DocBookWiki; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ //include DB support include_once dirname(__FILE__).'/DB.php'; class webnotes extends WebObject { function init() { $this->addSVar('page_id', ''); } function on_next($event_args) { $page = $event_args["page"]; WebApp::setSVar("page_notes->current_page", $page); } function onRender() { //set 'recount' to true WebApp::setSVar('page_notes->recount', 'true'); //change the date format $rs = WebApp::openRS('page_notes'); while (!$rs->EOF()) { $date = $rs->Field('date_modified'); $date = date('d-M-Y G:i', strtotime($date)); $rs->setFld('date_modified', $date); $rs->MoveNext(); } global $webPage; $webPage->addRecordset($rs); } } ?> --- NEW FILE: webnotes.js --- // -*-C-*- /* This file is part of DocBookWiki. DocBookWiki is a web application that displays and edits DocBook documents. Copyright (C) 2004, 2005 Dashamir Hoxha, das...@us... DocBookWiki is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. DocBookWiki is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with DocBookWiki; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ function edit_note(note_id) { var event_args = 'note_id='+note_id+';'+'status='+status; SendEvent('editnote', 'edit', event_args); } --- NEW FILE: webnotes.html --- <webbox id="webnotes"> <div class="webnotes"> <include src="{{./}}editnote/editnote.html" /> <br /> <table class="header" cellspacing="0"> <tr> <td> T_("User Comments/Notes For the Page:") <strong>{{page_id}}</strong> </td> <td align="right"> <a class="button" href="javascript:add_note()">T_("Add a New Note")</a> </td> </tr> </table> <repeat rs="page_notes"> <ifempty><br/></ifempty> <var name="note">({{CurrentRowNr}} % 2 ? "note-1" : "note-2")</var> <a name="{{note_id}}"></a> <table class="{{note}}" cellpadding="2" cellspacing="0"> <tr class="note-title"> <td> {{date_modified}} <strong>{{email}}</strong> </td> <td align="right"> #{{note_id}} </td> </tr> <tr class="note-text"> <td colspan="2"><tt>{{note_text}}</tt></td> </tr> </table> </repeat> <include src="{{./}}footer.html" /> </div> </webbox> --- NEW FILE: webnotes.db --- <!--# -*-SQL-*- #tell emacs to use SQL mode #--> <Recordset ID="page_notes" type="PagedRS" recs_per_page="10"> <Query> SELECT * FROM webnotes WHERE page_id = '{{page_id}}' AND status = 'approved' </Query> </Recordset> --- NEW FILE: webnotes.css --- div.webnotes { } div.webnotes .button, div.webnotes a.button, div.webnotes a.button:hover { margin: 1px; border: none; padding: 1px 3px; background: #0088bb; color: #ffffff; font-weight: bold; } div.webnotes table { border: 0px; width: 100%; } div.webnotes tr { vertical-align: top; } div.webnotes td { font-family: Verdana, Arial; font-size: 10pt; padding: 4px; } div.webnotes .header { background-color: #e0e0e0; border: 1px outset #e0e0e0; } div.webnotes .note-1, div.webnotes .note-2 { border: 1px solid #aaaaaa; margin-top: 2px; margin-bottom: 2px; } .note-1 .note-title { background-color: #ddddd6; } .note-1 .note-text { background-color: #eeeee6; } .note-2 .note-title { background-color: #e6e6ee; } .note-2 .note-text { background-color: #f6f6f6; } --- NEW FILE: footer.html --- <rsnavig rs="page_notes"> <table width="100%" border="0" cellspacing="0" cellpading="3" bgcolor="#dddddd"> <tr> <td width="25%"> T_("Found: {{AllRecs}} Notes") </td> <td width="25%"> T_("Page {{CurrPage}} of {{LastPage}}") </td> <td> <if condition="'{{CurrPage}}' > '{{PrevPage}}'"> <a href="javascript:SendEvent('webnotes','next','page=1')"> T_("&lt;&lt;First") </a> <a href="javascript:SendEvent('webnotes','next','page={{PrevPage}}')"> T_("&lt;Prev") </a> </if> <if condition="'{{NextPage}}' > '{{CurrPage}}'"> <a href="javascript:SendEvent('webnotes','next','page={{NextPage}}')"> T_("Next&gt;") </a> <a href="javascript:SendEvent('webnotes','next','page={{LastPage}}')"> T_("Last&gt;&gt;") </a> </if> </td> <td align="right"> <a class="button" href="javascript:add_note()">T_("Add a New Note")</a> </td> </tr> </table> </rsnavig> --- NEW FILE: DB.php --- <?php //connection parameters $host = 'localhost'; $user = 'dasho'; $passwd = 'dasho'; $db = 'webnotes'; //include database classes include_once DB_PATH."class.MySQLCnn.php"; include_once DB_PATH."class.Recordset.php"; include_once DB_PATH."class.EditableRS.php"; include_once DB_PATH."class.PagedRS.php"; //create a global connection variable global $cnn; $cnn = new MySQLCnn($host, $user, $passwd, $db); ?> |