当前位置: 首页>>代码示例>>PHP>>正文


PHP CrowdfundingHelperRoute::getProjectsRoute方法代码示例

本文整理汇总了PHP中CrowdfundingHelperRoute::getProjectsRoute方法的典型用法代码示例。如果您正苦于以下问题:PHP CrowdfundingHelperRoute::getProjectsRoute方法的具体用法?PHP CrowdfundingHelperRoute::getProjectsRoute怎么用?PHP CrowdfundingHelperRoute::getProjectsRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CrowdfundingHelperRoute的用法示例。


在下文中一共展示了CrowdfundingHelperRoute::getProjectsRoute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveState

 public function saveState()
 {
     JSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
     $userId = JFactory::getUser()->get('id');
     if (!$userId) {
         $redirectOptions = array('force_direction' => 'index.php?option=com_users&view=login');
         $this->displayNotice(JText::_('COM_CROWDFUNDING_ERROR_NOT_LOG_IN'), $redirectOptions);
         return;
     }
     // Get component parameters
     $params = JComponentHelper::getParams($this->option);
     /** @var  $params Joomla\Registry\Registry */
     // Get the data from the form
     $itemId = $this->input->get->get('id', 0, 'int');
     $state = $this->input->get->get('state', 0, 'int');
     $state = !$state ? 0 : 1;
     $return = $this->input->get->get('return', '', 'base64');
     $returnLink = JRoute::_(CrowdfundingHelperRoute::getProjectsRoute(), false);
     // Get return link from parameters.
     if (strlen($return) > 0) {
         $returnLink = base64_decode($return);
     }
     $redirectOptions = array('force_direction' => $returnLink);
     $model = $this->getModel();
     /** @var $model CrowdfundingModelProjectItem */
     $item = $model->getItem($itemId, $userId);
     if (!$item->id) {
         $this->displayNotice(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), $redirectOptions);
         return;
     }
     // Include plugins to validate content.
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('content');
     // Trigger onContentValidate event.
     $context = $this->option . '.projects.changestate';
     $results = $dispatcher->trigger('onContentValidateChangeState', array($context, &$item, &$params, $state));
     // If there is an error, redirect to another page.
     foreach ($results as $result) {
         if ((bool) $result['success'] === false) {
             $this->displayNotice(Joomla\Utilities\ArrayHelper::getValue($result, 'message'), $redirectOptions);
             return;
         }
     }
     try {
         $model->saveState($itemId, $userId, $state);
     } catch (RuntimeException $e) {
         $this->setMessage($e->getMessage(), 'warning');
         $this->setRedirect($returnLink);
         return;
     } catch (Exception $e) {
         JLog::add($e->getMessage(), JLog::ERROR, 'com_crowdfunding');
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     // Redirect to next page
     if (!$state) {
         $msg = JText::_('COM_CROWDFUNDING_PROJECT_STOPPED_SUCCESSFULLY');
     } else {
         $msg = JText::_('COM_CROWDFUNDING_PROJECT_LAUNCHED_SUCCESSFULLY_INFO');
     }
     $this->displayMessage($msg, $redirectOptions);
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:61,代码来源:projects.php


注:本文中的CrowdfundingHelperRoute::getProjectsRoute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。