public function display($tpl = null) { $this->option = JFactory::getApplication()->input->getCmd('option'); $container = Prism\Container::getContainer(); $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); // Get params $this->params = $this->state->get('params'); /** @var $this->params Joomla\Registry\Registry */ $this->numberInRow = (int) $this->params->get('featured_items_row', 3); $helperBus = new Prism\Helper\HelperBus($this->items); $helperBus->addCommand(new Crowdfunding\Helper\PrepareItemsHelper()); $helperBus->handle(); $this->displayCreator = (bool) $this->params->get('integration_display_creator', true); // Prepare integration. Load avatars and profiles. if ($this->displayCreator) { $userIds = Prism\Utilities\ArrayHelper::getIds($this->items, 'user_id'); $this->socialProfiles = CrowdfundingHelper::prepareIntegration($this->params->get('integration_social_platform'), $userIds); } $this->layoutData = new stdClass(); $this->layoutData->items = $this->items; $this->layoutData->params = $this->params; $this->layoutData->money = $this->getMoneyFormatter($container, $this->params); $this->layoutData->socialProfiles = $this->socialProfiles; $this->layoutData->imageFolder = $this->params->get('images_directory', 'images/crowdfunding'); $this->prepareDocument(); parent::display($tpl); }
/** * Add a menu on the sidebar of page */ protected function addSidebar() { // Add submenu CrowdfundingHelper::addSubmenu($this->getName()); JHtmlSidebar::setAction('index.php?option=' . $this->option . '&view=' . $this->getName()); $this->sidebar = JHtmlSidebar::render(); }
/** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * @since 1.6 */ protected function loadFormData() { $app = JFactory::getApplication(); /** @var $app JApplicationSite */ $data = $app->getUserState($this->option . '.edit.funding.data', array()); if (!$data) { $itemId = (int) $this->getState($this->getName() . '.id'); $userId = JFactory::getUser()->get("id"); $data = $this->getItem($itemId, $userId); // Prepare date format. $dateFormat = CrowdfundingHelper::getDateFormat(); $dateValidator = new Prism\Validator\Date($data->funding_end); // Validate end date. If the date is not valid, generate a valid one. // Use minimum allowed days to generate end funding date. if (!$dateValidator->isValid()) { // Get minimum days. $params = $this->getState("params"); $minDays = $params->get("project_days_minimum", 30); // Generate end date. $today = new Crowdfunding\Date(); $fundingEndDate = $today->calculateEndDate($minDays); $data->funding_end = $fundingEndDate->format("Y-m-d"); } $date = new JDate($data->funding_end); $data->funding_end = $date->format($dateFormat); } return $data; }
/** * Pre-processor for $table->delete($pk) * * @param mixed $pk An optional primary key value to delete. If not set the instance property value is used. * * @return void * * @since 3.1.2 * @throws UnexpectedValueException */ public function onBeforeDelete($pk) { $userId = CrowdfundingHelper::getUserIdByRewardId($this->table->id); $imagesFolder = CrowdfundingHelper::getImagesFolder($userId); // Remove image. if (!empty($this->table->image)) { $fileSource = $imagesFolder . DIRECTORY_SEPARATOR . $this->table->image; if (JFile::exists($fileSource)) { JFile::delete($fileSource); } } // Remove thumbnail. if (!empty($this->table->image_thumb)) { $fileSource = $imagesFolder . DIRECTORY_SEPARATOR . $this->table->image_thumb; if (JFile::exists($fileSource)) { JFile::delete($fileSource); } } // Remove square image. if (!empty($this->table->image_square)) { $fileSource = $imagesFolder . DIRECTORY_SEPARATOR . $this->table->image_square; if (JFile::exists($fileSource)) { JFile::delete($fileSource); } } }
public function display($tpl = null) { $this->state = $this->get('State'); $this->form = $this->get('Form'); $this->importType = $this->state->get("import.context"); switch ($this->importType) { case "locations": $this->legend = JText::_("COM_CROWDFUNDING_IMPORT_LOCATIONS_DATA"); $this->uploadTask = "import.locations"; break; case "countries": $this->legend = JText::_("COM_CROWDFUNDING_IMPORT_COUNTRIES_DATA"); $this->uploadTask = "import.countries"; break; case "states": $this->legend = JText::_("COM_CROWDFUNDING_IMPORT_STATES_DATA"); $this->uploadTask = "import.states"; break; default: // Currencies $this->legend = JText::_("COM_CROWDFUNDING_IMPORT_CURRENCY_DATA"); $this->uploadTask = "import.currencies"; break; } // Add submenu CrowdfundingHelper::addSubmenu($this->importType); // Prepare actions $this->addToolbar(); $this->setDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->app = JFactory::getApplication(); /** @var $this->app JApplicationSite */ $this->option = JFactory::getApplication()->input->get('option'); $this->state = $this->get('State'); $this->item = $this->get('Item'); // Get params $this->params = $this->state->get('params'); /** @var $this->params Joomla\Registry\Registry */ $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding'); if (!$this->item) { $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), 'notice'); $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute(), false)); return; } $container = Prism\Container::getContainer(); $this->money = $this->getMoneyFormatter($container, $this->params); // Integrate with social profile. $this->displayCreator = $this->params->get('integration_display_creator', true); // Prepare integration. Load avatars and profiles. if ($this->displayCreator and (is_object($this->item) and $this->item->user_id > 0)) { $socialProfile = CrowdfundingHelper::prepareIntegration($this->params->get('integration_social_platform'), $this->item->user_id); $this->socialProfileLink = !$socialProfile ? null : $socialProfile->getLink(); } // Set a link to project page $uri = JUri::getInstance(); $host = $uri->toString(array('scheme', 'host')); $this->item->link = $host . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug), false); // Set a link to image $this->item->link_image = $host . '/' . $this->imageFolder . '/' . $this->item->image; $this->embedCode = $this->prepareEmbedCode($this->item, $host); $this->prepareDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->option = JFactory::getApplication()->input->getCmd('option'); $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); // Get params $this->params = $this->state->get('params'); /** @var $this->params Joomla\Registry\Registry */ $this->numberInRow = (int) $this->params->get('featured_items_row', 3); $this->items = CrowdfundingHelper::prepareItems($this->items, $this->numberInRow); // Get the folder with images $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding'); // Get currency $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get('project_currency')); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($currency); $this->displayCreator = (bool) $this->params->get('integration_display_creator', true); // Prepare integration. Load avatars and profiles. if ($this->displayCreator) { $socialProfilesBuilder = new Prism\Integration\Profiles\Builder(array('social_platform' => $this->params->get('integration_social_platform'), 'users_ids' => CrowdfundingHelper::fetchUserIds($this->items))); $socialProfilesBuilder->build(); $this->socialProfiles = $socialProfilesBuilder->getProfiles(); } $this->layoutData = array('items' => $this->items, 'params' => $this->params, 'amount' => $this->amount, 'socialProfiles' => $this->socialProfiles, 'imageFolder' => $this->imageFolder, 'titleLength' => $this->params->get('discover_title_length', 0), 'descriptionLength' => $this->params->get('discover_description_length', 0), 'span' => $this->numberInRow > 0 ? round(12 / $this->numberInRow) : 4); $this->prepareDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->params = $this->state->get("params"); $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->state->params->get("project_currency")); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($currency); // Get rewards number $usersIds = array(); foreach ($this->items as $item) { $usersIds[] = $item->id; } // Get number of rewards. $statistics = new Crowdfunding\Statistics\Users(JFactory::getDbo(), $usersIds); $this->projects = $statistics->getProjectsNumber(); $this->amounts = $statistics->getAmounts(); // Add submenu CrowdfundingHelper::addSubmenu($this->getName()); // Prepare sorting data $this->prepareSorting(); // Prepare actions $this->addToolbar(); $this->addSidebar(); $this->setDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->option = JFactory::getApplication()->input->getCmd('option'); $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->params = $this->state->get('params'); $this->numberInRow = (int) $this->params->get('items_row', 3); $this->prepareItems($this->items); // Get the folder with images $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding'); // Get currency $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get('project_currency')); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($currency); $this->displayCreator = (bool) $this->params->get('display_creator', true); // Prepare social integration. if ($this->displayCreator !== false) { $usersIds = CrowdfundingHelper::fetchIds($this->items, 'user_id'); $this->socialProfiles = CrowdfundingHelper::prepareIntegrations($this->params->get('integration_social_platform'), $usersIds); } $this->layoutData = array('items' => $this->items, 'params' => $this->params, 'amount' => $this->amount, 'socialProfiles' => $this->socialProfiles, 'imageFolder' => $this->imageFolder, 'titleLength' => $this->params->get('discover_title_length', 0), 'descriptionLength' => $this->params->get('discover_description_length', 0), 'span' => $this->numberInRow > 0 ? round(12 / $this->numberInRow) : 4); $this->prepareDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->params = $this->state->get("params"); // Get currencies $currencies = array(); foreach ($this->items as $item) { $currencies[] = $item->txn_currency; } $currencies = array_unique($currencies); if (!empty($currencies)) { $options = new Joomla\Registry\Registry(); $options->set("locale_intl", $this->params->get("locale_intl")); $options->set("amount_format", $this->params->get("amount_format")); $this->currencies = new Crowdfunding\Currencies(JFactory::getDbo(), $options); $this->currencies->loadByCode($currencies); } $this->amount = new Crowdfunding\Amount($this->params); // Get enabled specefic plugins. $extensions = new Prism\Extensions(JFactory::getDbo(), $this->specificPlugins); $this->enabledSpecificPlugins = $extensions->getEnabled(); // Add submenu CrowdfundingHelper::addSubmenu($this->getName()); // Prepare sorting data $this->prepareSorting(); // Prepare actions $this->addToolbar(); $this->addSidebar(); $this->setDocument(); parent::display($tpl); }
public function display($tpl = null) { // Initialise variables $this->state = $this->get("State"); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); // Get params $this->params = $this->state->get("params"); /** @var $this->params Joomla\Registry\Registry */ $this->numberInRow = $this->params->get("items_row", 3); $this->items = CrowdfundingHelper::prepareItems($this->items, $this->numberInRow); // Get the folder with images $this->imageFolder = $this->params->get("images_directory", "images/crowdfunding"); // Get currency $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get("project_currency")); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($currency); $this->displayCreator = $this->params->get("integration_display_creator", true); // Prepare social integration. if (!empty($this->displayCreator)) { $socialProfilesBuilder = new Prism\Integration\Profiles\Builder(array("social_platform" => $this->params->get("integration_social_platform"), "users_ids" => CrowdfundingHelper::fetchUserIds($this->items))); $socialProfilesBuilder->build(); $this->socialProfiles = $socialProfilesBuilder->getProfiles(); } $this->layoutData = array("items" => $this->items, "params" => $this->params, "amount" => $this->amount, "socialProfiles" => $this->socialProfiles, "imageFolder" => $this->imageFolder, "titleLength" => $this->params->get("discover_title_length", 0), "descriptionLength" => $this->params->get("discover_description_length", 0), "span" => !empty($this->numberInRow) ? round(12 / $this->numberInRow) : 4); $this->prepareDocument(); parent::display($tpl); }
public function onAfterDispatch() { $app = JFactory::getApplication(); /** @var $app JApplicationSite */ if ($app->isAdmin()) { return; } $document = JFactory::getDocument(); /** @var $document JDocumentHtml */ $type = $document->getType(); if (strcmp('html', $type) !== 0) { return; } // It works only for GET and POST requests. $method = strtolower($app->input->getMethod()); if (!in_array($method, array('get', 'post'), true)) { return; } // Check component enabled if (!JComponentHelper::isEnabled('com_crowdfunding')) { return; } $view = $app->input->getCmd('view'); $option = $app->input->getCmd('option'); $isCrowdfundingComponent = strcmp($option, 'com_crowdfunding') === 0; $isDetailsPage = (strcmp($option, 'com_crowdfunding') === 0 and strcmp($view, 'details') === 0); // Allowed views for the module Crowdfunding Details $allowedViewsModuleDetails = array('backing', 'embed', 'report', 'friendmail'); $allowedViewsModuleFilters = array('discover', 'category'); // Hide some modules if it is not details page. if (!$isDetailsPage) { $this->hideModule('mod_crowdfundinginfo'); $this->hideModule('mod_crowdfundingprofile'); $this->hideModule('mod_crowdfundingreporting'); } // Module Crowdfunding Rewards (mod_crowdfundingrewards). if (!$isDetailsPage) { $this->hideModule('mod_crowdfundingrewards'); } else { // Check project type. If the rewards are disable, hide the module. $projectId = $app->input->getInt('id'); if ($projectId > 0 and !CrowdfundingHelper::isRewardsEnabled($projectId)) { // Hide the module Crowdfunding Rewards, if rewards are disabled. $this->hideModule('mod_crowdfundingrewards'); } } // Module Crowdfunding Details (mod_crowdfundingdetails) on backing and embed pages. if (!$isCrowdfundingComponent or strcmp($option, 'com_crowdfunding') === 0 and !in_array($view, $allowedViewsModuleDetails, true)) { $this->hideModule('mod_crowdfundingdetails'); } // Module Crowdfunding Filters (mod_crowdfundingfilters). if (!$isCrowdfundingComponent or strcmp($option, 'com_crowdfunding') === 0 and !in_array($view, $allowedViewsModuleFilters, true)) { $this->hideModule('mod_crowdfundingfilters'); } // Module Crowdfunding Filters (mod_crowdfundingsearch). if (!$isCrowdfundingComponent or strcmp($option, 'com_crowdfunding') === 0 and !in_array($view, $allowedViewsModuleFilters, true)) { $this->hideModule('mod_crowdfundingsearch'); } }
/** * Add a menu on the sidebar of page */ protected function addSidebar() { // Add submenu CrowdfundingHelper::addSubmenu('projects'); JHtmlSidebar::setAction('index.php?option=' . $this->option . '&view=' . $this->getName()); 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)); $this->sidebar = JHtmlSidebar::render(); }
public function onAfterDispatch() { $app = JFactory::getApplication(); /** @var $app JApplicationSite */ if ($app->isAdmin()) { return; } $document = JFactory::getDocument(); /** @var $document JDocumentHtml */ $type = $document->getType(); if (strcmp("html", $type) != 0) { return; } // It works only for GET and POST requests. $method = JString::strtolower($app->input->getMethod()); if (!in_array($method, array("get", "post"))) { return; } // Check component enabled if (!JComponentHelper::isEnabled('com_crowdfunding', true)) { return; } $view = $app->input->getCmd("view"); $option = $app->input->getCmd("option"); $isCrowdfundingComponent = strcmp($option, "com_crowdfunding") == 0; $isDetailsPage = (strcmp($option, "com_crowdfunding") == 0 and strcmp($view, "details") == 0); // Allowed views for the module Crowdfunding Details $allowedViewsModuleDetails = array("backing", "embed", "report"); $allowedViewsModuleFilters = array("discover", "category"); // Hide some modules if it is not details page. if (!$isDetailsPage) { $this->hideModule("mod_crowdfundinginfo"); $this->hideModule("mod_crowdfundingprofile"); $this->hideModule("mod_crowdfundingreporting"); } // Module Crowdfunding Rewards (mod_crowdfundingrewards). if (!$isDetailsPage) { $this->hideModule("mod_crowdfundingrewards"); } else { // Check project type. If the rewards are disable, hide the module. $projectId = $app->input->getInt("id"); if (!empty($projectId)) { // Hide the module Crowdfunding Rewards, if rewards are disabled. if (!CrowdfundingHelper::isRewardsEnabled($projectId)) { $this->hideModule("mod_crowdfundingrewards"); } } } // Module Crowdfunding Details (mod_crowdfundingdetails) on backing and embed pages. if (!$isCrowdfundingComponent or strcmp($option, "com_crowdfunding") == 0 and !in_array($view, $allowedViewsModuleDetails)) { $this->hideModule("mod_crowdfundingdetails"); } // Module Crowdfunding Filters (mod_crowdfundingfilters). if (!$isCrowdfundingComponent or strcmp($option, "com_crowdfunding") == 0 and !in_array($view, $allowedViewsModuleFilters)) { $this->hideModule("mod_crowdfundingfilters"); } }
/** * Add a menu on the sidebar of page */ protected function addSidebar() { // Add submenu CrowdfundingHelper::addSubmenu($this->getName()); JHtmlSidebar::setAction('index.php?option=' . $this->option . '&view=' . $this->getName()); $filters = Crowdfunding\Filters::getInstance(JFactory::getDbo()); $types = $filters->getLogTypes(); JHtmlSidebar::addFilter(JText::_('COM_CROWDFUNDING_SELECT_TYPE'), 'filter_type', JHtml::_('select.options', $types, 'value', 'text', $this->state->get('filter.type'), true)); $this->sidebar = JHtmlSidebar::render(); }
/** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * @since 1.6 */ protected function loadFormData() { // Check the session for previously entered form data. $data = JFactory::getApplication()->getUserState($this->option . '.edit.report.data', array()); if (empty($data)) { $data = $this->getItem(); $data->title = CrowdfundingHelper::getProjectTitle($data->project_id); } return $data; }
public function save($key = null, $urlVar = null) { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $data = $this->input->post->get('jform', array(), 'array'); $itemId = JArrayHelper::getValue($data, "id"); $redirectOptions = array("task" => $this->getTask(), "id" => $itemId); // Parse formatted goal and funded amounts. $data["goal"] = CrowdfundingHelper::parseAmount($data["goal"]); $data["funded"] = CrowdfundingHelper::parseAmount($data["funded"]); $model = $this->getModel(); /** @var $model CrowdfundingModelProject */ $form = $model->getForm($data, false); /** @var $form JForm */ if (!$form) { throw new Exception(JText::_("COM_Crowdfunding_ERROR_FORM_CANNOT_BE_LOADED"), 500); } // Validate the form $validData = $model->validate($form, $data); $validData["duration_type"] = JArrayHelper::getValue($data, "funding_duration_type"); // Check for errors. if ($validData === false) { $this->displayNotice($form->getErrors(), $redirectOptions); return; } try { // Get image $files = $this->input->files->get('jform', array(), 'array'); $image = JArrayHelper::getValue($files, "image"); $pitchImage = JArrayHelper::getValue($files, "pitch_image"); // Upload image if (!empty($image['name'])) { $imageNames = $model->uploadImage($image); if (!empty($imageNames["image"])) { $validData = array_merge($validData, $imageNames); } } // Upload pitch image if (!empty($pitchImage['name'])) { $pitchImageName = $model->uploadPitchImage($pitchImage); if (!empty($pitchImageName)) { $validData["pitch_image"] = $pitchImageName; } } $itemId = $model->save($validData); $redirectOptions["id"] = $itemId; } catch (Exception $e) { JLog::add($e->getMessage()); throw new Exception(JText::_('COM_Crowdfunding_ERROR_SYSTEM')); } $this->displayMessage(JText::_('COM_Crowdfunding_PROJECT_SAVED'), $redirectOptions); }
/** * This method prepares a code that will be included to step "Extras" on project wizard. * * @param string $context This string gives information about that where it has been executed the trigger. * @param object $item A project data. * @param Joomla\Registry\Registry $params The parameters of the component * * @return null|string */ public function onExtrasDisplay($context, &$item, &$params) { if (strcmp("com_crowdfunding.project.extras", $context) != 0) { return null; } if ($this->app->isAdmin()) { return null; } $doc = JFactory::getDocument(); /** @var $doc JDocumentHtml */ // Check document type $docType = $doc->getType(); if (strcmp("html", $docType) != 0) { return null; } if (empty($item->user_id)) { return null; } // Create a media folder. $mediaFolder = CrowdfundingFilesHelper::getMediaFolder(); if (!JFolder::exists($mediaFolder)) { CrowdfundingHelper::createFolder($mediaFolder); } // Create a media folder for a user. $mediaFolder = CrowdfundingFilesHelper::getMediaFolder($item->user_id); if (!JFolder::exists($mediaFolder)) { CrowdfundingHelper::createFolder($mediaFolder); } $componentParams = JComponentHelper::getParams("com_crowdfundingfiles"); /** @var $componentParams Joomla\Registry\Registry */ $mediaUri = CrowdfundingFilesHelper::getMediaFolderUri($item->user_id); $options = array("project_id" => $item->id, "user_id" => $item->user_id); $files = new CrowdfundingFiles\Files(JFactory::getDbo()); $files->load($options); // Load jQuery JHtml::_("jquery.framework"); JHtml::_("prism.ui.pnotify"); JHtml::_('prism.ui.fileupload'); JHtml::_('prism.ui.joomlaHelper'); // Include the translation of the confirmation question. JText::script('PLG_CROWDFUNDING_FILES_DELETE_QUESTION'); // Get the path for the layout file $path = JPath::clean(JPluginHelper::getLayoutPath('crowdfunding', 'files')); // Render the login form. ob_start(); include $path; $html = ob_get_clean(); return $html; }
public function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); // Add submenu CrowdfundingHelper::addSubmenu($this->getName()); // Prepare sorting data $this->prepareSorting(); // Prepare actions $this->addToolbar(); $this->addSidebar(); $this->setDocument(); parent::display($tpl); }
protected function prepareDefaultLayout() { $this->rewards = new Crowdfunding\User\Rewards(JFactory::getDbo()); $this->rewards->load(array('reward_id' => $this->item->id)); $this->rewardOwnerId = CrowdfundingHelper::getUserIdByRewardId($this->item->id); $dateValidator = new Prism\Validator\Date($this->item->delivery); $this->deliveryDate = $dateValidator->isValid() ? JHtml::_('date', $this->item->delivery, JText::_('DATE_FORMAT_LC3')) : '--'; $this->imagesFolder = CrowdfundingHelper::getImagesFolderUri($this->rewardOwnerId); // Get social profile $socialPlatform = $this->params->get('integration_social_platform'); if ($socialPlatform) { $this->socialProfile = CrowdfundingHelper::prepareIntegration($socialPlatform, $this->rewardOwnerId); $this->profileLink = $this->socialProfile->getLink(); } $this->returnUrl = base64_encode('index.php?option=com_crowdfunding&view=reward&id=' . $this->item->id); }
public function display($tpl = null) { $app = JFactory::getApplication(); /** @var $app JApplicationSite */ $this->option = JFactory::getApplication()->input->get('option'); // Get user ID. $this->userId = JFactory::getUser()->get('id'); // Get reward ID. $rewardId = $app->input->getInt('id'); // Validate reward owner $validator = new Crowdfunding\Validator\Reward\Owner(JFactory::getDbo(), $rewardId, $this->userId); if (!$validator->isValid()) { $app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_REWARD'), 'notice'); $app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute())); return; } $this->items = $this->get('Items'); $this->state = $this->get('State'); $this->pagination = $this->get('Pagination'); // Get params /** @var $params Joomla\Registry\Registry */ $params = $this->state->get('params'); $this->params = $params; // Prepare an URL where user will be redirected when change the state of a reward. $this->redirectUrl = 'index.php?option=com_crowdfunding&view=reward&id=' . $rewardId; // Prepare filters $this->listOrder = $this->escape($this->state->get('list.ordering')); $this->listDirn = $this->escape($this->state->get('list.direction')); $this->saveOrder = strcmp($this->listOrder, 'a.ordering') === 0; // Load reward data. $this->reward = new Crowdfunding\Reward(JFactory::getDbo()); $this->reward->load($rewardId); // Prepare reward delivery date. $dateValidator = new Prism\Validator\Date($this->reward->getDeliveryDate()); $this->deliveryDate = $dateValidator->isValid() ? JHtml::_('date', $this->reward->getDeliveryDate(), JText::_('DATE_FORMAT_LC3')) : '--'; // Get images folder. $this->imagesFolder = CrowdfundingHelper::getImagesFolderUri($this->userId); // Get social profile $socialPlatform = $this->params->get('integration_social_platform'); if (JString::strlen($socialPlatform) > 0) { $this->prepareSocialIntegration($socialPlatform); } $this->prepareDocument(); parent::display($tpl); }
public function validate($data) { if (!is_array($data) or count($data) === 0) { throw new InvalidArgumentException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_REWARDS')); } $filter = JFilterInput::getInstance(); $params = JComponentHelper::getParams('com_crowdfunding'); /** @var $params Joomla\Registry\Registry */ $money = $this->getMoneyFormatter($params); foreach ($data as $key => &$item) { $item['amount'] = $money->setAmount($item['amount'])->parse(); // Filter data if (!is_numeric($item['amount'])) { $item['amount'] = 0.0; } $item['title'] = $filter->clean($item['title'], 'string'); $item['title'] = JString::trim($item['title']); $item['title'] = JString::substr($item['title'], 0, 128); $item['description'] = $filter->clean($item['description'], 'string'); $item['description'] = JString::trim($item['description']); $item['description'] = JString::substr($item['description'], 0, 500); $item['number'] = (int) $item['number']; $item['delivery'] = trim($item['delivery']); $item['delivery'] = $filter->clean($item['delivery'], 'string'); if (!empty($item['delivery'])) { $item['delivery'] = CrowdfundingHelper::convertToSql($item['delivery']); $validatorDate = new Prism\Validator\Date($item['delivery']); if (!$validatorDate->isValid()) { $item['delivery'] = ''; } } if (!$item['title']) { throw new RuntimeException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_TITLE')); } if (!$item['description']) { throw new RuntimeException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_DESCRIPTION')); } if (!$item['amount']) { throw new RuntimeException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_AMOUNT')); } } unset($item); return $data; }
public function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); // Get log files and count them. $logFiles = new Crowdfunding\Log\Files($this->includeFiles); $logFiles->load(); $this->numberLogFilse = count($logFiles); // Add submenu CrowdfundingHelper::addSubmenu($this->getName()); // Prepare sorting data $this->prepareSorting(); // Prepare actions $this->addToolbar(); $this->addSidebar(); $this->setDocument(); parent::display($tpl); }
protected function prepareDefaultLayout() { $this->rewards = new Crowdfunding\User\Rewards(JFactory::getDbo()); $this->rewards->load(array("reward_id" => $this->item->id)); $this->rewardOwnerId = CrowdfundingHelper::getUserIdByRewardId($this->item->id); $dateValidator = new Prism\Validator\Date($this->item->delivery); $this->deliveryDate = $dateValidator->isValid() ? JHtml::_('date', $this->item->delivery, JText::_('DATE_FORMAT_LC3')) : "--"; $this->imagesFolder = CrowdfundingHelper::getImagesFolderUri($this->rewardOwnerId); // Get social profile $socialPlatform = $this->params->get("integration_social_platform"); if (!empty($socialPlatform)) { $options = array("social_platform" => $socialPlatform, "user_id" => $this->rewardOwnerId); $profileBuilder = new Prism\Integration\Profile\Builder($options); $profileBuilder->build(); $this->socialProfile = $profileBuilder->getProfile(); $this->profileLink = $this->socialProfile->getLink(); } $this->returnUrl = base64_encode("index.php?option=com_crowdfunding&view=reward&id=" . $this->item->id); }
public function display($tpl = null) { $this->option = JFactory::getApplication()->input->get('option'); $this->state = $this->get('State'); $this->params = $this->state->get('params'); $this->version = new Crowdfunding\Version(); // Load Prism library version if (!class_exists('Prism\\Version')) { $this->prismVersion = JText::_('COM_CROWDFUNDING_PRISM_LIBRARY_DOWNLOAD'); } else { $prismVersion = new Prism\Version(); $this->prismVersion = $prismVersion->getShortVersion(); if (version_compare($this->prismVersion, $this->version->requiredPrismVersion, '<')) { $this->prismVersionLowerMessage = JText::_('COM_CROWDFUNDING_PRISM_LIBRARY_LOWER_VERSION'); } } // Get popular projects. $this->popular = new Crowdfunding\Statistics\Projects\Popular(JFactory::getDbo()); $this->popular->load(array('limit' => 5)); // Get popular most funded. $this->mostFunded = new Crowdfunding\Statistics\Projects\MostFunded(JFactory::getDbo()); $this->mostFunded->load(array('limit' => 5)); // Get latest started. $options = array('limit' => 10, 'order_by' => 'funding_start', 'order_direction' => 'DESC'); $this->latestStarted = new Crowdfunding\Statistics\Projects\Latest(JFactory::getDbo()); $this->latestStarted->load($options); // Get latest created. $options = array('limit' => 10, 'order_by' => 'created', 'order_direction' => 'DESC'); $this->latestCreated = new Crowdfunding\Statistics\Projects\Latest(JFactory::getDbo()); $this->latestCreated->load($options); // Get currency. $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get('project_currency')); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($currency); // Add submenu CrowdfundingHelper::addSubmenu($this->getName()); $this->addToolbar(); $this->addSidebar(); $this->setDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->params = $this->state->get("params"); $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->state->params->get("project_currency")); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($currency); // Add submenu CrowdfundingHelper::addSubmenu("projects"); $projectId = $this->state->get("project_id"); $this->projectTitle = CrowdfundingHelper::getProjectTitle($projectId); // Prepare sorting data $this->prepareSorting(); // Prepare actions $this->addToolbar(); $this->addSidebar(); $this->setDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->option = JFactory::getApplication()->input->get('option'); $this->items = $this->get('Items'); $this->state = $this->get('State'); $this->pagination = $this->get('Pagination'); $this->params = $this->state->get('params'); $this->displayProjectsNumber = $this->params->get('categories_display_projects_number', 0); $this->numberInRow = $this->params->get('categories_categories_row', 3); // Get description length $this->descriptionLength = $this->params->get('categories_description_length', 128); // Load projects number. if ($this->displayProjectsNumber) { $ids = array(); foreach ($this->items as $item) { $ids[] = $item->id; } $categories = new Crowdfunding\Categories(); $categories->setDb(JFactory::getDbo()); $this->projectsNumber = $categories->getProjectsNumber($ids, array('state' => Prism\Constants::PUBLISHED, 'approved' => Prism\Constants::APPROVED)); } // Prepare items parameters. if (is_array($this->items)) { $this->items = CrowdfundingHelper::prepareCategories($this->items, $this->numberInRow); } // Get layout $layout = $this->params->get('categories_layout', 'grid'); $this->templateView = in_array($layout, $this->allowedLayouts, true) ? $layout : 'grid'; // Get params /** @var $params Joomla\Registry\Registry */ $params = $this->state->get('params'); $this->params = $params; // Prepare filters $this->listOrder = $this->escape($this->state->get('list.ordering')); $this->listDirn = $this->escape($this->state->get('list.direction')); $this->saveOrder = strcmp($this->listOrder, 'a.ordering') === 0; $this->prepareDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->state = $this->get("State"); $this->params = $this->state->get("params"); $this->version = new Crowdfunding\Version(); // Load ITPrism library version if (!class_exists("Prism\\Version")) { $this->prismVersion = JText::_("COM_CROWDFUNDING_PRISM_LIBRARY_DOWNLOAD"); } else { $prismVersion = new Prism\Version(); $this->prismVersion = $prismVersion->getShortVersion(); if (version_compare($this->prismVersion, $this->version->requiredPrismVersion, "<")) { $this->prismVersionLowerMessage = JText::_("COM_CROWDFUNDING_PRISM_LIBRARY_LOWER_VERSION"); } } // Get popular projects. $this->popular = new Crowdfunding\Statistics\Projects\Popular(JFactory::getDbo()); $this->popular->load(5); // Get popular most funded. $this->mostFunded = new Crowdfunding\Statistics\Projects\MostFunded(JFactory::getDbo()); $this->mostFunded->load(5); // Get latest started. $this->latestStarted = new Crowdfunding\Statistics\Projects\Latest(JFactory::getDbo()); $this->latestStarted->load(5); // Get latest created. $this->latestCreated = new Crowdfunding\Statistics\Projects\Latest(JFactory::getDbo()); $this->latestCreated->loadByCreated(5); // Get currency. $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get("project_currency")); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($currency); // Add submenu CrowdfundingHelper::addSubmenu($this->getName()); $this->addToolbar(); $this->addSidebar(); $this->setDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->option = JFactory::getApplication()->input->get('option'); $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); // Get parameters of com_crowdfunding. $this->cfParams = JComponentHelper::getParams('com_crowdfunding'); // Get currencies $currencyCodes = array(); foreach ($this->items as $item) { $currencyCodes[] = $item->txn_currency; $currencyCodes = array_unique($currencyCodes); } if (count($currencyCodes) > 0) { $this->currencies = new Crowdfunding\Currencies(JFactory::getDbo()); $this->currencies->load(array('codes' => $currencyCodes)); $this->money = $this->getMoneyFormatter($this->cfParams); } // Get project title. $search = $this->state->get('filter.search'); if (JString::strlen($search) > 0 and strpos($search, 'pid') === 0) { $projectId = (int) substr($search, 4); $this->projectTitle = CrowdfundingHelper::getProjectTitle($projectId); } // Get enabled specific plugins. $extensions = new Prism\Extensions(JFactory::getDbo(), $this->specificPlugins); $this->enabledSpecificPlugins = $extensions->getEnabled(); // Prepare sorting data $this->prepareSorting(); // Prepare actions $this->addToolbar(); $this->addSidebar(); $this->setDocument(); // Include HTML helper JLoader::register('JHtmlString', JPATH_LIBRARIES . '/joomla/html/html/string.php'); parent::display($tpl); }
public function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); // Get parameters of com_crowdfunding. $this->cfParams = JComponentHelper::getParams("com_crowdfunding"); // Get currencies foreach ($this->items as $item) { $currencies[] = $item->txn_currency; $currencies = array_unique($currencies); } if (!empty($currencies)) { $this->currencies = new Crowdfunding\Currencies(JFactory::getDbo()); $this->currencies->load(array("codes" => $currencies)); $this->amount = new Crowdfunding\Amount($this->cfParams); } // Get project title. $search = $this->state->get("filter.search"); if (!empty($search) and 0 === strpos($search, "pid")) { $projectId = (int) substr($search, 4); $this->projectTitle = CrowdfundingHelper::getProjectTitle($projectId); } // Get enabled specific plugins. $extensions = new Prism\Extensions(JFactory::getDbo(), $this->specificPlugins); $this->enabledSpecificPlugins = $extensions->getEnabled(); // Add submenu CrowdfundingFinanceHelper::addSubmenu($this->getName()); // Prepare sorting data $this->prepareSorting(); // Prepare actions $this->addToolbar(); $this->addSidebar(); $this->setDocument(); // Include HTML helper JLoader::register('JHtmlString', JPATH_LIBRARIES . '/joomla/html/html/string.php'); parent::display($tpl); }