Exemple #1
0
 protected function prepareBasic()
 {
     $model = JModelLegacy::getInstance('Project', 'CrowdfundingModel', $config = array('ignore_request' => false));
     /** @var $model CrowdfundingModelProject */
     // Get state
     $this->state = $model->getState();
     /** @var  $this->state Joomla\Registry\Registry */
     // Get params
     $this->params = $this->state->get('params');
     /** @var  $this->params Joomla\Registry\Registry */
     // Get item
     $itemId = $this->state->get('project.id');
     $this->item = $model->getItem($itemId, $this->userId);
     if (!CrowdfundingHelper::isAuthorized($this->userId, $this->item, 'basic')) {
         $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_SOMETHING_WRONG'), 'notice');
         $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute()));
         return;
     }
     // Set a flag that describes the item as new.
     $this->isNew = false;
     if (!(int) $this->item->id) {
         $this->isNew = true;
     }
     $this->form = $model->getForm();
     // Get types
     $this->types = Crowdfunding\Types::getInstance(JFactory::getDbo());
     $this->numberOfTypes = count($this->types);
     // Prepare images
     $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
     if (!$this->item->get('image')) {
         $this->imagePath = 'media/com_crowdfunding/images/no_image.png';
         $this->displayRemoveButton = 'none';
     } else {
         $this->imagePath = $this->imageFolder . '/' . $this->item->get('image');
         $this->displayRemoveButton = 'inline';
     }
     $this->pathwayName = JText::_('COM_CROWDFUNDING_STEP_BASIC');
     // Remove the temporary pictures if they exists.
     $this->removeTemporaryImages($model);
 }
Exemple #2
0
 protected function prepareBasic()
 {
     $model = JModelLegacy::getInstance("Project", "CrowdfundingModel", $config = array('ignore_request' => false));
     /** @var $model CrowdfundingModelProject */
     // Get state
     $this->state = $model->getState();
     /** @var  $this->state Joomla\Registry\Registry */
     // Get params
     $this->params = $this->state->get("params");
     /** @var  $this->params Joomla\Registry\Registry */
     // Get item
     $itemId = $this->state->get('project.id');
     $this->item = $model->getItem($itemId, $this->userId);
     // Set a flag that describes the item as new.
     $this->isNew = false;
     if (!$this->item->id) {
         $this->isNew = true;
     }
     $this->form = $model->getForm();
     // Get types
     $types = Crowdfunding\Types::getInstance(JFactory::getDbo());
     $this->numberOfTypes = count($types);
     // Prepare images
     $this->imageFolder = $this->params->get("images_directory", "images/crowdfunding");
     if (!$this->item->get("image")) {
         $this->imagePath = "media/com_crowdfunding/images/no_image.png";
         $this->displayRemoveButton = "none";
     } else {
         $this->imagePath = $this->imageFolder . "/" . $this->item->get("image");
         $this->displayRemoveButton = "inline";
     }
     $this->pathwayName = JText::_("COM_CROWDFUNDING_STEP_BASIC");
     // Remove the temporary pictures if they exists.
     $this->removeTemporaryImages($model);
 }
 /**
  * Add a menu on the sidebar of page.
  *
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  */
 protected function addSidebar()
 {
     CrowdfundingHelper::addSubmenu($this->getName());
     JHtmlSidebar::setAction('index.php?option=' . $this->option . '&view=' . $this->getName());
     // Prepare options
     $approvedOptions = array(JHtml::_('select.option', 1, JText::_('COM_CROWDFUNDING_APPROVED')), JHtml::_('select.option', 0, JText::_('COM_CROWDFUNDING_DISAPPROVED')));
     $featuredOptions = array(JHtml::_('select.option', 1, JText::_('COM_CROWDFUNDING_FEATURED')), JHtml::_('select.option', 0, JText::_('COM_CROWDFUNDING_NOT_FEATURED')));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_state', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('archived' => false)), 'value', 'text', $this->state->get('filter.state'), true));
     JHtmlSidebar::addFilter(JText::_('COM_CROWDFUNDING_SELECT_APPROVED_STATUS'), 'filter_approved', JHtml::_('select.options', $approvedOptions, 'value', 'text', $this->state->get('filter.approved'), true));
     JHtmlSidebar::addFilter(JText::_('COM_CROWDFUNDING_SELECT_FEATURED_STATUS'), 'filter_featured', JHtml::_('select.options', $featuredOptions, 'value', 'text', $this->state->get('filter.featured'), true));
     JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_CATEGORY'), 'filter_category_id', JHtml::_('select.options', JHtml::_('category.options', 'com_crowdfunding'), 'value', 'text', $this->state->get('filter.category_id')));
     $projectTypes = new Crowdfunding\Types(JFactory::getDbo());
     $projectTypes->load();
     $typesOptions = $projectTypes->toOptions();
     JHtmlSidebar::addFilter(JText::_('COM_CROWDFUNDING_SELECT_TYPE'), 'filter_type_id', JHtml::_('select.options', $typesOptions, 'value', 'text', $this->state->get('filter.type_id')));
     $this->sidebar = JHtmlSidebar::render();
 }