public function imprimir() { // Implementada en la subclase $this->imprimirCabecera(); for ($index = 0; $index < count($this->horarios); $index++) { $horario = $this->horarios[$index]; // Implementada en la subclase $this->imprimirFila($horario, $index); } imprimirTabulados(6); echo $this->tabla->toHtml(); }
/** * Muestra el formulario para iniciar sesión. */ private function imprimirFormularioLogin() { imprimirTabulados(5); echo '<div class="tablaTituloBotones">'; imprimirTabulados(6); echo '<h2>Iniciar sesión</h2>'; imprimirTabulados(6); echo '<form action="index.php" method="post">'; imprimirTabulados(6); echo '<fieldset class="login">'; imprimirTabulados(6); $clase = array('class' => 'tablaCarga'); $tabla = new HTML_Table($clase); $tabla->setAutoGrow(true); $tabla->setHeaderContents(0, 0, 'Usuario'); $tabla->setCellContents(0, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="username" value="" />'); $tabla->setHeaderContents(1, 0, 'Contraseña'); $tabla->setCellContents(1, 1, '<input class="campoTexto campoTextoAlineado" type="password" name="password" value="" />'); $tabla->setColAttributes(0, $clase); $tabla->setColAttributes(1, $clase); echo $tabla->toHtml(); imprimirTabulados(6); echo '<br /><input type="submit" name="botonIniciarSesion" value="Iniciar sesión" >'; imprimirTabulados(6); echo '</fieldset>'; imprimirTabulados(6); echo '</form>'; imprimirTabulados(5); echo '</div>'; }
public function __construct() { parent::__construct('all_categories'); if ($this->loginError) { return; } $cat_list = pdCatList::create($this->db); echo '<h1>Publication Categories</h1>'; foreach (array_keys($cat_list) as $cat_id) { unset($fields); unset($cells); $category = new pdCategory(); $result = $category->dbLoad($this->db, $cat_id); assert('$result'); $table = new HTML_Table(array('class' => 'publist')); $table->setAutoGrow(true); $cells[] = '<b>' . $category->category . '</b><br/>'; if (count($category->info) > 0) { foreach ($category->info as $info_id => $name) { $fields[] = $name; } $cells[] = 'Fields: ' . implode(', ', $fields); } else { $cells[] = ''; } if ($this->access_level > 0) { $cells[] = $this->getCategoryIcons($category); } $table->addRow($cells); $table->updateColAttributes(0, array('class' => 'category'), NULL); $table->updateColAttributes(2, array('class' => 'icons'), NULL); echo $table->toHtml(); unset($table); } }
public function __construct() { parent::__construct('aicml_staff'); if ($this->loginError) { return; } echo '<h1>AICML Staff</h1>'; $table = new HTML_Table(array('class' => 'stats')); $table->addRow(array('Name', 'Start', 'End', 'Num Pubs', 'Pub Ids')); $table->setRowType(0, 'th'); //pdDb::debugOn(); $staff_list = pdAicmlStaffList::create($this->db); foreach ($staff_list as $staff_id => $author_id) { $staff = pdAicmlStaff::newFromDb($this->db, $staff_id, pdAicmlStaff::DB_LOAD_PUBS_MIN); $author = pdAuthor::newFromDb($this->db, $author_id, pdAuthor::DB_LOAD_MIN); //debugVar('staff', array($staff, $author)); $pub_links = array(); if (isset($staff->pub_ids)) { foreach ($staff->pub_ids as $pub_id) { $pub_links[] = '<a href="../view_publication.php?pub_id=' . $pub_id . '">' . $pub_id . '</a>'; } } $table->addRow(array($author->name, $staff->start_date, $staff->end_date, count($staff->pub_ids), implode(', ', $pub_links)), array('class' => 'stats_odd')); } echo $table->toHtml(); }
public function imprimir() { // Implementada en la subclase $this->imprimirCabecera(); for ($index = 0; $index < count($this->listaHorasAsignadas); $index++) { $horasAsignadas = $this->listaHorasAsignadas[$index]; // El usuario pidio editar este horario if (isset($_REQUEST['botonEditarHoras'])) { $this->filaTablaHorasAsignadasEditar($horasAsignadas, $index); } else { // Muestra una fila ordinaria $this->filaTablaHorasAsignadas($horasAsignadas, $index); } } imprimirTabulados(6); echo $this->tabla->toHtml(); }
/** * View list * * @author John.meng * @since version1.0 - Dec 12, 2005 */ function viewList() { global $__Lang__, $FlushPHPObj, $smarty; include_once PEAR_DIR . "HTML/Table.php"; include_once PEAR_DIR . "HTML/QuickForm.php"; include_once APP_DIR . "UI.class.php"; $form =& new HTML_QuickForm(); $FilesDirsObj = $FlushPHPObj->loadUtility("FilesDirs"); $FilesDirsObj->FilesDirs(MODULE_DIR, 1, "CVS,General"); $Module_arr = $FilesDirsObj->listDirs(); asort($Module_arr); reset($Module_arr); $data = array(); $installImageObj = new UIImage(THEMES_DIR . "images/install.gif"); $unInstallImageObj = new UIImage(THEMES_DIR . "images/uninstall.gif"); if (sizeof($Module_arr)) { foreach ($Module_arr as $key => $value) { $temp_Module_arr = $FlushPHPObj->getModuleInfo($value); if (file_exists(MODULE_DIR . "/" . $temp_Module_arr['name'] . "/" . $temp_Module_arr['logo']) && $temp_Module_arr['logo']) { $ModuleImageLogo = new UIImage(MODULE_DIR . "/" . $temp_Module_arr['name'] . "/" . $temp_Module_arr['logo']); $Module_logo = $ModuleImageLogo->toHTML() . "<br/>"; } $data[$key] = array($Module_logo . $temp_Module_arr['name'] . " <b> " . $temp_Module_arr['version'] . " <b/> ", $temp_Module_arr['description'], $temp_Module_arr['author'], $unInstallImageObj->toHTML() . "<br/>" . $__Lang__['langGeneralUnInstall'], $installImageObj->toHTML() . "<br/>" . $__Lang__['langGeneralInstall']); } } $tableAttrs = array("class" => "grid_table"); $table = new HTML_Table($tableAttrs); $table->setAutoGrow(true); $table->setAutoFill("n/a"); for ($nr = 0; $nr < count($data); $nr++) { $table->setHeaderContents($nr + 1, 0, (string) $nr); for ($i = 0; $i < 5; $i++) { if ("" != $data[$nr][$i]) { $table->setCellContents($nr + 1, $i + 1, $data[$nr][$i]); } } } $table->setColAttributes(3, array(" align" => "center")); $table->setColAttributes(4, array(" align" => "center")); $table->setColAttributes(5, array(" align" => "center")); $altRow = array("class" => "grid_table_tr_alternate"); $table->altRowAttributes(1, null, $altRow); $table->setHeaderContents(0, 0, ""); $table->setHeaderContents(0, 1, $__Lang__['langMenuModule']); $table->setHeaderContents(0, 2, $__Lang__['langGeneralSummary']); $table->setHeaderContents(0, 3, $__Lang__['langGeneralAuthor']); $table->setHeaderContents(0, 4, $__Lang__['langGeneralStatus']); $table->setHeaderContents(0, 5, $__Lang__['langGeneralOperation']); $hrAttrs = array("class" => "grid_table_head"); $table->setRowAttributes(0, $hrAttrs, true); $table->setColAttributes(0, $hrAttrs); $smarty->assign("Main", $table->toHtml()); }
private function pubByYears() { $pub_years = pdPubList::create($this->db, array('year_list' => true)); if (empty($pub_years) || count($pub_years) == 0) { return; } $table = new HTML_Table(array('class' => 'nomargins', 'width' => '60%')); $text = ''; foreach (array_values($pub_years) as $item) { $text .= '<a href="list_publication.php?year=' . $item['year'] . '">' . $item['year'] . '</a> '; } $table->addRow(array($text)); echo '<h2>Publications by Year:</h2>', $table->toHtml(); }
public function __construct() { parent::__construct('auth_success', 'Authorization Success', 'Admin/auth_success.php'); if ($this->loginError) { return; } echo "<h2>Authorization Successful</h2>" . "\n<p>The following users have been granted access.</p>"; $table = new HTML_Table(array('class' => 'stats')); $table->addRow(array('Access Level', 'Login', 'Name', 'Conf. Email')); $table->setRowType(0, 'th'); foreach ($_SESSION['auth_success'] as $auth) { $table->addRow(array(AccessLevel::getAccessLevelStr($auth['user']->access_level), $auth['user']->login, $auth['user']->name, $auth['email']), array('class' => 'stats_odd')); } echo $table->toHtml(); }
public function __construct() { parent::__construct('auth_error', 'Authorization Error', 'Admin/auth_error.php'); if ($this->loginError) { return; } echo "<h2>Invalid Access Level</h2>" . "\n<p>The following users have incorrect access level.</p>"; $table = new HTML_Table(array('class' => 'stats')); $table->addRow(array('Access Level', 'Login', 'Name')); $table->setRowType(0, 'th'); foreach ($_SESSION['auth_errors'] as $auth_err) { $table->addRow(array(AccessLevel::getAccessLevelStr($auth_err['access']), $auth_err['user']->login, $auth_err['user']->name), array('class' => 'stats_odd')); } echo $table->toHtml(); echo '<p><a href="authorize_new_users.php">Authorize new users</a></p>'; }
public function __construct() { parent::__construct('bibtex', null, false); if ($this->loginError) { return; } $this->loadHttpVars(); if (!isset($this->pub_ids)) { $this->pageError = true; return; } $pubs = explode(',', $this->pub_ids); if (!is_array($pubs) || count($pubs) == 0) { $this->pageError = true; return; } $pub_list = pdPubList::create($this->db, array('pub_ids' => $pubs)); if (!is_array($pub_list) || count($pub_list) == 0) { $this->pageError = true; return; } $table = new HTML_Table(array('width' => '100%', 'border' => '0', 'cellpadding' => '0', 'cellspacing' => '0')); $table->setAutoGrow(true); $pub_count = 0; foreach ($pub_list as $pub) { $pub_count++; $result = $pub->dbLoad($this->db, $pub->pub_id); if ($result === false) { $this->pageError = true; return; } $table->addRow(array('<pre>' . $pub->getBibtex() . '</pre>')); } // now assign table attributes including highlighting for even and odd // rows for ($i = 0; $i < $table->getRowCount(); $i++) { if ($i & 1) { $table->updateRowAttributes($i, array('class' => 'even'), true); } else { $table->updateRowAttributes($i, array('class' => 'odd'), true); } } $table->updateColAttributes(0, array('class' => 'publist'), true); echo $table->toHtml(); }
public function __construct() { parent::__construct('all_authors'); if ($this->loginError) { return; } $this->loadHttpVars(true, false); if (!isset($this->tab)) { $this->tab = 'A'; } else { $tab = strtoupper($this->tab); if (strlen($tab) != 1 || ord($tab) < ord('A') || ord($tab) > ord('Z')) { $this->pageError = true; return; } } $auth_list = pdAuthorList::create($this->db, null, $this->tab); echo $this->alphaSelMenu($this->tab, get_class($this) . '.php'); echo "<h2>Authors</h2>"; if (empty($auth_list) || count($auth_list) == 0) { echo 'No authors with last name starting with ', $this->tab, '<br/>'; return; } foreach ($auth_list as $author_id => $name) { $author = new pdAuthor(); $author->dbLoad($this->db, $author_id, pdAuthor::DB_LOAD_BASIC | pdAuthor::DB_LOAD_PUBS_MIN); $name = '<span class="emph"><a href="view_author.php?author_id=' . $author_id . '">' . $name . '</a> '; $icons = $this->getAuthorIcons($author) . '</span>'; $info = array(); if ($author->title != '') { $info[] = '<span class="small">' . $author->title . '</span>'; } if ($author->organization != '') { $info[] = '<span class="small">' . $author->organization . '</span>'; } $info[] .= '<a href="list_publication.php?author_id=' . $author_id . '&menu=0"><span class="small" style="color:#000;font-weight:normal;">' . 'Publication entries in database: ' . $author->totalPublications . '</span>'; $table = new HTML_Table(array('class' => 'publist')); $table->addRow(array($name . '<br/>' . implode('<br/>', $info), $icons)); $table->updateColAttributes(1, array('class' => 'icons'), NULL); echo $table->toHtml(); unset($table); } }
if ($current_access_url_id == $url_info['access_url_id']) { $add_user = false; } $access_info_to_string .= $url_info['url'] . '<br />'; } } if ($add_user) { $row_table = array(); $row_table[] = api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ') '; $row_table[] = $access_info_to_string; $url = api_get_self() . '?action=add_user_to_my_url&user_id=' . $user['id'] . '&sec_token=' . $_SESSION['sec_token']; $row_table[] = Display::url(get_lang('AddUserToMyURL'), $url, array('class' => 'btn')); foreach ($row_table as $cell) { $table->setCellContents($row, $column, $cell); $table->updateCellAttributes($row, $column, 'align="center"'); $column++; } $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true); $row++; } } $extra_search_options .= $table->toHtml(); $table_result = ''; } } } $tpl = new Template($tool_name); $tpl->assign('actions', $actions); $tpl->assign('message', $message); $tpl->assign('content', $form . $table_result . $extra_search_options); $tpl->display_one_col_template();
$table->setCellAttributes($row, $column, array('width' => '300px')); $column++; $table->setCellContents($row, $column, $userResult['sent_date']); $column++; $dateQualification = !empty($workExtraData['expires_on']) && $workExtraData['expires_on'] != '0000-00-00 00:00:00' ? api_get_local_time($workExtraData['expires_on']) : '-'; $table->setCellContents($row, $column, $dateQualification); $column++; $score = '-'; if (!empty($scoreWeight)) { $score = strip_tags($userResult['qualification']) . "/" . $scoreWeight; } $table->setCellContents($row, $column, $score); $column++; // Actions $links = null; // is a text $url = api_get_path(WEB_CODE_PATH) . 'work/view.php?' . api_get_cidreq() . '&id=' . $userResult['id']; $links .= Display::url(Display::return_icon('default.png'), $url); if (!empty($userResult['url'])) { $url = api_get_path(WEB_CODE_PATH) . 'work/download.php?' . api_get_cidreq() . '&id=' . $userResult['id']; $links .= Display::url(Display::return_icon('save.png', get_lang('Download')), $url); } $url = api_get_path(WEB_CODE_PATH) . 'work/edit.php?' . api_get_cidreq() . '&item_id=' . $userResult['id'] . '&id=' . $workId . '&parent_id=' . $workId; $links .= Display::url(Display::return_icon('edit.png', get_lang('Comment')), $url); $table->setCellContents($row, $column, $links); $row++; $column = 0; } } echo $table->toHtml(); Display::display_footer();
/** * Returns a category summary report * @params int exercise id * @params array pre filled array with the category_id, score, and weight * example: array(1 => array('score' => '10', 'total' => 20)); */ public static function get_stats_table_by_attempt($exercise_id, $category_list = array()) { if (empty($category_list)) { return null; } $category_name_list = TestCategory::getListOfCategoriesNameForTest($exercise_id); $table = new HTML_Table(array('class' => 'data_table')); $table->setHeaderContents(0, 0, get_lang('Categories')); $table->setHeaderContents(0, 1, get_lang('AbsoluteScore')); $table->setHeaderContents(0, 2, get_lang('RelativeScore')); $row = 1; $none_category = array(); if (isset($category_list['none'])) { $none_category = $category_list['none']; unset($category_list['none']); } $total = array(); if (isset($category_list['total'])) { $total = $category_list['total']; unset($category_list['total']); } if (count($category_list) > 1) { foreach ($category_list as $category_id => $category_item) { $table->setCellContents($row, 0, $category_name_list[$category_id]); $table->setCellContents($row, 1, ExerciseLib::show_score($category_item['score'], $category_item['total'], false)); $table->setCellContents($row, 2, ExerciseLib::show_score($category_item['score'], $category_item['total'], true, false, true)); $row++; } if (!empty($none_category)) { $table->setCellContents($row, 0, get_lang('None')); $table->setCellContents($row, 1, ExerciseLib::show_score($none_category['score'], $none_category['total'], false)); $table->setCellContents($row, 2, ExerciseLib::show_score($none_category['score'], $none_category['total'], true, false, true)); $row++; } if (!empty($total)) { $table->setCellContents($row, 0, get_lang('Total')); $table->setCellContents($row, 1, ExerciseLib::show_score($total['score'], $total['total'], false)); $table->setCellContents($row, 2, ExerciseLib::show_score($total['score'], $total['total'], true, false, true)); } return $table->toHtml(); } return null; }
/** * Muestra el formulario para dar de alta un nuevo usuario. */ private function imprimirFormularioNuevoUsuario() { imprimirTabulados(5); echo '<div class="tablaTituloBotones">'; imprimirTabulados(6); echo '<h1>Nuevo usuario</h1>'; imprimirTabulados(6); echo '<form action="usuario.php" method="post">'; imprimirTabulados(6); echo '<fieldset>'; imprimirTabulados(6); $clase = array('class' => 'tablaCarga'); $tabla = new HTML_Table($clase); $tabla->setAutoGrow(true); $tabla->setHeaderContents(0, 0, 'Tipo de documento'); $tabla->setCellContents(0, 1, '<select class="cuadroSeleccion cuadroSeleccionAlineado" name="tipoDocumento"><option>DNI</option><option>LE</option><option>LC</option></select>'); $tabla->setHeaderContents(1, 0, 'Número de documento *'); $tabla->setCellContents(1, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="numeroDocumentoNuevo" value="" />'); $tabla->setHeaderContents(2, 0, 'Nombre *'); $tabla->setCellContents(2, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="nombre" value="" />'); $tabla->setHeaderContents(3, 0, 'Segundo nombre'); $tabla->setCellContents(3, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="segundoNombre" value="" />'); $tabla->setHeaderContents(4, 0, 'Apellido *'); $tabla->setCellContents(4, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="apellido" value="" />'); $tabla->setHeaderContents(5, 0, 'Fecha de nacimiento *'); $tabla->setCellContents(5, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="fechaNacimiento" value="DD-MM-AAAA" />'); $tabla->setHeaderContents(6, 0, 'Dirección *'); $tabla->setCellContents(6, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="direccion" value="" />'); $tabla->setHeaderContents(7, 0, 'Teléfono fijo'); $tabla->setCellContents(7, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="telefonoFijo" value="" />'); $tabla->setHeaderContents(8, 0, 'Teléfono celular'); $tabla->setCellContents(8, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="telefonoCelular" value="" />'); $tabla->setHeaderContents(9, 0, 'E-mail *'); $tabla->setCellContents(9, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="email" value="" />'); $tabla->setHeaderContents(10, 0, 'Legajo *'); $tabla->setCellContents(10, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="legajo" value="" />'); $tabla->setHeaderContents(11, 0, 'Área *'); $tabla->setCellContents(11, 1, $this->mostrarAreasMultipleSeleccion()); $tabla->setHeaderContents(12, 0, 'Tipo de usuario'); $tabla->setCellContents(12, 1, $this->mostrarNiveles()); $tabla->setHeaderContents(13, 0, 'Activo'); $tabla->setCellContents(13, 1, '<select class="cuadroSeleccionAlineado" name="activo"><option value="1">Si</option><option value="0">No</option></select>'); $tabla->setHeaderContents(14, 0, 'Notas'); $tabla->setCellContents(14, 1, '<textarea class="areaTexto" name="notas" rows="4" cols="20"></textarea>'); $tabla->setColAttributes(0, $clase); $tabla->setColAttributes(1, $clase); echo $tabla->toHtml(); imprimirTabulados(6); echo '<br /><input type="submit" name="enviarNuevoUsuario" value="Enviar" >'; imprimirTabulados(6); echo '</fieldset>'; imprimirTabulados(6); echo '</form>'; imprimirTabulados(6); echo '<div class="notas">'; imprimirTabulados(7); echo '<p>(*) Campos obligatorios</p>'; imprimirTabulados(6); echo '</div>'; imprimirTabulados(5); echo '</div>'; }
public function pubSelect($viewCat = null) { assert('is_object($this->db)'); echo $this->pubSelMenu($viewCat), '<br/>'; $text = ''; switch ($viewCat) { case "year": $pub_years = pdPubList::create($this->db, array('year_list' => true)); echo '<h2>Publications by Year:</h2>'; if (count($pub_years) > 0) { $table = new HTML_Table(array('class' => 'nomargins', 'width' => '100%')); $table->addRow(array('Year', 'Num. Publications'), array('class' => 'emph')); foreach (array_values($pub_years) as $item) { $cells = array(); $cells[] = '<a href="list_publication.php?year=' . $item['year'] . '">' . $item['year'] . '</a>'; $cells[] = $item['count']; $table->addRow($cells); } echo $table->toHtml(); } else { echo 'No publication entries.'; } break; case 'author': echo '<h2>Publications by Author:</h2>'; $al = pdAuthorList::create($this->db); for ($c = 65; $c <= 90; ++$c) { $table = new HTML_Table(array('class' => 'publist')); $text = ''; foreach ($al as $auth_id => $name) { if (substr($name, 0, 1) == chr($c)) { $text .= '<a href="list_publication.php?author_id=' . $auth_id . '">' . $name . '</a> '; } } $table->addRow(array(chr($c), $text)); $table->updateColAttributes(0, array('class' => 'item'), NULL); echo $table->toHtml(); } break; case 'venue': // publications by keyword unset($table); $vl = pdVenueList::create($this->db); echo '<h2>Publications by Venue:</h2>'; for ($c = 65; $c <= 90; ++$c) { $table = new HTML_Table(array('class' => 'publist')); $text = ''; foreach ($vl as $vid => $v) { if (substr($v, 0, 1) == chr($c)) { $text .= '<a href="list_publication.php?venue_id=' . $vid . '">' . $v . '</a> '; } } $table->addRow(array(chr($c), $text)); $table->updateColAttributes(0, array('class' => 'item'), NULL); echo $table->toHtml(); } break; case 'category': $table = new HTML_Table(array('class' => 'nomargins', 'width' => '100%')); $cl = pdCatList::create($this->db); $table->addRow(array('Category', 'Num. Publications'), array('class' => 'emph')); foreach ($cl as $cat_id => $category) { $cells = array(); $cells[] = '<a href="list_publication.php?cat_id=' . $cat_id . '">' . $category . '</a><br/>'; $cells[] = pdCatList::catNumPubs($this->db, $cat_id); $table->addRow($cells); } echo '<h2>Publications by Category:</h2>', $table->toHtml(); break; case 'keywords': // publications by keyword unset($table); $kl = pdPubList::create($this->db, array('keywords_list' => true)); echo '<h2>Publications by Keyword:</h2>'; for ($c = 65; $c <= 90; ++$c) { $table = new HTML_Table(array('class' => 'publist')); $text = ''; foreach ($kl as $kw) { if (substr($kw, 0, 1) == chr($c)) { $text .= '<a href="list_publication.php?keyword=' . $kw . '">' . $kw . '</a> '; } } $table->addRow(array(chr($c), $text)); $table->updateColAttributes(0, array('class' => 'item'), NULL); echo $table->toHtml(); } break; default: $this->pageError = true; } }
function manage_display($task) { global $cfg, $db, $cache; if ($task == '') { $task = 'status'; } // Verify that the user has management perms for the selected contest $res =& db_query('contest_by_id', $_GET['id']); $res->fetchInto($row); $res->free(); if ($_SESSION['user_id'] != $row['manager'] && !auth_user_in_group('Administrators')) { error("Access denied. You are not the contest-manager for this contest."); } switch ($task) { case 'status': $table = new HTML_Table(); // Re-use $row from above if ($row['show_future'] == 1) { $status = 'Hidden (not activated yet)'; } else { if ($row['begin_future'] == 1) { $status = 'Not started'; } else { if ($row['end_future'] == 1) { $status = 'Running'; } else { $status = 'Ended'; } } } $table->addRow(array('Contest status: ', $status), null, 'TH'); $table->addRow(array('Name: ', $row['name'])); $table->addRow(array('Description: ', $row['description'])); $table->addRow(array('Activation time: ', $row['show_time'])); $table->addRow(array('Begin time: ', $row['begin_time'])); $table->addRow(array('End time: ', $row['end_time'])); if ($row['team_size'] != 1) { $table->addRow(array('Max size of team: ', $row['team_size'])); $prefix = 'Teams'; } else { $table->addRow(array('Individual event: ', 'Yes')); $prefix = 'Participants'; } // No. of registered teams $res =& db_query('count_teams_by_contest_id', $_GET['id']); $res->fetchInto($row); $res->free(); $table->addRow(array($prefix . ' registered: ', $row['count'])); // No. of teams logged in $res =& db_query('count_last_teams_by_contest_id', $_GET['id']); $res->fetchInto($row); $res->free(); $table->addRow(array($prefix . ' seen in last 30 minutes: ', $row['count'])); $table->altRowAttributes(1, null, array("class" => "altrow")); echo '<div class="overflow">' . $table->toHtml() . '</div>'; break; case 'problems': // display problem info as table $table = new HTML_Table(); $res =& db_query('problems_by_contest_id', $_GET['id']); if (!$res->fetchInto($row)) { ?> <p>No problems added yet.</p> <?php } else { // extra attributes $row['content'] = null; $row['actions'] = null; $table->addRow(array_keys($row), null, 'TH'); while ($row) { $row['content'] = "<a href=\"index.php?view=manage&task=show_problem&id={$_GET['id']}&prob_id={$row['prob_id']}\">show</a>"; $row['actions'] = "<a href=\"index.php?view=manage&task=edit_problem&id={$_GET['id']}&prob_id={$row['prob_id']}\">edit</a>, " . "<a href=\"index.php?view=manage&task=del_problem&id={$_GET['id']}&prob_id={$row['prob_id']}\">delete</a>"; $table->addRow(array_values($row)); $res->fetchInto($row); } $res->free(); // display tables $table->altRowAttributes(1, null, array("class" => "altrow")); echo '<div class="overflow">' . $table->toHtml() . '</div>'; } echo "<hr />"; // form for adding a problem $form = new HTML_QuickForm('problemAddForm', 'post', selflink()); $form->addElement('header', null, 'Add a problem'); $form->addElement('text', 'prob_id', 'Name (one word ID): '); $form->addElement('text', 'summary', 'Summary: '); $form->addElement('text', 'weight', 'Points weightage: '); $form->addElement('text', 'time_limit', 'Time limit: '); $form->addElement('text', 'mem_limit', 'Memory limit: '); $elem =& $form->addElement('textarea', 'content', 'Problem content (XML): '); $elem->setRows(10); $elem->setCols(80); $form->addElement('submit', null, 'Submit'); $form->applyFilter('prob_id', 'trim'); $form->applyFilter('summary', 'trim'); $form->applyFilter('weight', 'trim'); $form->applyFilter('time_limit', 'trim'); $form->applyFilter('mem_limit', 'trim'); $form->addRule('prob_id', 'Problem ID is required', 'required', null, 'client'); $form->addRule('summary', 'Problem summary is required', 'required', null, 'client'); $form->addRule('weight', 'Points weightage is required', 'required', null, 'client'); $form->addRule('time_limit', 'Time limit is required', 'required', null, 'client'); $form->addRule('mem_limit', 'Memory limit is required', 'required', null, 'client'); $form->addRule('content', 'Problem content in XML is required', 'required', null, 'client'); if ($form->validate()) { $data = $form->getSubmitValues(); $errs = problem_check($data['content']); if ($errs == null) { $data['contest_id'] = $_GET['id']; $res =& $db->autoExecute('problems', $data, DB_AUTOQUERY_INSERT); if (PEAR::isError($res)) { error($res->toString()); } $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.htm'); $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.prob'); redirect('index.php?view=manage&task=problems&id=' . $_GET['id']); } else { ?> <p><b>Error:</b> The problem could not be added due to the following errors encountered while parsing the problem XML file. Please fix them and try submitting again.</p> <?php echo "<ol class=\"errors\">\n"; foreach ($errs as $line) { echo "<li>{$line}</li>\n"; } echo "</ol>\n<hr />\n"; } } $form->display(); break; case 'del_problem': db_query('del_problem_by_id', array($_GET['prob_id'], $_GET['id'])); redirect('index.php?view=manage&task=problems&id=' . $_GET['id']); break; case 'edit_problem': $res =& db_query('problem_by_id', array($_GET['prob_id'], $_GET['id'])); $res->fetchInto($row); $res->free(); // Get XML content too $res =& db_query('problem_content_by_id', array($_GET['prob_id'], $_GET['id'])); $res->fetchInto($row2); $res->free(); $row['content'] =& $row2['content']; // form for editing a problem $form = new HTML_QuickForm('problemAddForm', 'post', selflink()); $form->addElement('header', null, 'Edit a problem'); $form->addElement('text', 'prob_id', 'Name (one word ID): '); $form->addElement('text', 'summary', 'Summary: '); $form->addElement('text', 'weight', 'Points weightage: '); $form->addElement('text', 'time_limit', 'Time limit: '); $form->addElement('text', 'mem_limit', 'Memory limit: '); $elem =& $form->addElement('textarea', 'content', 'Problem content (XML): '); $elem->setRows(10); $elem->setCols(80); $form->addElement('submit', null, 'Submit'); $form->applyFilter('prob_id', 'trim'); $form->applyFilter('summary', 'trim'); $form->applyFilter('weight', 'trim'); $form->applyFilter('time_limit', 'trim'); $form->applyFilter('mem_limit', 'trim'); $form->addRule('prob_id', 'Problem ID is required', 'required', null, 'client'); $form->addRule('summary', 'Problem summary is required', 'required', null, 'client'); $form->addRule('weight', 'Points weightage is required', 'required', null, 'client'); $form->addRule('time_limit', 'Time limit is required', 'required', null, 'client'); $form->addRule('mem_limit', 'Memory limit is required', 'required', null, 'client'); $form->addRule('content', 'Problem content in XML is required', 'required', null, 'client'); $form->setDefaults($row); if ($form->validate()) { $data = $form->getSubmitValues(); $errs = problem_check($data['content']); if ($errs == null) { //$data['contest_id'] = $_GET['id']; $data['version'] = $row['version'] + 1; // increment version $res =& $db->autoExecute('problems', $data, DB_AUTOQUERY_UPDATE, 'contest_id=' . $_GET['id'] . " AND prob_id='" . $data['prob_id'] . "'"); if (PEAR::isError($res)) { error($res->toString()); } $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.htm'); $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.prob'); redirect('index.php?view=manage&task=problems&id=' . $_GET['id']); } else { ?> <p><b>Error:</b> The changes could not be saved due to the following errors encountered while parsing the problem XML file. Please fix them and try submitting again.</p> <?php echo "<ol class=\"errors\">\n"; foreach ($errs as $line) { echo "<li>{$line}</li>\n"; } echo "</ol>\n<hr />\n"; } } $form->display(); break; case 'show_problem': $res =& db_query('problem_by_id', array($_GET['prob_id'], $_GET['id'])); $res->fetchInto($problem); $res->free(); problem_display($problem); break; case 'settings': // Re-using $row from above // form for editing the contest $form = new HTML_QuickForm('contestEditForm', 'post', selflink()); $form->addElement('header', null, "Edit contest {$row['name']} (id: {$row['contest_id']})"); $form->addElement('text', 'name', 'Name: '); $form->addElement('text', 'description', 'Description: '); $elem =& $form->addElement('text', 'team_size', 'Size of team: '); $elem->setValue('1'); $date = getdate(); $form->addElement('date', 'show_time', 'Activation time: ', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5)); $form->addElement('date', 'begin_time', 'Begin time: ', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5)); $form->addElement('date', 'end_time', 'End time: ', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5)); $form->addElement('text', 'rules', 'Rules URL: '); $form->addElement('submit', null, 'Submit'); // convert date format and store default values $row['show_time'] = sql2form_datetime($row['show_time']); $row['begin_time'] = sql2form_datetime($row['begin_time']); $row['end_time'] = sql2form_datetime($row['end_time']); $form->setDefaults($row); $form->applyFilter('name', 'trim'); $form->applyFilter('description', 'trim'); $form->applyFilter('team_size', 'trim'); $form->addRule('name', 'Contest name is required.', 'required', null, 'client'); $form->addRule('team_size', 'Team size is required.', 'required', null, 'client'); // validate or display form if ($form->validate()) { $data = $form->getSubmitValues(); $data['show_time'] = form2sql_datetime($data['show_time']); $data['begin_time'] = form2sql_datetime($data['begin_time']); $data['end_time'] = form2sql_datetime($data['end_time']); $db->autoExecute('contests', $data, DB_AUTOQUERY_UPDATE, 'contest_id=' . $_GET['id']); if (PEAR::isError($res)) { error($db->toString()); } redirect('index.php?view=manage&id=' . $_GET['id']); } else { $form->display(); } break; case 'submissions': // Re-use $row from above if ($row['end_future'] != '1') { // Contest has ended, show system test button if ($row['tested'] != 1) { ?> <p>Contest has ended. <a class="button" href="index.php?view=manage&&task=test&updateratings=false&id=<?php echo $_GET['id']; ?> ">Test and grade all submissions.</a> <a class="button" href="index.php?view=manage&task=test&updateratings=true&id=<?php echo $_GET['id']; ?> ">Update Ratings</a> </p> <?php } else { ?> <p>Contest has ended and system tests are over. <a class="button" href="index.php?view=manage&task=test&id=<?php echo $_GET['id']; ?> ">Re-run system tests.</a> </p> <?php } } // Show table of all solutions in the contest $table = new HTML_Table(); $res =& db_query('solutions_by_contest_id', $_GET['id']); if (!$res->fetchInto($row)) { // If no solutions in yet ?> <p>Sorry, no solutions have been submitted yet.</p> <?php } else { $table->addRow(array_keys($row), null, 'TH'); if ($row['score'] == '') { $row['score'] = 'n/a'; } if ($row['passed'] == '') { $row['passed'] = 'n/a'; } $table->addRow(array_values($row)); while ($res->fetchInto($row)) { if ($row['score'] == '') { $row['score'] = 'n/a'; } if ($row['passed'] == '') { $row['passed'] = 'n/a'; } $table->addRow(array_values($row)); } $table->altRowAttributes(1, null, array("class" => "altrow")); echo '<div class="overflow">' . $table->toHtml() . '</div>'; } break; case 'test': require_once 'tester.php'; ob_end_clean(); html_reset(); html_header(null, $cfg["dir"]["themes"] . '/' . $_SESSION["theme"] . '.css', $cfg["dir"]["themes"] . '/' . $_SESSION["theme"] . '-ie.css', null, "submit_frame"); $contest_id = $_GET['id']; $update_ratings = $_GET['updateratings']; session_write_close(); test_contest($update_ratings, $contest_id); echo ' <a class="white" href="index.php?view=statistics&task=contest&id=' . $_GET['id'] . '">See the results.</a>'; html_footer(); exit; } }
function admin_display($task) { global $db, $cfg; if ($task == NULL) { $task = 'contests'; } switch ($task) { case 'users': $table = new HTML_Table(); $res =& db_query('users_list'); $res->fetchInto($row); // add users table headers $headers = array_keys($row); array_push($headers, 'groups'); array_push($headers, 'actions'); $table->addRow($headers, null, 'TH'); // add user records while ($row) { $res2 =& db_query('groups_by_user_id', $row['user_id']); // get list of gourps for this user $groups = ''; $res2->fetchInto($row2); while ($row2) { $groups .= $row2['name']; if ($res2->fetchInto($row2)) { $groups .= ', '; } } $res2->free(); array_push($row, $groups); // actions array_push($row, "<a href=\"index.php?view=admin&task=edit_user&id={$row['user_id']}\">edit</a>" . ", <a href=\"index.php?view=admin&task=del_user&id={$row['user_id']}\">delete</a>"); $table->addRow(array_values($row)); $res->fetchInto($row); } $res->free(); $table->altRowAttributes(1, null, array("class" => "altrow")); echo '<div class="overflow">' . $table->toHtml() . '</div>'; break; case 'del_user': db_query('del_user_by_id', $_GET['id']); db_query('del_user_perms_by_id', $_GET['id']); redirect('index.php?view=admin&task=users'); break; case 'edit_user': // user id to edit given as arg $res =& db_query('groups_by_user_id', $_GET['id']); // get list of all groups for this user $user_groups = array(); while ($res->fetchInto($row)) { array_push($user_groups, $row['group_id']); } $res->free(); // get hanndle of user $res =& db_query('user_by_id', $_GET['id']); $res->fetchInto($row); $handle = $row['handle']; $res->free(); $form = new HTML_QuickForm('userForm', 'post', 'index.php?view=admin&task=edit_user&id=' . $_GET['id']); $form->addElement('header', null, 'Groups for user ' . $handle . ' (id: ' . $_GET['id'] . ')'); // get list of all available groups $res =& db_query('groups_list'); // add checkbox for each group $groups = array(); while ($res->fetchInto($row)) { $elem =& $form->addElement('checkbox', $row['group_id'], $row['name']); if (in_array($row['group_id'], $user_groups)) { $elem->setChecked(true); } $groups[$row['group_id']] = $row['name']; } $res->free(); $form->addElement('submit', 'submit', 'Apply Changes'); if ($form->validate()) { $data = $form->getSubmitValues(); foreach ($groups as $gid => $name) { $elem =& $form->getElement($gid); if ($data[$gid] == 1) { auth_set_perm($_GET['id'], $gid); $elem->setChecked(true); } else { auth_clear_perm($_GET['id'], $gid); $elem->setChecked(false); } } } $form->display(); break; case 'groups': $table = new HTML_Table(); $res =& db_query('groups_list'); $res->fetchInto($row); // add groups table header $headers = array_keys($row); array_push($headers, 'views'); array_push($headers, 'actions'); $table->addRow($headers, null, 'TH'); // add group records while ($row) { $res2 =& db_query('views_by_group_id', $row['group_id']); // get list of views allowed for this group $views = ''; $res2->fetchInto($row2); while ($row2) { $views .= $row2['view']; if ($res2->fetchInto($row2)) { $views .= ', '; } } $res2->free(); array_push($row, $views); array_push($row, "<a href=\"index.php?view=admin&task=edit_group&id={$row['group_id']}\">edit</a>" . ", <a href=\"index.php?view=admin&task=del_group&id={$row['group_id']}\">delete</a>"); $table->addRow(array_values($row)); $res->fetchInto($row); } $res->free(); // decor $table->altRowAttributes(1, null, array("class" => "altrow")); echo '<div class="overflow">' . $table->toHtml() . '</div>'; echo "<hr />"; // form for adding a group $form = new HTML_QuickForm('addGroupForm', 'post', 'index.php?view=admin&task=groups'); $form->addElement('header', null, 'Add a group'); $form->addElement('text', 'name', 'Name: '); $form->addElement('submit', null, 'Submit'); $form->applyFilter('name', 'trim'); $form->addRule('name', 'Group name is required.', 'required', null, 'client'); if ($form->validate()) { $res =& $db->autoExecute('groups', $form->getSubmitValues(), DB_AUTOQUERY_INSERT); if (PEAR::isError($res)) { error($db->toString()); } redirect('index.php?view=admin&task=groups'); } $form->display(); break; case 'del_group': db_query('del_group_by_id', $_GET['id']); redirect('index.php?view=admin&task=groups'); break; case 'edit_group': // get list of views allowed for this group $group_views = array(); $res =& db_query('views_by_group_id', $_GET['id']); while ($res->fetchInto($row)) { array_push($group_views, $row['view']); } $res->free(); // get name of group $res =& db_query('group_by_id', $_GET['id']); $res->fetchInto($row); $name = $row['name']; $res->free(); $form = new HTML_QuickForm('groupForm', 'post', 'index.php?view=admin&task=edit_group&id=' . $_GET['id']); $form->addElement('header', null, 'Views for group ' . $name . ' (id: ' . $_GET['id'] . ')'); // get list of all available views $view_paths = glob($cfg['dir']['views'] . '/*.php'); $views = array(); // create the checkboxes, add each view to $views for later checking foreach ($view_paths as $path) { $tmp = explode('.', basename($path)); $elem =& $form->addElement('checkbox', $tmp[0], $tmp[0]); if (in_array($tmp[0], $group_views)) { $elem->setChecked(true); } array_push($views, $tmp[0]); } $form->addElement('submit', 'submit', 'Apply Changes'); if ($form->validate()) { $data = $form->getSubmitValues(); foreach ($views as $view) { $elem =& $form->getElement($view); if ($data[$view] == 1) { auth_set_view($_GET['id'], $view); $elem->setChecked(true); } else { auth_clear_view($_GET['id'], $view); $elem->setChecked(false); } } } $form->display(); break; case 'views': $table = new HTML_Table(); $table->addRow(array('name', 'path'), null, 'TH'); // display list of views $view_paths = glob($cfg['dir']['views'] . '/*.php'); foreach ($view_paths as $path) { $tmp = explode('.', basename($path)); $table->addRow(array($tmp[0], $path)); } $table->altRowAttributes(1, null, array("class" => "altrow")); echo '<div class="overflow">' . $table->toHtml() . '</div>'; ?> <p>To add a view, just drop a .php view-module file inside the views directory. You can remove a view by deleting or renaming the corresponding file inside the views directory. </p> <?php break; case 'contests': $table = new HTML_Table(); $res =& db_query('contests_list'); $res->fetchInto($row); if ($row) { // add contests table headers $headers = array_keys($row); array_push($headers, 'actions'); $table->addRow($headers, null, 'TH'); // add contests table records while ($row) { // Get the handle of the manager for displaying $manager_name = '[none]'; $res2 =& $db->query($cfg['sql']['user_by_id'], $row['manager']); if (!PEAR::isError($res2)) { $res2->fetchInto($row2); $manager_name = $row2['handle']; $res2->free(); } $row['manager'] = $manager_name; // add edit,delete actions $row['actions'] = "<a href=\"index.php?view=admin&task=edit_contest&id={$row['contest_id']}\">edit</a>, " . "<a href=\"index.php?view=admin&task=del_contest&id={$row['contest_id']}\">delete</a>"; $table->addRow(array_values($row)); $res->fetchInto($row); } $res->free(); // decoration $table->altRowAttributes(1, null, array("class" => "altrow")); echo '<div class="overflow">' . $table->toHtml() . '</div>'; } else { ?> <p>No contests added yet.</p> <?php } echo "<hr />"; // get list of all available managers $res =& db_query('users_by_group_name', 'Managers'); while ($res->fetchInto($row)) { $managers[$row['user_id']] = $row['handle']; } // form for adding a contest $form = new HTML_QuickForm('contestAddForm', 'post', selflink()); $form->addElement('header', null, 'Add a contest'); $form->addElement('text', 'name', 'Name:'); $form->addElement('text', 'description', 'Description:'); $elem =& $form->addElement('text', 'team_size', 'Size of team:'); $form->addElement('select', 'division', 'Division:', $cfg['tcl']['divisions']); $elem->setValue('1'); $date = getdate(); $form->addElement('date', 'show_time', 'Activation time:', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5)); $form->addElement('date', 'begin_time', 'Begin time:', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5)); $form->addElement('date', 'end_time', 'End time:', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5)); $form->addElement('select', 'manager', 'Contest manager:', $managers); $form->addElement('submit', null, 'Submit'); $form->applyFilter('name', 'trim'); $form->applyFilter('description', 'trim'); $form->applyFilter('team_size', 'trim'); $form->addRule('name', 'Contest name is required.', 'required', null, 'client'); $form->addRule('manager', 'Contest manager is required.', 'required', null, 'client'); $form->addRule('team_size', 'Team size is required.', 'required', null, 'client'); // validate or display form if ($form->validate()) { $data = $form->getSubmitValues(); $data['show_time'] = form2sql_datetime($data['show_time']); $data['begin_time'] = form2sql_datetime($data['begin_time']); $data['end_time'] = form2sql_datetime($data['end_time']); $db->autoExecute('contests', $data, DB_AUTOQUERY_INSERT); if (PEAR::isError($res)) { error($db->toString()); } redirect('index.php?view=admin&task=contests'); } else { $form->display(); } break; case 'del_contest': $res =& db_query('del_contest_by_id', $_GET['id']); redirect('index.php?view=admin&task=contests'); break; case 'edit_contest': // contest to edit given as arg $res =& db_query('contest_by_id', $_GET['id']); $res->fetchInto($row); $res->free(); // get list of all available managers $res =& db_query('users_by_group_name', 'Managers'); while ($res->fetchInto($row2)) { $managers[$row2['user_id']] = $row2['handle']; } // form for editing the contest $form = new HTML_QuickForm('contestEditForm', 'post', selflink()); $form->addElement('header', null, "Edit contest {$row['name']} (id: {$row['contest_id']})"); $form->addElement('text', 'name', 'Name:'); $form->addElement('text', 'description', 'Description:'); $elem =& $form->addElement('text', 'team_size', 'Size of team:'); $elem->setValue('1'); $form->addElement('select', 'division', 'Division:', $cfg['tcl']['divisions']); $date = getdate(); $form->addElement('date', 'show_time', 'Activation time:', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5)); $form->addElement('date', 'begin_time', 'Begin time:', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5)); $form->addElement('date', 'end_time', 'End time:', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5)); $form->addElement('select', 'manager', 'Contest manager:', $managers); $form->addElement('text', 'rules', 'Rules URL:'); $form->addElement('submit', null, 'Submit'); // convert date format and dtore default values $row['show_time'] = sql2form_datetime($row['show_time']); $row['begin_time'] = sql2form_datetime($row['begin_time']); $row['end_time'] = sql2form_datetime($row['end_time']); $form->setDefaults($row); $form->applyFilter('name', 'trim'); $form->applyFilter('description', 'trim'); $form->applyFilter('team_size', 'trim'); $form->addRule('name', 'Contest name is required.', 'required', null, 'client'); $form->addRule('manager', 'Contest manager is required.', 'required', null, 'client'); $form->addRule('team_size', 'Team size is required.', 'required', null, 'client'); // validate or display form if ($form->validate()) { $data = $form->getSubmitValues(); $data['show_time'] = form2sql_datetime($data['show_time']); $data['begin_time'] = form2sql_datetime($data['begin_time']); $data['end_time'] = form2sql_datetime($data['end_time']); $db->autoExecute('contests', $data, DB_AUTOQUERY_UPDATE, 'contest_id=' . $_GET['id']); if (PEAR::isError($res)) { error($db->toString()); } redirect('index.php?view=admin&task=contests'); } else { $form->display(); } break; case 'shell': $form = new HTML_QuickForm('shellForm', 'post', selflink()); $field =& $form->addElement('text', 'command', 'Command:'); $field->setSize(100); $ifield =& $form->addElement('textarea', 'input', 'Standard Input:'); $ifield->setRows(10); $ifield->SetCols(80); $form->addElement('submit', null, 'Submit'); $form->display(); if ($form->validate()) { // Write std input file $iname = tempnam("/tmp", "in"); $ifile = fopen($iname, 'w'); fwrite($ifile, $form->getSubmitValue('input')); fclose($ifile); $cmd = $form->getSubmitValue('command'); echo "<pre class=\"shell_output\">"; echo "<b>\$ " . html_escape($cmd) . "</b>\n"; exec("{$cmd} 2>&1 < {$iname}", $out, $ret); foreach ($out as $line) { echo html_escape($line) . "\n"; } echo "</pre>\n"; echo "<p>Command returned: {$ret}</p>\n"; } break; case 'uploader': // Get list of directories to which files can be uploaded $dirs = subdir_list('.'); array_unshift($dirs, './'); $form = new HTML_QuickForm('uploaderForm', 'post', selflink()); $form->addElement('header', null, 'Upload a File:'); $file =& $form->addElement('file', 'file', 'File:'); $form->addElement('select', 'dir', 'Destination:', $dirs); $form->addElement('submit', 'upload', 'Upload'); $form->addRule('file', 'Please select file to upload.', 'required', null, 'client'); $form->setMaxFileSize(10485760); // try 10 MB max file size if ($form->validate()) { if ($file->isUploadedFile()) { $dir = $dirs[$form->getSubmitValue('dir')]; if ($file->moveUploadedFile($dir)) { echo "<p>File uploaded successfully to {$dir}.</p>"; } else { echo "<p>Failed to save uploaded file to {$dir} (insufficient permissions?).</p>"; } } else { echo "<p>File upload did not finish successfully</p>"; } } $form->display(); echo "<p><b>Note:</b> Any previous file with the same name will be replaced.</p>"; echo "<hr />"; $form = new HTML_QuickForm('mkdirForm', 'post', selflink()); $form->addElement('header', null, 'Create a Directory:'); $form->addElement('text', 'name', 'Name:'); $form->addElement('select', 'dir', 'Destination:', $dirs); $form->addElement('submit', 'mkdir', 'Mkdir'); $form->addRule('name', 'Please enter directory name.', 'required', null, 'client'); if ($form->validate()) { $path = $dirs[$form->getSubmitValue('dir')] . '/' . $form->getSubmitValue('name'); if (file_exists($path)) { echo "<p><b>Warning:</b> File or directory {$path} already exists.</p>"; } else { if (mkdir($path)) { echo "<p>Directory {$path} created.</p>"; } else { echo "<p>Failed to create directory {$path}. Make sure parent directory permissions allow it.</p>"; } } } $form->display(); break; case 'phpinfo': phpinfo(); break; } }
$column = 0; foreach ($header_names as $item) { $table->setHeaderContents($row, $column, $item); $column++; } $row = 1; if (!empty($newarray)) { foreach ($newarray as $data) { $column = 0; $table->setCellContents($row, $column, $data); $table->updateCellAttributes($row, $column, 'align="center"'); $column++; $row++; } } $html .= $table->toHtml(); $pdf = new PDF(); $pdf->content_to_pdf($html); exit; } $actions = '<div class="actions">'; if (isset($_GET['selectcat'])) { $interbreadcrumb[] = array('url' => 'gradebook_flatview.php?selectcat=' . Security::remove_XSS($_GET['selectcat']), 'name' => get_lang('FlatView')); $actions .= '<a href=gradebook_flatview.php?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '>' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>'; } if (isset($_GET['selecteval'])) { $interbreadcrumb[] = array('url' => 'gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']), 'name' => get_lang('ViewResult')); $actions .= '<a href=gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']) . '> ' . Display::return_icon('back.png', get_lang('BackToEvaluation'), '', ICON_SIZE_MEDIUM) . '</a>'; } $actions .= '<a href="' . api_get_self() . '?exportpdf=&userid=' . Security::remove_XSS($_GET['userid']) . '&selectcat=' . $category[0]->get_id() . '" target="_blank">
/** * @param array $headers * @param array $rows * @param array $attributes * @return string */ public static function table($headers, $rows, $attributes = array()) { if (empty($attributes)) { $attributes['class'] = 'data_table'; } $table = new HTML_Table($attributes); $row = 0; $column = 0; //Course headers if (!empty($headers)) { foreach ($headers as $item) { $table->setHeaderContents($row, $column, $item); $column++; } $row = 1; $column = 0; } if (!empty($rows)) { foreach ($rows as $content) { $table->setCellContents($row, $column, $content); $row++; //$column++; } } return $table->toHtml(); }
/** * @param FormValidator $form * @param array $extraData * @param string $form_name * @param bool $admin_permissions * @param int $user_id * @param array $extra * @param int $itemId * * @return array */ public function set_extra_fields_in_form($form, $extraData, $form_name, $admin_permissions = false, $user_id = null, $extra = array(), $itemId = null) { $user_id = intval($user_id); $type = $this->type; // User extra fields if ($type == 'user') { $extra = UserManager::get_extra_fields(0, 50, 5, 'ASC', true, null, true); } $jquery_ready_content = null; if (!empty($extra)) { foreach ($extra as $field_details) { // Getting default value id if is set $defaultValueId = null; if (isset($field_details['options']) && !empty($field_details['options'])) { $valueToFind = null; if (isset($field_details['field_default_value'])) { $valueToFind = $field_details['field_default_value']; } // If a value is found we override the default value if (isset($extraData['extra_' . $field_details['field_variable']])) { $valueToFind = $extraData['extra_' . $field_details['field_variable']]; } foreach ($field_details['options'] as $option) { if ($option['option_value'] == $valueToFind) { $defaultValueId = $option['id']; } } } if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { continue; } } switch ($field_details['field_type']) { case ExtraField::FIELD_TYPE_TEXT: $form->addElement('text', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('class' => 'span4')); $form->applyFilter('extra_' . $field_details['field_variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['field_variable'], 'trim'); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_TEXTAREA: $form->add_html_editor('extra_' . $field_details['field_variable'], $field_details['field_display_text'], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130')); $form->applyFilter('extra_' . $field_details['field_variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['field_variable'], 'trim'); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_RADIO: $group = array(); if (isset($field_details['options']) && !empty($field_details['options'])) { foreach ($field_details['options'] as $option_details) { $options[$option_details['option_value']] = $option_details['option_display_text']; $group[] = $form->createElement('radio', 'extra_' . $field_details['field_variable'], $option_details['option_value'], $option_details['option_display_text'] . '<br />', $option_details['option_value']); } } $form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], ''); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_CHECKBOX: $group = array(); if (isset($field_details['options']) && !empty($field_details['options'])) { foreach ($field_details['options'] as $option_details) { $options[$option_details['option_value']] = $option_details['option_display_text']; $group[] = $form->createElement('checkbox', 'extra_' . $field_details['field_variable'], $option_details['option_value'], $option_details['option_display_text'] . '<br />', $option_details['option_value']); } } else { // We assume that is a switch on/off with 1 and 0 as values $group[] = $form->createElement('checkbox', 'extra_' . $field_details['field_variable'], null, 'Yes <br />', null); } $form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], ''); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_SELECT: $get_lang_variables = false; if (in_array($field_details['field_variable'], array('mail_notify_message', 'mail_notify_invitation', 'mail_notify_group_message'))) { $get_lang_variables = true; } // Get extra field workflow $userInfo = api_get_user_info(); $addOptions = array(); $optionsExists = Database::getManager()->getRepository('ChamiloCoreBundle:ExtraFieldOptionRelFieldOption')->findOneBy(array('fieldId' => $field_details['id'])); if ($optionsExists) { if (isset($userInfo['status']) && !empty($userInfo['status'])) { $fieldWorkFlow = Database::getManager()->getRepository('ChamiloCoreBundle:ExtraFieldOptionRelFieldOption')->findBy(array('fieldId' => $field_details['id'], 'relatedFieldOptionId' => $defaultValueId, 'roleId' => $userInfo['status'])); foreach ($fieldWorkFlow as $item) { $addOptions[] = $item->getFieldOptionId(); } } } $options = array(); if (empty($defaultValueId)) { $options[''] = get_lang('SelectAnOption'); } $optionList = array(); if (!empty($field_details['options'])) { foreach ($field_details['options'] as $option_details) { $optionList[$option_details['id']] = $option_details; if ($get_lang_variables) { $options[$option_details['option_value']] = get_lang($option_details['option_display_text']); } else { if ($optionsExists) { // Adding always the default value if ($option_details['id'] == $defaultValueId) { $options[$option_details['option_value']] = $option_details['option_display_text']; } else { if (isset($addOptions) && !empty($addOptions)) { // Parsing filters if (in_array($option_details['id'], $addOptions)) { $options[$option_details['option_value']] = $option_details['option_display_text']; } } } } else { // Normal behaviour $options[$option_details['option_value']] = $option_details['option_display_text']; } } } if (isset($optionList[$defaultValueId])) { if (isset($optionList[$defaultValueId]['option_value']) && $optionList[$defaultValueId]['option_value'] == 'aprobada') { if (api_is_question_manager() == false) { $form->freeze(); } } } // Setting priority message if (isset($optionList[$defaultValueId]) && isset($optionList[$defaultValueId]['priority'])) { if (!empty($optionList[$defaultValueId]['priority'])) { $priorityId = $optionList[$defaultValueId]['priority']; $option = new ExtraFieldOption($this->type); $messageType = $option->getPriorityMessageType($priorityId); $form->addElement('label', null, Display::return_message($optionList[$defaultValueId]['priority_message'], $messageType)); } } } if ($get_lang_variables) { $field_details['field_display_text'] = get_lang($field_details['field_display_text']); } // chzn-select doesn't work for sessions?? $form->addElement('select', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], $options, array('id' => 'extra_' . $field_details['field_variable'])); if ($optionsExists && $field_details['field_loggeable'] && !empty($defaultValueId)) { $form->addElement('textarea', 'extra_' . $field_details['field_variable'] . '_comment', $field_details['field_display_text'] . ' ' . get_lang('Comment')); $em = Database::getManager(); $extraFieldValue = new ExtraFieldValue($this->type); $repo = $em->getRepository($extraFieldValue->entityName); $repoLog = $em->getRepository('Gedmo\\Loggable\\Entity\\LogEntry'); $newEntity = $repo->findOneBy(array($this->handlerEntityId => $itemId, 'fieldId' => $field_details['id'])); // @todo move this in a function inside the class if ($newEntity) { $logs = $repoLog->getLogEntries($newEntity); if (!empty($logs)) { $html = '<b>' . get_lang('LatestChanges') . '</b><br /><br />'; $table = new HTML_Table(array('class' => 'data_table')); $table->setHeaderContents(0, 0, get_lang('Value')); $table->setHeaderContents(0, 1, get_lang('Comment')); $table->setHeaderContents(0, 2, get_lang('ModifyDate')); $table->setHeaderContents(0, 3, get_lang('Username')); $row = 1; foreach ($logs as $log) { $column = 0; $data = $log->getData(); $fieldValue = isset($data['fieldValue']) ? $data['fieldValue'] : null; $comment = isset($data['comment']) ? $data['comment'] : null; $table->setCellContents($row, $column, $fieldValue); $column++; $table->setCellContents($row, $column, $comment); $column++; $table->setCellContents($row, $column, api_get_local_time($log->getLoggedAt()->format('Y-m-d H:i:s'))); $column++; $table->setCellContents($row, $column, $log->getUsername()); $row++; } $form->addElement('label', null, $html . $table->toHtml()); } } } if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_SELECT_MULTIPLE: $options = array(); foreach ($field_details['options'] as $option_id => $option_details) { $options[$option_details['option_value']] = $option_details['option_display_text']; } $form->addElement('select', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], $options, array('multiple' => 'multiple')); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_DATE: $form->addElement('datepickerdate', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('form_name' => $form_name)); $form->_elements[$form->_elementIndex['extra_' . $field_details['field_variable']]]->setLocalOption('minYear', 1900); $defaults['extra_' . $field_details['field_variable']] = date('Y-m-d 12:00:00'); if (!isset($form->_defaultValues['extra_' . $field_details['field_variable']])) { $form->setDefaults($defaults); } if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } $form->applyFilter('theme', 'trim'); break; case ExtraField::FIELD_TYPE_DATETIME: $form->addElement('datepicker', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('form_name' => $form_name)); $form->_elements[$form->_elementIndex['extra_' . $field_details['field_variable']]]->setLocalOption('minYear', 1900); $defaults['extra_' . $field_details['field_variable']] = date('Y-m-d 12:00:00'); if (!isset($form->_defaultValues['extra_' . $field_details['field_variable']])) { $form->setDefaults($defaults); } if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } $form->applyFilter('theme', 'trim'); break; case ExtraField::FIELD_TYPE_DOUBLE_SELECT: $first_select_id = 'first_extra_' . $field_details['field_variable']; $url = api_get_path(WEB_AJAX_PATH) . 'extra_field.ajax.php?1=1'; $jquery_ready_content .= ' $("#' . $first_select_id . '").on("change", function() { var id = $(this).val(); if (id) { $.ajax({ url: "' . $url . '&a=get_second_select_options", dataType: "json", data: "type=' . $type . '&field_id=' . $field_details['id'] . '&option_value_id="+id, success: function(data) { $("#second_extra_' . $field_details['field_variable'] . '").empty(); $.each(data, function(index, value) { $("#second_extra_' . $field_details['field_variable'] . '").append($("<option/>", { value: index, text: value })); }); }, }); } else { $("#second_extra_' . $field_details['field_variable'] . '").empty(); } });'; $first_id = null; $second_id = null; if (!empty($extraData)) { $first_id = $extraData['extra_' . $field_details['field_variable']]['extra_' . $field_details['field_variable']]; $second_id = $extraData['extra_' . $field_details['field_variable']]['extra_' . $field_details['field_variable'] . '_second']; } $options = ExtraField::extra_field_double_select_convert_array_to_ordered_array($field_details['options']); $values = array('' => get_lang('Select')); $second_values = array(); if (!empty($options)) { foreach ($options as $option) { foreach ($option as $sub_option) { if ($sub_option['option_value'] == '0') { $values[$sub_option['id']] = $sub_option['option_display_text']; } else { if ($first_id === $sub_option['option_value']) { $second_values[$sub_option['id']] = $sub_option['option_display_text']; } } } } } $group = array(); $group[] = $form->createElement('select', 'extra_' . $field_details['field_variable'], null, $values, array('id' => $first_select_id)); $group[] = $form->createElement('select', 'extra_' . $field_details['field_variable'] . '_second', null, $second_values, array('id' => 'second_extra_' . $field_details['field_variable'])); $form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], ' '); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_DIVIDER: $form->addElement('static', $field_details['field_variable'], '<br /><strong>' . $field_details['field_display_text'] . '</strong>'); break; case ExtraField::FIELD_TYPE_TAG: $field_variable = $field_details['field_variable']; $field_id = $field_details['id']; if ($this->type == 'user') { // The magic should be here $user_tags = UserManager::get_user_tags($user_id, $field_details['id']); $tag_list = ''; if (is_array($user_tags) && count($user_tags) > 0) { foreach ($user_tags as $tag) { $tag_list .= '<option value="' . $tag['tag'] . '" class="selected">' . $tag['tag'] . '</option>'; } } $url = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php?'; } else { $extraFieldValue = new ExtraFieldValue($this->type); $tags = array(); if (!empty($itemId)) { $tags = $extraFieldValue->getAllValuesByItemAndField($itemId, $field_id); } $tag_list = ''; if (is_array($tags) && count($tags) > 0) { $extraFieldOption = new ExtraFieldOption($this->type); foreach ($tags as $tag) { $option = $extraFieldOption->get($tag['field_value']); $tag_list .= '<option value="' . $option['id'] . '" class="selected">' . $option['option_display_text'] . '</option>'; } } $url = api_get_path(WEB_AJAX_PATH) . 'extra_field.ajax.php'; } $form->addElement('hidden', 'extra_' . $field_details['field_variable'] . '__persist__', 1); $multiSelect = '<select id="extra_' . $field_details['field_variable'] . '" name="extra_' . $field_details['field_variable'] . '"> ' . $tag_list . ' </select>'; $form->addElement('label', $field_details['field_display_text'], $multiSelect); $complete_text = get_lang('StartToType'); //if cache is set to true the jquery will be called 1 time $jquery_ready_content .= <<<EOF \$("#extra_{$field_variable}").fcbkcomplete({ json_url: "{$url}?a=search_tags&field_id={$field_id}&type={$this->type}", cache: false, filter_case: true, filter_hide: true, complete_text:"{$complete_text}", firstselected: false, filter_selected: true, newel: true }); EOF; $jquery_ready_content = null; break; case ExtraField::FIELD_TYPE_TIMEZONE: $form->addElement('select', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], api_get_timezones(), ''); if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } break; case ExtraField::FIELD_TYPE_SOCIAL_PROFILE: // get the social network's favicon $icon_path = UserManager::get_favicon_from_url($extraData['extra_' . $field_details['field_variable']], $field_details['field_default_value']); // special hack for hi5 $leftpad = '1.7'; $top = '0.4'; $domain = parse_url($icon_path, PHP_URL_HOST); if ($domain == 'www.hi5.com' or $domain == 'hi5.com') { $leftpad = '3'; $top = '0'; } // print the input field $form->addElement('text', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('size' => 60, 'style' => 'background-image: url(\'' . $icon_path . '\'); background-repeat: no-repeat; background-position: 0.4em ' . $top . 'em; padding-left: ' . $leftpad . 'em; ')); $form->applyFilter('extra_' . $field_details['field_variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['field_variable'], 'trim'); if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } break; } } } $return = array(); $return['jquery_ready_content'] = $jquery_ready_content; return $return; }
}*/ $table->setCellContents($row, 0, $userLink); $link = $reportingLink . $courseUserLink . $removeLink . $addUserToUrlLink . $editUrl; switch ($user['relation_type']) { case 1: $status = get_lang('Drh'); $link = Display::url(Display::return_icon('edit.png', get_lang('Edit')), api_get_path(WEB_CODE_PATH) . 'admin/dashboard_add_sessions_to_user.php?user='******'Student'); } $table->setCellContents($row, 1, $status); $table->setCellContents($row, 2, $link); $row++; } $userListToShow .= $table->toHtml(); } /** @var SequenceRepository $repo */ $repo = Database::getManager()->getRepository('ChamiloCoreBundle:SequenceResource'); $requirementAndDependencies = $repo->getRequirementAndDependencies($sessionId, SequenceResource::SESSION_TYPE); $requirements = ''; if (!empty($requirementAndDependencies['requirements'])) { $requirements = Display::page_subheader(get_lang('Requirements')); $requirements .= implode(' + ', array_column($requirementAndDependencies['requirements'], 'admin_link')); } $dependencies = ''; if (!empty($requirementAndDependencies['dependencies'])) { $dependencies = Display::page_subheader(get_lang('Dependencies')); $dependencies .= implode(', ', array_column($requirementAndDependencies['dependencies'], 'admin_link')); } //$tpl = new Template(get_lang('Session'));
} $userInformation = $table->toHtml(); $table = new HTML_Table(array('class' => 'data_table')); $table->setHeaderContents(0, 0, get_lang('Tracking')); $csvContent[] = get_lang('Tracking'); $data = array(get_lang('FirstLogin') => Tracking::get_first_connection_date($user['user_id']), get_lang('LatestLogin') => Tracking::get_last_connection_date($user['user_id'], true)); $row = 1; foreach ($data as $label => $item) { if (!empty($label)) { $label = $label . ': '; } $table->setCellContents($row, 0, $label . $item); $csvContent[] = array($label, strip_tags($item)); $row++; } $trackingInformation = $table->toHtml(); $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $user_id = $user['user_id']; $sessions = SessionManager::get_sessions_by_user($user_id, true); $personal_course_list = array(); $courseToolInformationTotal = null; if (count($sessions) > 0) { $sessionInformation = null; $header = array(array(get_lang('Code'), true), array(get_lang('Title'), true), array(get_lang('Status'), true), array(get_lang('TimeSpentInTheCourse'), true), array(get_lang('TotalPostsInAllForums'), true), array('', false)); $headerList = array(); foreach ($header as $item) { $headerList[] = $item[0];
function statistics_display($task) { global $db, $cfg; switch ($task) { case 'overall': ?> <p><b>Overall member ratings.</b><br />Below are the present standings of all registered members, based on ratings calculated over their performance in various contests.</p> <?php //for($i = 0; $i < 3; $i++) //{ if(!isset($_GET['div'])) { $_GET['div'] = '0'; } echo '<p><b>'; $i = 0; for($i = '0'; $i < $cfg["tcl"]["divcount"]; $i++) { if($i == $_GET['div']) echo $cfg["tcl"]["divisions"][$_GET['div']]; else echo '<a href="index.php?view=statistics&task=overall&div='.$i.'">'.$cfg["tcl"]["divisions"][$i].'</a>'; if($i <> $cfg["tcl"]["divcount"] - '1') echo ' | '; } /* while(true) { echo 'here'; if($i != $_GET['div']) echo $cfg["tcl"]["divisions"][$_GET['div']]; else echo '<a href="index.php?view=statistics&task=overall&div='.$i; if($i != 2) { echo ' | '; break; } $i++; };*/ echo '</b></p>'; $table = new HTML_Table; $table->addRow(array('<a href="index.php?view=statistics&task=overall">Rank</a>', '<a href="index.php?view=statistics&task=overall&sort=handle">User Handle</a>', 'Name', '<a href="index.php?view=statistics&task=overall">Rating</a>', '<a href="index.php?view=statistics&task=overall&sort=volatility">Volatility</a>', 'Participated contests'), null, 'TH'); if (!isset($_GET['sort'])) { $_GET['sort'] = 'rating DESC'; } $res =& $db->query('SELECT user_id, first_name, last_name, handle, rating, volatility FROM users WHERE division = '.$_GET['div'].' ORDER BY '.$_GET['sort']); if (PEAR::isError($res)) error($res->toString()); $prev_rat = -1; $rank = 0; $carried = 0; while ($res->fetchInto($user)) { if ($user['handle'] == 'tester') continue; if (abs($prev_rat-$user['rating']) < 1e-4) { ++$carried; } else { $rank = $rank + $carried + 1; $prev_rat = $user['rating']; $carried = 0; } $res2 =& $db->query('SELECT COUNT(*) AS count FROM members WHERE user_id = '.$user['user_id']); if (PEAR::isError($res)) error($res->toString()); $res2->fetchInto($count); $res2->free(); $table->addRow(array($rank, user_handle($user['handle']), ucwords(strtolower($user['first_name'].' '.$user['last_name'])), $user['rating'], $user['volatility'], $count['count'])); } $res->free(); $table->altRowAttributes(1, null, array ("class" => "altrow")); echo '<div class="overflow">'.$table->toHtml().'</div>'; //} break; case 'contest': $res =& db_query('contest_by_id', $_GET['id']); $res->fetchInto($contest); $res->free(); /* if ($contest['tested'] != 1 && $contest['end_future'] != 1 && !auth_user_in_group('Administrators')) { ?> <p><b>System tests for this contest have not finished yet.</b><br /> Contest statistics containing the scores and standings of each team will be put up here, once the testing phase is over. Please check back in a few minutes.</p> <?php return; } */ $table = new HTML_Table; if ($contest['show_future'] == 1) { $status = 'Hidden (not activated yet)'; } else if ($contest['begin_future'] == 1) { $status = 'Not started'; } else if ($contest['end_future'] == 1) { $status = 'Running'; } else { $status = 'Ended'; } $table->addRow(array('Contest status: ', $status), null, 'TH'); $table->addRow(array('Name: ', $contest['name'])); $table->addRow(array('Description: ', $contest['description'])); $table->addRow(array('Begin time: ', $contest['begin_time'])); $table->addRow(array('End time: ', $contest['end_time'])); if ($contest['team_size'] != 1) { $table->addRow(array('Max size of team: ', $contest['team_size'])); $prefix = 'Teams'; } else { $table->addRow(array('Individual event: ', 'Yes')); $prefix = 'Participants'; } // No. of registered teams $res =& db_query('count_teams_by_contest_id', $_GET['id']); $res->fetchInto($count); $res->free(); $table->addRow(array($prefix.' registered: ', $count['count'])); $table->altRowAttributes(1, null, array ("class" => "altrow")); echo '<div class="overflow">'.$table->toHtml().'</div>'; echo "<hr />\n"; if ($contest['end_future'] == 1) { ?> <p><b>Contest Standings.</b><br/></p> <?php } else { ?> <p><b>System testing results.</b><br /> For details about particular solutions, please click on the underlined scores.</p> <?php } $header = array('Rank'); array_push($header, 'Coder'); array_push($header, 'College'); $probs = array(); $res =& db_query('problems_by_contest_id', $_GET['id']); while ($res->fetchInto($problem)) { array_push($header, '<i>'.$problem['prob_id'].'</i>'); array_push($probs, $problem['prob_id']); } $res->free(); array_push($header, 'Score'); $table = new HTML_Table; $table->addRow($header, null, 'TH'); if ($contest['end_future'] != 1) $res =& db_query('teams_by_contest_id', $_GET['id']); else $res =& db_query('standings_by_contest_id', $_GET['id']); if ($res->numRows() == 0) { ?> <p><b>No Rankings!</b><br />No teams participated in this contest.</p> <?php return; } $prev_score = -1; $rank = 0; $carried = 0; while ($res->fetchInto($team)) { // calculate rank if (abs($prev_score-$team['score']) < 1e-4) { ++$carried; } else { $rank = $rank + $carried + 1; $prev_score = $team['score']; $carried = 0; } $row = array($rank, $team['name'], $team['college']); // add users if ($contest['team_size'] > 1) { $res2 =& db_query('users_by_team_id', array($_GET['id'], $team['team_id'])); if ($res2->fetchInto($user)) { $users = user_handle($user['handle']); while ($res2->fetchInto($user)) { $users .= ', '.user_handle($user['handle']); } } $res2->free(); array_push($row, $users); } // add prob scores foreach ($probs as $prob_id) { $res2 =& db_query('score_by_id', array($_GET['id'], $team['team_id'], $prob_id)); if ($res2->fetchInto($solution) && isset($solution['language'])) { if ($contest['end_future'] == 1) array_push($row, sprintf("%.3f", $solution['score'])); else array_push($row, '<a target="_blank" href="solution.php?id='.$_GET['id'].'&prob_id='.$prob_id.'&team_id='.$team['team_id'].'">'.sprintf("%.3f", $solution['score']).'</a>'); } else { array_push($row, '-'); } $res2->free(); } // add total score array_push($row, sprintf("%.3f", $team['score'])); $table->addRow($row); } $table->altRowAttributes(1, null, array ("class" => "altrow")); echo '<div class="overflow">'.$table->toHtml().'</div>'; break; case 'profile': $table = new HTML_Table; $res =& db_query('user_by_handle', $_GET['handle']); if (!$res->fetchInto($user)) { ?> <p><b>No such handle!</b><br/>Maybe you mistyped the user handle.</p> <?php; return; } $table->addRow(array('User handle: ', $_GET['handle']), null, 'TH'); $table->addRow(array('Division: ', $cfg["tcl"]["divisions"][$user['division']])); $table->addRow(array('Rating: ', $user['rating'])); $table->addRow(array('Volatility: ', $user['volatility'])); $table->addRow(array('Name: ', $user['first_name'].' '.$user['last_name'])); $table->addRow(array('Date of Birth: ', $user['birth_date'])); $table->addRow(array('City: ', $user['city'])); $table->addRow(array('Country: ', $user['country'])); $table->addRow(array('Quote: ', $user['quote'])); $table->altRowAttributes(1, null, array ("class" => "altrow")); echo '<div class="overflow">'.$table->toHtml().'</div>'; break; } }
/** * @param string $startDate in UTC time * @param string $endDate in UTC time * * @return string */ public function exportAttendanceLogin($startDate, $endDate) { $data = $this->getAttendanceLogin($startDate, $endDate); if (!$data) { return null; } $users = $data['users']; $results = $data['results']; $table = new HTML_Table(array('class' => 'data_table')); $table->setHeaderContents(0, 0, get_lang('User')); $table->setHeaderContents(0, 1, get_lang('Date')); $row = 1; foreach ($users as $user) { $table->setCellContents($row, 0, $user['lastname'] . ' ' . $user['firstname'] . ' (' . $user['username'] . ')'); $row++; } $table->setColAttributes(0, array('style' => 'width:28%')); $row = 1; foreach ($users as $user) { if (isset($results[$user['user_id']]) && !empty($results[$user['user_id']])) { $dates = implode(', ', array_keys($results[$user['user_id']])); $table->setCellContents($row, 1, $dates); } $row++; } //$tableToString = null; //$sessionInfo = api_get_session_info(api_get_session_id()); //if (!empty($sessionInfo)) { /*$tableToString .= '<strong>'.get_lang('PeriodToDisplay').'</strong>: '. sprintf(get_lang('FromDateXToDateY'), $startDate, $endDate);*/ //} $tableToString = $table->toHtml(); $params = array('filename' => get_lang('Attendance') . '_' . api_get_utc_datetime(), 'pdf_title' => get_lang('Attendance'), 'course_code' => api_get_course_id(), 'show_real_course_teachers' => true); $pdf = new PDF('A4', null, $params); $pdf->html_to_pdf_with_template($tableToString); }
// Format A table $table = new HTML_Table(array('class' => 'data_table')); $row = 0; $column = 0; foreach ($headers as $header) { $table->setHeaderContents($row, $column, $header); $column++; } $row++; foreach ($data as $row_table) { $column = 0; foreach ($row_table as $cell) { $table->setCellContents($row, $column, $cell); $table->updateCellAttributes($row, $column, 'align="center"'); $column++; } $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true); $row++; } $content .= $table->toHtml(); $interbreadcrumb[] = array("url" => "exercice.php?gradebook={$gradebook}", "name" => get_lang('Exercices')); $interbreadcrumb[] = array("url" => "admin.php?exerciseId={$exercise_id}", "name" => $objExercise->name); $tpl = new Template(get_lang('ReportByQuestion')); //$actions = array(); //$actions[]= array(get_lang('Back'), Display::return_icon('back.png', get_lang('Back'), 'exercise_report.php?'.$exercise_id)); //$tpl->set_actions($actions); $actions = '<a href="exercise_report.php?exerciseId=' . intval($_GET['exerciseId']) . '">' . Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>'; $actions = Display::div($actions, array('class' => 'actions')); $content = $actions . $content; $tpl->assign('content', $content); $tpl->display_one_col_template();
/** * @param string $categorySource * * @return string */ function listCategories($categorySource) { $categorySource = isset($categorySource) ? $categorySource : null; $categories = self::getCategories($categorySource); if (count($categories) > 0) { $table = new HTML_Table(array('class' => 'data_table')); $column = 0; $row = 0; $headers = array(get_lang('Category'), get_lang('CategoriesNumber'), get_lang('Courses'), get_lang('Actions')); foreach ($headers as $header) { $table->setHeaderContents($row, $column, $header); $column++; } $row++; $mainUrl = api_get_path(WEB_CODE_PATH) . 'admin/course_category.php?category=' . $categorySource; $editIcon = Display::return_icon('edit.png', get_lang('EditNode'), null, ICON_SIZE_SMALL); $deleteIcon = Display::return_icon('delete.png', get_lang('DeleteNode'), null, ICON_SIZE_SMALL); $moveIcon = Display::return_icon('up.png', get_lang('UpInSameLevel'), null, ICON_SIZE_SMALL); foreach ($categories as $category) { $editUrl = $mainUrl . '&id=' . $category['code'] . '&action=edit'; $moveUrl = $mainUrl . '&id=' . $category['code'] . '&action=moveUp&tree_pos=' . $category['tree_pos']; $deleteUrl = $mainUrl . '&id=' . $category['code'] . '&action=delete'; $actions = Display::url($editIcon, $editUrl) . Display::url($moveIcon, $moveUrl) . Display::url($deleteIcon, $deleteUrl); $url = api_get_path(WEB_CODE_PATH) . 'admin/course_category.php?category=' . $category['code']; $title = Display::url(Display::return_icon('folder_document.gif', get_lang('OpenNode'), null, ICON_SIZE_SMALL) . ' ' . $category['name'], $url); $content = array($title, $category['children_count'], $category['nbr_courses'], $actions); $column = 0; foreach ($content as $value) { $table->setCellContents($row, $column, $value); $column++; } $row++; } return $table->toHtml(); } else { return Display::return_message(get_lang("NoCategories"), 'warning'); } }
/** * @param array $data * @param array $params * * @return string */ public static function convert_array_to_html($data, $params = array()) { $headers = $data[0]; unset($data[0]); $header_attributes = isset($params['header_attributes']) ? $params['header_attributes'] : array(); $table = new HTML_Table(array('class' => 'data_table', 'repeat_header' => '1')); $row = 0; $column = 0; foreach ($headers as $header) { $table->setHeaderContents($row, $column, $header); $attributes = array(); if (isset($header_attributes) && isset($header_attributes[$column])) { $attributes = $header_attributes[$column]; } if (!empty($attributes)) { $table->updateCellAttributes($row, $column, $attributes); } $column++; } $row++; foreach ($data as &$printable_data_row) { $column = 0; foreach ($printable_data_row as &$printable_data_cell) { $table->setCellContents($row, $column, $printable_data_cell); //$table->updateCellAttributes($row, $column, $atributes); $column++; } $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true); $row++; } $table_tp_html = $table->toHtml(); return $table_tp_html; }
/** * Returns a category summary report * * @param int exercise id * @param array prefilled array with the category_id, score, and weight example: array(1 => array('score' => '10', 'total' => 20)); * @param bool $categoryMinusOne shows category - 1 see BT#6540 * @return string */ public static function get_stats_table_by_attempt($exercise_id, $category_list = array(), $categoryMinusOne = false) { if (empty($category_list)) { return null; } $category_name_list = Testcategory::getListOfCategoriesNameForTest($exercise_id, false); $table = new HTML_Table(array('class' => 'data_table')); $table->setHeaderContents(0, 0, get_lang('Categories')); $table->setHeaderContents(0, 1, get_lang('AbsoluteScore')); $table->setHeaderContents(0, 2, get_lang('RelativeScore')); $row = 1; $none_category = array(); if (isset($category_list['none'])) { $none_category = $category_list['none']; unset($category_list['none']); } $total = array(); if (isset($category_list['total'])) { $total = $category_list['total']; unset($category_list['total']); } $em = Database::getManager(); $repo = $em->getRepository('ChamiloCoreBundle:CQuizCategory'); $redefineCategoryList = array(); if (!empty($category_list) && count($category_list) > 1) { $globalCategoryScore = array(); foreach ($category_list as $category_id => $category_item) { $cat = $em->find('ChamiloCoreBundle:CQuizCategory', $category_id); $path = $repo->getPath($cat); $categoryName = $category_name_list[$category_id]; $index = 0; if ($categoryMinusOne) { $index = 1; } if (isset($path[$index])) { $category_id = $path[$index]->getIid(); $categoryName = $path[$index]->getTitle(); } if (!isset($globalCategoryScore[$category_id])) { $globalCategoryScore[$category_id] = array(); $globalCategoryScore[$category_id]['score'] = 0; $globalCategoryScore[$category_id]['total'] = 0; $globalCategoryScore[$category_id]['title'] = ''; } $globalCategoryScore[$category_id]['score'] += $category_item['score']; $globalCategoryScore[$category_id]['total'] += $category_item['total']; $globalCategoryScore[$category_id]['title'] = $categoryName; } foreach ($globalCategoryScore as $category_item) { $table->setCellContents($row, 0, $category_item['title']); $table->setCellContents($row, 1, ExerciseLib::show_score($category_item['score'], $category_item['total'], false)); $table->setCellContents($row, 2, ExerciseLib::show_score($category_item['score'], $category_item['total'], true, false, true)); $class = 'class="row_odd"'; if ($row % 2) { $class = 'class="row_even"'; } $table->setRowAttributes($row, $class, true); $row++; } if (!empty($none_category)) { $table->setCellContents($row, 0, get_lang('None')); $table->setCellContents($row, 1, ExerciseLib::show_score($none_category['score'], $none_category['total'], false)); $table->setCellContents($row, 2, ExerciseLib::show_score($none_category['score'], $none_category['total'], true, false, true)); $row++; } if (!empty($total)) { $table->setCellContents($row, 0, get_lang('Total')); $table->setCellContents($row, 1, ExerciseLib::show_score($total['score'], $total['total'], false)); $table->setCellContents($row, 2, ExerciseLib::show_score($total['score'], $total['total'], true, false, true)); $table->setRowAttributes($row, 'class="row_total"', true); } return $table->toHtml(); } return null; }
public function authorShow($auth) { $result = ''; $table = new HTML_Table(array('width' => '600', 'border' => '0', 'cellpadding' => '6', 'cellspacing' => '0')); $table->setAutoGrow(true); $table->addRow(array('Name:', $auth->name)); if (isset($auth->title) && trim($auth->title) != "") { $table->addRow(array('Title:', $auth->title)); } $table->addRow(array('Email:', "<a href='mailto:" . $auth->email . "'>" . $auth->email . "</a>")); $table->addRow(array('Organization:', $auth->organization)); $webpage = str_replace('http://', '', $auth->webpage); if (isset($auth->webpage) && !empty($webpage)) { $webpage = "<a href=\"" . $auth->webpage . "\" target=\"_blank\">" . $auth->webpage . "</a>"; } else { $webpage = "none"; } $table->addRow(array('Webpage:', $webpage)); $interestsStr = ''; if (isset($auth->interests) && is_array($auth->interests)) { $interestsStr = implode('; ', array_values($auth->interests)); } $table->addRow(array('Interest(s):', $interestsStr)); if ($auth->totalPublications == 0) { $table->addRow(array('No publications by this author'), array('colspan' => 2)); } else { if ($auth->totalPublications <= 6) { assert('is_array($auth->pub_list)'); $headingCell = 'Publications:'; $table->addRow(array($headingCell)); } else { $table->addRow(array('Publications:', '<a id="start" href="#">Show Publications by this author</a>')); } } $table->updateColAttributes(0, array('class' => 'emph', 'width' => '25%')); $result .= $table->toHtml(); if ($auth->totalPublications > 0 && $auth->totalPublications <= 6) { $result .= displayPubList($this->db, $auth->pub_list); } else { $result .= "<div id=\"publist\"> </div>"; } $this->css(); $this->javascript(); return $result; }