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


PHP JDate::setTimezone方法代码示例

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


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

示例1: correctTimeOffset

 function correctTimeOffset(&$inputDate)
 {
     $config = JFactory::getConfig();
     $this->siteOffset = $config->get('offset');
     $date = new JDate($inputDate);
     $date->setTimezone($this->siteTimezone);
     $inputDate = $date->format('Y-m-d H:i:s', true);
 }
开发者ID:lenard112,项目名称:cms,代码行数:8,代码来源:report.php

示例2: convert

 /**
  * Convert a date string to another timezone.
  *
  * @param string $date
  * @param string $from
  * @param string $to
  * @param string $format
  *
  * @return  string
  */
 public static function convert($date, $from = 'UTC', $to = 'UTC', $format = null)
 {
     if (!$format) {
         /** @var \JDatabaseDriver $db */
         $db = Container::getInstance()->get('db');
         $format = $db->getDateFormat();
     }
     $from = $from instanceof \DateTimeZone ? $from : new \DateTimeZone($from);
     $to = $to instanceof \DateTimeZone ? $to : new \DateTimeZone($to);
     $date = new \JDate($date, $from);
     $date->setTimezone($to);
     return $date->format($format, true);
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:23,代码来源:DateHelper.php

示例3: saveCatg

function saveCatg()
{
    require JPATH_COMPONENT_ADMINISTRATOR . DS . 'config.datsogallery.php';
    $is_admin = array(7, 8);
    $db = JFactory::getDBO();
    $user = JFactory::getUser();
    $userGroups = JAccess::getGroupsByUser($user->id, true);
    $post = JRequest::get('post');
    //$post['description'] = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);
    $row = new DatsoCategories($db);
    if (!array_intersect($is_admin, $userGroups)) {
        $category = explode(',', $ad_category);
        $getfirst = array_shift($category);
        $db->setQuery('SELECT cid' . ' FROM #__datsogallery_catg' . ' WHERE user_id = ' . (int) $user->id . ' AND parent = ' . $ad_category);
        $result = $db->loadResult();
        $row->parent = $result ? $result : $ad_category;
        $row->ordering = $row->getNextOrder('parent = ' . $row->parent);
    } else {
        $row->ordering = $row->getNextOrder('parent = 0');
    }
    $row->user_id = $user->id;
    $row->approved = !$user_categories_approval || array_intersect($is_admin, $userGroups) ? 1 : 0;
    $row->published = 1;
    jimport('joomla.utilities.date');
    $dtz = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
    $date = new JDate($row->date);
    $date->setTimezone($dtz);
    $row->date = $date->toMySQL(true);
    if (!$row->bind($post)) {
        JError::raiseError(500, $row->getError());
    }
    if (!$row->check()) {
        JError::raiseError(500, $row->getError());
    }
    if (!$row->store()) {
        JError::raiseError(500, $row->getError());
    }
    if ($ad_category_notify && !array_intersect($is_admin, $userGroups)) {
        categoryNotify($user->username, $post['name']);
    }
}
开发者ID:j0rg3m414,项目名称:centerar,代码行数:41,代码来源:datso.usercategory.php

示例4: testdate

 function testdate($date, $format)
 {
     $date = new JDate($date, new DateTimeZone("UTC"));
     $date->setTimezone(FSF_Helper::getTimezone());
     return $date->format($format, true);
 }
开发者ID:sansandeep143,项目名称:av,代码行数:6,代码来源:view.html.php

示例5: DateTimeZone

<?php

/**
* @copyright (C) 2013 iJoomla, Inc. - All rights reserved.
* @license GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html)
* @author iJoomla.com <webmaster@ijoomla.com>
* @url https://www.jomsocial.com/license-agreement
* The PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript *are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0
* More info at https://www.jomsocial.com/license-agreement
*/
defined('_JEXEC') or die;
$timeZone = new DateTimeZone(JFactory::getConfig()->get('offset'));
$jnow = new JDate();
$jnow->setTimezone($timeZone);
$params = JComponentHelper::getParams('com_media');
$fileExtensions = $params->get('upload_extensions');
$config = CFactory::getConfig();
$enableFileSharing = (int) $config->get('message_file_sharing');
$maxFileSize = (int) $config->get('message_file_maxsize');
?>

<div class="joms-popup__content">
    <div class="joms-stream__header" style="padding:0">
        <div class= "joms-avatar--stream <?php 
echo CUserHelper::onlineIndicator($user);
?>
"><img src="<?php 
echo $user->getThumbAvatar();
?>
" alt="<?php 
echo $user->getDisplayName();
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:31,代码来源:inbox.ajaxcompose.php

示例6: getListQuery

 /**
  * Build an SQL query to load the list data.
  *
  * @return  JDatabaseQuery
  *
  * @since   1.6
  */
 protected function getListQuery()
 {
     // Create a new query object.
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     // Select the required fields from the table.
     $query->select($this->getState('list.select', 'a.*'));
     $query->from($db->quoteName('#__users') . ' AS a');
     // If the model is set to check item state, add to the query.
     $state = $this->getState('filter.state');
     if (is_numeric($state)) {
         $query->where('a.block = ' . (int) $state);
     }
     // If the model is set to check the activated state, add to the query.
     $active = $this->getState('filter.active');
     if (is_numeric($active)) {
         if ($active == '0') {
             $query->where('a.activation = ' . $db->quote(''));
         } elseif ($active == '1') {
             $query->where($query->length('a.activation') . ' = 32');
         }
     }
     // Filter the items over the group id if set.
     $groupId = $this->getState('filter.group_id');
     $groups = $this->getState('filter.groups');
     if ($groupId || isset($groups)) {
         $query->join('LEFT', '#__user_usergroup_map AS map2 ON map2.user_id = a.id');
         $query->group($db->quoteName(array('a.id', 'a.name', 'a.username', 'a.password', 'a.usertype', 'a.block', 'a.sendEmail', 'a.registerDate', 'a.lastvisitDate', 'a.activation', 'a.params', 'a.email')));
         if ($groupId) {
             $query->where('map2.group_id = ' . (int) $groupId);
         }
         if (isset($groups)) {
             $query->where('map2.group_id IN (' . implode(',', $groups) . ')');
         }
     }
     // Filter the items over the search string if set.
     if ($this->getState('filter.search') !== '') {
         // Escape the search token.
         $token = $db->Quote('%' . $db->escape($this->getState('filter.search')) . '%');
         // Compile the different search clauses.
         $searches = array();
         $searches[] = 'a.name LIKE ' . $token;
         $searches[] = 'a.username LIKE ' . $token;
         $searches[] = 'a.email LIKE ' . $token;
         // Add the clauses to the query.
         $query->where('(' . implode(' OR ', $searches) . ')');
     }
     // Add filter for registration ranges select list
     $range = $this->getState('filter.range');
     // Apply the range filter.
     if ($range = $this->getState('filter.range')) {
         // Get UTC for now.
         $dNow = new JDate();
         $dStart = clone $dNow;
         switch ($range) {
             case 'past_week':
                 $dStart->modify('-7 day');
                 break;
             case 'past_1month':
                 $dStart->modify('-1 month');
                 break;
             case 'past_3month':
                 $dStart->modify('-3 month');
                 break;
             case 'past_6month':
                 $dStart->modify('-6 month');
                 break;
             case 'post_year':
             case 'past_year':
                 $dStart->modify('-1 year');
                 break;
             case 'today':
                 // Ranges that need to align with local 'days' need special treatment.
                 $app = JFactory::getApplication();
                 $offset = $app->getCfg('offset');
                 // Reset the start time to be the beginning of today, local time.
                 $dStart = new JDate('now', $offset);
                 $dStart->setTime(0, 0, 0);
                 // Now change the timezone back to UTC.
                 $tz = new DateTimeZone('GMT');
                 $dStart->setTimezone($tz);
                 break;
         }
         if ($range == 'post_year') {
             $query->where($db->quoteName('a.registerDate') . ' < ' . $db->quote($dStart->format('Y-m-d H:i:s')));
         } else {
             $query->where($db->quoteName('a.registerDate') . ' >= ' . $db->quote($dStart->format('Y-m-d H:i:s')) . ' AND ' . $db->quoteName('a.registerDate') . ' <=' . $db->quote($dNow->format('Y-m-d H:i:s')));
         }
     }
     // Filter by excluded users
     $excluded = $this->getState('filter.excluded');
     if (!empty($excluded)) {
         $query->where('id NOT IN (' . implode(',', $excluded) . ')');
//.........这里部分代码省略.........
开发者ID:densem-2013,项目名称:exikom,代码行数:101,代码来源:users.php

示例7: getItems

 /**
  * Method to get a list of milestones
  *
  * @param     integer    $pid      The parent project
  *
  * @return    array      $items    The milestones
  */
 public static function getItems($pid = 0)
 {
     if (!$pid) {
         return array();
     }
     $user = JFactory::getUser();
     $config = JFactory::getConfig();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $nd = $db->getNullDate();
     $query->select('a.id, a.title, a.alias, a.created, a.state, a.start_date, a.end_date')->select('p.alias AS p_alias')->from('#__pf_milestones AS a')->join('LEFT', '#__pf_projects AS p ON p.id = a.project_id')->where('a.project_id = ' . $pid)->where('a.state != -2');
     // Filter access
     if (!$user->authorise('core.admin')) {
         $query->where('a.access IN(' . implode(', ', $user->getAuthorisedViewLevels()) . ')');
     }
     $query->order('a.id ASC');
     $db->setQuery($query);
     $data = $db->loadObjectList();
     if (!is_array($data)) {
         return array();
     }
     // Prepare data
     $frames = array();
     $pks = JArrayHelper::getColumn($data, 'id');
     $completed = self::getCompleted($pks);
     foreach ($data as $i => $item) {
         // Check start date
         if ($item->start_date == $nd) {
             $item->start_date = self::getStartDate($item->id);
         }
         // Check end date
         if ($item->end_date == $nd) {
             $item->end_date = self::getEndDate($item->id);
         }
         // Skip item if no end is set
         if ($item->end_date == $nd) {
             continue;
         }
         // Set completition state
         $item->complete = $completed[$item->id];
         // Floor the start and end date
         if ($item->start_date == $nd) {
             $item->start_date = null;
             $item->start_time = 0;
         } else {
             $start_date = new JDate($item->start_date, 'UTC');
             $start_date->setTimezone(new DateTimeZone($user->getParam('timezone', $config->get('offset'))));
             $start_time = floor($start_date->toUnix() / 86400) * 86400;
             $item->start_date = $start_date->format('Y-m-d H:i:s', true, false);
             $item->start_time = $start_time;
             $item->start_year = (int) $start_date->format('Y', true, false);
             $item->start_month = (int) $start_date->format('m', true, false);
             $item->start_day = (int) $start_date->format('d', true, false);
         }
         $end_date = new JDate($item->end_date, 'UTC');
         $end_date->setTimezone(new DateTimeZone($user->getParam('timezone', $config->get('offset'))));
         $end_time = floor($end_date->toUnix() / 86400) * 86400;
         $item->end_date = $end_date->format('Y-m-d H:i:s', true, false);
         $item->end_time = $end_time;
         $item->end_year = (int) $end_date->format('Y', true, false);
         $item->end_month = (int) $end_date->format('m', true, false);
         $item->end_day = (int) $end_date->format('d', true, false);
         // Calculate the duration
         $item->duration = $end_time - $start_time;
         // Set item type
         $item->type = 'milestone';
         // Add item to time frame
         if (!isset($frames[$start_time])) {
             $frames[$start_time] = array();
         }
         $frames[$start_time][] = $item;
     }
     ksort($frames, SORT_NUMERIC);
     $items = array();
     foreach ($frames as $key => $data) {
         foreach ($data as $item) {
             $items[] = $item;
         }
     }
     return $items;
 }
开发者ID:MrJookie,项目名称:pm,代码行数:88,代码来源:milestones.php

示例8: Date

 static function Date($date, $format = FSS_DATE_LONG, $format_custom = null)
 {
     //echo "In : $date<br>";
     //echo "Format : " . $format . "<br>";
     //echo "Offset : " . FSS_Settings::Get('timezone_offset') . "<br>";
     if ((int) $date > 10000) {
         $date = date("Y-m-d H:i:s", $date);
     }
     if ((int) FSS_Settings::Get('timezone_offset') != 0) {
         $time = strtotime($date);
         $time += 3600 * (int) FSS_Settings::Get('timezone_offset');
         $date = date("Y-m-d H:i:s", $time);
     }
     switch ($format) {
         case FSS_DATE_SHORT:
             $ft = JText::_('DATE_FORMAT_LC4');
             break;
         case FSS_DATE_MID:
             $ft = JText::_('DATE_FORMAT_LC3');
             break;
         case FSS_DATE_LONG:
             $ft = JText::_('DATE_FORMAT_LC1');
             break;
         case FSS_TIME_SHORT:
             $ft = 'H:i';
             break;
         case FSS_TIME_LONG:
             $ft = 'H:i:s';
             break;
         case FSS_DATETIME_SHORT:
             $ft = JText::_('DATE_FORMAT_LC4') . ', H:i';
             break;
         case FSS_DATETIME_MID:
             $ft = JText::_('DATE_FORMAT_LC3') . ', H:i';
             break;
         case FSS_DATETIME_LONG:
             $ft = JText::_('DATE_FORMAT_LC1') . ', H:i';
             break;
         case FSS_DATETIME_MYSQL:
             $ft = 'Y-m-d H:i:s';
             break;
         case FSS_DATE_CUSTOM:
             $ft = $format_custom;
             break;
         default:
             $ft = JText::_('DATE_FORMAT_LC');
     }
     if ($format == FSS_DATETIME_SHORT && FSS_Settings::Get('date_dt_short') != "") {
         $ft = FSS_Settings::Get('date_dt_short');
     }
     if ($format == FSS_DATETIME_MID && FSS_Settings::Get('date_dt_long') != "") {
         $ft = FSS_Settings::Get('date_dt_long');
     }
     if ($format == FSS_DATE_SHORT && FSS_Settings::Get('date_d_short') != "") {
         $ft = FSS_Settings::Get('date_d_short');
     }
     if ($format == FSS_DATE_MID && FSS_Settings::Get('date_d_long') != "") {
         $ft = FSS_Settings::Get('date_d_long');
     }
     $date = new JDate($date, new DateTimeZone("UTC"));
     $date->setTimezone(FSS_Helper::getTimezone());
     //echo "Out : " . $date->format($ft, true) . "<br>";
     return $date->format($ft, true);
 }
开发者ID:vstorm83,项目名称:propertease,代码行数:64,代码来源:helper.php

示例9: getLatestComments

 public static function getLatestComments(&$params)
 {
     $mainframe = JFactory::getApplication();
     $limit = $params->get('comments_limit', '5');
     $user = JFactory::getUser();
     $aid = $user->get('aid');
     $db = JFactory::getDBO();
     $cid = $params->get('category_id', NULL);
     $jnow = JFactory::getDate();
     $now = K2_JVERSION != '15' ? $jnow->toSql() : $jnow->toMySQL();
     $nullDate = $db->getNullDate();
     $model = K2Model::getInstance('Item', 'K2Model');
     $componentParams = JComponentHelper::getParams('com_k2');
     $query = "SELECT c.*, i.catid, i.title, i.alias, category.alias as catalias, category.name as categoryname\n\t\tFROM #__k2_comments as c\n\t\tLEFT JOIN #__k2_items as i ON i.id=c.itemID\n\t\tLEFT JOIN #__k2_categories as category ON category.id=i.catid\n\t\tWHERE i.published=1\n\t\tAND ( i.publish_up = " . $db->Quote($nullDate) . " OR i.publish_up <= " . $db->Quote($now) . " )\n\t\tAND ( i.publish_down = " . $db->Quote($nullDate) . " OR i.publish_down >= " . $db->Quote($now) . " )\n\t\tAND i.trash=0 ";
     if (K2_JVERSION != '15') {
         $query .= " AND i.access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ") ";
     } else {
         $query .= " AND i.access<={$aid} ";
     }
     $query .= " AND category.published=1 AND category.trash=0 ";
     if (K2_JVERSION != '15') {
         $query .= " AND category.access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ") ";
     } else {
         $query .= " AND category.access<={$aid} ";
     }
     $query .= " AND c.published=1 ";
     if ($params->get('catfilter')) {
         if (!is_null($cid)) {
             if (is_array($cid)) {
                 JArrayHelper::toInteger($cid);
                 $query .= " AND i.catid IN(" . implode(',', $cid) . ")";
             } else {
                 $query .= " AND i.catid=" . (int) $cid;
             }
         }
     }
     if (K2_JVERSION != '15') {
         if ($mainframe->getLanguageFilter()) {
             $languageTag = JFactory::getLanguage()->getTag();
             $query .= " AND category.language IN (" . $db->Quote($languageTag) . ", " . $db->Quote('*') . ") AND i.language IN (" . $db->Quote($languageTag) . ", " . $db->Quote('*') . ")";
         }
     }
     $query .= " ORDER BY c.commentDate DESC ";
     $db->setQuery($query, 0, $limit);
     $rows = $db->loadObjectList();
     $pattern = "@\\b(https?://)?(([0-9a-zA-Z_!~*'().&=+\$%-]+:)?[0-9a-zA-Z_!~*'().&=+\$%-]+\\@)?(([0-9]{1,3}\\.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+\\.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\\.[a-zA-Z]{2,6})(:[0-9]{1,4})?((/[0-9a-zA-Z_!~*'().;?:\\@&=+\$,%#-]+)*/?)@";
     if (count($rows)) {
         foreach ($rows as $row) {
             if ($params->get('commentDateFormat') == 'relative') {
                 $config = JFactory::getConfig();
                 $now = new JDate();
                 if (K2_JVERSION == '30') {
                     $tzoffset = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
                     $now->setTimezone($tzoffset);
                 } else {
                     $tzoffset = $config->getValue('config.offset');
                     $now->setOffset($tzoffset);
                 }
                 $created = new JDate($row->commentDate);
                 $diff = $now->toUnix() - $created->toUnix();
                 $dayDiff = floor($diff / 86400);
                 if ($dayDiff == 0) {
                     if ($diff < 5) {
                         $row->commentDate = JText::_('K2_JUST_NOW');
                     } elseif ($diff < 60) {
                         $row->commentDate = $diff . ' ' . JText::_('K2_SECONDS_AGO');
                     } elseif ($diff < 120) {
                         $row->commentDate = JText::_('K2_1_MINUTE_AGO');
                     } elseif ($diff < 3600) {
                         $row->commentDate = floor($diff / 60) . ' ' . JText::_('K2_MINUTES_AGO');
                     } elseif ($diff < 7200) {
                         $row->commentDate = JText::_('K2_1_HOUR_AGO');
                     } elseif ($diff < 86400) {
                         $row->commentDate = floor($diff / 3600) . ' ' . JText::_('K2_HOURS_AGO');
                     }
                 }
             }
             $row->commentText = K2HelperUtilities::wordLimit($row->commentText, $params->get('comments_word_limit'));
             $row->commentText = preg_replace($pattern, '<a target="_blank" rel="nofollow" href="\\0">\\0</a>', $row->commentText);
             $row->itemLink = urldecode(JRoute::_(K2HelperRoute::getItemRoute($row->itemID . ':' . urlencode($row->alias), $row->catid . ':' . urlencode($row->catalias))));
             $row->link = $row->itemLink . "#comment{$row->id}";
             $row->catLink = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($row->catid . ':' . urlencode($row->catalias))));
             if ($row->userID > 0) {
                 $row->userLink = JRoute::_(K2HelperRoute::getUserRoute($row->userID));
                 $getExistingUser = JFactory::getUser($row->userID);
                 $row->userUsername = $getExistingUser->username;
             } else {
                 $row->userUsername = $row->userName;
             }
             // Switch between commenter name and username
             if ($params->get('commenterName', 1) == 2) {
                 $row->userName = $row->userUsername;
             }
             $row->userImage = '';
             if ($params->get('commentAvatar')) {
                 $row->userImage = K2HelperUtilities::getAvatar($row->userID, $row->commentEmail, $componentParams->get('commenterImgWidth'));
             }
             $comments[] = $row;
         }
         return $comments;
//.........这里部分代码省略.........
开发者ID:emavro,项目名称:k2,代码行数:101,代码来源:helper.php

示例10: testCreatedDate

 /**
  * testCreatedDate
  *
  * @return  void
  *
  * @covers Windwalker/View/Helper/GridHelper::createdDate
  */
 public function testCreatedDate()
 {
     $this->config['field']['created'] = 'createdDate';
     $grid = new GridHelper($this->view, $this->config);
     $item = new \stdClass();
     $item->id = 123;
     $item->title = 'one two three';
     $item->createdDate = '2015-01-01 08:00:00';
     $grid->setItem($item, 1);
     $result = $grid->createdDate('l, d F Y, g:i:s A');
     // Expected Date
     $date = new \JDate('2015-01-01 08:00:00');
     $date->setTimezone(new \DateTimeZone(\JFactory::getConfig()->get('offset', 'UTC')));
     $this->assertEquals($date->format('l, d F Y, g:i:s A', true), $result);
 }
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:22,代码来源:GridHelperTest.php

示例11: getItem

 public function getItem($pk = null)
 {
     if ($result = parent::getItem($pk)) {
         // Prime required properties.
         if (empty($result->id)) {
             $result->context = JFactory::getApplication()->input->getCmd('context', $this->getState('field.context'));
         }
         if (property_exists($result, 'fieldparams')) {
             $registry = new Registry();
             $registry->loadString($result->fieldparams);
             $result->fieldparams = $registry->toArray();
         }
         if ($result->catid) {
             $result->catid = explode(',', $result->catid);
         }
         // Convert the created and modified dates to local user time for
         // display in the form.
         $tz = new DateTimeZone(JFactory::getApplication()->get('offset'));
         if ((int) $result->created_time) {
             $date = new JDate($result->created_time);
             $date->setTimezone($tz);
             $result->created_time = $date->toSql(true);
         } else {
             $result->created_time = null;
         }
         if ((int) $result->modified_time) {
             $date = new JDate($result->modified_time);
             $date->setTimezone($tz);
             $result->modified_time = $date->toSql(true);
         } else {
             $result->modified_time = null;
         }
         if (!empty($result->id)) {
             $result->tags = new JHelperTags();
             $result->tags->getTagIds($result->id, 'com_dpfields.field');
         }
     }
     return $result;
 }
开发者ID:beingsane,项目名称:DPFields,代码行数:39,代码来源:field.php

示例12: saveCatg

function saveCatg()
{
    $app = JFactory::getApplication('administrator');
    $db = JFactory::getDBO();
    $user = JFactory::getUser();
    $post = JRequest::get('post');
    $query = 'SELECT ordering, user_id, date' . ' FROM #__datsogallery_catg' . ' WHERE cid = ' . $post['cid'];
    $db->setQuery($query);
    $obj = $db->loadObject();
    $post['description'] = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);
    $row = new DatsoCategories($db);
    if (!$post['cid'] || $obj->ordering == 0) {
        $row->ordering = $row->getNextOrder('parent = ' . $post['parent']);
        $row->approved = 1;
    }
    if ($obj->user_id == 0) {
        $row->user_id = $user->id;
    }
    if (!$obj->date) {
        jimport('joomla.utilities.date');
        $dtz = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
        $date = new JDate($row->date);
        $date->setTimezone($dtz);
        $row->date = $date->toMySQL(true);
    }
    if (!$row->bind($post)) {
        JError::raiseError(500, $row->getError());
    }
    if (!$row->check()) {
        JError::raiseError(500, $row->getError());
    }
    if (!$row->store()) {
        JError::raiseError(500, $row->getError());
    }
    $app->redirect("index.php?option=com_datsogallery&task=showcatg");
}
开发者ID:j0rg3m414,项目名称:centerar,代码行数:36,代码来源:admin.datsogallery.php

示例13: getItem

 /**
  * Method to get a tag.
  *
  * @param   integer  $pk  An optional id of the object to get, otherwise the id from the model state is used.
  *
  * @return  mixed  Tag data object on success, false on failure.
  *
  * @since   3.1
  */
 public function getItem($pk = null)
 {
     if ($result = parent::getItem($pk)) {
         // Prime required properties.
         if (empty($result->id)) {
             $result->parent_id = $this->getState('tag.parent_id');
         }
         // Convert the metadata field to an array.
         $registry = new JRegistry();
         $registry->loadString($result->metadata);
         $result->metadata = $registry->toArray();
         // Convert the images field to an array.
         $registry = new JRegistry();
         $registry->loadString($result->images);
         $result->images = $registry->toArray();
         // Convert the urls field to an array.
         $registry = new JRegistry();
         $registry->loadString($result->urls);
         $result->urls = $registry->toArray();
         // Convert the created and modified dates to local user time for display in the form.
         $tz = new DateTimeZone(JFactory::getApplication()->get('offset'));
         if ((int) $result->created_time) {
             $date = new JDate($result->created_time);
             $date->setTimezone($tz);
             $result->created_time = $date->toSql(true);
         } else {
             $result->created_time = null;
         }
         if ((int) $result->modified_time) {
             $date = new JDate($result->modified_time);
             $date->setTimezone($tz);
             $result->modified_time = $date->toSql(true);
         } else {
             $result->modified_time = null;
         }
     }
     return $result;
 }
开发者ID:edwardmagbago,项目名称:joomlatools-platform-content,代码行数:47,代码来源:tag.php

示例14: getItem

 /**
  * Method to get a category.
  *
  * @param integer $pk An optional id of the object to get, otherwise the id
  *        	from the model state is used.
  *
  * @return mixed Category data object on success, false on failure.
  *
  */
 public function getItem($pk = null)
 {
     if ($result = parent::getItem($pk)) {
         // Prime required properties.
         if (empty($result->id)) {
             $result->parent_id = $this->getState('category.parent_id');
         }
         // Convert the metadata field to an array.
         $registry = new JRegistry();
         $registry->loadString($result->metadata);
         $result->metadata = $registry->toArray();
         // Convert the created and modified dates to local user time for
         // display in the form.
         jimport('joomla.utilities.date');
         $tz = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
         if (intval($result->created_time)) {
             $date = new JDate($result->created_time);
             $date->setTimezone($tz);
             $result->created_time = $date->toSql(true);
         } else {
             $result->created_time = null;
         }
         if (intval($result->modified_time)) {
             $date = new JDate($result->modified_time);
             $date->setTimezone($tz);
             $result->modified_time = $date->toSql(true);
         } else {
             $result->modified_time = null;
         }
     }
     if (!empty($result->image)) {
         if (strpos($result->image, 'images/') !== false) {
             # the image selected contains the images path
         } else {
             # the image selected doesn't have the /images/ path
             # we're looking at the locimage so we'll append the venues folder
             $result->image = 'images/jem/categories/' . $result->image;
         }
     }
     return $result;
 }
开发者ID:JKoelman,项目名称:JEM-3,代码行数:50,代码来源:category.php

示例15: getItemsDetail

 /**
  * Method to get a list of items of a project to render in the gantt chart
  *
  * @return    array    $items    The items to render
  */
 protected static function getItemsDetail()
 {
     $data = self::getProjectDetails();
     $user = JFactory::getUser();
     $config = JFactory::getConfig();
     $params = self::$params;
     $items = array();
     $can_edit_m_state = $user->authorise('core.edit.state', 'com_pfmilestones');
     $can_edit_t_state = $user->authorise('core.edit.state', 'com_pftasks');
     $default = array('1', '0', '2');
     $show_ms = $params->get('show_milestones', $default);
     $show_l = $params->get('show_lists', $default);
     $show_t = $params->get('show_tasks', $default);
     $ms_display = (int) $params->get('ms_display');
     $highlight = (int) $params->get('highlight_today');
     $date_now = new JDate('now', 'UTC');
     $date_now->setTimezone(new DateTimeZone($user->getParam('timezone', $config->get('offset'))));
     $today = $date_now->toUnix() * 1000;
     $icons = array('milestone' => 'icon-flag', 'tasklist' => 'icon-list-view', 'task-complete' => 'icon-checkbox', 'task-incomplete' => 'icon-checkbox-unchecked');
     $prev_level = 0;
     $level = 0;
     // Fix "Show Task Lists" setting from older module versions
     if (!is_array($show_l)) {
         if ($show_l == '1') {
             $show_l = array('1', '0', '2');
         } else {
             $show_l = array('-1');
         }
     }
     // Fix empty "Show X" settings
     if (is_array($show_ms) && count($show_ms) == 0) {
         $show_ms = $default;
     }
     if (is_array($show_l) && count($show_l) == 0) {
         $show_l = $default;
     }
     if (is_array($show_t) && count($show_t) == 0) {
         $show_t = $default;
     }
     // Map item keys
     $map_ms = array();
     $map_l = array();
     $map_t = array();
     foreach ($data as $i => $record) {
         if ($record->type == 'milestone') {
             $map_ms[$record->id] = $i;
         }
         if ($record->type == 'tasklist') {
             $map_l[$record->id] = $i;
         }
         if ($record->type == 'task') {
             $map_t[$record->id] = $i;
         }
     }
     foreach ($data as $i => $record) {
         $link = '#';
         $prev_level = $level;
         $dep = array();
         if ($record->type == 'milestone') {
             // Hide milestone?
             if (!in_array($record->state, $show_ms)) {
                 continue;
             }
             $slug = $record->id . ':' . $record->alias;
             $pslug = self::$project . ':' . $record->p_alias;
             $link = JRoute::_(PFmilestonesHelperRoute::getMilestoneRoute($slug, $pslug));
             $level = 0;
             $class = 'gantt-m';
             $bid = 'gantt-m-' . $record->id;
             $can_edit = $can_edit_m_state;
         }
         if ($record->type == 'tasklist') {
             // Hide list?
             if (!in_array($record->state, $show_l)) {
                 continue;
             }
             $slug = $record->id . ':' . $record->alias;
             $pslug = self::$project . ':' . $record->p_alias;
             $mslug = $record->milestone_id . ':' . $record->m_alias;
             $link = JRoute::_(PFtasksHelperRoute::getTasksRoute($pslug, $mslug, $slug));
             $class = 'gantt-l';
             $bid = 'gantt-l-' . $record->id;
             $can_edit = $can_edit_t_state;
             if ($record->milestone_id) {
                 if (isset($map_ms[$record->milestone_id])) {
                     $k = $map_ms[$record->milestone_id];
                     $ms = $data[$k];
                     if (!in_array($ms->state, $show_ms)) {
                         $record->milestone_id = 0;
                     }
                 }
             }
             $level = $record->milestone_id ? 1 : 0;
         }
         if ($record->type == 'task') {
//.........这里部分代码省略.........
开发者ID:MrJookie,项目名称:pm,代码行数:101,代码来源:helper.php


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