? //---------------------------------------------------------------------------------------------------------------------------------------------- // Class Library for PD //---------------------------------------------------------------------------------------------------------------------------------------------- // Menu class // creates text or gif menus. // Has a userdefineable onClass, OffClass, contatainer html, cell html and divider html // if container html has <%title%> the title of the group is included // Which will hopefully cover all possibilities. Unlike prev versions this isn't editable out front. // The widths and heights are set by the css. If there's on/offgif is a colour then the entire bgcolour of a cell is set with these as mouseovers. // The templateBuilder class has sub classes of TD, A, title etc. //---------------------------------------------------------------------------------------------------------------------------------------------- class menu{ var $menuValID; // The id of the chosen menu item var $category; // category/title of menu var $uid; // the id level of the punter var $template; var $pageID=array(); // page ID //------------------------------------------------------------------------------------------------------------------------------------------ function menu($menuValID, $category,$uid,$template){ $yyy=array_keys($xxx = get_defined_vars()); // generic populate for ($i=((phpversion()>=5)?0:1);$i{$yyy[$i]}=$xxx[$yyy[$i]];} } // draw menu function ends. // output the menu // designed to be as flexible as poss for all but dhtml dropdown type menus. // It can handle vertical, horizontal, gif and mouseover div menus // // //------------------------------------------------------------------------------------------------------------------------------------------------------------------- function outputMenu(){ $db=new db(); $str_sql="select * from DB_010_MENU where DB_002_MENUGROUP_ID='".$this->category."'"; $str_sql.=" order by DB_010_ORDER"; $vals=$db->get2dArray($str_sql); $this->menuValID=$this->menuValID!=''?$this->menuValID:$vals[3][0]; //set the value passed in to the first in the list by default // Table Layout : id, name, menugroup, pageid, order, externalurl, popup, accesslevel. $n=0; for ($i=0;$iuid) or ($accessLevel==1 and $this->uid) or ($accessLevel==2 and isAllowed($this->uid, 'page', $vals[3][$i]))) { $okToShow='y'; if ($vals[3][$i] and $db->getFieldVal('DB_001_PAGE',$vals[3][$i],2,0)==2) { $okToShow=isAllowed($this->uid, 'page', $vals[3][$i]); } if ($okToShow) { if ($vals[5][$i] and !$vals[3][$i]) { $url=stripslashes($vals[5][$i]); }elseif($vals[5][$i] and $vals[3][$i]){ $url="index.php?pageID=".$vals[3][$i].$vals[5][$i]; }else{ $url="index.php?pageID=".$vals[3][$i]; } $presetClass=$vals[7][$i]?$vals[7][$i]:""; if ($this->menuValID==$vals[3][$i] or $db->getFieldVal('DB_001_PAGE',$this->menuValID,6,0)==$vals[0][$i]) { $class=$presetClass?$presetClass.'Active':'active'; }else{ $class=$presetClass?$presetClass:'plain'; } $target=$vals[6][$i]?" target=\"_blank\"":""; if ($vals[7][$i] and $vals[8][$i] ) { // each menu element has a seperate class, so you can have image gifs. $class=$class==$onClass?$vals[7][$i]:$vals[8][$i]; $display="\"".stripslashes($vals[1][$i])."\""; // the css needs to have an img subtag. }else{ $display=stripslashes($vals[1][$i]); } $loopVals[0][$n]=$class; $loopVals[1][$n]="".$display.""; $showFlag='y'; $n++; } } } if ($showFlag) { $loopTags=array('<%class%>','<%link%>'); $m=new templateBuilder($this->template); $menu=$m->cellContainerLoop('<%container%>','<%cell%>','<%divider%>',$loopTags, $loopVals); $menu="\n\n".str_replace("<%title%>",$db->getFieldVal('DB_002_MENUGROUP',$this->category,1,0), $menu)."\n\n"; }else{ $menu=""; } return $menu; } // output menu ends } // draw menu class ends //------------------------------------------------------------------------------------------------------------------------------------------------------------------- // The database class - a load of database type things that are used a lot. // genericTableUpdate($type, $valArray,$tableName,$id,$fields) // getArray($table,$idNum) - returns a row // getFieldVal($tableName,$id,$fieldNum,$keyNum) - returns a field // getDateVal($tableName,$id,$fieldNum,$keyNum) - returns a formatted date // getMysqlArray($str_sql,$idNum) - returns a column // get2dArray($str_sql) - returns a 2darray // get1dArray($str_sql) - returns a 1darray // qry($str_sql) //------------------------------------------------------------------------------------------------------------------------------------------------------------------- class db{ // var $conn; // var $config; var $thetable; var $n; var $IDField; var $idstring; var $tableIDField; var $type; var $valArray; var $tableName; var $id; var $fields; var $fieldNum; var $keyNum; var $msg; var $table; var $idNum; var $str_sql; var $result; // variables for connection held in an external file //------------------------------------------------------------------------------------------------------------------------------------------------------------------- function getFields($thetable,$n){ if (eregi('select ', $thetable)) { $str_sql=$thetable; }else{ $str_sql="SELECT * FROM ".$thetable. " limit 1"; } $result = mysql_query($str_sql) or die($this->outputError($str_sql."

".mysql_error())); for($i=0;$i-1) { $fields=mysql_field_name($result, $n); } mysql_free_result($result); return $fields; } // getfields ends // next ID for Appending //------------------------------------------------------------------------------------------------------------------------------------------------------------------- function getnextid($thetable,$IDField){ if ($thetable){ $str="SELECT Max(".$IDField.") FROM ".$thetable; $rs=mysql_query($str) or die($this->outputError($str_sql."

".mysql_error())); $row = mysql_fetch_array($rs); mysql_free_result($rs); return $row[0]+1; } } // getnextid ends // if there is a search string then get the ids. //------------------------------------------------------------------------------------------------------------------------------------------------------------------- function makeSearchSql($idstring, $tableIDField){ if ($idstring) { $ids=explode(":",$idstring); if (count($ids)) { $idStr.=" and ("; for ($i=0;$i7?" or ":"").$tableIDField."=".$ids[$i]; } $idStr.=") "; } } return $idStr; } // function makeSearchSql($idstring, $tableIDField) // This will update add or delete any table regardless of format. // when updating %skip% in val array means the field stays the same. // returns a new ID //------------------------------------------------------------------------------------------------------------------------------------------------------------------- function genericTableUpdate($type, $valArray,$tableName,$id,$fields){ if (!$fields) { $fields=$this->getfields($tableName,-1);} // if the fields aren't passed in it finds them list($type,$slashes)=explode(":",$type); switch($type){ case 'delete': if ($id) { $str_sql="delete from ".$tableName." where ".$fields[0]."=".$id; $result=mysql_query($str_sql); $id=$this->getnextid($tableName,$fields[0])-1; } break; case 'update': if ($id) { $str_sql="UPDATE ".$tableName." SET "; $str_sql.=$tableName.".".$fields[0]."='".$valArray[0]."'"; for($i=1; $i