本文整理汇总了PHP中SpoonFilter::arraySortKeys方法的典型用法代码示例。如果您正苦于以下问题:PHP SpoonFilter::arraySortKeys方法的具体用法?PHP SpoonFilter::arraySortKeys怎么用?PHP SpoonFilter::arraySortKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpoonFilter
的用法示例。
在下文中一共展示了SpoonFilter::arraySortKeys方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testArraySortKeys
public function testArraySortKeys()
{
// test array
$testArray = array(-2 => 'Davy Hellemans', 1 => 'Tijs Verkoyen', 4 => 'Dave Lens');
// expected result
$expectedArray = array('Davy Hellemans', 'Tijs Verkoyen', 'Dave Lens');
// perform test
$this->assertEquals($expectedArray, SpoonFilter::arraySortKeys($testArray));
}
示例2: getContent
//.........这里部分代码省略.........
$nextURL = str_replace(array('[offset]', '[order]', '[sort]'), array($offset + $numPerPage, $order, $sort), $URL);
$tpl->assign('nextLabel', $nextLabel);
$tpl->assign('nextURL', $nextURL);
}
// limit
$limit = 7;
$breakpoint = 4;
$items = array();
/**
* Less than or 7 pages. We know all the keys, and we put them in the array
* that we will use to generate the actual pagination.
*/
if ($numPages <= $limit) {
for ($i = 1; $i <= $numPages; $i++) {
$items[$i] = $i;
}
} else {
// first page
if ($currentPage == 1) {
// [1] 2 3 4 5 6 7 8 9 10 11 12 13
for ($i = 1; $i <= $limit; $i++) {
$items[$i] = $i;
}
$items[$limit + 1] = '...';
} elseif ($currentPage == $numPages) {
// 1 2 3 4 5 6 7 8 9 10 11 12 [13]
$items[$numPages - $limit - 1] = '...';
for ($i = $numPages - $limit; $i <= $numPages; $i++) {
$items[$i] = $i;
}
} else {
// 1 2 3 [4] 5 6 7 8 9 10 11 12 13
// define min & max
$min = $currentPage - $breakpoint + 1;
$max = $currentPage + $breakpoint - 1;
// minimum doesnt exist
while ($min <= 0) {
$min++;
$max++;
}
// maximum doesnt exist
while ($max > $numPages) {
$min--;
$max--;
}
// create the list
if ($min != 1) {
$items[$min - 1] = '...';
}
for ($i = $min; $i <= $max; $i++) {
$items[$i] = $i;
}
if ($max != $numPages) {
$items[$max + 1] = '...';
}
}
}
// init var
$pages = array();
// loop pages
foreach ($items as $item) {
// counter
if (!isset($i)) {
$i = 0;
}
// base details
$pages[$i]['page'] = false;
$pages[$i]['currentPage'] = false;
$pages[$i]['otherPage'] = false;
$pages[$i]['noPage'] = false;
$pages[$i]['url'] = '';
$pages[$i]['pageNumber'] = $item;
// hellips
if ($item == '...') {
$pages[$i]['noPage'] = true;
} else {
// show page
$pages[$i]['page'] = true;
// current page ?
if ($item == $currentPage) {
$pages[$i]['currentPage'] = true;
} else {
// show the page
$pages[$i]['otherPage'] = true;
// url to this page
$pages[$i]['url'] = str_replace(array('[offset]', '[order]', '[sort]'), array($numPerPage * $item - $numPerPage, $order, $sort), $URL);
}
}
// update counter
$i++;
}
// first key needs to be zero
$pages = SpoonFilter::arraySortKeys($pages);
// assign pages
$tpl->assign('pages', $pages);
// cough it up
ob_start();
$tpl->display(dirname(__FILE__) . '/paging.tpl');
return ob_get_clean();
}
示例3: clear
/**
* Clear all (or a specific) elements in the breadcrumb
*
* @return void
* @param int[optional] $key If the key is provided it will be removed from the array, otherwise the whole array will be cleared.
*/
public function clear($key = null)
{
// key given?
if ($key !== null) {
// remove specific key
unset($this->items[(int) $key]);
// resort, to avoid shit when parsing
$this->items = SpoonFilter::arraySortKeys($this->items);
} else {
$this->items = array();
}
}
示例4: getColumnsSequence
/**
* Retrieve the columns sequence.
*
* @return array
*/
private function getColumnsSequence()
{
// init var
$columns = array();
// loop all the columns
foreach ($this->columns as $column) {
$columns[$column->getSequence()] = $column->getName();
}
// reindex
return !empty($columns) ? SpoonFilter::arraySortKeys($columns) : $columns;
}
示例5: getExtrasData
/**
* Get all the available extra's
*
* @return array
*/
public static function getExtrasData()
{
// get all extras
$extras = (array) BackendModel::getDB()->getRecords('SELECT i.id, i.module, i.type, i.label, i.data
FROM modules_extras AS i
INNER JOIN modules AS m ON i.module = m.name
WHERE i.hidden = ?
ORDER BY i.module, i.sequence', array('N'));
// build array
$values = array();
// init var
$itemsToRemove = array();
// loop extras
foreach ($extras as $id => $row) {
// unserialize data
$row['data'] = @unserialize($row['data']);
// remove items that are not for the current language
if (isset($row['data']['language']) && $row['data']['language'] != BackendLanguage::getWorkingLanguage()) {
continue;
}
// set URL if needed
if (!isset($row['data']['url'])) {
$row['data']['url'] = BackendModel::createURLForAction('index', $row['module']);
}
// build name
$name = SpoonFilter::ucfirst(BL::lbl($row['label']));
if (isset($row['data']['extra_label'])) {
$name = $row['data']['extra_label'];
}
if (isset($row['data']['label_variables'])) {
$name = vsprintf($name, $row['data']['label_variables']);
}
// create modulename
$moduleName = SpoonFilter::ucfirst(BL::lbl(SpoonFilter::toCamelCase($row['module'])));
// build array
if (!isset($values[$row['module']])) {
$values[$row['module']] = array('value' => $row['module'], 'name' => $moduleName, 'items' => array());
}
// add real extra
$values[$row['module']]['items'][$row['type']][$name] = array('id' => $row['id'], 'label' => $name);
}
// loop
foreach ($values as &$row) {
if (!empty($row['items']['widget'])) {
$row['items']['widget'] = SpoonFilter::arraySortKeys($row['items']['widget']);
}
if (!empty($row['items']['block'])) {
$row['items']['block'] = SpoonFilter::arraySortKeys($row['items']['block']);
}
}
return $values;
}