Example #1
0
 public static function instance_config_form($instance)
 {
     $user_storage = new GcrUserStorageAccessS3();
     $file_list = $user_storage->getFileList(false);
     $options = array();
     foreach ($file_list as $filename) {
         $options[$user_storage->getStaticUrl($filename)] = $filename;
     }
     $configdata = $instance->get('configdata');
     return array('videoid' => array('title' => get_string('videourl', 'blocktype.cloudstoragevideo'), 'description' => get_string('videourldescription2', 'blocktype.cloudstoragevideo'), 'type' => 'select', 'multiple' => false, 'options' => $options, 'collapseifoneoption' => false, 'type' => 'select', 'width' => '90%', 'defaultvalue' => isset($configdata['videoid']) ? $configdata['videoid'] : null, 'rules' => array('required' => true)), 'width' => array('type' => 'text', 'title' => get_string('width', 'blocktype.cloudstoragevideo'), 'size' => 3, 'rules' => array('required' => true, 'integer' => true, 'minvalue' => 100, 'maxvalue' => 800), 'defaultvalue' => !empty($configdata['width']) ? $configdata['width'] : self::$default_width), 'height' => array('type' => 'text', 'title' => get_string('height', 'blocktype.cloudstoragevideo'), 'size' => 3, 'rules' => array('required' => true, 'integer' => true, 'minvalue' => 100, 'maxvalue' => 800), 'defaultvalue' => !empty($configdata['height']) ? $configdata['height'] : self::$default_height));
 }
 public function executeGetUserStorageFileList(sfWebRequest $request)
 {
     global $CFG;
     $CFG->current_app->requireLogin();
     $return_array = array();
     $user_storage = new GcrUserStorageAccessS3();
     $file_list = $user_storage->getFileList(false);
     foreach ($file_list as $filename) {
         $file_array = array('filename' => $filename, 'mimetype' => GcrFileLib::mimeinfo($filename));
         $return_array[$user_storage->getStaticUrl($filename)] = $file_array;
     }
     $this->getResponse()->setHttpHeader('Content-type', 'application/json');
     return $this->renderText(json_encode($return_array));
 }