From: <on...@us...> - 2002-09-19 16:42:48
|
Update of /cvsroot/xoops/xoops-current/html/class In directory usw-pr-cvs1:/tmp/cvs-serv605 Modified Files: xoopsblock.php Log Message: no message Index: xoopsblock.php =================================================================== RCS file: /cvsroot/xoops/xoops-current/html/class/xoopsblock.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** xoopsblock.php 6 Sep 2002 02:28:42 -0000 1.4 --- xoopsblock.php 19 Sep 2002 16:42:45 -0000 1.5 *************** *** 49,52 **** --- 49,55 ---- $this->initVar("show_func", "textbox", NULL, false, 50); $this->initVar("edit_func", "textbox", NULL, false, 50); + $this->initVar('balias', "textbox", NULL, false, 50); + $this->initVar('bcachetime', "int", 0, false, 10); + $this->initVar('btemplate', "other", NULL, false); if ( !empty($id) ) { *************** *** 60,64 **** function load($id) { ! $sql = "SELECT * FROM ".$this->db->prefix("newblocks")." WHERE bid = ".$id.""; $arr = $this->db->fetchArray($this->db->query($sql)); $this->set($arr); --- 63,67 ---- function load($id) { ! $sql = 'SELECT * FROM '.$this->db->prefix('newblocks').' WHERE bid = '.$id; $arr = $this->db->fetchArray($this->db->query($sql)); $this->set($arr); *************** *** 72,80 **** } foreach ( $this->cleanVars as $k=>$v ) { ! $$k = $v; } if ( empty($bid) ) { $bid = $this->db->genId($this->db->prefix("blocks")."_bid_seq"); ! $sql = "INSERT INTO ".$this->db->prefix("newblocks")." (bid, mid, func_num, options, name, position, title, content, side, weight, visible, type, c_type, isactive, dirname, func_file, show_func, edit_func) VALUES ('$bid', '$mid', '$func_num', '$options', '".$name."', '$position', '".$title."', '".$content."', '".$side."', '".$weight."', '".$visible."', '$type', '".$c_type."', 1, '.$dirname.', '".$func_file."', '".$show_func."', '".$edit_func."')"; } else { $sql = "UPDATE ".$this->db->prefix("newblocks")." SET options='".$options."'"; --- 75,83 ---- } foreach ( $this->cleanVars as $k=>$v ) { ! ${$k} = $v; } if ( empty($bid) ) { $bid = $this->db->genId($this->db->prefix("blocks")."_bid_seq"); ! $sql = "INSERT INTO ".$this->db->prefix("newblocks")." (bid, mid, func_num, options, name, position, title, content, side, weight, visible, type, c_type, isactive, dirname, func_file, show_func, edit_func, balias, bcachetime, btemplate) VALUES ('$bid', '$mid', '$func_num', '$options', '".$name."', '$position', '".$title."', '".$content."', '".$side."', '".$weight."', '".$visible."', '$type', '".$c_type."', 1, '.$dirname.', '".$func_file."', '".$show_func."', '".$edit_func."', '".$balias."', $bcachetime, '".$btemplate."')"; } else { $sql = "UPDATE ".$this->db->prefix("newblocks")." SET options='".$options."'"; *************** *** 83,89 **** $sql .= ", name='".$name."'"; } ! $sql .= ", position='".$position."', title='".$title."', content='".$content."', side='".$side."', weight='".$weight."', visible='".$visible."', c_type='".$c_type."' WHERE bid='".$bid."'"; } ! //echo $sql; if ( !$this->db->query($sql) ) { $this->setErrors("Could not save block data into database"); --- 86,92 ---- $sql .= ", name='".$name."'"; } ! $sql .= ", position='".$position."', title='".$title."', content='".$content."', side='".$side."', weight='".$weight."', visible='".$visible."', c_type='".$c_type."', balias='".$balias."', bcachetime=".$bcachetime.", btemplate='".$btemplate."' WHERE bid='".$bid."'"; } ! echo $sql; if ( !$this->db->query($sql) ) { $this->setErrors("Could not save block data into database"); *************** *** 97,105 **** function delete() { ! $sql = "DELETE FROM ".$this->db->prefix("newblocks")." WHERE bid=".$this->getVar("bid").""; if ( !$this->db->query($sql) ) { return false; } ! $sql = "DELETE FROM ".$this->db->prefix("groups_blocks_link")." WHERE block_id=".$this->getVar("bid").""; $this->db->query($sql); return true; --- 100,108 ---- function delete() { ! $sql = 'DELETE FROM '.$this->db->prefix('newblocks').' WHERE bid='.$this->getVar('bid'); if ( !$this->db->query($sql) ) { return false; } ! $sql = 'DELETE FROM '.$this->db->prefix('groups_blocks_link').' WHERE block_id='.$this->getVar('bid'); $this->db->query($sql); return true; *************** *** 113,120 **** * @returns string */ ! function getContent($format = "S", $c_type = "T") { $myts =& MyTextSanitizer::getInstance(); switch ( $format ) { ! case "S": // check the type of content // H : custom HTML block --- 116,123 ---- * @returns string */ ! function getContent($format = 'S', $c_type = 'T') { $myts =& MyTextSanitizer::getInstance(); switch ( $format ) { ! case 'S': // check the type of content // H : custom HTML block *************** *** 122,147 **** // S : use text sanitizater (smilies enabled) // T : use text sanitizater (smilies disabled) ! if ( $c_type == "H" ) { ! $content = $myts->oopsStripSlashesRT($this->getVar("content", "N")); ! $content = str_replace("{X_SITEURL}", XOOPS_URL."/", $content); return $content; ! } elseif ( $c_type == "P" ) { ob_start(); ! print eval($this->getVar("content", "N")); $content = ob_get_contents(); ob_end_clean(); ! $content = str_replace("{X_SITEURL}", XOOPS_URL."/", $content); return $content; ! } elseif ( $c_type == "S" ) { ! $content = $myts->makeTareaData4Show($this->getVar("content", "N"), 1, 1); ! $content = str_replace("{X_SITEURL}", XOOPS_URL."/", $content); return $content; } else { ! $content = $myts->makeTareaData4Show($this->getVar("content", "N")); ! $content = str_replace("{X_SITEURL}", XOOPS_URL."/", $content); return $content; } ! case "E": ! $content = $this->getVar("content", "E"); } return $content; --- 125,150 ---- // S : use text sanitizater (smilies enabled) // T : use text sanitizater (smilies disabled) ! if ( $c_type == 'H' ) { ! $content = $myts->oopsStripSlashesRT($this->getVar('content', 'N')); ! $content = str_replace('{X_SITEURL}', XOOPS_URL.'/', $content); return $content; ! } elseif ( $c_type == 'P' ) { ob_start(); ! print eval($this->getVar('content', 'N')); $content = ob_get_contents(); ob_end_clean(); ! $content = str_replace('{X_SITEURL}', XOOPS_URL.'/', $content); return $content; ! } elseif ( $c_type == 'S' ) { ! $content = $myts->makeTareaData4Show($this->getVar('content', 'N'), 1, 1); ! $content = str_replace('{X_SITEURL}', XOOPS_URL.'/', $content); return $content; } else { ! $content = $myts->makeTareaData4Show($this->getVar('content', 'N')); ! $content = str_replace('{X_SITEURL}', XOOPS_URL.'/', $content); return $content; } ! case 'E': ! $content = $this->getVar('content', 'E'); } return $content; *************** *** 299,305 **** if ( isset($side) ) { // get both sides in sidebox? (some themes need this) ! if ( $side == 2 ) { $side = "(b.side=0 OR b.side=1)"; ! } elseif ( $side == 6 ) { $side = "(b.side=3 OR b.side=4 OR b.side=5)"; } else { --- 302,308 ---- if ( isset($side) ) { // get both sides in sidebox? (some themes need this) ! if ( $side == XOOPS_SIDEBLOCK_BOTH ) { $side = "(b.side=0 OR b.side=1)"; ! } elseif ( $side == XOOPS_CENTERBLOCK_ALL ) { $side = "(b.side=3 OR b.side=4 OR b.side=5)"; } else { *************** *** 390,393 **** --- 393,442 ---- } else { $ret[] = $myrow['bid']; + } + } + return $ret; + } + + function &getAllByGroupModule($groupid, $module_id=0, $toponlyblock=false, $visible=null, $orderby='b.weight,b.bid', $isactive=1){ + $db =& Database::getInstance(); + $ret = array(); + $sql = 'SELECT b.* FROM '.$db->prefix('block_module_link').' m LEFT JOIN '.$db->prefix('newblocks').' b ON b.bid=m.block_id LEFT JOIN '.$db->prefix('groups_blocks_link').' l ON l.block_id=b.bid'; + if ( is_array($groupid) ) { + $sql .= ' WHERE (l.groupid='.intval($groupid[0]); + $size = sizeof($groupid); + if ( $size > 1 ) { + for ($i = 1; $i < $size; $i++) { + $sql .= ' OR l.groupid='.intval($groupid[$i]); + } + } + $sql .= ')'; + } else { + $sql .= ' WHERE l.groupid='.intval($groupid); + } + $sql .= ' AND b.isactive='.$isactive; + $module_id = intval($module_id); + if (!empty($module_id)) { + $sql .= ' AND (m.module_id=0 OR m.module_id='.$module_id; + if ($toponlyblock) { + $sql .= ' OR m.module_id=-1'; + } + $sql .= ')'; + } else { + if ($toponlyblock) { + $sql .= ' AND (m.module_id=0 OR m.module_id=-1)'; + } else { + $sql .= ' AND m.module_id=0'; + } + } + if (isset($visible)) { + $sql .= ' AND b.visible='.intval($visible); + } + $sql .= ' ORDER BY '.$orderby; + $result = $db->query($sql); + $added = array(); + while ( $myrow = $db->fetchArray($result) ) { + if ( !in_array($myrow['bid'], $added) ) { + $ret[] = new XoopsBlock($myrow); + array_push($added, $myrow['bid']); } } |