Update of /cvsroot/phpslash/phpslash-ft/class
In directory usw-pr-cvs1:/tmp/cvs-serv24474/phpslash-ft/class
Modified Files:
Block.class Block_i.class
Log Message:
add/remove block_types
Index: Block.class
===================================================================
RCS file: /cvsroot/phpslash/phpslash-ft/class/Block.class,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Block.class 2002/01/08 21:38:23 1.8
--- Block.class 2002/02/01 21:38:55 1.9
***************
*** 82,86 ****
$id = generateID("psl_blocktype_seq");
$type = addslashes($type);
! $this->db->query("INSERT INTO psl_block_type SET id='$id' type='$type'");
if ($this->db->affected_rows != 1) {
echo "Block Type: $type added with an id of: $id";
--- 82,86 ----
$id = generateID("psl_blocktype_seq");
$type = addslashes($type);
! $this->db->query("INSERT INTO psl_block_type (id, name) VALUES ('$id','$type')");
if ($this->db->affected_rows != 1) {
echo "Block Type: $type added with an id of: $id";
***************
*** 89,93 ****
}
}
!
/**
* getBlock - returns a block from an id
--- 89,142 ----
}
}
!
!
! /* deleteType - deletes the type from the db
! *
! * Given the type_name, it deletes that from the psl_block_type table.
! * IT check and make sure there are NO blocks associated with this
! * block_type before deleting it. Returns true if block_type is deleted,
! * false if not.
! *
! * @param integer type_name
! *
! * @access public
! */
! function deleteType($type_name) {
!
! $go_ahead = true;
!
! if (!$type_name) {
! return false;
! }
!
! /* check for any blocks associated with this type_name */
!
! $q = "SELECT psl_block.title
! FROM psl_block,
! psl_block_type
! WHERE psl_block.type = psl_block_type.id
! AND psl_block_type.name = '$type_name'";
! $this->db->query($q);
! while ($this->db->next_record()) {
! $go_ahead = false;
! $title = $this->db->Record["title"];
! echo "Sorry, this block_type($type_name) is assigned to this block:";
! echo "<font color=\"red\">'$title'</font><br />\n";
! }
!
! if (!$go_ahead) {
! return false;
! } else {
! $q = "DELETE
! FROM psl_block_type
! WHERE name = '$type_name'";
! $this->db->query($q);
! echo "<i>Block Type $type_name deleted</i>";
!
! return true;
! }
! }
!
!
/**
* getBlock - returns a block from an id
Index: Block_i.class
===================================================================
RCS file: /cvsroot/phpslash/phpslash-ft/class/Block_i.class,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Block_i.class 2002/01/22 12:25:07 1.12
--- Block_i.class 2002/02/01 21:38:56 1.13
***************
*** 389,392 ****
--- 389,472 ----
}
}
+
+ /**
+ * listBlockTypes - display a list of all available block types
+ *
+ * displays the complete list of available block types
+ * Used only by admin
+ *
+ * @param string option
+ * @access public
+ */
+ function listBlockTypes($option="", $name="") {
+
+ $this->templ = new Template($this->psl[templatedir]);
+ $this->templ->debug = 0;
+ $this->templ->set_file(array(
+ listblocktypes => "blocktypeList.tpl"
+ ));
+
+ titlebar("100%","Manage Block Types");
+
+ if( $option == "all") {
+
+ $fulldirlist = dir($this->psl[classdir]);
+ $i=1;
+ while( $eachfile = $fulldirlist->read()) {
+ $each = $this->psl[classdir] . "/" . $eachfile;
+ if( (is_file($each)) AND
+ ( $each != ".") AND
+ ( $each != "..") AND
+ ( $each != "CVS") AND
+ ( preg_match('/Block_render_/i', $each)) ) {
+
+ $eachtype = str_replace("Block_render_", "", $eachfile);
+ $eachtype = str_replace(".class", "", $eachtype);
+ $avail_ary[$eachtype] = $i;
+ $i++;
+ }
+ }
+
+ $current_types = $this->getTypes();
+
+ $this->templ->set_block("listblocktypes", "removerow", "removerows");
+
+ while( list($key, $val) = each($current_types) ) {
+ $current_type = $val;
+ $this->templ->set_var(array(
+ REMOVENAME => $current_type,
+ REMOVEURL => $this->psl[phpself] ."?option=delete". $this->psl[amp] ."name=". $current_type
+
+ ));
+ $this->templ->parse("removerows","removerow",true);
+ if( isset($avail_ary[$current_type])) {
+ unset($avail_ary[$current_type]);
+
+ }
+
+ }
+ $this->templ->set_block("listblocktypes","addrow","rows");
+ while( list($key, $val) = each($avail_ary) ) {
+
+ $this->templ->set_var(array(
+ ADDNAME => $key,
+ ADDURL => $this->psl[phpself] ."?option=add". $this->psl[amp] ."name=". $key
+ ));
+ $this->templ->parse("rows","addrow",true);
+
+ }
+
+ $this->templ->parse(OUT,array("listblocktypes"));
+ $this->templ->p(OUT);
+ } elseif ($option == "add") {
+ $this->putType($name);
+ $this->listBlockTypes("all");
+ } elseif ($option == "delete") {
+ $this->deleteType($name);
+ $this->listBlockTypes("all");
+ } else {
+ echo "<A HREF=" . $this->psl[phpself] . "?submit=display" . $this->psl[amp] . "option=all>[Add or Remove Block Types]</A>";
+ }
+ }
|