/** * Execute the action */ public function execute() { parent::execute(); //--Get the ids as array $ids = \SpoonFilter::getPostValue('ids', null, '', 'array'); //--Set module $module = (string) \SpoonFilter::getPostValue('mediaModule', null, '', 'string'); //--Set action $action = (string) \SpoonFilter::getPostValue('mediaAction', null, '', 'string'); //--Set the id $id = (int) \SpoonFilter::getPostValue('mediaId', null, '', 'int'); //--Set the type $type = (string) \SpoonFilter::getPostValue('mediaType', null, '', 'string'); //--Create media object $media = new BackendMediaHelper(new BackendForm('add_image', null, 'post', false), $module, $id, $action, $type); //--Check if the ids is not empty if (!empty($ids)) { foreach ($ids as $id) { //--Link mediaitem with id to item $media->linkMediaToModule($id); } } // success output $this->output(self::OK, null, 'files added'); }
public function execute() { parent::execute(); //--Get the video info //$video_type = \SpoonFilter::getPostValue('video_type', null, '', 'int'); $video_url = \SpoonFilter::getPostValue('video', null, '', 'string'); if (preg_match('%youtube|youtu\\.be%i', $video_url)) { $video_type = 0; $video_id = self::getYoutubeId($video_url); } elseif (preg_match('%vimeo%i', $video_url)) { $video_type = 1; $video_id = self::getVimeoId($video_url); } elseif (preg_match('%vine%i', $video_url)) { $video_type = 2; $video_id = preg_replace('/^.*\\//', '', $video_url); } if (isset($video_id)) { //--Set module $module = (string) \SpoonFilter::getPostValue('mediaModule', null, '', 'string'); //--Set action $action = (string) \SpoonFilter::getPostValue('mediaAction', null, '', 'string'); //--Set the id $id = (int) \SpoonFilter::getPostValue('mediaId', null, '', 'int'); //--Set the type $type = (string) \SpoonFilter::getPostValue('mediaType', null, '', 'string'); //--Create media object $media = new BackendMediaHelper(new BackendForm('add_image', null, 'post', false), $module, $id, $action, $type); //--Validate media -> add video $media->addVideo($video_type, $video_id); $tpl = new Template(); $media->item['txtText'] = $media->frm->addTextarea("text-" . $media->item["id"], $media->item['text'])->setAttribute('style', 'resize: none;')->parse(); switch ($media->item['extension']) { //youtube case 0: $media->item['video_html'] = '<iframe id="ytplayer" type="text/html" width="100%" src="http://www.youtube.com/embed/' . $media->item['filename'] . '?autoplay=0" frameborder="0"></iframe>'; break; //vimeo //vimeo case 1: $media->item['video_html'] = '<iframe src="//player.vimeo.com/video/' . $media->item['filename'] . '" width="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'; break; //vine //vine case 2: $media->item['video_html'] = '<iframe src="https://vine.co/v/' . $media->item['filename'] . '/embed/postcard" width="100%" frameborder="0"></iframe><script src="https://platform.vine.co/static/scripts/embed.js"></script>'; break; default: $media->item['video_html'] = ""; break; } $tpl->assign('mediaItems', array('videos' => array($media->item))); $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Media/Layout/Templates/Ajax/Video.tpl'); $this->output(self::OK, array($media->item['filetype'], $html), FrontendLanguage::msg('Success')); } else { $this->output(self::OK, null, 'video not added'); } // success output }
/** * Contstructor * */ public function execute() { parent::execute(); //--Set post var to check submit $_POST["form"] = "add_image"; //--Set module $module = (string) \SpoonFilter::getPostValue('mediaModule', null, '', 'string'); //--Set action $action = (string) \SpoonFilter::getPostValue('mediaAction', null, '', 'string'); //--Set the id $id = (int) \SpoonFilter::getPostValue('mediaId', null, '', 'int'); //--Set the type $type = (string) \SpoonFilter::getPostValue('mediaType', null, '', 'string'); //--Create media helper $this->media = new BackendMediaHelper(new BackendForm('add_image', null, 'post', false), $module, $id, $action, $type); //--Validate media -> upload file $this->media->validate(); //--File is image if ($this->media->item['filetype'] == 1) { //Create html $tpl = new Template(); $this->media->item['txtText'] = $this->media->frm->addTextarea("text-" . $this->media->item["id"], $this->media->item['text'])->setAttribute('style', 'resize: none;')->parse(); //--Get file info (ext, filename, path) $path_parts = pathinfo(FRONTEND_FILES_PATH . '/Media/Images/Source/' . $this->media->item['filename']); $this->media->item['name'] = $path_parts['filename']; $folders = BackendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Media/Images', true); foreach ($folders as $folder) { $this->media->item['image_' . $folder['dirname']] = $folder['url'] . '/' . $folder['dirname'] . '/' . $this->media->item['filename']; } $tpl->assign('mediaItems', array('images' => array($this->media->item))); $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Media/Layout/Templates/Ajax/Image.tpl'); //--File is file } else { //Create html $tpl = new Template(); $this->media->item['txtText'] = $this->media->frm->addTextarea("text-" . $this->media->item["id"], $this->media->item['text'])->setAttribute('style', 'resize: none;')->parse(); //--Get file info (ext, filename, path) $path_parts = pathinfo(FRONTEND_FILES_PATH . '/Media/Files/' . $this->media->item['filename']); $this->media->item['url'] = FRONTEND_FILES_URL . '/Media/Files/' . $this->media->item['filename']; $this->media->item['name'] = $path_parts['filename']; $tpl->assign('mediaItems', array('files' => array($this->media->item))); $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Media/Layout/Templates/Ajax/File.tpl'); } // output (filetype, html) $this->output(self::OK, array($this->media->item['filetype'], $html), FrontendLanguage::msg('Success')); }
/** * Execute the action */ public function execute() { parent::execute(); //--Create template object $tpl = new Template(); //--Add list of all mediaitems to template $tpl->assign('mediaItems', BackendMediaHelper::getAllMediaItems()); //--Get html list $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Media/Layout/Templates/Ajax/Link.tpl'); // success output $this->output(self::OK, $html, ''); }