Пример #1
0
 /**
  * Browse a glossary entries by date.
  *
  * @param int $id The glossary ID.
  * @param string $order The way to order the records.
  * @param string $sort The direction of the order.
  * @param int $from Start returning records from here.
  * @param int $limit Number of records to return.
  * @param array $options Array of options.
  * @return array Containing count, entries and warnings.
  * @since Moodle 3.1
  * @throws moodle_exception
  * @throws invalid_parameter_exception
  */
 public static function get_entries_by_date($id, $order, $sort, $from, $limit, $options)
 {
     $params = self::validate_parameters(self::get_entries_by_date_parameters(), array('id' => $id, 'order' => core_text::strtoupper($order), 'sort' => core_text::strtoupper($sort), 'from' => $from, 'limit' => $limit, 'options' => $options));
     $id = $params['id'];
     $order = $params['order'];
     $sort = $params['sort'];
     $from = $params['from'];
     $limit = $params['limit'];
     $options = $params['options'];
     $warnings = array();
     if (!in_array($order, array('CREATION', 'UPDATE'))) {
         throw new invalid_parameter_exception('invalidorder');
     } else {
         if (!in_array($sort, array('ASC', 'DESC'))) {
             throw new invalid_parameter_exception('invalidsort');
         }
     }
     // Get and validate the glossary.
     list($glossary, $context) = self::validate_glossary($id);
     // Validate the mode.
     $modes = self::get_browse_modes_from_display_format($glossary->displayformat);
     if (!in_array('date', $modes)) {
         throw new invalid_parameter_exception('invalidbrowsemode');
     }
     $entries = array();
     list($records, $count) = glossary_get_entries_by_date($glossary, $context, $order, $sort, $from, $limit, $options);
     foreach ($records as $key => $record) {
         self::fill_entry_details($record, $context);
         $entries[] = $record;
     }
     return array('count' => $count, 'entries' => $entries, 'warnings' => $warnings);
 }
Пример #2
0
     list($allentries, $count) = glossary_get_entries_by_author($glossary, $context, $hook, $field, $sortorder, $offset, $pagelimit);
     unset($field);
     break;
 case GLOSSARY_CATEGORY_VIEW:
     $hook = (int) $hook;
     // Make sure it's properly casted to int.
     list($allentries, $count) = glossary_get_entries_by_category($glossary, $context, $hook, $offset, $pagelimit);
     $pivotkey = 'categoryname';
     if ($hook != GLOSSARY_SHOW_ALL_CATEGORIES) {
         $printpivot = false;
     }
     break;
 case GLOSSARY_DATE_VIEW:
     $printpivot = false;
     $field = $sortkey == 'CREATION' ? 'CREATION' : 'UPDATE';
     list($allentries, $count) = glossary_get_entries_by_date($glossary, $context, $field, $sortorder, $offset, $pagelimit);
     unset($field);
     break;
 case GLOSSARY_APPROVAL_VIEW:
     $fullpivot = false;
     $printpivot = false;
     list($allentries, $count) = glossary_get_entries_to_approve($glossary, $context, $hook, $sortkey, $sortorder, $offset, $pagelimit);
     break;
 case GLOSSARY_STANDARD_VIEW:
 default:
     $fullpivot = false;
     switch ($mode) {
         case 'search':
             list($allentries, $count) = glossary_get_entries_by_search($glossary, $context, $hook, $fullsearch, $sortkey, $sortorder, $offset, $pagelimit);
             break;
         case 'term':