本文整理汇总了PHP中StringUtil::sort方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::sort方法的具体用法?PHP StringUtil::sort怎么用?PHP StringUtil::sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtil
的用法示例。
在下文中一共展示了StringUtil::sort方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAvailableContentLanguages
/**
* Returns a list of all available content languages.
*
* @return array
*/
public static function getAvailableContentLanguages()
{
$availableLanguages = array();
foreach (Language::getAvailableContentLanguages(PACKAGE_ID) as $language) {
$availableLanguages[$language['languageID']] = WCF::getLanguage()->get('wcf.global.language.' . $language['languageCode']);
}
// sort languages
StringUtil::sort($availableLanguages);
return $availableLanguages;
}
示例2: execute
/**
* @see EventListener::execute()
*/
public function execute($eventObj, $className, $eventName)
{
if (TEAM_SHOW_MODERATED_BOARDS) {
if ($eventName == 'readData') {
$eventObj->activeFields[] = 'moderatedBoards';
} else {
if ($eventName == 'assignVariables') {
require_once WBB_DIR . 'lib/data/board/Board.class.php';
// get user ids
$userIDArray = array_keys($eventObj->members);
if (count($userIDArray)) {
// get user to groups
$userToGroups = array();
$groupIDArray = array();
$sql = "SELECT\tuserID, groupID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\tWHERE\tuserID IN (" . implode(',', $userIDArray) . ")";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
if (!isset($userToGroups[$row['userID']])) {
$userToGroups[$row['userID']] = array();
}
$userToGroups[$row['userID']][] = $row['groupID'];
$groupIDArray[$row['groupID']] = $row['groupID'];
}
// get user to boards
$userToBoards = array();
$sql = "SELECT\tuserID, boardID\n\t\t\t\t\t\tFROM\twbb" . WBB_N . "_board_moderator\n\t\t\t\t\t\tWHERE\tuserID IN (" . implode(',', $userIDArray) . ")";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
if (!isset($userToBoards[$row['userID']])) {
$userToBoards[$row['userID']] = array();
}
$userToBoards[$row['userID']][] = $row['boardID'];
}
// get group to boards
$groupToBoards = array();
if (count($groupIDArray)) {
$sql = "SELECT\tgroupID, boardID\n\t\t\t\t\t\t\tFROM\twbb" . WBB_N . "_board_moderator\n\t\t\t\t\t\t\tWHERE\tgroupID IN (" . implode(',', $groupIDArray) . ")";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
if (!isset($groupToBoards[$row['groupID']])) {
$groupToBoards[$row['groupID']] = array();
}
$groupToBoards[$row['groupID']][] = $row['boardID'];
}
}
foreach ($eventObj->members as $key => $memberData) {
// get board ids
$boardIDArray = array();
if (isset($userToBoards[$key])) {
$boardIDArray = $userToBoards[$key];
}
if (isset($userToGroups[$key])) {
foreach ($userToGroups[$key] as $groupID) {
if (isset($groupToBoards[$groupID])) {
$boardIDArray = array_merge($boardIDArray, $groupToBoards[$groupID]);
}
}
}
// get boards and check permissions
array_unique($boardIDArray);
$boards = array();
foreach ($boardIDArray as $boardID) {
$board = Board::getBoard($boardID);
if ($board->getPermission('canViewBoard')) {
$boards[$board->boardID] = WCF::getLanguage()->get(StringUtil::encodeHTML($board->title));
}
}
if (count($boards)) {
// sort boards
StringUtil::sort($boards);
// generate output
$output = '';
foreach ($boards as $boardID => $title) {
if (!empty($output)) {
$output .= ', ';
}
$output .= '<a href="index.php?page=Board&boardID=' . $boardID . SID_ARG_2ND . '">' . $title . '</a>';
}
$eventObj->members[$key]['moderatedBoards'] = $output;
}
}
}
}
}
}
}
示例3: getSortedByNames
protected function getSortedByNames()
{
$names = $this->lastOnlineByName = array();
foreach ($this->lastOnline as $key => $row) {
$names[$key] = $row['plainname'];
}
StringUtil::sort($names);
foreach ($names as $key => $row) {
$this->lastOnlineByName[] = $this->lastOnline[$key];
}
}
示例4: readData
/**
* @see Page::readData()
*/
public function readData()
{
parent::readData();
// boards
$this->boardOptions = Board::getBoardSelect(array(), true, true);
// language
$this->languages = Language::getAvailableContentLanguages();
foreach ($this->languages as $languageID => $language) {
$this->languages[$languageID] = WCF::getLanguage()->get('wcf.global.language.' . $language['languageCode']);
}
StringUtil::sort($this->languages);
}
示例5: selectLanguages
/**
* Shows the page for choosing the installed languages.
*/
protected function selectLanguages()
{
$errorField = $errorType = '';
$allLanguages = $this->getAllLanguages();
$illegalLanguages = array();
// build visible language list
$languages = array();
foreach ($allLanguages as $languageCode) {
$languages[$languageCode] = self::getLanguage()->get('wcf.global.language.' . $languageCode) . ' (' . $languageCode . ')';
}
// skip step in developer mode
// select all available languages automatically
if (self::$developerMode) {
self::$selectedLanguages = array();
foreach ($allLanguages as $languageCode) {
if (Language::isSupported($languageCode)) {
self::$selectedLanguages[] = $languageCode;
}
}
self::getTPL()->assign('selectedLanguages', self::$selectedLanguages);
$this->gotoNextStep('configureDB');
exit;
}
// sort languages
StringUtil::sort($languages);
// start error handling
if (isset($_POST['send'])) {
try {
// no languages selected
if (count(self::$selectedLanguages) == 0) {
throw new UserInputException('selectedLanguages');
}
// illegal selection
// language is not available in the active charset
foreach (self::$selectedLanguages as $language) {
if (!Language::isSupported($language)) {
$illegalLanguages[] = $language;
}
}
if (count($illegalLanguages) > 0) {
throw new UserInputException('selectedLanguages', 'notAvailable');
}
// no errors
// go to next step
$this->gotoNextStep('configureDB');
exit;
} catch (UserInputException $e) {
$errorField = $e->getField();
$errorType = $e->getType();
}
} else {
self::$selectedLanguages[] = self::$selectedLanguageCode;
WCF::getTPL()->assign('selectedLanguages', self::$selectedLanguages);
}
WCF::getTPL()->assign(array('illegalLanguages' => $illegalLanguages, 'errorField' => $errorField, 'errorType' => $errorType, 'charsets' => Language::$supportedCharsets, 'languages' => $languages, 'disableMultiByte' => !extension_loaded('mbstring'), 'nextStep' => 'selectLanguages'));
WCF::getTPL()->display('stepSelectLanguages');
}
示例6: readData
/**
* @see Page::readData()
*/
public function readData()
{
parent::readData();
// get profile options
require_once WCF_DIR . 'lib/data/user/option/UserOptions.class.php';
$userOptions = new UserOptions();
$this->categories = $userOptions->getOptionTree('profile', $this->frame->getUser());
// move contact information and about me
foreach ($this->categories as $category => $categoryData) {
if ($category == 'profile.contact' || $category == 'profile.messenger') {
foreach ($categoryData['options'] as $key => $option) {
if (isset($option['outputData'])) {
$this->contactInformation[] = $option['outputData'];
} else {
if (!empty($option['optionValue']) && (empty($option['outputClass']) || !$userOptions->getOutputObject($option['outputClass']) instanceof UserOptionOutputContactInformation)) {
$this->contactInformation[] = array('icon' => '', 'title' => WCF::getLanguage()->get('wcf.user.option.' . $option['optionName']), 'value' => $option['optionValue'], 'url' => '');
}
}
}
unset($this->categories[$category]);
}
}
// add vcard link
$this->contactInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('vCardM.png'), 'title' => WCF::getLanguage()->get('wcf.user.profile.downloadVCard'), 'value' => StringUtil::encodeHTML($this->frame->getUser()->username), 'url' => 'index.php?page=VCard&userID=' . $this->frame->getUserID() . SID_ARG_2ND);
// add general informations
// registration date
$this->generalInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('registerM.png'), 'title' => WCF::getLanguage()->get('wcf.user.registrationDate'), 'value' => DateUtil::formatTime(null, $this->frame->getUser()->registrationDate));
// languages
require_once WCF_DIR . 'lib/acp/form/UserOptionListForm.class.php';
$languages = array();
$availableLanguages = UserOptionListForm::getAvailableContentLanguages();
if (!$this->frame->getUser()->languageIDs) {
$this->languages = $availableLanguages;
} else {
$languageIDs = explode(',', $this->frame->getUser()->languageIDs);
foreach ($languageIDs as $languageID) {
if (isset($availableLanguages[$languageID])) {
$languages[$languageID] = $availableLanguages[$languageID];
}
}
// sort languages
StringUtil::sort($languages);
}
if (count($languages)) {
$this->generalInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('languageM.png'), 'title' => WCF::getLanguage()->get('wcf.user.profile.languages'), 'value' => implode(', ', $languages));
}
// last activity
if (!$this->frame->getUser()->isOnline() && (!$this->frame->getUser()->invisible || WCF::getUser()->getPermission('admin.general.canViewInvisible')) && $this->frame->getUser()->lastActivityTime != 0) {
$this->generalInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('offlineM.png'), 'title' => WCF::getLanguage()->get('wcf.user.lastActivity'), 'value' => DateUtil::formatTime(null, $this->frame->getUser()->lastActivityTime, true));
}
// profile visits
WCF::getTPL()->assign('user', $this->frame->getUser());
$this->generalInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('visitsM.png'), 'title' => WCF::getLanguage()->get('wcf.user.profile.hits'), 'value' => StringUtil::formatNumeric($this->frame->getUser()->profileHits) . ($this->frame->getUser()->getProfileAge() > 1 ? ' ' . WCF::getLanguage()->getDynamicVariable('wcf.user.profile.hitsPerDay') : ''));
// get profile visitors
$sql = "SELECT\t\tavatar.*, user_table.*, visitor.*\n\t\t\tFROM\t\twcf" . WCF_N . "_user_profile_visitor visitor\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_user user_table\n\t\t\tON \t\t(user_table.userID = visitor.userID)\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_avatar avatar\n\t\t\tON \t\t(avatar.avatarID = user_table.avatarID)\n\t\t\tWHERE\t\townerID = " . $this->frame->getUserID() . "\n\t\t\t\t\tAND user_table.userID IS NOT NULL\n\t\t\tORDER BY\ttime DESC";
$result = WCF::getDB()->sendQuery($sql, 5);
while ($row = WCF::getDB()->fetchArray($result)) {
$this->profileVisitors[] = new UserProfile(null, $row);
}
// friends
if (MODULE_MEMBERS_LIST == 1 && $this->frame->getUser()->shareWhitelist) {
$sql = "SELECT\t\tavatar.*, user_table.*\n\t\t\t\tFROM\t\twcf" . WCF_N . "_user_whitelist friends\n\t\t\t\tLEFT JOIN \twcf" . WCF_N . "_user user_table\n\t\t\t\tON \t\t(user_table.userID = friends.whiteUserID)\n\t\t\t\tLEFT JOIN \twcf" . WCF_N . "_avatar avatar\n\t\t\t\tON \t\t(avatar.avatarID = user_table.avatarID)\n\t\t\t\tWHERE\t\tfriends.userID = " . $this->frame->getUserID() . "\n\t\t\t\t\t\tAND confirmed = 1\n\t\t\t\t\t\tAND user_table.userID IS NOT NULL\n\t\t\t\tORDER BY\tfriends.time DESC";
$result = WCF::getDB()->sendQuery($sql, 5);
while ($row = WCF::getDB()->fetchArray($result)) {
$this->friends[] = new UserProfile(null, $row);
}
}
}
示例7: getLanguages
/**
* Returns a sorted list of all installed languages.
*
* @return array
*/
public static function getLanguages()
{
$languages = array();
foreach (self::$cache['languages'] as $languageID => $language) {
$languages[$languageID] = WCF::getLanguage()->getDynamicVariable('wcf.global.language.' . $language['languageCode']);
}
StringUtil::sort($languages);
return $languages;
}