Example #1
0
 public function initialize()
 {
     $file = new File('media');
     $this->add($file);
     // CSRF
     $csrf = new Hidden('csrf');
     $csrf->addValidator(new Identical(['value' => $this->security->getSessionToken(), 'message' => $this->constants->csrfError()]));
     // Display for type of media. Such as images, videos, audios, etc
     $totalMedia = MediaType::sum(["column" => "amount"]);
     $mediaType = new Select("mediaType", MediaType::find(['columns' => array('id', " CONCAT(name, ' (', amount, ')') as type_amount")]), ['using' => ['id', 'type_amount'], 'name' => 'mediaType', 'class' => 'form-control col-md-3 btn-mini', 'useEmpty' => true, 'emptyText' => "All (" . $totalMedia . ")", 'emptyValue' => "all"]);
     $this->add($mediaType);
     // Search some thing
     $search = new Text('search', ['placeholder' => $this->constants->searchPlaceHolder(), 'class' => 'form-control btn-mini', 'required' => false]);
     $this->add($search);
 }
Example #2
0
 /**
  * Get default media type
  * @return mixed
  */
 public static function getConfig()
 {
     $names = MediaType::find();
     $config = [];
     foreach ($names as $key) {
         $config[$key->getName()] = 0;
     }
     return $config;
 }