\n"; $html .= "\n"; $html .= " function select(link) {\n"; $html .= " var title = link.title;\n"; $html .= " var url = link.href;\n"; $html .= "\n"; $html .= $this->insertLinkJavascript() . "\n"; $html .= " }\n"; $html .= "\n"; return $html; } function getHtml() { $o = parent::getJavascript(); $o .= $this->aboveTreeHtml(); $o .= $this->makeProMenu($icons = false); return $o; } /** * Override this function */ function insertLinkJavascript() { return ' alert("Selected URL: " + url + "\nSelected title: " + title);' . "\n"; } function aboveTreeHtml() { global $WABBIT, $SESSION; $pro = $this->getContainerId(); $domain = $WABBIT->getDomain(); $id = $_GET["id"]; $html = "\n"; $html .= "

Interne link

"; $html .= "Klik de pagina aan waarnaar u een link wilt maken."; return $html; } function getImagesPath() { return parent::getImagesPath(); } function getLinkTarget($id) { return parent::getLinkTarget($id); } function getHeader() { return ""; } function getIcons() { return ""; } } ?>thisPage = "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']."?ac=shift"; if (isset($_GET["sub"])) { // 'sub' parameter is set; determine enclosed pagenumber $sub = $_GET["sub"]; $prefix = "page"; $this->pageNumber = (int) substr($sub, strlen($prefix)); } if (isset($_GET["expertmode"]) && (((int)$_GET["expertmode"])==1)) { $this->expertMode = true; } else { $this->expertMode = false; } // populate 'modules' and 'nodes' cache $this->loadCache(); parent::ProMenu(); } function getTree() { $o = parent::getJavascript(); $o .= $this->aboveTreeHtml(); $o .= $this->makeProMenu($icons = false); return $o; } function getHtml() { switch ($this->pageNumber) { case 1: // parent::setDefaultState("collapsed"); return $this->getTree(); case 2: $page2 = new MoveArticle_Page2($this->expertMode); return $page2->getHtml(); case 3: $page3 = new MoveArticle_Page3($this->expertMode); return $page3->getHtml(); default: return parent::getHtml(); } } /** * Populates the internal cache containing information on the module each article is in or part of */ function loadCache() { global $CONNECT, $WABBIT; $structure = $WABBIT->getTbl('structure'); if (array_key_exists("node_id", $_GET)) { // dit is de ajax-call $node_id = $_GET["node_id"]; $_ORIG = $this->getCallersParameters(); $source_id = intval($_ORIG["id"]); // alleen die artikelen laden die onder 'deze' node hangen $sql = "SELECT id, module, is_node FROM $structure WHERE parent_id=$node_id OR id=$source_id ORDER BY id ASC"; } else { // dit is geen ajax-call -> laad de info voor de hele boom (???!) $sql = "SELECT id, module, is_node FROM $structure ORDER BY id ASC"; } $result = $CONNECT->readQuery($sql); // convert the obtained datastructure to something that can be accessed at once // e.g. by requesting $this->modules[$id] $this->modules = array(); $this->isNode = array(); foreach ($result as $record) { $this->modules[$record["id"]] = $record["module"]; $this->isNode[$record["id"]] = $record["is_node"]; } } /** * Returns the module-number of the provided article */ function getModule($id) { // which module is the provided article id in? return (int)$this->modules[$id]; } function isNode($id) { return (bool)$this->isNode[$id]; } /** * Returns "true" if the article indicated by 'from' can be moved * to the article indicated by 'to'. Returns "false" in all other cases. */ function canMove($from, $to) { // when in expert mode, everything can be moved everywhere if ($this->expertMode == true) { return true; // never happens anyway :) - EA } $moduleCorrect = false; $m_from = $this->getModule($from); $m_to = $this->getModule($to); $compatible_modules = array(1, 4); // allow this move if 'from' and 'to' are of the same module if ( ($this->getModule($from) == $this->getModule($to)) || ( (in_array($this->getModule($from), $compatible_modules)) && (in_array($this->getModule($to ), $compatible_modules)) ) ) { if ($this->isNode($from) && $this->isNode($to)) { // nodes can only be placed under or next to other nodes, // not under articles return true; } if (!$this->isNode($from)) { // articles can be placed under nodes or next to other articles; // in any case, they are clickable. return true; } } return false; } // functions overriding similar functions in class 'Promenu' function makeArticleLink($id, $title) { // extract 'id' field from current URL->this is the source id(the article we 're moving) $_ORIG = $this->getCallersParameters(); $source_id = intval($_ORIG["id"]); if ($this->canMove($source_id, $id)) { // return parent :: makeArticleLink($id, $title); $divid = $this->getContainerId(); if ($source_id == $id){ return "".htmlentities($title, ENT_QUOTES, 'utf-8')."\n"; } else { return "".htmlentities($title, ENT_QUOTES, 'utf-8')."\n"; } } return "
$title
"; } function makeNodeLink($id, $title) { if (isset($_GET["id"])) { $source_id = intval($_GET["id"]); } else { $_ORIG = $this->getCallersParameters(); $source_id = intval($_ORIG["id"]); } if ($this->canMove($source_id, $id)) { return $this->makeNodeLink2($id, $title); } $divid = $this->getContainerId(); $html_id = "id$id"; return "
$title
"; } function aboveTreeHtml() { global $_GET; global $WABBIT, $SESSION; $id = $_GET["id"]; $struct = new DBstructure($id); $title = $struct->getTitle(); $pro = $this->getContainerId(); $domain = $WABBIT->getDomain(); $o = "\n"; $o .= "

Verplaatsen

\n"; if ($this->expertMode==true) { $o .= "(Let op! Expertmode staat aan; onzorgvuldig handelen kan leiden tot een onbruikbare site.)

"; } $o .= "

Waar wilt u \"$title\" naartoe verplaatsen?

\n"; return $o; } function makeNodeLink2($id, $title) { $divid = $this->getContainerId(); $html_id = "id$id"; return "".htmlentities($title, ENT_QUOTES, 'utf-8').""; } } class MoveArticle_Page2 { var $expertMode; var $thisPage; function MoveArticle_Page2($expertMode) { $this->thisPage = "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']."?ac=shift"; $this->expertMode = $expertMode; } function getHtml() { global $_GET; $from = $_GET["from_id"]; $struct = new DBstructure($from); $fromTitle = $struct->getTitle(); $to = $_GET["to_id"]; $struct = new DBStructure($to); $toTitle = $struct->getTitle(); $toHasChildren = sizeof($struct->getChildren())>0; /* $to is op nivo0, hier mag alleen iets onder, niet boven/naast, anders kun je nl steeds een nieuw hoofdmenu aanmaken toegevoegd: PS 19-12-2007 */ if ($struct->getParentID() == 0){ $moveOptions = "onder"; } elseif (($toHasChildren) || ($this->expertMode==true)) { $moveOptions = "voor, onder of na"; } else { $moveOptions = "voor of na"; } $html = "

Verplaatsen

\n"; $html .= "\n"; $html .= "

\n"; $html .= "Wilt u '$fromTitle' $moveOptions '$toTitle' plaatsen?\n"; $html .= "

\n"; $html .= "\n"; $html .= "
\n"; $html .= "\n"; $html .= "\n"; $html .= "\n"; //geklikt op een hoofdmenu? dan alleen optie 'onder' if ($struct->getParentID() == 0){ $html .= "\n"; $html .= ''; } else { $html .= "\n"; $html .= "\n"; $html .= "\n"; $html .= "\n"; if (($toHasChildren==true) || ($this->expertMode==true)) { $html .= ''; } } $html .= "
$toTitle
$toTitle
\n"; $html .= "
\n"; $html .= "  \n"; $html .= "
\n"; $html .= "\n"; return $html; } } class MoveArticle_Page3 { var $expertMode; function MoveArticle_Page3($expertMode) { $this->expertMode = $expertMode; } function getHtml() { global $_POST; global $SESSION; global $WABBIT; $position = $_POST["position"]; $from = $_POST["from_id"]; $to = $_POST["to_id"]; $newParent = null; switch ($position) { case "onder": //$this->updateParent($from, $to); $this->moveUnder($from, $to); break; case "voor": $this->relativeMove($from, $to, "voor"); break; case "na": $this->relativeMove($from, $to, "na"); break; } $o = "\n"; return $o; } function updateParent($node_id, $parent_id) { global $WABBIT; global $CONNECT; $table = $WABBIT->getTbl('structure'); $sql = "UPDATE $table SET parent_id=$parent_id WHERE id=$node_id"; $CONNECT->writeQuery($sql); } function moveUnder($fromid, $toid) { global $WABBIT; global $CONNECT; $table = $WABBIT->getTbl('structure'); //alles +1 opschuiven $sql = "UPDATE $table SET RANK=RANK+1 WHERE parent_id=$toid"; $CONNECT->writeQuery($sql); //artikel of node eronder hangen $sql = "UPDATE $table SET parent_id=$toid where id=$fromid"; $CONNECT->writeQuery($sql); //bovenaan plaatsen $sql = "UPDATE $table SET rank=0 where id=$fromid"; $CONNECT->writeQuery($sql); } /* function copyModuleNumber($moved_from_id, $moved_to_id) { // replace the modulenumber of the article indicated by 'moved_from_id' // with the modulenumber of the article indicated by 'moved_to_id' $moved_to = new DBstructure($moved_to_id); $moved_from = new DBstructure($moved_from_id); $moved_from->setModule($moved_to->getModule()); $moved_from->updateMe(); }*/ function relativeMove($nodeId, $targetSibling, $relativePosition) { $struct = new DBstructure; $nodeObject = new DBstructure($nodeId); $includeSelf = true; $struct = new DBStructure($targetSibling); $siblings = $struct->getSiblings($includeSelf); $parentId = $struct->getParentID(); // determine absolute position of targetSibling $absolutePosition = 0; $found = false; foreach ($siblings as $sibling) { if ($sibling->getID() == $targetSibling) { $found = true; break; } $absolutePosition++; } // re-order if ($found == true) { $rank = 0; for ($counter=0; $countergetID() == $nodeObject->getID()) { continue; } if ($counter==$absolutePosition) { switch ($relativePosition) { case "voor": $nodeObject->setRank($rank++); $nodeObject->updateMe(); $sibling->setRank($rank++); $sibling->updateMe(); break; case "na": $sibling->setRank($rank++); $sibling->updateMe(); $nodeObject->setRank($rank++); $nodeObject->updateMe(); break; } } else { $sibling->setRank($rank++); $sibling->updateMe(); } } } $this->updateParent($nodeId, $parentId); } } ?> 0 ) and ( $x{0} == "x" or ($x{0} == "0" and @$x{1} == "x")); } function utlMakeString( $s, $Seperator = "" ) // Function to convert an string array to a string { if( is_string( $s )) { return $s; } else { if( is_array( $s ) and count( $s ) > 0 ) { $sResult = ""; foreach( $s as $Line ) { if( $Seperator != "" and $sResult != "" ) { $sResult.= $Seperator.$Line; } else { $sResult.= $Line; } } return $sResult; } else return $s; } } function utlRepeatChar( $ch, $count = 80 ) { $sResult = ""; if( is_numeric( $count ) and $count > 0 ) { while( strlen( $sResult ) < $count ) { $sResult.=$ch; } } return $sResult; } function utlRemoveAllBetween( &$s, $startCode, $endCode = null, $sReplaceWith = null, $iReplaceCounter = null ) { // Removes all content between $startCode and $endCode "tag" in $s if( !is_string( $s ) ) { return false; } if( $endCode == null or $endCode == NULL or !is_string( $endCode )) { $endCode = $startCode; } $lC = strlen( $endCode ); $pOpen = @strpos( $s, $startCode ); $pClose = @strpos( $s, $endCode, $pOpen ); $bResult = false; $bUseNumbering = ( $sReplaceWith != null and is_numeric( $iReplaceCounter )); while( $pOpen !== false and $pClose !== false and $pOpen >= 0 and $pClose > $pOpen ) { $bResult = true; $sR = substr( $s, $pOpen, $pClose-$pOpen+$lC ); if( $bUseNumbering ) { @$iReplaceCounter++; $s = str_replace( $sR, str_replace( "%i", $iReplaceCounter, $sReplaceWith ), $s ); } else { $s = str_replace( $sR, $sReplaceWith, $s ); } $pOpen = @strpos( $s, $startCode ); $pClose = @strpos( $s, $endCode, $pOpen ); } return $bResult; } function utlGetTextBetween( &$s, $startCode, $endCode = null , $bReturnAsString = true ) { // Gets all content between $startCode and $endCode "tag" in $s if( !is_string( $s ) ) { $s = utlMakeString( $s ); } if( $endCode == null or $endCode == NULL or !is_string( $endCode )) { $endCode = $startCode; } $lo = strlen( $startCode ); $lC = strlen( $endCode ); $pOpen = @strpos( $s, $startCode ); $pClose = @strpos( $s, $endCode, $pOpen+$lo ); $aResult = Array(); while( $pOpen !== false and $pClose !== false and $pOpen >= 0 and $pClose > $pOpen ) { $sR = substr( $s, $pOpen+$lo, $pClose-$pOpen-$lo ); $aResult[] = $sR; $pOpen = @strpos( $s, $startCode, $pClose+$lC ); $pClose = @strpos( $s, $endCode, $pOpen+$lo ); } if( count( $aResult ) == 0 ) { if( $bReturnAsString ) { return null; } return $aResult; } if( $bReturnAsString ) { return utlMakeString( $aResult ); } return $aResult; } function utlReplaceTextBetween( &$s, $startCode, $endCode = null, $sReplaceWith = null ) { return utlRemoveAllBetween( &$s, $startCode, $endCode, $sReplaceWith ); } function utlExtractTextBetween( &$s, $startCode, $endCode = null, $sReplaceWith = null, $iReplaceCounter = null, $bReturnAsString = true ) { // Gets all content between $startCode and $endCode "tag" in $s and removes the code between these tags $sResult = utlGetTextBetween( $s, $startCode, $endCode, $bReturnAsString ); if( $bReturnAsString and $sResult == null ) { return null; } if( !$bReturnAsString and count( $sResult ) == 0 ) { return $sResult; } utlRemoveAllBetween( $s, $startCode, $endCode, $sReplaceWith, $iReplaceCounter ); return $sResult; } function utlCsvExplode( $aCSVArray ) // An CSVarray is nothing more than a string with comma seperated values { // but can also be indexed like an ordinary array, for example: // $MyCsvArr = "0=>number1,1=>number2,example=>This is a test"; // or: $MyCsvArr = "number1,number2,This is a test"; if( is_array( $aCSVArray )) { return $aCSVArray; } $bIsIndexed = ( strpos( $aCSVArray, "=>" ) !== false ); $aCSVArray = explode( ",", $aCSVArray ); $bIsArr = is_array( $aCSVArray ); if( $bIsArr and $bIsIndexed ) { $aResult = array(); foreach( $aCSVArray as $index=>$value ) { $vals = explode( "=>", $value ); if( is_array( $vals ) and @count( $vals ) > 1 ) { $aResult[ trim( $vals[ 0 ] ) ] = $vals[ 1 ]; } else { $aResult[ $index ] = $value; } } return $aResult; } if( !$bIsArr ) { return array(); } return $aCSVArray; } function utlGetCSValue( $s, $index, $retDefault = null ) { // Gets a value available in a CSVarray, An CSVarray is nothing more than a string with comma seperated values // This can be used in conditional defines. $as = utlCsvExplode( $s ); if( !array_key_exists( $index, $as )) { return $retDefault; } return @$as[ $index ]; } function utlInCsvArray( $value, $aCSVArray, $bStrict = false ) // An CSVarray is nothing more than a string with comma seperated values { if( !is_array( $aCSVArray )) { $aCSVArray = utlCsvExplode( $aCSVArray ); } return ( @in_array( $value, $aCSVArray, $bStrict )); // returns true or false } function utlCsvIndexOf( $value, $aCSVArray, $bStrict = false, $retDefault = false ) { if( !is_array( $aCSVArray )) { $aCSVArray = utlCsvExplode( $aCSVArray ); } //print_r( $aCSVArray ); $sResult = ( array_search( $value, $aCSVArray, $bStrict )); // returns the key of the value if( $sResult === false ) { return $retDefault; } return $sResult; } function utlCsvImplode( $aArray ) // An CSVarray is nothing more than a string with comma seperated values { if( !is_array( $aArray )) { return $aArray; } return implode( ",", $aArray ); } function utlHtmlSpecialCharsDecode( $s ) { $aHex = utlGetTextBetween( $s, "&#", ";", false ); $c = @count( $aHex ); if( $c > 0 ) for( $i = 0; $i < $c; $i++ ) { $L = strlen( $aHex[ $i ] ); if( $L >= 1 and $L <= 5 ) { $chr = $aHex[ $i ]; if( is_hex( $chr )) { $chr = hexdec( str_replace( "x", "", $aHex[ $i ] )); } else { if( !is_numeric( $chr )) { $chr = null; } } if( $chr != null ) { $s = str_replace( "&#".$aHex[ $i ].";", chr( $chr ), $s ); } } } return $s; } /** * function utlExtractTemplateSnippet() : String * Extracts snippet/code between a begin and end tag and replaces everything between these tags with a * third tag to replace it later with parsed snippet(s). For example $tplID can be: * define( "TPLIDS_NEWSITEM", ",," ); */ function utlExtractTemplateSnippet( &$document, $tplIDs ) { $sResult = utlExtractTextBetween( $document, utlGetCSValue( $tplIDs, 0 ), // Begin tag utlGetCSValue( $tplIDs, 1 ), // End tag utlGetCSValue( $tplIDs, 2 ) ); // Replace tag return $sResult; } /** * function utlExtractTemplateSnippets() : Array/String * Extracts snippets/codes between a begin and end tag and replaces everything between these tags with a * third tag to replace it later with parsed snippets. For example $tplID can be: * define( "TPLIDS_NEWSITEMS", ",," ); * NOTICE: The %i will be replaced with a number (counter), so it is always unique */ function utlExtractTemplateSnippets( &$document, $tplIDs, $startCounter = -1, $bReturnAsString = false ) { $sResult = utlExtractTextBetween( $document, utlGetCSValue( $tplIDs, 0 ), // Begin tag utlGetCSValue( $tplIDs, 1 ), // End tag utlGetCSValue( $tplIDs, 2 ), // Replace tag $startCounter, $bReturnAsString ); return $sResult; } function utlGetCommentVarID( $s ) { return trim( utlGetTextBetween( $s, "", true )); } function utlGetAsCommentVar( $s ) { return ""; } function utlAddPrefixSuffix( $a_s, $sPrefix, $sSuffix = null, $bDoKeys = true, $bDoValues = false ) { if( ( !$bDoKeys and !$bDoValues ) or ( empty( $sPrefix ) and empty( $sSuffix )) ) { return $a_s; } if( !is_array( $a_s ) ) { return $prefix.$a_s.$suffix; } $aResult = array(); foreach( $a_s as $key=>$value ) { if( $bDoKeys ) { $key = $sPrefix.$key.$sSuffix; } if( $bDoValues ) { $value = $sPrefix.$value.$sSuffix; } $aResult[ $key ] = $value; } return $aResult; } function utlGetTableColumnNames( $tableName, $connObj = null ) { global $WABBIT; if( $conObj == null ) { global $CONNECT; $connObj = $CONNECT; } $bResult = !empty( $tableName ) and is_object( $connObj ) and is_object( $WABBIT ); if( $bResult ) { $sSql = "SHOW COLUMNS FROM ".$WABBIT->getTbl( $tableName ); $result = $connObj->readQuery( $sSql ); $bResult = ( is_array( $result ) and @count( $result ) > 0 ); } $aResult = array(); if( $bResult ) { foreach( $result as $row ) { $name = @trim( $row[ "Field" ] ); if( !empty( $name ) or $name == '0' ) // Looks silly but is required! { $aResult[] = $name; } } } return $aResult; } function utlGetRestrictions( ) { $a = func_get_args(); return implode( ",", $a ); } function utlTplRenderItems( $records, $msgNoItems, $tplItem, $tplItems, $ridVars ) { if( !is_array( $records ) or count( $records ) == 0 ) { return $msgNoItems; } $bFirst = true; $sHtml = ""; $RIDS = array(); foreach($records as $d) { if( $bFirst ) { $bFirst = false; foreach( $d as $name=>$void ) { $RIDS[] = "[/".strtoupper( trim( $name ))."/]"; } } $sHtml.= str_replace( $RIDS, $d, $tplItem ); } $sHtml = str_replace( $ridVars, $sHtml, $tplItems ); return $sHtml; } function utlGetStrucItemList( $moduleNum, $limit = null, $dateFormat = "%d-%m%-%Y", $dateIdName = "nl_date" ) { global $CONNECT, $WABBIT, $SESSION; if( is_array( $limit ) ) { $limit = " LIMIT ".implode( ",", $limit ); } elseif( !empty( $limit )) { $limit =" LIMIT ".$limit; } else { $limit = null; } $lang = $SESSION->getLanguage(); /* OPMERKING EH 25/09/2008: DIT IS DUS NIET DE BEDOELING! Dit bestand is bedoeld voor algemeen gebruik! * WIE HEEFT DIT HIERIN GEZET? MAAK EEN EIGEN FUNCTIE OF JE HAD EEN EXTRA PARAMETER KUNNEN TOEVOEGEN! * ZOIETS ALS $extraSQL = null en de rest in je eigen code! * * Onderstaande is alleen van toepassing op het ophalen van de nieuwsitems ten behoeve van de diensten pagina's * De bedoeling is dat de diensten pagina's vaste pagina's zijn en deze niet worden verwijderd etc. * * 1 = Personeel & Organisatie * 2 = Finance & Control * 3 = Informatisering & Automatisering */ if ($_GET['id'] == '18'){ // 1 $strDienstJoin = " LEFT JOIN ".$WABBIT->getTbl('integer')." AS i ON i.FK_structure=s.id "; $strDienstFilter = ' AND i.value=1 '; } elseif ($_GET['id'] == '19'){ //2 $strDienstJoin = " LEFT JOIN ".$WABBIT->getTbl('integer')." AS i ON i.FK_structure=s.id "; $strDienstFilter = ' AND i.value=2 '; } elseif ($_GET['id'] == '20'){ //3 $strDienstJoin = " LEFT JOIN ".$WABBIT->getTbl('integer')." AS i ON i.FK_structure=s.id "; $strDienstFilter = ' AND i.value=3 '; } else { $strDienstJoin = ''; $strDienstFilter = ''; } $sql = " SELECT *, t.content,DATE_FORMAT(date, '$dateFormat') AS $dateIdName FROM ".$WABBIT->getTbl('structure')." AS s"; $sql .= " LEFT JOIN ".$WABBIT->getTbl('text')." AS t ON t.FK_structure=s.id AND t.identifier='intro'" . $strDienstJoin; $sql .= " WHERE module=$moduleNum AND is_node=0 and language='$lang'" . $strDienstFilter; $sql .= " and (date_expire='0000-00-00' or date_expire is null or date_expire>now())"; $sql .= " ORDER BY date DESC"; $sql .= " $limit"; /* $sql = "select *,DATE_FORMAT(date, '$dateFormat') AS $dateIdName from ".$WABBIT->getTbl('structure'); $sql .= " where (date <= now()) and "; $sql .= "(date_expire='0000-00-00' or date_expire is null or date_expire>now())"; $sql .= " and module=$moduleNum and is_node=0"; $sql .= " order by date desc ".$limit; */ //print( $sql ); die; $records = $CONNECT->readQuery( $sql ); //print( $records ); return $records; } function utlGetNewsItems( $limit = null, $dateFormat = "%d-%m%-%Y", $dateIdName = "nl_date" ) { $records = utlGetStrucItemList( MOD_NEWS, $limit, $dateFormat, $dateIdName ); $records = utlTplRenderItems( $records, MSG_NONEWS, TPL_NEWS_ITEM, TPL_NEWS_ITEMLIST, RID_ITEMS ); //print( $records ); return $records; } function utlGetPositionItems( $limit = null, $dateFormat = "%d-%m%-%Y", $dateIdName = "nl_date" ) // Vacatures { $records = utlGetStrucItemList( MOD_POSITIONS, $limit, $dateFormat, $dateIdName ); $records = utlTplRenderItems( $records, MSG_NOPOSITION, TPL_POSITION_ITEM, TPL_POSITION_ITEMLIST, RID_ITEMS ); //print( $records ); return $records; } function utlGetDefines( $filterPrefix = null, $onlyOrdVals = true ) { if( empty( $filterPrefix ) and $fileterPrefix != 0 and !is_array( $filterPrefix )) { return get_defined_constants(); } $defs = get_defined_constants(); $aResult = array(); if( !is_array( $defs )) { return $aResult; } foreach( $defs as $name=>$value) { if( strpos( $name, $filterPrefix ) === 0 ) { if( !$onlyOrdVals or $onlyOrdVals and !is_array( $value ) and !is_bool( $value ) and !is_object( $value )) { $aResult[ $name ] = $value; } } } return $aResult; } function utlAlignString( $s, $bJustify = false, $maxLen = 80, $alignMode = UTL_AS_LEFT, $bTruncate = false, $spaceChar = " " ) { $s = trim( $s ); //print( $s."\n" ); $len = strlen( $s ); $bContinue = ( $len < $maxLen ); if( $bContinue ) { if( !$bJustify ) { switch( $alignMode ) { case UTL_AS_LEFT : // Align left { while( $len < $maxLen ) { $s.=$spaceChar; $len++; } break; } case UTL_AS_RIGHT : // Align right { while( $len < $maxLen ) { $s = $spaceChar.$s; $len++; } break; } case UTL_AS_CENTER : // Align center { $iSide = round( ( $maxLen-$len ) / 2 ); $iSide = ( $iSide > 0 ) ? $iSide : 0; $L = $iSide; while( $L > 0 ) { $s = $spaceChar.$s; $L--; } $L = $iSide; $len+=$L; while( $len < $maxLen and $L > 0 ) { $s.=$spaceChar; $L--; $len++; } break; } default : { break; } } } else { $a = explode( $spaceChar, $s ); $c = count( $a ); $spaceCount = max( 0, round( ($maxLen-$len ) / strlen( $spaceChar )) ); $spaceSize = $spaceCount * strlen( $spaceChar ); $spaceProcent = 100 - ($spaceSize * ( $maxLen / 100 )); //print( $spaceProcent."\n" ); $abLen = array(); $scLen = array(); $b = false; //print( (int)$spaceCount ); //if( $spaceCount > 1 ) { $i = 0; $c--; $s = ""; while( $spaceCount > 0 ) { //if( !array_key_exists( $i, $abLen )) // { $abLen[ $i ] = ( strlen( $a[ $i ] ) > 2 ); } if( !array_key_exists( $i, $scLen )) { $scLen[ $i ] = 0; } $scLen[ $i ]++; if( $spaceProcent <= 30 or $scLen[ $i ] < 3 ) { $a[ $i ].=$spaceChar; } $spaceCount--; $i = ( ( $i+1 ) < $c ) ? ( $i+1 ) : 0; } //print( implode( $spaceChar, $a ) ); $s = implode( $spaceChar, $a ); } } } if( $bTruncate and $len > $maxLen ) { $s = substr( $s, 0, $maxLen-1 ); } //print( $s ); return $s; } /** * Prints debug-information * * @param mixed $object The object to print * @param string $name (optional) The name of the object * @param string $from (optional) A clue to determine the location of 'this' debug-call */ if( !function_exists( "debug" )) { function debug($object, $name=null, $from=null) { echo "
"; // print variable name, if available if ($name!=null) { echo "$name: "; } // print location, if available if ($from!=null) { echo "(printed from $from)"; } // get object contents ob_start(); $output = htmlspecialchars(ob_get_contents()); ob_end_clean(); // print object echo "
";
        echo $output;
        echo "
"; echo "
"; } } if( !function_exists( "backtrace" )) { function backtrace() { $output = "

Backtrace:

\n"; $output .= "
\n"; $backtrace = debug_backtrace(); foreach ($backtrace as $bt) { $args = ''; foreach( $bt['args'] as $a ) { if (!empty ($args)) { $args .= ', '; } switch (gettype($a)) { case 'integer' : case 'double' : $args .= $a; break; case 'string' : $a = htmlspecialchars(substr($a, 0, 64)). ((strlen($a) > 64) ? '...' : ''); $args .= "\"$a\""; break; case 'array' : $args .= 'Array('.count($a).')'; break; case 'object' : $args .= 'Object('.get_class($a).')'; break; case 'resource' : $args .= 'Resource('.strstr($a, '#').')'; break; case 'boolean' : $args .= $a ? 'True' : 'False'; break; case 'NULL' : $args .= 'Null'; break; default : $args .= 'Unknown'; } } $output .= "file: {$bt['file']}, line {$bt['line']}
\n"; $output .= "call: {$bt['class']}{$bt['type']}{$bt['function']}($args);
\n"; $output .= "
\n"; } $output .= "
\n"; return $output; } } /** * Creates a 'cloaked' but click-able link for a given e-mail address. * The result needs to be installed in the 'onclick' attribute of an 'A' tag. * * @param string $email The e-mail address to cloak * @return string A cloaked e-mail address that can be used in the 'onclick' handler of an 'A' tag */ function cloakMailtoLink($email) { if (strpos($email, "@")!==false) { list($user, $domain) = explode("@", $email); return "mailto=\"mailto:\";mailto+=\"$user\";mailto+=\"@\";mailto+=\"$domain\";document.location.href=mailto;return false;"; } // else: return ""; } /** * Returns a 'cloaked' e-mail address. * * @param string $email The e-mail address to cloak * @return string A cloaked e-mail address */ function cloakEmail($email) { if (strpos($email, "@")!==false) { list($user, $domain) = explode("@", $email); return ""; } // else: return ""; } /** * Prepares a value for insertion in the database. If magic quotes are enabled, * these quotes are removed. Then, if the remaining value is not numeric, the * value is quoted with mysql_real_escape_string. * * @param mixed $value The value that needs to be escaped * @return string The escaped value */ if( !function_exists( "escape" )) { function escape($value) { if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote if not integer if (!is_numeric($value)) { $value = mysql_real_escape_string($value); } return $value; } } /** * Determines the size of an image if it is proportionally scaled to a certain maximum height or maximum width. * Note that this function DOES NOT ACTUALLY SCALE the image! * * @param string $filename The filename of the image that needs to be scaled. Can be a JP(E)G, GIF or PNG file. * @param int $max_x The maximum width of the scaled image. Defaults to 200 pixels. * @param int $max_y The maximum height of the scaled image. Defaults to 200 pixels. * @return array An array($scaled_width, $scaled_height) containing the scaled width and scaled height of the image. * If the image cannot be found, or is of an unsupported type, this function will return an array(-1, -1); */ function getScaledImageSize($filename, $max_x=200, $max_y=200) { $stop = false; if (!file_exists($filename)) { $stop = true; } $imageName = basename($filename); // een beetje van mezelf, en een beetje van php.net :) preg_match("'^(.*)\.(gif|jpe?g|png)$'i", $imageName, $ext); if (!$stop) { switch (strtolower($ext[2])) { case 'jpg' : case 'jpeg' : $im = imagecreatefromjpeg($filename); break; case 'gif' : $im = imagecreatefromgif($filename); break; case 'png' : $im = imagecreatefrompng($filename); break; default : $stop = true; break; } } if (!$stop) { $x = imagesx($im); $y = imagesy($im); if (($x < $max_x) && ($y < $max_y)) { // do not rescale small images return array($x, $y); } else { // determine new width and height if (($max_x / $max_y) < ($x / $y)) { return array($x / ($x / $max_x), $y / ($x / $max_x)); } else { return array($x / ($y / $max_y), $y / ($y / $max_y)); } } } return array(-1, -1); } function validEmail($email){ return (eregi("^[_a-z0-9-]+([_a-z0-9-\.\']+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", strtolower($email))); } /** * encode e-mail address by replacing characters by their hexa or decimal code **/ function encodeEmail($email){ $code = ''; $len = strlen($email); if ($len > 0){ for ($i=0; $i < $len; $i++){ $code .= (mt_rand(0,1)) ? "&#x".dechex(ord($email{$i})).";" : '&#'.ord($email{$i}).";"; } } return $code; } ?>