• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Contao\Date类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Contao\Date的典型用法代码示例。如果您正苦于以下问题:PHP Date类的具体用法?PHP Date怎么用?PHP Date使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var PageModel $objPage */
     global $objPage;
     $arrJumpTo = array();
     $arrNewsletter = array();
     $strRequest = ampersand(\Environment::get('request'), true);
     $objNewsletter = \NewsletterModel::findSentByPids($this->nl_channels);
     if ($objNewsletter !== null) {
         while ($objNewsletter->next()) {
             /** @var NewsletterChannelModel $objTarget */
             if (!($objTarget = $objNewsletter->getRelated('pid')) instanceof NewsletterChannelModel) {
                 continue;
             }
             $jumpTo = intval($objTarget->jumpTo);
             // A jumpTo page is not mandatory for newsletter channels (see #6521) but required for the list module
             if ($jumpTo < 1) {
                 throw new \Exception("Newsletter channels without redirect page cannot be used in a newsletter list");
             }
             $strUrl = $strRequest;
             if (!isset($arrJumpTo[$objTarget->jumpTo])) {
                 if (($objJumpTo = $objTarget->getRelated('jumpTo')) instanceof PageModel) {
                     /** @var PageModel $objJumpTo */
                     $arrJumpTo[$objTarget->jumpTo] = $objJumpTo->getFrontendUrl(\Config::get('useAutoItem') ? '/%s' : '/items/%s');
                 } else {
                     $arrJumpTo[$objTarget->jumpTo] = $strUrl;
                 }
             }
             $strUrl = $arrJumpTo[$objTarget->jumpTo];
             $strAlias = $objNewsletter->alias ?: $objNewsletter->id;
             $arrNewsletter[] = array('subject' => $objNewsletter->subject, 'title' => \StringUtil::stripInsertTags($objNewsletter->subject), 'href' => sprintf($strUrl, $strAlias), 'date' => \Date::parse($objPage->dateFormat, $objNewsletter->date), 'datim' => \Date::parse($objPage->datimFormat, $objNewsletter->date), 'time' => \Date::parse($objPage->timeFormat, $objNewsletter->date), 'channel' => $objNewsletter->pid);
         }
     }
     $this->Template->newsletters = $arrNewsletter;
 }
开发者ID:contao,项目名称:newsletter-bundle,代码行数:38,代码来源:ModuleNewsletterList.php


示例2: determineDateFormat

 /**
  * Obtain the correct date/time string.
  *
  * @return string
  */
 private function determineDateFormat()
 {
     if ($format = trim($this->get('dateformat'))) {
         return $format;
     }
     return Date::getFormatFromRgxp($this->get('timetype'));
 }
开发者ID:metamodels,项目名称:filter_fromto,代码行数:12,代码来源:FromToDate.php


示例3: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     // Create the date object
     try {
         if (\Input::get('month')) {
             $this->Date = new \Date(\Input::get('month'), 'Ym');
         } elseif (\Input::get('day')) {
             $this->Date = new \Date(\Input::get('day'), 'Ymd');
         } else {
             $this->Date = new \Date();
         }
     } catch (\OutOfBoundsException $e) {
         throw new PageNotFoundException('Page not found');
     }
     $time = \Date::floorToMinute();
     // Find the boundaries
     $objMinMax = $this->Database->query("SELECT MIN(startTime) AS dateFrom, MAX(endTime) AS dateTo, MAX(repeatEnd) AS repeatUntil FROM tl_calendar_events WHERE pid IN(" . implode(',', array_map('intval', $this->cal_calendar)) . ")" . (!BE_USER_LOGGED_IN ? " AND (start='' OR start<='{$time}') AND (stop='' OR stop>'" . ($time + 60) . "') AND published='1'" : ""));
     /** @var FrontendTemplate|object $objTemplate */
     $objTemplate = new \FrontendTemplate($this->cal_ctemplate);
     // Store year and month
     $intYear = date('Y', $this->Date->tstamp);
     $intMonth = date('m', $this->Date->tstamp);
     $objTemplate->intYear = $intYear;
     $objTemplate->intMonth = $intMonth;
     // Previous month
     $prevMonth = $intMonth == 1 ? 12 : $intMonth - 1;
     $prevYear = $intMonth == 1 ? $intYear - 1 : $intYear;
     $lblPrevious = $GLOBALS['TL_LANG']['MONTHS'][$prevMonth - 1] . ' ' . $prevYear;
     $intPrevYm = intval($prevYear . str_pad($prevMonth, 2, 0, STR_PAD_LEFT));
     // Only generate a link if there are events (see #4160)
     if ($objMinMax->dateFrom !== null && $intPrevYm >= date('Ym', $objMinMax->dateFrom)) {
         $objTemplate->prevHref = $this->strUrl . '?month=' . $intPrevYm;
         $objTemplate->prevTitle = specialchars($lblPrevious);
         $objTemplate->prevLink = $GLOBALS['TL_LANG']['MSC']['cal_previous'] . ' ' . $lblPrevious;
         $objTemplate->prevLabel = $GLOBALS['TL_LANG']['MSC']['cal_previous'];
     }
     // Current month
     $objTemplate->current = $GLOBALS['TL_LANG']['MONTHS'][date('m', $this->Date->tstamp) - 1] . ' ' . date('Y', $this->Date->tstamp);
     // Next month
     $nextMonth = $intMonth == 12 ? 1 : $intMonth + 1;
     $nextYear = $intMonth == 12 ? $intYear + 1 : $intYear;
     $lblNext = $GLOBALS['TL_LANG']['MONTHS'][$nextMonth - 1] . ' ' . $nextYear;
     $intNextYm = $nextYear . str_pad($nextMonth, 2, 0, STR_PAD_LEFT);
     // Only generate a link if there are events (see #4160)
     if ($objMinMax->dateTo !== null && $intNextYm <= date('Ym', max($objMinMax->dateTo, $objMinMax->repeatUntil))) {
         $objTemplate->nextHref = $this->strUrl . '?month=' . $intNextYm;
         $objTemplate->nextTitle = specialchars($lblNext);
         $objTemplate->nextLink = $lblNext . ' ' . $GLOBALS['TL_LANG']['MSC']['cal_next'];
         $objTemplate->nextLabel = $GLOBALS['TL_LANG']['MSC']['cal_next'];
     }
     // Set the week start day
     if (!$this->cal_startDay) {
         $this->cal_startDay = 0;
     }
     $objTemplate->days = $this->compileDays();
     $objTemplate->weeks = $this->compileWeeks();
     $objTemplate->substr = $GLOBALS['TL_LANG']['MSC']['dayShortLength'];
     $this->Template->calendar = $objTemplate->parse();
 }
开发者ID:burguin,项目名称:test02,代码行数:62,代码来源:ModuleCalendar.php


示例4: formatOptions

 /**
  * @inheritdoc
  *
  * @param CalendarEventsModel   $current
  * @param CalendarEventsModel[] $models
  */
 protected function formatOptions(Model $current, Model\Collection $models)
 {
     $options = [];
     foreach ($models as $model) {
         $options[$model->id] = sprintf('%s [%s]', $model->title, Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $model->startTime));
     }
     return $options;
 }
开发者ID:terminal42,项目名称:contao-changelanguage,代码行数:14,代码来源:CalendarEventsListener.php


示例5: addTypeIcon

 public function addTypeIcon($row, $label, DataContainer $dc, $args = null)
 {
     $args[0] = \Image::getHtml(\Image::get('system/modules/mail_to/assets/mail-open-image.png', 16, 16));
     $objFile = FilesModel::findByUuid($row['folder']);
     $args[2] = $objFile !== null ? $objFile->path : '-';
     $args[5] = Date::parse(Date::getFormatFromRgxp('datim'), $row['lastrun']);
     return $args;
 }
开发者ID:kozi,项目名称:contao-mail_to,代码行数:8,代码来源:tl_mailto.php


示例6: scopeActive

 public function scopeActive(Builder $query)
 {
     $time = Date::floorToMinute();
     return $query->where('disable', '')->where(function (Builder $query) use($time) {
         return $query->where('start', '')->orWhere('start', '<=', $time);
     })->where(function (Builder $query) use($time) {
         return $query->where('stop', '')->orWhere('stop', '>', $time + 60);
     });
 }
开发者ID:fuzzyma,项目名称:contao-eloquent-bundle,代码行数:9,代码来源:ActiveScopeTrait.php


示例7: formatOptions

 /**
  * @inheritdoc
  *
  * @param NewsModel   $current
  * @param NewsModel[] $models
  */
 protected function formatOptions(Model $current, Model\Collection $models)
 {
     $sameDay = $GLOBALS['TL_LANG']['tl_product']['sameDay'];
     $otherDay = $GLOBALS['TL_LANG']['tl_product']['otherDay'];
     $dayBegin = strtotime('0:00', $current->date);
     $options = [$sameDay => [], $otherDay => []];
     foreach ($models as $model) {
         $group = strtotime('0:00', $model->date) === $dayBegin ? $sameDay : $otherDay;
         $options[$group][$model->id] = sprintf('%s (%s) [%s]', $model->title, $model->code, Date::parse($GLOBALS['TL_CONFIG']['dateFormat'], $model->date));
     }
     return $options;
 }
开发者ID:respinar,项目名称:contao-product,代码行数:18,代码来源:ProductListener.php


示例8: scopePublished

 public function scopePublished(Builder $query, $ignoreFePreview = false)
 {
     // mimic behavior of contao models who never apply the pusblished filter when Backenduser is logged in
     if ($ignoreFePreview || BE_USER_LOGGED_IN) {
         return $query;
     }
     $time = Date::floorToMinute();
     return $query->where('published', 1)->where(function (Builder $query) use($time) {
         return $query->where('start', '')->orWhere('start', '<=', $time);
     })->where(function (Builder $query) use($time) {
         return $query->where('stop', '')->orWhere('stop', '>', $time + 60);
     });
 }
开发者ID:fuzzyma,项目名称:contao-eloquent-bundle,代码行数:13,代码来源:PublishedScopeTrait.php


示例9: run

 /**
  * Run the test
  *
  * @param array  $data
  * @param string $table
  *
  * @throws ErrorException
  * @throws WarningException
  */
 public function run(array $data, $table)
 {
     switch ($table) {
         case 'tl_calendar_events':
         case 'tl_news':
             $this->check($data['teaser']);
             break;
         case 'tl_page':
             $time = Date::floorToMinute();
             if ($data['type'] === 'regular' && $data['robots'] !== 'noindex,nofollow' && $data['published'] && (!$data['start'] || $data['start'] <= $time) && (!$data['stop'] || $data['stop'] > $time)) {
                 $this->check($data['description']);
             }
             break;
     }
 }
开发者ID:derhaeuptling,项目名称:contao-seo-serp-preview,代码行数:24,代码来源:DescriptionTest.php


示例10: processCustomDateRegexp

 /**
  * Process a custom date regexp on a widget.
  *
  * @param string $rgxp   The rgxp being evaluated.
  *
  * @param string $value  The value to check.
  *
  * @param Widget $widget The widget to process.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 public static function processCustomDateRegexp($rgxp, $value, $widget)
 {
     if ('MetaModelsFilterRangeDateRgXp' !== $rgxp) {
         return;
     }
     $format = $widget->dateformat;
     if (!preg_match('~^' . Date::getRegexp($format) . '$~i', $value)) {
         $widget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['date'], Date::getInputFormat($format)));
     } else {
         // Validate the date (see https://github.com/contao/core/issues/5086)
         try {
             new Date($value, $format);
         } catch (\OutOfBoundsException $e) {
             $widget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $value));
         }
     }
 }
开发者ID:metamodels,项目名称:filter_fromto,代码行数:31,代码来源:MetaModelsFilterRangeDateRgXp.php


示例11: getSeparatedNumericDateTimeInterval

 public static function getSeparatedNumericDateTimeInterval($intStartDate = null, $intEndDate = null, $intStartTime = null, $intEndTime = null, $strIntervalDelimiter = ' &ndash; ', $strDelimiter = ', ')
 {
     $strStartDate = \Contao\Date::parse(\Contao\Date::getNumericDateFormat(), $intStartDate);
     $strEndDate = \Contao\Date::parse(\Contao\Date::getNumericDateFormat(), $intEndDate);
     $strStartTime = \Contao\Date::parse(\Contao\Date::getNumericTimeFormat(), $intStartTime);
     $strEndTime = \Contao\Date::parse(\Contao\Date::getNumericTimeFormat(), $intEndTime);
     $strResult = $strStartDate;
     if ($intEndDate > 0 && $intEndDate > $intStartDate && $strStartDate != $strEndDate) {
         $strResult .= $strIntervalDelimiter . $strEndDate;
     }
     if ($intStartTime > 0) {
         if ($intEndTime > $intStartTime && $strStartTime != $strEndTime) {
             $strResult .= $strDelimiter . $strStartTime . $strIntervalDelimiter . $strEndTime;
         } else {
             $strResult .= $strDelimiter . $strStartTime;
         }
     }
     return $strResult;
 }
开发者ID:heimrichhannot,项目名称:contao-haste_plus,代码行数:19,代码来源:DateUtil.php


示例12: renderDropdown

    /**
     * Render the versions dropdown menu
     *
     * @return string
     */
    public function renderDropdown()
    {
        $objVersion = $this->Database->prepare("SELECT tstamp, version, username, active FROM tl_version WHERE fromTable=? AND pid=? ORDER BY version DESC")->execute($this->strTable, $this->intPid);
        if ($objVersion->numRows < 2) {
            return '';
        }
        $versions = '';
        while ($objVersion->next()) {
            $versions .= '
  <option value="' . $objVersion->version . '"' . ($objVersion->active ? ' selected="selected"' : '') . '>' . $GLOBALS['TL_LANG']['MSC']['version'] . ' ' . $objVersion->version . ' (' . \Date::parse(\Config::get('datimFormat'), $objVersion->tstamp) . ') ' . $objVersion->username . '</option>';
        }
        return '
<div class="tl_version_panel">

<form action="' . ampersand(\Environment::get('request'), true) . '" id="tl_version" class="tl_form" method="post">
<div class="tl_formbody">
<input type="hidden" name="FORM_SUBMIT" value="tl_version">
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">
<select name="version" class="tl_select">' . $versions . '
</select>
<button type="submit" name="showVersion" id="showVersion" class="tl_submit">' . $GLOBALS['TL_LANG']['MSC']['restore'] . '</button>
<a href="' . \Backend::addToUrl('versions=1&amp;popup=1') . '" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['showDifferences']) . '" onclick="Backend.openModalIframe({\'width\':768,\'title\':\'' . \StringUtil::specialchars(str_replace("'", "\\'", sprintf($GLOBALS['TL_LANG']['MSC']['recordOfTable'], $this->intPid, $this->strTable))) . '\',\'url\':this.href});return false">' . \Image::getHtml('diff.svg') . '</a>
</div>
</form>

</div>
';
    }
开发者ID:bytehead,项目名称:core-bundle,代码行数:33,代码来源:Versions.php


示例13: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     // Show logout form
     if (FE_USER_LOGGED_IN) {
         $this->import('FrontendUser', 'User');
         $this->Template->logout = true;
         $this->Template->formId = 'tl_logout_' . $this->id;
         $this->Template->slabel = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['logout']);
         $this->Template->loggedInAs = sprintf($GLOBALS['TL_LANG']['MSC']['loggedInAs'], $this->User->username);
         $this->Template->action = ampersand(\Environment::get('indexFreeRequest'));
         if ($this->User->lastLogin > 0) {
             /** @var PageModel $objPage */
             global $objPage;
             $this->Template->lastLogin = sprintf($GLOBALS['TL_LANG']['MSC']['lastLogin'][1], \Date::parse($objPage->datimFormat, $this->User->lastLogin));
         }
         return;
     }
     $flashBag = \System::getContainer()->get('session')->getFlashBag();
     if ($flashBag->has($this->strFlashType)) {
         $this->Template->hasError = true;
         $this->Template->message = $flashBag->get($this->strFlashType)[0];
     }
     $this->Template->username = $GLOBALS['TL_LANG']['MSC']['username'];
     $this->Template->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
     $this->Template->action = ampersand(\Environment::get('indexFreeRequest'));
     $this->Template->slabel = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['login']);
     $this->Template->value = \StringUtil::specialchars(\Input::post('username'));
     $this->Template->formId = 'tl_login_' . $this->id;
     $this->Template->autologin = $this->autologin && \Config::get('autologin') > 0;
     $this->Template->autoLabel = $GLOBALS['TL_LANG']['MSC']['autologin'];
 }
开发者ID:contao,项目名称:core-bundle,代码行数:34,代码来源:ModuleLogin.php


示例14: formatValue

 /**
  * Format a value
  *
  * @param string  $k
  * @param mixed   $value
  * @param boolean $blnListSingle
  *
  * @return mixed
  */
 protected function formatValue($k, $value, $blnListSingle = false)
 {
     $value = \StringUtil::deserialize($value);
     // Return if empty
     if (empty($value)) {
         return '';
     }
     /** @var PageModel $objPage */
     global $objPage;
     // Array
     if (is_array($value)) {
         $value = implode(', ', $value);
     } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'date') {
         $value = \Date::parse($objPage->dateFormat, $value);
     } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'time') {
         $value = \Date::parse($objPage->timeFormat, $value);
     } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'datim') {
         $value = \Date::parse($objPage->datimFormat, $value);
     } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'url' && preg_match('@^(https?://|ftp://)@i', $value)) {
         $value = \Idna::decode($value);
         // see #5946
         $value = '<a href="' . $value . '" target="_blank">' . $value . '</a>';
     } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['rgxp'] == 'email') {
         $value = \StringUtil::encodeEmail(\Idna::decode($value));
         // see #5946
         $value = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;' . $value . '">' . $value . '</a>';
     } elseif (is_array($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['reference'])) {
         $value = $GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['reference'][$value];
     } elseif ($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['eval']['isAssociative'] || array_is_assoc($GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['options'])) {
         if ($blnListSingle) {
             $value = $GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['options'][$value];
         } else {
             $value = '<span class="value">[' . $value . ']</span> ' . $GLOBALS['TL_DCA'][$this->list_table]['fields'][$k]['options'][$value];
         }
     }
     return $value;
 }
开发者ID:contao,项目名称:listing-bundle,代码行数:46,代码来源:ModuleListing.php


示例15: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var PageModel $objPage */
     global $objPage;
     $blnClearInput = false;
     $intYear = \Input::get('year');
     $intMonth = \Input::get('month');
     $intDay = \Input::get('day');
     // Jump to the current period
     if (!isset($_GET['year']) && !isset($_GET['month']) && !isset($_GET['day'])) {
         switch ($this->cal_format) {
             case 'cal_year':
                 $intYear = date('Y');
                 break;
             case 'cal_month':
                 $intMonth = date('Ym');
                 break;
             case 'cal_day':
                 $intDay = date('Ymd');
                 break;
         }
         $blnClearInput = true;
     }
     $blnDynamicFormat = !$this->cal_ignoreDynamic && in_array($this->cal_format, array('cal_day', 'cal_month', 'cal_year'));
     // Create the date object
     try {
         if ($blnDynamicFormat && $intYear) {
             $this->Date = new \Date($intYear, 'Y');
             $this->cal_format = 'cal_year';
             $this->headline .= ' ' . date('Y', $this->Date->tstamp);
         } elseif ($blnDynamicFormat && $intMonth) {
             $this->Date = new \Date($intMonth, 'Ym');
             $this->cal_format = 'cal_month';
             $this->headline .= ' ' . \Date::parse('F Y', $this->Date->tstamp);
         } elseif ($blnDynamicFormat && $intDay) {
             $this->Date = new \Date($intDay, 'Ymd');
             $this->cal_format = 'cal_day';
             $this->headline .= ' ' . \Date::parse($objPage->dateFormat, $this->Date->tstamp);
         } else {
             $this->Date = new \Date();
         }
     } catch (\OutOfBoundsException $e) {
         throw new PageNotFoundException('Page not found');
     }
     list($strBegin, $strEnd, $strEmpty) = $this->getDatesFromFormat($this->Date, $this->cal_format);
     // Get all events
     $arrAllEvents = $this->getAllEvents($this->cal_calendar, $strBegin, $strEnd);
     $sort = $this->cal_order == 'descending' ? 'krsort' : 'ksort';
     // Sort the days
     $sort($arrAllEvents);
     // Sort the events
     foreach (array_keys($arrAllEvents) as $key) {
         $sort($arrAllEvents[$key]);
     }
     $arrEvents = array();
     $dateBegin = date('Ymd', $strBegin);
     $dateEnd = date('Ymd', $strEnd);
     // Remove events outside the scope
     foreach ($arrAllEvents as $key => $days) {
         if ($key < $dateBegin || $key > $dateEnd) {
             continue;
         }
         foreach ($days as $day => $events) {
             foreach ($events as $event) {
                 $event['firstDay'] = $GLOBALS['TL_LANG']['DAYS'][date('w', $day)];
                 $event['firstDate'] = \Date::parse($objPage->dateFormat, $day);
                 $arrEvents[] = $event;
             }
         }
     }
     unset($arrAllEvents);
     $total = count($arrEvents);
     $limit = $total;
     $offset = 0;
     // Overall limit
     if ($this->cal_limit > 0) {
         $total = min($this->cal_limit, $total);
         $limit = $total;
     }
     // Pagination
     if ($this->perPage > 0) {
         $id = 'page_e' . $this->id;
         $page = \Input::get($id) !== null ? \Input::get($id) : 1;
         // Do not index or cache the page if the page number is outside the range
         if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) {
             throw new PageNotFoundException('Page not found');
         }
         $offset = ($page - 1) * $this->perPage;
         $limit = min($this->perPage + $offset, $total);
         $objPagination = new \Pagination($total, $this->perPage, \Config::get('maxPaginationLinks'), $id);
         $this->Template->pagination = $objPagination->generate("\n  ");
     }
     $strMonth = '';
     $strDate = '';
     $strEvents = '';
     $dayCount = 0;
     $eventCount = 0;
//.........这里部分代码省略.........
开发者ID:burguin,项目名称:test02,代码行数:101,代码来源:ModuleEventlist.php


示例16: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var PageModel $objPage */
     global $objPage;
     $limit = null;
     $offset = 0;
     $intBegin = 0;
     $intEnd = 0;
     $intYear = \Input::get('year');
     $intMonth = \Input::get('month');
     $intDay = \Input::get('day');
     // Jump to the current period
     if (!isset($_GET['year']) && !isset($_GET['month']) && !isset($_GET['day']) && $this->news_jumpToCurrent != 'all_items') {
         switch ($this->news_format) {
             case 'news_year':
                 $intYear = date('Y');
                 break;
             default:
             case 'news_month':
                 $intMonth = date('Ym');
                 break;
             case 'news_day':
                 $intDay = date('Ymd');
                 break;
         }
     }
     // Create the date object
     try {
         if ($intYear) {
             $strDate = $intYear;
             $objDate = new \Date($strDate, 'Y');
             $intBegin = $objDate->yearBegin;
             $intEnd = $objDate->yearEnd;
             $this->headline .= ' ' . date('Y', $objDate->tstamp);
         } elseif ($intMonth) {
             $strDate = $intMonth;
             $objDate = new \Date($strDate, 'Ym');
             $intBegin = $objDate->monthBegin;
             $intEnd = $objDate->monthEnd;
             $this->headline .= ' ' . \Date::parse('F Y', $objDate->tstamp);
         } elseif ($intDay) {
             $strDate = $intDay;
             $objDate = new \Date($strDate, 'Ymd');
             $intBegin = $objDate->dayBegin;
             $intEnd = $objDate->dayEnd;
             $this->headline .= ' ' . \Date::parse($objPage->dateFormat, $objDate->tstamp);
         } elseif ($this->news_jumpToCurrent == 'all_items') {
             $intBegin = 0;
             $intEnd = time();
         }
     } catch (\OutOfBoundsException $e) {
         throw new PageNotFoundException('Page not found: ' . \Environment::get('uri'));
     }
     $this->Template->articles = array();
     // Split the result
     if ($this->perPage > 0) {
         // Get the total number of items
         $intTotal = \NewsModel::countPublishedFromToByPids($intBegin, $intEnd, $this->news_archives);
         if ($intTotal > 0) {
             $total = $intTotal;
             // Get the current page
             $id = 'page_a' . $this->id;
             $page = \Input::get($id) !== null ? \Input::get($id) : 1;
             // Do not index or cache the page if the page number is outside the range
             if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) {
                 throw new PageNotFoundException('Page not found: ' . \Environment::get('uri'));
             }
             // Set limit and offset
             $limit = $this->perPage;
             $offset = (max($page, 1) - 1) * $this->perPage;
             // Add the pagination menu
             $objPagination = new \Pagination($total, $this->perPage, \Config::get('maxPaginationLinks'), $id);
             $this->Template->pagination = $objPagination->generate("\n  ");
         }
     }
     // Get the news items
     if (isset($limit)) {
         $objArticles = \NewsModel::findPublishedFromToByPids($intBegin, $intEnd, $this->news_archives, $limit, $offset);
     } else {
         $objArticles = \NewsModel::findPublishedFromToByPids($intBegin, $intEnd, $this->news_archives);
     }
     // Add the articles
     if ($objArticles !== null) {
         $this->Template->articles = $this->parseArticles($objArticles);
     }
     $this->Template->headline = trim($this->headline);
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     $this->Template->empty = $GLOBALS['TL_LANG']['MSC']['empty'];
 }
开发者ID:contao,项目名称:news-bundle,代码行数:92,代码来源:ModuleNewsArchive.php


示例17: compileDailyMenu

 /**
  * Generate the dayil menu
  */
 protected function compileDailyMenu()
 {
     $arrData = array();
     $time = \Date::floorToMinute();
     // Get the dates
     $objDates = $this->Database->query("SELECT FROM_UNIXTIME(date, '%Y%m%d') AS day, COUNT(*) AS count FROM tl_news WHERE pid IN(" . implode(',', array_map('intval', $this->news_archives)) . ")" . (!BE_USER_LOGGED_IN || TL_MODE == 'BE' ? " AND (start='' OR start<='{$time}') AND (stop='' OR stop>'" . ($time + 60) . "') AND published='1'" : "") . " GROUP BY day ORDER BY day DESC");
     while ($objDates->next()) {
         $arrData[$objDates->day] = $objDates->count;
     }
     // Sort the data
     krsort($arrData);
     // Create the date object
     try {
         $this->Date = \Input::get('day') ? new \Date(\Input::get('day'), 'Ymd') : new \Date();
     } catch (\OutOfBoundsException $e) {
         throw new PageNotFoundException('Page not found');
     }
     $intYear = date('Y', $this->Date->tstamp);
     $intMonth = date('m', $this->Date->tstamp);
     $this->Template->intYear = $intYear;
     $this->Template->intMonth = $intMonth;
     // Previous month
     $prevMonth = $intMonth == 1 ? 12 : $intMonth - 1;
     $prevYear = $intMonth == 1 ? $intYear - 1 : $intYear;
     $lblPrevious = $GLOBALS['TL_LANG']['MONTHS'][$prevMonth - 1] . ' ' . $prevYear;
     $this->Template->prevHref = $this->strUrl . '?day=' . $prevYear . (strlen($prevMonth) < 2 ? '0' : '') . $prevMonth . '01';
     $this->Template->prevTitle = specialchars($lblPrevious);
     $this->Template->prevLink = $GLOBALS['TL_LANG']['MSC']['news_previous'] . ' ' . $lblPrevious;
     $this->Template->prevLabel = $GLOBALS['TL_LANG']['MSC']['news_previous'];
     // Current month
     $this->Template->current = $GLOBALS['TL_LANG']['MONTHS'][date('m', $this->Date->tstamp) - 1] . ' ' . date('Y', $this->Date->tstamp);
     // Next month
     $nextMonth = $intMonth == 12 ? 1 : $intMonth + 1;
     $nextYear = $intMonth == 12 ? $intYear + 1 : $intYear;
     $lblNext = $GLOBALS['TL_LANG']['MONTHS'][$nextMonth - 1] . ' ' . $nextYear;
     $this->Template->nextHref = $this->strUrl . '?day=' . $nextYear . (strlen($nextMonth) < 2 ? '0' : '') . $nextMonth . '01';
     $this->Template->nextTitle = specialchars($lblNext);
     $this->Template->nextLink = $lblNext . ' ' . $GLOBALS['TL_LANG']['MSC']['news_next'];
     $this->Template->nextLabel = $GLOBALS['TL_LANG']['MSC']['news_next'];
     // Set week start day
     if (!$this->news_startDay) {
         $this->news_startDay = 0;
     }
     $this->Template->daily = true;
     $this->Template->days = $this->compileDays();
     $this->Template->weeks = $this->compileWeeks($arrData);
     $this->Template->showQuantity = $this->news_showQuantity != '' ? true : false;
 }
开发者ID:burguin,项目名称:test02,代码行数:51,代码来源:ModuleNewsMenu.php


示例18: getSearchablePages

 /**
  * Add newsletters to the indexer
  *
  * @param array   $arrPages
  * @param integer $intRoot
  * @param boolean $blnIsSitemap
  *
  * @return array
  */
 public function getSearchablePages($arrPages, $intRoot = 0, $blnIsSitemap = false)
 {
     $arrRoot = array();
     if ($intRoot > 0) {
         $arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page');
     }
     $arrProcessed = array();
     $time = \Date::floorToMinute();
     // Get all channels
     $objNewsletter = \NewsletterChannelModel::findAll();
     // Walk through each channel
     if ($objNewsletter !== null) {
         while ($objNewsletter->next()) {
             if (!$objNewsletter->jumpTo) {
                 continue;
             }
             // Skip channels outside the root nodes
             if (!empty($arrRoot) && !in_array($objNewsletter->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objNewsletter->jumpTo])) {
                 $objParent = \PageModel::findWithDetails($objNewsletter->jumpTo);
                 // The target page does not exist
                 if ($objParent === null) {
                     continue;
                 }
                 // The target page has not been published (see #5520)
                 if (!$objParent->published || $objParent->start != '' && $objParent->start > $time || $objParent->stop != '' && $objParent->stop <= $time + 60) {
                     continue;
                 }
                 // The target page is exempt from the sitemap (see #6418)
                 if ($blnIsSitemap && $objParent->sitemap == 'map_never') {
                     continue;
                 }
                 // Set the domain (see #6421)
                 $domain = ($objParent->rootUseSSL ? 'https://' : 'http://') . ($objParent->domain ?: \Environment::get('host')) . \Environment::get('path') . '/';
                 // Generate the URL
                 $arrProcessed[$objNewsletter->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), \Config::get('useAutoItem') ? '/%s' : '/items/%s', $objParent->language);
             }
             $strUrl = $arrProcessed[$objNewsletter->jumpTo];
             // Get the items
             $objItem = \NewsletterModel::findSentByPid($objNewsletter->id);
             if ($objItem !== null) {
                 while ($objItem->next()) {
                     $arrPages[] = sprintf($strUrl, $objItem->alias ?: $objItem->id);
                 }
             }
         }
     }
     return $arrPages;
 }
开发者ID:burguin,项目名称:test02,代码行数:61,代码来源:Newsletter.php


示例19: setUserFromDb

 /**
  * Set all user properties from a database record
  */
 protected function setUserFromDb()
 {
     $this->intId = $this->id;
     // Unserialize values
     foreach ($this->arrData as $k => $v) {
         if (!is_numeric($v)) {
             $this->{$k} = deserialize($v);
         }
     }
     $GLOBALS['TL_USERNAME'] = $this->username;
     \System::getContainer()->get('request_stack')->getCurrentRequest()->setLocale($this->language);
     \System::getContainer()->get('translator')->setLocale($this->language);
     // Deprecated since Contao 4.0, to be removed in Contao 5.0
     $GLOBALS['TL_LANGUAGE'] = str_replace('_', '-', $this->language);
     \Config::set('showHelp', $this->showHelp);
     \Config::set('useRTE', $this->useRTE);
     \Config::set('useCE', $this->useCE);
     \Config::set('thumbnails', $this->thumbnails);
     \Config::set('backendTheme', $this->backendTheme);
     // Inherit permissions
     $always = array('alexf');
     $depends = array('modules', 'themes', 'pagemounts', 'alpty', 'filemounts', 'fop', 'forms', 'formp', 'imageSizes');
     // HOOK: Take custom permissions
     if (!empty($GLOBALS['TL_PERMISSIONS']) && is_array($GLOBALS['TL_PERMISSIONS'])) {
         $depends = array_merge($depends, $GLOBALS['TL_PERMISSIONS']);
     }
     // Overwrite user permissions if only group permissions shall be inherited
     if ($this->inherit == 'group') {
         foreach ($depends as $field) {
             $this->{$field} = array();
         }
     }
     // Merge permissions
     $inherit = in_array($this->inherit, array('group', 'extend')) ? array_merge($always, $depends) : $always;
     $time = \Date::floorToMinute();
     foreach ((array) $this->groups as $id) {
         $objGroup = $this->Database->prepare("SELECT * FROM tl_user_group WHERE id=? AND disable!='1' AND (start='' OR start<='{$time}') AND (stop='' OR stop>'" . ($time + 60) . "')")->limit(1)->execute($id);
         if ($objGroup->numRows > 0) {
             foreach ($inherit as $field) {
                 $value = deserialize($objGroup->{$field}, true);
                 // The new page/file picker can return integers instead of arrays, so use empty() instead of is_array() and deserialize(true) here
                 if (!empty($value)) {
                     $this->{$field} = array_merge(is_array($this->{$field}) ? $this->{$field} : ($this->{$field} != '' ? array($this->{$field}) : array()), $value);
                     $this->{$field} = array_unique($this->{$field});
                 }
             }
         }
     }
     // Make sure pagemounts and filemounts are set!
     if (!is_array($this->pagemounts)) {
         $this->pagemounts = array();
     } else {
         $this->pagemounts = array_filter($this->pagemounts);
     }
     if (!is_array($this->filemounts)) {
         $this->filemounts = array();
     } else {
         $this->filemounts = array_filter($this->filemounts);
     }
     // Store the numeric file mounts
     $this->arrFilemountIds = $this->filemounts;
     // Convert the file mounts into paths
     if (!$this->isAdmin && !empty($this->filemounts)) {
         $objFiles = \FilesModel::findMultipleByUuids($this->filemounts);
         if ($objFiles !== null) {
             $this->filemounts = $objFiles->fetchEach('path');
         }
     }
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:72,代码来源:BackendUser.php


示例20: loadDetails

 /**
  * Get the details of a page including inherited parameters
  *
  * @return PageModel The page model
  *
  * @throws NoRootPageFoundException If no root page is found
  */
 public function loadDetails()
 {
     // Loaded already
     if ($this->blnDetailsLoaded) {
         return $this;
     }
     // Set some default values
     $this->protected = (bool) $this->protected;
     $this->groups = $this->protected ? \StringUtil::deserialize($this->groups) : false;
     $this->layout = $this->includeLayout ? $this->layout : false;
     $this->mobileLayout = $this->includeLayout ? $this->mobileLayout : false;
     $this->cache = $this->includeCache ? $this->cache : false;
     $pid = $this->pid;
     $type = $this->type;
     $alias = $this->alias;
     $name = $this->title;
     $title = $this->pageTitle ?: $this->title;
     $folderUrl = '';
     $palias = '';
     $pname = '';
     $ptitle = '';
     $trail = array($this->id, $pid);
     // Inherit the settings
     if ($this->type == 'root') {
         $objParentPage = $this;
         // see #4610
     } else {
         // Load all parent pages
         $objParentPage = \PageModel::findParentsById($pid);
         if ($objParentPage !== null) {
             while ($pid > 0 && $type != 'root' && $objParentPage->next()) {
                 $pid = $objParentPage->pid;
                 $type = $objParentPage->type;
                 // Parent title
                 if ($ptitle == '') {
                     $palias = $objParentPage->alias;
                     $pname = $obj 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Contao\Environment类代码示例发布时间:2022-05-23
下一篇:
PHP Contao\Config类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap