Skip to content
This repository was archived by the owner on Aug 13, 2022. It is now read-only.

Commit aeb283f

Browse files
committed
Make category function work with enabled shorturl mode. Refs #19. Pagination not yet working with this function
1 parent 7e23213 commit aeb283f

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

src/modules/Feeds/lib/Feeds/Api/User.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,14 @@ public function encodeurl($args)
250250
}
251251
}
252252

253+
// category function
254+
if ($args['func'] == 'category' && isset($args['args']['cat'])) {
255+
$vars .= $args['args']['cat'];
256+
if (isset($args['args']['startnum'])) {
257+
$vars .= '/startnum/'.$args['args']['startnum'];
258+
}
259+
}
260+
253261
// for the display function use either the title (if present) or the page id
254262
if ($args['func'] == 'display') {
255263
// check for the generic object id parameter
@@ -276,6 +284,9 @@ public function encodeurl($args)
276284
} else {
277285
return $args['modname'] . '/' . $args['func'] . '/' . $vars . '/';
278286
}
287+
288+
289+
279290
}
280291

281292
/**
@@ -292,7 +303,7 @@ public function decodeurl($args)
292303
}
293304

294305
// define the available user functions
295-
$funcs = array('main', 'view', 'display');
306+
$funcs = array('main', 'view', 'display', 'category');
296307
// set the correct function name based on our input
297308
if (empty($args['vars'][2])) {
298309
System::queryStringSetVar('func', 'main');
@@ -322,6 +333,13 @@ public function decodeurl($args)
322333
}
323334
}
324335

336+
// category function
337+
if (FormUtil::getPassedValue('func') == 'category') {
338+
if (is_numeric($args['vars'][$nextvar])) {
339+
System::queryStringSetVar('cat', $args['vars'][$nextvar]);
340+
}
341+
}
342+
325343
// identify the correct parameter to identify the page
326344
if (FormUtil::getPassedValue('func') == 'display') {
327345
if (is_numeric($args['vars'][$nextvar])) {

src/modules/Feeds/lib/Feeds/Controller/User.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ function category($args)
255255
return LogUtil::registerError($this->__('Invalid category'));
256256
}
257257

258+
$rootCat = CategoryUtil::getCategoryByID($catregistry[$prop]);
259+
$rootCat['path'] .= '/'; // add this to make the relative paths of the subcategories with ease
260+
258261
// Get all matching feeds
259262
$items = ModUtil::apiFunc('Feeds', 'user', 'getall', array('category' => isset($catFilter) ? $catFilter : null,
260263
'catregistry' => isset($catregistry) ? $catregistry : null));
@@ -270,17 +273,17 @@ function category($args)
270273
$feed = ModUtil::apiFunc('Feeds', 'user', 'get', array('fid' => $item['fid']));
271274
if ($feed != false) {
272275
$furls[] = $feed['url'];
273-
$FeedLinkBack[$feed['url']] = array('name' => $feed['name'], 'fid' => $feed['fid'], 'url' => $feed['url']);
276+
$FeedLinkBack[DataUtil::formatForDisplayHTML($feed['url'])] = array('name' => $feed['name'], 'fid' => $feed['fid'], 'url' => $feed['url']);
274277
}
275278
}
276-
277279
// read the feed sources
278280
$FeedInfo = ModUtil::apiFunc('Feeds', 'user', 'getfeed', array('furl' => $furls, 'limit' => $modvars['multifeedlimit']));
279281
}
280282

281283
// Display details of the item.
282284
$this->view->assign('lang', ZLanguage::getLanguageCode());
283285
$this->view->assign('catID', $cat);
286+
$this->view->assign('rootCat', $rootCat);
284287
$this->view->assign('FeedLinkBack', $FeedLinkBack);
285288
$this->view->assign('category', $catInfo);
286289
$this->view->assign('property', $prop);

src/modules/Feeds/templates/user/category.tpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
</div>
1313

1414
<div class="feed-list">
15-
<p>&nbsp;</p>
1615
{foreach from=$feeditems item='feeditem'}
1716
<div class="feeditem">
1817
{assign var='feeditemlink' value=$feeditem->get_link()}
@@ -26,12 +25,13 @@
2625
{if $feeditemauthorid}
2726
{assign var='feeditemauthor' value=$feeditemauthorid->get_name()}
2827
{/if}
28+
2929
<div class="feeditem-title">
30-
<a href="{$feeditemlink|safetext}" {if $modvars.Feeds.openinnewwindow eq 1}target="_blank"{/if}>{$feeditemtitle|safetext}</a>
30+
<a href="{$feeditemlink}" {if $modvars.Feeds.openinnewwindow eq 1}target="_blank"{/if}>{$feeditemtitle|safetext}</a>
3131
</div>
3232
<div class="feeditem-info">
3333
{$feeditemdate|dateformat:'%I:%M %p %A, %B %e, %Y'}
34-
&nbsp;-&nbsp;
34+
&nbsp;
3535
<a href="{modurl modname='Feeds' type='user' func='display' fid=$FeedLinkInfo.fid}" title="{$FeedLinkInfo.name|safetext}">{$FeedLinkInfo.name|safetext}</a>
3636
&nbsp;
3737
{if $feeditemauthor neq ''}
@@ -40,9 +40,9 @@
4040
</div>
4141
<div class="feeditem-text">
4242
{if $feeditemdescription neq ''}
43-
<p>{$feeditemdescription|safehtml}</p>
43+
<div>{$feeditemdescription|safehtml}</div>
4444
<div class="feeditem-more">
45-
<a href="{$feeditemlink|safetext}" {if $modvars.Feeds.openinnewwindow eq 1}target="_blank"{/if}>{gt text='Read more'}</a>
45+
<a href="{$feeditemlink}" {if $modvars.Feeds.openinnewwindow eq 1}target="_blank"{/if}>{gt text='Read more'}</a>
4646
</div>
4747
{/if}
4848
</div>

src/modules/Feeds/templates/user/display.tpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
{assign var='image' value=$feed->get_image_url()}
88
{assign var='title' value=$feed->get_image_title()}
99
{if $link neq ''}
10-
<a href="{$link|safetext}"><img src="{$image}" alt="{$title|safetext}" /></a>
10+
<a href="{$link}"><img src="{$image}" alt="{$title|safetext}" /></a>
1111
{else}
12-
<img src="{$link|safetext}" alt="{$title|safetext}" />
12+
<img src="{$link}" alt="{$title|safetext}" />
1313
{/if}
1414
</div>
1515
{/if}
@@ -32,7 +32,7 @@
3232
{assign var='feeditemauthor' value=$feeditemauthorid->get_name()}
3333
{/if}
3434
<h4 class="feeditem-title">
35-
<a href="{$feeditemlink|safetext}" {if $modvars.Feeds.openinnewwindow eq 1}target="_blank"{/if}>{$feeditemtitle|safetext}</a>
35+
<a href="{$feeditemlink}" {if $modvars.Feeds.openinnewwindow eq 1}target="_blank"{/if}>{$feeditemtitle|safetext}</a>
3636
</h4>
3737
<span class="feeditem-info" >
3838
{$feeditemdate|dateformat:'%I:%M %p %A, %B %e, %Y'}
@@ -44,7 +44,7 @@
4444
{if $feeditemdescription neq ''}
4545
<div class="feeditem-text">{$feeditemdescription|safehtml}</div>
4646
<span class="feeditem-more">
47-
<a href="{$feeditemlink|safetext}" {if $modvars.Feeds.openinnewwindow eq 1}target="_blank"{/if}>{gt text='Read more'}</a>
47+
<a href="{$feeditemlink}" {if $modvars.Feeds.openinnewwindow eq 1}target="_blank"{/if}>{gt text='Read more'}</a>
4848
</span>
4949
{/if}
5050
</div>

0 commit comments

Comments
 (0)