function keywords()
 {
     global $IN;
     if (!class_exists('Typography')) {
         require_once PATH_CORE . 'core.typography' . EXT;
     }
     $format = new Typography();
     return $IN->GBL('q') ? $format->light_xhtml_typography(stripslashes($IN->GBL('q'))) : FALSE;
 }
 function create_stack()
 {
     global $IN, $DB, $PREFS;
     // Only continue if we have segments to check and this is a page request
     if (REQ != "PAGE" || empty($IN->SEGS)) {
         return;
     }
     // Added by: Leevi Graham - Technical Director - Newism Pty Ltd <http://leevigraham.com> | <http://newism.com.au> on Dec 9th 2009
     // quick check to see if there is a comparison string, and if so does the comparison string match the URI?
     // no point doing a DB lookup if there is no category
     // This requires a new $conf variable to match against eg:
     // $conf['low_seg2cat_match'] = "#^/(earn|spend|save)#";
     if ($PREFS->ini('low_seg2cat_match') != FALSE && !preg_match($PREFS->ini('low_seg2cat_match'), $IN->URI)) {
         return;
     }
     // initiate some vars
     $site = $PREFS->ini('site_id');
     $data = $cats = $segs = array();
     $data['segment_category_ids'] = '';
     // loop through segments and set data array thus: segment_1_category_id etc
     foreach ($IN->SEGS as $nr => $seg) {
         $data['segment_' . $nr . '_category_id'] = '';
         $data['segment_' . $nr . '_category_name'] = '';
         $data['segment_' . $nr . '_category_description'] = '';
         $data['segment_' . $nr . '_category_image'] = '';
         $data['segment_' . $nr . '_category_parent_id'] = '';
         $segs[] = $DB->escape_str($seg);
     }
     // put segments in sql IN query; retrieve categories that match
     $sql_segs = "'" . implode("','", $segs) . "'";
     $sql = "SELECT\r\n\t\t\t\tcat_id, cat_url_title, cat_name, cat_description, cat_image, parent_id\r\n\t\t\tFROM\r\n\t\t\t\texp_categories\r\n\t\t\tWHERE\r\n\t\t\t\tcat_url_title\r\n\t\t\tIN\r\n\t\t\t\t({$sql_segs})\r\n\t\t\tAND\r\n\t\t\t\tsite_id = '{$site}'\r\n\t\t";
     $query = $DB->query($sql);
     // if we have matching categories, continue...
     if ($query->num_rows) {
         // initiate typography class for category title
         if (!class_exists('Typography')) {
             require PATH_CORE . 'core.typography' . EXT;
         }
         $TYPE = new Typography();
         // flip segment array to get 'segment_1' => '1'
         $ids = array_flip($IN->SEGS);
         // loop through categories
         foreach ($query->result as $row) {
             // overwrite values in data array
             $data['segment_' . $ids[$row['cat_url_title']] . '_category_id'] = $row['cat_id'];
             $data['segment_' . $ids[$row['cat_url_title']] . '_category_name'] = $TYPE->light_xhtml_typography($row['cat_name']);
             $data['segment_' . $ids[$row['cat_url_title']] . '_category_description'] = $row['cat_description'];
             $data['segment_' . $ids[$row['cat_url_title']] . '_category_image'] = $row['cat_image'];
             $data['segment_' . $ids[$row['cat_url_title']] . '_category_parent_id'] = $row['parent_id'];
             $cats[] = $row['cat_id'];
         }
         // create inclusive stack of all category ids present in segments
         $data['segment_category_ids'] = implode('&', $cats);
     }
     // register global variables
     $IN->global_vars = array_merge($IN->global_vars, $data);
 }