diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 01011017f..ea0378fc7 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -248,6 +248,9 @@ class admin_newspost function __construct($qry, $pstobj) { global $user_pref; + + + $this->parseRequest($qry); require_once(e_HANDLER."cache_handler.php"); @@ -377,7 +380,7 @@ class admin_newspost { /*if($sefstr) $sefstr = md5($sefstr); ecache::clear_sys("news_sefurl".$sefstr);*/ - news::clearRewriteCache($sefstr); + // news::clearRewriteCache($sefstr); } function set_rwcache($sefstr, $data) @@ -385,7 +388,7 @@ class admin_newspost /**$sefstr = md5($sefstr); if(is_array($data)) $data = e107::getArrayStorage()->WriteArray($data, false); ecache::set_sys("news_sefurl".$sefstr, $data, true);*/ - news::setRewriteCache($sefstr, $data); + // news::setRewriteCache($sefstr, $data); } function ajax_observer() @@ -461,6 +464,9 @@ class admin_newspost function show_page() { + + print_a($POST); + switch ($this->getAction()) { case 'savepreset': case 'clr_preset': @@ -523,13 +529,7 @@ class admin_newspost switch ($delete) { case 'main': //clear rewrite cache - if(e107::getDb()->db_Select('news_rewrite', 'news_rewrite_id, news_rewrite_string', 'news_rewrite_source='.$del_id.' AND news_rewrite_type=1')) - { - $tmp = e107::getDb()->db_Fetch(); - e107::getDb()->db_Delete('news_rewrite', 'news_rewrite_id='.$tmp['news_rewrite_id']); - $this->clear_rwcache($tmp['news_rewrite_string']); - unset($tmp); - } + if ($e107->sql->db_Count('news','(*)',"WHERE news_id={$del_id}")) { e107::getEvent()->trigger("newsdel", $del_id); @@ -551,13 +551,7 @@ class admin_newspost //clear rewrite cache if(!getperms('0|7')) $this->noPermissions(); - if(e107::getDb()->db_Select('news_rewrite', 'news_rewrite_id, news_rewrite_string', 'news_rewrite_source='.$del_id.' AND news_rewrite_type=2')) - { - $tmp = e107::getDb()->db_Fetch(); - e107::getDb()->db_Delete('news_rewrite', 'news_rewrite_id='.$tmp['news_rewrite_id']); - $this->clear_rwcache($tmp['news_rewrite_string']); - unset($tmp); - } + if ($e107->sql->db_Count('news_category','(*)',"WHERE category_id={$del_id}")) { e107::getEvent()->trigger("newscatdel", $del_id); @@ -1072,10 +1066,8 @@ class admin_newspost // -------------------------------------------- $query = " - SELECT n.*, nc.*, nr.news_rewrite_string, ncr.news_rewrite_string AS news_category_rewrite_string, u.user_name FROM #news AS n + SELECT n.*, nc.*, u.user_name FROM #news AS n LEFT JOIN #news_category AS nc ON n.news_category=nc.category_id - LEFT JOIN #news_rewrite AS nr ON n.news_id=nr.news_rewrite_source AND nr.news_rewrite_type=1 - LEFT JOIN #news_rewrite AS ncr ON n.news_category=ncr.news_rewrite_source AND nr.news_rewrite_type=2 LEFT JOIN #user AS u ON n.news_author=u.user_id "; @@ -1334,17 +1326,6 @@ class admin_newspost $_POST['news_meta_description'] = $row['news_meta_description']; } } - - $row = array(); - if(e107::getDb()->db_Select('news_rewrite', '*', 'news_rewrite_source='.intval($this->getId()).' AND news_rewrite_type=1')) - { - $row = e107::getDb()->db_Fetch(); - } - - $_POST['news_rewrite_id'] = varset($row['news_rewrite_id'], 0); - $_POST['news_rewrite_source'] = $this->getId(); - $_POST['news_rewrite_string'] = isset($_POST['news_rewrite_string']) ? $_POST['news_rewrite_string'] : varset($row['news_rewrite_string'], ''); - $_POST['news_rewrite_type'] = 1; } } @@ -2020,9 +2001,9 @@ class admin_newspost 'news_rewrite_string' => '', 'news_rewrite_type' => 0 ); - if ($e107->sql->db_Select('news_rewrite', '*', 'news_rewrite_source='.$this->getId().' AND news_rewrite_type=2')) + // if ($e107->sql->db_Select('news_rewrite', '*', 'news_rewrite_source='.$this->getId().' AND news_rewrite_type=2')) { - $category_rewrite = $e107->sql->db_Fetch(); + // $category_rewrite = $e107->sql->db_Fetch(); } $jshelper->addResponseAction('fill-form', $category_rewrite); diff --git a/url.php b/url.php new file mode 100644 index 000000000..172bd91b3 --- /dev/null +++ b/url.php @@ -0,0 +1,136 @@ +urlPath = $urlPath; + $this->urlSrch = $urlSrch; + } + else // Root position SEF Url. + { + $this->urlPath = ""; + $this->urlSrch = $urlPath; + } + + $this->include = $this->getInclude(); //TODO Clean and Check returned URL. + + list($self,$query) = explode("?",$this->include); + $this->incFile = $tp->replaceConstants($self); + + if(!$query && $_SERVER['QUERY_STRING']) + { + $e_QUERY = str_replace(array('{', '}', '%7B', '%7b', '%7D', '%7d'), '', rawurldecode($_SERVER['QUERY_STRING'])); + $e_QUERY = str_replace('&', '&', $tp->post_toForm($e_QUERY)); + $query = $e_QUERY; + } + + define("e_SELF", e_REQUEST_SELF); + define("e_QUERY", $query); + } + + + function getInclude() + { + // Check SiteLinks First + $lnk = e107::getSitelinks(); + $links = $lnk->getlinks(0); + if(isset($lnk->sefList[$this->urlSrch])) + { + return $lnk->sefList[$this->urlSrch]; + } + + // Check Plugins (including News and Pages) + $urlConfig = e107::getAddonConfig('e_url'); + + foreach($urlConfig as $class_name=>$val) + { + foreach($val as $p=>$t) + { + if((vartrue($t['path']) == $this->urlPath) && vartrue($t['function'])) + { + if($ret = e107::callMethod($class_name."_url", $t['function'], $this->urlSrch)) + { + return $ret; + } + } + } + } + } + + + function debug() + { + echo "
REQUEST=".$_SERVER['REQUEST_URI']; + echo "
URI Path= ".$this->urlPath; + echo "
URI Found= ".$this->urlSrch; + echo "
Calculated e_SELF= ".$this->include; + echo "
Renewed e_SELF= ".e_SELF; + + echo "
e_QUERY= ".e_QUERY; + echo "
Including: ".$this->incFile; + + // echo "
e_REQUEST_URL= ".e_REQUEST_URL; + // echo "
e_REQUEST_SELF= " . e_REQUEST_SELF; // full URL without the QUERY string + // echo "
e_REQUEST_URI= " .e_REQUEST_URI; // absolute http path + query string + // echo "
e_REQUEST_HTTP= ". e_REQUEST_HTTP; // SELF URL without the QUERY string and leading domain part + // echo "
e_HTTP= ".e_HTTP; + // echo "
e_SELF= ".e_SELF; + } + + function create() + { + + } +} + + +$url = new eUrl; +$url->debug(); + + +if($url->incFile) +{ + require_once($url->incFile); +} + + +require_once(FOOTERF); // in case of URL failure. +?> \ No newline at end of file