本文整理汇总了PHP中CrowdfundingHelper::getImagesFolderUri方法的典型用法代码示例。如果您正苦于以下问题:PHP CrowdfundingHelper::getImagesFolderUri方法的具体用法?PHP CrowdfundingHelper::getImagesFolderUri怎么用?PHP CrowdfundingHelper::getImagesFolderUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CrowdfundingHelper
的用法示例。
在下文中一共展示了CrowdfundingHelper::getImagesFolderUri方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareDefaultLayout
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);
}
示例2: display
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);
}
示例3: prepareDefaultLayout
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);
}
示例4: switch
$amount = new Crowdfunding\Amount($componentParams);
$amount->setCurrency($currency);
$project = Crowdfunding\Project::getInstance(JFactory::getDbo(), $projectId);
$rewards = $project->getRewards(array('state' => Prism\Constants::PUBLISHED, 'order_by' => 'ordering', 'order_direction' => 'ASC'));
// Calculate the number of funders.
if ($params->get('display_funders', 0)) {
$rewards->countReceivers();
}
$additionalInfo = false;
if ($params->get('display_funders', 0) or $params->get('display_claimed', 0) or $params->get('display_delivery_date', 0)) {
$additionalInfo = true;
}
$layout = $params->get('layout', 'default');
switch ($layout) {
case '_:square':
case '_:thumbnail':
// Get the folder where the images are saved.
$userId = $project->getUserId();
$rewardsImagesUri = CrowdfundingHelper::getImagesFolderUri($userId);
JHtml::_('crowdfunding.jqueryFancybox');
$js = '
jQuery(document).ready(function() {
jQuery("a.js-rewards-images-gallery").fancybox();
});';
$doc = JFactory::getDocument();
$doc->addScriptDeclaration($js);
break;
default:
break;
}
require JModuleHelper::getLayoutPath('mod_crowdfundingrewards', $layout);
示例5: prepareRewards
protected function prepareRewards()
{
$model = JModelLegacy::getInstance("Rewards", "CrowdfundingModel", $config = array('ignore_request' => false));
// Get state
$this->state = $model->getState();
// Get params
$this->projectId = $this->state->get("rewards.project_id");
// Check if rewards are enabled.
if (!$this->rewardsEnabled) {
$this->app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_REWARDS_DISABLED"), "notice");
$this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getFormRoute($this->projectId, "manager"), false));
return;
}
$this->items = $model->getItems($this->projectId);
// Get project and validate it
$project = Crowdfunding\Project::getInstance(JFactory::getDbo(), $this->projectId);
$project = $project->getProperties();
$this->item = Joomla\Utilities\ArrayHelper::toObject($project);
// Check if the item exists.
if (!$this->isValid()) {
return;
}
// Create a currency object.
$this->currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get("project_currency"));
$this->amount = new Crowdfunding\Amount($this->params);
$this->amount->setCurrency($this->currency);
// Get date format
$this->dateFormat = CrowdfundingHelper::getDateFormat();
$this->dateFormatCalendar = CrowdfundingHelper::getDateFormat(true);
$language = JFactory::getLanguage();
$languageTag = $language->getTag();
$js = '
// Rewards calendar date format.
var projectWizard = {
dateFormat: "' . $this->dateFormatCalendar . '",
locale: "' . substr($languageTag, 0, 2) . '"
};
';
$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");
}
示例6: cropImage
public function cropImage()
{
// 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();
}
// Get the model
$model = $this->getModel();
/** @var $model CrowdfundingModelProject */
$projectId = $this->input->post->get("id");
// If there is a project, validate the owner.
if (!empty($projectId)) {
// Validate project owner.
$validator = new Crowdfunding\Validator\Project\Owner(JFactory::getDbo(), $projectId, $userId);
if (!$validator->isValid()) {
$response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'))->failure();
echo $response;
$app->close();
}
}
// Get the filename from the session.
$fileName = basename($app->getUserState(Crowdfunding\Constants::TEMPORARY_IMAGE_CONTEXT));
$temporaryFile = JPath::clean(CrowdfundingHelper::getTemporaryImagesFolder() . "/" . $fileName);
if (!$fileName or !JFile::exists($temporaryFile)) {
$response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_FILE_DOES_NOT_EXIST'))->failure();
echo $response;
$app->close();
}
$imageUrl = "";
try {
// Get the folder where the images will be stored
$destination = CrowdfundingHelper::getTemporaryImagesFolder();
$params = JComponentHelper::getParams("com_crowdfunding");
$options = array("width" => $this->input->getFloat("width"), "height" => $this->input->getFloat("height"), "x" => $this->input->getFloat("x"), "y" => $this->input->getFloat("y"), "destination" => $destination, "resize_width" => $params->get("image_width", 200), "resize_height" => $params->get("image_height", 200));
// Resize the picture.
$images = $model->cropImage($temporaryFile, $options);
$imageName = basename(Joomla\Utilities\ArrayHelper::getValue($images, "image"));
// Remove the temporary images if they exist.
$temporaryImages = $app->getUserState(Crowdfunding\Constants::CROPPED_IMAGES_CONTEXT);
if (!empty($temporaryImages)) {
$model->removeTemporaryImages($temporaryImages, $destination);
}
// If there is a project, store the images to database.
// If there is NO project, store the images in the session.
if (!empty($projectId)) {
$model->updateImages($projectId, $images, $destination);
$app->setUserState(Crowdfunding\Constants::CROPPED_IMAGES_CONTEXT, null);
// Get the folder of the images where the pictures will be stored.
$imageUrl = JUri::base() . CrowdfundingHelper::getImagesFolderUri() . "/" . $imageName;
} else {
$app->setUserState(Crowdfunding\Constants::CROPPED_IMAGES_CONTEXT, $images);
// Get the temporary folder where the images will be stored.
$imageUrl = JUri::base() . CrowdfundingHelper::getTemporaryImagesFolderUri() . "/" . $imageName;
}
} catch (RuntimeException $e) {
$response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText($e->getMessage())->failure();
echo $response;
$app->close();
} 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_SAVED'))->setData($imageUrl)->success();
echo $response;
$app->close();
}
示例7: prepareRewards
protected function prepareRewards()
{
$model = JModelLegacy::getInstance('Rewards', 'CrowdfundingModel', $config = array('ignore_request' => false));
// Get state
$this->state = $model->getState();
// Get params
$this->projectId = $this->state->get('rewards.project_id');
// Check if rewards are enabled.
if (!$this->rewardsEnabled) {
$this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_REWARDS_DISABLED'), 'notice');
$this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getFormRoute($this->projectId, 'manager'), false));
return;
}
$this->items = $model->getItems($this->projectId);
// Get project and validate it
$project = Crowdfunding\Project::getInstance(JFactory::getDbo(), $this->projectId);
$project = $project->getProperties();
$this->item = Joomla\Utilities\ArrayHelper::toObject($project);
// Check if the item exists.
if (!CrowdfundingHelper::isAuthorized($this->userId, $this->item, 'rewards')) {
$this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_SOMETHING_WRONG'), 'notice');
$this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute()));
return;
}
// Create a currency object.
$this->currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get('project_currency'));
$this->amount = new Crowdfunding\Amount($this->params);
$this->amount->setCurrency($this->currency);
// Get date format
$this->dateFormat = CrowdfundingHelper::getDateFormat();
$this->dateFormatCalendar = CrowdfundingHelper::getDateFormat(true);
$language = JFactory::getLanguage();
$languageTag = $language->getTag();
$js = '
// Rewards calendar date format.
var projectWizard = {
dateFormat: "' . $this->dateFormatCalendar . '",
locale: "' . substr($languageTag, 0, 2) . '"
};
';
$this->document->addScriptDeclaration($js);
// Prepare rewards images.
$this->rewardsImagesEnabled = (bool) $this->params->get('rewards_images', 0);
$this->rewardsImagesUri = CrowdfundingHelper::getImagesFolderUri($this->userId);
$this->options['column_left'] = (!$this->rewardsImagesEnabled or count($this->items) === 0) ? 12 : 8;
$this->options['column_right'] = (!$this->rewardsImagesEnabled or count($this->items) === 0) ? 0 : 4;
$this->prepareProjectType();
$this->pathwayName = JText::_('COM_CROWDFUNDING_STEP_REWARDS');
}