Ejemplo n.º 1
0
 function event_ParseURL($data)
 {
     global $CONF, $manager, $curl_blogid, $blogid, $itemid, $catid;
     global $memberid, $archivelist, $archive, $query;
     // initialize
     $info = $data['info'];
     $complete =& $data['complete'];
     if ($complete) {
         return;
     }
     $useCustomURL = $this->getAllBlogOptions('use_customurl');
     // Use NP_MultipleCategories ?
     $mcategories = $this->pluginCheck('MultipleCategories');
     if ($mcategories) {
         $param = array();
         $mcategories->event_PreSkinParse($param);
         global $subcatid;
         if (method_exists($mcategories, 'getRequestName')) {
             $subrequest = $mcategories->getRequestName();
         } else {
             $subrequest = 'subcatid';
         }
     }
     // initialize and sanitize '$blogid'
     if (!$blogid) {
         if (getVar('blogid')) {
             if (is_numeric(getVar('blogid'))) {
                 $blogid = intval(getVar('blogid'));
             } else {
                 $blogid = intval(getBlogIDFromName(getVar('blogid')));
             }
         } elseif ($curl_blogid) {
             $blogid = intval($curl_blogid);
         } elseif ($itemid > 0) {
             //2008-09-19 Cacher
             $blogid = getBlogIDFromItemID($itemid);
         } else {
             $blogid = $CONF['DefaultBlog'];
         }
         //2008-09-19 Cacher
     } else {
         if (is_numeric($blogid)) {
             $blogid = intval($blogid);
         } else {
             $blogid = intval(getBlogIDFromName($blogid));
         }
     }
     if (!$info) {
         if (serverVar('PATH_INFO')) {
             $info = serverVar('PATH_INFO');
         } elseif (getNucleusVersion() < 330) {
             if (getVar('virtualpath')) {
                 $info = getVar('virtualpath');
             }
         } else {
             if (getVar('query')) {
                 $info = serverVar('REQUEST_URI');
             } else {
                 return;
             }
             //by nekonosippo 2008-04-06 http://japan.nucleuscms.org/bb/viewtopic.php?p=22351#22351
         }
     }
     // Sanitize 'PATH_INFO'
     $info = trim($info, '/');
     $v_path = explode("/", $info);
     foreach ($v_path as $key => $value) {
         $value = urlencode($value);
         $value = preg_replace('|[^a-zA-Z0-9-~+_.?#=&;,/:@%]|i', '', $value);
         $v_path[$key] = $value;
     }
     if (phpversion() >= '4.1.0') {
         $_SERVER['PATH_INFO'] = implode('/', $v_path);
     }
     global $HTTP_SERVER_VARS;
     $HTTP_SERVER_VARS['PATH_INFO'] = implode('/', $v_path);
     // Admin area check
     $tmpURL = sprintf("%s%s%s", "http://", serverVar("HTTP_HOST"), serverVar("SCRIPT_NAME"));
     $uri = str_replace('/', '\\/', $tmpURL);
     $plug_url = str_replace('/', '\\/', $CONF['PluginURL']);
     $u_plugAction = getVar('action') == 'plugin' && getVar('name');
     $UsingPlugAdmin = FALSE;
     if (strpos($uri, $plug_url) === 0 || $u_plugAction) {
         $UsingPlugAdmin = TRUE;
     }
     // get real blogid
     $blink = FALSE;
     if (empty($info)) {
         $bLink = TRUE;
     }
     $linkObj = array('bid' => 0, 'name' => reset($v_path), 'linkparam' => 'blog');
     $blog_id = $this->getRequestPathInfo($linkObj);
     if ($blog_id) {
         $blogid = $blog_id;
         $trush = array_shift($v_path);
         $bLink = TURE;
     }
     if ($useCustomURL[$blogid] == 'no') {
         return;
     }
     // redirect to other URL style
     $useCustomURLyes = $useCustomURL[$blogid] == 'yes';
     if ($useCustomURLyes && !$UsingPlugAdmin && !$CONF['UsingAdminArea']) {
         // Search query redirection
         // 301 permanent ? or 302 temporary ?
         $queryURL = strpos(serverVar('REQUEST_URI'), 'query=') !== FALSE;
         $search_q = getVar('query') || $queryURL;
         $redirectSerch = $this->getBlogOption($blogid, 'redirect_search') == 'yes';
         if ($redirectSerch) {
             if ($search_q) {
                 $que_str = getVar('query');
                 $que_str = $this->hsc($que_str);
                 if (extension_loaded('mbstring')) {
                     $que_str = str_replace('/', md5('/'), $que_str);
                     $que_str = str_replace("'", md5("'"), $que_str);
                     $que_str = str_replace('&', md5('&'), $que_str);
                 } else {
                     $que_str = str_replace('/', md5('/'), $que_str);
                     $que_str = str_replace("'", md5("'"), $que_str);
                     $que_str = str_replace('&', md5('&'), $que_str);
                 }
                 $que_str = urlencode($que_str);
                 $search_path = 'search/' . $que_str;
                 $b_url = createBlogidLink($blogid);
                 $redurl = sprintf("%s%s", $b_url, $search_path);
                 redirect($redurl);
                 // 302 Moved temporary
                 exit;
             }
         }
         $exLink = FALSE;
         if (!$redirectSerch && $search_q) {
             $exLink = TRUE;
         }
         // redirection nomal URL to FancyURL
         $temp_req = explode('?', serverVar('REQUEST_URI'));
         $reqPath = trim(end($temp_req), '/');
         $indexrdf = $reqPath == 'xml-rss1.php';
         $atomfeed = $reqPath == 'atom.php';
         $rss2feed = $reqPath == 'xml-rss2.php';
         $feeds = $indexrdf || $atomfeed || $rss2feed;
         $redirectNormal = $this->getBlogOption($blogid, 'redirect_normal') == 'yes';
         if ($redirectNormal && serverVar('QUERY_STRING') && !$feeds && !$exLink) {
             $temp = explode('&', serverVar('QUERY_STRING'));
             foreach ($temp as $k => $val) {
                 if (preg_match('/^virtualpath/', $val)) {
                     unset($temp[$k]);
                 }
             }
             if (!empty($temp)) {
                 $p_arr = array();
                 foreach ($temp as $key => $value) {
                     $p_key = explode('=', $value);
                     switch (reset($p_key)) {
                         case 'blogid':
                             $p_arr[] = $CONF['BlogKey'] . '/' . intGetVar('blogid');
                             unset($temp[$key]);
                             break;
                         case 'catid':
                             $p_arr[] = $CONF['CategoryKey'] . '/' . intGetVar('catid');
                             unset($temp[$key]);
                             break;
                         case $subrequest:
                             $p_arr[] = $subrequest . '/' . intGetVar($subrequest);
                             unset($temp[$key]);
                             break;
                         case 'itemid':
                             $p_arr[] = $CONF['ItemKey'] . '/' . intGetVar('itemid');
                             unset($temp[$key]);
                             break;
                         case 'memberid':
                             $p_arr[] = $CONF['MemberKey'] . '/' . intGetVar('memberid');
                             unset($temp[$key]);
                             break;
                         case 'archivelist':
                             $p_arr[] = $CONF['ArchivesKey'] . '/' . $blogid;
                             unset($temp[$key]);
                             break;
                         case 'archive':
                             $p_arr[] = $CONF['ArchiveKey'] . '/' . $blogid . '/' . getVar('archive');
                             unset($temp[$key]);
                             break;
                         default:
                             break;
                     }
                 }
                 if (!empty($temp)) {
                     $queryTemp = '/?' . implode('&', $temp);
                 }
                 if (reset($p_arr)) {
                     $b_url = createBlogidLink($blogid);
                     $red_path = '/' . implode('/', $p_arr);
                     if (substr($b_url, -1) == '/') {
                         $b_url = rtrim($b_url, '/');
                     }
                     $redurl = sprintf("%s%s", $b_url, $red_path) . $queryTemp;
                     // HTTP status 301 "Moved Permanentry"
                     header('HTTP/1.1 301 Moved Permanently');
                     header('Location: ' . $redurl);
                     exit;
                 }
             }
         } elseif ($redirectNormal && $feeds) {
             $b_url = rtrim(createBlogidLink($blogid), '/');
             switch ($reqPath) {
                 case 'xml-rss1.php':
                     $feed_code = '/index.rdf';
                     break;
                 case 'xml-rss2.php':
                     $feed_code = '/rss2.xml';
                     break;
                 case 'atom.php':
                     $feed_code = '/atom.xml';
                     break;
                 default:
                     break;
             }
             // HTTP status 301 "Moved Permanentry"
             header('HTTP/1.1 301 Moved Permanently');
             header('Location: ' . $b_url . $feed_code);
             exit;
         }
     }
     // decode path_info
     // decode unofficial Page switch '/page_2.html'
     /*		foreach($v_path as $pathName) {
     			if (preg_match('/^page_/', $pathName)) {
     				$temp_info    = explode('page_', $pathName);
     				$_GET['page'] = intval($temp_info[1]);
     				$page         = array_pop($v_path);
     			}
     		}*/
     // decode TrackBack URL shorten ver.
     $tail = end($v_path);
     if (substr($tail, -10, 10) == '.trackback') {
         $v_pathName = substr($tail, 0, -10);
         if (is_numeric($v_pathName) || substr($v_pathName, -5) == '.html') {
             $this->_trackback($blogid, $v_pathName);
         } else {
             $this->_trackback($blogid, $v_pathName . '.html');
         }
         return;
     }
     // decode other type URL
     //		$bLink = $cLink = $iLink = $exLink = FALSE;
     $cLink = $iLink = $exLink = FALSE;
     $i = 1;
     $NP_ExtraSkinJPFlag = FALSE;
     $redURI = NULL;
     $sc = NULL;
     foreach ($v_path as $pathName) {
         switch ($pathName) {
             // decode FancyURLs and redirection to Customized URL
             // for blogsgetAllBlogOptions($name)
             case $CONF['BlogKey']:
                 if (isset($v_path[$i]) && is_numeric($v_path[$i])) {
                     if ($useCustomURL[intval($v_path[$i])] != 'yes') {
                         $blogid = intval($v_path[$i]);
                         $bLink = TRUE;
                     } else {
                         $redURI = createBlogidLink(intval($v_path[$i]));
                     }
                 }
                 break;
                 // for items
             // for items
             case $CONF['ItemKey']:
                 if (isset($v_path[$i]) && is_numeric($v_path[$i])) {
                     if ($useCustomURL[$blogid] != 'yes') {
                         $itemid = intval($v_path[$i]);
                         $iLink = TRUE;
                     } else {
                         $redURI = createItemLink(intval($v_path[$i]));
                     }
                 }
                 break;
                 // for categories
             // for categories
             case $CONF['CategoryKey']:
             case 'catid':
                 if (isset($v_path[$i]) && is_numeric($v_path[$i])) {
                     if ($useCustomURL[$blogid] != 'yes') {
                         $catid = intval($v_path[$i]);
                         $cLink = TRUE;
                     } else {
                         $redURI = createCategoryLink(intval($v_path[$i]));
                     }
                 }
                 break;
                 // for subcategories
             // for subcategories
             case $subrequest:
                 $c = $i - 2;
                 $subCat = isset($v_path[$i]) && is_numeric($v_path[$i]);
                 if ($mcategories && $subCat && $i >= 3 && is_numeric($v_path[$c])) {
                     if ($useCustomURL[$blogid] != 'yes') {
                         $subcatid = intval($v_path[$i]);
                         $catid = intval($v_path[$c]);
                         $cLink = TRUE;
                     } else {
                         $subcat_id = intval($v_path[$i]);
                         $catid = intval($v_path[$c]);
                         $linkParam = array($subrequest => $subcat_id);
                         $redURI = createCategoryLink($catid, $linkParam);
                     }
                 }
                 break;
                 // for archives
             // for archives
             case $CONF['ArchivesKey']:
             case $this->getOption('customurl_archives'):
                 // FancyURL
                 if (isset($v_path[$i]) && is_numeric($v_path[$i])) {
                     if ($useCustomURL[intval($v_path[$i])] != 'yes') {
                         $archivelist = intval($v_path[$i]);
                         $blogid = $archivelist;
                         $exLink = TRUE;
                     } else {
                         $redURI = createArchiveListLink(intval($v_path[$i]));
                     }
                     // Customized URL
                 } elseif (isset($v_path[$i]) && strpos($v_path[$i], 'page') === FALSE) {
                     $archivelist = $blogid;
                     $redURI = createArchiveListLink($archivelist);
                 } else {
                     $archivelist = $blogid;
                     $exLink = TRUE;
                 }
                 break;
                 // for archive
             // for archive
             case $CONF['ArchiveKey']:
             case $this->getOption('customurl_archive'):
                 $y = $m = $d = '';
                 $ar = $i + 1;
                 if (isset($v_path[$i])) {
                     $darc = preg_match('/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/', $v_path[$i]);
                     $marc = preg_match('/([0-9]{4})-([0-9]{1,2})/', $v_path[$i]);
                     $yarc = preg_match('/([0-9]{4})/', $v_path[$i]);
                     if (isset($v_path[$ar])) {
                         $adarc = preg_match('/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/', $v_path[$ar]);
                         $amarc = preg_match('/([0-9]{4})-([0-9]{1,2})/', $v_path[$ar]);
                         $ayarc = preg_match('/([0-9]{4})/', $v_path[$ar]);
                     } else {
                         $adarc = $amarc = $ayarc = NULL;
                     }
                     $arc = !$darc && !$marc && !$yarc;
                     $aarc = $adarc || $amarc || $ayarc;
                     $carc = $darc || $marc || $yarc;
                     // FancyURL
                     if (is_numeric($v_path[$i]) && $arc && isset($v_path[$ar]) && $aarc) {
                         sscanf($v_path[$ar], '%d-%d-%d', $y, $m, $d);
                         if (!empty($d)) {
                             $archive = sprintf('%04d-%02d-%02d', $y, $m, $d);
                         } elseif (!empty($m)) {
                             $archive = sprintf('%04d-%02d', $y, $m);
                         } else {
                             $archive = sprintf('%04d', $y);
                         }
                         if ($useCustomURL[intval($v_path[$i])] != 'yes') {
                             $blogid = intval($v_path[$i]);
                             $exLink = TRUE;
                         } else {
                             $blogid = intval($v_path[$i]);
                             $redURI = createArchiveLink($blogid, $archive);
                         }
                         // Customized URL
                     } elseif ($carc) {
                         sscanf($v_path[$i], '%d-%d-%d', $y, $m, $d);
                         if (!empty($d)) {
                             $archive = sprintf('%04d-%02d-%02d', $y, $m, $d);
                         } elseif (!empty($m)) {
                             $archive = sprintf('%04d-%02d', $y, $m);
                         } else {
                             $archive = sprintf('%04d', $y);
                         }
                         $exLink = TRUE;
                     } else {
                         $redURI = createArchiveListLink($blogid);
                     }
                 } else {
                     $redURI = createArchiveListLink($blogid);
                 }
                 break;
                 // for member
             // for member
             case $CONF['MemberKey']:
             case $this->getOption('customurl_member'):
                 // Customized URL
                 $customMemberURL = substr($v_path[$i], -5, 5) == '.html';
                 if (isset($v_path[$i]) && $customMemberURL) {
                     $memberInfo = array('linkparam' => 'member', 'bid' => 0, 'name' => $v_path[$i]);
                     $member_id = $this->getRequestPathInfo($memberInfo);
                     $memberid = intval($member_id);
                     $exLink = TRUE;
                     // FancyURL
                 } elseif (isset($v_path[$i]) && is_numeric($v_path[$i])) {
                     if ($useCustomURL[$blogid] != 'yes') {
                         $memberid = intval($v_path[$i]);
                         $exLink = TRUE;
                     } else {
                         $redURI = createMemberLink(intval($v_path[$i]));
                     }
                 } else {
                     $redURI = createBlogidLink($blogid);
                 }
                 break;
                 // for tag
                 // for pageswitch
             // for tag
             // for pageswitch
             case 'tag':
                 //					if ($this->pluginCheck(TagEx)) $exLink = true;
                 if ($this->pluginCheck(TagEX)) {
                     $exLink = true;
                 }
                 break;
                 //2008-07-28 http://japan.nucleuscms.org/bb/viewtopic.php?p=23175#23175
             //2008-07-28 http://japan.nucleuscms.org/bb/viewtopic.php?p=23175#23175
             case 'page':
                 $exLink = TRUE;
                 break;
                 // for ExtraSkinJP
             // for ExtraSkinJP
             case 'extra':
                 $ExtraSkinJP = $this->pluginCheck('ExtraSkinJP');
                 if ($ExtraSkinJP) {
                     $NP_ExtraSkinJPFlag = TRUE;
                 }
                 break;
                 // for search query
             // for search query
             case 'search':
                 $redirectSerch = $this->getBlogOption($blogid, 'redirect_search') == 'yes';
                 if ($redirectSerch) {
                     $que_str = urldecode($v_path[$i]);
                     if (extension_loaded('mbstring')) {
                         $que_str = str_ireplace(md5('/'), '/', $que_str);
                         $que_str = str_ireplace(md5("'"), "'", $que_str);
                         $que_str = str_ireplace(md5('&'), '&', $que_str);
                     } else {
                         $que_str = str_ireplace(md5('/'), '/', $que_str);
                         $que_str = str_ireplace(md5("'"), "'", $que_str);
                         $que_str = str_ireplace(md5('&'), '&', $que_str);
                     }
                     $que_str = htmlspecialchars_decode($que_str);
                     $_GET['query'] = $que_str;
                     $query = $que_str;
                     $exLink = TRUE;
                 }
                 break;
                 // for tDiarySkin
             // for tDiarySkin
             case 'tdiarydate':
             case 'categorylist':
             case 'monthlimit':
                 $tDiaryPlugin = $this->pluginCheck('tDiarySkin');
                 if ($tDiaryPlugin && isset($v_path[$i])) {
                     $_GET[$pathName] = $v_path[$i];
                     $exLink = TRUE;
                 }
                 break;
             case 'special':
             case $CONF['SpecialskinKey']:
                 if (isset($v_path[$i]) && is_string($v_path[$i])) {
                     $_REQUEST['special'] = $v_path[$i];
                     $exLink = TRUE;
                 }
                 break;
                 // for trackback
             // for trackback
             case 'trackback':
                 if (isset($v_path[$i]) && is_string($v_path[$i])) {
                     $this->_trackback($blogid, $v_path[$i]);
                 }
                 return;
                 break;
                 // decode Customized URL
             // decode Customized URL
             default:
                 // initialyze
                 $linkObj = array('bid' => $blogid, 'name' => $pathName);
                 $comp = FALSE;
                 $isItem = substr($pathName, -5) == '.html';
                 // category ?
                 if (!$comp && !$cLink && !$iLink && !$isItem && !$exLink) {
                     //2007-10-06 http://japan.nucleuscms.org/bb/viewtopic.php?p=20641#20641
                     $linkObj['linkparam'] = 'category';
                     $cat_id = $this->getRequestPathInfo($linkObj);
                     if (!empty($cat_id)) {
                         $catid = intval($cat_id);
                         $cLink = TRUE;
                         $comp = TRUE;
                     }
                 }
                 // subcategory ?
                 if (!$comp && $cLink && !$iLink && $mcategories && !$isItem && !$exLink) {
                     //2007-10-06 http://japan.nucleuscms.org/bb/viewtopic.php?p=20641#20641
                     $linkObj['linkparam'] = 'subcategory';
                     $linkObj['bid'] = $catid;
                     $subcat_id = $this->getRequestPathInfo($linkObj);
                     if (!empty($subcat_id)) {
                         $_REQUEST[$subrequest] = intval($subcat_id);
                         $subcatid = intval($subcat_id);
                         $sc = $i;
                         $comp = TRUE;
                     }
                 }
                 // item ?
                 if ($isItem) {
                     $linkObj['linkparam'] = 'item';
                     $item_id = $this->getRequestPathInfo($linkObj);
                     if (!empty($item_id)) {
                         $itemid = intval($item_id);
                         $iLink = TRUE;
                     }
                     if (preg_match('/^page_/', $pathName)) {
                         $iLink = TRUE;
                     }
                     //var_dump($linkObj);
                 }
                 break;
         }
         if (preg_match('/^[0-9page]$/', $pathName)) {
             $exLink = $pathName;
         }
         $i++;
     }
     if ($NP_ExtraSkinJPFlag) {
         $this->goNP_ExtraSkinJP();
     }
     // FancyURL redirect to Customized URL if use it
     // HTTP status 301 "Moved Permanentry"
     if ($redURI) {
         if (strpos(serverVar('REQUEST_URI'), '?') !== FALSE) {
             list($trush, $tempQueryString) = explode('?', serverVar('REQUEST_URI'), 2);
         }
         if ($tempQueryString) {
             $temp = explode('&', $tempQueryString);
             foreach ($temp as $k => $val) {
                 if (preg_match('/^virtualpath/', $val)) {
                     unset($temp[$k]);
                 }
             }
             if (!empty($temp)) {
                 $tempQueryString = '?' . implode('&', $temp);
             }
         }
         header('HTTP/1.1 301 Moved Permanently');
         header('Location: ' . $redURI . $tempQueryString);
         exit;
     }
     $feedurl = array('rss1.xml', 'index.rdf', 'rss2.xml', 'atom.xml');
     $siteMapPlugin = $this->pluginCheck('GoogleSitemap');
     if (!$siteMapPlugin) {
         $siteMapPlugin = $this->pluginCheck('SEOSitemaps');
     }
     if ($siteMapPlugin) {
         $pcSitemaps = $siteMapPlugin->getAllBlogOptions('PcSitemap');
         foreach ($pcSitemaps as $pCsitemap) {
             if ($pCsitemap) {
                 $feedurl[] = $pCsitemap;
             }
         }
         $mobSitemaps = $siteMapPlugin->getAllBlogOptions('MobileSitemap');
         foreach ($mobSitemaps as $mobSitemap) {
             if ($mobSitemap) {
                 $feedurl[] = $mobSitemap;
             }
         }
     }
     $feedurl = array_unique($feedurl);
     $request_path = end($v_path);
     $feeds = in_array($request_path, $feedurl, true);
     // finish decode
     if (!$exLink && !$feeds) {
         // URL Not Found
         if (substr(end($v_path), -5) == '.html' && !$iLink) {
             $notFound = TRUE;
             if (!empty($subcatid)) {
                 $linkParam = array($subrequest => $subcatid);
                 $uri = createCategoryLink($catid, $linkParam);
             } elseif (!empty($catid)) {
                 $uri = createCategoryLink($catid);
             } else {
                 $uri = createBlogidLink($blogid);
             }
         } elseif (count($v_path) > $sc && !empty($subcatid) && !$iLink) {
             $notFound = TRUE;
             $linkParam = array($subrequest => $subcatid);
             $uri = createCategoryLink($catid, $linkParam);
         } elseif (count($v_path) >= 2 && !$subcatid && !$iLink) {
             $notFound = TRUE;
             if (isset($catid)) {
                 $uri = createCategoryLink($catid);
             } else {
                 $uri = createBlogidLink($blogid);
             }
         } elseif (reset($v_path) && !$catid && !$subcatid && !$iLink) {
             $notFound = TRUE;
             $uri = createBlogidLink($blogid);
         } else {
             // Found
             // setting $CONF['Self'] for other plugins
             $uri = createBlogidLink($blogid);
             $CONF['Self'] = rtrim($uri, '/');
             $CONF['BlogURL'] = rtrim($uri, '/');
             $CONF['ItemURL'] = rtrim($uri, '/');
             $CONF['CategoryURL'] = rtrim($uri, '/');
             $CONF['ArchiveURL'] = rtrim($uri, '/');
             $CONF['ArchiveListURL'] = rtrim($uri, '/');
             $complete = TRUE;
             return;
         }
     } else {
         $uri = createBlogidLink($blogid);
         $CONF['Self'] = rtrim($uri, '/');
         $CONF['BlogURL'] = rtrim($uri, '/');
         $CONF['ItemURL'] = rtrim($uri, '/');
         $CONF['CategoryURL'] = rtrim($uri, '/');
         $CONF['ArchiveURL'] = rtrim($uri, '/');
         $CONF['ArchiveListURL'] = rtrim($uri, '/');
         $complete = TRUE;
         return;
     }
     // Behavior Not Found
     if ($notFound) {
         if (substr($uri, -1) != '/') {
             $uri .= '/';
         }
         if ($this->getOption('customurl_notfound') == '404') {
             header('HTTP/1.1 404 Not Found');
             doError(_NO_SUCH_URI);
             exit;
         } else {
             header('HTTP/1.1 303 See Other');
             header('Location: ' . $uri);
             exit;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Shows the list of categories using a given template
  */
 function showCategoryList($template)
 {
     global $CONF, $manager;
     // determine arguments next to catids
     // I guess this can be done in a better way, but it works
     global $archive, $archivelist;
     $linkparams = array();
     if ($archive) {
         $blogurl = createArchiveLink($this->getID(), $archive, '');
         $linkparams['blogid'] = $this->getID();
         $linkparams['archive'] = $archive;
     } else {
         if ($archivelist) {
             $blogurl = createArchiveListLink($this->getID(), '');
             $linkparams['archivelist'] = $archivelist;
         } else {
             $blogurl = createBlogidLink($this->getID(), '');
             $linkparams['blogid'] = $this->getID();
         }
     }
     //$blogurl = $this->getURL() . $qargs;
     //$blogurl = createBlogLink($this->getURL(), $linkparams);
     $template =& $manager->getTemplate($template);
     //: Change: Set nocatselected variable
     if ($this->getSelectedCategory()) {
         $nocatselected = 'no';
     } else {
         $nocatselected = 'yes';
     }
     echo TEMPLATE::fill(isset($template['CATLIST_HEADER']) ? $template['CATLIST_HEADER'] : null, array('blogid' => $this->getID(), 'blogurl' => $blogurl, 'self' => $CONF['Self'], 'catiscurrent' => $nocatselected, 'currentcat' => $nocatselected));
     $query = 'SELECT catid, cdesc as catdesc, cname as catname FROM ' . sql_table('category') . ' WHERE cblog=' . $this->getID() . ' ORDER BY cname ASC';
     $res = sql_query($query);
     while ($data = sql_fetch_assoc($res)) {
         $data['blogid'] = $this->getID();
         $data['blogurl'] = $blogurl;
         $data['catlink'] = createLink('category', array('catid' => $data['catid'], 'name' => $data['catname'], 'extra' => $linkparams));
         $data['self'] = $CONF['Self'];
         //catiscurrent
         //: Change: Bugfix for catiscurrent logic so it gives catiscurrent = no when no category is selected.
         $data['catiscurrent'] = 'no';
         $data['currentcat'] = 'no';
         if ($this->getSelectedCategory()) {
             if ($this->getSelectedCategory() == $data['catid']) {
                 $data['catiscurrent'] = 'yes';
                 $data['currentcat'] = 'yes';
             }
             /*else {
             			$data['catiscurrent'] = 'no';
             			$data['currentcat'] = 'no';
             		}*/
         } else {
             global $itemid;
             if (intval($itemid) && $manager->existsItem(intval($itemid), 0, 0)) {
                 $iobj =& $manager->getItem(intval($itemid), 0, 0);
                 $cid = $iobj['catid'];
                 if ($cid == $data['catid']) {
                     $data['catiscurrent'] = 'yes';
                     $data['currentcat'] = 'yes';
                 }
                 /*else {
                 			$data['catiscurrent'] = 'no';
                 			$data['currentcat'] = 'no';
                 		}*/
             }
         }
         $manager->notify('PreCategoryListItem', array('listitem' => &$data));
         echo TEMPLATE::fill(isset($template['CATLIST_LISTITEM']) ? $template['CATLIST_LISTITEM'] : null, $data);
         //$temp = TEMPLATE::fill((isset($template['CATLIST_LISTITEM']) ? $template['CATLIST_LISTITEM'] : null), $data);
         //echo strftime($temp, $current->itime);
     }
     sql_free_result($res);
     echo TEMPLATE::fill(isset($template['CATLIST_FOOTER']) ? $template['CATLIST_FOOTER'] : null, array('blogid' => $this->getID(), 'blogurl' => $blogurl, 'self' => $CONF['Self']));
 }
Ejemplo n.º 3
0
 /**
  *	A link to the archives for the current blog (or for default blog)
  */
 function parse_archivelink($linktext = '')
 {
     global $blog, $CONF;
     if ($blog) {
         echo $this->_link(createArchiveListLink($blog->getID(), $this->linkparams), $linktext);
     } else {
         echo $this->_link(createArchiveListLink(), $linktext);
     }
 }