[Jaws-project-commits] jaws/html/gadgets/Glossary Glossary.php,1.12,1.13 GlossaryModel.php,1.7,1.8
Status: Alpha
Brought to you by:
ionmx
|
From: Pablo F. <pab...@us...> - 2005-03-17 07:24:53
|
Update of /cvsroot/jaws-project/jaws/html/gadgets/Glossary In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16319 Modified Files: Glossary.php GlossaryModel.php Log Message: Works! Compatible with Jaws 0.5: * Debug done * Errors are handled by JawsError * Translation 100% Index: GlossaryModel.php =================================================================== RCS file: /cvsroot/jaws-project/jaws/html/gadgets/Glossary/GlossaryModel.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** GlossaryModel.php 15 Mar 2005 08:15:25 -0000 1.7 --- GlossaryModel.php 17 Mar 2005 07:24:40 -0000 1.8 *************** *** 6,10 **** * @author Pablo Fischer <pa...@pa...> * @copyright Jaws 2004 ! * @package JawsModel */ class GlossaryModel extends JawsModel --- 6,11 ---- * @author Pablo Fischer <pa...@pa...> * @copyright Jaws 2004 ! * @package Gadgets ! * @subpackage Glossary */ class GlossaryModel extends JawsModel *************** *** 18,23 **** { $this->_Name = "Glossary"; - $this->_Description = "This gadget will let you to have a dictionary"; - $this->_Version = "0.4"; } --- 19,22 ---- *************** *** 26,32 **** --- 25,34 ---- * * @access public + * @return boolean True on success and JawsError on failure */ function InstallGadget () { + if (!file_exists ($GLOBALS["path"]."gadgets/Glossary/sql/".$GLOBALS["app"]->DB->GetDriverName().".sql")) + return new JawsError (_t("_GLOBAL_ERROR_SQLFILE_NOT_EXISTS", $GLOBALS["app"]->DB->GetDriverName().".sql"), _t("_GLOSSARY_NAME")); // Execute the sql file $queries = explode(';',implode('',file($GLOBALS["path"]."gadgets/Glossary/sql/". *************** *** 34,38 **** foreach ($queries as $q) if (!trim($q) == '') ! $GLOBALS["app"]->DB->Execute ($q); // ACL keys --- 36,42 ---- foreach ($queries as $q) if (!trim($q) == '') ! if (!$GLOBALS["app"]->DB->Execute ($q)) ! return new JawsError (_t("_GLOBAL_ERROR_FAILED_QUERY_FILE", $GLOBALS["app"]->DB->GetDriverName().".sql"), _t("_GLOSSARY_NAME")); ! // ACL keys *************** *** 56,60 **** * @access public * @param string $letter Letter to find ! * @return array Returns an array of the terms that begin with a letter and false on error */ function GetTermsOf ($letter) --- 60,64 ---- * @access public * @param string $letter Letter to find ! * @return array Returns an array of the terms that begin with a letter and JawsError on failure */ function GetTermsOf ($letter) *************** *** 66,73 **** $rs = $GLOBALS["app"]->DB->Execute ($sql); ! if ($rs) return $rs->GetRows (); ! else ! return false; } --- 70,78 ---- $rs = $GLOBALS["app"]->DB->Execute ($sql); ! if ($rs) { return $rs->GetRows (); ! } else { ! return new JawsError (_t("_GLOBAL_ERROR_QUERY_FAILED", "GetTermsOf"), _t("_GLOSSARY_NAME")); ! } } *************** *** 108,115 **** $rs = $GLOBALS["app"]->DB->Execute ($sql, array ("id" => $id)); ! if ($rs) return $rs->FetchRow (); ! else ! return false; } --- 113,122 ---- $rs = $GLOBALS["app"]->DB->Execute ($sql, array ("id" => $id)); ! if ($rs) { return $rs->FetchRow (); ! } else { ! return new JawsError (_t("_GLOBAL_ERROR_QUERY_FAILED", "GetTerm"), _t("_GLOSSARY_NAME")); ! } ! } *************** *** 125,132 **** $rs = $GLOBALS["app"]->DB->Execute ($sql); ! if ($rs) return $rs->FetchRow (); ! else ! return false; } --- 132,140 ---- $rs = $GLOBALS["app"]->DB->Execute ($sql); ! if ($rs) { return $rs->FetchRow (); ! } else { ! return new JawsError (_t("_GLOBAL_ERROR_QUERY_FAILED", "GetRandomTerm"), _t("_GLOSSARY_NAME")); ! } } *************** *** 142,149 **** $rs = $GLOBALS["app"]->DB->Execute ($sql); ! if ($rs) return $rs->GetRows (); ! else ! return false; } --- 150,158 ---- $rs = $GLOBALS["app"]->DB->Execute ($sql); ! if ($rs) { return $rs->GetRows (); ! } else { ! return new JawsError (_t("_GLOBAL_ERROR_QUERY_FAILED", "GetTerms"), _t("_GLOSSARY_NAME")); ! } } *************** *** 161,168 **** $rs = $GLOBALS["app"]->DB->Execute ($sql, array ("id" => $id)); ! if ($rs) return true; ! else ! return false; } --- 170,180 ---- $rs = $GLOBALS["app"]->DB->Execute ($sql, array ("id" => $id)); ! if ($rs) { ! $GLOBALS["session"]->PushLastResponse (_t("_GLOSSARY_TERM_DELETED"), RESPONSE_NOTICE); return true; ! } else { ! $GLOBALS["session"]->PushLastResponse (_t("_GLOSSARY_ERROR_TERM_NOT_DELETED"), RESPONSE_ERROR); ! return new JawsError (_t("_GLOSSARY_ERROR_TERM_NOT_DELETED"), _t("_GLOSSARY_NAME")); ! } } *************** *** 185,192 **** "desc" => $desc)); ! if ($rs) return true; ! else ! return false; } --- 197,207 ---- "desc" => $desc)); ! if ($rs) { ! $GLOBALS["session"]->PushLastResponse (_t("_GLOSSARY_TERM_UPDATED"), RESPONSE_NOTICE); return true; ! } else { ! $GLOBALS["session"]->PushLastResponse (_t("_GLOSSARY_ERROR_TERM_NOT_UPDATED"), RESPONSE_ERROR); ! return new JawsError (_t("_GLOSSARY_ERROR_TERM_NOT_UPDATED"), _t("_GLOSSARY_NAME")); ! } } *************** *** 205,213 **** $rs = $GLOBALS["app"]->DB->Execute ($sql, array ("term" => $term, "desc" => $desc)); ! ! if ($rs) return true; ! else ! return false; } --- 220,231 ---- $rs = $GLOBALS["app"]->DB->Execute ($sql, array ("term" => $term, "desc" => $desc)); ! ! if ($rs) { ! $GLOBALS["session"]->PushLastResponse (_t("_GLOSSARY_TERM_ADDED"), RESPONSE_NOTICE); return true; ! } else { ! $GLOBALS["session"]->PushLastResponse (_t("_GLOSSARY_ERROR_TERM_NOT_CREATED"), RESPONSE_ERROR); ! return new JawsError (_t("_GLOSSARY_ERROR_TERM_NOT_CREATED"), _t("_GLOSSARY_NAME")); ! } } *************** *** 221,225 **** function Search ($match) { ! if (strlen(trim($match)) < 3) return false; $sql = "SELECT id, term, description, createtime FROM [[term]] WHERE"; $data = explode (" ", $match); --- 239,244 ---- function Search ($match) { ! if (strlen(trim($match)) < 3) ! return new JawsError (_t("_GLOSSARY_ERROR_CANT_SEARCH_LENGTH"), _t("_GLOSSARY_NAME")); $sql = "SELECT id, term, description, createtime FROM [[term]] WHERE"; $data = explode (" ", $match); Index: Glossary.php =================================================================== RCS file: /cvsroot/jaws-project/jaws/html/gadgets/Glossary/Glossary.php,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Glossary.php 9 Mar 2005 05:45:17 -0000 1.12 --- Glossary.php 17 Mar 2005 07:24:39 -0000 1.13 *************** *** 5,8 **** --- 5,10 ---- * @author Jonathan Hernandez <io...@gl...> * @copyright 2004 Jaws + * @package Gadgets + * @subpackage Glossary */ require_once "GlossaryModel.php"; *************** *** 11,26 **** { function Glossary () { $this->Init ('GlossaryModel'); //Actions.. ! $this->NormalAction ("DefaultAction", _("Default Action")); ! $this->NormalAction ("ViewTerm", _("View a specific term")); ! ! $this->LayoutAction ("RandomTerms", _("Random Term"), ! _("Will show a term selected randomly")); ! $this->LayoutAction ("ListOfTerms", _("List of Terms"), ! _("Will show a list of all the terms with their links to their meanings")); $this->AdminAction ("Admin"); $this->AdminAction ("EditTerm"); --- 13,33 ---- { + /** + * Constructor + * + * @access public + */ function Glossary () { $this->Init ('GlossaryModel'); //Actions.. ! $this->NormalAction ("DefaultAction"); ! $this->NormalAction ("ViewTerm"); + $this->LayoutAction ("RandomTerm", _t("_GLOSSARY_LAYOUT_RANDOM"), + _t("_GLOSSARY_LAYOUT_RANDOM_DESC")); + $this->LayoutAction ("ListOfTerm", _t("_GLOSSARY_LAYOUT_LISTOF"), + _t("_GLOSSARY_LAYOUT_LISTOF_DESC")); + $this->AdminAction ("Admin"); $this->AdminAction ("EditTerm"); *************** *** 35,38 **** --- 42,48 ---- /** * Installs Glossary gadget + * + * @access public + * @return boolean Returns true on success and JawsError on failure */ function InstallGadget () *************** *** 41,44 **** --- 51,60 ---- } + /** + * Runs the default action + * + * @access public + * @return string HTML content of Default action + */ function DefaultAction () { *************** *** 46,49 **** --- 62,71 ---- } + /** + * Look for a term and prints it + * + * @access public + * @return string HTML content + */ function ViewTerm () { *************** *** 51,62 **** $tpl->Load ("ViewTerm.html"); $tpl->SetBlock ("definition"); ! $tpl->SetVariable ("gadget_name", _("Glossary")); $term = $this->_Model->GetTerm ($_GET["term"]); ! if (count ($term) > 0) { $tpl->SetBlock ("definition/item"); $tpl->SetVariable ("term", $term["term"]); $tpl->SetVariable ("description", $this->ParseText ($term["description"])); ! $tpl->SetVariable ("created_in", _t("Create time")); ! $tpl->SetVariable ("updated_in", _t("Update time")); $tpl->SetVariable ("createtime", JawsDateFormat::Format ($term["createtime"])); $tpl->SetVariable ("updatetime", JawsDateFormat::Format ($term["updatetime"])); --- 73,84 ---- $tpl->Load ("ViewTerm.html"); $tpl->SetBlock ("definition"); ! $tpl->SetVariable ("gadget_name", _t("_GLOSSARY_NAME")); $term = $this->_Model->GetTerm ($_GET["term"]); ! if (!JawsError::IsError ($term) && isset ($term["term"])) { $tpl->SetBlock ("definition/item"); $tpl->SetVariable ("term", $term["term"]); $tpl->SetVariable ("description", $this->ParseText ($term["description"])); ! $tpl->SetVariable ("created_in", _t("_GLOBAL_CREATETIME")); ! $tpl->SetVariable ("updated_in", _t("_GLOBAL_UPDATETIME")); $tpl->SetVariable ("createtime", JawsDateFormat::Format ($term["createtime"])); $tpl->SetVariable ("updatetime", JawsDateFormat::Format ($term["updatetime"])); *************** *** 64,69 **** } else { $tpl->SetBlock ("definition/notfound"); ! $tpl->SetVariable ("term", $_GET["term"]); ! $tpl->SetVariable ("notfound", _t("The term doesn't exists")); $tpl->ParseBlock ("definition/notfound"); } --- 86,91 ---- } else { $tpl->SetBlock ("definition/notfound"); ! $tpl->SetVariable ("term", isset ($_GET["term"]) ? $_GET["term"] : _t("_GLOSSARY_ERROR_TERM_NO_TERM")); ! $tpl->SetVariable ("notfound", _t("_GLOSSARY_ERROR_TERM_DOES_NOT_EXISTS")); $tpl->ParseBlock ("definition/notfound"); } *************** *** 72,75 **** --- 94,103 ---- } + /** + * Look for a random term and prints it + * + * @access public + * @return string HTML content + */ function RandomTerms () { *************** *** 78,88 **** $tpl->SetBlock ("random"); $term = $this->_Model->GetRandomTerm (); ! $tpl->SetVariable ("gadget_name", _("Random Term")); ! $tpl->SetVariable ("term", $term["term"]); ! $tpl->SetVariable ("description", $this->ParseText ($term["description"])); $tpl->ParseBlock ("random"); return $tpl->Get (); } function ListOfTerms () { --- 106,124 ---- $tpl->SetBlock ("random"); $term = $this->_Model->GetRandomTerm (); ! if (!JawsError::IsError ($term)) { ! $tpl->SetVariable ("gadget_name", _t("_GLOSSARY_RANDOM_TERM")); ! $tpl->SetVariable ("term", $term["term"]); ! $tpl->SetVariable ("description", $this->ParseText ($term["description"])); ! } $tpl->ParseBlock ("random"); return $tpl->Get (); } + /** + * Looks for a list of terms (general) and prints them + * + * @access public + * @return string HTML Content + */ function ListOfTerms () { *************** *** 90,99 **** $tpl->Load ("SimpleList.html"); $tpl->SetBlock ("list_of_terms"); ! $tpl->SetVariable ("gadget_name", _("Glossary")); ! $term = $this->_Model->GetTerms (); ! foreach ($term as $t) { ! $tpl->SetBlock ("list_of_terms/term"); ! $tpl->SetVariable ("term", $t["term"]); ! $tpl->ParseBlock ("list_of_terms/term"); } $tpl->ParseBlock ("list_of_terms"); --- 126,137 ---- $tpl->Load ("SimpleList.html"); $tpl->SetBlock ("list_of_terms"); ! $tpl->SetVariable ("gadget_name", _t("_GLOSSARY_NAME")); ! $terms = $this->_Model->GetTerms (); ! if (!JawsError::IsError ($terms)) { ! foreach ($terms as $t) { ! $tpl->SetBlock ("list_of_terms/term"); ! $tpl->SetVariable ("term", $t["term"]); ! $tpl->ParseBlock ("list_of_terms/term"); ! } } $tpl->ParseBlock ("list_of_terms"); *************** *** 101,104 **** --- 139,148 ---- } + /** + * Look for all the terms, order them and prints them all together + * + * @access public + * @return string HTML Content + */ function Display () { *************** *** 106,121 **** $tpl->Load ("AlphabeticList.html"); $tpl->SetBlock ("list"); ! $tpl->SetVariable ("gadget_name", _("Glossary")); ! foreach ($this->_Model->GetSizeOfTerms() as $term_letter) { ! if ($term_letter["size"] > 0) { ! $tpl->SetBlock ("list/letter"); ! $tpl->SetVariable ("letter", $term_letter["letter"]); ! foreach ($this->_Model->GetTermsOf ($term_letter["letter"]) as $term) { ! $tpl->SetBlock ("list/letter/term"); ! $tpl->SetVariable ("term", $term["term"]); ! $tpl->SetVariable ("description", $this->ParseText ($term["description"])); ! $tpl->ParseBlock ("list/letter/term"); } - $tpl->ParseBlock ("list/letter"); } } --- 150,172 ---- $tpl->Load ("AlphabeticList.html"); $tpl->SetBlock ("list"); ! $tpl->SetVariable ("gadget_name", _t("_GLOSSARY_NAME")); ! $termssize = $this->_Model->GetSizeOfTerms(); ! if (!JawsError::IsError ($termssize)) { ! foreach ($this->_Model->GetSizeOfTerms() as $term_letter) { ! if ($term_letter["size"] > 0) { ! $tpl->SetBlock ("list/letter"); ! $tpl->SetVariable ("letter", $term_letter["letter"]); ! ! $termsof = $this->_Model->GetTermsOf ($term_letter["letter"]); ! if (!JawsError::IsError ($termsof)) { ! foreach ($termsof as $term) { ! $tpl->SetBlock ("list/letter/term"); ! $tpl->SetVariable ("term", $term["term"]); ! $tpl->SetVariable ("description", $this->ParseText ($term["description"])); ! $tpl->ParseBlock ("list/letter/term"); ! } ! } ! $tpl->ParseBlock ("list/letter"); } } } *************** *** 125,150 **** } function NewTerm () { $GLOBALS["session"]->CheckPermission ("Glossary", "AddTerm"); ! if ($this->_Model->NewTerm ($_POST["term"], $_POST["description"])) ! $GLOBALS["session"]->PushLastResponse (_t("A new term has been added")); ! else ! $GLOBALS["session"]->PushLastResponse (_t("There was a problem adding the term")); ! header ("Location: admin.php?gadget=Glossary&action=Admin"); } ! function DeleteTerm () { $GLOBALS["session"]->CheckPermission ("Glossary", "DeleteTerm"); ! if ($this->_Model->DeleteTerm ($_GET["id"])) ! $GLOBALS["session"]->PushLastResponse (_t("The term has been deleted")); ! else ! $GLOBALS["session"]->PushLastResponse (_t("There was a problem deleting the term")); ! header ("Location: admin.php?gadget=Glossary&action=Admin"); } ! function EditTerm () { --- 176,209 ---- } + /** + * Adds a new term + * + * @access public + */ function NewTerm () { $GLOBALS["session"]->CheckPermission ("Glossary", "AddTerm"); ! $this->_Model->NewTerm ($_POST["term"], $_POST["description"]); ! JawsHeader::Location ("admin.php?gadget=Glossary&action=Admin"); } ! /** ! * Deletes a new term ! * ! * @access public ! */ function DeleteTerm () { $GLOBALS["session"]->CheckPermission ("Glossary", "DeleteTerm"); ! $this->_Model->DeleteTerm ($_GET["id"]); ! JawsHeader::Location ("admin.php?gadget=Glossary&action=Admin"); } ! /** ! * Prepares the term Form to edit/update a term ! * ! * @access public ! * @return string HTML content of EditForm ! */ function EditTerm () { *************** *** 153,156 **** --- 212,221 ---- } + /** + * Prepares the term Form to write a new term + * + * @access public + * @return string HTML content of EditForm + */ function AddTerm () { *************** *** 159,172 **** } function UpdateTerm () { $GLOBALS["session"]->CheckPermission ("Glossary", "EditTerm"); ! if ($this->_Model->UpdateTerm ($_POST["id"], $_POST["term"], $_POST["description"])) ! $GLOBALS["session"]->PushLastResponse (_t("The term has been updated")); ! else ! $GLOBALS["session"]->PushLastResponse (_t("There was a problem updating the term")); ! header ("Location: admin.php?gadget=Glossary&action=Admin"); } function MenuBar ($action_selected) { --- 224,245 ---- } + /** + * Updates a new term + * + * @access public + */ function UpdateTerm () { $GLOBALS["session"]->CheckPermission ("Glossary", "EditTerm"); ! $this->_Model->UpdateTerm ($_POST["id"], $_POST["term"], $_POST["description"]); ! JawsHeader::Location ("admin.php?gadget=Glossary&action=Admin"); } + /** + * Builds the menubar of Glossary admin + * + * @access private + * @return string HTML of menubar + */ function MenuBar ($action_selected) { *************** *** 177,187 **** $menubar =& new JawsMenubar (); if ($GLOBALS["session"]->GetPermission ("Glossary", "default")) ! $menubar->AddOption ("Admin", _t("View Terms"), "admin.php?gadget=Glossary&action=Admin", STOCK_DOCUMENTS); if ($GLOBALS["session"]->GetPermission ("Glossary", "Addterm")) ! $menubar->AddOption ("AddTerm", _t("Add a new Term"), "admin.php?gadget=Glossary&action=AddTerm", STOCK_NEW); $menubar->Activate ($action_selected); return $menubar->Get (); } function PreviewNew () { --- 250,266 ---- $menubar =& new JawsMenubar (); if ($GLOBALS["session"]->GetPermission ("Glossary", "default")) ! $menubar->AddOption ("Admin", _t("_GLOSSARY_MENUBAR_VIEWTERMS"), "admin.php?gadget=Glossary&action=Admin", STOCK_DOCUMENTS); if ($GLOBALS["session"]->GetPermission ("Glossary", "Addterm")) ! $menubar->AddOption ("AddTerm", _t("_GLOSSARY_MENUBAR_ADDTERM"), "admin.php?gadget=Glossary&action=AddTerm", STOCK_NEW); $menubar->Activate ($action_selected); return $menubar->Get (); } + /** + * Loads again the the EditForm to continue writing the new term but also displays a preview of it + * + * @access public + * @return string HTML content of EditForm + */ function PreviewNew () { *************** *** 190,194 **** } ! function PreviewEdit () { --- 269,278 ---- } ! /** ! * Loads again the the EditForm to continue editing the term but also displays a preview of it ! * ! * @access public ! * @return string HTML content of EditForm ! */ function PreviewEdit () { *************** *** 197,200 **** --- 281,290 ---- } + /** + * Builds the EditForm + * + * @access public + * @return stirng HTML of EditForm + */ function EditForm () { *************** *** 204,218 **** $tpl->SetBlock ("edit_form"); $tpl->SetVariable("icon",JawsUtils::CheckImage("gadgets/Glossary/images/Glossary.png")); ! $tpl->SetVariable ("title","<a href=\"admin.php\">"._t("Control Panel"). ! "</a> → "._t("Glossary")); ! $tpl->SetVariable ("menubar", $this->MenuBar ($_GET["action"])); $term = array (); ! if ($_POST["action"] == "PreviewEdit" || $_POST["action"] == "PreviewNew") { $term["term"] = $_POST["term"]; $term["description"] = $_POST["description"]; $term["id"] = $_POST["id"] = $_POST["id"]; } else { ! $term = $this->_Model->GetTerm ($_GET["id"]); } --- 294,314 ---- $tpl->SetBlock ("edit_form"); $tpl->SetVariable("icon",JawsUtils::CheckImage("gadgets/Glossary/images/Glossary.png")); ! $tpl->SetVariable ("title","<a href=\"admin.php\">"._t("_CONTROLPANEL_NAME"). ! "</a> → "._t("_GLOSSARY_NAME")); ! $tpl->SetVariable ("menubar", $this->MenuBar (isset ($_GET["action"]) ? $_GET["action"] : "")); $term = array (); ! $action = isset ($_REQUEST["action"]) ? $_REQUEST["action"] : ""; ! ! if ($action == "PreviewEdit" || $action == "PreviewNew") { $term["term"] = $_POST["term"]; $term["description"] = $_POST["description"]; $term["id"] = $_POST["id"] = $_POST["id"]; } else { ! if (isset ($_GET["id"])) { ! $term = $this->_Model->GetTerm ($_GET["id"]); ! if (JawsError::IsError ($term)) ! $term = array (); ! } } *************** *** 227,236 **** } ! $termentry =& new Entry ("term", $term["term"]); ! $termentry->SetTitle (_t("Term")); $termentry->SetStyle ("width: 100%;"); ! $editor =& new JawsEditor ("Glossary", "description", $term["description"]); $termform->Add ($termentry); --- 323,332 ---- } ! $termentry =& new Entry ("term", isset ($term["term"]) ? $term["term"] : ""); ! $termentry->SetTitle (_t("_GLOSSARY_TERM")); $termentry->SetStyle ("width: 100%;"); ! $editor =& new JawsEditor ("Glossary", "description", isset ($term["description"]) ? $term["description"] : ""); $termform->Add ($termentry); *************** *** 238,247 **** if ($_GET["action"] == "AddTerm") ! $submit =& new Button ("saveterm", _t("Add Term"), STOCK_SAVE); else ! $submit =& new Button ("saveterm", _t("Update Term"), STOCK_SAVE); $submit->SetSubmit (); ! $preview =& new Button ("preview", _t("Preview"), STOCK_PRINT_PREVIEW); if ($_GET["action"] == "PreviewNew" || $_GET["action"] == "AddTerm") $preview->AddEvent (new JSEvent (ON_CLICK, "javascript: this.form.action.value = 'PreviewNew'; this.form.submit ();")); --- 334,343 ---- if ($_GET["action"] == "AddTerm") ! $submit =& new Button ("saveterm", _t("_GLOBAL_SAVE", _t("_GLOSSARY_TERM")), STOCK_SAVE); else ! $submit =& new Button ("updateterm", _t("_GLOBAL_UPDATE", _t("GLOSSARY_TERM")), STOCK_SAVE); $submit->SetSubmit (); ! $preview =& new Button ("preview", _t("_GLOBAL_PREVIEW"), STOCK_PRINT_PREVIEW); if ($_GET["action"] == "PreviewNew" || $_GET["action"] == "AddTerm") $preview->AddEvent (new JSEvent (ON_CLICK, "javascript: this.form.action.value = 'PreviewNew'; this.form.submit ();")); *************** *** 258,262 **** $tpl->SetVariable ("form", $termform->Get ()); ! if ($_POST["action"] == "PreviewNew" || $_POST["action"] == "PreviewEdit") { $tpl->SetBlock ("edit_form/preview"); $tpl->SetVariable ("term", $term["term"]); --- 354,358 ---- $tpl->SetVariable ("form", $termform->Get ()); ! if ($action == "PreviewNew" || $action == "PreviewEdit") { $tpl->SetBlock ("edit_form/preview"); $tpl->SetVariable ("term", $term["term"]); *************** *** 270,273 **** --- 366,375 ---- } + /** + * Manages the main functions of Glossary administration + * + * @access public + * @return stirng HTML Content + */ function Admin () { *************** *** 277,299 **** $tpl->SetBlock ("glossary"); $tpl->SetVariable("icon",JawsUtils::CheckImage("gadgets/Glossary/images/Glossary.png")); ! $tpl->SetVariable ("title","<a href=\"admin.php\">"._t("Control Panel"). ! "</a> → "._t("Glossary")); $tpl->SetVariable ("menubar", $this->MenuBar ($_GET["action"])); $terms = $this->_Model->GetTerms (); ! $datagrid =& new DataGrid ($terms, _t("Glossary")); ! $datagrid->SetActionLabel (_("Actions")); $datagrid->SetStyle ("width: 100%;"); ! $datagrid->AddColumn (new Column (_t("Term"), "term")); ! $datagrid->AddColumn (new Column (_t("Description"), "description", false, "String", true, "", 'nl2br')); if ($GLOBALS["session"]->GetPermission ("Glossary", "DeleteTerm")) ! $datagrid->AddColumn (new ActionColumn (_t("Delete"), ! "javascript: if (confirm ('"._t("Do you want to delete this term?")."')) ". "window.location = 'admin.php?gadget=Glossary&action=DeleteTerm&id={id}'; ", STOCK_DELETE)); if ($GLOBALS["session"]->GetPermission ("Glossary", "EditTerm")) ! $datagrid->AddColumn (new ActionColumn (_t("Edit"), "admin.php?gadget=Glossary&action=EditTerm&id={id}", STOCK_EDIT)); --- 379,402 ---- $tpl->SetBlock ("glossary"); $tpl->SetVariable("icon",JawsUtils::CheckImage("gadgets/Glossary/images/Glossary.png")); ! $tpl->SetVariable ("title","<a href=\"admin.php\">"._t("_CONTROLPANEL_NAME"). ! "</a> → "._t("_GLOSSARY_NAME")); $tpl->SetVariable ("menubar", $this->MenuBar ($_GET["action"])); $terms = $this->_Model->GetTerms (); ! $datagrid =& new DataGrid ($terms, _t("_GLOSSARY_NAME")); ! $datagrid->SetActionLabel (_t("_GLOBAL_ACTIONS")); $datagrid->SetStyle ("width: 100%;"); ! $datagrid->AddColumn (new Column (_t("_GLOSSARY_TERM"), "term")); ! $datagrid->AddColumn (new Column (_t("_GLOSSARY_DESCRIPTION"), "description", false, "String", true, "", 'nl2br')); if ($GLOBALS["session"]->GetPermission ("Glossary", "DeleteTerm")) ! $datagrid->AddColumn (new ActionColumn (_t("_GLOBAL_DELETE"), ! "javascript: if (confirm ('"._t("_GLOBAL_CONFIRM_DELETE", _t("_GLOSSARY_TERM"))."')) ". "window.location = 'admin.php?gadget=Glossary&action=DeleteTerm&id={id}'; ", + STOCK_DELETE)); if ($GLOBALS["session"]->GetPermission ("Glossary", "EditTerm")) ! $datagrid->AddColumn (new ActionColumn (_t("_GLOBAL_EDIT"), "admin.php?gadget=Glossary&action=EditTerm&id={id}", STOCK_EDIT)); *************** *** 301,307 **** //show response ! if ($response = $GLOBALS["session"]->PopLastResponse("Glossary")) { $tpl->SetBlock ("glossary/message"); ! $tpl->SetVariable ("message", $response); $tpl->ParseBlock ("glossary/message"); } --- 404,411 ---- //show response ! if ($response = $GLOBALS["session"]->PopLastResponse()) { $tpl->SetBlock ("glossary/message"); ! $tpl->SetVariable ("message", $response["message"]); ! $tpl->SetVariable ("class", $response["css"]); $tpl->ParseBlock ("glossary/message"); } |