/**
  * Find one by hours event
  *
  * @param integer $hours
  * @param Date $date
  * @return Cursor
  */
 public function findOneByHoursEvent($hours = null, $date = null)
 {
     if (!$date) {
         $currentDatetime = new \DateTime("now");
         $hoursDatetime = new \DateTime("now");
         $startDay = new \DateTime("now");
         $finishDay = new \DateTime("now");
     } else {
         $currentDatetime = new \DateTime($date->format('Y-m-d H:s:i'));
         $hoursDatetime = new \DateTime($date->format('Y-m-d H:s:i'));
         $startDay = new \DateTime($date->format('Y-m-d H:s:i'));
         $finishDay = new \DateTime($date->format('Y-m-d H:s:i'));
     }
     $hoursDatetime->add(new \DateInterval('PT' . $hours . 'H'));
     $startDay->setTime(0, 0, 0);
     $finishDay->setTime(23, 59, 59);
     $currentDayEvents = $this->createQueryBuilder()->field('display')->equals(true)->field('date')->gte($startDay)->field('date')->lte($finishDay)->sort('date', 1)->getQuery()->execute();
     $duration = 0;
     foreach ($currentDayEvents as $event) {
         $eventDate = new \DateTime($event->getDate()->format("Y-m-d H:i:s"));
         if ($eventDate <= $hoursDatetime && $currentDatetime <= $eventDate->add(new \DateInterval('PT' . $event->getDuration() . 'M'))) {
             return $event;
         }
     }
     return null;
 }
Exemple #2
0
 /**
  * Returns human readable date.
  *
  * @param  array  $config An optional array with configuration options.
  * @return string Formatted date.
  */
 public function humanize($config = array())
 {
     $config = new ObjectConfig($config);
     $config->append(array('date' => 'now', 'timezone' => date_default_timezone_get(), 'default' => \JText::_('Never'), 'smallest_period' => 'second'));
     $result = $config->default;
     if (!in_array($config->date, array('0000-00-00 00:00:00', '0000-00-00'))) {
         $periods = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year');
         $lengths = array(60, 60, 24, 7, 4.35, 12, 10);
         $now = new \DateTime();
         try {
             $date = new Date(array('date' => $config->date, 'timezone' => 'UTC'));
             $date->setTimezone(new \DateTimeZone($config->timezone));
             if ($now != $date) {
                 // TODO: Use DateTime::getTimeStamp().
                 if ($now > $date) {
                     $difference = $now->format('U') - $date->format('U');
                     $tense = 'ago';
                 } else {
                     $difference = $date->format('U') - $now->format('U');
                     $tense = 'from now';
                 }
                 for ($i = 0; $difference >= $lengths[$i] && $i < 6; $i++) {
                     $difference /= $lengths[$i];
                 }
                 $difference = round($difference);
                 $period_index = array_search($config->smallest_period, $periods);
                 $omitted_periods = $periods;
                 array_splice($omitted_periods, $period_index);
                 if (in_array($periods[$i], $omitted_periods)) {
                     $difference = 1;
                     $i = $period_index;
                 }
                 if ($periods[$i] == 'day' && ($difference == 1 || $difference == 2)) {
                     if ($difference == 1) {
                         $result = \JText::_('Today');
                     } else {
                         $result = $tense == 'ago' ? \JText::_('Yesterday') : \JText::_('Tomorrow');
                     }
                 } else {
                     if ($difference != 1) {
                         $periods[$i] .= 's';
                     }
                     $result = sprintf(\JText::_('%d ' . $periods[$i] . ' ' . $tense), $difference);
                 }
             } else {
                 $result = \JText::_('Now');
             }
         } catch (\Exception $e) {
         }
     }
     return $result;
 }
Exemple #3
0
/**
 * @param $date
 * @param string $format
 * @return string
 */
function showDate($date, $format = 'date')
{
    $dt = new Date($date);
    if (app::getLocale() == 'en') {
        if ($format == 'date') {
            return $dt->format('Y-m-d');
        }
        if ($format == 'text') {
            return $dt->format('l F j, Y');
        }
        if ($format == 'text-court') {
            return $dt->format('l F j');
        }
        return $dt->format($format);
    }
    if ($format == 'date') {
        return $dt->format('d-m-Y');
    }
    if ($format == 'text') {
        return $dt->format('l j F Y');
    }
    if ($format == 'text-court') {
        return $dt->format('l j F');
    }
    return $dt->format($format);
}
 protected function _calculatePredictiveDate()
 {
     // Прогностическая дата
     $this->_datePredictive = clone $this->_dateOriginal;
     if ($this->_datePredictive->format("Y-m-d H:i:s") <= "1919-07-01 01:59:00" || $this->_notime || $this->city === null) {
         return;
     }
     // Рассчитываем дату и время с учетом поправки на летнее время
     $connection = Yii::app()->db;
     $command = $connection->createCommand("SELECT * FROM {{bazi_summertime}} WHERE `date_start` <= :date AND `date_end` >= :date AND `name` = :name");
     $command->bindParam(":date", $this->_datePredictive->format("Y-m-d H:i:s"));
     $command->bindParam(":name", $this->city->country);
     //$command->bindParam(":date_end", $this->_datePredictive->format("Y-m-d H:i:s"));
     $summerTime = $command->queryRow();
     // Рассчитываем Поправку на часовой пояс (в минутах)
     $command = $connection->createCommand("SELECT * FROM {{bazi_zone}} WHERE `line` = :line AND `date_start` <= :date AND `date_end` >= :date");
     $command->bindParam(":line", $this->city->num, PDO::PARAM_INT);
     $command->bindParam(":date", $this->_datePredictive->format("Y-m-d H:i:s"));
     //$command->bindParam(":date_start", $this->_datePredictive->format("Y-m-d H:i:s"));
     //$command->bindParam(":date_end", $this->_datePredictive->format("Y-m-d H:i:s"));
     $lineInfo = $command->queryRow();
     // Модифицируем дату
     if ($summerTime) {
         $this->_datePredictive->modify(($summerTime['minussec'] - $summerTime['plussec'] > 0 ? "+" : "-") . abs($summerTime['minussec'] - $summerTime['plussec']) . " seconds");
     }
     if ($lineInfo) {
         $this->_datePredictive->modify((-($lineInfo['zone'] * 3600 - $this->city->r * 60) > 0 ? "+" : "-") . abs(-($lineInfo['zone'] * 3600 - $this->city->r * 60)) . " seconds");
     }
 }
Exemple #5
0
 public function get(array $ids = NULL)
 {
     $agent = $this->_section->agent();
     $fids = $this->active_fields();
     $documents = array();
     $results = array('total' => 0, 'documents' => array());
     $pagination = $this->pagination($ids);
     $query = $agent->get_query_props(array_keys($fids), (array) $this->sorting())->select('d.created_on')->select('d.created_by_id')->select('dss.name')->join(array('datasources', 'dss'))->on('d.ds_id', '=', 'dss.id');
     if (!empty($ids)) {
         $query->where('d.id', 'in', $ids);
     }
     $query = $this->search_by_keyword($query);
     $result = $query->limit($this->limit())->offset($this->offset())->execute()->as_array('id');
     if (count($result) > 0) {
         $results['total'] = $pagination->total_items;
         foreach ($result as $id => $row) {
             $data = array('id' => $id, 'published' => (bool) $row['published'], 'header' => $row['header'], 'created_on' => Date::format($row['created_on']), 'created_by_id' => $row['created_by_id']);
             foreach ($fids as $field) {
                 if (isset($row[$field->id])) {
                     $data[$field->name] = $field->fetch_headline_value($row[$field->id], $id);
                 }
             }
             $document = new DataSource_Hybrid_Document($this->_section);
             $document->id = $id;
             $documents[$id] = $document->read_values($data)->set_read_only();
         }
         $results['documents'] = $documents;
     }
     return $results;
 }
Exemple #6
0
 public static function modified($format = false)
 {
     global $page;
     global $settings;
     $format = $format === false ? $settings['timestamp_format'] : $format;
     return Date::format($page['mod_date_unix'], $format);
 }
Exemple #7
0
 public function isValideByDate($date)
 {
     if ($this->dateDeb->format('Y-m-d') <= $date && $this->dateFin->format('Y-m-d') >= $date) {
         return TRUE;
     }
     return FALSE;
 }
Exemple #8
0
 /**
  * Magic setter
  *
  * @param  string  $key
  * @param  mixed   $value
  */
 public function __set($key, $value)
 {
     switch ($key) {
         // Date of birth
         case 'dob':
             $value = Date::format(Date::DATE_SQL, $value);
             break;
             // Always lowercase e-mail
         // Always lowercase e-mail
         case 'email':
             $value = UTF8::strtolower($value);
             break;
             // Hash password
         // Hash password
         case 'password':
             $visitor = Visitor::instance();
             $value = $visitor->hash_password($value);
             break;
             // Set cleaned username when setting username
         // Set cleaned username when setting username
         case 'username':
             $this->username_clean = Text::clean($value);
             break;
     }
     parent::__set($key, $value);
 }
 function format($format)
 {
     global $prefs;
     // Format the date
     $return = parent::format($format);
     // Translate the date if we are not already in english
     // Divide the date into an array of strings by looking for dates elements (specified in $this->trad)
     $words = preg_split('/(' . implode('|', $this->trad) . ')/', $return, -1, PREG_SPLIT_DELIM_CAPTURE);
     // For each strings in $words array...
     $return = '';
     foreach ($words as $w) {
         if (array_key_exists($w, $this->translated_trad)) {
             // ... we've loaded this previously
             $return .= $this->translated_trad["{$w}"];
         } else {
             if (in_array($w, $this->trad)) {
                 // ... or we have a date element that needs a translation
                 $t = tra($w, '', true);
                 $this->translated_trad["{$w}"] = $t;
                 $return .= $t;
             } else {
                 // ... or we have a string that should not be translated
                 $return .= $w;
             }
         }
     }
     return $return;
 }
Exemple #10
0
 /**
  * Render content.
  *
  * @return  string
  */
 public function content()
 {
     ob_start();
     // Stamp
     echo HTML::time(Date('l ', $this->event->stamp_begin) . Date::format('DDMMYYYY', $this->event->stamp_begin), $this->event->stamp_begin, true);
     // Location
     if ($this->event->venue) {
         echo ' @ ', HTML::anchor(Route::model($this->event->venue), HTML::chars($this->event->venue->name)), ', ', HTML::chars($this->event->venue->city_name);
     } elseif ($this->event->venue_name) {
         echo ' @ ', $this->event->venue_url ? HTML::anchor($this->event->venue_url, $this->event->venue_name) : HTML::chars($this->event->venue_name), $this->event->city_name ? ', ' . HTML::chars($this->event->city_name) : '';
     } elseif ($this->event->city_name) {
         echo ' @ ', HTML::chars($this->event->city_name);
     }
     // Flyer
     if ($flyer = $this->event->flyer()) {
         echo '<figure>', HTML::image($flyer->image_url(Model_Image::SIZE_THUMBNAIL)), '</figure>';
     } elseif ($this->event->flyer_front_url) {
         echo '<figure>', HTML::image($this->event->flyer_front_url, ['class' => 'img-responsive']), '</figure>';
     }
     // Favorites
     if ($this->event->favorite_count) {
         echo '<span class="stats"><i class="fa fa-heart"></i> ' . $this->event->favorite_count . '</span>';
     }
     return ob_get_clean();
 }
Exemple #11
0
 /**
  * Handle an error.
  *
  * @param       int             $errorStatus    Error status code
  * @param       string          $errorMsg       Error message
  * @param       string          $errorFile      Error script file
  * @param       int             $errorLine      Error script line
  * @throws      ApiException                    API exception
  */
 public static function handle($errorStatus, $errorMsg, $errorFile, $errorLine)
 {
     // Build the complete error message
     $mailMsg = '<b>--- Spotzi ErrorHandler ---</b>' . PHP_EOL . PHP_EOL;
     $mailMsg .= 'Date: ' . Date::format() . PHP_EOL;
     $mailMsg .= 'Error status: ' . $errorStatus . PHP_EOL;
     $mailMsg .= 'Error message: ' . $errorMsg . PHP_EOL;
     $mailMsg .= 'Script name: ' . $errorFile . PHP_EOL;
     $mailMsg .= 'Line number: ' . $errorLine . PHP_EOL;
     //$mailMsg .= 'Request referer: ' . REQUEST_REFERER . PHP_EOL;
     //$mailMsg .= 'Request URL: ' . URL_BASE . ltrim(REQUEST_URI, '/') . PHP_EOL;
     if (isset($_SERVER['HTTP_USER_AGENT'])) {
         $mailMsg .= 'User agent: ' . $_SERVER['HTTP_USER_AGENT'];
     }
     // Determine whether debug mode is active
     if (debugMode()) {
         // In case debug mode is active, set the error message as the frontend message
         debugPrint($mailMsg);
     } else {
         // Send the error email when needed
         if (HttpStatus::emailStatus($errorStatus)) {
             // Prepare the error mailer
             Mail::addMailer(EMAIL_HOST, EMAIL_PORT, EMAIL_ERROR_FROM, EMAIL_ERROR_FROM_PASSWORD, BRAND_PRODUCT);
             // Send the error email
             Mail::send(EMAIL_ERROR_RECIPIENT, EMAIL_ERROR_FROM, EMAIL_ERROR_SUBJECT, nl2br($mailMsg));
         }
         throw new ApiException($errorStatus, $errorMsg);
     }
 }
Exemple #12
0
function updateBludit()
{
    global $Site;
    global $dbPosts;
    // Check if Bludit need to be update.
    if ($Site->currentBuild() < BLUDIT_BUILD || isset($_GET['update'])) {
        // --- Update dates ---
        foreach ($dbPosts->db as $key => $post) {
            $date = Date::format($post['date'], 'Y-m-d H:i', DB_DATE_FORMAT);
            if ($date !== false) {
                $dbPosts->setPostDb($key, 'date', $date);
            }
        }
        $dbPosts->save();
        // --- Update directories ---
        $directories = array(PATH_POSTS, PATH_PAGES, PATH_PLUGINS_DATABASES, PATH_UPLOADS_PROFILES, PATH_UPLOADS_THUMBNAILS, PATH_TMP);
        foreach ($directories as $dir) {
            // Check if the directory is already created.
            if (!file_exists($dir)) {
                // Create the directory recursive.
                mkdir($dir, DIR_PERMISSIONS, true);
            }
        }
        // Set and save the database.
        $Site->set(array('currentBuild' => BLUDIT_BUILD));
        Log::set('updateBludit' . LOG_SEP . 'System updated');
    }
}
Exemple #13
0
 public function testSettingDefaultFormat()
 {
     $ts = mktime(12, 30, 0, 7, 4, 1983);
     $date = new Date($ts);
     $date->setFormat('d.m.Y H:i:s');
     return $this->assertEqual($date->format(), '04.07.1983 12:30:00');
 }
 /**
  * Handle an error.
  *
  * @param       int             $errorNo        Error number
  * @param       string          $errorMsg       Error message
  * @param       string          $errorFile      Error script file
  * @param       int             $errorLine      Error script line
  */
 public static function handle($errorNo, $errorMsg, $errorFile, $errorLine)
 {
     // Build the complete error message
     $mailMsg = '<b>--- ' . BRAND_NAME . ' ErrorHandler ---</b>' . PHP_EOL . PHP_EOL;
     $mailMsg .= 'Date: ' . Date::format() . PHP_EOL;
     $mailMsg .= 'Error number: ' . $errorNo . PHP_EOL;
     $mailMsg .= 'Error type: ' . self::$errortypes[$errorNo] . PHP_EOL;
     $mailMsg .= 'Error message: ' . $errorMsg . PHP_EOL;
     $mailMsg .= 'Script name: ' . $errorFile . PHP_EOL;
     $mailMsg .= 'Line number: ' . $errorLine . PHP_EOL;
     $mailMsg .= 'Request URL: ' . URL_BASE . ltrim(REQUEST_URI, '/') . PHP_EOL;
     if (isset($_SERVER['HTTP_USER_AGENT'])) {
         $mailMsg .= 'User agent: ' . $_SERVER['HTTP_USER_AGENT'];
     }
     // Determine whether debug mode is active
     if (debugMode()) {
         // In case debug mode is active, set the error message as the frontend message
         debugPrint($mailMsg);
     } else {
         // Prepare the error mailer
         Mail::addMailer(EMAIL_HOST, EMAIL_PORT, EMAIL_ERROR_FROM, EMAIL_ERROR_FROM_PASSWORD, BRAND_PRODUCT);
         // Send the error email
         Mail::send(EMAIL_ERROR_RECIPIENT, EMAIL_ERROR_FROM, EMAIL_ERROR_SUBJECT, nl2br($mailMsg));
         // In case of a fatal error, stop execution and show the general frontend message
         if ($errorNo !== E_WARNING && $errorNo !== E_NOTICE && $errorNo !== E_USER_NOTICE && $errorNo !== E_STRICT) {
             debugPrint(__('An unexpected error has occured.<br>If this error keeps occuring, please contact your vendor for assistance') . __('<br>Message: %s', $errorMsg));
         }
     }
 }
Exemple #15
0
 public function fetch_headline_value($value, $document_id)
 {
     if (!empty($value)) {
         return Date::format($value, 'j F Y H:i:s');
     }
     return parent::fetch_headline_value($value, $document_id);
 }
Exemple #16
0
 private function createXML()
 {
     global $Site;
     global $dbPages;
     global $dbPosts;
     global $Url;
     $doc = new DOMDocument('1.0', 'UTF-8');
     // Friendly XML code
     $doc->formatOutput = true;
     // Create urlset element
     $urlset = $doc->createElement('urlset');
     $attribute = $doc->createAttribute('xmlns');
     $attribute->value = 'http://www.sitemaps.org/schemas/sitemap/0.9';
     $urlset->appendChild($attribute);
     // --- Base URL ---
     // Create url, loc and lastmod elements
     $url = $doc->createElement('url');
     $loc = $doc->createElement('loc', $Site->url());
     $lastmod = $doc->createElement('lastmod', '');
     // Append loc and lastmod -> url
     $url->appendChild($loc);
     $url->appendChild($lastmod);
     // Append url -> urlset
     $urlset->appendChild($url);
     // --- Pages and Posts ---
     $all = array();
     $url = trim($Site->url(), '/');
     // --- Pages ---
     $filter = trim($Url->filters('page'), '/');
     $pages = $dbPages->getDB();
     unset($pages['error']);
     foreach ($pages as $key => $db) {
         $permalink = empty($filter) ? $url . '/' . $key : $url . '/' . $filter . '/' . $key;
         $date = Date::format($db['date'], DB_DATE_FORMAT, SITEMAP_DATE_FORMAT);
         array_push($all, array('permalink' => $permalink, 'date' => $date));
     }
     // --- Posts ---
     $filter = rtrim($Url->filters('post'), '/');
     $posts = $dbPosts->getDB();
     foreach ($posts as $key => $db) {
         $permalink = empty($filter) ? $url . '/' . $key : $url . '/' . $filter . '/' . $key;
         $date = Date::format($db['date'], DB_DATE_FORMAT, SITEMAP_DATE_FORMAT);
         array_push($all, array('permalink' => $permalink, 'date' => $date));
     }
     // Generate the XML for posts and pages
     foreach ($all as $db) {
         // Create url, loc and lastmod elements
         $url = $doc->createElement('url');
         $loc = $doc->createElement('loc', $db['permalink']);
         $lastmod = $doc->createElement('lastmod', $db['date']);
         // Append loc and lastmod -> url
         $url->appendChild($loc);
         $url->appendChild($lastmod);
         // Append url -> urlset
         $urlset->appendChild($url);
     }
     // Append urlset -> XML
     $doc->appendChild($urlset);
     $doc->save(PATH_PLUGINS_DATABASES . $this->directoryName . DS . 'sitemap.xml');
 }
Exemple #17
0
 /**
  * ฟังก์ชั่นส่งเมล์จากแม่แบบจดหมาย
  *
  * @param int $id ID ของจดหมายที่ต้องการส่ง
  * @param string $module ชื่อโมดูลของจดหมายที่ต้องการส่ง
  * @param array $datas ข้อมูลที่จะถูกแทนที่ลงในจดหมาย ในรูป 'ตัวแปร'=>'ข้อความ'
  * @param string $to ที่อยู่อีเมล์ผู้รับ  คั่นแต่ละรายชื่อด้วย ,
  * @return string สำเร็จคืนค่าว่าง ไม่สำเร็จ คืนค่าข้อความผิดพลาด
  */
 public static function send($id, $module, $datas, $to)
 {
     $model = new static();
     $sql = "SELECT `from_email`,`copy_to`,`subject`,`detail` FROM `" . $model->tableWithPrefix('emailtemplate') . "`";
     $sql .= " WHERE `module`=:module AND `email_id`=:email_id AND `language` IN (:language,'th')";
     $sql .= " LIMIT 1";
     $where = array(':module' => $module, ':email_id' => (int) $id, ':language' => \Language::name());
     $email = $model->db->customQuery($sql, true, $where, $model->cache);
     if (empty($email)) {
         return \Language::get('email template not found');
     } else {
         $email = $email[0];
         // ผู้ส่ง
         $from = empty($email['from_email']) ? self::$cfg->noreply_email : $email['from_email'];
         // ข้อความในอีเมล์
         $replace = array('/%WEBTITLE%/' => strip_tags(self::$cfg->web_title), '/%WEBURL%/' => WEB_URL, '/%ADMINEMAIL%/' => $from, '/%TIME%/' => \Date::format());
         $replace = \Arraytool::replace($replace, $datas);
         \Arraytool::extract($replace, $keys, $values);
         $msg = preg_replace($keys, $values, $email['detail']);
         $subject = preg_replace($keys, $values, $email['subject']);
         $to = explode(',', $to);
         if (!empty($email['copy_to'])) {
             $to[] = $email['copy_to'];
         }
         // ส่งอีเมล์
         return self::custom(implode(',', $to), $from, $subject, $msg);
     }
 }
 private function build_form($user_id)
 {
     $form = new HTMLForm('member-view-profile', '', false);
     $fieldset = new FormFieldsetHTML('profile', $this->lang['profile']);
     $form->add_fieldset($fieldset);
     if (AppContext::get_current_user()->check_level(User::ADMIN_LEVEL)) {
         $link_edit = '<a href="' . UserUrlBuilder::edit_profile($user_id)->rel() . '" title="' . $this->lang['profile.edit'] . '" class="fa fa-edit"></a>';
         $fieldset->add_field(new FormFieldFree('profile_edit', $this->lang['profile.edit'], $link_edit));
     }
     $fieldset->add_field(new FormFieldFree('display_name', $this->lang['display_name'], $this->user_infos['display_name']));
     $fieldset->add_field(new FormFieldFree('level', $this->lang['level'], '<a class="' . UserService::get_level_class($this->user_infos['level']) . '">' . $this->get_level_lang() . '</a>'));
     $fieldset->add_field(new FormFieldFree('groups', $this->lang['groups'], $this->build_groups($this->user_infos['groups'])));
     $registration_date = new Date($this->user_infos['registration_date']);
     $fieldset->add_field(new FormFieldFree('registered_on', $this->lang['registration_date'], $registration_date ? $registration_date->format(Date::FORMAT_DAY_MONTH_YEAR) : ''));
     $fieldset->add_field(new FormFieldFree('nbr_msg', $this->lang['number-messages'], $this->user_infos['posted_msg'] . '<br>' . '<a href="' . UserUrlBuilder::messages($user_id)->rel() . '">' . $this->lang['messages'] . '</a>'));
     $last_connection_date = !empty($this->user_infos['last_connection_date']) ? Date::to_format($this->user_infos['last_connection_date'], Date::FORMAT_DAY_MONTH_YEAR) : LangLoader::get_message('never', 'main');
     $fieldset->add_field(new FormFieldFree('last_connect', $this->lang['last_connection'], $last_connection_date));
     if (AppContext::get_current_user()->check_auth(UserAccountsConfig::load()->get_auth_read_members(), UserAccountsConfig::AUTH_READ_MEMBERS_BIT) && $this->user_infos['show_email']) {
         $link_email = '<a href="mailto:' . $this->user_infos['email'] . '" class="basic-button smaller">Mail</a>';
         $fieldset->add_field(new FormFieldFree('email', $this->lang['email'], $link_email));
     }
     if (!$this->same_user_view_profile($user_id) && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
         $link_mp = '<a href="' . UserUrlBuilder::personnal_message($user_id)->rel() . '" class="basic-button smaller">MP</a>';
         $fieldset->add_field(new FormFieldFree('private_message', $this->lang['private_message'], $link_mp));
     }
     MemberExtendedFieldsService::display_profile_fields($form, $user_id);
     $this->form = $form;
 }
 /**
  * The method to generate a plugin-style report XLS from an already
  * prepared statistics page OA_Admin_Statistics_Common object.
  */
 function export()
 {
     // Prepare the report name
     // Get system navigation
     $oMenu = OA_Admin_Menu::singleton();
     // Get section by pageId
     $oCurrentSection = $oMenu->get($this->oStatsController->pageId);
     if ($oCurrentSection == null) {
         phpAds_Die($GLOBALS['strErrorOccurred'], 'Menu system error: <strong>' . OA_Permission::getAccountType(true) . '::' . htmlspecialchars($ID) . '</strong> not found for the current user');
     }
     // Get name
     $reportName = $oCurrentSection->getName();
     $this->_name = $reportName;
     // Prepare the output writer for generation
     $reportFileName = 'Exported Statistics - ' . $reportName;
     if (!empty($this->oStatsController->aDates['day_begin'])) {
         $oStartDate = new Date($this->oStatsController->aDates['day_begin']);
         $reportFileName .= ' from ' . $oStartDate->format($GLOBALS['date_format']);
     }
     if (!empty($this->oStatsController->aDates['day_end'])) {
         $oEndDate = new Date($this->oStatsController->aDates['day_end']);
         $reportFileName .= ' to ' . $oEndDate->format($GLOBALS['date_format']);
     }
     $reportFileName .= '.xls';
     $this->_oReportWriter->openWithFilename($reportFileName);
     // Get the header and data arrays from the same statistics controllers
     // that prepare stats for the user interface stats pages
     list($aHeaders, $aData) = $this->getHeadersAndDataFromStatsController(null, $this->oStatsController);
     // Add the worksheet
     $name = ucfirst($this->oStatsController->entity) . ' ' . ucfirst($this->oStatsController->breakdown);
     $this->createSubReport($reportName, $aHeaders, $aData);
     // Close the report writer and send the report to the user
     $this->_oReportWriter->closeAndSend();
 }
 /**
 * extend PEAR Date's format() meet to translation needs
 */
 function format($format)
 {
     setlocale(LC_ALL, 'en_AU' . ($locale_char_set ? '.' . $locale_char_set : '.utf8'));
     $output = parent::format($format);
     setlocale(LC_ALL, $AppUI->user_lang);
     return $output;
 }
Exemple #21
0
 /**
  * Render content.
  *
  * @return  string
  */
 public function content()
 {
     ob_start();
     // Cover
     if (Valid::url($this->track->cover)) {
         echo HTML::image($this->track->cover, array('class' => 'cover img-responsive', 'alt' => __('Cover')));
     }
     // Time
     if ($this->track->size_time) {
         echo '<i class="fa fa-fw fa-clock-o"></i> ' . $this->track->size_time . '<br />';
     }
     // Listen count
     if ($this->track->listen_count > 1) {
         echo '<i class="fa fa-fw fa-play"></i> ' . ($this->track->listen_count == 1 ? __(':count play', array(':count' => $this->track->listen_count)) : __(':count plays', array(':count' => $this->track->listen_count))) . '<br />';
     }
     // Tags
     if ($tags = $this->track->tags()) {
         echo '<i class="fa fa-fw fa-music"></i> ' . implode(', ', $tags) . '<br />';
     } elseif (!empty($this->track->music)) {
         echo '<i class="fa fa-fw fa-music"></i> ' . $this->track->music . '<br />';
     }
     // Meta
     echo '<footer class="meta text-muted">';
     echo __('Added :date', array(':date' => HTML::time(Date::format(Date::DMY_SHORT, $this->track->created), $this->track->created)));
     echo '</footer>';
     return ob_get_clean();
 }
Exemple #22
0
    /**
     * Render content.
     *
     * @return  string
     */
    public function content()
    {
        if (!$this->events) {
            return '';
        }
        ob_start();
        ?>

<ul class="list-unstyled">

	<?php 
        foreach ($this->events as $event) {
            ?>
	<li>
		<span title="<?php 
            echo Date::format(Date::DATETIME, $event->stamp_begin) . ($event->stamp_end ? ' - ' . Date::format(Date::TIME, $event->stamp_end) : '');
            ?>
"><?php 
            echo Date::format(Date::DM_PADDED, $event->stamp_begin);
            ?>
</span>
		<?php 
            echo HTML::anchor(Route::model($event), HTML::chars($event->name), array('class' => 'hoverable', 'title' => HTML::chars($event->name)));
            ?>
	</li>
	<?php 
        }
        ?>

</ul>

<?php 
        return ob_get_clean();
    }
Exemple #23
0
 /**
  * Render content.
  *
  * @return  string
  */
 public function content()
 {
     ob_start();
     // Stamp
     echo HTML::time(Date('l ', $this->event->stamp_begin) . Date::format('DDMMYYYY', $this->event->stamp_begin), $this->event->stamp_begin, true);
     // Location
     if ($this->event->venue) {
         echo ' @ ', HTML::anchor(Route::model($this->event->venue), HTML::chars($this->event->venue->name)), ', ', HTML::chars($this->event->venue->city_name);
     } elseif ($this->event->venue_name) {
         echo ' @ ', $this->event->venue_url ? HTML::anchor($this->event->venue_url, $this->event->venue_name) : HTML::chars($this->event->venue_name), $this->event->city_name ? ', ' . HTML::chars($this->event->city_name) : '';
     } elseif ($this->event->city_name) {
         echo ' @ ', HTML::chars($this->event->city_name);
     }
     // Flyer
     if ($this->event->flyer_front) {
         echo '<figure>', HTML::image($this->event->flyer_front->get_url(Model_Image::SIZE_THUMBNAIL)), '</figure>';
     } elseif ($this->event->flyer_back) {
         echo '<figure>', HTML::image($this->event->flyer_back->get_url(Model_Image::SIZE_THUMBNAIL)), '</figure>';
     } elseif (Valid::url($this->event->flyer_front_url)) {
         echo '<br /><figure>', HTML::image($this->event->flyer_front_url, array('width' => 160)), '</figure>';
     }
     // Favorites
     if ($this->event->favorite_count) {
         echo '<span class="stats"><i class="icon-heart"></i> ' . $this->event->favorite_count . '</span>';
     }
     return ob_get_clean();
 }
 protected function _calculatePredictiveDate()
 {
     if ($this->datePredictive->format("Y-m-d H:i:s") <= "1919-07-01 01:59:00" || $this->notime || empty($this->cityInfo)) {
         return;
     }
     // Рассчитываем дату и время с учетом поправки на летнее время
     $this->getDatabase()->setQuery("SELECT * FROM {" . SUMMERTIME_TABLE . "} \n                                            WHERE `date_start` <= '%s'\n                                            AND `date_end` >= '%s'\n                                            AND `name` = '%s'");
     $result = $this->getDatabase()->executeQuery($this->datePredictive->format("Y-m-d H:i:s"), $this->datePredictive->format("Y-m-d H:i:s"), $this->cityInfo['country']);
     if (!$result) {
         $this->_showErrorMessage($this->getDatabase()->getQuery());
     }
     $summerTime = $this->getDatabase()->dbFetchAssoc($result);
     // Рассчитываем Поправку на часовой пояс (в минутах)
     $this->getDatabase()->setQuery("SELECT * FROM {" . ZONES_TABLE . "} \n                                                                        WHERE `line` = %d\n                                                                        AND `date_start` <= '%s'\n                                                                        AND `date_end` >= '%s'");
     $result = $this->getDatabase()->executeQuery($this->cityInfo['num'], $this->datePredictive->format("Y-m-d H:i:s"), $this->datePredictive->format("Y-m-d H:i:s"));
     if (!$result) {
         $this->_showErrorMessage($this->getDatabase()->getQuery());
     }
     $lineInfo = $this->getDatabase()->dbFetchAssoc($result);
     // Модифицируем дату
     if ($summerTime) {
         $this->datePredictive->modify(($summerTime['minussec'] - $summerTime['plussec'] > 0 ? "+" : "-") . abs($summerTime['minussec'] - $summerTime['plussec']) . " seconds");
     }
     if ($lineInfo) {
         $this->datePredictive->modify((-($lineInfo['zone'] * 3600 - $this->cityInfo['r'] * 60) > 0 ? "+" : "-") . abs(-($lineInfo['zone'] * 3600 - $this->cityInfo['r'] * 60)) . " seconds");
     }
 }
Exemple #25
0
 /**
  * 
  * @return array
  */
 public static function formats()
 {
     $dates = array();
     foreach (Kohana::$config->load('global')->get('date_formats', array()) as $format) {
         $dates[$format] = Date::format(time(), $format);
     }
     return $dates;
 }
Exemple #26
0
 public function messages()
 {
     $messages = array();
     foreach ($this->messages as $message) {
         $messages[] = array('created' => Date::format($message->created), 'subject' => $message->subject, 'content' => substr(strip_tags($message->content), 0, 100), 'id' => $message->id, 'read' => $message->read, 'href' => Route::url('message.view', array('id' => $message->id)), 'sender' => array('id' => $message->sender->id, 'username' => $message->sender->username, 'avatar' => $message->sender->avatar(), 'href' => Route::url('user.profile', array('id' => $message->sender->id))));
     }
     return $messages;
 }
Exemple #27
0
 public function dateRaw($format = false)
 {
     $date = $this->getField('dateRaw');
     if ($format) {
         return Date::format($date, DB_DATE_FORMAT, $format);
     }
     return $date;
 }
Exemple #28
0
 public static function time($timestamp, $format = 'short', $classes = '')
 {
     $brick = new Brick('time');
     $brick->datetime = Date::format($timestamp, 'iso');
     $brick->text(Date::format($timestamp, $format));
     $brick->addClass($classes);
     return $brick;
 }
Exemple #29
0
 /**
 * extend PEAR Date's format() meet to translation needs
 */
 function format($format)
 {
     global $AppUI;
     $AppUI->setBaseLocale();
     $output = parent::format($format);
     setlocale(LC_ALL, $AppUI->user_lang);
     return $output;
 }
 public function display_field_profile(MemberExtendedField $member_extended_field)
 {
     $fieldset = $member_extended_field->get_fieldset();
     if ($member_extended_field->get_value()) {
         $date = new Date($member_extended_field->get_value());
         $fieldset->add_field(new FormFieldFree($member_extended_field->get_field_name(), $member_extended_field->get_name(), $date->format(Date::FORMAT_DAY_MONTH_YEAR)));
     }
 }