Пример #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' => CSRF_ERROR]));
     $userName = $this->getDI()->getAuth()->getUsername();
     // Display for type of media. Such as images, videos, audios, etc
     // Get user media config file for total media file
     $mediaFiles = new MediaFiles();
     $userConfig = $mediaFiles->getConfigFile($userName);
     $totalMedia = 0;
     $displayData = [];
     foreach ($userConfig as $key => $value) {
         $totalMedia += $value;
         $displayData[MediaType::getTypeFromName($key)->getId()] = $key . "({$value})";
     }
     $mediaType = new Select("mediaType", $displayData, ['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' => SEARCH_PLACE_HOLDER, 'class' => 'form-control btn-mini', 'required' => false]);
     $this->add($search);
 }