/** * @return void */ public function show() { $editing = false; if (Team::isSuperAdmin()) { $editing = HTMLResponse::fromGET('edit', ''); if (!$editing) { ?> <a href="<?=HTMLResponse::getRoute()?>?edit=1"> Editar página </a> <? } else { ?> <a href="<?=HTMLResponse::getRoute()?>" onclick="return confirm('Quieres descartar los cambios?')"> Descartar y volver a la página </a> <? } ?> <div style="height: 6px"></div> <? } $content = Setting::getKey('rules_content'); if (!$editing) { ?><div class="inblock" style="margin: 0 auto; max-width: 90%; text-align: justify"> <?=$content?> </div><? } else { if (!$csrf = $_SESSION['csrf']) { $_SESSION['csrf'] = $csrf = rand(1, 1000000); } if (HTMLResponse::fromGETorPOST('csrf', '') == $csrf) { $content = HTMLResponse::fromPOST('content'); Setting::setKey('rules_content', $content); HTMLResponse::exitWithRoute(HTMLResponse::getRoute()); } $this->design->addJavaScript('//cdn.ckeditor.com/4.5.7/full/ckeditor.js'); $this->design->addJavaScript(" CKEDITOR.replace( 'editor' ) ", false); ?> <form action="<?=HTMLResponse::getRoute()?>?edit=1" method="post"> <div style="width:90%; margin: 0 auto"> <textarea name="content" id="editor"><?=htmlentities($content)?></textarea> </div> <br> <input type="hidden" name="csrf" value="<?=$csrf?>"> <button type="submit">Guardar cambios</button> </form> <? } }
/** * @return void */ public function show() { if (!TwitterAuth::isLogged()) { ?> Sólo los miembros pueden ver esta página. <a href="<?=HTMLResponse::getRoute()?>?authenticate=1"> Inicia sesión. </a><br> <? return; } else { if (!Team::isMember()) { HTMLResponse::exitWithRoute('/votaciones/'); } $answer = PollVote::findOne('userid = ? and pollid = ?', [TwitterAuth::getUserId(), $this->poll->pollid]); $options = PollOption::find('pollid = ? order by polloptionid asc', [$this->poll->pollid]); if (!$answer && strlen($hash = HTMLResponse::fromGET('hash', ''))) { $optionid = HTMLResponse::fromGET('vote'); foreach($options as $index => $option) { if ($option->polloptionid == $optionid && $option->getHash() == $hash) { $answer = PollVote::create(); $answer->userid = TwitterAuth::getUserId(); $answer->dateline = time(); $answer->avatar = TwitterAuth::getAvatar(); $answer->pollid = $this->poll->pollid; $answer->polloptionid = $option->polloptionid; $answer->username = TwitterAuth::getUserName(); $answer->save(); } } } $answers = Model::groupBy(PollVote::find('pollid = ?', [$this->poll->pollid]), 'polloptionid'); $hasAnswered = !!$answer; ?><div style="text-align:left; margin: 0 auto" class="inblock"> <table style="width:640px"> <thead> <tr> <td>Lista de opciones</td> </tr> </thead> <? foreach($options as $index => $option) { ?> <tr><td class="row" style="text-align: left"> <div style="height: 6px"></div> <div class="inblock middle" style="width:320px"> <b>Opción <?=$index+1?></b>: <?= htmlentities($option->title) ?> </div> <div class="inblock middle"> <div class="moreless inblock middle" style="width: 150px"> <a href="javascript:void(0)" onclick="$(this).closest('.row').find('.moreless').toggle(); $(this).closest('.row').find('.onmore').slideDown(500);">+ Mostrar más</a> </div> <div class="moreless inblock middle" style="width: 150px; display: none"> <a href="javascript:void(0)" onclick="$(this).closest('.row').find('.moreless').toggle(); $(this).closest('.row').find('.onmore').slideUp(400);">- Mostrar menos</a> </div> </div> <div class="inblock middle"> <? if (!$hasAnswered) { ?> <a href="<?=HTMLResponse::getRoute()?>?vote=<?=$option->polloptionid?>&hash=<?=$option->getHash()?>" onclick="return confirm('¿Votas <?=htmlentities($option->title)?>?')"> Votar esta opción </a> <? } else if ($answer->polloptionid == $option->polloptionid) { ?> <i>Votaste esta opción</i> <? } ?> </div> <div class="onmore" style="display: none; padding: 12px"> <?= $option->description ?> </div> <div style="height: 6px"></div> <? if (!$hasAnswered) { ?><i>Vota primero para ver los resultados</i><? } else { $optionAnswers = $answers[$option->polloptionid]; ?> Votado por: <?= $optionAnswers ? '<b>'.implode(', ', Model::pluck($optionAnswers, 'username')).'</b> ('.count($optionAnswers).' votos)' : '<i>Nadie</i>'; ?> <? } ?> <div style="height: 6px"></div> </td></tr> <? } ?></table></div><br><br><? } }
public function __construct(PublicSection $section) { parent::__construct(); if (HTMLResponse::fromGET('authenticate')) { HTMLResponse::exitWithRoute(TwitterAuth::getAuthorizeURL(HTMLResponse::getRoute())); } if (HTMLResponse::fromGET('logout')) { session_destroy(); HTMLResponse::exitWithRoute(HTMLResponse::getRoute()); } TwitterAuth::isLogged(); if (TwitterAuth::isBot()) { if (HTMLResponse::fromGET('authenticatebot')) { HTMLResponse::exitWithRoute(TwitterAuth::getBotAuthorizeURL(HTMLResponse::getRoute())); } TwitterAuth::doBotLogin(); } $this->topMenu = array(); $this->setMeta('charset', 'utf-8'); $this->setMeta('viewport', 'width=device-width, initial-scale=1.0'); $this->setTitle($section->getTitle() . ' - ' . $section->getSubtitle()); $this->addStyleSheet('/css/style.css'); if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1' || $_SERVER['REMOTE_ADDR'] == '::1') { $this->addJavaScript("http://localhost/jquery.js", true); } else { $this->addJavaScript("https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js", true); } $this->addJavaScript(" $(document).ready(function() { if(screen.width <= 512) { document.getElementById('meta-viewport').setAttribute('content','width=512'); } }) ", false); $this->season = null; if ($_SESSION['seasonid']) { $this->season = Season::get($_SESSION['seasonid']); } $section->setDesign($this); $this->section = $section; if ($this->season == null) { $this->season = Season::findOne('ispublic order by isdefault desc'); } $seasonLink = $this->season->getLink(); $this->addToTopMenu("/{$seasonLink}/", 'Enfrentamientos', '/'); $this->addToTopMenu("/{$seasonLink}/equipos/", 'Equipos', '/equipos/.*'); $this->addToTopMenu("/{$seasonLink}/calendario/", 'Calendario', '/calendario/'); $this->addToTopMenu("/{$seasonLink}/clasificacion/", 'Clasificación', '/clasificacion/'); $this->addToTopMenu("/{$seasonLink}/quiniela/", 'Quiniela', '/quiniela/'); $this->addToTopMenu('/normas/', 'Normas', '/normas/'); if (Team::isAdmin()) { $this->addToTopMenu('/unete/', '¡Únete!', '/unete/'); } /* if (Team::isMember()) { // $this->addToTopMenu('/votaciones/', 'Votaciones', '/votaciones/.*'); } if (Team::isSuperAdmin()) { // $this->addToTopMenu('/admin/', 'Admin', '/admin/.*'); // $this->addToTopMenu('/comunicados/', 'Comunicados', '/comunicados/.*'); } */ $this->addJavaScript('/js/lce.js', true); $this->addStyleSheet(" html { background: url(/".$this->season->getBackgroundLink().") no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } ", false); ob_start(); $this->section->show(); $this->contents = ob_get_contents(); ob_end_clean(); }