示例#1
0
文件: report.php 项目: lenard112/cms
 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);
 }
 /**
  * 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);
 }
示例#3
0
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']);
    }
}
示例#4
0
 function testdate($date, $format)
 {
     $date = new JDate($date, new DateTimeZone("UTC"));
     $date->setTimezone(FSF_Helper::getTimezone());
     return $date->format($format, true);
 }
<?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 <*****@*****.**>
* @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();
示例#6
0
 /**
  * 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) . ')');
     }
     // Add the list ordering clause.
     $query->order($db->escape($this->getState('list.ordering', 'a.name')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
     return $query;
 }
示例#7
0
 /**
  * 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;
 }
示例#8
0
 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);
 }
示例#9
0
文件: helper.php 项目: emavro/k2
 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;
     }
 }
 /**
  * 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);
 }
示例#11
0
 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;
 }
示例#12
0
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");
}
 /**
  * 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;
 }
示例#14
0
 /**
  * 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;
 }
示例#15
0
文件: helper.php 项目: MrJookie/pm
 /**
  * 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') {
             // Hide task?
             if (!in_array($record->state, $show_t)) {
                 continue;
             }
             $slug = $record->id . ':' . $record->alias;
             $pslug = self::$project . ':' . $record->p_alias;
             $mslug = $record->milestone_id . ':' . $record->m_alias;
             $lslug = $record->list_id . ':' . $record->l_alias;
             $link = JRoute::_(PFtasksHelperRoute::getTaskRoute($slug, $pslug, $mslug, $lslug));
             $bid = 'gantt-t-' . $record->id;
             $record->type .= '-' . ($record->complete ? 'complete' : 'incomplete');
             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;
                     }
                 }
             }
             if ($record->list_id) {
                 if (isset($map_l[$record->list_id])) {
                     $k = $map_l[$record->list_id];
                     $l = $data[$k];
                     if (!in_array($l->state, $show_l)) {
                         $record->list_id = 0;
                     }
                 }
             }
             if ($record->l_ms) {
                 if (isset($map_l[$record->l_ms])) {
                     $k = $map_l[$record->list_id];
                     $l = $data[$k];
                     if (!in_array($l->state, $show_l)) {
                         $record->l_ms = 0;
                     }
                 }
             }
             if (in_array('-1', $show_l)) {
                 $record->l_ms = 0;
             }
             $level = $record->list_id ? $record->l_ms ? 2 : 1 : ($record->milestone_id ? 1 : 0);
             $class = 'gantt-t';
             $can_edit = $can_edit_t_state;
             // Add task dependencies
             if (count($record->parents)) {
                 foreach ($record->parents as $parent) {
                     $dep[] = 'gantt-t-' . $parent;
                 }
             }
         }
         // Set arrow direction and indentation
         if ($level == 0) {
             $indent = '<i class="icon-arrow-right-3"></i> ';
         } else {
             $indent = '<i class="icon-arrow-' . ($ms_display ? 'down' : 'up') . '-3" style="margin-left:' . 16 * $level . 'px"></i> ';
         }
         if (!$can_edit) {
             $name = '<i class="' . $icons[$record->type] . '"></i> ' . '<span>' . ucfirst(htmlspecialchars($record->title)) . '</span>';
         } else {
             $name = '<i class="' . $icons[$record->type] . '"></i> ' . '<a href="' . $link . '">' . ucfirst(htmlspecialchars($record->title)) . '</a>';
         }
         // Create row object
         $row = new stdClass();
         $row->name = $indent . $name;
         $row->desc = self::formatDuration($record->duration, $record->start_time, $record->end_time, $record->complete);
         $row->values = array();
         // Create row item object
         $item = new stdClass();
         if ($record->type == 'milestone' && $ms_display) {
             $item->label = '<i class="icon-flag"></i>';
             $item->from = '/Date(' . $record->end_year . ', ' . ($record->end_month - 1) . ', ' . $record->end_day . ')/';
         } else {
             $item->label = ucfirst(htmlspecialchars($record->title));
             $item->from = '/Date(' . $record->start_year . ', ' . ($record->start_month - 1) . ', ' . $record->start_day . ')/';
         }
         $item->to = '/Date(' . $record->end_year . ', ' . ($record->end_month - 1) . ', ' . $record->end_day . ')/';
         $item->id = $bid;
         $item->desc = '';
         // Determine custom class
         $item->customClass = $class;
         if ($record->complete) {
             $item->customClass .= '-complete';
         } elseif ($record->start_time > self::$time_today) {
             $item->customClass .= '-notstarted';
         } elseif ($record->end_time < self::$time_today) {
             $item->customClass .= '-behind';
         }
         // Add dependencies
         if (count($dep)) {
             $item->dep = $dep;
         }
         // Highlight today?
         if ($highlight) {
             $hl = new stdClass();
             $hl->label = '';
             $hl->desc = '';
             $hl->from = '/Date()/';
             $hl->to = '/Date()/';
             $hl->customClass = 'gantt-today';
             $row->values[] = $hl;
         }
         $row->values[] = $item;
         $items[] = $row;
     }
     return $items;
 }
示例#16
0
 /**
  * User export
  *
  * @copyright
  * @author		RolandD
  * @todo
  * @see
  * @access 		public
  * @param
  * @return 		void
  * @since 		3.4
  */
 public function getStart()
 {
     // Get some basic data
     $db = JFactory::getDbo();
     $csvidb = new CsviDb();
     $jinput = JFactory::getApplication()->input;
     $csvilog = $jinput->get('csvilog', null, null);
     $template = $jinput->get('template', null, null);
     $exportclass = $jinput->get('export.class', null, null);
     $export_fields = $jinput->get('export.fields', array(), 'array');
     $sef = new CsviSef();
     // Build something fancy to only get the fieldnames the user wants
     $userfields = array();
     foreach ($export_fields as $column_id => $field) {
         switch ($field->field_name) {
             case 'fullname':
                 $userfields[] = $db->qn('u.name', 'fullname');
                 break;
             case 'usergroup_name':
                 $userfields[] = $db->qn('id');
                 break;
             case 'custom':
                 break;
             default:
                 $userfields[] = $db->qn($field->field_name);
                 break;
         }
     }
     // Build the query
     $userfields = array_unique($userfields);
     $query = $db->getQuery(true);
     $query->select(implode(",\n", $userfields));
     $query->from($db->qn("#__users", "u"));
     $selectors = array();
     // Filter by published state
     $user_state = $template->get('user_state', 'user');
     if ($user_state != '*') {
         $selectors[] = $db->qn('u.block') . ' = ' . $user_state;
     }
     // Filter by active state
     $user_active = $template->get('user_active', 'user');
     if ($user_active == '0') {
         $selectors[] = $db->qn('u.activation') . ' = ' . $db->q('');
     } elseif ($user_active == '1') {
         $selectors[] = $db->qn('u.activation') . ' = ' . $db->q('32');
     }
     // Filter by user group
     $user_groups = $template->get('user_group', 'user');
     if ($user_groups && $user_groups[0] != '*') {
         $query->join('LEFT', $db->qn('#__user_usergroup_map', 'map2') . ' ON ' . $db->qn('map2.user_id') . ' = ' . $db->qn('u.id'));
         if (isset($user_groups)) {
             $selectors[] = $db->qn('map2.group_id') . ' IN (' . implode(',', $user_groups) . ')';
         }
     }
     // Filter on range
     $user_range = $template->get('user_range', 'user');
     if ($user_range != '*') {
         jimport('joomla.utilities.date');
         // Get UTC for now.
         $dNow = new JDate();
         $dStart = clone $dNow;
         switch ($user_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 ($user_range == 'post_year') {
             $selectors[] = $db->qn('u.registerDate') . ' < ' . $db->q($dStart->format('Y-m-d H:i:s'));
         } else {
             $selectors[] = $db->qn('u.registerDate') . ' >= ' . $db->q($dStart->format('Y-m-d H:i:s')) . ' AND u.registerDate <=' . $db->q($dNow->format('Y-m-d H:i:s'));
         }
     }
     // Check if we need to attach any selectors to the query
     if (count($selectors) > 0) {
         $query->where(implode("\n AND ", $selectors));
     }
     // Ingore fields
     $ignore = array('custom', 'fullname', 'usergroup_name');
     // Check if we need to group the users together
     $groupby = $template->get('groupby', 'general', false, 'bool');
     if ($groupby) {
         $filter = $this->getFilterBy('groupby', $ignore);
         if (!empty($filter)) {
             $query->group($filter);
         }
     }
     // Order by set field
     $orderby = $this->getFilterBy('sort', $ignore);
     if (!empty($orderby)) {
         $query->order($orderby);
     }
     // Add a limit if user wants us to
     $limits = $this->getExportLimit();
     // Execute the query
     $csvidb->setQuery($query, $limits['offset'], $limits['limit']);
     $csvilog->addDebug(JText::_('COM_CSVI_EXPORT_QUERY'), true);
     // There are no records, write SQL query to log
     if (!is_null($csvidb->getErrorMsg())) {
         $this->addExportContent(JText::sprintf('COM_CSVI_ERROR_RETRIEVING_DATA', $csvidb->getErrorMsg()));
         $this->writeOutput();
         $csvilog->AddStats('incorrect', $csvidb->getErrorMsg());
     } else {
         $logcount = $csvidb->getNumRows();
         $jinput->set('logcount', $logcount);
         if ($logcount > 0) {
             while ($record = $csvidb->getRow()) {
                 if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
                     $this->addExportContent($exportclass->NodeStart());
                 }
                 foreach ($export_fields as $column_id => $field) {
                     $fieldname = $field->field_name;
                     $fieldreplace = $field->field_name . $field->column_header;
                     // Add the replacement
                     if (isset($record->{$fieldname})) {
                         $fieldvalue = CsviHelper::replaceValue($field->replace, $record->{$fieldname});
                     } else {
                         $fieldvalue = '';
                     }
                     switch ($fieldname) {
                         case 'usergroup_name':
                             $query = $db->getQuery(true);
                             $query->select($db->qn('title'));
                             $query->from($db->qn('#__usergroups'));
                             $query->leftJoin($db->qn('#__user_usergroup_map') . ' ON ' . $db->qn('#__user_usergroup_map.group_id') . ' = ' . $db->qn('#__usergroups.id'));
                             $query->where($db->qn('user_id') . ' = ' . $record->id);
                             $db->setQuery($query);
                             $groups = $db->loadColumn();
                             if (is_array($groups)) {
                                 $fieldvalue = implode('|', $groups);
                             } else {
                                 $fieldvalue = '';
                             }
                             if (strlen(trim($fieldvalue)) == 0) {
                                 $fieldvalue = $field->default_value;
                             }
                             $record->output[$column_id] = $fieldvalue;
                             break;
                         case 'custom':
                             if (strlen(trim($fieldvalue)) == 0) {
                                 $fieldvalue = $field->default_value;
                             }
                             $fieldvalue = CsviHelper::replaceValue($field->replace, $fieldvalue);
                             $record->output[$column_id] = $fieldvalue;
                             break;
                         default:
                             // Check if we have any content otherwise use the default value
                             if (strlen(trim($fieldvalue)) == 0) {
                                 $fieldvalue = $field->default_value;
                             }
                             $record->output[$column_id] = $fieldvalue;
                             break;
                     }
                 }
                 // Output the data
                 $this->addExportFields($record);
                 if ($template->get('export_file', 'general') == 'xml' || $template->get('export_file', 'general') == 'html') {
                     $this->addExportContent($exportclass->NodeEnd());
                 }
                 // Output the contents
                 $this->writeOutput();
             }
         } else {
             $this->addExportContent(JText::_('COM_CSVI_NO_DATA_FOUND'));
             // Output the contents
             $this->writeOutput();
         }
     }
 }
示例#17
0
 static function Date($date, $format = FST_DATE_LONG)
 {
     if (FST_Helper::Is16()) {
         /*$setting = FST_Settings::get('datetime_'.$format);
         		if ($setting)
         		{
         			$ft = $setting;
         		} else {*/
         switch ($format) {
             case FST_DATE_SHORT:
                 $ft = JText::_('DATE_FORMAT_LC4');
                 break;
             case FST_DATE_MID:
                 $ft = JText::_('DATE_FORMAT_LC3');
                 break;
             case FST_DATE_LONG:
                 $ft = JText::_('DATE_FORMAT_LC1');
                 break;
             case FST_TIME_SHORT:
                 $ft = 'H:i';
                 break;
             case FST_TIME_LONG:
                 $ft = 'H:i:s';
                 break;
             case FST_DATETIME_SHORT:
                 $ft = JText::_('DATE_FORMAT_LC4') . ', H:i';
                 break;
             case FST_DATETIME_MID:
                 $ft = JText::_('DATE_FORMAT_LC3') . ', H:i';
                 break;
             case FST_DATETIME_LONG:
                 $ft = JText::_('DATE_FORMAT_LC1') . ', H:i';
                 break;
             case FST_DATETIME_MYSQL:
                 $ft = 'Y-m-d H:i:s';
                 break;
             default:
                 $ft = JText::_('DATE_FORMAT_LC');
         }
         if ($format == FST_DATETIME_SHORT && FST_Settings::Get('date_dt_short') != "") {
             $ft = FST_Settings::Get('date_dt_short');
         }
         if ($format == FST_DATETIME_MID && FST_Settings::Get('date_dt_long') != "") {
             $ft = FST_Settings::Get('date_dt_long');
         }
         if ($format == FST_DATE_SHORT && FST_Settings::Get('date_d_short') != "") {
             $ft = FST_Settings::Get('date_d_short');
         }
         if ($format == FST_DATE_MID && FST_Settings::Get('date_d_long') != "") {
             $ft = FST_Settings::Get('date_d_long');
         }
         $date = new JDate($date, new DateTimeZone("UTC"));
         $date->setTimezone(FST_Helper::getTimezone());
         return $date->format($ft, true);
     } else {
         /*$setting = FST_Settings::get('datetime_'.$format);
         		if ($setting)
         		{
         			$ft = $setting;
         		} else {*/
         switch ($format) {
             case FST_DATE_SHORT:
                 $ft = JText::_('DATE_FORMAT_LC4');
                 break;
             case FST_DATE_MID:
                 $ft = JText::_('DATE_FORMAT_LC3');
                 break;
             case FST_DATE_LONG:
                 $ft = JText::_('DATE_FORMAT_LC1');
                 break;
             case FST_TIME_SHORT:
                 $ft = '%H:%M';
                 break;
             case FST_TIME_LONG:
                 $ft = '%H:%M:%S';
                 break;
             case FST_DATETIME_SHORT:
                 $ft = JText::_('DATE_FORMAT_LC4') . ', %H:%M';
                 break;
             case FST_DATETIME_MID:
                 $ft = JText::_('DATE_FORMAT_LC3') . ', %H:%M';
                 break;
             case FST_DATETIME_LONG:
                 $ft = JText::_('DATE_FORMAT_LC1') . ', %H:%M';
                 break;
             default:
                 $ft = JText::_('DATE_FORMAT_LC');
         }
         //}
         //echo "Format : $ft, Requested: $format<br>";
         $date = new JDate($date);
         return $date->toFormat($ft);
     }
     return $date;
 }
示例#18
0
    function add_comment()
    {
        $addcomm = JRequest::getVar('addcomm', '', 'post', 'string', JREQUEST_ALLOWRAW);
        $addcomm = strip_tags($addcomm);
        $math_id = JRequest::getVar('mid', 0, 'post', 'int');
        $user = JFactory::getUser();
        $db = JFactory::getDBO();
        if ($user->get('guest')) {
            return false;
            //return;
        }
        $query = "INSERT INTO `#__bl_comments` ( `id` , `user_id` , `match_id` , `date_time` , `comment` ) VALUES(0," . $user->id . "," . $math_id . ",'" . gmdate("Y-m-d H:i:s") . "','" . addslashes($addcomm) . "')";
        $db->setQuery($query);
        $db->query();
        $curid = $db->insertid();
        //$query = "SELECT IF(pl.nick <> '',pl.nick,p.name) FROM #__users as p LEFT JOIN #__bl_players as pl ON p.id=pl.usr_id WHERE p.id=".$user->id;
        //$db->setQuery($query);
        //$name = $db->loadResult();
        $query = "SELECT cfg_value FROM #__bl_config WHERE cfg_name='player_name'";
        $db->setQuery($query);
        if ($db->loadResult()) {
            $fullname = "IF(pl.nick <> '',pl.nick,p.name)";
        } else {
            $fullname = "CONCAT(pl.first_name,' ',pl.last_name)";
        }
        $query = "SELECT " . $fullname . " FROM #__users as p LEFT JOIN #__bl_players as pl ON p.id=pl.usr_id WHERE p.id=" . $user->id;
        $db->setQuery($query);
        $name = $db->loadResult();
        if (!$name) {
            $query = "SELECT p.name FROM #__users as p WHERE p.id=" . $user->id;
            $db->setQuery($query);
            $name = $db->loadResult();
        }
        /////
        $query = "SELECT pl.def_img,pl.id FROM #__users as p LEFT JOIN #__bl_players as pl ON p.id=pl.usr_id WHERE p.id=" . $user->id;
        $db->setQuery($query);
        $playesr = $db->loadObject();
        $def_img = '';
        if (!empty($playesr)) {
            if ($pl_id = $playesr->id) {
                $pl_image = $playesr->def_img;
                $query = "SELECT p.ph_name as name,p.id as id,p.ph_filename as filename FROM #__bl_assign_photos as ap, #__bl_photos as p WHERE ap.photo_id = p.id AND cat_type = 1 AND cat_id = " . $pl_id;
                $db->setQuery($query);
                $photos = $db->loadObjectList();
                if ($pl_image) {
                    $query = "SELECT ph_filename FROM  #__bl_photos as p WHERE p.id = " . $pl_image;
                    $db->setQuery($query);
                    $def_img = $db->loadResult();
                } else {
                    if (isset($photos[0])) {
                        $def_img = $photos[0]->filename;
                    }
                }
            }
        }
        $avatar = JURI::base() . "components/com_joomsport/img/ico/season-list-player-ico.gif";
        if (is_file('media/bearleague/' . $def_img)) {
            $avatar = JURI::base() . "media/bearleague/" . $def_img;
        }
        ?>

		<li id="divcomb_<?php 
        echo $curid;
        ?>
">
			<img src="<?php 
        echo $avatar;
        ?>
" width="30" height="30" alt="" />
			<div class="comments-box-inner">
				<span class="date">
					<?php 
        echo "<img src='" . JURI::base() . "components/com_joomsport/img/ico/close.png' width='15' border=0 style='cursor:pointer;' onClick='javascript:delCom(" . $curid . ");' />";
        ?>

					<?php 
        jimport('joomla.utilities.date');
        if (getVer() > '1.6') {
            $tz = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
            $jdate = new JDate(time());
            $jdate->setTimezone($tz);
        } else {
            $jdate = new JDate('now', JFactory::getApplication()->getCfg('offset'));
        }
        echo $jdate->format('Y-m-d H:i:s', true, false);
        ?>

				</span>
				<h4 class="nickname"><?php 
        echo $name;
        ?>
</h4>
				<p><?php 
        echo str_replace("\n", '<br />', htmlspecialchars($addcomm));
        ?>
</p>
			</div>
		</li>
		<?php 
    }
示例#19
0
 /**
  * Write precaching file on disk accordingly to request params hash
  * If processStatus is detected as end, the temp named file is renamed to
  * final name that will be used by main display controller as precached sitemap
  *
  * @access protected
  * @return boolean
  */
 protected function writeFile($data)
 {
     // Never write if no data
     if (!$data) {
         return false;
     }
     // Manage file name as temp, to avoid that not complete operations have resulting broken sitemap files
     $tempFileName = $this->preCachingPath . 'temp_' . $this->fileName;
     // Delete any pre-existant incomplete temp processing files - otherwise the result would be append again
     if ($this->processStatus == 'start' && file_exists($tempFileName)) {
         if (!JFile::delete($tempFileName)) {
             throw new JMapExceptionPrecaching(JText::_('COM_JMAP_PRECACHING_ERROR_DELETE_TEMPFILE'), 'error', 'delete_temp_file');
         }
     }
     // Open file in write append mode
     if (!$this->fileStreamWriter->open($tempFileName, 'a')) {
         throw new JMapExceptionPrecaching(JText::sprintf('COM_JMAP_PRECACHING_ERROR_OPENING_FILE', $this->fileStreamWriter->getError()), 'error', 'open_file');
     }
     // Write append to file
     if ($data) {
         // Add always new line if process status is not start
         if ($this->processStatus != 'start') {
             $data = PHP_EOL . $data;
         }
         // Try to append data to precaching file
         $result = $this->fileStreamWriter->write($data);
         // Something went wrong
         if (!$result) {
             throw new JMapExceptionPrecaching(JText::sprintf('COM_JMAP_PRECACHING_ERROR_WRITING_FILE', $this->fileStreamWriter->getError()), 'error', 'write_file');
         }
     }
     // Finished operation, close file handle
     if (!$this->fileStreamWriter->close()) {
         throw new JMapExceptionPrecaching(JText::sprintf('COM_JMAP_PRECACHING_ERROR_CLOSING_FILE', $this->fileStreamWriter->getError()), 'error', 'close_file');
     }
     // Check if process status has ended successfully, and if so try to rename temp file to be ready to use
     if ($this->processStatus == 'end') {
         if (!rename($tempFileName, $this->preCachingPath . $this->fileName)) {
             throw new JMapExceptionPrecaching(JText::_('COM_JMAP_PRECACHING_ERROR_RENAMING_FILE'), 'error', 'rename_file');
         }
         // Set filemtime
         $joomlaConfig = JFactory::getConfig();
         $localTimeZone = new DateTimeZone($joomlaConfig->get('offset'));
         $lastGenerationTimestamp = filemtime($this->preCachingPath . $this->fileName);
         $dateObject = new JDate($lastGenerationTimestamp);
         $dateObject->setTimezone($localTimeZone);
         $this->finalFileMTime = $dateObject->format('Y-m-d', true);
     }
     return true;
 }
</video:title>
<video:description><![CDATA[<?php 
    echo substr($this->apiJsonResponse[0]->description, 0, 2048);
    ?>
]]></video:description>
<video:player_loc allow_embed="yes" autoplay="ap=1"><?php 
    echo "http://player.vimeo.com/video/" . $this->videoID;
    ?>
</video:player_loc>
<video:duration><?php 
    echo $this->apiJsonResponse[0]->duration;
    ?>
</video:duration>
<video:view_count><?php 
    echo $this->apiJsonResponse[0]->stats_number_of_plays;
    ?>
</video:view_count>
<video:publication_date><?php 
    $dateObj = new JDate($this->apiJsonResponse[0]->upload_date);
    $dateObj->setTimezone(new DateTimeZone('UTC'));
    echo $dateObj->toISO8601(true);
    ?>
</video:publication_date>
<video:uploader><?php 
    echo htmlspecialchars($this->apiJsonResponse[0]->user_name, ENT_COMPAT, 'UTF-8');
    ?>
</video:uploader>
<video:live>no</video:live>
</video:video> 
<?php 
}
示例#21
0
 /**
  * Convert the UTC timestamp of a match (stored as UTC in the database) to:
  * - the timezone of the Joomla user if that is set
  * - to the project timezone as set in the project otherwise (so also for guest users,
  *   aka visitors that have not logged in).
  *
  * @param match $match Typically obtained from a DB-query and contains the match_date and timezone (of the project)
  */
 public static function convertMatchDateToTimezone(&$match)
 {
     if ($match->match_date > 0) {
         $app = JFactory::getApplication();
         if ($app->isAdmin()) {
             // In case we are editing match(es) always use the project timezone
             $timezone = $match->timezone;
         } else {
             // Otherwise use user timezone for display, and if not set use the project timezone
             $user = JFactory::getUser();
             $timezone = $user->getParam('timezone', $match->timezone);
         }
         $matchDate = new JDate($match->match_date, 'UTC');
         $matchDate->setTimezone(new DateTimeZone($timezone));
         $match->match_date = $matchDate;
         $match->timezone = $timezone;
     } else {
         $match->match_date = null;
     }
 }
示例#22
0
 /**
  * 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.
  *
  * @since   1.6
  */
 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');
             $result->extension = $this->getState('category.extension');
         }
         // Convert the metadata field to an array.
         $registry = new Registry();
         $registry->loadString($result->metadata);
         $result->metadata = $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;
         }
         if (!empty($result->id)) {
             $result->tags = new JHelperTags();
             $result->tags->getTagIds($result->id, $result->extension . '.category');
         }
     }
     $assoc = $this->getAssoc();
     if ($assoc) {
         if ($result->id != null) {
             $result->associations = CategoriesHelper::getAssociations($result->id, $result->extension);
             JArrayHelper::toInteger($result->associations);
         } else {
             $result->associations = array();
         }
     }
     return $result;
 }
示例#23
0
 /**
  * Check what sitemaps are cached on disk to show accordingly green labels
  *
  * @access private
  * @param $idEntity
  * @param $additionalModels
  *
  * @Return array
  */
 private function getPrecachedSitemaps($queryStringLinksArray, $additionalModels = null)
 {
     // Response JSON object
     $response = new stdClass();
     try {
         // Resource Action detection dall'HTTP method name
         $HTTPMethod = $this->app->input->server->get('REQUEST_METHOD', 'GET');
         if ($HTTPMethod !== 'GET') {
             throw new JMapException(JText::_('COM_JMAP_INVALID_RESTFUL_METHOD'), 'error');
         }
         // Init empty status
         $response->sitemapLinksStatus = array();
         // Start to set an associative array based on url parsing and file existance
         if (!empty($queryStringLinksArray) && is_array($queryStringLinksArray)) {
             $joomlaConfig = JFactory::getConfig();
             $localTimeZone = new DateTimeZone($joomlaConfig->get('offset'));
             foreach ($queryStringLinksArray as $singlePostedSitemapLink) {
                 $filename = 'sitemap_';
                 $extractedQuery = parse_url($singlePostedSitemapLink, PHP_URL_QUERY);
                 parse_str($extractedQuery, $parsedLink);
                 // Evaluate format
                 if (!empty($parsedLink['format'])) {
                     $filename .= $parsedLink['format'];
                 }
                 // Evaluate language
                 if (!empty($parsedLink['lang'])) {
                     $filename .= '_' . $parsedLink['lang'];
                 }
                 // Evaluate dataset
                 if (!empty($parsedLink['dataset'])) {
                     $filename .= '_dataset' . $parsedLink['dataset'];
                 }
                 // Evaluate Itemid
                 if (!empty($parsedLink['Itemid'])) {
                     $filename .= '_menuid' . $parsedLink['Itemid'];
                 }
                 if (JFile::exists(JPATH_COMPONENT_SITE . '/precache/' . $filename . '.xml')) {
                     // get last generation time
                     $lastGenerationTimestamp = filemtime(JPATH_COMPONENT_SITE . '/precache/' . $filename . '.xml');
                     $dateObject = new JDate($lastGenerationTimestamp);
                     $dateObject->setTimezone($localTimeZone);
                     $response->sitemapLinksStatus[$singlePostedSitemapLink] = array('cached' => true, 'lastgeneration' => $dateObject->format('Y-m-d', true));
                 } else {
                     $response->sitemapLinksStatus[$singlePostedSitemapLink] = false;
                 }
             }
         }
         // All completed succesfully
         $response->result = true;
     } catch (Exception $e) {
         $jmapException = new JMapException($e->getMessage(), 'error');
         $response->result = false;
         $response->exception_message = $jmapException->getMessage();
         return $response;
     }
     return $response;
 }
示例#24
0
文件: users.php 项目: adjaika/J3Base
 /**
  * Construct the date range to filter on.
  *
  * @param   string  $range  The textual range to construct the filter for.
  *
  * @return  string  The date range to filter on.
  *
  * @since   3.6.0
  */
 private function buildDateRange($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':
             $dNow = false;
         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->get('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;
         case 'never':
             $dNow = false;
             $dStart = $this->_db->getNullDate();
             break;
     }
     return array('dNow' => $dNow, 'dStart' => $dStart);
 }
示例#25
0
 /**
  * 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.
  *
  * @since   1.6
  */
 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');
             $result->extension = $this->getState('category.extension');
         }
         // 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;
         }
     }
     return $result;
 }
示例#26
0
 $endTime = new JDate($record['backupend']);
 $duration = $endTime->toUnix() - $startTime->toUnix();
 if ($duration > 0) {
     $seconds = $duration % 60;
     $duration = $duration - $seconds;
     $minutes = $duration % 3600 / 60;
     $duration = $duration - $minutes * 60;
     $hours = $duration / 3600;
     $duration = sprintf('%02d', $hours) . ':' . sprintf('%02d', $minutes) . ':' . sprintf('%02d', $seconds);
 } else {
     $duration = '';
 }
 $user = JFactory::getUser();
 $userTZ = $user->getParam('timezone', 'UTC');
 $tz = new DateTimeZone($userTZ);
 $startTime->setTimezone($tz);
 // Link for Show Comments lightbox
 $info_link = "";
 if (!empty($record['comment'])) {
     $info_link = "<span class=\"icon icon-question-sign akeebaCommentPopover\" rel=\"popover\" data-content=\"" . $this->escape($record['comment']) . "\"></span>";
 }
 // Label class based on status
 $status = JText::_('STATS_LABEL_STATUS_' . $record['meta']);
 $statusClass = '';
 switch ($record['meta']) {
     case 'ok':
         $statusIcon = 'fa-check';
         $statusClass = 'label-success';
         break;
     case 'pending':
         $statusIcon = 'fa-play-circle-o';
示例#27
0
文件: time.php 项目: Jougito/DynWeb
 /**
  * Return locale date
  *
  * @param	null
  * @return	date object
  * @since   2.4.2
  * */
 public static function getLocaleDate($date = 'now')
 {
     $mainframe = JFactory::getApplication();
     $systemOffset = $mainframe->getCfg('offset');
     $now = new JDate($date, $systemOffset);
     // // Joomla 1.6
     $timezone = new DateTimeZone($systemOffset);
     $now->setTimezone($timezone);
     return $now;
 }
示例#28
0
 /**
  * Method to get a category.
  *
  * @param	integer	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.
  * @since	1.6
  */
 public function getItem($pk = null)
 {
     $pk = $pk ? $pk : $this->_id;
     if ($result = parent::getItem($pk)) {
         // Prime required properties.
         if (empty($result->id)) {
             $result->parent_id = $this->getState('com_flexicontent.category.parent_id');
             $result->extension = $this->getState('com_flexicontent.category.extension');
         }
         // Convert the metadata field to an array.
         $registry = new JRegistry($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');
         $site_zone = JFactory::getApplication()->getCfg('offset');
         $user_zone = JFactory::getUser()->getParam('timezone', $site_zone);
         $tz_string = $user_zone;
         $tz = new DateTimeZone($tz_string);
         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;
         }
         $this->_category = $result;
     }
     $useAssocs = $this->useAssociations();
     if ($useAssocs) {
         if ($result->id != null) {
             $result->associations = CategoriesHelper::getAssociations($result->id, $result->extension);
             JArrayHelper::toInteger($result->associations);
         } else {
             $result->associations = array();
         }
     }
     return $result;
 }
示例#29
0
</link>
<description><![CDATA[<?php 
echo $this->cparams->get('rss_channel_description', null);
?>
]]></description>
<language><?php 
echo $this->rssLang;
?>
</language>
<webMaster><?php 
echo htmlspecialchars($this->cparams->get('rss_webmaster_email', $this->joomlaConfig->get('mailfrom', null)) . ' ' . '(' . $this->cparams->get('rss_webmaster_name', $this->joomlaConfig->get('fromname', null)) . ')', ENT_COMPAT, 'UTF-8');
?>
</webMaster>
<pubDate><?php 
$dateObj = new JDate();
$dateObj->setTimezone(new DateTimeZone($this->globalConfig->get('offset')));
echo htmlspecialchars($dateObj->toRFC822(true), ENT_COMPAT, 'UTF-8');
?>
</pubDate>
<generator>JSitemap Pro</generator>
<atom:link rel="self" type="application/rss+xml" href="<?php 
$current = JUri::getInstance();
echo htmlspecialchars($current->toString(array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query')), ENT_COMPAT, 'UTF-8');
?>
"/>
<?php 
if ($channelImage = $this->cparams->get('rss_channel_image', null)) {
    ?>
<image>
	<url><?php 
    echo $this->liveSite . '/' . $channelImage;
示例#30
0
 /**
  * Testing setTimezone
  *
  * @param   string  $tz        Which Time Zone should it be?
  * @param   string  $expected  What should the resulting time string look like?
  *
  * @return  void
  *
  * @dataProvider casesSetTimezone
  * @since   11.3
  * @covers  JDate::setTimezone
  */
 public function testSetTimezone($tz, $expected)
 {
     $this->object->setTimezone(new DateTimeZone($tz));
     $this->assertThat($this->object->format('r', true), $this->equalTo($expected));
 }