Commit d9d1cd84 authored by Robert Lyon's avatar Robert Lyon

Bug 1515484: Fix the site fonts pagination to use json

This is one of 6 patches to standardize pagination

To help test this there is a zip file in Bug 1515774

behatnotneeded

Change-Id: I278ae35cdbe83929cd8eca2b28d1191cab5c3ea6
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 49c2f8ce
<?php
/**
*
* @package mahara
* @subpackage skin
* @author Gregor Anzelj
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
* @copyright (C) 2010-2013 Gregor Anzelj <gregor.anzelj@gmail.com>
*
*/
define('INTERNAL', 1);
define('ADMIN', 1);
define('JSON', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once(get_config('libroot') . 'skin.php');
require_once('pieforms/pieform.php');
if (!get_config('skins')) {
json_reply('local', get_string('accessdenied', 'error'));
}
$fontpreview = !is_null($SESSION->get('fontpreview')) ? $SESSION->get('fontpreview') : 21;
$fontsize = !is_null($SESSION->get('fontsize')) ? $SESSION->get('fontsize') : 28;
$fonttype = !is_null($SESSION->get('fonttype')) ? $SESSION->get('fonttype') : 'all'; // possible values: all, site, google
$setlimit = param_boolean('setlimit', false);
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$query = param_integer('query', null);
$data = Skin::get_sitefonts_data($limit, $offset, $fonttype);
$sitefonts = '';
$googlefonts = '';
foreach ($data->data as $font) {
if ($font['fonttype'] == 'site') {
$sitefonts .= $font['title'] . '|';
}
if ($font['fonttype'] == 'google') {
$googlefonts .= urlencode($font['title']) . '|';
}
}
$sitefonts = rtrim($sitefonts, '|');
$googlefonts = rtrim($googlefonts, '|');
$pagination = build_pagination(array(
'url' => get_config('wwwroot') . 'admin/site/fonts.php',
'count' => $data->count,
'limit' => $limit,
'offset' => $offset,
'setlimit' => true,
'datatable' => 'fontlist',
'jsonscript' => 'admin/site/fonts.json.php',
'resultcounttextsingular' => get_string('font', 'skin'),
'resultcounttextplural' => get_string('fonts', 'skin')
));
$smarty = smarty_core();
$smarty->assign('query', $query);
$smarty->assign('sitefonts', $data->data);
$smarty->assign('preview', $fontpreview); // Transfer $SESSION value into template
$smarty->assign('size', $fontsize); // Transfer $SESSION value into template
$html = $smarty->fetch('skin/sitefontresults.tpl');
json_reply(false, array(
'message' => null,
'data' => array(
'tablerows' => $html,
'pagination' => $pagination['html'],
'pagination_js' => $pagination['javascript'],
'count' => $data->count,
'results' => $data->count . ' ' . ($data->count == 1 ? get_string('result') : get_string('results')),
'offset' => $offset,
'setlimit' => $setlimit,
)
));
\ No newline at end of file
......@@ -132,6 +132,8 @@ $pagination = build_pagination(array(
'limit' => $limit,
'offset' => $offset,
'setlimit' => true,
'datatable' => 'fontlist',
'jsonscript' => 'admin/site/fonts.json.php',
'resultcounttextsingular' => get_string('font', 'skin'),
'resultcounttextplural' => get_string('fonts', 'skin')
));
......@@ -162,10 +164,13 @@ $smarty = smarty(array('paginator'), $css, array(), array());
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('query', $query);
$smarty->assign('sitefonts', $data->data);
$smarty->assign('form', $previewform);
$smarty->assign('preview', $fontpreview); // Transfer $SESSION value into template
$smarty->assign('size', $fontsize); // Transfer $SESSION value into template
$html = $smarty->fetch('skin/sitefontresults.tpl');
$smarty->assign('sitefontshtml', $html);
$smarty->assign('form', $previewform);
$smarty->assign('pagination', $pagination['html']);
$smarty->assign('pagination_js', $pagination['javascript']);
$smarty->assign('PAGEHEADING', hsc(TITLE));
$smarty->display('skin/sitefonts.tpl');
......
{foreach from=$sitefonts item=font}
<div class="{cycle values='r0,r1'} listrow list-group-item">
<div class="col-md-10" style="font-family:'{$font.title|escape_css_string}';font-size:{$size}pt;line-height:{$size}pt;padding:3px 0;">
<h2 class="title">{$font.title}</h2>
{if $preview == 10}
{$font.title}
{/if}
{if $preview >= 11}
{str tag="sampletext$preview" section="skin"}
{/if}
</div>
<ul class="actionlist col-md-2">
<li class="notbtn">
<strong>{str tag="fonttype.$font.fonttype" section="skin"}</strong>
</li>
{if $font.fonttype == 'google'}
<li>
<a class="btn-display" href="javascript:" onclick="window.open('http://www.google.com/webfonts/specimen/{$font.urlencode}','specimen','width=700,height=800,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=no')">
{str tag="viewfontspecimen" section="skin"}
<span class="accessible-hidden sr-only">
{str tag=viewfontspecimenfor section=skin arg1=$font.title}
</span>
</a>
</li>
{else}
<li>
<a class="btn-display" href="javascript:" onclick="window.open('{$WWWROOT}admin/site/font/specimen.php?font={$font.name}','specimen','width=700,height=800,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=no')">
{str tag="viewfontspecimen" section="skin"}
<span class="accessible-hidden sr-only">
{str tag=viewfontspecimenfor section=skin arg1=$font.title}
</span>
</a>
</li>
{/if}
{if $font.fonttype == 'site'}
<li>
<a class="btn-edit" href="{$WWWROOT}admin/site/font/edit.php?font={$font.name}">
{str tag="editproperties" section="skin"}
<span class="accessible-hidden sr-only">
{str tag=viewfontspecimenfor section=skin arg1=$font.title}
</span>
</a>
</li>
{/if}
{if $font.fonttype == 'site'}
<li>
<a class="btn-add" href="{$WWWROOT}admin/site/font/add.php?font={$font.name}">
{str tag="addfontvariant" section="skin"}
<span class="accessible-hidden sr-only">
{str tag=viewfontspecimenfor section=skin arg1=$font.title}
</span>
</a>
</li>
{/if}
<li>
<a class="btn-del" href="{$WWWROOT}admin/site/font/delete.php?font={$font.name}">
{str tag=deletefont section=skin}
<span class="accessible-hidden sr-only">
{$font.title}
</span>
</a>
</li>
</ul>
<div class="clearfix"></div>
</div>
{/foreach}
\ No newline at end of file
......@@ -15,73 +15,7 @@
<h2 id="searchresultsheading" class="accessible-hidden sr-only">{str tag=Results}</h2>
{/if}
<div id="fontlist" class="panel-default fullwidth listing">
{foreach from=$sitefonts item=font}
<div class="{cycle values='r0,r1'} listrow list-group-item">
<div class="col-md-10" style="font-family:'{$font.title|escape_css_string}';font-size:{$size}pt;line-height:{$size}pt;padding:3px 0;">
<h2 class="title">{$font.title}</h2>
{if $preview == 10}
{$font.title}
{/if}
{if $preview >= 11}
{str tag="sampletext$preview" section="skin"}
{/if}
</div>
<ul class="actionlist col-md-2">
<li class="notbtn">
<strong>{str tag="fonttype.$font.fonttype" section="skin"}</strong>
</li>
{if $font.fonttype == 'google'}
<li>
<a class="btn-display" href="javascript:" onclick="window.open('http://www.google.com/webfonts/specimen/{$font.urlencode}','specimen','width=700,height=800,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=no')">
{str tag="viewfontspecimen" section="skin"}
<span class="accessible-hidden sr-only">
{str tag=viewfontspecimenfor section=skin arg1=$font.title}
</span>
</a>
</li>
{else}
<li>
<a class="btn-display" href="javascript:" onclick="window.open('{$WWWROOT}admin/site/font/specimen.php?font={$font.name}','specimen','width=700,height=800,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=no')">
{str tag="viewfontspecimen" section="skin"}
<span class="accessible-hidden sr-only">
{str tag=viewfontspecimenfor section=skin arg1=$font.title}
</span>
</a>
</li>
{/if}
{if $font.fonttype == 'site'}
<li>
<a class="btn-edit" href="{$WWWROOT}admin/site/font/edit.php?font={$font.name}">
{str tag="editproperties" section="skin"}
<span class="accessible-hidden sr-only">
{str tag=viewfontspecimenfor section=skin arg1=$font.title}
</span>
</a>
</li>
{/if}
{if $font.fonttype == 'site'}
<li>
<a class="btn-add" href="{$WWWROOT}admin/site/font/add.php?font={$font.name}">
{str tag="addfontvariant" section="skin"}
<span class="accessible-hidden sr-only">
{str tag=viewfontspecimenfor section=skin arg1=$font.title}
</span>
</a>
</li>
{/if}
<li>
<a class="btn-del" href="{$WWWROOT}admin/site/font/delete.php?font={$font.name}">
{str tag=deletefont section=skin}
<span class="accessible-hidden sr-only">
{$font.title}
</span>
</a>
</li>
</ul>
<div class="clearfix"></div>
</div>
{/foreach}
{$sitefontshtml|safe}
</div>
{else}
<p class="no-results">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment