/**
  * Method to set up the document properties
  *
  * @return void
  */
 protected function setDocument()
 {
     $this->document->setTitle($this->documentTitle);
     // Add scripts
     JHtml::_('bootstrap.tooltip');
     JHtml::_('behavior.keepalive');
     JHtml::_('behavior.formvalidation');
     $d3Cdn = (bool) $this->params->get('d3_cdn', true);
     JHtml::_('Prism.ui.d3', $d3Cdn);
     $js = '
         cfProjectId = ' . $this->item->id . ';
     ';
     $this->document->addScriptDeclaration($js);
     $this->document->addScript('../media/' . $this->option . '/js/admin/' . JString::strtolower($this->getName()) . '.js');
 }
 public function display($tpl = null)
 {
     $this->option = JFactory::getApplication()->input->get('option');
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->form = $this->get('Form');
     // Load the component parameters.
     $params = JComponentHelper::getParams($this->option);
     $filesystemHelper = new Prism\Filesystem\Helper($params);
     $this->mediaFolder = $filesystemHelper->getMediaFolder();
     // Prepare contexts.
     $achievements = new Gamification\Achievement\Achievements(JFactory::getDbo());
     $contexts = $achievements->getContexts();
     $js = 'var gfyContexts = ' . json_encode($contexts) . ';';
     $this->document->addScriptDeclaration($js);
     // Prepare actions, behaviors, scripts and document
     $this->addToolbar();
     $this->setDocument();
     parent::display($tpl);
 }
Exemple #3
0
    protected function prepareRewards()
    {
        $model = JModelLegacy::getInstance("Rewards", "CrowdFundingModel", $config = array('ignore_request' => false));
        // Initialise variables
        // Get state
        /** @var  $state Joomla\Registry\Registry */
        $state = $model->getState();
        $this->state = $state;
        // Get params
        /** @var  $params Joomla\Registry\Registry */
        $params = $this->state->get("params");
        $this->params = $params;
        $this->projectId = $this->state->get("rewards.id");
        $this->items = $model->getItems($this->projectId);
        // Get project and validate it
        jimport("crowdfunding.project");
        $project = CrowdFundingProject::getInstance(JFactory::getDbo(), $this->projectId);
        $project = $project->getProperties();
        $this->item = JArrayHelper::toObject($project);
        if (!$this->item->id or $this->item->user_id != $this->userId) {
            throw new Exception(JText::_("COM_CROWDFUNDING_ERROR_INVALID_PROJECT"));
        }
        // Create a currency object.
        jimport("crowdfunding.currency");
        $currencyId = $this->params->get("project_currency");
        $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
        // Get date format
        $this->dateFormat = CrowdFundingHelper::getDateFormat();
        $this->dateFormatCalendar = CrowdFundingHelper::getDateFormat(true);
        $js = '
	        // Rewards calendar date format.
            var projectWizard = {
                dateFormat: "' . $this->dateFormatCalendar . '"
            };
        ';
        $this->document->addScriptDeclaration($js);
        // Prepare rewards images.
        $this->rewardsImagesEnabled = $this->params->get("rewards_images", 0);
        $this->rewardsImagesUri = CrowdFundingHelper::getImagesFolderUri($this->userId);
        $this->prepareProjectType();
        $this->pathwayName = JText::_("COM_CROWDFUNDING_STEP_REWARDS");
    }
Exemple #4
0
 /**
  * Prepares the document
  */
 protected function prepareDocument()
 {
     // Prepare page suffix
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     $menus = $this->app->getMenu();
     // Because the application sets a default page title,
     // we need to get it from the menu item itself
     $menu = $menus->getActive();
     if ($menu) {
         $this->params->def('page_heading', $menu->title);
     } else {
         $this->params->def('page_heading', JText::_('COM_CROWDFUNDING_RAISE_DEFAULT_PAGE_TITLE'));
     }
     // Prepare page title
     $title = $menu->title;
     if (!$title) {
         $title = $this->app->get('sitename');
         // Set site name if it is necessary ( the option 'sitename' = 1 )
     } elseif ($this->app->get('sitename_pagetitles', 0)) {
         $title = JText::sprintf('JPAGETITLE', $this->app->get('sitename'), $title);
         // Item title to the browser title.
     } else {
         if (!empty($this->item)) {
             $title .= " | " . $this->escape($this->item->title);
         }
     }
     $this->document->setTitle($title);
     // Meta Description
     $this->document->setDescription($this->params->get('menu-meta_description'));
     // Meta keywords
     $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     // Add current layout into breadcrumbs.
     $pathway = $this->app->getPathway();
     $pathway->addItem($this->pathwayName);
     // Scripts
     if ($this->userId) {
         JHtml::_('behavior.core');
         JHtml::_('behavior.keepalive');
         if ($this->params->get("enable_chosen", 1)) {
             JHtml::_('formbehavior.chosen', '.cf-advanced-select');
         }
     }
     switch ($this->layout) {
         case "rewards":
             // Load language string in JavaScript
             JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_REWARD');
             JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_IMAGE');
             JText::script('COM_CROWDFUNDING_PICK_IMAGE');
             // Scripts
             if ($this->params->get("rewards_images", 0)) {
                 JHtml::_('prism.ui.bootstrap3Fileinput');
             }
             JHtml::_('prism.ui.pnotify');
             JHtml::_("prism.ui.joomlaHelper");
             $this->document->addScript('media/' . $this->option . '/js/site/project_rewards.js');
             break;
         case "funding":
             JHtml::_('prism.ui.parsley');
             JHtml::_('prism.ui.bootstrap3Datepicker');
             $this->document->addScript('media/' . $this->option . '/js/site/project_funding.js');
             // Load language string in JavaScript
             JText::script('COM_CROWDFUNDING_THIS_VALUE_IS_REQUIRED');
             break;
         case "story":
             // Scripts
             JHtml::_('prism.ui.bootstrap3FileInput');
             // Include translation of the confirmation question for image removing.
             JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_IMAGE');
             JText::script('COM_CROWDFUNDING_PICK_IMAGE');
             JText::script('COM_CROWDFUNDING_REMOVE');
             $this->document->addScript('media/' . $this->option . '/js/site/project_story.js');
             break;
         case "manager":
             $this->document->addScript('media/' . $this->option . '/js/site/project_manager.js');
             // Load language string in JavaScript
             JText::script('COM_CROWDFUNDING_QUESTION_LAUNCH_PROJECT');
             JText::script('COM_CROWDFUNDING_QUESTION_STOP_PROJECT');
             break;
         case "extras":
             break;
         default:
             // Basic
             if ($this->userId) {
                 JHtml::_('prism.ui.bootstrapMaxLength');
                 JHtml::_('prism.ui.bootstrap3Typeahead');
                 JHtml::_('prism.ui.parsley');
                 JHtml::_('prism.ui.cropper');
                 JHtml::_('prism.ui.fileupload');
                 JHtml::_('prism.ui.pnotify');
                 JHtml::_("prism.ui.joomlaHelper");
                 $this->document->addScript('media/' . $this->option . '/js/site/project_basic.js');
                 // Load language string in JavaScript
                 JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_IMAGE');
                 // Provide image size.
                 $js = "\r\n                    var cfImageWidth  = " . $this->params->get("image_width", 200) . ";\r\n                    var cfImageHeight = " . $this->params->get("image_height", 200) . ";\r\n                ";
                 $this->document->addScriptDeclaration($js);
             }
             break;
     }
 }
 /**
  * Prepares the document.
  */
 protected function prepareDocument()
 {
     // Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     // Prepare page heading
     $this->preparePageHeading();
     // Prepare page heading
     $this->preparePageTitle();
     // Meta Description
     if (!$this->params->get('metadesc')) {
         $this->document->setDescription($this->params->get('menu-meta_description'));
     } else {
         $this->document->setDescription($this->params->get('metadesc'));
     }
     // Meta keywords
     if (!$this->params->get('metakey')) {
         $this->document->setDescription($this->params->get('menu-meta_keywords'));
     } else {
         $this->document->setMetaData('keywords', $this->params->get('metakey'));
     }
     // Create and add title into breadcrumbs.
     $this->activeMenu = $this->app->getMenu()->getActive();
     if (array_key_exists('view', $this->activeMenu->query) and strcmp('form', $this->activeMenu->query['view']) !== 0) {
         $pathway = $this->app->getPathway();
         $pathway->addItem(JText::_('COM_SOCIALCOMMUNITY_EDIT_PROFILE'));
     }
     $version = new Socialcommunity\Version();
     JHtml::_('jquery.framework');
     switch ($this->layout) {
         case 'contact':
             JHtml::_('Prism.ui.bootstrap3Typeahead');
             if ($this->params->get('include_chosen', 0)) {
                 JHtml::_('formbehavior.chosen', '#jform_country_id');
             }
             $this->document->addScript('media/' . $this->option . '/js/site/form_contact.js');
             break;
         case 'avatar':
             JHtml::_('Prism.ui.cropper');
             JHtml::_('Prism.ui.fileupload');
             JHtml::_('Prism.ui.pnotify');
             JHtml::_('Prism.ui.joomlaHelper');
             JHtml::_('Prism.ui.serializeJson');
             JHtml::_('Prism.ui.isLoading');
             $this->document->addScript('media/' . $this->option . '/js/site/form_avatar.js?v=' . $version->getShortVersion());
             // Load language string in JavaScript.
             JText::script('COM_SOCIALCOMMUNITY_QUESTION_REMOVE_IMAGE');
             JText::script('COM_SOCIALCOMMUNITY_CROPPING___');
             // Provide image size.
             $js = '
                 var scImageWidth  = ' . $this->params->get('image_width', 200) . ';
                 var scImageHeight = ' . $this->params->get('image_height', 200) . ';
                 var scUrl         = "' . JUri::base() . '"
             ';
             $this->document->addScriptDeclaration($js);
             break;
         default:
             // Load scripts used on layout 'Basic'.
             if ($this->params->get('include_chosen', 0)) {
                 JHtml::_('formbehavior.chosen', '#jform_gender');
             }
             JHtml::_('Prism.ui.bootstrapMaxLength');
             $this->document->addScript('media/' . $this->option . '/js/site/form_basic.js');
             break;
     }
 }
 /**
  * Prepares the document.
  *
  * @throws \InvalidArgumentException
  */
 protected function prepareDocument()
 {
     // Prepare page suffix
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     $menus = $this->app->getMenu();
     // Because the application sets a default page title,
     // we need to get it from the menu item itself
     $menu = $menus->getActive();
     if ($menu) {
         $this->params->def('page_heading', $menu->title);
     } else {
         $this->params->def('page_heading', JText::_('COM_CROWDFUNDING_RAISE_DEFAULT_PAGE_TITLE'));
     }
     // Prepare page title
     $title = $menu->title;
     if (!$title) {
         $title = $this->app->get('sitename');
         // Set site name if it is necessary ( the option 'sitename' = 1 )
     } elseif ($this->app->get('sitename_pagetitles', 0)) {
         $title = JText::sprintf('JPAGETITLE', $this->app->get('sitename'), $title);
         // Item title to the browser title.
     } else {
         if ($this->item !== null) {
             $title .= ' | ' . $this->escape($this->item->title);
         }
     }
     $this->document->setTitle($title);
     // Meta Description
     $this->document->setDescription($this->params->get('menu-meta_description'));
     // Meta keywords
     $this->document->setMetaData('keywords', $this->params->get('menu-meta_keywords'));
     // Add current layout into breadcrumbs.
     $pathway = $this->app->getPathway();
     $pathway->addItem($this->pathwayName);
     JHtml::_('jquery.framework');
     // Scripts
     if ($this->userId) {
         JHtml::_('behavior.core');
         JHtml::_('behavior.keepalive');
         if ($this->params->get('enable_chosen', 1)) {
             JHtml::_('formbehavior.chosen', '.cf-advanced-select');
         }
     }
     $version = new Crowdfunding\Version();
     switch ($this->layout) {
         case 'rewards':
             // Load language string in JavaScript
             JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_REWARD');
             JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_IMAGE');
             JText::script('COM_CROWDFUNDING_PICK_IMAGE');
             // Scripts
             if ($this->params->get('rewards_images', 0)) {
                 JHtml::_('Prism.ui.bootstrap3Fileinput');
             }
             JHtml::_('Prism.ui.pnotify');
             JHtml::_('Prism.ui.joomlaHelper');
             $this->document->addScript('media/' . $this->option . '/js/site/project_rewards.js?v=' . $version->getShortVersion());
             break;
         case 'funding':
             JHtml::_('Prism.ui.parsley');
             JHtml::_('Prism.ui.bootstrap3Datepicker');
             $this->document->addScript('media/' . $this->option . '/js/site/project_funding.js?v=' . $version->getShortVersion());
             // Load language string in JavaScript
             JText::script('COM_CROWDFUNDING_THIS_VALUE_IS_REQUIRED');
             break;
         case 'story':
             JHtml::_('Prism.ui.bootstrap3FileInput');
             // Include translation of the confirmation question for image removing.
             JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_IMAGE');
             JText::script('COM_CROWDFUNDING_PICK_IMAGE');
             JText::script('COM_CROWDFUNDING_REMOVE');
             $this->document->addScript('media/' . $this->option . '/js/site/project_story.js?v=' . $version->getShortVersion());
             break;
         case 'manager':
             $this->document->addScript('media/' . $this->option . '/js/site/project_manager.js?v=' . $version->getShortVersion());
             // Load language string in JavaScript
             JText::script('COM_CROWDFUNDING_QUESTION_LAUNCH_PROJECT');
             JText::script('COM_CROWDFUNDING_QUESTION_STOP_PROJECT');
             break;
         case 'extras':
             JHtml::_('Prism.ui.serializeJson');
             break;
         default:
             // Basic
             if ($this->userId) {
                 JHtml::_('Prism.ui.bootstrapMaxLength');
                 JHtml::_('Prism.ui.bootstrap3Typeahead');
                 JHtml::_('Prism.ui.parsley');
                 JHtml::_('Prism.ui.cropper');
                 JHtml::_('Prism.ui.fileupload');
                 JHtml::_('Prism.ui.pnotify');
                 JHtml::_('Prism.ui.joomlaHelper');
                 $this->document->addScript('media/' . $this->option . '/js/site/project_basic.js?v=' . $version->getShortVersion());
                 // Load language string in JavaScript
                 JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_IMAGE');
                 $js = '
                 var crowdfundingOptions = {
                     imageWidth:  ' . $this->params->get('image_width', 200) . ',
                     imageHeight: ' . $this->params->get('image_width', 200) . ',
                     aspectRatio: ' . $this->params->get('image_aspect_ratio', '""') . '
                 }';
                 $this->document->addScriptDeclaration($js);
             }
             break;
     }
 }