/** * remove from set */ function removefromset() { $model = $this->getModel(); $table = $model->getTable(); $key = $table->getKeyName(); $urlVar = $key; $jinput = JFactory::getApplication()->input; $recordId = $jinput->getInt($urlVar); $recurrence_group = $jinput->getInt('recurrence_group'); # Retrieve id of current event from recurrence_table $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('id'); $query->from($db->quoteName('#__jem_recurrence')); $query->where(array('groupid_ref = ' . $recurrence_group, 'itemid= ' . $recordId)); $db->setQuery($query); $recurrenceid = $db->loadResult(); # Update field recurrence_group in event-table $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->update('#__jem_events'); $query->set(array('recurrence_count = ""', 'recurrence_freq = ""', 'recurrence_group = ""', 'recurrence_interval = ""', 'recurrence_until = ""', 'recurrence_weekday = ""')); $query->where('id = ' . $recordId); $db->setQuery($query)->query(); # Blank field groupid_ref in recurrence-table and set exdate value $recurrence_table = JTable::getInstance('Recurrence', 'JEMTable'); $recurrence_table->load($recurrenceid); $startdate_org_input = new JDate($recurrence_table->startdate_org); $exdate = $startdate_org_input->format('Ymd\\THis\\Z'); $recurrence_table->exdate = $exdate; $recurrence_table->groupid_ref = ""; $recurrence_table->store(); # redirect back $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $urlVar), false)); }
protected function getInput() { $class = !empty($this->class) ? $this->class : ''; $required = $this->required ? ' required aria-required="true"' : ''; $birthdayDay = ''; $birthdayMonth = '01'; $birthdayYear = ''; // Prepare birthday if (!empty($this->value)) { $date = new Prism\Validator\Date($this->value); if (!$date->isValid()) { $birthdayDay = ''; $birthdayMonth = ''; $birthdayYear = ''; } else { $date = new JDate($this->value); $birthdayDay = $date->format('d'); $birthdayMonth = $date->format('m'); $birthdayYear = $date->format('Y'); } } $months = new Socialcommunity\Filter\Months(); $html = array(); $html[] = '<div class="' . $class . '">'; $html[] = ' <input name="' . $this->name . '[day]" value="' . $birthdayDay . '" id="birthday_day" class="col-md-3 ' . $class . '" type="text" placeholder="' . JText::_('COM_SOCIALCOMMUNITY_DAY') . '" ' . $required . '>'; $html[] = JHTML::_('select.genericlist', $months->toOptions(), $this->name . '[month]', array('class' => 'col-md-3 ' . $class), 'text', 'value', $birthdayMonth, 'birthday_month'); $html[] = ' <input name="' . $this->name . '[year]" value="' . $birthdayYear . '" id="birthday_year" class="col-md-4 ' . $class . '" type="text" placeholder="' . JText::_('COM_SOCIALCOMMUNITY_YEAR') . '" ' . $required . '>'; $html[] = '</div>'; return implode($html); }
/** * Display the view */ public function display($tpl = null) { // get the data $this->months = $this->get('Months'); $this->month_days = $this->get('MonthDays'); $this->month_start = $this->get('MonthStart'); $this->month_16 = $this->get('Month16'); $this->hotels = $this->get('Hotels'); $this->hotel = $this->get('Hotel'); $this->inventory = $this->get('Inventory'); $this->bookings_in_progress = $this->get('BookingsInProgress'); // filters $this->state = $this->get('State'); // default dates $app = JFactory::getApplication(); $date_format = CHPanelHelper::getDateFormat(JText::_('COM_CHPANEL_LOCALE')); // start & end $this->start = $app->getUserStateFromRequest('com_chpanel.manage.start', 'start', JFactory::getDate()->format($date_format), 'string'); $this->end = $app->getUserStateFromRequest('com_chpanel.manage.end', 'end', JFactory::getDate('+ 1 day')->format($date_format), 'string'); // title $date = new JDate('01-' . $this->state->get('filter.month')); $this->title = $this->hotel ? $this->hotel->title . ' - ' . $date->format('F Y') : $date->format('F Y'); // toolbar CHPanelHelper::getToolbar('manage'); // sidebar $this->sidebar = JHtmlSidebar::render(); // display the view layout parent::display($tpl); }
protected function getInput() { $class = !empty($this->class) ? $this->class : ''; $required = $this->required ? ' required aria-required="true"' : ''; // Prepare birthday if (!empty($this->value)) { $date = new Prism\Validator\Date($this->value); if (!$date->isValid()) { $birthdayDay = ""; $birthdayMonth = ""; $birthdayYear = ""; } else { $date = new JDate($this->value); $birthdayDay = $date->format("d"); $birthdayMonth = $date->format("m"); $birthdayYear = $date->format("Y"); } } $html = array(); $html[] = '<div class="' . $class . '">'; $html[] = ' <input name="' . $this->name . '[day]" value="' . $birthdayDay . '" id="birthday_day" class="span3" type="text" placeholder="' . JText::_("COM_SOCIALCOMMUNITY_DAY") . '" ' . $required . '>'; $html[] = ' <input name="' . $this->name . '[month]" value="' . $birthdayMonth . '" id="birthday_month" class="span3" type="text" placeholder="' . JText::_("COM_SOCIALCOMMUNITY_MONTH") . '" ' . $required . '>'; $html[] = ' <input name="' . $this->name . '[year]" value="' . $birthdayYear . '" id="birthday_year" class="span4" type="text" placeholder="' . JText::_("COM_SOCIALCOMMUNITY_YEAR") . '" ' . $required . '>'; $html[] = '</div>'; return implode($html); }
private function getInvoiceListParameters() { JLoader::import('joomla.utilities.date'); $jNow = new JDate(); $month = $this->input->getInt('month', 0); if ($month < 1 || $month > 12) { $month = (int) $jNow->format('m'); $month--; } $year = $this->input->getInt('year', 0); if ($year < 2010 || $year > 2100) { $year = (int) $jNow->format('Y'); } if ($month <= 0) { $month = 12; $year--; } $vies = false; $vatmoss = false; switch ($this->getTask()) { case 'vies': $vies = true; break; case 'vatmoss': $vatmoss = true; break; } $invoiceExtension = $this->input->getCmd('extension', 'akeebasubs'); return array('month' => $month, 'year' => $year, 'vies' => $vies, 'vatmoss' => $vatmoss, 'extension' => $invoiceExtension); }
function build() { $formatedDate = ""; if (!empty($this->dataValue) && $this->dataValue != "0000-00-00" && $this->dataValue != "00:00:00" && $this->dataValue != "0000-00-00 00:00:00") { jimport("joomla.utilities.date"); $date = new JDate($this->dataValue); if ($tz = $this->timezone) { if ($tz == 'server') { //TODO : Get the server timezone $tz = 0; //DBG } else { if ($tz == 'local') { //TODO : Get the current user local timezone $tz = 0; //DBG } } $date->setOffset((int) $tz); } $formatedDate = $date->format($this->dateFormat, !empty($tz)); } $this->addClass('fly-date'); $html = '<span <%STYLE%><%CLASS%><%SELECTORS%>>' . $formatedDate . '</span>'; return $html; }
public function browse() { // Check permissions $this->_checkPermissions(); // Set the profile $this->_setProfile(); // Start the backup JLoader::import('joomla.utilities.date'); AECoreKettenrad::reset(array('maxrun' => 0)); AEUtilTempfiles::deleteTempFiles(); AEUtilTempvars::reset(AKEEBA_BACKUP_ORIGIN); $kettenrad = AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN); $dateNow = new JDate(); $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true); $options = array('description' => $description, 'comment' => ''); $kettenrad->setup($options); $kettenrad->tick(); $kettenrad->tick(); $array = $kettenrad->getStatusArray(); AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN); if ($array['Error'] != '') { // An error occured die('500 ERROR -- ' . $array['Error']); } else { $noredirect = $this->input->get('noredirect', 0, 'int'); if ($noredirect != 0) { @ob_end_clean(); echo "301 More work required"; flush(); JFactory::getApplication()->close(); } else { $this->_customRedirect(JURI::base() . 'index.php?option=com_akeeba&view=backup&task=step&key=' . $this->input->get('key', '', 'none', 2) . '&profile=' . $this->input->get('profile', 1, 'int')); } } }
/** * Tries to authenticate the user and start the backup, or send him back to the default task */ public function authenticate() { // Enforce raw mode - I need to be in full control! $document =& JFactory::getDocument(); $document->setType('raw'); if (!$this->_checkPermissions()) { parent::redirect(); } else { $session =& JFactory::getSession(); $session->set('litemodeauthorized', 1, 'akeeba'); $this->_setProfile(); jimport('joomla.utilities.date'); AECoreKettenrad::reset(); $memory_filename = AEUtilTempvars::get_storage_filename(AKEEBA_BACKUP_ORIGIN); @unlink($memory_filename); $kettenrad =& AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN); $user =& JFactory::getUser(); $userTZ = $user->getParam('timezone', 0); $dateNow = new JDate(); $dateNow->setOffset($userTZ); if (AKEEBA_JVERSION == '16') { $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true); } else { $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->toFormat(JText::_('DATE_FORMAT_LC2')); } $options = array('description' => $description, 'comment' => ''); $kettenrad->setup($options); $ret = $kettenrad->tick(); AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN); $this->setRedirect(JURI::base() . 'index.php?option=com_akeeba&view=light&task=step&key=' . urlencode(JRequest::getVar('key')) . '&profile=' . JRequest::getInt('profile') . '&format=raw'); } }
/** * Testing toString * * @param string $format How should the time be formatted? * @param string $expectedTime What should the resulting time string look like? * * @return void * @dataProvider casesToString */ public function testToString($format, $expectedTime) { if (!is_null($format)) { JDate::$format = $format; } $this->assertThat($this->object->__toString(), $this->equalTo($expectedTime)); }
public static function formatDate($date, $format = null, $jsFormat = true) { if (is_null($format)) { if (!($format = self::getDateFormat())) { reset(self::$_dateFormats); $format = key(self::$_dateFormats); } } if ($jsFormat) { if (isset(self::$_dateFormats[$format])) { $format = self::$_dateFormats[$format]; } else { $format = reset(self::$_dateFormats); } } if ($date instanceof DateTime) { $timestamp = $date->getTimestamp(); } else { if (is_int($date)) { $timestamp = $date; } else { $timestamp = strtotime((string) $date); } } //return date($format, $timestamp); $dt = new JDate($date); return $dt->format($format); }
/** * Tries to authenticate the user and start the backup, or send him back to the default task */ public function authenticate() { // Enforce raw mode - I need to be in full control! if (!$this->_checkPermissions()) { parent::redirect(); } else { $session = JFactory::getSession(); $session->set('litemodeauthorized', 1, 'akeeba'); $this->_setProfile(); JLoader::import('joomla.utilities.date'); AECoreKettenrad::reset(array('maxrun' => 0)); AEUtilTempvars::reset(AKEEBA_BACKUP_ORIGIN); $kettenrad = AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN); $dateNow = new JDate(); /* $user = JFactory::getUser(); $userTZ = $user->getParam('timezone',0); $dateNow->setOffset($userTZ); */ $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true); $options = array('description' => $description, 'comment' => ''); $kettenrad->setup($options); $ret = $kettenrad->tick(); AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN); JFactory::getApplication()->redirect(JURI::base() . 'index.php?option=com_akeeba&view=light&task=step&key=' . urlencode($this->input->get('key', '', 'none', 2)) . '&profile=' . $this->input->get('profile', 1, 'int') . '&format=raw'); } }
/** * Execute the controller. * * @return string The rendered view. */ public function execute() { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('*')->from('Comments'); $db->setQuery($query); $comments = $db->loadAssocList(); $commentMarkup = ''; foreach ($comments as $comment) { $date = new JDate($comment['date']); $commentMarkup .= '<article><h3><a href="mailto:' . htmlspecialchars($comment['Email']) . '">' . htmlspecialchars($comment['Name']) . '</a> wrote:</h3> <p>' . htmlspecialchars($comment['Comment']) . '</p> <small>' . $date->format('d.m.Y', true) . ', ' . htmlspecialchars(long2ip($comment['Ip'])) . '</small></article>'; } return ' <form action="index.php" enctype="application/x-www-form-urlencoded" method="post"> <fieldset> <input id="name" autofocus="autofocus" type="text" name="name" placeholder="Name" size="40" required="required" /><br /> <input id="email" type="email" name="email" placeholder="E-Mail" size="40" required="required" /><br /> <textarea id="comment" name="comment" placeholder="Your Comment" rows="10" cols="40" required="required"></textarea><br /> <input type="hidden" name="task" value="add" /> <input type="submit" vale="Send" /> </fieldset> </form> <section> <h2>Comments</h2> ' . $commentMarkup . ' </section> '; }
function date_bl($date, $time) { return JSBaseView::formatDate($date . ' ' . $time); $format = "d-m-Y H:i"; if ($date == '' || $date == '0000-00-00') { return ''; } // $format = getJS_Config('date_format'); // print_r($format);echo "<hr>"; /*switch ($format){ case "d-m-Y H:i": $format = "%d-%m-%Y %H:%M"; break; case "m-d-Y g:i A": $format = "%m-%d-%Y %I:%M %p"; break; case "j F, Y H:i": $format = "%m %B, %Y %H:%M"; break; case "j F, Y g:i A": $format = "%m %B, %Y %I:%H %p"; break; case "d-m-Y": $format = "%d-%m-%Y"; break; case "l d F, Y H:i": $format = "%A %d %B, %Y %H:%M"; break; }*/ if (!$time) { $time = '00:00'; } $time_m = explode(':', $time); $date_m = explode('-', $date); if (function_exists('date_default_timezone_set')) { date_default_timezone_set('GMT'); } $tm = @mktime($time_m[0], $time_m[1], '0', $date_m[1], $date_m[2], $date_m[0]); jimport('joomla.utilities.date'); $dt = new JDate($tm, null); return $dt->format($format); }
public function export($event) { //CFactory::load( 'helpers' , 'event' ); $handler = CEventHelper::getHandler($event); if (!$handler->showExport()) { echo JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN'); return; } header('Content-type: text/Calendar'); header('Content-Disposition: attachment; filename="calendar.ics"'); $creator = CFactory::getUser($event->creator); $offset = $creator->getUtcOffset(); $date = new JDate($event->startdate); $dtstart = $date->format('Ymd\\THis'); //$date->format('%Y%m%dT%H%M%S'); $date = new JDate($event->enddate); $dtend = $date->format('Ymd\\THis'); //$date->format('%Y%m%dT%H%M%S'); $date = new JDate($event->repeatend); $rend = $date->format('Ymd\\THis'); //$date->format('%Y%m%dT%H%M%S'); $url = $handler->getFormattedLink('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false, true); $tmpl = new CTemplate(); $tmpl->set('dtstart', $dtstart); $tmpl->set('dtend', $dtend); $tmpl->set('rend', $rend); $tmpl->set('url', $url); $tmpl->set('event', $event); $raw = $tmpl->fetch('events.ical'); unset($tmpl); echo $raw; exit; }
/** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * @since 1.6 */ protected function loadFormData() { $app = JFactory::getApplication(); /** @var $app JApplicationSite */ $data = $app->getUserState($this->option . '.edit.funding.data', array()); if (!$data) { $itemId = (int) $this->getState($this->getName() . '.id'); $userId = JFactory::getUser()->get("id"); $data = $this->getItem($itemId, $userId); // Prepare date format. $dateFormat = CrowdfundingHelper::getDateFormat(); $dateValidator = new Prism\Validator\Date($data->funding_end); // Validate end date. If the date is not valid, generate a valid one. // Use minimum allowed days to generate end funding date. if (!$dateValidator->isValid()) { // Get minimum days. $params = $this->getState("params"); $minDays = $params->get("project_days_minimum", 30); // Generate end date. $today = new Crowdfunding\Date(); $fundingEndDate = $today->calculateEndDate($minDays); $data->funding_end = $fundingEndDate->format("Y-m-d"); } $date = new JDate($data->funding_end); $data->funding_end = $date->format($dateFormat); } return $data; }
/** * Formats a time/date. * * @param mixed $date * @param string $format * @return string */ public function format($date, $format = 'medium') { $date = new \JDate($date); if (isset($this->formats[$format])) { $format = $this->formats[$format]; } return $date->format($format); }
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); }
/** * adds the link for the connect param * @since 1.7.3 * @param $user pass-by-reference * @return void */ private function getUserLink(&$user) { $username = KunenaFactory::getUser($user['userid'])->getName(); if ($user['leapcorrection'] == $this->timeo->format('z', true) + 1) { $subject = getSubject($username); $db = JFactory::getDBO(); $query = "SELECT id,catid,subject,time as year FROM #__kunena_messages WHERE subject='{$subject}'"; $db->setQuery($query, 0, 1); $post = $db->loadAssoc(); if ($db->getErrorMsg()) { KunenaError::checkDatabaseError(); } $catid = $this->params->get('bcatid'); $postyear = new JDate($post['year'], $this->soffset); if (empty($post) && !empty($catid) || !empty($post) && !empty($catid) && $postyear->format('Y', true) < $this->timeo->format('Y', true)) { $botname = $this->params->get('swkbbotname', JText::_('SW_KBIRTHDAY_FORUMPOST_BOTNAME_DEF')); $botid = $this->params->get('swkbotid'); $time = CKunenaTimeformat::internalTime(); //Insert the birthday thread into DB $query = "INSERT INTO #__kunena_messages (catid,name,userid,email,subject,time, ip)\n\t\t \t\tVALUES({$catid},'{$botname}',{$botid}, '','{$subject}', {$time}, '')"; $db->setQuery($query); $db->query(); if ($db->getErrorMsg()) { KunenaError::checkDatabaseError(); } //What ID get our thread? $messid = (int) $db->insertID(); //Insert the thread message into DB $message = getMessage($username); $query = "INSERT INTO #__kunena_messages_text (mesid,message)\n VALUES({$messid},'{$message}')"; $db->setQuery($query); $db->query(); if ($db->getErrorMsg()) { KunenaError::checkDatabaseError(); } //We know the thread ID so we can update the parent thread id with it's own ID because we know it's //the first post $query = "UPDATE #__kunena_messages SET thread={$messid} WHERE id={$messid}"; $db->setQuery($query); $db->query(); if ($db->getErrorMsg()) { KunenaError::checkDatabaseError(); } // now increase the #s in categories CKunenaTools::modifyCategoryStats($messid, 0, $time, $catid); $user['link'] = CKunenaLink::GetViewLink('view', $messid, $catid, '', $username); $uri = JFactory::getURI(); if ($uri->getVar('option') == 'com_kunena') { $app =& JFactory::getApplication(); $app->redirect($uri->toString()); } } elseif (!empty($post)) { $user['link'] = CKunenaLink::GetViewLink('view', $post['id'], $post['catid'], '', $username); } } else { $user['link'] = CKunenaLink::GetProfileLink($user['userid']); } }
static function getTimeOptions($date = '0000-00-00 00:00:00') { // Get time (not including the final secons) $time = substr($date, 11, 5); $html = ''; $config = new JXConfig(); $tz = $config->getTimezone() != '' ? $config->getTimezone() : JText::_('JXLIB_DEFAULT_TIMEZONE'); $tz = new DateTimeZone($tz); /* create a date for every hour */ for ($i = 0; $i < 24; $i++) { $newDate = new JDate(mktime($i, 0, 0, 7, 1, 2000), $tz); $newDate->format(JText::_('H:i'), false); /* if the selected is in hours */ $selected = $time == $newDate->format(JText::_('H:i'), true) ? 'selected="selected"' : ''; /* add the options */ $html .= '<option ' . $selected . 'value="' . $newDate->format(JText::_('H:i'), true) . '" >' . $newDate->format(JText::_('JXLIB_TIME_SHORT_FORMAT'), true) . '</option>'; /* and modify for 30 mins between these hours */ $newDate->modify('+30 minute'); /* check again to see if its in 30 mins interval */ $selected = $time == $newDate->format(JText::_('H:i'), true) ? 'selected="selected"' : ''; /* add the options */ $html .= '<option ' . $selected . 'value="' . $newDate->format(JText::_('H:i'), true) . '" >' . $newDate->format(JText::_('JXLIB_TIME_SHORT_FORMAT'), true) . '</option>'; } return $html; }
/** * This method will be called if the login process fails * * @param array $response * * @return null|bool */ public function onUserLoginFailure($response) { $app = JFactory::getApplication(); /** @var $app JApplicationSite */ if ($app->isAdmin()) { return; } $doc = JFactory::getDocument(); /** @var $doc JDocumentHtml */ // Check document type $docType = $doc->getType(); if (strcmp('html', $docType) !== 0) { return; } $ipAddressesFile = JPath::clean(__DIR__ . '/files/ip.log'); $content = $this->getContent($ipAddressesFile); $isBruteForceAttack = false; $recordExists = false; $ip = $this->getIp($app); $today = new JDate(); $todayFormatted = $today->format('Y-m-d'); foreach ($content as $key => $userData) { if (strcmp($userData['ip'], $ip) === 0) { if ($userData['date'] === $todayFormatted) { $content[$key]['attempts']++; } else { // Restart attempts. $content[$key]['date'] = $todayFormatted; $content[$key]['attempts'] = 1; } $recordExists = true; $isBruteForceAttack = $this->isBruteForceAttack($content[$key]); break; } } if (!$recordExists) { $content[] = array('ip' => $ip, 'date' => $todayFormatted, 'attempts' => 1); } // Send notification mail to the administrator. if ($isBruteForceAttack and $this->params->get('send_email_brute_force', 0)) { $this->loadLanguage(); $uri = JUri::getInstance(); $senderId = $this->params->get('sender_id'); $sender = JFactory::getUser($senderId); $subject = JText::_('PLG_USER_FACECONTROL_BRUTE_FORCE_ATTACK_SUBJECT'); $body = JText::sprintf('PLG_USER_FACECONTROL_BRUTE_FORCE_BODY_S', $ip, $uri->toString(array('scheme', 'host', 'port'))); $mailer = JFactory::getMailer(); $return = $mailer->sendMail($sender->get('email'), $sender->get('name'), $app->get('mailfrom'), $subject, $body); // Check for an error. if ($return !== true) { JLog::add(JText::sprintf('PLG_USER_FACECONTROL_MAIL_ERROR_S', $mailer->ErrorInfo)); } } // Store the content. $buffer = json_encode($content); JFile::write($ipAddressesFile, $buffer); }
public function getItems() { if (!$this->pid) { return array(); } $user = JFactory::getUser(); $db = JFactory::getDbo(); $query = $db->getQuery(true); $nd = $db->getNullDate(); $query->select('a.id, a.milestone_id, a.title, a.created')->select('m.start_date AS m_start, m.end_date AS m_end')->from('#__pf_task_lists AS a')->join('LEFT', '#__pf_projects AS p ON p.id = a.project_id')->join('LEFT', '#__pf_milestones AS m ON m.id = a.milestone_id')->where('a.project_id = ' . $this->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 $datas = array(); $keys = JArrayHelper::getColumn($data, 'id'); $completed = $this->getCompleted($keys); foreach ($data as $i => $item) { // Set dates $item->start_date = $this->getStartDate($item->id, $item->milestone_id, $item->m_start); $item->end_date = $this->getEndDate($item->id, $item->milestone_id, $item->m_end); // Skip item if no start or end is set if ($item->start_date == $nd || $item->end_date == $nd) { continue; } $item->complete = $completed[$item->id]; $item->start_time = floor(strtotime($item->start_date) / 86400) * 86400; $item->end_time = floor(strtotime($item->end_date) / 86400) * 86400; $start_date = new JDate($item->start_date); $end_date = new JDate($item->end_date); $item->start_date = $start_date->format('Y-m-d H:i:s'); $item->end_date = $end_date->format('Y-m-d H:i:s'); $item->duration = $item->end_time - $item->start_time; $duration = strtotime($item->end_date) - strtotime($item->start_date); $item->fduration = $this->time2string($duration); $item->type = 'tasklist'; if (!isset($datas[$item->start_time])) { $datas[$item->start_time] = array(); } $datas[$item->start_time][] = $item; } ksort($datas, SORT_NUMERIC); $items = array(); foreach ($datas as $key => $vals) { foreach ($vals as $val) { $items[] = $val; } } return $items; }
public static function log($action, $user_id = null) { $table = JTable::getInstance('', 'CTableEngagement'); $table->action = $action; $table->user_id = $user_id; $date = new JDate(); $table->created = $date->toSql(); $table->week = $date->format('W'); $table->store(); }
/** * Method to render the view. * * @return string The rendered view. * * @throws RuntimeException */ public function render() { $comments = $this->model->getAll(); foreach ($comments as $key => $comment) { $date = new JDate($comment['date']); $comments[$key]['date'] = $date->format('d.m.Y', true); } $this->comments = $comments; return parent::render(); }
public function display() { // Check permissions $this->_checkPermissions(); // Set the profile $this->_setProfile(); // Start the backup jimport('joomla.utilities.date'); AECoreKettenrad::reset(); $memory_filename = AEUtilTempvars::get_storage_filename(AKEEBA_BACKUP_ORIGIN); @unlink($memory_filename); $kettenrad =& AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN); $user =& JFactory::getUser(); $userTZ = $user->getParam('timezone',0); $dateNow = new JDate(); $dateNow->setOffset($userTZ); if( AKEEBA_JVERSION == '16' ) { $description = JText::_('BACKUP_DEFAULT_DESCRIPTION').' '.$dateNow->format(JText::_('DATE_FORMAT_LC2'), true); } else { $description = JText::_('BACKUP_DEFAULT_DESCRIPTION').' '.$dateNow->toFormat(JText::_('DATE_FORMAT_LC2')); } $options = array( 'description' => $description, 'comment' => '' ); $kettenrad->setup($options); $array = $kettenrad->tick(); $array = $kettenrad->tick(); AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN); if($array['Error'] != '') { // An error occured die('500 ERROR -- '.$array['Error']); } else { $noredirect = JRequest::getInt('noredirect', 0); if($noredirect != 0) { @ob_end_clean(); echo "301 More work required"; flush(); JFactory::getApplication()->close(); } else { $this->setRedirect(JURI::base().'index.php?option=com_akeeba&view=backup&task=step&key='.JRequest::getVar('key').'&profile='.JRequest::getInt('profile',1)); } } }
public static function date($date, $format = null) { JLoader::import('joomla.utilities.date'); $jDate = new JDate($date); if (empty($format)) { if (!class_exists('AkeebasubsHelperCparams')) { require_once JPATH_ADMINISTRATOR . '/components/com_akeebasubs/helpers/cparams.php'; } $format = AkeebasubsHelperCparams::getParam('dateformat', 'Y-m-d H:i'); $format = str_replace('%', '', $format); } return $jDate->format($format, 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); }
/** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ protected function getInput() { // Initialize variables. $html = array(); $time_created = $this->value; if (!$time_created) { $time_created = date("Y-m-d H:i:s"); $html[] = '<input type="hidden" name="' . $this->name . '" value="' . $time_created . '" />'; } $jdate = new JDate($time_created); $pretty_date = $jdate->format(JText::_('DATE_FORMAT_LC2')); $html[] = "<div>" . $pretty_date . "</div>"; return implode($html); }
function display($tpl = null) { $doc = JFactory::getDocument(); $doc->setTitle(JText::_("COM_STREAM_LABEL_ALL_EVENTS")); $html = ''; $this->addPathway(JText::_('NAVIGATOR_LABEL_EVENTS'), JRoute::_('index.php?option=com_stream&view=groups')); $this->_attachScripts(); $tmpl = new StreamTemplate(); $html .= $tmpl->fetch('event.page'); $my = JXFactory::getUser(); if (!$my->getParam(ALERT_CALENDAR_INTRO)) { $html .= ' <div class="alert alert-success" data-alert_id="' . ALERT_CALENDAR_INTRO . '"> <a data-dismiss="alert" class="close">×</a> ' . JText::_('COM_STREAM_HELPER_EVENT') . '</div>'; } JXModule::addBuffer('right', $this->getUpcomingHotEvent()); // Show calendar $now = new JDate(); StreamFactory::load('helpers' . DS . 'calendar'); $html .= '<div id="stream-calendar">' . StreamCalendarHelper::generate_calendar($now->format('Y'), $now->format('m')) . '</div>'; echo $html; //echo $this->getStreamDataHTML(); }
/** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ protected function getInput() { // Initialize variables. $html = array(); $time_created = $this->value; if (!strtotime($time_created)) { $time_created = JFactory::getDate()->toSql(); $html[] = '<input type="hidden" name="' . $this->name . '" value="' . $time_created . '" />'; } $hidden = (bool) $this->element['hidden']; if ($hidden == null || !$hidden) { $jdate = new JDate($time_created); $pretty_date = $jdate->format(JText::_('DATE_FORMAT_LC2')); $html[] = "<div>" . $pretty_date . "</div>"; } return implode($html); }
/** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ protected function getInput() { // Initialize variables. $html = array(); $time_created = $this->value; if (!strtotime($time_created)) { $time_created = ImcFrontendHelper::convert2UTC(date("Y-m-d H:i:s")); } $hidden = (bool) $this->element['hidden']; if ($hidden == null || !$hidden) { $jdate = new JDate(ImcFrontendHelper::convertFromUTC($time_created)); $pretty_date = $jdate->format(JText::_('DATE_FORMAT_LC2')); $html[] = "<span>" . $pretty_date . "</span>"; } $html[] = '<input type="hidden" name="' . $this->name . '" value="' . $time_created . '" />'; return implode("\n", $html); }