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


PHP CrowdfundingHelper::createFolder方法代码示例

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


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

示例1: save

 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");
     $dataFile = $this->input->files->get('jform', array(), 'array');
     $image = JArrayHelper::getValue($dataFile, "image", array(), "array");
     $imageName = Joomla\String\String::trim(JArrayHelper::getValue($image, 'name'));
     $redirectOptions = array("task" => $this->getTask(), "id" => $itemId);
     // Parse formatted amount.
     $data["amount"] = CrowdfundingHelper::parseAmount($data["amount"]);
     $model = $this->getModel();
     /** @var $model CrowdfundingModelReward */
     $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);
     // Check for errors.
     if ($validData === false) {
         $this->displayNotice($form->getErrors(), $redirectOptions);
         return;
     }
     $params = JComponentHelper::getParams("com_crowdfunding");
     /** @var  $params Joomla\Registry\Registry */
     try {
         $itemId = $model->save($validData);
         $redirectOptions["id"] = $itemId;
         // Upload an image
         $imagesAllowed = $params->get("rewards_images", 0);
         // Upload images.
         if ($imagesAllowed and !empty($imageName) and !empty($itemId)) {
             $reward = new Crowdfunding\Reward(JFactory::getDbo());
             $reward->load($itemId);
             // Get the folder where the images will be stored
             $imagesFolder = CrowdfundingHelper::getImagesFolder($reward->getUserId());
             jimport("joomla.filesystem.folder");
             if (!JFolder::exists($imagesFolder)) {
                 CrowdfundingHelper::createFolder($imagesFolder);
             }
             $images = $model->uploadImage($image, $imagesFolder);
             if (!empty($images)) {
                 $model->storeImage($images, $imagesFolder, $itemId);
             }
         }
     } catch (RuntimeException $e) {
         $this->displayError($e->getMessage(), $redirectOptions);
         return;
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_Crowdfunding_ERROR_SYSTEM'));
     }
     $this->displayMessage(JText::_('COM_Crowdfunding_REWARD_SAVED'), $redirectOptions);
 }
开发者ID:pashakiz,项目名称:crowdf,代码行数:56,代码来源:reward.php

示例2: save

 public function save($key = null, $urlVar = null)
 {
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $data = $this->input->post->get('jform', array(), 'array');
     $itemId = Joomla\Utilities\ArrayHelper::getValue($data, 'id');
     $dataFile = $this->input->files->get('jform', array(), 'array');
     $image = Joomla\Utilities\ArrayHelper::getValue($dataFile, 'image', array(), 'array');
     $imageName = JString::trim(Joomla\Utilities\ArrayHelper::getValue($image, 'name'));
     $redirectOptions = array('task' => $this->getTask(), 'id' => $itemId);
     $model = $this->getModel();
     /** @var $model CrowdfundingModelReward */
     $form = $model->getForm($data, false);
     /** @var $form JForm */
     if (!$form) {
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_FORM_CANNOT_BE_LOADED'));
     }
     $params = JComponentHelper::getParams('com_crowdfunding');
     /** @var  $params Joomla\Registry\Registry */
     // Prepare amounts.
     $moneyFormatter = $this->getMoneyFormatter($params);
     $data['amount'] = $moneyFormatter->setAmount($data['amount'])->parse();
     // Validate the form
     $validData = $model->validate($form, $data);
     // Check for errors.
     if ($validData === false) {
         $this->displayNotice($form->getErrors(), $redirectOptions);
         return;
     }
     try {
         $itemId = $model->save($validData);
         $redirectOptions['id'] = $itemId;
         // Upload an image
         $imagesAllowed = $params->get('rewards_images', 0);
         // Upload images.
         if ($imagesAllowed and !empty($imageName) and !empty($itemId)) {
             $reward = new Crowdfunding\Reward(JFactory::getDbo());
             $reward->load($itemId);
             // Get the folder where the images will be stored
             $imagesFolder = CrowdfundingHelper::getImagesFolder($reward->getUserId(), JPATH_ROOT);
             if (!JFolder::exists($imagesFolder)) {
                 CrowdfundingHelper::createFolder($imagesFolder);
             }
             $images = $model->uploadImage($image, $imagesFolder);
             if (!empty($images)) {
                 $model->storeImage($images, $imagesFolder, $itemId);
             }
         }
     } catch (RuntimeException $e) {
         $this->displayError($e->getMessage(), $redirectOptions);
         return;
     } catch (Exception $e) {
         JLog::add($e->getMessage(), JLog::ERROR, 'com_crowdfunding');
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     $this->displayMessage(JText::_('COM_CROWDFUNDING_REWARD_SAVED'), $redirectOptions);
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:56,代码来源:reward.php

示例3: onExtrasDisplay

 /**
  * 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;
 }
开发者ID:pashakiz,项目名称:crowdf,代码行数:58,代码来源:files.php

示例4: save

 public function save()
 {
     // Check for request forgeries.
     JSession::checkToken() 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;
     }
     $params = JComponentHelper::getParams('com_crowdfunding');
     /** @var  $params Joomla\Registry\Registry */
     // Get the data from the form POST
     $projectId = $this->input->post->get('id', 0, 'int');
     // Check if rewards are enabled.
     if (!$params->get('rewards_enabled', 1)) {
         $redirectOptions = array('view' => 'project', 'layout' => 'manager', 'id' => $projectId);
         $this->displayNotice(JText::_('COM_CROWDFUNDING_ERROR_REWARDS_DISABLED'), $redirectOptions);
         return;
     }
     $data_ = $this->input->post->get('rewards', array(), 'array');
     $actionSubmit = $this->input->post->getCmd('btn_submit', 'save');
     // Reorder items.
     $data = array();
     foreach ($data_ as $item) {
         $ordering = array_key_exists('ordering', $item) ? (int) abs($item['ordering']) : 0;
         if (!$ordering or $ordering > 30) {
             continue;
         }
         $data[$ordering] = $item;
     }
     unset($data_);
     $images = $this->input->files->get('images', array(), 'array');
     // Get wizard type
     $wizardType = $params->get('project_wizard_type', 'five_steps');
     $fiveStepsWizard = strcmp($wizardType, 'five_steps') === 0;
     // If it is five steps wizard type, redirect to manager.
     // If it is six steps wizard type, redirect to extras.
     if (!$fiveStepsWizard) {
         $layout = strcmp($actionSubmit, 'save_continue') === 0 ? 'extras' : 'rewards';
     } else {
         $layout = strcmp($actionSubmit, 'save_continue') === 0 ? 'manager' : 'rewards';
     }
     $redirectOptions = array('view' => 'project', 'layout' => $layout, 'id' => $projectId);
     // Validate project owner.
     $validator = new Crowdfunding\Validator\Project\Owner(JFactory::getDbo(), $projectId, $userId);
     if (!$projectId or !$validator->isValid()) {
         $this->displayWarning(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), $redirectOptions);
         return;
     }
     $model = $this->getModel();
     /** @var $model CrowdfundingModelRewards */
     try {
         $validData = $model->validate($data);
         $rewardsIds = $model->save($validData, $projectId);
         $imagesAllowed = $params->get('rewards_images', 0);
         // Upload images.
         if ($imagesAllowed and count($images) > 0 and count($rewardsIds) > 0) {
             // Get the folder where the images will be stored
             $imagesFolder = CrowdfundingHelper::getImagesFolder($userId, JPATH_ROOT);
             if (!JFolder::exists($imagesFolder)) {
                 CrowdfundingHelper::createFolder($imagesFolder);
             }
             $options = array('temporary_path' => JFactory::getApplication()->get('tmp_path'), 'destination_path' => $imagesFolder);
             $images = $model->uploadImages($images, $rewardsIds, $options, $params);
             if (count($images) > 0) {
                 $model->storeImages($images, $imagesFolder);
             }
         }
     } catch (InvalidArgumentException $e) {
         $this->displayWarning($e->getMessage(), $redirectOptions);
         return;
     } catch (RuntimeException $e) {
         $this->displayWarning($e->getMessage(), $redirectOptions);
         return;
     } catch (Exception $e) {
         JLog::add($e->getMessage(), JLog::ERROR, 'com_crowdfunding');
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     // Redirect to next page
     $this->displayMessage(JText::_('COM_CROWDFUNDING_REWARDS_SUCCESSFULLY_SAVED'), $redirectOptions);
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:82,代码来源:rewards.php

示例5: save

 public function save()
 {
     // Check for request forgeries.
     JSession::checkToken() 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;
     }
     $params = JComponentHelper::getParams("com_crowdfunding");
     /** @var  $params Joomla\Registry\Registry */
     // Get the data from the form POST
     $projectId = $this->input->post->get('id', 0, 'int');
     // Check if rewards are enabled.
     if (!$params->get("rewards_enabled", 1)) {
         $redirectOptions = array("view" => "project", "layout" => "manager", "id" => $projectId);
         $this->displayNotice(JText::_("COM_CROWDFUNDING_ERROR_REWARDS_DISABLED"), $redirectOptions);
         return;
     }
     $data = $this->input->post->get('rewards', array(), 'array');
     $actionSubmit = $this->input->post->getCmd('btn_submit', 'save');
     $images = $this->input->files->get('images', array(), 'array');
     // Get wizard type
     $wizardType = $params->get("project_wizard_type", "five_steps");
     $fiveStepsWizard = strcmp($wizardType, "five_steps") == 0 ? true : false;
     // If it is five steps wizard type, redirect to manager.
     // If it is six steps wizard type, redirect to extras.
     if (!$fiveStepsWizard) {
         $layout = strcmp($actionSubmit, "save_continue") == 0 ? "extras" : "rewards";
     } else {
         $layout = strcmp($actionSubmit, "save_continue") == 0 ? "manager" : "rewards";
     }
     $redirectOptions = array("view" => "project", "layout" => $layout, "id" => $projectId);
     // Validate project owner.
     $validator = new Crowdfunding\Validator\Project\Owner(JFactory::getDbo(), $projectId, $userId);
     if (!$projectId or !$validator->isValid()) {
         $this->displayWarning(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), $redirectOptions);
         return;
     }
     $model = $this->getModel();
     /** @var $model CrowdfundingModelRewards */
     try {
         $validData = $model->validate($data);
         $rewardsIds = $model->save($validData, $projectId);
         $imagesAllowed = $params->get("rewards_images", 0);
         // Upload images.
         if ($imagesAllowed and !empty($images) and !empty($rewardsIds)) {
             // Get the folder where the images will be stored
             $imagesFolder = CrowdfundingHelper::getImagesFolder($userId);
             jimport("joomla.filesystem.folder");
             if (!JFolder::exists($imagesFolder)) {
                 CrowdfundingHelper::createFolder($imagesFolder);
             }
             $images = $model->uploadImages($images, $imagesFolder, $rewardsIds);
             if (!empty($images)) {
                 $model->storeImages($images, $imagesFolder);
             }
         }
     } catch (InvalidArgumentException $e) {
         $this->displayWarning($e->getMessage(), $redirectOptions);
         return;
     } catch (RuntimeException $e) {
         $this->displayWarning($e->getMessage(), $redirectOptions);
         return;
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     // Redirect to next page
     $this->displayMessage(JText::_("COM_CROWDFUNDING_REWARDS_SUCCESSFULLY_SAVED"), $redirectOptions);
 }
开发者ID:pashakiz,项目名称:crowdf,代码行数:72,代码来源:rewards.php


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