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


PHP JDate::getTimestamp方法代码示例

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


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

示例1: getPayoutAccessToken

 /**
  * Check if the user access token connected to payout exists. If it does not exist, returns null.
  *
  * If it exist, check for its expiration. If the token has been expired, refresh it with new one.
  *
  * @param array   $apiKeys
  * @param Payout  $payout
  * @param int     $expires
  *
  * @return Registry|AccessToken|null
  */
 public static function getPayoutAccessToken($apiKeys, Payout $payout, $expires = 7)
 {
     try {
         $token = $payout->getStripe();
         // Try to get an access token (using the authorization code grant)
         $alias = !$apiKeys['test'] ? 'production' : 'test';
         if ($token === null or !$token->get('stripeconnect.' . $alias . '.access_token')) {
             return null;
         }
         $options = array('access_token' => $token->get('stripeconnect.' . $alias . '.access_token'), 'refresh_token' => $token->get('stripeconnect.' . $alias . '.refresh_token'), 'expires' => $token->get('stripeconnect.' . $alias . '.expires'));
         $accessToken = new AccessToken($options);
         if ($accessToken->hasExpired()) {
             $provider = new Stripe(['clientId' => $apiKeys['client_id'], 'clientSecret' => $apiKeys['secret_key']]);
             $accessToken = $provider->getAccessToken('refresh_token', ['refresh_token' => $token->get('stripeconnect.' . $alias . '.refresh_token')]);
             // Prepare expiration date.
             $date = new \JDate();
             $date->add(new \DateInterval('P' . $expires . 'D'));
             $token->set('stripeconnect.' . $alias . '.access_token', $accessToken->getToken());
             $token->set('stripeconnect.' . $alias . '.refresh_token', $accessToken->getRefreshToken());
             $token->set('stripeconnect.' . $alias . '.expires', $date->getTimestamp());
             $payout->setStripe($token);
             $payout->storeStripe();
         }
     } catch (\Exception $e) {
         \JLog::add($e->getMessage());
         return null;
     }
     return $accessToken;
 }
开发者ID:bellodox,项目名称:CrowdfundingFinance,代码行数:40,代码来源:Helper.php

示例2: onPayoutsAuthorize

 /**
  * Authorize user to payment gateway.
  *
  * @param string                   $context
  * @param Joomla\Registry\Registry $params
  *
  * @return null|array
  */
 public function onPayoutsAuthorize($context, $params)
 {
     if (strcmp('com_crowdfundingfinance.payouts.authorize.stripeconnect', $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;
     }
     // Prepare output data.
     $output = array('redirect_url' => '', 'message' => '');
     $errorOutput = array('redirect_url' => JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute()), 'message' => '');
     // DEBUG DATA
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . '_DEBUG_GET_RESPONSE_AUTHORIZE'), $this->debugType, $_GET) : null;
     $userId = JFactory::getUser()->get('id');
     if (!$userId) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_NOT_REGISTERED_USER');
         return $errorOutput;
     }
     // Get token
     $code = $this->app->input->get('code');
     $state = $this->app->input->get('state');
     if (!$code or !$state) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_INVALID_AUTHORIZATION_DATA');
         return $errorOutput;
     }
     // Get project ID and redirect URL from the session.
     $stateData = $this->app->getUserState($state);
     if (count($stateData) === 0 or (!$stateData['redirect_url'] or !$stateData['project_id'])) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_INVALID_AUTHORIZATION_DATA');
         return $errorOutput;
     }
     $cfFinanceParams = JComponentHelper::getParams('com_crowdfundingfinance');
     $apiKeys = Crowdfundingfinance\Stripe\Helper::getKeys($cfFinanceParams);
     if (!$apiKeys['client_id'] or !$apiKeys['secret_key']) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_CONFIGURATION');
         return $errorOutput;
     }
     // Prepare expiration date.
     $date = new JDate();
     $date->add(new DateInterval('P' . $cfFinanceParams->get('stripe_expiration_period', '7') . 'D'));
     // Prepare Stripe data.
     $provider = new AdamPaterson\OAuth2\Client\Provider\Stripe(['clientId' => $apiKeys['client_id'], 'clientSecret' => $apiKeys['secret_key']]);
     $token = $provider->getAccessToken('authorization_code', ['code' => $code]);
     // Get resource owner.
     $resourceOwner = $provider->getResourceOwner($token);
     $alias = !$apiKeys['test'] ? 'production' : 'test';
     $stripe = new \Joomla\Registry\Registry(array('stripeconnect' => array($alias => array('access_token' => $token->getToken(), 'refresh_token' => $token->getRefreshToken(), 'expires' => $date->getTimestamp(), 'account_id' => $resourceOwner->getId()))));
     $payout = new Crowdfundingfinance\Payout(JFactory::getDbo());
     $payout->setSecretKey($this->app->get('secret'));
     $payout->load(array('project_id' => (int) $stateData['project_id']));
     // Create user record.
     if (!$payout->getId()) {
         $payout->setProjectId((int) $stateData['project_id']);
     }
     $payout->setStripe($stripe);
     $payout->store();
     // Get next URL.
     $output['redirect_url'] = base64_decode($stateData['redirect_url']);
     return $output;
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:75,代码来源:payoutoptions.php

示例3: getCalendar

 /**
  * Method to get the calendar input markup.
  *
  * @param   string  $display  The display to render ('static' or 'repeatable')
  *
  * @return  string	The field input markup.
  *
  * @since   2.1.rc4
  */
 protected function getCalendar($display)
 {
     // Initialize some field attributes.
     $format = $this->format ? $this->format : '%Y-%m-%d';
     $class = $this->class ? $this->class : '';
     $default = $this->element['default'] ? (string) $this->element['default'] : '';
     // Get some system objects.
     $config = $this->form->getContainer()->platform->getConfig();
     $user = $this->form->getContainer()->platform->getUser();
     // Check for empty date values
     if (empty($this->value) || $this->value == $this->form->getContainer()->platform->getDbo()->getNullDate() || $this->value == '0000-00-00') {
         $this->value = $default;
     }
     // Handle the special case for "now".
     if (strtoupper($this->value) == 'NOW') {
         $this->value = strftime($format);
     }
     // If a known filter is given use it.
     switch (strtoupper($this->filter)) {
         case 'SERVER_UTC':
             // Convert a date to UTC based on the server timezone.
             if ((int) $this->value) {
                 // Get a date object based on the correct timezone.
                 $date = \JFactory::getDate($this->value, 'UTC');
                 $date->setTimezone(new \DateTimeZone($config->get('offset')));
                 // Transform the date string.
                 $this->value = $date->format('Y-m-d H:i:s', true, false);
             }
             break;
         case 'USER_UTC':
             // Convert a date to UTC based on the user timezone.
             if ((int) $this->value) {
                 // Get a date object based on the correct timezone.
                 $date = \JFactory::getDate($this->value, 'UTC');
                 $date->setTimezone(new \DateTimeZone($user->getParam('timezone', $config->get('offset'))));
                 // Transform the date string.
                 $this->value = $date->format('Y-m-d H:i:s', true, false);
             }
             break;
     }
     if ($display == 'static') {
         // Build the attributes array.
         $attributes = array();
         if ($this->size) {
             $attributes['size'] = $this->size;
         }
         if ($this->maxlength) {
             $attributes['maxlength'] = $this->maxlength;
         }
         if ($this->class) {
             $attributes['class'] = $this->class;
         }
         if ($this->readonly) {
             $attributes['readonly'] = 'readonly';
         }
         if ($this->disabled) {
             $attributes['disabled'] = 'disabled';
         }
         if ($this->onchange) {
             $attributes['onchange'] = $this->onchange;
         }
         if ($this->required) {
             $attributes['required'] = 'required';
             $attributes['aria-required'] = 'true';
         }
         // Including fallback code for HTML5 non supported browsers.
         JHtml::_('jquery.framework');
         JHtml::_('script', 'system/html5fallback.js', false, true);
         return JHtml::_('calendar', $this->value, $this->name, $this->id, $format, $attributes);
     } else {
         if (!$this->value && (string) $this->element['empty_replacement']) {
             $value = $this->element['empty_replacement'];
         } else {
             $jDate = new \JDate($this->value);
             $value = strftime($format, $jDate->getTimestamp());
         }
         return '<span class="' . $this->id . ' ' . $class . '">' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '</span>';
     }
 }
开发者ID:akeeba,项目名称:fof,代码行数:88,代码来源:Calendar.php

示例4: jimport

			<th rowspan="2"><?php echo JText::_('COM_AKEEBAEXAMPLE_LIST_FIELD_TYPE');?></th>
			<th rowspan="2"><?php echo JText::_('COM_AKEEBAEXAMPLE_LIST_FIELD_PROFILEID');?></th>
			<th rowspan="2"><?php echo JText::_('COM_AKEEBAEXAMPLE_LIST_FIELD_TOTALSIZE');?></th>
		</tr>
		<tr>
			<th><?php echo JText::_('COM_AKEEBAEXAMPLE_LIST_FIELD_START');?></th>
			<th><?php echo JText::_('COM_AKEEBAEXAMPLE_LIST_FIELD_DURATION');?></th>
		</tr>
	</thead>
	<tbody>
		<?php jimport('joomla.utilities.date'); ?>
		<?php foreach($this->items as $item): ?>
		<?php
			$dateFrom = new JDate($item->backupstart);
			$dateTo = new JDate($item->backupend);
			$duration = $dateTo->getTimestamp() - $dateFrom->getTimestamp();
		?>
		<tr>
			<td><?php echo $this->escape($item->id)?></td>
			<td><?php echo $this->escape($item->description)?></td>
			<td><?php echo $dateFrom->format('Y-m-d H:i:s');?></td>
			<td><?php echo $duration ?></td>
			<td><?php echo $item->status?></td>
			<td><?php echo $item->origin?></td>
			<td><?php echo $item->type?></td>
			<td><?php echo $item->profile_id?></td>
			<td><?php echo $item->total_size?></td>
		</tr>
		<?php endforeach; ?>
	</tbody>
</table>
开发者ID:nikosdion,项目名称:Akeeba-Example,代码行数:31,代码来源:default.php


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