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


PHP JDate::getInstance方法代码示例

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


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

示例1: getModel

 private function getModel($contentIds, $count)
 {
     $dbo = JFactory::getDBO();
     $nullDate = $dbo->getNullDate();
     $date = JFactory::getDate();
     $now = JDate::getInstance()->toSql($date);
     $query = $dbo->getQuery(true);
     $query->select('a . id');
     $query->select('a . title');
     $query->select('a . alias');
     $query->select('a . access');
     $query->select('CASE WHEN CHAR_LENGTH(a . alias) THEN CONCAT_WS(":", a . id, a . alias) ELSE a . id END as slug');
     $query->select('CASE WHEN CHAR_LENGTH(cc . alias) THEN CONCAT_WS(":", cc . id, cc . alias) ELSE cc . id END as catslug');
     $query->from('#__content AS a');
     $query->innerJoin('#__categories AS cc ON cc.id = a.catid');
     $query->where('a.id in(' . @implode(',', $contentIds) . ')');
     $query->where('a.state = 1');
     $query->where('( a.publish_up = ' . $dbo->Quote($nullDate) . ' OR a.publish_up <= ' . $dbo->Quote($now) . ' )');
     $query->where('( a.publish_down = ' . $dbo->Quote($nullDate) . ' OR a.publish_down >= ' . $dbo->Quote($now) . ' )');
     $query->where('cc.published = 1');
     $dbo->setQuery($query, 0, $count);
     //$queryDump = $query->dump();
     $rows = $dbo->loadObjectList();
     return $rows;
 }
开发者ID:lautarodragan,项目名称:ideary,代码行数:25,代码来源:joomla.php

示例2: authenticate

 private function authenticate($username, $password = null, $valid = 86400)
 {
     // Get a database object
     $db = JFactory::getDbo();
     // Look for any tokens for this user
     $db->setQuery($db->getQuery(true)->select('*')->from('#__rvs_user_tokens')->where('uid=' . $db->q($result->id)));
     $obj = $db->loadObject();
     // If there is already a valid token, just return that, otherwise try to create one
     if ($obj->valid > JDate::getInstance()->toUnix()) {
         return $obj->token;
     } else {
         $db->setQuery($db->getQuery(true)->select('id, password')->from('#__users')->where('username=' . $db->q($username)));
         $result = $db->loadObject();
         $parts = explode(':', $result->password);
         $crypt = $parts[0];
         $salt = @$parts[1];
         $testcrypt = JUserHelper::getCryptedPassword($password, $salt);
         if ($crypt == $testcrypt) {
             // Authentication successful, create a token and populate the table
             $obj = new stdClass();
             $obj->uid = $result->id;
             $obj->token = md5(rand() . $salt);
             $obj->valid = JDate::getInstance()->toUnix() + $valid;
             $db->setQuery($db->getQuery(true)->select('uid')->from('#__rvs_user_tokens')->where('uid=' . $db->q($obj->uid)));
             if ($db->loadResult()) {
                 $db->updateObject('#__rvs_user_tokens', $obj, 'uid');
             } else {
                 $db->insertObject('#__rvs_user_tokens', $obj, 'uid');
             }
             return $obj->token;
         }
     }
     return null;
 }
开发者ID:rvsjoen,项目名称:joomla-extensions,代码行数:34,代码来源:rvs_token.php

示例3: onAfterRoute

	function onAfterRoute()
	{
		$input = $this->_app->input;
		$option = $input->get('option', false);
		$is_testemail = $input->get('plg_testemail', false);
		
		if($option != 'com_config' || !$is_testemail){
			return true;
		}
		
		$from 	= $input->get('from_email', false, 'string');
		$sender = $input->get('from_name', false);
		$date 	= JDate::getInstance()->toSql();
		
		$subject = JText::_('PLG_SYSTEM_TESTEMAIL_EMAIL_SUBJECT');
		$body 	 = JText::sprintf('PLG_SYSTEM_TESTEMAIL_EMAIL_BODY', $date);
		$result	 = array();
		$message = JText::_('PLG_SYSTEM_TESTEMAIL_MESSAGE_SUCCESS');
		$state	 = 'message';
		
		$mailer = self::createMailer();
		
		if ($mailer->sendMail($from, $sender, $from, $subject, $body) !== true)
		{
			$this->_error();
		}
		
		$this->_success();
	}
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:29,代码来源:emailconfigverifier.php

示例4: onContentBeforeSave

 /**
  * Plugin that manipulate uploaded images
  *
  * @param   string   $context       The context of the content being passed to the plugin.
  * @param   object   &$object_file  The file object.
  *
  * @return  object  The file object.
  */
 public function onContentBeforeSave($context, &$object_file)
 {
     // Are we in the right context?
     if ($context != 'com_media.file') {
         return;
     }
     // Get the current date
     $date = JDate::getInstance('now');
     // Respect the timezone
     $config = JFactory::getConfig();
     $date->setTimezone(new DateTimeZone($config->get('offset')));
     // Set current year, month, day
     $year = $date->year;
     $month = $date->month;
     $day = $date->day;
     // Set the images subfolder, defaults to images/uploads
     $folder = $this->params->get('folder');
     $folder = isset($folder) ? $folder . '/' : '';
     $basePath = JPATH_ROOT . '/images/' . $folder;
     // Make some directories checks
     if (!is_dir(rtrim($basePath, "/"))) {
         mkdir(rtrim($basePath, "/"));
     }
     if (!is_dir($basePath . $year)) {
         mkdir($basePath . $year);
     }
     if (!is_dir($basePath . $year . '/' . $month)) {
         mkdir($basePath . $year . '/' . $month);
     }
     if (!is_dir($basePath . $year . '/' . $month . '/' . $day)) {
         mkdir($basePath . $year . '/' . $month . '/' . $day);
     }
     // Update the object to the new path
     $object_file->filepath = $basePath . $year . '/' . $month . '/' . $day . '/' . $object_file->name;
     return $object_file;
 }
开发者ID:brianteeman,项目名称:imageUploaderHelper,代码行数:44,代码来源:uploader.php

示例5: getTimestamp

 private function getTimestamp($ts)
 {
     $app = JFactory::getApplication();
     $tsDate = date("Y-m-d H:i:s", $ts);
     $offsetDate = JDate::getInstance($tsDate, JFactory::getConfig()->get('offset'));
     $updates = array('newestTS' => $ts, 'ts' => $ts, 'offset' => $offsetDate, 'pois' => null, 'categories' => null, 'steps' => null, 'votes' => null, 'comments' => null);
     $app->input->set('ts', $ts);
     //$updates['pois'] = self::pois(false);
     //$updates['categories'] = self::categories(false);
     //$updates['steps'] = self::steps(false);
     //$updates['votes'] = self::votes(false);
     //$updates['comments'] = self::comments(false);
     return $updates;
 }
开发者ID:7thZoneTechnology,项目名称:citybranding,代码行数:14,代码来源:api.json.php

示例6: unifyDate

 /**
  * Unify the api dates
  *
  * @param $date
  *
  * @return JDate
  */
 protected function unifyDate($date)
 {
     $timeZone = isset($date->timezone) ? $date->timezone : null;
     if (isset($date->dateTime)) {
         return JDate::getInstance($date->dateTime, $timeZone);
     }
     return JDate::getInstance($date->date, $timeZone);
 }
开发者ID:nternetinspired,项目名称:joomlade,代码行数:15,代码来源:helper.php

示例7: save

 /**
  * Saves an issue entity.
  *
  * @param   JInput  $input  Holds the data to be saved.
  *
  * @return  int   ID of the inserted / saved object.
  *
  * @throws Exception
  */
 public function save($input)
 {
     $query = $this->db->getQuery(true);
     $user = JFactory::getUser();
     // Validate form data.
     $values = array("title" => $input->getString('title'), "text" => $input->getString('text'), "version" => $input->getString('version'), "project_id" => $input->getInt('project_id'), "classification" => $input->getInt('classification'));
     $values = $this->validate($values);
     if (!$values) {
         return false;
     }
     // Validate attachments.
     $params = $this->getParams();
     $enableAttachments = $params->get('issue_enable_attachments', 1);
     if ($enableAttachments) {
         $modelAttachments = new MonitorModelAttachments();
         $files = $input->files->get('file', null, 'raw');
         if (($files = $this->validateFiles($files, $values, $modelAttachments)) === null) {
             return false;
         }
     }
     $id = $input->getInt('id');
     if ($id != 0) {
         $query->update('#__monitor_issues')->where('id = ' . $id);
     } else {
         $values["author_id"] = $user->id;
         $query->insert('#__monitor_issues');
     }
     $values["created"] = JDate::getInstance()->toSql();
     $query->set(MonitorHelper::sqlValues($values, $query));
     $this->db->setQuery($query);
     $this->db->execute();
     if ($id == 0) {
         $id = $this->db->insertid();
     }
     if ($enableAttachments) {
         // Upload attachments
         $modelAttachments->upload($files, $id);
     }
     return $id;
 }
开发者ID:Harmageddon,项目名称:com_monitor,代码行数:49,代码来源:issue.php

示例8: getCountdown

 static function getCountdown($params)
 {
     // Explicitly disable caching for this module
     $params->set('cache', 0);
     // look for events import plugins
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('system');
     $result = $dispatcher->trigger('onCountdownGetEventsQueue', array('mod_smartcountdown', $params));
     if (in_array(false, $result, true)) {
         return false;
     }
     // get combined events queue from all plugins
     $groups = self::unionQueues($result);
     if ($groups === false || $params->get('session_time_count', 0) || $params->get('submit_form', '')) {
         // all elements of the result array === true: means that no plugin
         // is enabled. This is not an error, just get internal countdown
         // Also if counter mode is set to "relative to session start" or
         // "submit form on countdown zero" is not empty, we ignore all plugin data
         return self::getInternal($params);
     }
     // we have event queue here, let's proceed
     $show_countdown = $params->get('show_countdown', -1);
     // auto
     $now_ts = JDate::getInstance()->getTimestamp();
     /**
      * Queue format: 2-dimensional array
      * 1-st dimension - events indexed by start time
      * 2-nd dimension - events indexed by end time
      */
     /*
      * Re-process all events provided by events import plugins.
      * *** current versions of plugins can be significantly simplified ***
      * For new plugins - no need to calculate diff_js and up_limit in plugin
      * code, as these values will be overwritten here. At the moment it is just
      * a performance issue
      */
     $past_slice = null;
     $start_times = array_keys($groups);
     foreach ($start_times as $i => $time) {
         // we have to filter out all past groups except the most recent one
         if ($time < $now_ts) {
             if (isset($past_slice)) {
                 // we can safely use $i - 1 index, as $past_slice will never be
                 // set on the first iteration s_tyles
                 // unset previous group
                 unset($groups[$start_times[$i - 1]]);
             }
             // set flag: at least one past event found
             $past_slice = $time;
         }
         $next_start = @$start_times[$i + 1];
         if (isset($next_start)) {
             $events_hop = $next_start - $time;
         } else {
             $events_hop = PHP_INT_MAX - $time;
         }
         foreach ($groups[$time] as $end => &$event) {
             $duration = $end - $time;
             if ($show_countdown == 0) {
                 // do not show countdown - conrinue count up until the next event start
                 $event['up_limit'] = $events_hop;
             } else {
                 if ($show_countdown == -2) {
                     // do not show count up - start countdown right after previous event start
                     $event['up_limit'] = 0;
                 } else {
                     if ($show_countdown == -1) {
                         // auto - use event duration
                         $event['up_limit'] = $events_hop == 0 || $events_hop > $duration ? $duration : $events_hop;
                     } else {
                         if ($show_countdown > 0) {
                             // positive value means time to show countdown before the next event start
                             // if greater than events hop, use event hop instead
                             $event['up_limit'] = $events_hop > $show_countdown ? $events_hop - $show_countdown : $events_hop;
                         } else {
                             // negative value means time to show count up after the event start
                             // if greater than events hop, use event hop instead
                             $show_countup = $show_countdown * -1;
                             $event['up_limit'] = $show_countup > $events_hop ? $events_hop : $show_countup;
                         }
                     }
                 }
             }
             // up_limit can never be greater than duration
             $event['up_limit'] = min($event['up_limit'], $duration);
         }
     }
     // Concatenate titles for duplicate-time events. We add support for different titles
     // in countdown and count up modes. Plugins can e.g. configure event links according
     // to their settings
     // We presume that if $tevent['title'] is set we have equal titles for both modes,
     // otherwise we look in $tevent['title_down'] and $tevent['title_up'] properties
     $titles_down = array();
     $titles_up = array();
     foreach ($groups as $time => $tgroup) {
         foreach (array_reverse($tgroup, true) as $tevent) {
             if (isset($tevent['title'])) {
                 // the same title for both countdown and count up modes
                 if (isset($titles_down[$time])) {
                     $titles_down[$time][''] = $tevent['title'] . ', ' . $titles_down[$time][''];
//.........这里部分代码省略.........
开发者ID:ankaau,项目名称:GathBandhan,代码行数:101,代码来源:helper.php

示例9: testGetInstance

 /**
  * Tests the getInstance method.
  *
  * @return  void
  *
  * @since   11.3
  * @covers  JDate::getInstance
  */
 public function testGetInstance()
 {
     $this->assertThat(JDate::getInstance(), $this->isInstanceOf('JDate'));
     JDate::$format = 'Y-m-d H:i:s';
     $this->assertThat((string) JDate::getInstance('2000-01-01 00:00:00'), $this->equalTo('2000-01-01 00:00:00'));
 }
开发者ID:sural98,项目名称:joomla-cms,代码行数:14,代码来源:JDateTest.php

示例10: getHiddenFields

 /**
  * Generate and return the hidden fields.
  *
  * <code>
  * $keys = array(
  *      "api_login_id"      => "....",
  *      "transaction_key"   => "...."
  * );
  *
  * $dpm   = new Prism\Payment\AuthorizeNet\Service\Dpm($keys);
  * $hiddenFields = $dpm->getHiddenFields();
  * </code>
  *
  * @return array
  */
 public function getHiddenFields()
 {
     $date = \JDate::getInstance();
     $this->setTimestamp($date->toUnix());
     $this->generateFingerprint($this->transactionKey);
     // Exclude these params
     $excluded = array("transactionKey");
     return $this->getHiddenFieldsArray($excluded);
 }
开发者ID:bellodox,项目名称:PrismLibrary,代码行数:24,代码来源:Dpm.php

示例11: setModifiedDate

 /**
  * Method to set the modified date.
  *
  * @param   mixed  $date  The date as a string or JDate object.
  *
  * @return  void
  *
  * @since   12.1
  * @throws  InvalidArgumentException
  */
 protected function setModifiedDate($date)
 {
     // Convert the date if necessary.
     if (is_string($date)) {
         $date = JDate::getInstance($date);
     }
     // Verify the date is valid.
     if (!$date instanceof JDate) {
         throw new InvalidArgumentException(JText::_('JCONTENT_INVALID_DATE_TYPE'));
     }
     // Set the modified date.
     $this->setProperty('modified_date', $date->format($this->db->getDateFormat()), false);
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:23,代码来源:content.php

示例12: dateToSql

 private function dateToSql($date)
 {
     $start_date = \JDate::getInstance(str_replace('/', '-', $date));
     return $start_date->toSql();
 }
开发者ID:houzhenggang,项目名称:cobalt,代码行数:5,代码来源:GoalTable.php

示例13: store

 /**
  * @param $name
  * @param null $description
  * @param int $weight
  * @return bool|int
  */
 public function store($name, $description = null, $weight = 0)
 {
     $dbo = JFactory::getDbo();
     $cedTagsHelper = new CedTagsHelper();
     $name = $cedTagsHelper->isValidName($name);
     if (!$name) {
         return false;
     }
     $cedTagModelTag = new CedTagModelTag();
     $tagAlreadyExisting = $cedTagModelTag->getTagId($name);
     if (isset($tagAlreadyExisting) & isset($tagAlreadyExisting->id)) {
         $needUpdate = false;
         $updateQuery = 'update #__cedtag_term set ';
         if (isset($description) && !empty($description)) {
             $needUpdate = true;
             $updateQuery .= "description='" . $description . "'";
         }
         if (isset($weight)) {
             if ($needUpdate) {
                 $updateQuery .= ', weight=' . $weight;
             } else {
                 $updateQuery .= ' weight=' . $weight;
                 $needUpdate = true;
             }
         }
         if ($needUpdate) {
             $updateQuery .= ' where id=' . $tagAlreadyExisting->id;
             $dbo->setQuery($updateQuery);
             $dbo->query();
         }
         return $tagAlreadyExisting->id;
     } else {
         $insertQuery = "insert into #__cedtag_term (name";
         $valuePart = " values('" . $name . "'";
         if (isset($description) && !empty($description)) {
             $insertQuery .= ",description";
             $valuePart .= ",'" . $description . "'";
         }
         if (isset($weight)) {
             $insertQuery .= ",weight";
             $valuePart .= "," . $weight;
         }
         $date = JFactory::getDate();
         $now = JDate::getInstance()->toSql($date);
         $insertQuery .= ',created) ';
         $valuePart .= ',' . $dbo->Quote($now) . ')';
         $dbo->setQuery($insertQuery . $valuePart);
         $dbo->query();
         return $dbo->insertid();
     }
 }
开发者ID:lautarodragan,项目名称:ideary,代码行数:57,代码来源:term.php

示例14: defined

<?php

defined('_JEXEC') or die;
?>
<ul class="next-events">
	<?php 
foreach ($events as $event) {
    ?>
		<li class="event" itemscope itemtype="http://schema.org/Event">
			<meta itemprop="startDate" content="<?php 
    echo JDate::getInstance($event->startDate)->toISO8601(true);
    ?>
">
			<meta itemprop="endDate" content="<?php 
    echo JDate::getInstance($event->endDate)->toISO8601(true);
    ?>
">
			<div class="event-name">
				<?php 
    if ($params->get('show_link', true)) {
        ?>
				<a href="<?php 
        echo $event->htmlLink;
        ?>
" target="_blank">
					<?php 
    }
    ?>
					<span itemprop="name"><?php 
    echo $event->summary;
    ?>
开发者ID:nternetinspired,项目名称:joomlade,代码行数:31,代码来源:default.php

示例15: getInput

    protected function getInput()
    {
        global $expose;
        // necessary Joomla! classes
        $uri = JURI::getInstance();
        $db = JFactory::getDBO();
        $app = JFactory::getApplication();
        // variables from URL
        $tid = $uri->getVar('id', '');
        $task = $uri->getVar('config_task', '');
        $file = $uri->getVar('config_file', '');
        if ($file !== '') {
            $file = $file . '.json';
        }
        //if file name is given add its extension
        $path = JPATH_ROOT . '/templates/' . getTemplate($tid) . '/configs/';
        // helping variables
        $redirectUrl = $uri->root() . 'administrator/index.php?option=com_templates&view=style&layout=edit&id=' . $tid;
        $saveUrl = $redirectUrl . '&config_task=save&config_file=';
        $loadUrl = $redirectUrl . '&config_task=load&config_file=';
        // if the URL contains proper variables
        if ($tid !== 'none' && is_numeric($tid) && $task !== '') {
            if ($task == 'load') {
                if (JFile::exists($path . $file)) {
                    // Insert the params into DB
                    $query = '
						UPDATE 
							#__template_styles
						SET	
							params = ' . $db->quote(file_get_contents($path . $file)) . '
						WHERE 
						 	id = ' . $tid . '
						LIMIT 1
						';
                    // Executing SQL Query
                    $db->setQuery($query);
                    $result = $db->query();
                    // check the result
                    if ($result) {
                        // Redirect
                        $app->redirect($redirectUrl, $file . JText::_('CONFIGURATOR_LOADED_AND_SAVED'), 'message');
                    } else {
                        // Redirect
                        $app->redirect($redirectUrl, JText::_('CONFIGURATOR_SQL_ERROR'), 'error');
                    }
                } else {
                    // Redirect
                    $app->redirect($redirectUrl, JText::_('CONFIGURATOR_SELECTED_FILE_DOESNT_EXIST'), 'error');
                }
            } else {
                if ($task == 'save') {
                    if ($file == '') {
                        $date = JDate::getInstance();
                        $file = $date->format('Ymd-His') . '.json';
                    }
                    // write it
                    if (JFile::write($path . $file, $this->getParams($tid)->params)) {
                        $app->redirect($redirectUrl, JText::_('CONFIGURATOR_SAVED_AS') . $file . JText::_('CONFIGURATOR_SAVED_IN') . $path, 'message');
                    } else {
                        $app->redirect($redirectUrl, JText::_('CONFIGURATOR_FAILED_CHECK_PERM'), 'error');
                    }
                }
            }
        }
        // generate the select list
        $options = (array) $this->getOptions($tid);
        $file_select = JHtml::_('select.genericlist', $options, 'name', '', 'value', 'text', '0', 'config-load-filename');
        // return the standard formfield output
        $html = '';
        $class = $this->element['class'];
        $wrapstart = '<div class="clearfix ' . $class . '">';
        $wrapend = '</div>';
        //button
        $html .= "<p class='mod-chrome-button config-btn gradient hasTip' rel='#configurator-form' title='::" . JText::_($this->description) . "'><span>" . JText::_('CONFIGURATOR_BTN_LABEL') . "</span></p>";
        $html .= '<div id="configurator-form">';
        $html .= '<h3>' . JText::_('CONFIGURATOR_TITLE') . '</h3>';
        $html .= '<p class="alert-message">' . JText::_('CONFIGURATOR_MSG') . '</p>';
        $html .= '<div><span class="label">' . JText::_('CONFIGURATOR_LOAD_LABEL') . '</span>' . $file_select . '<a id="configurator-load" class="gradient" href="#">' . JText::_('CONFIGURATOR_LOAD_BTN') . '</a> </div>';
        $html .= '<div><span class="label">' . JText::_('CONFIGURATOR_SAVE_LABEL') . '</span> <input type="text" id="configurator-save-filename" /><span style="margin-top: 5px;">.json</span> <a id="configurator-save" class="gradient" href="#">' . JText::_('CONFIGURATOR_SAVE_BTN') . ' </a></div>';
        $html .= '</div>';
        // Js
        $js = "\n\n            var file, url = '';\n\n            \$('#configurator-save').on('click', function(e)\n            {\n                e.preventDefault();\n                if ( file = \$('#configurator-save-filename').val() )\n                {\n                    url  = '{$saveUrl}' + file ;\n                    window.location = url;\n                }else{\n\n                    alert('" . JText::_('CONFIGURATOR_FILENAME_EMPTY_ERROR') . "');\n                    return;\n                }\n            });\n\n            \$('#configurator-load').on('click', function(e)\n            {\n                e.preventDefault();\n                file = \$('#config-load-filename').val();\n                url  = '{$loadUrl}' + file ;\n\n                window.location = url;\n            });\n\n        ";
        $expose->addjQDom($js);
        // finish the output
        return $wrapstart . $html . $wrapend;
    }
开发者ID:pguilford,项目名称:vcomcc,代码行数:86,代码来源:configurator.php


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