Beispiel #1
0
 function sort(&$jTipsUsers, $sort_on = 'points', $sort_dir = 'asc')
 {
     global $database;
     $sorter = array();
     $jHistory = new jHistory($database);
     $users = array();
     foreach ($jTipsUsers as $jTipsUser) {
         $jTipsUser->getTotalScore($sort_on);
         //make sure the field is set
         array_push($users, $jTipsUser);
     }
     if ($sort_dir == 'asc') {
         $direction = 1;
     } else {
         $direction = -1;
     }
     jTipsSortArrayObjects($users, $sort_on, $direction);
     return $users;
 }
Beispiel #2
0
$jTeam = new jTeam($database);
$ids = jTipsGetParam($_REQUEST, 'cid', array());
//Do we have an existing Season?
$id = array_shift($ids);
if (is_numeric($id)) {
    $jTeam->load($id);
}
//set the page title
$title = $jLang['_ADMIN_TEAM_TITLE'] . ": " . ($jTeam->exists() ? $jLang['_ADMIN_OTHER_EDIT'] : $jLang['_ADMIN_OTHER_NEW']);
//set the custom javascripts
$mainframe->addCustomHeadTag("<script type='text/javascript' src='components/com_jtips/modules/Teams/Teams.js'></script>");
//what seasons are there
$jSeason = new jSeason($database);
$jSeasons = forceArray($jSeason->loadByParams(array()));
$jSeasonOptions = array(jTipsHTML::makeOption('', $jLang['_ADMIN_CONF_NONE']));
jTipsSortArrayObjects($jSeasons, 'name', 'ASC');
foreach ($jSeasons as $season) {
    $jSeasonOptions[] = jTipsHTML::makeOption($season->id, $season->name);
}
//build the field definitions
$formData = array('basic' => array('legend' => '_ADMIN_BASIC_INFORMATION', 'fields' => array('id' => array('field' => array('type' => 'hidden', 'attributes' => array('type' => 'hidden', 'name' => 'id', 'id' => 'id', 'value' => $jTeam->id))), 'season' => array('label' => '_ADMIN_TEAM_SEASON', 'field' => array('type' => 'select', 'attributes' => array('name' => 'season_id', 'id' => 'season_id', 'class' => 'inputbox'), 'options' => $jSeasonOptions, 'selected' => $jTeam->season_id)), 'name' => array('label' => '_ADMIN_TEAM_NAME', 'field' => array('type' => 'text', 'attributes' => array('name' => 'name', 'id' => 'name', 'class' => 'inputbox', 'size' => '50', 'type' => 'text', 'value' => $jTeam->name))), 'location' => array('label' => '_ADMIN_TEAM_LOCATION', 'field' => array('type' => 'text', 'attributes' => array('name' => 'location', 'id' => 'location', 'class' => 'inputbox', 'size' => '50', 'type' => 'text', 'value' => $jTeam->location))), 'website' => array('label' => '_ADMIN_TEAM_URL', 'field' => array('type' => 'text', 'attributes' => array('name' => 'url', 'id' => 'url', 'class' => 'inputbox', 'size' => '50', 'type' => 'text', 'value' => $jTeam->url))), 'about' => array('label' => '_ADMIN_TEAM_ABOUT', 'field' => array('type' => 'editor', 'attributes' => array('name' => 'about', 'id' => 'about', 'class' => 'inputbox', 'value' => jTipsStripslashes($jTeam->about)))))));
$formData['image'] = array('legend' => '_ADMIN_TEAM_LOGO', 'fields' => array('logo' => array('label' => '_ADMIN_TEAM_LOGO', 'field' => array('type' => 'file', 'attributes' => array('size' => '50', 'type' => 'file', 'class' => 'inputbox', 'name' => 'logo', 'id' => 'logo')))));
if ($jTeam->logo) {
    $formData['image']['fields']['current_logo'] = array('label' => '_ADMIN_TEAM_CURRENT_LOGO', 'field' => array('type' => 'img', 'attributes' => array('alt' => 'Logo', 'id' => 'current_logo', 'src' => $mosConfig_live_site . '/' . getJtipsImage($jTeam->logo, 100))));
    $formData['image']['fields']['remove_logo'] = array('label' => '_ADMIN_TEAM_REMOVE_LOGO', 'field' => array('type' => 'checkbox', 'attributes' => array('class' => 'inputbox', 'name' => 'remove_logo', 'value' => '1', 'type' => 'checkbox', 'onClick' => 'if (this.checked){$("logo").disabled=true;}else{$("logo").disabled=false}')), 'description' => '_ADMIN_TEAM_REMOVE_LOGO_DEF');
}
// BUG 287 - can no longer edit team points
/*$formData['points'] = array(
	'legend' => '_ADMIN_TEAM_POINTS_ADJUST',
	'fields' => array(
		'wins' => array(
Beispiel #3
0
 function getTeamLadder($field = 'wins', $dir = -1)
 {
     $jTeams = $this->getTeams();
     //BUG 86 - Team Ladder Sorting/Ordering
     $fieldSort = $goalSort = $nameSort = array();
     //multisort on $field, then for/against (desc) then name (asc)
     foreach ($jTeams as $jTeam) {
         $jTeam->setGoalDifference();
         //the selected column
         $fieldSort[$jTeam->id] = $jTeam->{$field};
         $goalSort[$jTeam->id] = $jTeam->for_against;
         $scoredSort[$jTeam->id] = $jTeam->points_for;
         $nameSort[$jTeam->id] = $jTeam->getName();
     }
     if ($dir < 0 or strtolower($dir) == 'desc') {
         $fieldDir = SORT_DESC;
     } else {
         $fieldDir = SORT_ASC;
     }
     //make sure all the arrays are the same langth to avoid errors
     /*
      * TODO: BUG: XXX - min was checking the minimum value in each array, needed to check the length instead
      */
     if (min(count($jTeams), count($fieldSort), count($goalSort), count($nameSort), count($scoredSort)) == count($jTeams) and count($jTeams) > 0) {
         array_multisort($fieldSort, $fieldDir, SORT_NUMERIC, $goalSort, SORT_DESC, SORT_NUMERIC, $scoredSort, SORT_DESC, SORT_NUMERIC, $nameSort, SORT_ASC, SORT_NUMERIC, $jTeams);
     } else {
         //as a fallback, use the original sort
         jTipsSortArrayObjects($jTeams, $field, $dir);
     }
     return $jTeams;
 }