123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <?php
- /* For licensing terms, see /license.txt */
- /**
- * Glossay request class definition
- * @package chamilo.glossary
- */
- /**
- * Init
- */
- namespace Glossary;
- use \ChamiloSession as Session;
- /**
- * Html request for course description.
- *
- * @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Genevas
- * @license /license.txt
- */
- class Request extends \Request
- {
- const PARAM_ID = 'id';
- const PARAM_IDS = 'ids';
- const PARAM_C_ID = 'c_id';
- const PARAM_SESSION_ID = 'id_session';
- const PARAM_ACTION = 'action';
- const PARAM_SEC_TOKEN = 'sec_token';
- const PARAM_IS_STUDENT_VIEW = 'isStudentView';
- const PARAM_SORT_COLUMN = 'sort_column';
- const PARAM_SORT_DIRECTION = 'sort_direction';
- const PARAM_PAGE = 'page';
- const PARAM_VIEW = 'view';
- /**
- * Action to perform. *
- * @return string
- */
- public static function get_action()
- {
- $result = Request::get(self::PARAM_ACTION, '');
- return $result;
- }
- /**
- * Returns the object id.
- *
- * @return int
- */
- public static function get_id()
- {
- $result = \Request::get(self::PARAM_ID, 0);
- $result = intval($result);
- return $result;
- }
- /**
- * List of objet ids
- *
- * @return array
- */
- public static function get_ids()
- {
- $result = Request::get(self::PARAM_IDS, array());
- if (is_array($result)) {
- return $result;
- }
- $result = trim($result);
- if (empty($result)) {
- return array();
- }
- $result = explode(',', $result);
- return $result;
- }
- /**
- * Returns the course id.
- *
- * @return int
- */
- public static function get_c_id()
- {
- $result = Request::get(self::PARAM_C_ID, 0);
- $result = intval($result);
- $result = $result ? $result : api_get_real_course_id();
- $result = $result ? $result : 0;
- return $result;
- }
- /**
- * Returns the session id.
- *
- * @return int
- */
- public static function get_session_id()
- {
- $result = Request::get(self::PARAM_SESSION_ID, 0);
- $result = intval($result);
- return $result;
- }
- /**
- * Returns the security token.
- *
- * @return string
- */
- public static function get_security_token()
- {
- $result = Request::get(self::PARAM_SEC_TOKEN, 0);
- return $result;
- }
- /**
- * Returns true if the user is in "student view". False otherwise.
- *
- * @return bool
- */
- public static function is_student_view()
- {
- return Request::get(self::PARAM_IS_STUDENT_VIEW, false) == 'true';
- }
- /**
- * Returns a course key parameters. I.e. not a real course but an
- * object with the course c_id and session set up.
- *
- * @return object
- */
- public static function get_course_key()
- {
- $result = (object) array();
- $result->c_id = Request::get_c_id();
- $result->session_id = Request::get_session_id();
- return $result;
- }
- /**
- * Returns an item key. I.e. not a real entity object but an
- * object with the object keys set up.
- *
- * @return object
- */
- public static function get_item_key()
- {
- $result = (object) array();
- $result->c_id = Request::get_c_id();
- $result->id = Request::get_id();
- return $result;
- }
- public static function get_sort_column()
- {
- $result = Request::get(self::PARAM_SORT_COLUMN, 'name');
- $result = ($result == 'description') ? 'description' : 'name';
- return $result;
- }
-
- public static function get_sort_direction(){
- $result = Request::get(self::PARAM_SORT_DIRECTION, 'name');
- $result = strtoupper($result);
- $result = ($result == 'DESC') ? 'DESC' : 'ASC';
- return $result;
- }
-
- public static function get_page(){
- $result = Request::get(self::PARAM_PAGE, 0);
- return (int)$result;
- }
-
- public static function get_view(){
- $result = Request::get(self::PARAM_VIEW);
- $result = $result ? $result : Session::read(self::PARAM_VIEW, 'list');
- $result = ($result == 'table') ? 'table' : 'list';
- return $result;
- }
- }
|