Пример #1
0
 /**
  * Gets the list of IDs from the request data
  *
  * @param DataModel $model      The model where the record will be loaded
  * @param bool      $loadRecord When true, the record matching the *first* ID found will be loaded into $model
  *
  * @return array
  */
 public function getIDsFromRequest(DataModel &$model, $loadRecord = true)
 {
     // Get the ID or list of IDs from the request or the configuration
     $cid = $this->input->get('cid', array(), 'array');
     $id = $this->input->getInt('id', 0);
     $kid = $this->input->getInt($model->getIdFieldName(), 0);
     $ids = array();
     if (is_array($cid) && !empty($cid)) {
         $ids = $cid;
     } else {
         if (empty($id)) {
             if (!empty($kid)) {
                 $ids = array($kid);
             }
         } else {
             $ids = array($id);
         }
     }
     if ($loadRecord && !empty($ids)) {
         $id = reset($ids);
         $model->find(array('id' => $id));
     }
     return $ids;
 }