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); } }
/** * 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(); } }
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); }