本文整理汇总了PHP中sortMultiArray函数的典型用法代码示例。如果您正苦于以下问题:PHP sortMultiArray函数的具体用法?PHP sortMultiArray怎么用?PHP sortMultiArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sortMultiArray函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
$admins = $_zp_authority->getAdministrators('all');
foreach ($admins as $key => $user) {
if ($user['valid'] && !($user['rights'] & ADMIN_RIGHTS)) {
if ($subscription) {
$admins[$key]['expires'] = strtotime($user['date']) + $subscription;
} else {
$admins[$key]['expires'] = 0;
}
} else {
unset($admins[$key]);
}
}
if ($subscription) {
$admins = sortMultiArray($admins, array('expires'), false);
} else {
$admins = sortMultiArray($admins, array('lastlogon'), true);
}
$adminordered = array();
foreach ($admins as $user) {
$adminordered[] = $user;
}
$msg = NULL;
if (isset($_GET['action'])) {
$action = sanitize($_GET['action']);
XSRFdefender($action);
if ($action == 'expiry') {
foreach ($_POST as $key => $action) {
if (strpos($key, 'r_') === 0) {
$userobj = $_zp_authority->getAnAdmin(array('`id`=' => sanitize(postIndexDecode(str_replace('r_', '', $key)))));
if ($userobj) {
switch ($action) {
示例2: getitems
/**
* Gets the feed items
*
* @return array
*/
public function getitems()
{
global $_zp_CMS;
switch ($this->feedtype) {
case 'gallery':
if ($this->mode == "albums") {
$items = getAlbumStatistic($this->itemnumber, $this->sortorder, $this->albumfolder, 0, $this->sortdirection);
} else {
$items = getImageStatistic($this->itemnumber, $this->sortorder, $this->albumfolder, $this->collection, 0, $this->sortdirection);
}
break;
case 'news':
switch ($this->newsoption) {
case "category":
if ($this->sortorder) {
$items = getZenpageStatistic($this->itemnumber, 'categories', $this->sortorder, $this->sortdirection);
} else {
$items = getLatestNews($this->itemnumber, $this->catlink, false, $this->sortdirection);
}
break;
default:
case "news":
if ($this->sortorder) {
$items = getZenpageStatistic($this->itemnumber, 'news', $this->sortorder, $this->sortdirection);
} else {
// Needed baceause type variable "news" is used by the feed item method and not set by the class method getArticles!
$items = getLatestNews($this->itemnumber, '', false, $this->sortdirection);
}
break;
}
break;
case "pages":
if ($this->sortorder) {
$items = getZenpageStatistic($this->itemnumber, 'pages', $this->sortorder, $this->sortdirection);
} else {
$items = $_zp_CMS->getPages(NULL, false, $this->itemnumber);
}
break;
case 'comments':
switch ($type = $this->commentfeedtype) {
case 'gallery':
$items = getLatestComments($this->itemnumber, 'all');
break;
case 'album':
$items = getLatestComments($this->itemnumber, 'album', $this->id);
break;
case 'image':
$items = getLatestComments($this->itemnumber, 'image', $this->id);
break;
case 'zenpage':
$type = 'all';
case 'news':
case 'page':
if (function_exists('getLatestZenpageComments')) {
$items = getLatestZenpageComments($this->itemnumber, $type, $this->id);
}
break;
case 'allcomments':
$items = getLatestComments($this->itemnumber, 'all');
$items_zenpage = array();
if (function_exists('getLatestZenpageComments')) {
$items_zenpage = getLatestZenpageComments($this->itemnumber, 'all', $this->id);
$items = array_merge($items, $items_zenpage);
$items = sortMultiArray($items, 'date', true);
$items = array_slice($items, 0, $this->itemnumber);
}
break;
}
break;
}
if (isset($items)) {
return $items;
}
if (TEST_RELEASE) {
zp_error(gettext('Bad ' . $this->feed . ' feed:' . $this->feedtype), E_USER_WARNING);
}
return NULL;
}
示例3: getZenpageStatistic
/**
* Gets the statistic for pages, news articles or categories as an unordered list
*
* @param int $number The number of news items to get
* @param string $option "all" pages, articles and categories
* "news" for news articles
* "categories" for news categories
* "pages" for pages
* @param string $mode "popular" most viewed for pages, news articles and categories
* "mostrated" for news articles and pages
* "toprated" for news articles and pages
* "random" for pages and news articles
* @param string $sortdirection "asc" for ascending otherwise descending (default)
* @return array
*/
function getZenpageStatistic($number = 10, $option = "all", $mode = "popular", $sortdirection = 'desc')
{
global $_zp_zenpage, $_zp_current_zenpage_news, $_zp_current_zenpage_pages;
$sortdir = strtolower($sortdirection) != 'asc';
$statsarticles = array();
$statscats = array();
$statspages = array();
if ($option == "all" || $option == "news") {
$articles = $_zp_zenpage->getArticles($number, NULL, true, $mode, $sortdir, false);
$counter = "";
$statsarticles = array();
foreach ($articles as $article) {
$counter++;
$obj = new ZenpageNews($article['titlelink']);
$statsarticles[$counter] = array("id" => $obj->getID(), "title" => $obj->getTitle(), "titlelink" => $article['titlelink'], "hitcounter" => $obj->getHitcounter(), "total_votes" => $obj->getTotal_votes(), "rating" => $obj->getRating(), "content" => $obj->getContent(), "date" => $obj->getDateTime(), "type" => "News");
}
$stats = $statsarticles;
}
if (($option == "all" || $option == "categories") && $mode != "mostrated" && $mode != "toprated") {
$categories = $_zp_zenpage->getAllCategories(true, $mode, $sortdir);
$counter = "";
$statscats = array();
foreach ($categories as $cat) {
$counter++;
$statscats[$counter] = array("id" => $cat['id'], "title" => html_encode(get_language_string($cat['title'])), "titlelink" => getNewsCategoryURL($cat['titlelink']), "hitcounter" => $cat['hitcounter'], "total_votes" => "", "rating" => "", "content" => '', "date" => '', "type" => "Category");
}
$stats = $statscats;
}
if ($option == "all" || $option == "pages") {
$pages = $_zp_zenpage->getPages(NULL, false, $number, $mode, $sortdir);
$counter = "";
$statspages = array();
foreach ($pages as $page) {
$counter++;
$pageobj = new ZenpagePage($page['titlelink']);
$statspages[$counter] = array("id" => $pageobj->getID(), "title" => $pageobj->getTitle(), "titlelink" => $page['titlelink'], "hitcounter" => $pageobj->getHitcounter(), "total_votes" => $pageobj->get('total_votes'), "rating" => $pageobj->get('rating'), "content" => $pageobj->getContent(), "date" => $pageobj->getDateTime(), "type" => "Page");
}
$stats = $statspages;
}
if ($option == "all") {
$stats = array_merge($statsarticles, $statscats, $statspages);
if ($mode == 'random') {
shuffle($stats);
} else {
switch ($sortdir) {
case 'asc':
$desc = false;
break;
case 'desc':
$desc = true;
break;
}
$stats = sortMultiArray($stats, $mode, $desc);
}
}
return $stats;
}
示例4: getOldCombiNews
//.........这里部分代码省略.........
case 'publishdate':
$imagequery = "(SELECT albums.folder, images.filename, IFNULL(images.publishdate,images.date), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
case 'mtime':
$imagequery = "(SELECT albums.folder, images.filename, FROM_UNIXTIME(images.mtime), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
break;
}
$result = $this->siftResults("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date " . $sortdir, $offset, $articles_per_page);
break;
case "latestalbums-thumbnail":
case "latestalbums-thumbnail-customcrop":
case "latestalbums-sizedimage":
case "latestalbums-sizedimage-maxspace":
case "latestalbums-fullimage":
default:
if (empty($show)) {
$albumWhere = ' WHERE ' . $albumWhere;
} else {
$albumWhere = ' AND ' . $albumWhere;
}
$sortorder = $combinews_sortorder;
$type1 = query("SET @type1:='news'");
$type2 = query("SET @type2:='albums'");
switch ($combinews_sortorder) {
case 'id':
case 'date':
$albumquery = "(SELECT albums.folder, albums.title, albums.date, @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
break;
case 'publishdate':
$albumquery = "(SELECT albums.folder, albums.title, IFNULL(albums.publishdate,albums.date), @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
break;
case 'mtime':
default:
$albumquery = "(SELECT albums.folder, albums.title, FROM_UNIXTIME(albums.mtime), @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
break;
}
$result = $this->siftResults("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $albumquery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date " . $sortdir, $offset, $articles_per_page);
break;
case "latestimagesbyalbum-thumbnail":
case "latestimagesbyalbum-thumbnail-customcrop":
case "latestimagesbyalbum-sizedimage":
case "latestimagesbyalbum-sizedimage-maxspace":
case "latestimagesbyalbum-fullimage":
$albumWhere = ' AND ' . $albumWhere;
$type1 = query("SET @type1:='news'");
$type2 = query("SET @type2:='albums'");
if (empty($combinews_sortorder) || $combinews_sortorder != "date" || $combinews_sortorder != "mtime" || $combinews_sortorder != "publishdate") {
$combinews_sortorder = "date";
}
$sortorder = "images." . $combinews_sortorder;
switch ($combinews_sortorder) {
case "date":
$imagequery = "(SELECT DISTINCT DATE_FORMAT(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.date,'%Y-%m-%d'), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
break;
case "mtime":
$imagequery = "(SELECT DISTINCT FROM_UNIXTIME(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.mtime,'%Y-%m-%d'), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
case "publishdate":
$imagequery = "(SELECT DISTINCT FROM_UNIXTIME(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.publishdate,'%Y-%m-%d'), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
break;
}
$result = $this->siftResults("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER By {$stickyorder} date " . $sortdir, $offset, $articles_per_page);
break;
case "latestupdatedalbums-thumbnail":
case "latestupdatedalbums-thumbnail-customcrop":
case "latestupdatedalbums-sizedimage":
case "latestupdatedalbums-sizedimage-maxspace":
case "latestupdatedalbums-fullimage":
$latest = $this->getArticles($articles_per_page, NULL, true, 'date', $sortdirection);
$counter = '';
foreach ($latest as $news) {
$article = new Article($news['titlelink']);
if ($article->checkAccess()) {
$counter++;
$latestnews[$counter] = array("albumname" => $article->getTitle(), "titlelink" => $article->getTitlelink(), "date" => $article->getDateTime(), "type" => "news");
}
}
$albums = getAlbumStatistic($articles_per_page, "latestupdated", false, 0, $sortdirection);
$latestalbums = array();
$counter = "";
foreach ($albums as $tempalbum) {
$counter++;
$tempalbumthumb = $tempalbum->getAlbumThumbImage();
$timestamp = $tempalbum->get('mtime');
if ($timestamp == 0) {
$albumdate = $tempalbum->getDateTime();
} else {
$albumdate = strftime('%Y-%m-%d %H:%M:%S', $timestamp);
}
$latestalbums[$counter] = array("albumname" => $tempalbum->getFileName(), "titlelink" => $tempalbum->getTitle(), "date" => $albumdate, "type" => 'albums');
}
//$latestalbums = array_merge($latestalbums, $item);
$latest = array_merge($latestnews, $latestalbums);
$result = sortMultiArray($latest, "date", $sortdirection != 'asc');
if (count($result) > $articles_per_page) {
$result = array_slice($result, 0, $articles_per_page);
}
break;
}
$_zp_combiNews_cache[$published . $mode . $sticky . $sortorder . $sortdirection] = $result;
return $result;
}
示例5: sortByKey
/**
* sorts the found albums (images) by the required key(s)
*
* NB: this sort is sensitive to the key(s) chosen and makes
* the appropriate sorts based on same. Some multi-key sorts
* will not make any sense and will give unexpected results.
* Most notably any that contain the keys "title" or "desc"
* as these require multi-lingual sorts.
*
* @param array $results
* @param string $sortkey
* @param string $order
*/
function sortByKey($results, $sortkey, $order)
{
$sortkey = str_replace('`', '', $sortkey);
switch ($sortkey) {
case 'title':
case 'desc':
return sortByMultilingual($results, $sortkey, $order);
case 'RAND()':
shuffle($results);
return $results;
default:
if (preg_match('`[\\/\\(\\)\\*\\+\\-!\\^\\%\\<\\>\\=\\&\\|]`', $sortkey)) {
return $results;
// We cannot deal with expressions
}
}
$indicies = explode(',', $sortkey);
foreach ($indicies as $key => $index) {
$indicies[$key] = trim($index);
}
$results = sortMultiArray($results, $indicies, $order, true, false, true);
return $results;
}
示例6: file_get_contents
$button_enable = true;
$button_XSRFTag = '';
$utilityStream = file_get_contents($utility);
eval(isolate('$button_text', $utilityStream));
eval(isolate('$button_hint', $utilityStream));
eval(isolate('$button_icon', $utilityStream));
eval(isolate('$button_rights', $utilityStream));
eval(isolate('$button_alt', $utilityStream));
eval(isolate('$button_hidden', $utilityStream));
eval(isolate('$button_action', $utilityStream));
eval(isolate('$button_enable', $utilityStream));
eval(isolate('$button_XSRFTag', $utilityStream));
$buttonlist[] = array('XSRFTag' => $button_XSRFTag, 'enable' => $button_enable, 'button_text' => $button_text, 'formname' => $utility, 'action' => $button_action, 'icon' => $button_icon, 'title' => $button_hint, 'alt' => $button_alt, 'hidden' => $button_hidden, 'rights' => $button_rights | ADMIN_RIGHTS);
}
$buttonlist = zp_apply_filter('admin_utilities_buttons', $buttonlist);
$buttonlist = sortMultiArray($buttonlist, 'button_text', false);
$count = 0;
foreach ($buttonlist as $key => $button) {
if (zp_loggedin($button['rights'])) {
$count++;
} else {
unset($buttonlist[$key]);
}
}
$count = round($count / 2);
?>
<div class="box" id="overview-utility">
<h2 class="h2_bordered"><?php
echo gettext("Utility functions");
?>
</h2>
示例7: getCombiNews
//.........这里部分代码省略.........
$stickyorder = '';
if ($sticky) {
$stickyorder = 'sticky DESC,';
}
$type3 = query("SET @type3:='0'");
switch ($mode) {
case "latestimages-thumbnail":
case "latestimages-thumbnail-customcrop":
case "latestimages-sizedimage":
$sortorder = "images." . $combinews_sortorder;
$type1 = query("SET @type1:='news'");
$type2 = query("SET @type2:='images'");
switch ($combinews_sortorder) {
case 'id':
case 'date':
$imagequery = "(SELECT albums.folder, images.filename, images.date, @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
break;
case 'mtime':
$imagequery = "(SELECT albums.folder, images.filename, FROM_UNIXTIME(images.mtime), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
break;
}
$result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
break;
case "latestalbums-thumbnail":
case "latestalbums-thumbnail-customcrop":
case "latestalbums-sizedimage":
$sortorder = $combinews_sortorder;
$type1 = query("SET @type1:='news'");
$type2 = query("SET @type2:='albums'");
switch ($combinews_sortorder) {
case 'id':
case 'date':
$albumquery = "(SELECT albums.folder, albums.title, albums.date, @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
break;
case 'mtime':
$albumquery = "(SELECT albums.folder, albums.title, FROM_UNIXTIME(albums.mtime), @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
break;
}
$result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $albumquery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
break;
case "latestimagesbyalbum-thumbnail":
case "latestimagesbyalbum-thumbnail-customcrop":
case "latestimagesbyalbum-sizedimage":
$type1 = query("SET @type1:='news'");
$type2 = query("SET @type2:='albums'");
if (empty($combinews_sortorder) || $combinews_sortorder != "date" || $combinews_sortorder != "mtime") {
$combinews_sortorder = "date";
}
$combinews_sortorder = "date";
$sortorder = "images." . $combinews_sortorder;
switch ($combinews_sortorder) {
case "date":
$imagequery = "(SELECT DISTINCT DATE_FORMAT(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.`date`,'%Y-%m-%d'), @type2 FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
break;
case "mtime":
$imagequery = "(SELECT DISTINCT FROM_UNIXTIME(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.`mtime`,'%Y-%m-%d'), @type2 FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
break;
}
$result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER By date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
//echo "<pre>"; print_r($result); echo "</pre>";
//$result = "";
break;
case "latestupdatedalbums-thumbnail":
case "latestupdatedalbums-thumbnail-customcrop":
case "latestupdatedalbums-sizedimage":
$latest = getNewsArticles($articles_per_page, '', NULL, true);
$counter = '';
foreach ($latest as $news) {
$article = new ZenpageNews($news['titlelink']);
if ($article->checkAccess($hint, $show)) {
$counter++;
$latestnews[$counter] = array("albumname" => $article->getTitle(), "titlelink" => $article->getTitlelink(), "date" => $article->getDateTime(), "type" => "news");
}
}
$albums = getAlbumStatistic($articles_per_page, "latestupdated");
$latestalbums = array();
$counter = "";
foreach ($albums as $album) {
$counter++;
$tempalbum = new Album($_zp_gallery, $album['folder']);
$tempalbumthumb = $tempalbum->getAlbumThumbImage();
$timestamp = $tempalbum->get('mtime');
if ($timestamp == 0) {
$albumdate = $tempalbum->getDateTime();
} else {
$albumdate = strftime('%Y-%m-%d %H:%M:%S', $timestamp);
}
$latestalbums[$counter] = array("albumname" => $tempalbum->getFolder(), "titlelink" => $tempalbum->getTitle(), "date" => $albumdate, "type" => 'albums');
}
//$latestalbums = array_merge($latestalbums, $item);
$latest = array_merge($latestnews, $latestalbums);
$result = sortMultiArray($latest, "date", true);
if (count($result) > $articles_per_page) {
$result = array_slice($result, 0, 10);
}
break;
}
//$result = "";
return $result;
}
示例8: groupList
static function groupList($userobj, $i, $background, $current, $template)
{
global $_zp_authority, $_zp_zenpage, $_zp_gallery;
$group = $userobj->getGroup();
$admins = $_zp_authority->getAdministrators('groups');
$groups = array();
$hisgroups = explode(',', $userobj->getGroup());
$admins = sortMultiArray($admins, 'user');
foreach ($admins as $user) {
if ($template || $user['name'] != 'template') {
$groups[] = $user;
}
}
if (empty($groups)) {
return gettext('no groups established');
}
// no groups setup yet
$grouppart = '
<script type="text/javascript">
// <!-- <![CDATA[
function groupchange' . $i . '(type) {
switch (type) {
case 0: // none
$(\'.user-' . $i . '\').prop(\'disabled\',false);
$(\'.templatelist' . $i . '\').prop(\'checked\',false);
$(\'.grouplist' . $i . '\').prop(\'checked\',false);
break;
case 1: // group
$(\'.user-' . $i . '\').prop(\'disabled\',true);
$(\'.user-' . $i . '\').prop(\'checked\',false);
$(\'#noGroup_' . $i . '\').prop(\'checked\',false);
$(\'.templatelist' . $i . '\').prop(\'checked\',false);
break;
case 2: // template
$(\'.user-' . $i . '\').prop(\'disabled\',false);
$(\'#noGroup_' . $i . '\').prop(\'checked\',false);
$(\'.grouplist' . $i . '\').prop(\'checked\',false);
break;
}
}
//]]> -->
</script>' . "\n";
$grouppart .= '<ul class="customchecklist">' . "\n";
$grouppart .= '<label title="' . gettext('*no group affiliation') . '"><input type="checkbox" id="noGroup_' . $i . '" name="' . $i . 'group[]" value="" onclick="groupchange' . $i . '(0);" />' . gettext('*no group selected') . '</label>' . "\n";
foreach ($groups as $key => $user) {
if ($user['name'] == 'template') {
$type = gettext(' (Template)');
$highlight = ' class="grouphighlight"';
$class = 'templatelist' . $i;
$case = 2;
} else {
$type = $highlight = '';
$class = 'grouplist' . $i;
$case = 1;
}
if (in_array($user['user'], $hisgroups)) {
$checked = ' checked="checked"';
} else {
$checked = '';
}
$grouppart .= '<label title="' . html_encode($user['custom_data']) . $type . '"' . $highlight . '><input type="checkbox" class="' . $class . '" name="' . $i . 'group[]" value="' . $user['user'] . '" onclick="groupchange' . $i . '(' . $case . ');"' . $checked . ' />' . html_encode($user['user']) . '</label>' . "\n";
}
$grouppart .= "</ul>\n";
return $grouppart;
}
示例9: exifvars
/**
* initializes the $_zp_exifvars array display state
*
* @author Stephen Billard
* @Copyright 2015 by Stephen L Billard for use in {@link https://github.com/ZenPhoto20/ZenPhoto20 ZenPhoto20}
*/
static function exifvars($default = false)
{
global $_zp_images_classes;
/*
* Note: If fields are added or deleted, setup should be run or the new data won't be stored
* (but existing fields will still work; nothing breaks).
*
* This array should be ordered by logical associations as it will be the order that EXIF information
* is displayed
*/
$exifvars = array();
$handlers = array_unique($_zp_images_classes);
$handlers[] = 'xmpMetadata';
foreach ($handlers as $handler) {
if (class_exists($handler)) {
$exifvars = array_merge($exifvars, $handler::getMetadataFields());
}
}
$exifvars = sortMultiArray($exifvars, 2, false, true, false, true);
if ($default) {
return $exifvars;
}
foreach ($exifvars as $key => $item) {
if (!is_null($disable = getOption($key . '-disabled'))) {
$exifvars[$key][5] = !($disable & true);
}
if (!is_null($display = getOption($key . '-display'))) {
$exifvars[$key][3] = $display;
}
}
return $exifvars;
}
示例10: getRelatedItems
function getRelatedItems($type = 'news', $album = NULL)
{
global $_zp_gallery, $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_page, $_zp_current_zenpage_news, $_zp_gallery_page;
$tags = getTags();
if (!empty($tags)) {
// if there are tags at all
$searchstring = '';
$count = '';
foreach ($tags as $tag) {
$count++;
if ($count == 1) {
$bool = '';
} else {
$bool = '|';
// connect tags by OR to get a wide range
}
$searchstring .= $bool . $tag;
}
$paramstr = urlencode('words') . '=' . $searchstring . '&searchfields=tags';
if (!is_null($album)) {
$paramstr = '&albumname=' . urlencode($album);
}
$search = new SearchEngine();
switch ($type) {
case 'albums':
$paramstr .= '&inalbums=1';
break;
case 'images':
$paramstr .= '&inimages=1';
break;
case 'news':
$paramstr .= '&innews=1';
break;
case 'pages':
$paramstr .= '&inpages=1';
break;
case 'all':
$paramstr .= '&inalbums=1&inimages=1&innews=1&inpages=1';
break;
}
$search->setSearchParams($paramstr);
// get the results
switch ($type) {
case 'albums':
$albumresult = $search->getAlbums(0, "date", "desc");
$result = createRelatedItemsResultArray($albumresult, $type);
break;
case 'images':
$imageresult = $search->getImages(0, 0, 'date', 'desc');
$result = createRelatedItemsResultArray($imageresult, $type);
break;
case 'news':
$newsresult = $search->getArticles(0, NULL, true, "date", "desc");
$result = createRelatedItemsResultArray($newsresult, $type);
break;
case 'pages':
$pageresult = $search->getPages();
$result = createRelatedItemsResultArray($pageresult, $type);
break;
case 'all':
$albumresult = $search->getAlbums(0, "date", "desc");
$imageresult = $search->getImages(0, 0, 'date', 'desc');
$newsresult = $search->getArticles(0, NULL, true, "date", "desc");
$pageresult = $search->getPages();
$result1 = createRelatedItemsResultArray($albumresult, 'albums');
$result2 = createRelatedItemsResultArray($imageresult, 'images');
$result3 = createRelatedItemsResultArray($newsresult, 'news');
$result4 = createRelatedItemsResultArray($pageresult, 'pages');
$result = array_merge($result1, $result2, $result3, $result4);
$result = sortMultiArray($result, 'weight', true, true, false, false);
// sort by search result weight
break;
}
return $result;
}
return array();
}
示例11: header
if (!zp_apply_filter('admin_managed_albums_access', false, $return)) {
header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php');
exitZP();
}
}
} else {
$object = '<em>' . gettext('Gallery') . '</em>';
$zenphoto_tabs['overview']['subtabs'] = array(gettext('Cache images') => PLUGIN_FOLDER . '/cacheManager/cacheImages.php?page = overview&tab=images', gettext('Cache stored images') => PLUGIN_FOLDER . '/cacheManager/cacheDBImages.php?page=overview&tab=DB&XSRFToken=' . getXSRFToken('cacheDBImages'));
}
$custom = array();
$result = query('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `type` = "cacheManager" ORDER BY `aux`');
while ($row = db_fetch_assoc($result)) {
$row = getSerializedArray($row['data']);
$custom[] = $row;
}
$custom = sortMultiArray($custom, array('theme', 'thumb', 'image_size', 'image_width', 'image_height'));
if (isset($_GET['select'])) {
XSRFdefender('cacheImages');
$enabled = @$_POST['enable'];
} else {
$enabled = false;
}
printAdminHeader('overview', 'images');
echo "\n</head>";
echo "\n<body>";
printLogoAndLinks();
echo "\n" . '<div id = "main">';
printTabs();
echo "\n" . '<div id = "content">';
printSubtabs();
?>
示例12: printBarGraph
//.........这里部分代码省略.........
break;
case "images":
$itemssorted = query_full_array($dbquery . " ORDER BY id DESC LIMIT " . $limit);
$barsize = 0;
$maxvalue = 1;
$headline = $typename . " - " . gettext("latest");
break;
}
break;
case "latestupdated":
// part taken from the image_albums_statistics - could probably be optimized regarding queries...
// get all albums
$allalbums = query_full_array("SELECT id, title, folder, `show` FROM " . prefix('albums'));
$albums = array();
$latestimages = array();
foreach ($allalbums as $album) {
$albumobj = new Album($gallery, $album['folder']);
$albumentry = array("id" => $albumobj->get('id'), "title" => $albumobj->getTitle(), "folder" => $albumobj->name, "imagenumber" => $albumobj->getNumImages(), "show" => $albumobj->get("show"));
array_unshift($albums, $albumentry);
}
// get latest images of each album
$count = 0;
foreach ($albums as $album) {
$count++;
$image = query_single_row("SELECT id, albumid, mtime FROM " . prefix('images') . " WHERE albumid = " . $album['id'] . " ORDER BY id DESC LIMIT 1");
if (is_array($image)) {
array_push($latestimages, $image);
}
if ($count === $to_number) {
break;
}
}
// sort latest image by mtime
$latestimages = sortMultiArray($latestimages, "mtime", "desc", false, false);
//echo "<pre>"; print_r($albums); echo "</pre>";
$itemssorted = array();
$count = 0;
foreach ($latestimages as $latestimage) {
$count++;
foreach ($allalbums as $album) {
if ($album['id'] === $latestimage['albumid']) {
array_push($albums, $album);
}
}
if ($count === $to_number) {
break;
}
}
if ($to_number < 1) {
$stopelement = 1;
} else {
$stopelement = $to_number;
}
$albums = array_slice($albums, 0, $stopelement);
// clear unnessesary items fron array
$maxvalue = 0;
if (empty($albums)) {
$itemssorted = array();
} else {
foreach ($albums as $key => $entry) {
if (array_key_exists('imagenumber', $entry)) {
$v = $entry['imagenumber'];
if ($v > $maxvalue) {
$maxvalue = $v;
}
} else {
示例13: handleOptionSave
static function handleOptionSave($themename, $themealbum)
{
if (!class_exists('user_groups')) {
$saved_rights = NO_RIGHTS;
$rightslist = sortMultiArray(Zenphoto_Authority::getRights(), array('set', 'value'));
foreach ($rightslist as $rightselement => $right) {
if (isset($_POST['register_user-' . $rightselement])) {
$saved_rights = $saved_rights | $_POST['register_user-' . $rightselement];
}
}
setOption('register_user_user_rights', $saved_rights);
}
return false;
}
示例14: getSearchArticles
/**
* Returns a list of News Titlelinks found in the search
*
* @param string $sorttype field to sort on
* @param string $sortdirection sort order
*
* @return array
*/
private function getSearchArticles($sorttype, $sortdirection)
{
if (!extensionEnabled('zenpage') || getOption('search_no_news') || $this->search_no_news) {
return array();
}
list($sorttype, $sortdirection) = $this->sortKey($sorttype, $sortdirection, 'title', 'news');
$searchstring = $this->getSearchString();
$searchdate = $this->dates;
if (empty($searchstring) && empty($searchdate)) {
return array();
}
// nothing to find
$criteria = $this->getCacheTag('news', serialize($searchstring), $sorttype . ' ' . $sortdirection);
if ($this->articles && $criteria == $this->searches['news']) {
return $this->articles;
}
$result = $this->getCachedSearch($criteria);
if (is_null($result)) {
$result = array();
if (empty($searchdate)) {
list($search_query, $weights) = $this->searchFieldsAndTags($searchstring, 'news', $sorttype, $sortdirection);
} else {
$search_query = $this->searchDate($searchstring, $searchdate, 'news', $sorttype, $sortdirection, $this->whichdates);
}
if (empty($search_query)) {
$search_result = false;
} else {
$search_result = query($search_query);
}
zp_apply_filter('search_statistics', $searchstring, 'news', !empty($search_result), false, $this->iteration++);
if ($search_result) {
while ($row = db_fetch_assoc($search_result)) {
$data = array('titlelink' => $row['titlelink']);
if (isset($weights)) {
$data['weight'] = $weights[$row['id']];
}
$result[] = $data;
}
db_free_result($search_result);
}
if (isset($weights)) {
$result = sortMultiArray($result, 'weight', true, true, false, false, array('weight'));
}
$this->cacheSearch($criteria, $result);
}
$this->articles = $result;
$this->searches['news'] = $criteria;
return $this->articles;
}
示例15: unset
unset($recentIP[$ip]['accessed'][$key]);
}
}
if ($__count > 1) {
$__interval = $__interval / $__count;
} else {
$__interval = 0;
}
$recentIP[$ip]['interval'] = $__interval;
if ($__count > 10 && $__interval < $__config['accessThreshold_THRESHOLD']) {
$recentIP[$ip]['blocked'] = 2;
}
}
if (count($recentIP) - 1 > $__config['accessThreshold_IP_RETENTION']) {
unset($recentIP['config']);
$recentIP = sortMultiArray($recentIP, array('lastAccessed'), true, true, false, true);
$recentIP = array_slice($recentIP, 0, $__config['accessThreshold_IP_RETENTION']);
$recentIP['config'] = $__config;
}
file_put_contents(SERVERPATH . '/' . DATA_FOLDER . '/recentIP', serialize($recentIP));
$mu->unlock();
unset($ip);
unset($full_ip);
unset($recentIP);
unset($__config);
unset($__time);
unset($__interval);
unset($__previous);
unset($__count);
unset($__locale);
}