/** * Reset the static route table. * * @since 1.11 * @author Robert Campbell * @internal */ public static function rebuild_static_routes() { // clear the route table. $db = cmsms()->GetDb(); $query = 'TRUNCATE TABLE ' . cms_db_prefix() . 'routes'; $db->Execute($query); // get content routes $query = 'SELECT content_id,page_url FROM ' . cms_db_prefix() . "content \n WHERE active=1 AND COALESCE(page_url,'') != ''"; $tmp = $db->GetArray($query); if (is_array($tmp) && count($tmp)) { for ($i = 0; $i < count($tmp); $i++) { $route = CmsRoute::new_builder($tmp[$i]['page_url'], '__CONTENT__', $tmp[$i]['content_id'], '', TRUE); cms_route_manager::add_static($route); } } // get the module routes $installed = ModuleOperations::get_instance()->GetInstalledModules(); foreach ($installed as $module_name) { $modobj = cms_utils::get_module($module_name); if (!$modobj) { continue; } $routes = $modobj->CreateStaticRoutes(); } }
protected function Insert() { $gCms = cmsms(); global $debug_errors; $db = $gCms->GetDb(); $config = $gCms->GetConfig(); $result = false; #Figure out the item_order if ($this->mItemOrder < 1) { $query = "SELECT max(item_order) as new_order FROM " . cms_db_prefix() . "content WHERE parent_id = ?"; $row = $db->Getrow($query, array($this->mParentId)); if ($row) { if ($row['new_order'] < 1) { $this->mItemOrder = 1; } else { $this->mItemOrder = $row['new_order'] + 1; } } } $newid = $db->GenID(cms_db_prefix() . "content_seq"); $this->mId = $newid; $this->mModifiedDate = $this->mCreationDate = trim($db->DBTimeStamp(time()), "'"); $query = "INSERT INTO " . $config["db_prefix"] . "content (content_id, content_name, content_alias, type, owner_id, parent_id, template_id, item_order, hierarchy, id_hierarchy, active, default_content, show_in_menu, cachable, secure, page_url, menu_text, markup, metadata, titleattribute, accesskey, tabindex, last_modified_by, create_date, modified_date) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; $dbresult = $db->Execute($query, array($newid, $this->mName, $this->mAlias, strtolower($this->mType), $this->mOwner, $this->mParentId, $this->mTemplateId, $this->mItemOrder, $this->mHierarchy, $this->mIdHierarchy, $this->mActive == true ? 1 : 0, $this->mDefaultContent == true ? 1 : 0, $this->mShowInMenu == true ? 1 : 0, $this->mCachable == true ? 1 : 0, $this->mSecure, $this->mURL, $this->mMenuText, $this->mMarkup, $this->mMetadata, $this->mTitleAttribute, $this->mAccessKey, $this->mTabIndex, $this->mLastModifiedBy, $this->mModifiedDate, $this->mCreationDate)); if (!$dbresult) { die($db->sql . '<br/>' . $db->ErrorMsg()); if ($config["debug"] == true) { # :TODO: Translate the error message $debug_errors .= "<p>Error inserting content</p>\n"; } } if (is_array($this->_props) && count($this->_props)) { // :TODO: There might be some error checking there debug_buffer('save from ' . __LINE__); $this->_save_properties(); } else { if (true == $config["debug"]) { # :TODO: Translate the error message $debug_errors .= "<p>Error inserting : the content has no properties</p>\n"; } } if (isset($this->mAdditionalEditors)) { foreach ($this->mAdditionalEditors as $oneeditor) { $new_addt_id = $db->GenID(cms_db_prefix() . "additional_users_seq"); $query = "INSERT INTO " . cms_db_prefix() . "additional_users (additional_users_id, user_id, content_id) VALUES (?,?,?)"; $db->Execute($query, array($new_addt_id, $oneeditor, $this->Id())); } } if ($this->mURL != '') { $route = CmsRoute::new_builder($this->mURL, '__CONTENT__', $this->mId, '', TRUE); cms_route_manager::add_static($route); } }
public function CreateStaticRoutes() { $db = cmsms()->GetDb(); $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)\\/(?P<junk>.*?)\\/d,(?P<detailtemplate>.*?)$/', $this->GetName()); cms_route_manager::add_static($route); $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)\\/(?P<junk>.*?)$/', $this->GetName()); cms_route_manager::add_static($route); $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)$/', $this->GetName()); cms_route_manager::add_static($route); $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)$/', $this->GetName()); cms_route_manager::add_static($route); $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)) { foreach ($tmp as $one) { news_admin_ops::register_static_route($one['news_url'], $one['news_id']); } } }
public static function register_static_route($news_url, $news_article_id, $detailpage = '') { if ($detailpage <= 0) { $gCms = cmsms(); $module = cms_utils::get_module('News'); $detailpage = $module->GetPreference('detail_returnid', -1); if ($detailpage == -1) { $detailpage = $gCms->GetContentOperations()->GetDefaultContent(); } } $parms = array('action' => 'detail', 'returnid' => $detailpage, 'articleid' => $news_article_id); $route = CmsRoute::new_builder($news_url, 'News', $news_article_id, $parms, TRUE); return cms_route_manager::add_static($route); }
$sqlarray = $dict->CreateIndexSQL(cms_db_prefix() . 'news_postdate', cms_db_prefix() . 'module_news', 'news_date'); $dict->ExecuteSQLArray($sqlarray); $sqlarray = $dict->CreateIndexSQL(cms_db_prefix() . 'news_daterange', cms_db_prefix() . 'module_news', 'start_time,end_time'); $dict->ExecuteSQLArray($sqlarray); $sqlarray = $dict->CreateIndexSQL(cms_db_prefix() . 'news_author', cms_db_prefix() . 'module_news', 'author_id'); $dict->ExecuteSQLArray($sqlarray); $sqlarray = $dict->CreateIndexSQL(cms_db_prefix() . 'news_hier', cms_db_prefix() . 'module_news', 'news_category_id'); $dict->ExecuteSQLArray($sqlarray); $sqlarray = $dict->CreateIndexSQL(cms_db_prefix() . 'news_url', cms_db_prefix() . 'module_news', 'news_url'); $dict->ExecuteSQLArray($sqlarray); $sqlarray = $dict->CreateIndexSQL(cms_db_prefix() . 'news_startenddate', cms_db_prefix() . 'module_news', 'start_time,end_time'); $dict->ExecuteSQLArray($sqlarray); #Setup events $this->CreateEvent('NewsArticleAdded'); $this->CreateEvent('NewsArticleEdited'); $this->CreateEvent('NewsArticleDeleted'); $this->CreateEvent('NewsCategoryAdded'); $this->CreateEvent('NewsCategoryEdited'); $this->CreateEvent('NewsCategoryDeleted'); $this->RegisterModulePlugin(TRUE); $this->RegisterSmartyPlugin('news', 'function', 'function_plugin'); // and routes... $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)\\/(?P<junk>.*?)\\/d,(?P<detailtemplate>.*?)$/', $this->GetName()); cms_route_manager::add_static($route); $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)\\/(?P<junk>.*?)$/', $this->GetName()); cms_route_manager::add_static($route); $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)$/', $this->GetName()); cms_route_manager::add_static($route); $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)$/', $this->GetName()); cms_route_manager::add_static($route);