Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites
View Statistics - Next Notice - Previous NoticeDirectory filter : [ all ] / postnuke_modules / articles [ view in CVS ]
| Date | Directory [filter] | File(s) [view] | Author [filter] |
| 16 Aug 2002 15:52:11 | postnuke_modules/articles | pnadmin.php,1.29,1.30 pninit.php,1.22,1.23 pnuser.php,1.48,1.49 pnuserapi.php,1.38,1.39 | Mike |
| AND categories, catid, modules aliases for short URLs and some other stuff | |||
Update of /home/cvsroot/postnuke_modules/articles
In directory ns7.hostnuke.net:/tmp/cvs-serv7872
Modified Files:
pnadmin.php pninit.php pnuser.php pnuserapi.php
Log Message:
AND categories, catid, modules aliases for short URLs and some other stuff
Index: pnadmin.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/articles/pnadmin.php,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** pnadmin.php 8 Aug 2002 23:03:20 -0000 1.29
--- pnadmin.php 16 Aug 2002 15:52:08 -0000 1.30
***************
*** 38,44 ****
return;
}
// Return the template variables defined in this function
! return array('menu' => articles_admin_getmenu());
}
--- 38,48 ----
return;
}
+ $welcome = '';
+ // TODO: make language-dependent
+ @include('modules/articles/pnlang/eng/admindoc.php');
// Return the template variables defined in this function
! return array('menu' => articles_admin_getmenu(),
! 'welcome' => $welcome);
}
***************
*** 1081,1088 ****
--- 1085,1094 ----
$name,
$descr,
+ $usealias,
$config) = pnVarCleanFromInput('ptid',
'action',
'name',
'descr',
+ 'usealias',
'config');
***************
*** 1091,1094 ****
--- 1097,1103 ----
$ptid = '';
}
+ if (!isset($usealias)) {
+ $usealias = 0;
+ }
// Initialise the template variables
***************
*** 1167,1170 ****
--- 1176,1182 ----
return false;
} else {
+ if ($usealias) {
+ pnModSetAlias($name,'articles');
+ }
// Redirect to the admin view page
pnSessionSetVar('statusmsg',
***************
*** 1175,1178 ****
--- 1187,1195 ----
}
} elseif ($action == 'update') {
+ if ($usealias) {
+ pnModSetAlias($pubtypes[$ptid]['name'],'articles');
+ } else {
+ pnModDelAlias($pubtypes[$ptid]['name'],'articles');
+ }
if (!pnModAPIFunc('articles',
'admin',
***************
*** 1210,1213 ****
--- 1227,1231 ----
}
} elseif ($action == 'confirm') {
+ pnModDelAlias($pubtypes[$ptid]['name'],'articles');
if (!pnModAPIFunc('articles',
'admin',
***************
*** 1287,1290 ****
--- 1305,1309 ----
$data['fields'][] = array('name' => $field, 'descr' => $value);
}
+ $labels['usealias'] = pnML('Use publication type as alias for articles in short URLs');
} elseif ($action == 'modify') {
$labels['title'] = pnML('Edit publication type');
***************
*** 1300,1303 ****
--- 1319,1329 ----
foreach ($pubtypes[$ptid]['config'] as $field => $value) {
$data['fields'][] = array('name' => $field, 'descr' => $value);
+ }
+ $labels['usealias'] = pnML('Use publication type as alias for articles in short URLs');
+ $alias = pnModGetAlias($pubtypes[$ptid]['name']);
+ if ($alias == 'articles') {
+ $data['aliaschecked'] = 'checked';
+ } else {
+ $data['aliaschecked'] = '';
}
} elseif ($action == 'delete') {
Index: pninit.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/articles/pninit.php,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** pninit.php 10 Aug 2002 11:43:09 -0000 1.22
--- pninit.php 16 Aug 2002 15:52:08 -0000 1.23
***************
*** 288,291 ****
--- 288,292 ----
// Register Block types (this *should* happen at activation/deactivation)
pnBlockTypeRegister('articles', 'related');
+ pnBlockTypeRegister('articles', 'topitems');
// Initialisation successful
***************
*** 386,389 ****
--- 387,393 ----
pnModDelVar('articles', 'number_of_categories.4');
pnModDelVar('articles', 'cids.4');
+
+ pnBlockTypeUnregister('articles', 'related');
+ pnBlockTypeUnregister('articles', 'topitems');
// Deletion successful
Index: pnuser.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/articles/pnuser.php,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** pnuser.php 14 Aug 2002 00:16:51 -0000 1.48
--- pnuser.php 16 Aug 2002 15:52:08 -0000 1.49
***************
*** 38,45 ****
// TODO: generalize, organize, put stuff in userapi and categories, simplify
- // TODO: allow *AND*-ing of categories (also in categories API) !!!
-
/**
* view articles
*/
function articles_user_view()
--- 38,48 ----
// TODO: generalize, organize, put stuff in userapi and categories, simplify
/**
* view articles
+ *
+ * catid=1 : category 1 == cids[0]=1
+ * catid=1-2 : category 1 OR 2 == cids[0]=1&cids[1]=2
+ * catid=1+2 : category 1 AND 2 == cids[0]=1&cids[1]=2&andcids=1
+ *
*/
function articles_user_view()
***************
*** 48,54 ****
--- 51,61 ----
list($startnum,
$cids,
+ $andcids,
+ $catid,
$ptid,
$authorid) = pnVarCleanFromInput('startnum',
'cids',
+ 'andcids',
+ 'catid',
'ptid',
'authorid');
***************
*** 61,65 ****
// Example : show only frontpage-approved news articles by default
// publication type ID (for news, sections, reviews, ...)
! if (!isset($cids) && !isset($ptid) && !isset($authorid)) {
$ishome = 1;
// news articles
--- 68,72 ----
// Example : show only frontpage-approved news articles by default
// publication type ID (for news, sections, reviews, ...)
! if (!isset($catid) && !isset($cids) && !isset($ptid) && !isset($authorid)) {
$ishome = 1;
// news articles
***************
*** 91,94 ****
--- 98,107 ----
return;
}
+ // allow articles to work without comments
+ if (!pnModAvailable('comments') || !pnModAPILoad('comments', 'user')) {
+ $skipcomments = 1;
+ } else {
+ $skipcomments = 0;
+ }
// TODO: show this *after* category list when we start from categories :)
***************
*** 122,125 ****
--- 135,160 ----
}
+ // turn catid into cids array (and set andcids)
+ if (!empty($catid)) {
+ if (strpos($catid,' ')) {
+ $cids = explode(' ',$catid);
+ $andcids = true;
+ } elseif (strpos($catid,'+')) {
+ $cids = explode('+',$catid);
+ $andcids = true;
+ } else {
+ $cids = explode('-',$catid);
+ $andcids = false;
+ }
+ } else {
+ $catid = null;
+ if (empty($cids)) {
+ $cids = array();
+ }
+ if (empty($andcids)) {
+ $andcids = false;
+ }
+ }
+
// Get articles
$articles = pnModAPIFunc('articles',
***************
*** 128,131 ****
--- 163,167 ----
array('startnum' => $startnum,
'cids' => $cids,
+ 'andcids' => $andcids,
'ptid' => (isset($ptid) ? $ptid : null),
'authorid' => $authorid,
***************
*** 162,166 ****
// TODO: make this dependent on publication type too ?
! $data['catlabel'] = pnML('Browse in');
$data['backlabel'] = pnML('All');
$data['backlink'] = pnModURL('articles', 'user', 'view',
--- 198,206 ----
// TODO: make this dependent on publication type too ?
! if ($andcids) {
! $data['catlabel'] = pnML('Selected filter');
! } else {
! $data['catlabel'] = pnML('Browse in');
! }
$data['backlabel'] = pnML('All');
$data['backlink'] = pnModURL('articles', 'user', 'view',
***************
*** 174,177 ****
--- 214,218 ----
array('status' => array(3,2),
'cids' => $cids,
+ // 'andcids' => $andcids,
'ptid' => $ptid,
'reverse' => 1));
***************
*** 205,209 ****
'user',
'view',
! array('cids' => array($info['cid']),
'ptid' => $ptid));
$item['ptitle'] = pnVarPrepForDisplay(pnVarCensor($info['name']));
--- 246,250 ----
'user',
'view',
! array('catid' => $info['cid'],
'ptid' => $ptid));
$item['ptitle'] = pnVarPrepForDisplay(pnVarCensor($info['name']));
***************
*** 212,216 ****
} else {
$item['pjoin'] = '';
! $item['plink'] = '';
if (!empty($info['image'])) {
$data['icons'][] = array('image' => $info['image'],
--- 253,259 ----
} else {
$item['pjoin'] = '';
! if (!$andcids) {
! $item['plink'] = '';
! }
if (!empty($info['image'])) {
$data['icons'][] = array('image' => $info['image'],
***************
*** 225,229 ****
//TODO: only show 1-st level children, horizontally ?
// show child categories (when only 1 category is selected)
- // if (count($cids) == 1 && empty($articles)) {
if (count($cids) == 1) {
if (!pnModAPILoad('categories', 'visual')) {
--- 268,271 ----
***************
*** 267,271 ****
// TODO: show icons instead of (or in addition to) a link if available ?
$info['link'] = pnModURL('articles','user','view',
! array('cids' => array($info['id']),
'ptid' => $ptid));
$info['name'] = pnVarPrepForDisplay(pnVarCensor($info['name']));
--- 309,313 ----
// TODO: show icons instead of (or in addition to) a link if available ?
$info['link'] = pnModURL('articles','user','view',
! array('catid' => $info['id'],
'ptid' => $ptid));
$info['name'] = pnVarPrepForDisplay(pnVarCensor($info['name']));
***************
*** 284,303 ****
$string = pnModGetVar('articles','cids');
}
- // TODO: make 1 call to get all
$rootcats = split(';',$string);
$isfirst = 1;
$data['catlinks'] = array();
! foreach ($rootcats as $cid) {
! if (empty($cid)) {
! continue;
! }
! $info = pnModAPIFunc('categories',
! 'user',
! 'getcatinfo',
! array('cid' => $cid));
$item = array();
$item['cattitle'] = pnVarPrepForDisplay(pnVarCensor($info['name']));
$item['catlink'] = pnModURL('articles','user','view',
! array('cids' => array($info['cid']),
'ptid' => $ptid));
if ($isfirst) {
--- 326,341 ----
$string = pnModGetVar('articles','cids');
}
$rootcats = split(';',$string);
$isfirst = 1;
$data['catlinks'] = array();
! $catlist = pnModAPIFunc('categories',
! 'user',
! 'getcatinfo',
! array('cids' => $rootcats));
! foreach ($catlist as $cid => $info) {
$item = array();
$item['cattitle'] = pnVarPrepForDisplay(pnVarCensor($info['name']));
$item['catlink'] = pnModURL('articles','user','view',
! array('catid' => $info['cid'],
'ptid' => $ptid));
if ($isfirst) {
***************
*** 309,312 ****
--- 347,355 ----
$data['catlinks'][] = $item;
}
+ } elseif (!empty($authorid)) {
+ $data['catlabel'] = pnML('Browse by author');
+ $data['author'] = pnUserGetVar('name', $authorid);
+ } else {
+ $data['catlabel'] = pnML('TODO: Now what ?');
}
***************
*** 316,320 ****
return $data;
}
-
$out = '';
foreach ($articles as $article)
--- 359,362 ----
***************
*** 323,327 ****
array('aid' => $article['aid'],
'ptid' => $article['pubtypeid'],
! 'cids' => $cids));
$bodylen = strlen($article['body']);
if ($bodylen > 0) {
--- 365,369 ----
array('aid' => $article['aid'],
'ptid' => $article['pubtypeid'],
! 'catid' => $catid));
$bodylen = strlen($article['body']);
if ($bodylen > 0) {
***************
*** 333,340 ****
}
! if ($article['pubtypeid'] == 1) {
$article['date'] = strftime(_DATETIMELONG, $article['pubdate']);
! // TODO: use some comments user API function to get comment count
! $article['comments'] = '';
// TODO: to be defined
$article['topic_icons'] = '';
--- 375,398 ----
}
! $curptid = $article['pubtypeid'];
! if (!empty($pubtypes[$curptid]['config']['pubdate'])) {
$article['date'] = strftime(_DATETIMELONG, $article['pubdate']);
! // TODO: make configurable too, and/or put in API
! if ($skipcomments) {
! $article['comments'] = '';
! } else {
! $article['comments'] = pnModAPIFunc('comments',
! 'user',
! 'TotalCount',
! array('modid' => pnModGetIDFromName('articles'),
! 'itemid' => $article['aid']));
! if (!$article['comments']) {
! $article['comments'] = pnML('no comments');
! } elseif ($article['comments'] == 1) {
! $article['comments'] .= ' ' . pnML('comment');
! } else {
! $article['comments'] .= ' ' . pnML('comments');
! }
! }
// TODO: to be defined
$article['topic_icons'] = '';
***************
*** 355,358 ****
--- 413,417 ----
pnModAPIFunc('articles', 'user', 'countitems',
array('cids' => $cids,
+ 'andcids' => $andcids,
'ptid' => (isset($ptid) ? $ptid : null),
'authorid' => $authorid,
***************
*** 362,366 ****
'user',
'view',
! array('cids' => $cids,
'ptid' => $ptid,
'startnum' => '%%')),
--- 421,425 ----
'user',
'view',
! array('catid' => $catid,
'ptid' => $ptid,
'startnum' => '%%')),
***************
*** 479,483 ****
'user',
'view',
! array('cids' => array($info['cid']),
'ptid' => $ptid));
$item['ptitle'] = pnVarPrepForDisplay(pnVarCensor($info['name']));
--- 538,542 ----
'user',
'view',
! array('catid' => $info['cid'],
'ptid' => $ptid));
$item['ptitle'] = pnVarPrepForDisplay(pnVarCensor($info['name']));
***************
*** 492,496 ****
$icons .= '<a href="' .
pnModURL('articles','user','view',
! array('cids' => array($info['cid']),
'ptid' => $ptid)) .
'"><img src="' . $info['image'] . '" border="0" ' .
--- 551,555 ----
$icons .= '<a href="' .
pnModURL('articles','user','view',
! array('catid' => $info['cid'],
'ptid' => $ptid)) .
'"><img src="' . $info['image'] . '" border="0" ' .
***************
*** 868,872 ****
'user',
'view',
! array('cids' => array($info['id'])));
$list[$i]['name'] = pnVarPrepForDisplay(pnVarCensor($info['name']));
if (isset($catcount[$info['id']])) {
--- 927,931 ----
'user',
'view',
! array('catid' => $info['id']));
$list[$i]['name'] = pnVarPrepForDisplay(pnVarCensor($info['name']));
if (isset($catcount[$info['id']])) {
***************
*** 889,893 ****
$cattree[$cid][$j]['link'] = pnModURL('articles','user','view',
array('ptid' => $ptid,
! 'cids' => array($childcid)));
if (isset($pubcatcount[$ptid][$childcid])) {
$cattree[$cid][$j]['count'] = $pubcatcount[$ptid][$childcid];
--- 948,952 ----
$cattree[$cid][$j]['link'] = pnModURL('articles','user','view',
array('ptid' => $ptid,
! 'catid' => $childcid));
if (isset($pubcatcount[$ptid][$childcid])) {
$cattree[$cid][$j]['count'] = $pubcatcount[$ptid][$childcid];
***************
*** 909,917 ****
// frontpage or approved
array('status' => array(3,2),
! 'numcids' => 2, // depends on ptid cids.
'reverse' => 1));
$dump = 'TODO: show matrix/pivottable for categories (under construction)<br />';
list($one,$two) = $publinks[0]['rootcats'];
! if (count($cattree[$one]) < count($cattree[$two])) {
$three = $one;
$one = $two;
--- 968,983 ----
// frontpage or approved
array('status' => array(3,2),
! 'groupcids' => 2, // depends on ptid cids.
'reverse' => 1));
$dump = 'TODO: show matrix/pivottable for categories (under construction)<br />';
+
+ $dump .= '<form method="post">' . pnML('Publication') . ' <select name="ptid"><option value=""> ' . pnML(' ALL ');
+ foreach ($publinks as $pub) {
+ $dump .= '<option value="' . $pub['pubid'] . '"> ' . $pub['pubtitle'];
+ }
+ $dump .= '</select></form><br />';
+
list($one,$two) = $publinks[0]['rootcats'];
! if (count($cattree[$one]) <= count($cattree[$two])) {
$three = $one;
$one = $two;
***************
*** 942,947 ****
foreach ($matrix as $cid1 => $list) {
foreach ($list as $cid2 => $val) {
! $link = pnModURL('articles','user','view',array('cids' => array($cid2)));
! $dump .= '<td><a href="' . $link . '">' . $name[$cid2] . '</a></td>';
}
break;
--- 1008,1019 ----
foreach ($matrix as $cid1 => $list) {
foreach ($list as $cid2 => $val) {
! $link = pnModURL('articles','user','view',array('catid' => $cid2));
! // $dump .= '<td><a href="' . $link . '">' . $name[$cid2] . '</a></td>';
! //$names = '';
! //for ($i=0; $i < strlen($name[$cid2]); $i++) {
! // $names .= substr($name[$cid2],$i,1) . '<br>';
! //}
! $showname = wordwrap($name[$cid2],9,'<br>',1);
! $dump .= '<td valign="top" align="middle"><a href="' . $link . '">' . $showname . '</a></td>';
}
break;
***************
*** 949,961 ****
$dump .= '</tr>';
foreach ($matrix as $cid1 => $list) {
! $link = pnModURL('articles','user','view',array('cids' => array($cid1)));
$dump .= '<td><a href="' . $link . '">' . $name[$cid1] . '</a></td>';
foreach ($list as $cid2 => $val) {
if ($val > 0) {
// TODO: support andcids as parameter :-)
! $cidlist = array($cid1,$cid2);
! sort($cidlist,SORT_NUMERIC);
! $cids = join('+',$cidlist);
! $link = pnModURL('articles','user','view',array('cids' => $cids));
$dump .= '<td align="center"><a href="' . $link . '"> ' .$val . ' </a></td>';
} else {
--- 1021,1033 ----
$dump .= '</tr>';
foreach ($matrix as $cid1 => $list) {
! $link = pnModURL('articles','user','view',array('catid' => $cid1));
$dump .= '<td><a href="' . $link . '">' . $name[$cid1] . '</a></td>';
foreach ($list as $cid2 => $val) {
if ($val > 0) {
// TODO: support andcids as parameter :-)
! $cids = array($cid1,$cid2);
! sort($cids,SORT_NUMERIC);
! $catid = join('+',$cids);
! $link = pnModURL('articles','user','view',array('catid' => $catid));
$dump .= '<td align="center"><a href="' . $link . '"> ' .$val . ' </a></td>';
} else {
Index: pnuserapi.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/articles/pnuserapi.php,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** pnuserapi.php 13 Aug 2002 22:14:48 -0000 1.38
--- pnuserapi.php 16 Aug 2002 15:52:08 -0000 1.39
***************
*** 50,60 ****
* @param $args['numitems'] number of articles to get
* @param $args['startnum'] starting article number
* @param $args['authorid'] the ID of the author
* @param $args['ptid'] publication type ID (for news, sections, reviews, ...)
* @param $args['status'] array of requested status(es) for the articles
! * @param $args['cids'] array of category IDs for which to get articles (OR)
* (for all categories don�t set it)
! // TODO : better name for params
! * @param $args['andcids'] array of category IDs for which to get articles (AND)
* @param $args['startdate'] articles published at startdate or later
* (unix timestamp format)
--- 50,60 ----
* @param $args['numitems'] number of articles to get
* @param $args['startnum'] starting article number
+ * @param $args['aids'] array of article ids to get
* @param $args['authorid'] the ID of the author
* @param $args['ptid'] publication type ID (for news, sections, reviews, ...)
* @param $args['status'] array of requested status(es) for the articles
! * @param $args['cids'] array of category IDs for which to get articles (OR/AND)
* (for all categories don�t set it)
! * @param $args['andcids'] true means AND-ing categories listed in cids
* @param $args['startdate'] articles published at startdate or later
* (unix timestamp format)
***************
*** 79,84 ****
$cids = array();
}
! if (empty($andcids)) {
! $andcids = array();
}
--- 79,84 ----
$cids = array();
}
! if (!isset($andcids)) {
! $andcids = false;
}
***************
*** 113,117 ****
$required['title'] = 1;
// force cids as required when categories are given
! if (count($cids) > 0 || count($andcids) > 0) {
$required['cids'] = 1;
}
--- 113,117 ----
$required['title'] = 1;
// force cids as required when categories are given
! if (count($cids) > 0) {
$required['cids'] = 1;
}
***************
*** 194,199 ****
// add this for SQL compliance when there are multiple JOINs
! if (!empty($required['counter']) || count($cids) > 0 ||
! count($andcids) > 0) {
$from = '(' . $from . ')';
}
--- 194,198 ----
// add this for SQL compliance when there are multiple JOINs
! if (!empty($required['counter']) || count($cids) > 0) {
$from = '(' . $from . ')';
}
***************
*** 205,209 ****
// add this for SQL compliance when there are multiple JOINs
! if (count($cids) > 0 || count($andcids) > 0) {
$from = '(' . $from . ')';
}
--- 204,208 ----
// add this for SQL compliance when there are multiple JOINs
! if (count($cids) > 0) {
$from = '(' . $from . ')';
}
***************
*** 230,234 ****
$where[] = $hitcountdef['where'];
}
! if (count($cids) > 0 || count($andcids) > 0) {
// we rely on leftjoin() to create the necessary categories clauses
$where[] = $categoriesdef['where'];
--- 229,233 ----
$where[] = $hitcountdef['where'];
}
! if (count($cids) > 0) {
// we rely on leftjoin() to create the necessary categories clauses
$where[] = $categoriesdef['where'];
***************
*** 252,255 ****
--- 251,255 ----
$msg = pnML('Database error for #(1) function #(2)() in module #(3)',
'user', 'getall', 'Articles');
+ $msg .= $dbconn->ErrorMsg() . ' ' . $sql;
pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
new SystemException($msg));
***************
*** 276,280 ****
$result->Close();
! if ($required['cids'] && count($articles) > 0) {
// Get all the categories at once
$aids = array();
--- 276,280 ----
$result->Close();
! if (!empty($required['cids']) && count($articles) > 0) {
// Get all the categories at once
$aids = array();
***************
*** 497,503 ****
* @param $args['status'] array of requested status(es) for the articles
* @param $args['ptid'] publication type ID
! * @param $args['cids'] array of category IDs (OR)
! * @param $args['andcids'] array of category IDs (AND), or
! * @param $args['numcids'] number of categories to group by (AND)
* @param $args['reverse'] default is ptid => cid, reverse (1) is cid => ptid
* @returns array
--- 497,503 ----
* @param $args['status'] array of requested status(es) for the articles
* @param $args['ptid'] publication type ID
! * @param $args['cids'] array of category IDs (OR/AND)
! * @param $args['andcids'] true means AND-ing categories listed in cids
! * @param $args['groupcids'] the number of categories you want items grouped by
* @param $args['reverse'] default is ptid => cid, reverse (1) is cid => ptid
* @returns array
***************
*** 664,669 ****
* count number of items depending on additional module criteria
*
! * @param $args['cids'] array of cids that we are counting for (OR)
! * @param $args['andcids'] array of cids that we are counting for (AND)
*
* @param $args['authorid'] the ID of the author
--- 664,669 ----
* count number of items depending on additional module criteria
*
! * @param $args['cids'] array of cids that we are counting for (OR/AND)
! * @param $args['andcids'] true means AND-ing categories listed in cids
*
* @param $args['authorid'] the ID of the author
***************
*** 696,702 ****
}
if (!isset($args['andcids'])) {
! $args['andcids'] = array();
}
! if (count($args['cids']) > 0 || count($args['andcids']) > 0) {
// Load API
if (!pnModAPILoad('categories', 'user')) {
--- 696,702 ----
}
if (!isset($args['andcids'])) {
! $args['andcids'] = false;
}
! if (count($args['cids']) > 0) {
// Load API
if (!pnModAPILoad('categories', 'user')) {
***************
*** 1080,1126 ****
}
if (isset($ptid) && isset($pubtypes[$ptid])) {
! $path = '/' . $module . '/' . $pubtypes[$ptid]['name'] . '/';
}
! if (isset($cids) && is_array($cids) && count($cids) > 0) {
! if (count($cids) == 1) {
! if (isset($ptid) && isset($pubtypes[$ptid])) {
! if (isset($bycat)) {
! $path = '/' . $module . '/c' . $cids[0]
! . '/' . $pubtypes[$ptid]['name'] . '/';
} else {
$path = '/' . $module . '/' . $pubtypes[$ptid]['name']
! . '/c' . $cids[0] . '/';
}
- } else {
- $path = '/' . $module . '/c' . $cids[0] . '/';
}
/*
// perhaps someday, with a convertor to 7-bit ASCII or something...
! // use a cache to avoid re-querying for each URL in the same cat
! static $catcache = array();
! $cid = $cids[0];
! if (pnModAPILoad('categories','user')) {
! if (isset($catcache[$cid])) {
! $cat = $catcache[$cid];
! } else {
! $cat = pnModAPIFunc('categories','user','getcatinfo',
! array('cid' => $cid));
! // put the category in cache
! $catcache[$cid] = $cat;
! }
! if (!empty($cat) && !empty($cat['name'])) {
! // use the category name as part of the path here
! $name = preg_replace('/\s+/','_',$cat['name']);
! $name = strtolower($name);
! $path = '/' . $module . '/c/' . rawurlencode($name) .'/';
! }
}
- */
-
- } else {
- // this is *not* supported for short URLs -> do nothing
- // (e.g. for multiple category selections)
- $path = '';
}
} elseif (empty($path)) {
$path = '/' . $module . '/';
--- 1080,1132 ----
}
if (isset($ptid) && isset($pubtypes[$ptid])) {
! $alias = pnModGetAlias($pubtypes[$ptid]['name']);
! if ($alias == $module) {
! // OK, we can use a 'fake' module name here
! $path = '/' . $pubtypes[$ptid]['name'] . '/';
! } else {
! $path = '/' . $module . '/' . $pubtypes[$ptid]['name'] . '/';
! }
}
! if (!empty($catid)) {
! if (isset($ptid) && isset($pubtypes[$ptid])) {
! if (isset($bycat)) {
! $path = '/' . $module . '/c' . $catid
! . '/' . $pubtypes[$ptid]['name'] . '/';
! } else {
! $alias = pnModGetAlias($pubtypes[$ptid]['name']);
! if ($alias == $module) {
! // OK, we can use a 'fake' module name here
! $path = '/' . $pubtypes[$ptid]['name']
! . '/c' . $catid . '/';
} else {
$path = '/' . $module . '/' . $pubtypes[$ptid]['name']
! . '/c' . $catid . '/';
}
}
+ } else {
+ $path = '/' . $module . '/c' . $catid . '/';
+ }
/*
// perhaps someday, with a convertor to 7-bit ASCII or something...
! // use a cache to avoid re-querying for each URL in the same cat
! static $catcache = array();
! $cid = $cids[0];
! if (pnModAPILoad('categories','user')) {
! if (isset($catcache[$cid])) {
! $cat = $catcache[$cid];
! } else {
! $cat = pnModAPIFunc('categories','user','getcatinfo',
! array('cid' => $cid));
! // put the category in cache
! $catcache[$cid] = $cat;
! }
! if (!empty($cat) && !empty($cat['name'])) {
! // use the category name as part of the path here
! $name = preg_replace('/\s+/','_',$cat['name']);
! $name = strtolower($name);
! $path = '/' . $module . '/c/' . rawurlencode($name) .'/';
}
}
+ */
} elseif (empty($path)) {
$path = '/' . $module . '/';
***************
*** 1128,1132 ****
} elseif ($func == 'display' && isset($aid)) {
if (isset($ptid) && isset($pubtypes[$ptid])) {
! $path = '/' . $module . '/' . $pubtypes[$ptid]['name'] . "/$aid.html";
} else {
$path = '/' . $module . "/$aid.html";
--- 1134,1144 ----
} elseif ($func == 'display' && isset($aid)) {
if (isset($ptid) && isset($pubtypes[$ptid])) {
! $alias = pnModGetAlias($pubtypes[$ptid]['name']);
! if ($alias == $module) {
! // OK, we can use a 'fake' module name here
! $path = '/' . $pubtypes[$ptid]['name'] . "/$aid.html";
! } else {
! $path = '/' . $module . '/' . $pubtypes[$ptid]['name'] . "/$aid.html";
! }
} else {
$path = '/' . $module . "/$aid.html";
***************
*** 1144,1147 ****
--- 1156,1166 ----
//}
} elseif ($func == 'archive') {
+ if (isset($ptid) && isset($pubtypes[$ptid])) {
+ $alias = pnModGetAlias($pubtypes[$ptid]['name']);
+ if ($alias == $module) {
+ // OK, we can use a 'fake' module name here
+ $module = $pubtypes[$ptid]['name'];
+ }
+ }
if (isset($month)) {
if ($month == 'all') {
***************
*** 1159,1162 ****
--- 1178,1182 ----
// anything else does not have a short URL equivalent
+ // TODO: add *any* extra args we didn't use yet here
// add some other module arguments as standard URL parameters
if (!empty($path) && isset($startnum)) {
***************
*** 1178,1181 ****
--- 1198,1217 ----
{
$args = array();
+
+ // Check if we're dealing with an alias here
+ if ($params[0] != 'articles') {
+ $alias = pnModGetAlias($params[0]);
+ if ($alias == 'articles') {
+ // yup, looks like it
+ $pubtypes = pnModAPIFunc('articles','user','getpubtypes');
+ foreach ($pubtypes as $id => $pubtype) {
+ if ($params[0] == $pubtype['name']) {
+ $args['ptid'] = $id;
+ break;
+ }
+ }
+ }
+ }
+
if (empty($params[1])) {
return array('view', $args);
***************
*** 1207,1213 ****
}
! } elseif (preg_match('/^c(\d+)/',$params[1],$matches)) {
! $cids[0] = $matches[1];
! $args['cids'] = $cids;
if (!empty($params[2])) {
$pubtypes = pnModAPIFunc('articles','user','getpubtypes');
--- 1243,1249 ----
}
! } elseif (preg_match('/^c([0-9 +-]+)/',$params[1],$matches)) {
! $catid = $matches[1];
! $args['catid'] = $catid;
if (!empty($params[2])) {
$pubtypes = pnModAPIFunc('articles','user','getpubtypes');
***************
*** 1235,1241 ****
$args['aid'] = $aid;
return array('display', $args);
! } elseif (preg_match('/^c(\d+)/',$params[2],$matches)) {
! $cids[0] = $matches[1];
! $args['cids'] = $cids;
return array('view', $args);
} elseif ($params[2] == 'archive') {
--- 1271,1277 ----
$args['aid'] = $aid;
return array('display', $args);
! } elseif (preg_match('/^c([0-9 +-]+)/',$params[2],$matches)) {
! $catid = $matches[1];
! $args['catid'] = $catid;
return array('view', $args);
} elseif ($params[2] == 'archive') {
View Statistics - Next Notice - Previous Notice
| Visit Developer Site - Browse CVS Repository |
Syndicate via backend.rss (max. once per hour please) | Powered by CVSNotice 0.1.3 |