[Phpslash-commit] CVS: phpslash-ft/class Glossary.class,1.5,1.6
Brought to you by:
joestewart,
nhruby
From: Joe S. <joe...@us...> - 2001-12-10 21:42:39
|
Update of /cvsroot/phpslash/phpslash-ft/class In directory usw-pr-cvs1:/tmp/cvs-serv19006/phpslash-ft/class Modified Files: Glossary.class Log Message: bugfix - moved Glossaryt color defs to template Index: Glossary.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-ft/class/Glossary.class,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Glossary.class 2001/11/23 18:00:44 1.5 --- Glossary.class 2001/12/10 21:42:36 1.6 *************** *** 1,208 **** ! <?php ! ! /* $Id$ */ ! ! /* ! * Class: Glossary ! * ! * Layer: All ! * Desc.: ! * ! */ ! class Glossary { ! var $templ,$db,$cell_color_1,$cell_color_2,$psl; ! ! /* ! * CONSTRUCTORS ! */ ! function Glossary () { ! ! global $_PSL; ! ! $this->db = new slashDB; ! $this->psl = $_PSL; ! ! $this->cell_color_1 = "#ECECFF"; ! $this->cell_color_2 = "#F7F7F7"; ! ! /* Templates */ ! $this->templ = new Template($this->psl[templatedir]); ! $this->templ->debug = 0; ! $this->templ->set_file(array( ! listglossary => "glossaryList.tpl", ! searchglossary => "glossarySearch.tpl", ! newglossary => "glossaryNew.tpl" ! )); ! ! } ! ! /* ! * METHODS ! */ ! ! /* ! * Just prints the form with the list of existing glossarys ! * Used only by admin ! */ ! function listGlossary() { ! ! $q = "SELECT * ! FROM psl_glossary ! ORDER BY term"; ! $this->db->query($q); ! ! titlebar("100%","Glossary Edit"); ! ! $this->templ->set_block("listglossary","row","rows"); ! ! while ($this->db->next_record()) { ! $this->templ->set_var(array( ! ACTION_URL => $this->psl[phpself], ! ID => $this->db->f("id"), ! TERM => $this->db->f("term"), ! DEF => $this->db->f("def") ! )); ! $this->templ->parse("rows","row",true); ! }; ! $this->templ->parse(OUT,array("listglossary")); ! $this->templ->p(OUT); ! } ! ! /* ! * Saves the glossary in the $ary array to the DB ! * Obligatory fields: ! * Optional fields: ! * ! * Returns true if sucessful (glossary added or updated), false on error ! * Used only by admin ! */ ! function saveGlossary($ary) { ! ! /* we need to check for the stuff to add in the DB before we actually ! * add anything. And yes, I know it looks like I just passed my ! * "Intro to C++ Programming" class. --ajay ! */ ! ! /* We don't test for id because no id means, that this is a new term. */ ! if ($ary[term] == "") { ! error("There is no term in Glossary.class::saveGlossary"); ! return false; ! } ! if ($ary[def] == "") { ! error("There is no def in Glossary.class::saveGlossary"); ! return false; ! } ! ! $ary = clean($ary); ! ! /* if a record exists, then we update, else we insert a new glossary! */ ! ! $q = "SELECT id ! FROM psl_glossary ! WHERE id = '$ary[id]'"; ! # echo "QUERY: $q<BR>\n"; ! $this->db->query($q); ! if ($this->db->next_record()) { ! ! echo "updating RECORD: " . $ary[id] . "<BR><BR>"; ! ! $q = "UPDATE psl_glossary ! SET term = '$ary[term]', ! def = '$ary[def]' ! WHERE id = '$ary[id]'"; ! } else { ! ! $ary[id] = generateID("psl_glossary_seq"); ! ! $q = "INSERT INTO psl_glossary ! (id, ! term, ! def) ! VALUES ('$ary[id]', ! '$ary[term]', ! '$ary[def]')"; ! } ! ! # echo "<BR><B>QUERY: $q</B><BR>\n"; ! $this->db->query($q); ! return true; ! } ! ! /* Given the glossary_id, it deletes that term from the glossary table. */ ! function deleteGlossary($glossary_id) { ! ! if (!$glossary_id) { ! return false; ! } else { ! $q = "DELETE ! FROM psl_glossary ! WHERE id = '$glossary_id'"; ! $this->db->query($q); ! return true; ! } ! } ! ! /* ! * Just prints out the "form" and points the user to the "save" method ! * Used only by admin ! */ ! function newGlossary() { ! ! titlebar("100%",pslgetText("Add a new Term")); ! ! $this->templ->set_var(array( ! ACTION_URL => $this->psl[phpself] ! )); ! ! $this->templ->parse(OUT,array("newglossary")); ! $this->templ->p(OUT); ! ! } ! ! function searchGlossary($search) { ! ! titlebar("100%",pslgetText("Glossary")); ! ! $this->templ->set_var(array( ! ACTION_URL => $this->psl[phpself] ! )); ! ! clean($search); ! ! if ($search == "") { ! $q = "SELECT * ! FROM psl_glossary"; ! } else { ! $q = "SELECT * ! FROM psl_glossary ! WHERE term LIKE '%$search%' ! OR def LIKE '%$search%'"; ! } ! $q .= " ORDER by term"; ! ! $this->db->query($q); ! ! $this->templ->set_block("searchglossary" , "row" , "rows"); ! $i = 0; ! while ($this->db->next_record()) { ! if ($i%2 == 0) { ! $cellcolor = $this->cell_color_1; ! } else { ! $cellcolor = $this->cell_color_2; ! } ! $i++; ! ! $this->templ->set_var(array( ! TERM => $this->db->f("term"), ! DEF => $this->db->f("def"), ! CELL_COLOR => $cellcolor ! )); ! ! $this->templ->parse("rows","row",true); ! } ! $this->templ->parse(OUT,array("searchglossary")); ! $this->templ->p(OUT); ! ! } ! ! }; /* end of Glossary.class */ --- 1,208 ---- ! <?php ! ! /* $Id$ */ ! ! /* ! * Class: Glossary ! * ! * Layer: All ! * Desc.: ! * ! */ ! class Glossary { ! var $templ,$db, $psl; ! ! /* ! * CONSTRUCTORS ! */ ! function Glossary () { ! ! global $_PSL; ! ! $this->db = new slashDB; ! $this->psl = $_PSL; ! ! /* Templates */ ! $this->templ = new Template($this->psl[templatedir]); ! $this->templ->debug = 0; ! $this->templ->set_file(array( ! listglossary => "glossaryList.tpl", ! searchglossary => "glossarySearch.tpl", ! newglossary => "glossaryNew.tpl" ! )); ! ! } ! ! /* ! * METHODS ! */ ! ! /* ! * Just prints the form with the list of existing glossarys ! * Used only by admin ! */ ! function listGlossary() { ! ! $q = "SELECT * ! FROM psl_glossary ! ORDER BY term"; ! $this->db->query($q); ! ! titlebar("100%","Glossary Edit"); ! ! $this->templ->set_block("listglossary","row","rows"); ! ! while ($this->db->next_record()) { ! $this->templ->set_var(array( ! ACTION_URL => $this->psl[phpself], ! ID => $this->db->f("id"), ! TERM => $this->db->f("term"), ! DEF => $this->db->f("def") ! )); ! $this->templ->parse("rows","row",true); ! }; ! $this->templ->parse(OUT,array("listglossary")); ! $this->templ->p(OUT); ! } ! ! /* ! * Saves the glossary in the $ary array to the DB ! * Obligatory fields: ! * Optional fields: ! * ! * Returns true if sucessful (glossary added or updated), false on error ! * Used only by admin ! */ ! function saveGlossary($ary) { ! ! /* we need to check for the stuff to add in the DB before we actually ! * add anything. And yes, I know it looks like I just passed my ! * "Intro to C++ Programming" class. --ajay ! */ ! ! /* We don't test for id because no id means, that this is a new term. */ ! if ($ary[term] == "") { ! error("There is no term in Glossary.class::saveGlossary"); ! return false; ! } ! if ($ary[def] == "") { ! error("There is no def in Glossary.class::saveGlossary"); ! return false; ! } ! ! $ary = clean($ary); ! ! /* if a record exists, then we update, else we insert a new glossary! */ ! ! $q = "SELECT id ! FROM psl_glossary ! WHERE id = '$ary[id]'"; ! # echo "QUERY: $q<BR>\n"; ! $this->db->query($q); ! if ($this->db->next_record()) { ! ! echo "updating RECORD: " . $ary[id] . "<BR><BR>"; ! ! $q = "UPDATE psl_glossary ! SET term = '$ary[term]', ! def = '$ary[def]' ! WHERE id = '$ary[id]'"; ! } else { ! ! $ary[id] = generateID("psl_glossary_seq"); ! ! $q = "INSERT INTO psl_glossary ! (id, ! term, ! def) ! VALUES ('$ary[id]', ! '$ary[term]', ! '$ary[def]')"; ! } ! ! # echo "<BR><B>QUERY: $q</B><BR>\n"; ! $this->db->query($q); ! return true; ! } ! ! /* Given the glossary_id, it deletes that term from the glossary table. */ ! function deleteGlossary($glossary_id) { ! ! if (!$glossary_id) { ! return false; ! } else { ! $q = "DELETE ! FROM psl_glossary ! WHERE id = '$glossary_id'"; ! $this->db->query($q); ! return true; ! } ! } ! ! /* ! * Just prints out the "form" and points the user to the "save" method ! * Used only by admin ! */ ! function newGlossary() { ! ! titlebar("100%",pslgetText("Add a new Term")); ! ! $this->templ->set_var(array( ! ACTION_URL => $this->psl[phpself] ! )); ! ! $this->templ->parse(OUT,array("newglossary")); ! $this->templ->p(OUT); ! ! } ! ! function searchGlossary($search) { ! ! titlebar("100%",pslgetText("Glossary")); ! ! $this->templ->set_var(array( ! ACTION_URL => $this->psl[phpself] ! )); ! ! clean($search); ! ! if ($search == "") { ! $q = "SELECT * ! FROM psl_glossary"; ! } else { ! $q = "SELECT * ! FROM psl_glossary ! WHERE term LIKE '%$search%' ! OR def LIKE '%$search%'"; ! } ! $q .= " ORDER by term"; ! ! $this->db->query($q); ! ! $this->templ->set_block("searchglossary" , "first_row" , "f_rows"); ! $this->templ->set_block("searchglossary" , "second_row" , "s_rows"); ! $i = 0; ! while ($this->db->next_record()) { ! if ($i%2 == 0) { ! $this->templ->set_var(array( ! FIRST_TERM => $this->db->f("term"), ! FIRST_DEF => $this->db->f("def") ! )); ! $this->templ->parse("f_rows","first_row",true); ! } ! else { ! $this->templ->set_var(array( ! SECOND_TERM => $this->db->f("term"), ! SECOND_DEF => $this->db->f("def") ! )); ! $this->templ->parse("f_rows","second_row",true); ! } ! ++$i; ! } ! $this->templ->parse(OUT,array("searchglossary")); ! $this->templ->p(OUT); ! ! } ! ! } /* end of Glossary.class */ ! ?> \ No newline at end of file |