/* * phpblock_Staticpages: creates html listing all newly edited staticpages * for inclusion in a block * * The function itself is very short and simple, but is set up so you can * customise it easily. * * From Heather Engineering (http://www.heatherengineering.com/) */ function phpblock_Staticpages() { global $_CONF,$_TABLES; // ------------------- CUSTOMISE THESE VARIABLES TO SUIT ------------------- // $lag = 60*60*24*7; // seconds since edit to display as new $nothingnew = "No new pages"; // text to display when no pages to display $max_len = 15; // maximum length of string to display $max_pages = 10; // maximum number of pages to show // start tag for date/new text $span_s = '<span style="float:right;color:red;font-size:x-small;">'; $disp = "date"; // if "date" will show date, otherwise will // return contents of $disp (text/<img> tag // etc.) $span_e = '</span>'; // end tag for date/new text // format link to show in block if ($_CONF['url_rewrite'] == true) { $l = '<a href="'.$_CONF['site_url'].'/staticpages/index.php/%s"> %s </a>'; } else { $l = '<a href="'.$_CONF['site_url'].'/staticpages/index.php?page=%s"> %s </a>'; } // ---------- YOU SHOULDN'T NEED TO CUSTOMISE ANYTHING BELOW HERE ---------- // $retval = ''; $diff = time()-$lag; $sql = "SELECT sp_id, sp_date, sp_title FROM {$_TABLES['staticpage']} ORDER BY sp_date DESC"; $q = DB_Query($sql); $nrows = DB_numRows( $q ); if( $nrows == 0 ) { $retval = $nothingnew; } else { for( $i = 0; $i < $max_pages; $i++ ) { $A = DB_fetchArray( $q ); if (strtotime($A['sp_date']) > $diff) { if (strlen($A['sp_title']) > $max_len) { $A['sp_title'] = substr($A['sp_title'],0,$max_len).'...'; } $retval .= sprintf($l, $A['sp_id'], $A['sp_title']); if ($disp=="date") { $d = explode(" ",$A['sp_date']); } else { $d = $disp; } $retval .= $span_s.$d[0].$span_e; $retval .= '<br>'; } } } return $retval; }