global $database, $wb; $template = (isset($template) ? $template : ''); if($template == '') { //set default template $template = '<li><span> {LANG} {DATE} {TIME} {USER}</span> '; $template .= '<a href="{LINK}" title="{PAGE_TITLE}">{MENU_TITLE}</a></li>'; } $count = (!isset($count)) ? 5 : intval($count); $sql = 'SELECT `p`.`page_id`,`p`.`link`,`p`.`modified_when`,'; $sql .= '`p`.`language`,`p`.`visibility`,`p`.`viewing_groups`,'; $sql .= '`p`.`viewing_users`,`p`.`page_title`, `p`.`menu_title`, '; $sql .= '`u`.`display_name` '; $sql .= 'FROM `'.TABLE_PREFIX.'pages` `p` LEFT JOIN `'.TABLE_PREFIX.'users` `u` ON `p`.`modified_by`= `u`.`user_id` '; $sql .= 'ORDER BY `p`.`modified_when` DESC'; $output = ''; if( ($res_pages = $database->query($sql)) ) { $placeholders = array('{LINK}','{PAGE_TITLE}','{MENU_TITLE}','{LANG}','{DATE}','{TIME}','{USER}'); $showall = ($count == -1); while( ($rec_page = $res_pages->fetchRow(MYSQL_ASSOC)) && ($count > 0 || $showall) ) { if( $wb->page_is_visible($rec_page) ) { $replacements = array(); $replacements['link'] = WB_URL.PAGES_DIRECTORY.$rec_page['link'].PAGE_EXTENSION; $replacements['page_title'] = $rec_page['page_title']; $replacements['menu_title'] = $rec_page['menu_title']; if(defined('PAGE_LANGUAGES') && PAGE_LANGUAGES == true) { $replacements['lang'] = '['.$rec_page['language'].']'; }else { $replacements['lang'] = ''; } $replacements['date'] = date(DATE_FORMAT, $rec_page['modified_when']); $replacements['time'] = date(TIME_FORMAT, $rec_page['modified_when']); $replacements['user'] = $rec_page['display_name']; $output .= str_replace($placeholders, $replacements, $template)."n"; $count--; } } } if($output == '') { $output = '[[LastModifiedPages::no pages found]]'."n"; }else { $output = '<ul class="lastpages">'."n".$output."</ul>n"; } return $output;