示例#1
0
 /**
  * $params object should be a json like
  * <code>
  * {
  *      "id": 1   // this is the slice ID displayed
  * }
  * @throws Exception|RokCommon_Ajax_Exception
  * @param $params
  * @return RokCommon_Ajax_Result
  */
 public function remove($params)
 {
     try {
         $result = new RokCommon_Ajax_Result();
         $slice = RokGallery_Model_SliceTable::getSingle($params->id);
         if ($slice === false) {
             throw new RokCommon_Ajax_Exception('No Slice Found');
         }
         if (RokCommon_Session::get(self::CONTEXT_ROOT . $slice->file_id, false)) {
             $slice->decrementLoves();
             RokCommon_Session::clear(self::CONTEXT_ROOT . $slice->file_id);
         }
         $result->setPayload(array('loves' => $slice->File->Loves->count, 'new_action' => 'love', 'text' => rc__(RokGallery_Config::getOption(RokGallery_Config::OPTION_LOVE_TEXT))));
     } catch (Exception $e) {
         throw $e;
     }
     return $result;
 }
示例#2
0
 /**
  * @param $module_id
  *
  * @return bool
  * @throws RokSprocket_Exception
  */
 public function addNewItem($module_id)
 {
     /** @var RokSprocket_ItemCollection $items */
     $items = $this->getItems($module_id);
     $new_rs_item = new RokSprocket_Item();
     $new_rs_item->setProvider(RokSprocket_Provider_Simple_Storage_Interface::PROVIDER_NAME);
     $new_rs_item->setId($items->getNextId());
     $new_rs_item->setParam('_article_title', rc__('ROKSPROCKET_NEW_SIMPLE_ITEM_TITLE', $new_rs_item->getId()));
     $new_rs_item->setTitle(rc__('ROKSPROCKET_NEW_SIMPLE_ITEM_TITLE', $new_rs_item->getId()));
     $new_rs_item->setOrder(0);
     /** @var RokSprocket_Item $item */
     foreach ($items as $item) {
         $item->setOrder($item->getOrder() + 1);
     }
     $items[$new_rs_item->getArticleId()] = $new_rs_item;
     $items->sort(RokSprocket_ItemCollection::SORT_METHOD_MANUAL);
     RokCommon_Session::set('roksprocket.module_' . $module_id, serialize($items));
     return true;
 }
示例#3
0
 /**
  * Method to display a view.
  *
  * @param bool $cachable
  * @param bool $urlparams
  *
  * @internal param \If $boolean true, the view output will be cached
  * @internal param \An $array array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return    JController        This object to support chaining.
  * @since    1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_modules/helpers/modules.php';
     // Load the submenu.
     ModulesHelper::addSubmenu(JFactory::getApplication()->input->getCmd('view', 'modules'));
     $view = JFactory::getApplication()->input->getCmd('view', 'modules');
     $layout = JFactory::getApplication()->input->getCmd('layout', 'default');
     $id = JFactory::getApplication()->input->getInt('id', null);
     // Check for edit form.
     if ($view == 'module' && $layout == 'edit' && !$this->checkEditId('com_roksprocket.edit.module', $id)) {
         // Somehow the person just went to the form - we don't allow that.
         $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(JRoute::_(sprintf('index.php?option=%s&view=modules', RokSprocket_Helper::getRedirectionOption()), false));
         return false;
     }
     if (RokCommon_Session::get('roksprocket.' . $id, false)) {
         RokCommon_Session::clear('roksprocket.' . $id);
     }
     parent::display();
 }
示例#4
0
 public function postSave($id)
 {
     RokCommon_Session::clear('roksprocket.module_' . $id);
 }
示例#5
0
 protected function _getDoILove($record)
 {
     return RokCommon_Session::get('com_rokgallery.site.loves.file_' . $record->file_id, false);
 }
示例#6
0
 function display($tpl = null)
 {
     JHTML::_('behavior.mootools');
     $session_namespace = 'com_rokgallery.site';
     $session =& JFactory::getSession();
     $app =& JFactory::getApplication();
     $params =& $app->getParams();
     $menu =& JSite::getMenu();
     $menuItem =& $menu->getActive();
     //$params = new JParameter($menuItem->params);
     $document =& JFactory::getDocument();
     $id = JRequest::getVar('id');
     $style = JRequest::getWord('style', $params->get('default_style'));
     $layout = JRequest::getVar('layout', $session->get('layout', $this->getLayout(), $session_namespace));
     if ($layout == 'default') {
         $layout = $params->get('detail_layout');
     }
     $gallery_id = $session->get('gallery_id', $params->get('gallery_id'), $session_namespace);
     $sort_by = $session->get('sort_by', $params->get('default_sort_by'), $session_namespace);
     $sort_direction = $session->get('sort_direction', $params->get('default_sort_direction'), $session_namespace);
     $page = JRequest::getVar('page', $session->get('last_page', 1, $session_namespace));
     $items_per_page = $session->get('items_per_page', (int) $params->get($layout . '-items_per_row', 2) * (int) $params->get($layout . '-rows_per_page', 2), $session_namespace);
     /** @var RokGallery_Site_DetailModel $rtmodel  */
     $this->rtmodel = new RokGallery_Site_DetailModel($gallery_id, $id, $page, $items_per_page, $sort_by, $sort_direction);
     $slice = $this->rtmodel->getSingle();
     if ($slice === false) {
         return JError::raiseError(500, 'Gallery Item is not published.');
     }
     if (!RokCommon_Session::get('com_rokgallery.site.views.file_' . $slice->file_id, false)) {
         $slice->incrementView();
         RokCommon_Session::set('com_rokgallery.site.views.file_' . $slice->file_id, true);
     }
     $base_page_url = RokCommon_URL::setParams('index.php', array('option' => 'com_rokgallery', 'view' => 'gallery'));
     $base_ajax_url = RokCommon_URL::setParams('index.php', array('option' => 'com_rokgallery', 'task' => 'ajax', 'format' => 'raw'));
     // Assignments to JS namespaces
     $this->assign('base_ajax_url', $base_ajax_url);
     $next_link = null;
     $prev_link = null;
     if ($this->rtmodel->getNextId() != null) {
         $next_link = JRoute::_(RokCommon_URL::updateParams($base_page_url, array('view' => 'detail', 'id' => $this->rtmodel->getNextId(), 'page' => $this->rtmodel->getNextPage())));
     }
     if ($this->rtmodel->getPrevId() != null) {
         $prev_link = JRoute::_(RokCommon_URL::updateParams($base_page_url, array('view' => 'detail', 'id' => $this->rtmodel->getPrevId(), 'page' => $this->rtmodel->getPrevPage())));
     }
     $pathway =& $app->getPathway();
     $pwc = $pathway->getPathway();
     $pwc[count($pwc) - 1]->link = $pwc[count($pwc) - 1]->link . '&page=' . $page;
     $pathway->setPathway($pwc);
     $pathway->addItem($slice->title);
     $layout = $this->getLayout();
     $context = 'com_rokgallery.detail.' . $layout;
     $style_context = $context . "." . $style;
     $this->assign('gallery_link', JRoute::_($menuItem->link . "&page=" . $this->rtmodel->getCurrentPage()));
     $this->assign('gallery_name', $menuItem->title);
     $this->assign('context', $context);
     $this->assign('style_context', $style_context);
     $this->assign('width', $slice->Gallery->width);
     $this->assign('height', $slice->Gallery->height);
     $this->assign('love_text', rc__(RokGallery_Config::getOption(RokGallery_Config::OPTION_LOVE_TEXT)));
     $this->assign('unlove_text', rc__(RokGallery_Config::getOption(RokGallery_Config::OPTION_UNLOVE_TEXT)));
     $this->assignRef('slice', $slice);
     $image = $this->getPresentationImage($slice, $params);
     $this->assignRef('image', $image);
     $session->set('last_page', $this->rtmodel->getCurrentPage(), $session_namespace);
     $document->setTitle($document->getTitle() . ' - ' . $image->title);
     $this->assign('next_link', $next_link);
     $this->assign('prev_link', $prev_link);
     $this->assign('show_title', $params->get('detail_show_title', false));
     $this->assign('show_caption', $params->get('detail_show_caption', false));
     $this->assign('show_tags', $params->get('detail_show_tags', false));
     $this->assign('show_tags_count', $params->get('detail_show_tags_count', false));
     $this->assign('show_created_at', $params->get('detail_show_created_at', true));
     $this->assign('show_updated_at', $params->get('detail_show_updated_at', true));
     $this->assign('show_loves', $params->get('detail_show_loves', false));
     $this->assign('show_views', $params->get('detail_show_views', false));
     $this->assign('show_filesize', $params->get('detail_show_filesize', true));
     $this->assign('show_dimensions', $params->get('detail_show_dimensions', true));
     $this->assign('show_download_full', $params->get('detail_show_download_full', true));
     $this->assign('show_gallery_info', $params->get('detail_show_download_full', true));
     $this->setLayout('default');
     parent::display($tpl);
 }