public function init() { // Set the method for the display form to POST $this->setMethod('post'); $decorators = array(array('ViewHelper'), array('Errors'), array('Description', array('tag' => 'p', 'class' => 'description'))); $this->addElement('text', 'idYoutube', array('label' => X_Env::_('p_youtube_form_video_label'), 'description' => X_Env::_('p_youtube_form_video_label_desc'), 'required' => true, 'filters' => array('StringTrim'))); $categories = array(); foreach (Application_Model_YoutubeCategoriesMapper::i()->fetchAll() as $category) { /* @var $category Application_Model_YoutubeCategory */ $categories[$category->getId()] = $category->getLabel(); } $this->addElement('select', 'idCategory', array('label' => X_Env::_('p_youtube_form_video_idCategory'), 'description' => X_Env::_('p_youtube_form_video_idCategory_desc'), 'required' => true, 'multiOptions' => $categories)); // Add the submit button $this->addElement('submit', 'submit', array('ignore' => true, 'required' => false, 'label' => X_Env::_('submit'))); // Add the submit button $this->addElement('reset', 'abort', array('ignore' => true, 'label' => X_Env::_('abort'))); // And finally add some CSRF protection $this->addElement('hash', 'csrf', array('salt' => 'p_youtube_video_new_salt')); $this->addDisplayGroup(array('submit', 'abort', 'csrf'), 'buttons', array('decorators' => $this->getDefaultButtonsDisplayGroupDecorators())); }
function dcategoryAction() { $categoryId = $this->getRequest()->getParam('idCategory', false); if ($categoryId != false && $categoryId != null && $categoryId != '') { $category = new Application_Model_YoutubeCategory(); Application_Model_YoutubeCategoriesMapper::i()->find($categoryId, $category); if ($categoryId == $category->getId()) { try { Application_Model_YoutubeVideosMapper::i()->deleteByCategory($category); Application_Model_YoutubeCategoriesMapper::i()->delete($category); $this->_helper->flashMessenger(array('text' => X_Env::_('p_youtube_delete_completed_category'), 'type' => 'info')); } catch (Exception $e) { $this->_helper->flashMessenger(array('text' => X_Env::_('p_youtube_delete_err_dberror') . ": {$e->getMessage()}", 'type' => 'error')); } } else { $this->_helper->flashMessenger(array('text' => X_Env::_('p_youtube_delete_invaliddata'), 'type' => 'error')); } } $this->_helper->redirector('index', 'youtube'); }
protected function libraryMenu(X_Page_ItemList_PItem $items, $submode = false) { X_Debug::i("Submode requested: " . print_r($submode, true)); // disabling cache plugin try { $cachePlugin = X_VlcShares_Plugins::broker()->getPlugins('cache'); if (method_exists($cachePlugin, 'setDoNotCache')) { $cachePlugin->setDoNotCache(); } } catch (Exception $e) { // cache plugin not registered, no problem } if ($submode === false || $submode == null) { // load all categories in the library $categories = Application_Model_YoutubeCategoriesMapper::i()->fetchAll(); foreach ($categories as $category) { /* @var $category Application_Model_YoutubeCategory */ $item = new X_Page_Item_PItem('youtube-category-' . $category->getId(), $category->getLabel()); $item->setThumbnail($category->getThumbnail())->setIcon('/images/youtube/icons/category.png')->setCustom(__CLASS__ . ':location', self::MODE_LIBRARY . "/" . $category->getId())->setLink(array('l' => X_Env::encode(self::MODE_LIBRARY . "/" . $category->getId())), 'default', false)->setGenerator(__CLASS__); $items->append($item); } } else { // load all video inside a category categories /* @var $category Application_Model_YoutubeCategory */ $category = new Application_Model_YoutubeCategory(); Application_Model_YoutubeCategoriesMapper::i()->find($submode, $category); X_Debug::i('Category found: ' . print_r($category, true)); if ($category->getId() != null && $category->getId() == $submode) { $videos = Application_Model_YoutubeVideosMapper::i()->fetchByCategory($category->getId()); foreach ($videos as $video) { /* @var $video Application_Model_YoutubeVideo */ $item = new X_Page_Item_PItem('youtube-library-' . $video->getId(), $video->getLabel()); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon('/images/youtube/icons/video.png')->setDescription($video->getDescription())->setThumbnail($video->getThumbnail())->setCustom(__CLASS__ . ':location', self::MODE_LIBRARY . "/" . $category->getId() . "/0/" . $video->getId())->setLink(array('action' => 'mode', 'l' => X_Env::encode(self::MODE_LIBRARY . "/" . $category->getId() . "/0/" . $video->getId())), 'default', false)->setGenerator(__CLASS__); $items->append($item); } } } }