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


PHP CrowdfundingHelper::getTemporaryImagesFolder方法代码示例

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


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

示例1: removeTemporaryImages

 /**
  * Remove the temporary images if a user upload or crop a picture,
  * but he does not store it or reload the page.
  *
  * @param CrowdfundingModelProject $model
  */
 protected function removeTemporaryImages($model)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Remove old image if it exists.
     $oldImage = $app->getUserState(Crowdfunding\Constants::TEMPORARY_IMAGE_CONTEXT);
     if (!empty($oldImage)) {
         $temporaryFolder = CrowdfundingHelper::getTemporaryImagesFolder();
         $oldImage = JPath::clean($temporaryFolder . "/" . basename($oldImage));
         if (JFile::exists($oldImage)) {
             JFile::delete($oldImage);
         }
     }
     // Set the name of the image in the session.
     $app->setUserState(Crowdfunding\Constants::TEMPORARY_IMAGE_CONTEXT, null);
     // Remove the temporary images if they exist.
     $temporaryImages = $app->getUserState(Crowdfunding\Constants::CROPPED_IMAGES_CONTEXT);
     if (!empty($temporaryImages)) {
         $temporaryFolder = CrowdfundingHelper::getTemporaryImagesFolder();
         $model->removeTemporaryImages($temporaryImages, $temporaryFolder);
     }
     // Reset the temporary images.
     $app->setUserState(Crowdfunding\Constants::CROPPED_IMAGES_CONTEXT, null);
 }
开发者ID:pashakiz,项目名称:crowdf,代码行数:30,代码来源:view.html.php

示例2: save

 public function save($key = null, $urlVar = null)
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     $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 the data from the form POST
     $data = $this->input->post->get('jform', array(), 'array');
     $itemId = Joomla\Utilities\ArrayHelper::getValue($data, 'id', 0, 'int');
     $terms = Joomla\Utilities\ArrayHelper::getValue($data, 'terms', false, 'bool');
     $redirectOptions = array('view' => 'project', 'id' => $itemId);
     $model = $this->getModel();
     /** @var $model CrowdfundingModelProject */
     // Get component parameters
     $params = JComponentHelper::getParams($this->option);
     /** @var  $params Joomla\Registry\Registry */
     $form = $model->getForm($data, false);
     /** @var $form JForm */
     if (!$form) {
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_FORM_CANNOT_BE_LOADED'));
     }
     // Validate data.
     $validData = $model->validate($form, $data);
     if ($validData === false) {
         $this->displayNotice($form->getErrors(), $redirectOptions);
         return;
     }
     if ($itemId > 0) {
         // Validate owner if the item already exists.
         $userId = JFactory::getUser()->get('id');
         $validator = new Crowdfunding\Validator\Project\Owner(JFactory::getDbo(), $itemId, $userId);
         if (!$validator->isValid()) {
             $this->displayWarning(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), $redirectOptions);
             return;
         }
     } else {
         // Verify terms of use during the process of creating a project.
         if ($params->get('project_terms', 0) and !$terms) {
             $redirectOptions = array('view' => 'project');
             $this->displayWarning(JText::_('COM_CROWDFUNDING_ERROR_TERMS_NOT_ACCEPTED'), $redirectOptions);
             return;
         }
     }
     // Include plugins to validate content.
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('content');
     // Trigger onContentValidate event.
     $context = $this->option . '.basic';
     $results = $dispatcher->trigger('onContentValidate', array($context, &$validData, &$params));
     // If there is an error, redirect to current step.
     foreach ($results as $result) {
         if ((bool) $result['success'] === false) {
             $this->displayWarning(Joomla\Utilities\ArrayHelper::getValue($result, 'message'), $redirectOptions);
             return;
         }
     }
     try {
         // Store the project data.
         $itemId = $model->save($validData);
         // Set the project ID to redirect options.
         $redirectOptions['id'] = $itemId;
         // Get the images from the session.
         $images = $app->getUserState(Crowdfunding\Constants::CROPPED_IMAGES_CONTEXT);
         // Store the images to the project record.
         if ($images !== null and is_array($images) and $itemId > 0) {
             // Get the folder where the images will be stored
             $temporaryFolder = CrowdfundingHelper::getTemporaryImagesFolder(JPATH_BASE);
             // Move the pictures from the temporary folder to the images folder.
             // Store the names of the pictures in project record.
             $model->updateImages($itemId, $images, $temporaryFolder);
             // Remove the pictures from the session.
             $app->setUserState(Crowdfunding\Constants::CROPPED_IMAGES_CONTEXT, null);
         }
     } catch (RuntimeException $e) {
         $this->displayWarning($e->getMessage(), $redirectOptions);
         return;
     } catch (InvalidArgumentException $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
     $redirectOptions = array('view' => 'project', 'layout' => 'funding', 'id' => $itemId);
     $this->displayMessage(JText::_('COM_CROWDFUNDING_PROJECT_SUCCESSFULLY_SAVED'), $redirectOptions);
 }
开发者ID:sis-direct,项目名称:CrowdFunding,代码行数:93,代码来源:project.php

示例3: cancelImageCrop

 public function cancelImageCrop()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     $response = new Prism\Response\Json();
     $userId = JFactory::getUser()->get("id");
     if (!$userId) {
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_NOT_LOG_IN'))->failure();
         echo $response;
         $app->close();
     }
     try {
         // Get the folder where the images will be stored
         $temporaryFolder = CrowdfundingHelper::getTemporaryImagesFolder();
         // Remove old image if it exists.
         $oldImage = $app->getUserState(Crowdfunding\Constants::TEMPORARY_IMAGE_CONTEXT);
         if (!empty($oldImage)) {
             $oldImage = JPath::clean($temporaryFolder . "/" . basename($oldImage));
             if (JFile::exists($oldImage)) {
                 JFile::delete($oldImage);
             }
         }
         // Set the name of the image in the session.
         $app->setUserState(Crowdfunding\Constants::TEMPORARY_IMAGE_CONTEXT, null);
     } catch (Exception $e) {
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'))->failure();
         echo $response;
         $app->close();
     }
     $response->setTitle(JText::_('COM_CROWDFUNDING_SUCCESS'))->setText(JText::_('COM_CROWDFUNDING_IMAGE_RESET_SUCCESSFULLY'))->success();
     echo $response;
     $app->close();
 }
开发者ID:Eautentik,项目名称:CrowdFunding,代码行数:35,代码来源:project.raw.php


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