Esempio n. 1
0
 public function getMedia($createIfNotExist = true)
 {
     if (!isset($this->media)) {
         $this->media = \Rebond\Core\Media\Data::loadById($this->mediaId, $createIfNotExist);
     }
     return $this->media;
 }
Esempio n. 2
0
 public static function loadRanking($type, $page)
 {
     $options = [];
     $options['clearSelect'] = true;
     $options['select'][] = Data::getList(['id', 'user_id', 'country', 'experience', 'username', 'tour_ranking', 'tour_point', 'tour_diff', 'race_ranking', 'race_point', 'race_diff']);
     $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'avatar_id'], 'player_user');
     $options['select'][] = \Rebond\Core\Media\Data::getList([], 'player_user_avatar');
     $options['leftJoin'][] = 'core_user player_user ON player_user.id = player.user_id';
     $options['leftJoin'][] = 'core_media player_user_avatar ON player_user_avatar.id = player_user.avatar_id';
     $options['where'][] = 'player.active = 1';
     $options['order'][] = 'player.' . $type . '_ranking, player.created_date';
     $options['limit'][] = $page * 20 . ', 20';
     return \Own\Bus\Player\Data::loadAll($options);
 }
Esempio n. 3
0
 public function validateUpload()
 {
     $v = Util\Validate::validate('upload', $this->getModel()->getUpload(), $this->uploadValidator);
     if ($v->getResult() == ResultType::ERROR) {
         return $v;
     }
     $options = [];
     $options['where'][] = ['media.upload = ?', $this->getModel()->getUpload()];
     $options['where'][] = ['media.id != ?', $this->getModel()->getId()];
     $options['where'][] = 'media.status IN (0,1)';
     $exist = Data::count($options);
     if ($exist >= 1) {
         $v->setResult(ResultType::ERROR);
         $v->setMessage('a media already exists with this url');
     }
     return $v;
 }
Esempio n. 4
0
 public function ranking()
 {
     $id = Converter::toInt('id', 'get', $this->player->getLeagueId());
     $league = \Own\Bus\League\Data::loadById($id);
     if (!isset($league)) {
         $league = $this->player->getLeague();
     }
     // player not logged in
     if (!isset($league)) {
         Session::redirect('/league');
     }
     // view
     $this->setTpl();
     $cacheTime = $this->app->site()->getCacheTime();
     $cache = \Rebond\Util\Cache::getCache('league-ranking', $league->getId(), $cacheTime);
     if (isset($cache)) {
         // layout
         $this->tplLayout->set('column1', $cache);
     } else {
         $options = [];
         $options['clearSelect'] = true;
         $options['select'][] = \Own\Bus\Player\Data::getList(['id', 'user_id', 'country', 'experience', 'username', 'league_ranking', 'league_point', 'league_diff']);
         $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'avatar_id'], 'player_user');
         $options['select'][] = \Rebond\Core\Media\Data::getList([], 'player_user_avatar');
         $options['leftJoin'][] = 'core_user player_user ON player_user.id = player.user_id';
         $options['leftJoin'][] = 'core_media player_user_avatar ON player_user_avatar.id = player_user.avatar_id';
         $options['where'][] = 'player.active = 1';
         $options['where'][] = 'player.league_id = ' . $league->getId();
         $options['order'][] = 'player.league_ranking, player.created_date';
         $players = \Own\Bus\Player\Data::loadAll($options);
         // main
         $tplMain = new Template(Template::SITE, ['www']);
         $tplMain->set('league', $league);
         $tplMain->set('player', $this->player);
         $tplMain->set('players', $players);
         // layout
         $cache = $tplMain->render('league-ranking');
         $this->tplLayout->set('column1', $cache);
         // cache
         \Rebond\Util\Cache::saveCache('league-ranking', $league->getId(), $cacheTime, $cache);
     }
     // template
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-center'));
     return $this->tplMaster->render('tpl-default');
 }
Esempio n. 5
0
 protected static function mapper(array $row, $alias = 'user')
 {
     $model = new \Rebond\Core\User\Model(false);
     if (isset($row[$alias . 'Id'])) {
         $model->setId($row[$alias . 'Id']);
     }
     if (isset($row[$alias . 'Username'])) {
         $model->setUsername($row[$alias . 'Username']);
     }
     if (isset($row[$alias . 'Email'])) {
         $model->setEmail($row[$alias . 'Email']);
     }
     if (isset($row[$alias . 'Password'])) {
         $model->setPassword($row[$alias . 'Password']);
     }
     if (isset($row[$alias . 'Firstname'])) {
         $model->setFirstname($row[$alias . 'Firstname']);
     }
     if (isset($row[$alias . 'Lastname'])) {
         $model->setLastname($row[$alias . 'Lastname']);
     }
     if (isset($row[$alias . 'AvatarId'])) {
         $model->setAvatarId($row[$alias . 'AvatarId']);
         $model->setAvatar(\Rebond\Core\Media\Data::join($row, $alias . '_avatar'));
     }
     if (isset($row[$alias . 'IsAdmin'])) {
         $model->setIsAdmin($row[$alias . 'IsAdmin']);
     }
     if (isset($row[$alias . 'IsDev'])) {
         $model->setIsDev($row[$alias . 'IsDev']);
     }
     if (isset($row[$alias . 'Status'])) {
         $model->setStatus($row[$alias . 'Status']);
     }
     if (isset($row[$alias . 'CreatedDate'])) {
         $model->setCreatedDate($row[$alias . 'CreatedDate']);
     }
     if (isset($row[$alias . 'ModifiedDate'])) {
         $model->setModifiedDate($row[$alias . 'ModifiedDate']);
     }
     return $model;
 }
Esempio n. 6
0
 public function text_editor()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, 'admin.media.image', true, '/media');
     // check
     $info = null;
     $generate = Converter::bool('generate');
     $imageListPath = \Rebond\Config::getPath('admin') . 'js/tinymce/imageList.js';
     // action
     if ($generate) {
         $url = \Rebond\Config::getPath('siteUrl') . \Rebond\Config::getPath('mediaFolder');
         $list = '[';
         $options = [];
         $options['clearSelect'] = true;
         $options['select'][] = \Rebond\Core\Media\Data::getList(['id', 'title', 'path', 'upload']);
         $options['where'][] = 'media.status = 1';
         $options['where'][] = 'media.extension IN ("png", "gif", "jpg", "jpeg")';
         $options['order'][] = 'media.title';
         $medium = \Rebond\Core\Media\Data::loadAll($options);
         foreach ($medium as $media) {
             $list .= '{title:"' . $media->getTitle() . '", value:"http://' . $url . $media->getPath() . $media->getUpload() . '"},' . chr(10);
         }
         if (count($medium) > 0) {
             $list = substr($list, 0, -2);
         }
         $list .= ']';
         File::save($imageListPath, 'w', $list);
         $info = '<p class="bg-success">' . count($medium) . ' ' . Lang::lang('photosGenerated') . '</p>';
     }
     // view
     $this->setTpl();
     // main
     $tplMain = new Template(Template::SITE, ['admin', 'media']);
     $tplMain->set('info', $info);
     if (file_exists($imageListPath)) {
         $tplMain->set('date', \Rebond\Util\Format::smartDate(filemtime($imageListPath)));
         $tplMain->set('link', '/js/tinymce/imageList.js');
     } else {
         $tplMain->set('date', 'n/a');
     }
     // layout
     $this->tplLayout->set('column1', $tplMain->render('text-editor'));
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     return $this->tplMaster->render('tpl-default');
 }
Esempio n. 7
0
 public function getAvatar($createIfNotExist = true)
 {
     if (!isset($this->avatar)) {
         $this->avatar = \Rebond\Core\Media\Data::loadById($this->avatarId, $createIfNotExist);
     }
     return $this->avatar;
 }
Esempio n. 8
0
File: Data.php Progetto: vincium/lot
 private static function link($linkTournament = false, $linkLeague = false, $players = false, $needBothPlayers = true)
 {
     $join = 'join';
     if (!$needBothPlayers) {
         $join = 'leftJoin';
     }
     $option = [];
     $option['clearSelect'] = true;
     $options['select'][] = self::getList(['id', 'player_match1_id', 'player_match2_id', 'surface', 'current_set', 'best_of_sets', 'type', 'winner_id', 'position', 'tournament_id', 'league_id', 'status', 'scheduled']);
     $options['select'][] = \Own\Bus\PlayerMatch\Data::getList(['id', 'player_id', 'seed', 'has_viewed', 'set1', 'set2', 'set3', 'set4', 'set5', 'points', 'level'], 'match_player_match1');
     $options['select'][] = \Own\Bus\PlayerMatch\Data::getList(['id', 'player_id', 'seed', 'has_viewed', 'set1', 'set2', 'set3', 'set4', 'set5', 'points', 'level'], 'match_player_match2');
     $options['select'][] = \Own\Bus\Player\Data::getList(['id', 'username', 'user_id', 'country', 'experience'], 'match_player_match1_player');
     if ($players) {
         $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'avatar_id'], 'match_player_match1_player_user');
         $options['select'][] = \Rebond\Core\Media\Data::getList([], 'match_player_match1_player_user_avatar');
     }
     $options['select'][] = \Own\Bus\Player\Data::getList(['id', 'username', 'user_id', 'country', 'experience'], 'match_player_match2_player');
     if ($players) {
         $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'avatar_id'], 'match_player_match2_player_user');
         $options['select'][] = \Rebond\Core\Media\Data::getList([], 'match_player_match2_player_user_avatar');
     }
     if ($linkTournament) {
         $options['select'][] = \Own\Bus\Tournament\Data::getList(['id', 'title', 'size', 'classification'], 'match_tournament');
     }
     if ($linkLeague) {
         $options['select'][] = \Own\Bus\League\Data::getList(['id', 'title'], 'match_league');
     }
     $options[$join][] = 'bus_player_match match_player_match1 ON match_player_match1.id = match.player_match1_id';
     $options[$join][] = 'bus_player_match match_player_match2 ON match_player_match2.id = match.player_match2_id';
     $options[$join][] = 'bus_player match_player_match1_player ON match_player_match1_player.id = match_player_match1.player_id';
     if ($players) {
         $options['leftJoin'][] = 'core_user match_player_match1_player_user ON match_player_match1_player_user.id = match_player_match1_player.user_id';
         $options['leftJoin'][] = 'core_media match_player_match1_player_user_avatar ON match_player_match1_player_user_avatar.id = match_player_match1_player_user.avatar_id';
     }
     $options[$join][] = 'bus_player match_player_match2_player ON match_player_match2_player.id = match_player_match2.player_id';
     if ($players) {
         $options['leftJoin'][] = 'core_user match_player_match2_player_user ON match_player_match2_player_user.id = match_player_match2_player.user_id';
         $options['leftJoin'][] = 'core_media match_player_match2_player_user_avatar ON match_player_match2_player_user_avatar.id = match_player_match2_player_user.avatar_id';
     }
     if ($linkTournament) {
         $options['leftJoin'][] = 'bus_tournament match_tournament ON match_tournament.id = match.tournament_id';
     }
     if ($linkLeague) {
         $options['leftJoin'][] = 'bus_league match_league ON match_league.id = match.league_id';
     }
     return $options;
 }
Esempio n. 9
0
 protected static function mapper(array $row, $alias = 'x')
 {
     $model = new \Rebond\App\Standard\Model(false);
     if (isset($row[$alias . 'AppId'])) {
         $model->setAppId($row[$alias . 'AppId']);
     }
     if (isset($row[$alias . 'MediaId'])) {
         $model->setMediaId($row[$alias . 'MediaId']);
         $model->setMedia(\Rebond\Core\Media\Data::join($row, $alias . '_media'));
     }
     if (isset($row[$alias . 'Description'])) {
         $model->setDescription($row[$alias . 'Description']);
     }
     return parent::mapEntity($model, $row);
 }
Esempio n. 10
0
 public function past()
 {
     $page = Converter::toInt('page', 'get', 1);
     $options = [];
     $options['where'][] = 'tournament.status IN (3,4)';
     $options['where'][] = 'tournament.start_date < NOW()';
     $count = \Own\Bus\Tournament\Data::count($options);
     $options['clearSelect'] = true;
     $options['select'][] = \Own\Bus\Tournament\Data::getList(['id', 'title', 'size', 'classification', 'start_date', 'end_date', 'surface', 'winner_id']);
     $options['select'][] = \Own\Bus\Player\Data::getList(['id', 'username', 'user_id', 'country', 'experience'], 'tournament_winner');
     $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'avatar_id'], 'tournament_winner_user');
     $options['select'][] = \Rebond\Core\Media\Data::getList([], 'tournament_winner_user_avatar');
     $options['join'][] = 'bus_player tournament_winner ON tournament_winner.id = tournament.winner_id';
     $options['leftJoin'][] = 'core_user tournament_winner_user ON tournament_winner_user.id = tournament_winner.user_id';
     $options['leftJoin'][] = 'core_media tournament_winner_user_avatar ON tournament_winner_user_avatar.id = tournament_winner_user.avatar_id';
     $options['order'][] = 'tournament.start_date DESC';
     $options['limit'][] = ($page - 1) * 20 . ', 20';
     $past = \Own\Bus\Tournament\Data::loadAll($options);
     $registeredIds = \Own\Bus\TournamentPlayer\Data::loadRegistered($this->player->getId());
     // view
     $this->setTpl();
     // filter
     $tplFilter = new Template(Template::SITE, ['www']);
     $tplFilter->set('current', $page);
     $tplFilter->set('count', $count);
     $tplFilter->set('url', '/tournament/past?page=');
     // main
     $tplMain = new Template(Template::SITE, ['www']);
     $tplMain->set('past', $past);
     $tplMain->set('registeredIds', $registeredIds);
     // layout
     $this->tplLayout->set('column1', $tplFilter->render('tour-past-filter'));
     $this->tplLayout->add('column1', $tplMain->render('tour-past'));
     // template
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-center'));
     return $this->tplMaster->render('tpl-default');
 }
Esempio n. 11
0
 public function selectMedia()
 {
     if (!$this->hasPrivilege('admin.content.edit')) {
         return $this->noPrivilege('admin.content.edit');
     }
     $json = [];
     $json['result'] = ResultType::ERROR;
     // check
     $field = Converter::string('field', 'post');
     $hashParam = Converter::string('hash', 'post');
     $search = Converter::string('search', 'post');
     if (!isset($field) || !isset($hashParam)) {
         $json['message'] = Lang::lang('errorInvalidParameters');
         return json_encode($json);
     }
     $hash = explode('/', $hashParam);
     $hash = array_slice($hash, 1);
     $folderId = isset($hash[0]) && $hash[0] != '' ? (int) $hash[0] : 0;
     $page = isset($hash[1]) && $hash[1] != '' ? (int) $hash[1] : 1;
     $type = isset($hash[2]) && $hash[2] != '' ? $hash[2] : 'all';
     $order = isset($hash[3]) && $hash[3] != '' ? $hash[3] : 'modified_date';
     $orderType = isset($hash[4]) && $hash[4] != '' ? $hash[4] : 'desc';
     if (!in_array($type, ['all', 'images', 'videos', 'documents'])) {
         $type = 'all';
     }
     if (!in_array($order, ['title', 'extension', 'modified_date'])) {
         $order = 'modified_date';
     }
     if (!in_array($orderType, ['asc', 'desc'])) {
         $orderType = 'desc';
     }
     $options = [];
     $options['where'][] = 'media.status = 1';
     $options['where'][] = 'media.is_selectable = 1';
     if ($folderId != 0) {
         $options['where'][] = ['media.folder_id = ?', $folderId];
     }
     if (isset($search) && $search != '') {
         $options['where'][] = ['media.title LIKE ?', '%' . $search . '%'];
     }
     if ($type != 'all') {
         switch ($type) {
             case 'images':
                 $options['where'][] = 'media.extension IN ("jpg", "jpeg", "png")';
                 break;
             case 'videos':
                 $options['where'][] = 'media.extension IN ("avi", "mov")';
                 break;
             case 'documents':
                 $options['where'][] = 'media.extension IN ("pdf", "xls", "xlsx", "doc", "docx")';
                 break;
         }
     }
     $mediaCount = \Rebond\Core\Media\Data::count($options);
     // get user settings
     $userSettings = \Rebond\Cms\UserSettings\Data::loadByUserId($this->signedUser->getId());
     $mediaView = 'grid';
     $mediaListCount = 10;
     if (isset($userSettings)) {
         $mediaView = $userSettings->getMediaView() == 0 ? 'grid' : 'list';
         $mediaListCount = (int) $userSettings->getMediaPagingValue();
     }
     if ($page < 1) {
         $page = 1;
     }
     if ($page > ceil($mediaCount / $mediaListCount) && $mediaCount > 0) {
         $page = ceil($mediaCount / $mediaListCount);
     }
     $folders = \Rebond\Core\Folder\Service::renderList();
     // add paging and order
     $options['order'][] = 'media.' . $order . ' ' . $orderType;
     $options['limit'][] = ($page - 1) * $mediaListCount . ', ' . $mediaListCount;
     $media = \Rebond\Core\Media\Data::loadAll($options);
     $tpl = new Template(Template::MODULE, ['core', 'media']);
     $tpl->set('items', $media);
     $tpl->set('field', $field);
     $tplFilter = new Template(Template::MODULE, ['core', 'media']);
     $tplFilter->set('current', $page);
     $tplFilter->set('folders', $folders);
     $tplFilter->set('maxByPage', $mediaListCount);
     $tplFilter->set('count', $mediaCount);
     $tplFilter->set('mediaView', $mediaView);
     $tplFilter->set('order', $order . '_' . $orderType);
     $tplFilter->set('type', $type);
     $tplFilter->set('folderId', $folderId);
     $tplFilter->set('hash', '#!/' . $folderId . '/' . $page . '/' . $type . '/' . $order . '/' . $orderType);
     $tplFilter->set('search', $search);
     $json['result'] = ResultType::SUCCESS;
     $json['message'] = Lang::lang('listUpdated') . ' (' . count($media) . ')';
     $json['html'] = $tplFilter->render('select-filter');
     $json['html'] .= $tpl->render('select-' . $mediaView);
     return json_encode($json);
 }