Skip to content

Commit

Permalink
Pager for user theme gallery added, closes #175.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phaidon authored and Drak committed Apr 29, 2012
1 parent 44e5749 commit 8af6ea4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
20 changes: 17 additions & 3 deletions web/system/ThemeModule/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ public function indexAction()
throw new \Zikula\Framework\Exception\ForbiddenException();
}

// get our input
$startnum = FormUtil::getPassedValue('startnum', isset($args['startnum']) ? $args['startnum'] : 1, 'GET');

// we need this value multiple times, so we keep it
$itemsperpage = $this->getVar('itemsperpage');

// get some use information about our environment
$currenttheme = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme()));

// get all themes in our environment
$themes = ThemeUtil::getAllThemes(ThemeUtil::FILTER_USER);
$allthemes = ThemeUtil::getAllThemes(ThemeUtil::FILTER_USER);

$previewthemes = array();
$currentthemepic = null;
foreach ($themes as $themeinfo) {
foreach ($allthemes as $key => $themeinfo) {
$themename = $themeinfo['name'];
if (file_exists($themepic = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/Resources/public/images/preview_medium.png')) {
$themeinfo['previewImage'] = $themepic;
Expand All @@ -51,19 +57,27 @@ public function indexAction()
$themeinfo['previewImage'] = 'system/Theme/Resources/public/images/preview_medium.png';
$themeinfo['largeImage'] = 'system/Theme/Resources/public/images/preview_large.png';
}
$previewthemes[$themename] = $themeinfo;
if ($themename == $currenttheme['name']) {
$currentthemepic = $themepic;
unset($allthemes[$key]);
} else {
$previewthemes[$themename] = $themeinfo;
}
}

$previewthemes = array_slice($previewthemes, $startnum-1, $itemsperpage);

$this->view->setCaching(Zikula_View::CACHE_DISABLED);

$this->view->assign('currentthemepic', $currentthemepic)
->assign('currenttheme', $currenttheme)
->assign('themes', $previewthemes)
->assign('defaulttheme', ThemeUtil::getInfo(ThemeUtil::getIDFromName(System::getVar('Default_Theme'))));

// assign the values for the pager plugin
$this->view->assign('pager', array('numitems' => sizeof($allthemes),
'itemsperpage' => $itemsperpage));

// Return the output that has been generated by this function
return $this->response($this->view->fetch('theme_user_main.tpl'));
}
Expand Down
4 changes: 2 additions & 2 deletions web/system/ThemeModule/Resources/views/theme_user_main.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<h3>{gt text="Themes list"}</h3>
<div id="themes_list" class="z-clearfix">
{foreach from=$themes item=theme}
{if $theme.name neq $currenttheme.name and $theme.structure}
<dl class="theme_item">
<dt><strong>{$theme.displayname}</strong></dt>
<dt>
Expand All @@ -34,8 +33,9 @@
<dd><a class="z-icon-es-preview" href="{$themeurl|safetext}">{gt text="Preview theme"}</a></dd>
<dd><a class="z-icon-es-ok" href="?newtheme={$theme.name}">{gt text="Use theme"}</a></dd>
</dl>
{/if}
{/foreach}
</div>

<br />{pager rowcount=$pager.numitems limit=$pager.itemsperpage posvar='startnum'}


0 comments on commit 8af6ea4

Please sign in to comment.