예제 #1
0
 /**
  * Register a route to use for pretty url parsing
  *
  * Note: This method is not compatible wih lazy loading in the front end.
  *
  * @final
  * @see SetParameters
  * @param string Regular Expression Route to register
  * @param array Defaults for parameters that might not be included in the url
  * @return void
  */
 public final function RegisterRoute($routeregex, $defaults = array())
 {
     $route = new CmsRoute($routeregex, $this->GetName(), $defaults);
     cms_route_manager::register($route);
 }
 /**
  * Grab URLs from the content table and register them with the route manager.
  *
  * @since 1.9
  * @author Robert Campbell <*****@*****.**>
  * @internal
  * @access private
  */
 public function register_routes()
 {
     $gCms = cmsms();
     $db = $gCms->GetDb();
     $query = 'SELECT content_id,page_url FROM ' . cms_db_prefix() . 'content
                WHERE active = 1 AND default_content = 0 AND page_url != \'\'';
     $data = $db->GetArray($query);
     if (is_array($data)) {
         foreach ($data as $onerow) {
             $route = new CmsRoute($onerow['page_url'], $onerow['content_id'], '', TRUE);
             cms_route_manager::register($route);
         }
     }
 }
예제 #3
0
 function InitializeFrontend()
 {
     $gCms = cmsms();
     $db = $gCms->GetDb();
     $query = 'SELECT news_id,news_url FROM ' . cms_db_prefix() . 'module_news
                        WHERE status = ? AND news_url != ? AND ' . '(' . $db->ifNull('start_time', $db->DbTimeStamp(1)) . ' < NOW()) AND ' . '((' . $db->IfNull('end_time', $db->DbTimeStamp(1)) . ' = ' . $db->DbTimeStamp(1) . ') OR (end_time > NOW()))';
     $query .= ' ORDER BY news_date DESC';
     $tmp = $db->GetArray($query, array('published', ''));
     if (is_array($tmp)) {
         $detailpage = $this->GetPreference('detail_returnid', -1);
         if ($detailpage == -1) {
             $contentops = $gCms->GetContentOperations();
             $detailpage = $contentops->GetDefaultContent();
         }
         foreach ($tmp as $one) {
             $parms = array('action' => 'detail', 'returnid' => $detailpage, 'articleid' => $one['news_id']);
             $route = new CmsRoute($one['news_url'], $this->GetName(), $parms, TRUE);
             cms_route_manager::register($route);
         }
     }
     $this->RestrictUnknownParams();
     $this->RegisterRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)\\/(?P<junk>.*?)\\/d,(?P<detailtemplate>.*?)$/');
     $this->RegisterRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)\\/(?P<junk>.*?)$/');
     $this->RegisterRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)$/');
     $this->RegisterRoute('/[nN]ews\\/(?P<articleid>[0-9]+)$/');
     $this->SetParameterType('pagelimit', CLEAN_INT);
     $this->SetParameterType('browsecat', CLEAN_INT);
     $this->SetParameterType('showall', CLEAN_INT);
     $this->SetParameterType('showarchive', CLEAN_INT);
     $this->SetParameterType('sortasc', CLEAN_STRING);
     // should be int, or boolean
     $this->SetParameterType('sortby', CLEAN_STRING);
     $this->SetParameterType('detailpage', CLEAN_STRING);
     $this->SetParameterType('detailtemplate', CLEAN_STRING);
     $this->SetParameterType('formtemplate', CLEAN_STRING);
     $this->SetParameterType('browsecattemplate', CLEAN_STRING);
     $this->SetParameterType('summarytemplate', CLEAN_STRING);
     $this->SetParameterType('moretext', CLEAN_STRING);
     $this->SetParameterType('category', CLEAN_STRING);
     $this->SetParameterType('category_id', CLEAN_STRING);
     $this->SetParameterType('number', CLEAN_INT);
     $this->SetParameterType('start', CLEAN_INT);
     $this->SetParameterType('pagenumber', CLEAN_INT);
     $this->SetParameterType('articleid', CLEAN_INT);
     $this->SetParameterType('origid', CLEAN_INT);
     $this->SetParameterType('showtemplate', CLEAN_STRING);
     $this->SetParameterType('assign', CLEAN_STRING);
     $this->SetParameterType('inline', CLEAN_STRING);
     $this->SetParameterType('preview', CLEAN_STRING);
     // form parameters
     $this->SetParameterType('submit', CLEAN_STRING);
     $this->SetParameterType('cancel', CLEAN_STRING);
     $this->SetParameterType('category', CLEAN_STRING);
     $this->SetParameterType('title', CLEAN_STRING);
     $this->SetParameterType('content', CLEAN_STRING);
     $this->SetParameterType('summary', CLEAN_STRING);
     $this->SetParameterType('extra', CLEAN_STRING);
     $this->SetParameterType('postdate', CLEAN_STRING);
     $this->SetParameterType('postdate_Hour', CLEAN_STRING);
     $this->SetParameterType('postdate_Minute', CLEAN_STRING);
     $this->SetParameterType('postdate_Second', CLEAN_STRING);
     $this->SetParameterType('postdate_Month', CLEAN_STRING);
     $this->SetParameterType('postdate_Day', CLEAN_STRING);
     $this->SetParameterType('postdate_Year', CLEAN_STRING);
     $this->SetParameterType('startdate', CLEAN_STRING);
     $this->SetParameterType('startdate_Hour', CLEAN_STRING);
     $this->SetParameterType('startdate_Minute', CLEAN_STRING);
     $this->SetParameterType('startdate_Second', CLEAN_STRING);
     $this->SetParameterType('startdate_Month', CLEAN_STRING);
     $this->SetParameterType('startdate_Day', CLEAN_STRING);
     $this->SetParameterType('startdate_Year', CLEAN_STRING);
     $this->SetParameterType('enddate', CLEAN_STRING);
     $this->SetParameterType('enddate_Hour', CLEAN_STRING);
     $this->SetParameterType('enddate_Minute', CLEAN_STRING);
     $this->SetParameterType('enddate_Second', CLEAN_STRING);
     $this->SetParameterType('enddate_Month', CLEAN_STRING);
     $this->SetParameterType('enddate_Day', CLEAN_STRING);
     $this->SetParameterType('enddate_Year', CLEAN_STRING);
     $this->SetParameterType('useexp', CLEAN_INT);
     $this->SetParameterType('input_category', CLEAN_STRING);
     $this->SetParameterType('category_id', CLEAN_INT);
     $this->SetParameterType(CLEAN_REGEXP . '/news_customfield_.*/', CLEAN_STRING);
     $this->SetParameterType('junk', CLEAN_STRING);
 }