本文整理汇总了PHP中CrowdfundingHelper::getDateFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP CrowdfundingHelper::getDateFormat方法的具体用法?PHP CrowdfundingHelper::getDateFormat怎么用?PHP CrowdfundingHelper::getDateFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CrowdfundingHelper
的用法示例。
在下文中一共展示了CrowdfundingHelper::getDateFormat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadFormData
/**
* 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;
}
示例2: 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');
}
示例3: 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");
}
示例4: calendar
/**
* Displays a calendar control field based on Twitter Bootstrap 3
*
* @param string $value The date value
* @param string $name The name of the text field
* @param string $id The id of the text field
* @param string $format The date format
* @param mixed $attributes Additional HTML attributes
*
* @return string HTML markup for a calendar field
*
* @since 1.5
* @see http://eonasdan.github.io/bootstrap-datetimepicker/
*/
public static function calendar($value, $name, $id, $format = 'Y-m-d', $attributes = null)
{
static $done;
if ($done === null) {
$done = array();
}
$readonly = isset($attributes['readonly']) && $attributes['readonly'] == 'readonly';
$disabled = isset($attributes['disabled']) && $attributes['disabled'] == 'disabled';
if (is_array($attributes)) {
$attributes['class'] = isset($attributes['class']) ? $attributes['class'] : 'form-control';
$attributes['class'] = trim($attributes['class'] . ' hasTooltip');
$attributes = JArrayHelper::toString($attributes);
}
// Format value when not nulldate ('0000-00-00 00:00:00'), otherwise blank it as it would result in 1970-01-01.
if ((int) $value && $value != JFactory::getDbo()->getNullDate()) {
$date = new DateTime($value, new DateTimeZone('UTC'));
$inputvalue = $date->format($format);
} else {
$inputvalue = '';
}
// Load the calendar behavior
JHtml::_('prism.ui.bootstrap3Datepicker');
$languageTag = JFactory::getLanguage()->getTag();
$locale = substr($languageTag, 0, 2);
// Only display the triggers once for each control.
if (!in_array($id, $done)) {
$calendarDateFormat = CrowdfundingHelper::getDateFormat(true);
$document = JFactory::getDocument();
$document->addScriptDeclaration('jQuery(document).ready(function($) {
jQuery("#' . $id . '_datepicker").datetimepicker({
format: "' . $calendarDateFormat . '",
locale: "' . \JString::strtolower($locale) . '",
allowInputToggle: true
});
});');
$done[] = $id;
}
// Hide button using inline styles for readonly/disabled fields
$btn_style = $readonly || $disabled ? ' style="display:none;"' : '';
return '<div class="input-group date" id="' . $id . '_datepicker">
<input type="text" title="' . ($inputvalue ? JHtml::_("date", $value, null, null) : "") . '"
name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($inputvalue, ENT_COMPAT, 'UTF-8') . '" ' . $attributes . ' />
<span class="input-group-addon" id="' . $id . '_img">
<span class="glyphicon glyphicon-calendar" id="' . $id . '_icon"' . $btn_style . '></span>
</span>
</div>';
}