예제 #1
0
 public static function fetchFromParameters($params)
 {
     $roomPricePlan = new RoomPricePlan();
     if (isset($params['id']) && is_numeric($params['id'])) {
         $roomPricePlan->id = intval($params['id']);
     }
     if (isset($params['room_id'])) {
         $roomPricePlan->roomId = intval($params['room_id']);
     }
     if (isset($params['start_date'])) {
         $roomPricePlan->startDate = Date::parse($params['start_date']);
     }
     if (isset($params['end_date'])) {
         $roomPricePlan->endDate = Date::parse($params['end_date']);
     }
     if (isset($params['price'])) {
         $roomPricePlan->price = floatval($params['price']);
     }
     if (isset($params['extrabed'])) {
         $roomPricePlan->extraBedPrice = floatval($params['extrabed']);
     }
     if (isset($params['default_plan'])) {
         $roomPricePlan->isDefault = intval($params['default_plan']) == 1;
     }
     return $roomPricePlan;
 }
 protected function parseCity($objAirQualityCity, $blnAddArchive = false, $strClass = '', $intCount = 0)
 {
     /** @var \PageModel $objPage */
     global $objPage;
     $objTemplate->setData($objAirQualityCity->row());
     $this->Template->date = \Date::parse('l j F');
 }
예제 #3
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $arrJumpTo = array();
     $arrNewsletter = array();
     $strRequest = ampersand(\Environment::get('request'), true);
     $objNewsletter = \NewsletterModel::findSentByPids($this->nl_channels);
     if ($objNewsletter !== null) {
         while ($objNewsletter->next()) {
             if (($objTarget = $objNewsletter->getRelated('pid')) === null) {
                 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])) {
                 $objJumpTo = $objTarget->getRelated('jumpTo')->loadDetails();
                 if ($objJumpTo !== null) {
                     $arrJumpTo[$objTarget->jumpTo] = $this->generateFrontendUrl($objJumpTo->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s');
                 } else {
                     $arrJumpTo[$objTarget->jumpTo] = $strUrl;
                 }
             }
             $strUrl = $arrJumpTo[$objTarget->jumpTo];
             $strAlias = $objNewsletter->alias != '' && !\Config::get('disableAlias') ? $objNewsletter->alias : $objNewsletter->id;
             $arrNewsletter[] = array('subject' => $objNewsletter->subject, 'title' => strip_insert_tags($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->channel);
         }
     }
     $this->Template->newsletters = $arrNewsletter;
 }
 /**
  * Return the meta fields of a news article as array
  * @param object
  * @return array
  */
 public static function getMetaFields($objModule, $objArticle)
 {
     $meta = deserialize($objModule->news_metaFields);
     if (!is_array($meta)) {
         return array();
     }
     global $objPage;
     $return = array();
     foreach ($meta as $field) {
         switch ($field) {
             case 'date':
                 $return['date'] = \Date::parse($objPage->datimFormat, $objArticle->date);
                 break;
             case 'author':
                 if (($objAuthor = $objArticle->getRelated('author')) !== null) {
                     if ($objAuthor->google != '') {
                         $return['author'] = $GLOBALS['TL_LANG']['MSC']['by'] . ' <a href="https://plus.google.com/' . $objAuthor->google . '" rel="author" target="_blank">' . $objAuthor->name . '</a>';
                     } else {
                         $return['author'] = $GLOBALS['TL_LANG']['MSC']['by'] . ' ' . $objAuthor->name;
                     }
                 }
                 break;
             case 'comments':
                 if ($objArticle->noComments || $objArticle->source != 'default') {
                     break;
                 }
                 $intTotal = \CommentsModel::countPublishedBySourceAndParent('tl_news', $objArticle->id);
                 $return['ccount'] = $intTotal;
                 $return['comments'] = sprintf($GLOBALS['TL_LANG']['MSC']['commentCount'], $intTotal);
                 break;
         }
     }
     return $return;
 }
예제 #5
0
 public function addSystemMessages()
 {
     $objUser = \BackendUser::getInstance();
     if ($GLOBALS['TL_CONFIG']['be_changelog_src'] == '') {
         return '';
     }
     $strFile = file_get_contents($GLOBALS['TL_CONFIG']['be_changelog_src']);
     if ($strFile == '') {
         return '';
     }
     $objJson = json_decode($strFile);
     $objTemplate = new \BackendTemplate('be_changelog');
     $objTemplate->strTitle = 'Changelog';
     $arrEntries = array();
     foreach ($objJson as $objEntry) {
         $objTemplateEntry = new \BackendTemplate('be_changelog_entry');
         $objTemplateEntry->strCssClass = $objUser->lastLogin > $objEntry->timestamp ? '' : ' tl_info';
         $objTemplateEntry->strDate = \Date::parse(\Config::get('datimFormat'), $objEntry->timestamp);
         $objTemplateEntry->strVersion = $objEntry->version;
         $objTemplateEntry->strEntries = '<li style="padding-bottom: 5px;">' . implode('</li><li style="padding-bottom: 5px;">', $objEntry->entries) . '</li>';
         $arrEntries[$objEntry->timestamp] = $objTemplateEntry->parse();
     }
     krsort($arrEntries);
     $objTemplate->strEntries = implode('', $arrEntries);
     return $objTemplate->parse();
 }
예제 #6
0
 /**
  * Compile the current element
  */
 protected function compile()
 {
     $arrResult = array();
     foreach ($this->arrLog as $key => $data) {
         $tstamp = \Date::parse("Y-m-d", $data['tstamp']);
         if (!isset($arrResult[$tstamp])) {
             $arrResult[$tstamp] = $this->arrAction;
         }
         $arrResult[$tstamp]['date'] = $tstamp;
         $arrResult[$tstamp]['tstamp'] = $data['tstamp'];
         $arrResult[$tstamp][strtolower($data['action'])] += 1;
     }
     $arrData = array();
     foreach ($arrResult as $value) {
         $arrData[] = $value;
     }
     $arrAction = array_keys($this->arrAction);
     $arrColor = $this->getColorArray($arrAction);
     $arrLabels = $arrAction;
     $arrLabels = array_map("ucfirst", $arrLabels);
     $this->Template->inputAction = $arrAction;
     $this->Template->inputLabel = $arrLabels;
     $this->Template->inputLabelColor = $arrColor;
     $this->Template->data = json_encode($arrData);
     $this->Template->yKeys = "['" . implode("','", $arrAction) . "']";
     $this->Template->labels = "['" . implode("','", $arrLabels) . "']";
     $this->Template->lineColors = "['" . implode("','", $arrColor) . "']";
     $this->Template->xKey = "date";
     $this->Template->headline = $GLOBALS['TL_LANG']['MOD']['log'][0];
 }
    /**
     * Add the type of input field
     * @param array
     * @return string
     */
    public function listNewsletterArticles($arrRow)
    {
        $strStats = '';
        $strContents = '';
        $objContents = \ContentModel::findPublishedByPidAndTable($arrRow['id'], 'tl_newsletter');
        if (!is_null($objContents)) {
            foreach ($objContents as $objContent) {
                $strContents .= $this->getContentElement($objContent->id) . '<hr>';
            }
        }
        $intTotal = $arrRow['recipients'] + $arrRow['rejected'];
        //		$intTracked = NewsletterContent\Models\NewsletterTrackingModel::countTrackedByPid($arrRow['id']);
        $objTracked = NewsletterContent\Models\NewsletterTrackingModel::findTrackedInteractionsByPid($arrRow['id']);
        $intTracked = !is_null($objTracked) ? $objTracked->count() : 0;
        $intPercent = @round($intTracked / $intTotal * 100);
        $strStats = sprintf($GLOBALS['TL_LANG']['tl_newsletter']['sentTo'], $arrRow['recipients'], strval($intTotal), strval($intTracked), strval($intPercent));
        return '
<div class="cte_type ' . ($arrRow['sent'] && $arrRow['date'] ? 'published' : 'unpublished') . '"><strong>' . $arrRow['subject'] . '</strong> - ' . ($arrRow['sent'] && $arrRow['date'] ? sprintf($GLOBALS['TL_LANG']['tl_newsletter']['sentOn'], Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $arrRow['date'])) . '<br>' . $strStats : $GLOBALS['TL_LANG']['tl_newsletter']['notSent']) . '</div>
<div class="limit_height' . (!$GLOBALS['TL_CONFIG']['doNotCollapse'] ? ' h128' : '') . '">
' . (!$arrRow['sendText'] && strlen($strContents) ? '
' . $strContents : '') . '
' . nl2br_html5($arrRow['text']) . '
</div>' . "\n";
        return '<div class="tl_content_left">' . $arrRow['subject'] . ' <span style="color:#b3b3b3;padding-left:3px">[' . $arrRow['senderName'] . ' &lt;' . $arrRow['sender'] . '&gt;]</span></div>';
    }
예제 #8
0
 /**
  * Get the label for a form value to store in lead table.
  *
  * @param mixed $varValue
  * @param \Database\Result $objField
  *
  * @return mixed
  */
 public static function prepareLabel($varValue, $objField)
 {
     // Run for all values in an array
     if (is_array($varValue)) {
         foreach ($varValue as $k => $v) {
             $varValue[$k] = self::prepareLabel($v, $objField);
         }
         return $varValue;
     }
     // File upload
     if ($objField->type == 'upload') {
         $objFile = \FilesModel::findByUuid($varValue);
         if ($objFile !== null) {
             return $objFile->path;
         }
     }
     // Convert timestamps into date format
     if ($varValue != '' && in_array($objField->rgxp, array('date', 'time', 'datim'))) {
         $varValue = \Date::parse($GLOBALS['TL_CONFIG'][$objField->rgxp . 'Format'], $varValue);
     }
     if ($objField->options != '') {
         $arrOptions = deserialize($objField->options, true);
         foreach ($arrOptions as $arrOption) {
             if ($arrOption['value'] == $varValue && $arrOption['label'] != '') {
                 $varValue = $arrOption['label'];
             }
         }
     }
     return $varValue;
 }
 private function formatsByConfigFormat($format)
 {
     $const = get_called_class() . '::' . strtoupper($format) . '_FORMAT';
     $tstamp = time();
     $expected = \Date::parse(constant($const), $tstamp);
     $definition['eval']['rgxp'] = $format;
     $this->format($tstamp, $format, $definition)->shouldReturn($expected);
 }
예제 #10
0
 /**
  * Return the date of the last login
  *
  * @return string
  */
 public function lastLogin()
 {
     $this->import('BackendUser', 'User');
     if ($this->User->lastLogin > 0) {
         return '<p class="tl_info">' . sprintf($GLOBALS['TL_LANG']['MSC']['lastLogin'][1], \Date::parse(\Config::get('datimFormat'), $this->User->lastLogin)) . '</p>';
     }
     return '';
 }
예제 #11
0
 public static function transform($varValue, $strField, $arrParams, \HeimrichHannot\Submissions\SubmissionModel $objSubmission)
 {
     switch ($arrParams[0]) {
         case 'date':
             $varValue = \Date::parse($arrParams[1], $varValue);
             break;
     }
     return $varValue;
 }
예제 #12
0
 public static function fetchFromParameters($params, $isDatabaseRow = false)
 {
     NewsPost::$staticErrors = array();
     $newsPost = new NewsPost();
     if (isset($params['id']) && is_numeric($params['id'])) {
         $newsPost->id = intval($params['id']);
     }
     if (isset($params['category_id']) && is_numeric($params['category_id'])) {
         $newsPost->categoryId = intval($params['category_id']);
     }
     $newsPost->title = LocalizedText::fetchFromParameters($params, NewsPost::$titlePrefix);
     $newsPost->contents = LocalizedText::fetchFromParameters($params, NewsPost::$contentsPrefix);
     if ($isDatabaseRow && isset($params['image_small'])) {
         $newsPost->imageSmall = $params['image_small'];
     } else {
         if (!$isDatabaseRow && isset($_FILES['image_small']['name']) && trim($_FILES['image_small']['name']) != "") {
             $imageName = NULL;
             if (!UploadImage::upload($_FILES, "image_small", "../images", $imageName)) {
                 NewsPost::$staticErrors = UploadImage::$errors;
                 return null;
             }
             $newsPost->imageSmall = $imageName;
         }
     }
     if ($isDatabaseRow && isset($params['image_medium'])) {
         $newsPost->imageMedium = $params['image_medium'];
     } else {
         if (!$isDatabaseRow && isset($_FILES['image_medium']['name']) && trim($_FILES['image_medium']['name']) != "") {
             $imageName = NULL;
             if (!UploadImage::upload($_FILES, "image_medium", "../images", $imageName)) {
                 NewsPost::$staticErrors = UploadImage::$errors;
                 return null;
             }
             $newsPost->imageMedium = $imageName;
         }
     }
     if ($isDatabaseRow && isset($params['image_large'])) {
         $newsPost->imageLarge = $params['image_large'];
     } else {
         if (!$isDatabaseRow && isset($_FILES['image_large']['name']) && trim($_FILES['image_large']['name']) != "") {
             $imageName = NULL;
             if (!UploadImage::upload($_FILES, "image_large", "../images", $imageName)) {
                 NewsPost::$staticErrors = UploadImage::$errors;
                 return null;
             }
             $newsPost->imageLarge = $imageName;
         }
     }
     if (isset($params['poster_name'])) {
         $newsPost->posterName = trim($params['poster_name']);
     }
     if (isset($params['date_posted'])) {
         $newsPost->postedDate = Date::parse(trim($params['date_posted']));
     }
     return $newsPost;
 }
예제 #13
0
 /**
  * {@inheritDoc}
  */
 public function format($value, $fieldName, array $fieldDefinition, $context = null)
 {
     if (empty($fieldDefinition['eval']['rgxp'])) {
         $format = 'datim';
     } else {
         $format = $fieldDefinition['eval']['rgxp'];
     }
     $dateFormat = $this->config->get($format . 'Format');
     return \Date::parse($dateFormat, $value);
 }
 public function listChildren($arrRow)
 {
     $strTitle = $arrRow['id'];
     if (($objSubmission = \HeimrichHannot\Submissions\SubmissionModel::findByPk($arrRow['id'])) !== null && ($objSubmissionArchive = $objSubmission->getRelated('pid')) !== null) {
         $strTitle = preg_replace_callback('@%([^%]+)%@i', function ($arrMatches) use($objSubmission) {
             return $objSubmission->{$arrMatches[1]};
         }, $objSubmissionArchive->titlePattern);
     }
     return '<div class="tl_content_left">' . $strTitle . ' <span style="color:#b3b3b3; padding-left:3px">[' . \Date::parse(\Config::get('datimFormat'), trim($arrRow['dateAdded'])) . ']</span></div>';
 }
예제 #15
0
    /**
     * Add the type of input field
     *
     * @param array $arrRow
     *
     * @return string
     */
    public function listQuestions($arrRow)
    {
        $key = $arrRow['published'] ? 'published' : 'unpublished';
        $date = Date::parse(Config::get('datimFormat'), $arrRow['tstamp']);
        return '
<div class="cte_type ' . $key . '"><strong>' . $arrRow['question'] . '</strong> - ' . $date . '</div>
<div class="limit_height' . (!Config::get('doNotCollapse') ? ' h52' : '') . '">
' . StringUtil::insertTagToSrc($arrRow['answer']) . '
</div>' . "\n";
    }
 public function modifyDC()
 {
     // adjust start date
     $this->dca['fields']['startDate']['eval']['mandatory'] = false;
     $this->dca['fields']['startDate']['eval']['placeholder'] =& $GLOBALS['TL_LANG']['eventfilter']['startDatePlaceholder'];
     $this->dca['fields']['startDate']['eval']['autocomplete'] = false;
     $this->dca['fields']['startDate']['eval']['linkedEnd'] = '#ctrl_endDate';
     $this->dca['fields']['startDate']['eval']['linkedUnlock'] = 'true';
     $this->dca['fields']['startDate']['eval']['data-toggle'] = 'tooltip';
     $this->dca['fields']['startDate']['eval']['minDate'] = \Date::parse(\Config::get('dateFormat'), time());
     // adjust end date
     $this->dca['fields']['endDate']['eval']['mandatory'] = false;
     $this->dca['fields']['endDate']['eval']['placeholder'] =& $GLOBALS['TL_LANG']['eventfilter']['endDatePlaceholder'];
     $this->dca['fields']['endDate']['eval']['autocomplete'] = false;
     $this->dca['fields']['endDate']['eval']['linkedStart'] = '#ctrl_startDate';
     $this->dca['fields']['endDate']['eval']['linkedUnlock'] = 'true';
     $this->dca['fields']['endDate']['eval']['data-toggle'] = 'tooltip';
     // adjust promoter field
     $this->dca['fields']['promoter']['options_callback'] = array('HeimrichHannot\\CalendarPlus\\EventFilterHelper', 'getPromoterSelectOptions');
     unset($this->dca['fields']['promoter']['eval']['chosen']);
     $this->dca['fields']['promoter']['eval']['includeBlankOption'] = true;
     $this->dca['fields']['promoter']['eval']['blankOptionLabel'] =& $GLOBALS['TL_LANG']['eventfilter']['promoterBlankOptionLabel'];
     // adjust city field
     $this->dca['fields']['city']['inputType'] = 'select';
     $this->dca['fields']['city']['options_callback'] = array('HeimrichHannot\\CalendarPlus\\EventFilterHelper', 'getCitySelectOptions');
     $this->dca['fields']['city']['eval']['includeBlankOption'] = true;
     $this->dca['fields']['city']['eval']['blankOptionLabel'] =& $GLOBALS['TL_LANG']['eventfilter']['cityBlankOptionLabel'];
     // adjust eventtypes field
     $this->dca['fields']['eventtypes']['options_callback'] = array('HeimrichHannot\\CalendarPlus\\EventFilterHelper', 'getEventTypesFieldsByArchive');
     unset($this->dca['fields']['eventtypes']['eval']['chosen']);
     $this->dca['fields']['eventtypes']['eval']['multiple'] = false;
     $this->dca['fields']['eventtypes']['eval']['includeBlankOption'] = true;
     $this->dca['fields']['eventtypes']['eval']['blankOptionLabel'] =& $GLOBALS['TL_LANG']['eventfilter']['eventTypesBlankOptionLabel'];
     // adjust docents field
     if ($this->objModule->cal_docent_combine) {
         $this->dca['fields']['docents']['options_callback'] = array('HeimrichHannot\\CalendarPlus\\EventFilterHelper', 'getCombinedHostsAndDocentsSelectOptions');
     } else {
         $this->dca['fields']['docents']['options_callback'] = array('HeimrichHannot\\CalendarPlus\\EventFilterHelper', 'getDocentSelectOptions');
     }
     unset($this->dca['fields']['docents']['eval']['chosen']);
     unset($this->dca['fields']['docents']['eval']['style']);
     $this->dca['fields']['docents']['eval']['multiple'] = false;
     $this->dca['fields']['docents']['eval']['includeBlankOption'] = true;
     $this->dca['fields']['docents']['eval']['blankOptionLabel'] =& $GLOBALS['TL_LANG']['eventfilter']['docentsBlankOptionLabel'];
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['loadDCEventFilterForm']) && is_array($GLOBALS['TL_HOOKS']['loadDCEventFilterForm'])) {
         foreach ($GLOBALS['TL_HOOKS']['loadDCEventFilterForm'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($this->dca);
         }
     }
     return true;
 }
 protected function compile()
 {
     $arrContent = array();
     $objContent = $this->Database->prepare("SELECT * FROM tl_content WHERE tstamp > ? && outSide_log = ? && invisible = ? ORDER BY tstamp DESC")->execute($this->Member->lastLogin, '', '');
     while ($objContent->next()) {
         $arrItem = $objContent->row();
         if ($objContent->type == 'module') {
             $objModule = \ModuleModel::findById($objContent->module);
         }
         if ($objContent->type != 'module' or $objContent->type == 'module' && $objModule->type != 'content_log') {
             $arrItem['htmlElement'] = $this->getContentElement($objContent->id);
             foreach ($GLOBALS['TL_HOOKS']['contentLog'] as $callback) {
                 $this->import($callback[0]);
                 $arrItem = $this->{$callback}[0]->{$callback}[1]($objContent->ptable, $objContent->tstamp, $arrItem);
             }
             if ($mod++ % 2 == 0) {
                 $arrItem['css'] .= 'even';
             } else {
                 $arrItem['css'] .= 'odd';
             }
             $arrItem['headline'] = deserialize($arrItem['headline']);
             $arrItem['parseDate'] = '<time datetime="' . date('Y-m-d\\TH:i:sP', $arrItem['tstamp']) . '">' . \Date::parse($GLOBALS['objPage']->datimFormat, $arrItem['tstamp']) . '</time>';
             $arrContent[] = (object) $arrItem;
         }
     }
     $objFAQ = $this->Database->prepare("SELECT * FROM tl_faq WHERE tstamp > ? && published = ? ORDER BY tstamp DESC")->execute($this->Member->lastLogin, '1');
     while ($objFAQ->next()) {
         $arrItem = $objFAQ->row();
         foreach ($GLOBALS['TL_HOOKS']['contentLog'] as $callback) {
             $this->import($callback[0]);
             $arrItem = $this->{$callback}[0]->{$callback}[1]('tl_faq', $objFAQ->tstamp, $arrItem);
         }
         if ($mod++ % 2 == 0) {
             $arrItem['css'] .= 'even';
         } else {
             $arrItem['css'] .= 'odd';
         }
         $arrItem['parseDate'] = '<time datetime="' . date('Y-m-d\\TH:i:sP', $arrItem['tstamp']) . '">' . \Date::parse($GLOBALS['objPage']->datimFormat, $arrItem['tstamp']) . '</time>';
         $arrContent[] = (object) $arrItem;
     }
     $arrContent[0]->css .= ' first';
     $arrContent[count($arrContent) - 1]->css .= ' last';
     foreach ($arrContent as $v) {
         $objTemplate = new \FrontendTemplate($this->contentLogTpl);
         $objTemplate->setData((array) $v);
         $html .= $objTemplate->parse();
     }
     if ($this->contentLogTpl == 'cl_list') {
         $html = '<table>' . $html . '</table>';
     }
     $this->Template->html = $html;
 }
예제 #18
0
    /**
     * Add the type of input field
     * @param array
     * @return string
     */
    public function listSongs($arrRow)
    {
        $key = $arrRow['published'] ? 'published' : 'unpublished';
        $date = Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $arrRow['tstamp']);
        return '
<div class="cte_type ' . $key . '">' . $date . '</div>
<div class="limit_height' . (!$GLOBALS['TL_CONFIG']['doNotCollapse'] ? ' h52' : '') . '">
<strong>' . $GLOBALS['TL_LANG']['tl_audiomax_song']['title'][0] . ': </strong>' . $arrRow['title'] . '<br>
' . (!empty($arrRow['interpreter']) ? '<strong>' . $GLOBALS['TL_LANG']['tl_audiomax_song']['interpreter'][0] . ': </strong>' . $arrRow['interpreter'] . '<br>' : '') . '
' . (!empty($arrRow['album']) ? '<strong>' . $GLOBALS['TL_LANG']['tl_audiomax_song']['album'][0] . ': </strong>' . $arrRow['album'] . '<br>' : '') . '
' . (!empty($arrRow['track']) ? '<strong>' . $GLOBALS['TL_LANG']['tl_audiomax_song']['track'][0] . ': </strong>' . $arrRow['track'] . '<br>' : '') . '
</div>' . "\n";
    }
예제 #19
0
 /**
  * Generate label for this record.
  *
  * @param array
  * @param string
  *
  * @return string
  */
 public function getLabel($row, $label)
 {
     $objForm = \FormModel::findById($row['master_id']);
     if ($objForm != null && $objForm->encryptLeadsData) {
         $arrTokens = array('created' => \Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $row['created']));
         $objData = \Database::getInstance()->prepare("SELECT * FROM tl_lead_data WHERE pid=?")->execute($row['id']);
         while ($objData->next()) {
             Haste\Util\StringUtil::flatten(deserialize(\Encryption::decrypt($objData->value)), $objData->name, $arrTokens);
         }
         return \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($objForm->leadLabel, $arrTokens);
     }
     return parent::getLabel($row, $label);
 }
 /**
  * Generate item label and return it as HTML string
  * @param object
  * @param string
  * @param object
  * @param string
  * @param mixed
  * @return string
  */
 public static function generateItemLabel($objItem, $strForeignTable, $objDca = null, $strTitleField = '', $varCallback = null)
 {
     $args = array();
     $label = '';
     $blnSimple = false;
     $showFields = $GLOBALS['TL_DCA'][$strForeignTable]['list']['label']['fields'];
     // Generate simple label, e.g. for breadcrumb
     if ($strTitleField != '') {
         $blnSimple = true;
         $showFields['titleField'] = $strTitleField;
     }
     foreach ($showFields as $k => $v) {
         // Decrypt the value
         if ($GLOBALS['TL_DCA'][$strForeignTable]['fields'][$v]['eval']['encrypt']) {
             $objItem->{$v} = \Encryption::decrypt(deserialize($objItem->{$v}));
         }
         if (strpos($v, ':') !== false) {
             list($strKey, $strTable) = explode(':', $v);
             list($strTable, $strField) = explode('.', $strTable);
             $objRef = \Database::getInstance()->prepare("SELECT " . $strField . " FROM " . $strTable . " WHERE id=?")->limit(1)->execute($objItem->{$strKey});
             $args[$k] = $objRef->numRows ? $objRef->{$strField} : '';
         } elseif (in_array($GLOBALS['TL_DCA'][$strForeignTable]['fields'][$v]['flag'], array(5, 6, 7, 8, 9, 10))) {
             $args[$k] = \Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $objItem->{$v});
         } elseif ($GLOBALS['TL_DCA'][$strForeignTable]['fields'][$v]['inputType'] == 'checkbox' && !$GLOBALS['TL_DCA'][$strForeignTable]['fields'][$v]['eval']['multiple']) {
             $args[$k] = $objItem->{$v} != '' ? isset($GLOBALS['TL_DCA'][$strForeignTable]['fields'][$v]['label'][0]) ? $GLOBALS['TL_DCA'][$strForeignTable]['fields'][$v]['label'][0] : $v : '';
         } else {
             $args[$k] = $GLOBALS['TL_DCA'][$strForeignTable]['fields'][$v]['reference'][$objItem->{$v}] ?: $objItem->{$v};
         }
     }
     $label = vsprintf(strlen($GLOBALS['TL_DCA'][$strForeignTable]['list']['label']['format']) ? $GLOBALS['TL_DCA'][$strForeignTable]['list']['label']['format'] : '%s', $args);
     // Shorten the label if it is too long
     if ($GLOBALS['TL_DCA'][$strForeignTable]['list']['label']['maxCharacters'] > 0 && $GLOBALS['TL_DCA'][$strForeignTable]['list']['label']['maxCharacters'] < utf8_strlen(strip_tags($label))) {
         $label = trim(\String::substrHtml($label, $GLOBALS['TL_DCA'][$strForeignTable]['list']['label']['maxCharacters'])) . ' …';
     }
     $label = preg_replace('/\\(\\) ?|\\[\\] ?|\\{\\} ?|<> ?/', '', $label);
     // Use the default callback if none provided
     if ($varCallback === null) {
         $varCallback = $GLOBALS['TL_DCA'][$strForeignTable]['list']['label']['label_callback'];
     }
     // Call the label_callback ($row, $label, $this)
     if (is_array($varCallback)) {
         $strClass = $varCallback[0];
         $strMethod = $varCallback[1];
         $label = \System::importStatic($strClass)->{$strMethod}($objItem->row(), $label, $objDca, '', $blnSimple, false);
     } elseif (is_callable($varCallback)) {
         $label = $varCallback($objItem->row(), $label, $objDca, '', $blnSimple, false);
     } else {
         $label = \Image::getHtml('iconPLAIN.gif') . ' ' . ($blnSimple ? $args['titleField'] : $label);
     }
     return $label;
 }
예제 #21
0
 protected function initializeData($strPeriod, $intStart, $intStop, $privateDate, $publicDate)
 {
     $intStart = strtotime('first day of this month', $intStart);
     $arrData = array('rows' => array());
     $arrData['header'] = array(array('value' => &$GLOBALS['TL_LANG']['ISO_REPORT']['period'], 'header' => true), array('value' => &$GLOBALS['TL_LANG']['ISO_REPORT']['orders#'], 'attributes' => ' style="text-align:right"'), array('value' => &$GLOBALS['TL_LANG']['ISO_REPORT']['products#'], 'attributes' => ' style="text-align:right"'), array('value' => &$GLOBALS['TL_LANG']['ISO_REPORT']['items#'], 'attributes' => ' style="text-align:right"'), array('value' => &$GLOBALS['TL_LANG']['ISO_REPORT']['sales#'], 'attributes' => ' style="text-align:right"'));
     $arrData['footer'] = array(array('value' => $GLOBALS['TL_LANG']['ISO_REPORT']['sums']), array('value' => 0, 'attributes' => ' style="text-align:right"'), array('value' => 0, 'attributes' => ' style="text-align:right"'), array('value' => 0, 'attributes' => ' style="text-align:right"'), array('value' => array(), 'attributes' => ' style="text-align:right"'));
     while ($intStart <= $intStop) {
         $arrData['rows'][date($privateDate, $intStart)] = array('columns' => array(array('value' => \Date::parse($publicDate, $intStart)), array('value' => 0, 'attributes' => ' style="text-align:right"'), array('value' => 0, 'attributes' => ' style="text-align:right"'), array('value' => 0, 'attributes' => ' style="text-align:right"'), array('value' => 0, 'attributes' => ' style="text-align:right"')));
         $intStart = strtotime('+ 1 ' . $strPeriod, $intStart);
     }
     if ($strPeriod == 'week') {
         $arrData['rows'][date($privateDate, $intStart)] = array('columns' => array(array('value' => \Date::parse($publicDate, $intStart)), array('value' => 0, 'attributes' => ' style="text-align:right"'), array('value' => 0, 'attributes' => ' style="text-align:right"'), array('value' => 0, 'attributes' => ' style="text-align:right"'), array('value' => 0, 'attributes' => ' style="text-align:right"')));
     }
     RowClass::withKey('class')->addEvenOdd()->applyTo($arrData['rows']);
     return $arrData;
 }
 /**
  * @see \Components\Ui_Panel::onRetrieveValue() onRetrieveValue
  */
 protected function onRetrieveValue()
 {
     $params = $this->scriptlet->request->getParams();
     $id = $this->id();
     if ($params->containsKey("{$id}-date")) {
         $date = $params->get("{$id}-date");
     } else {
         $date = Date::now()->formatLocalized('common/date/pattern/short');
     }
     if ($params->containsKey("{$id}-time")) {
         $time = $params->get("{$id}-time");
     } else {
         $time = Date::now()->formatLocalized('common/time/pattern/short');
     }
     $this->value(Date::parse("{$date} {$time}", Timezone::systemDefault()));
 }
 /**
  * {@inheritdoc}
  */
 protected function getParameterFilterOptions($objAttribute, $arrIds, &$arrCount = null)
 {
     $arrOptions = $objAttribute->getFilterOptions($this->get('onlypossible') ? $arrIds : null, (bool) $this->get('onlyused'), $arrCount);
     $arrNewOptions = array();
     // Sort the values, first char uppercase.
     foreach ($arrOptions as $strOptionsValue => $strOptionLabel) {
         if ($strOptionsValue == '-' || $strOptionLabel == '-') {
             continue;
         }
         $parsedYear = \Date::parse('Y', $strOptionsValue);
         $arrNewOptions[$parsedYear] = $parsedYear;
     }
     arsort($arrNewOptions);
     $arrOptions = $arrNewOptions;
     return $arrOptions;
 }
 /**
  * Generate a row and return it as HTML string
  * @param array
  * @return string
  */
 public function generateRow($arrRow)
 {
     //$aqi = new \AirQuality($arrRow);
     $aqitext = '';
     $AirQualityIndexes = deserialize($arrRow['AQI_ALL']);
     $AirQualityIndex = deserialize($arrRow['AQI_MAX']);
     foreach ($AirQualityIndexes as $aqiv) {
         if ($AirQualityIndex[parameter] == $aqiv[parameter]) {
             $max = 'max ';
         } else {
             $max = '';
         }
         $aqitext = $aqitext . ' <span class="aqi ' . $max . $aqiv[level] . '">' . $aqiv[parameter] . ' (' . $aqiv[value] . ')</span>';
     }
     return '<div><span style="color:#b3b3b3;padding-right:3px">[' . Date::parse(Config::get('dateFormat'), $arrRow['date']) . ']</span> ' . $aqitext . '</div>';
 }
예제 #25
0
 public static function fetchFromParameters($params)
 {
     $searchCriteria = new SearchCriteria();
     if (isset($params['check_in'])) {
         $searchCriteria->checkInDate = Date::parse($params['check_in']);
     }
     if (isset($params['check_out'])) {
         $searchCriteria->checkOutDate = Date::parse($params['check_out']);
     }
     if (isset($params['adults'])) {
         $searchCriteria->adultsCount = intval($params['adults']);
     }
     if (isset($params['children'])) {
         $searchCriteria->childrenCount = intval($params['children']);
     }
     return $searchCriteria;
 }
 public function addDate($row, $label)
 {
     if ($row['start'] || $row['end']) {
         $label .= '&nbsp;<strong>[';
         if ($row['start']) {
             $label .= $GLOBALS['TL_LANG']['tl_entity_import']['start'][0] . ': ' . \Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $row['start']);
             if ($row['end']) {
                 $label .= '&nbsp;-&nbsp;';
             }
         }
         if ($row['end']) {
             $label .= $GLOBALS['TL_LANG']['tl_entity_import']['end'][0] . ': ' . \Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $row['end']);
         }
         $label .= ']</strong>';
     }
     return $label;
 }
 public static function fetchFromParameters($params)
 {
     $newsletterSubscription = new NewsletterSubscription();
     if (isset($params['id']) && is_numeric($params['id'])) {
         $newsletterSubscription->id = intval($params['id']);
     }
     if (isset($params['email'])) {
         $newsletterSubscription->email = trim($params['email']);
     }
     if (isset($params['is_active'])) {
         $newsletterSubscription->isActive = intval($params['is_active']) == 1;
     }
     if (isset($params['subscription_date'])) {
         $newsletterSubscription->subscriptionDate = Date::parse($params['subscription_date']);
     }
     return $newsletterSubscription;
 }
예제 #28
0
 /**
  * Generate the content element
  */
 protected function compile()
 {
     $arrItems = array();
     $t = 'tl_calendar_events';
     if ($this->include_type == 'archives') {
         $arrArchiveIds = deserialize($this->include_archives, true);
         $strSortOrder = $this->sortOrder == 'ascending' ? 'ASC' : 'DESC';
         if (sizeof($arrArchiveIds)) {
             $arrColumns = array("{$t}.pid IN(" . implode(',', array_map('intval', $arrArchiveIds)) . ")");
             if (!BE_USER_LOGGED_IN) {
                 $time = time();
                 $arrColumns[] = "({$t}.start='' OR {$t}.start<{$time}) AND ({$t}.stop='' OR {$t}.stop>{$time}) AND {$t}.published=1";
             }
             $objItems = \CalendarEventsModel::findBy($arrColumns, null, array('order' => 'startDate ' . $strSortOrder));
         }
     } else {
         $arrItemIds = deserialize($this->include_items, true);
         if (sizeof($arrItemIds)) {
             $arrItems = array_map(function () {
                 return '';
             }, array_flip($arrItemIds));
             $arrColumns = array("{$t}.id IN(" . implode(',', array_map('intval', $arrItemIds)) . ")");
             if (!BE_USER_LOGGED_IN) {
                 $time = time();
                 $arrColumns[] = "({$t}.start='' OR {$t}.start<{$time}) AND ({$t}.stop='' OR {$t}.stop>{$time}) AND {$t}.published=1";
             }
             $objItems = \CalendarEventsModel::findBy($arrColumns, null);
         }
     }
     if (!is_null($objItems)) {
         while ($objItems->next()) {
             $objReaderPage = \PageModel::findById($objItems->getRelated('pid')->jumpTo);
             $arrItem = $objItems->row();
             $arrItem['dateStart'] = \Date::parse('Y-m-d', $objItems->startDate);
             $arrItem['dateStartReadable'] = \Date::parse(\Config::get('dateFormat') ?: 'Y-m-d', $objItems->startDate);
             if ($objItems->endDate) {
                 $arrItem['dateEnd'] = \Date::parse('Y-m-d', $objItems->endDate);
                 $arrItem['dateEndReadable'] = \Date::parse(\Config::get('dateFormat') ?: 'Y-m-d', $objItems->endDate);
             }
             $arrItem['href'] = ampersand($this->generateFrontendUrl($objReaderPage->row(), (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/items/') . (!\Config::get('disableAlias') && $objItems->alias != '' ? $objItems->alias : $objItems->id)));
             $arrItems[$objItems->id] = $arrItem;
         }
     }
     $this->Template->items = array_filter($arrItems);
 }
예제 #29
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $database = \Database::getInstance();
     $language = "de";
     $conjunction = " bis ";
     $stagesAlias = "etappen";
     $registerAlias = "meine-spieler";
     $resultsAlias = "etappenstaende";
     $translations = array("details" => "Details", "register" => "Anmeldung", "results" => "Ergebnisse");
     if ($objPage->language == "it") {
         $language = "it";
         $conjunction = " a ";
         $stagesAlias = "tappe";
         $registerAlias = "i-miei-giocatori";
         $resultsAlias = "risultati-tappe";
         $translations = array("details" => "Dettagli", "register" => "Iscrizione", "results" => "Risultati");
     }
     if (($registerPage = $database->prepare("SELECT id, alias FROM tl_page WHERE alias = ?")->execute($registerAlias)->fetchAssoc()) != null) {
         $registerLink = $this->generateFrontendUrl($registerPage);
     }
     if (($resultsPage = $database->prepare("SELECT id, alias FROM tl_page WHERE alias = ?")->execute($resultsAlias)->fetchAssoc()) != null) {
         $resultsLink = $this->generateFrontendUrl($resultsPage);
     }
     $stages = $database->query("SELECT tl_beachcup_stage.id, tl_beachcup_stage.is_enabled, tl_beachcup_stage.name_{$language} AS name, tl_beachcup_stage.start_date, tl_beachcup_stage.end_date, tl_beachcup_venue.picture, tl_beachcup_venue.latitude, tl_beachcup_venue.longitude, tl_beachcup_venue.address_{$language} AS address \n                                    FROM tl_beachcup_stage \n                                    JOIN tl_beachcup_venue ON tl_beachcup_stage.venue_id = tl_beachcup_venue.id \n                                    JOIN tl_beachcup_season ON tl_beachcup_stage.season_id = tl_beachcup_season.id \n                                    WHERE tl_beachcup_season.active = true \n                                    ORDER BY tl_beachcup_stage.start_date")->fetchAllAssoc();
     foreach ($stages as &$stage) {
         $src = deserialize($stage["picture"]);
         $file = \FilesModel::findByUuid($src);
         $path = $file->path;
         $stage["src"] = $path;
         if ($stage["start_date"] == $stage["end_date"]) {
             $stage["date"] = \Date::parse("j. F Y", $stage["start_date"]);
         } else {
             $stage["date"] = \Date::parse("j.", $stage["start_date"]) . $conjunction . \Date::parse("j. F Y", $stage["end_date"]);
         }
         if (($alias = $database->prepare("SELECT id, alias FROM tl_page WHERE alias = ?")->execute($objPage->alias)->fetchAssoc()) != null) {
             $stage["link"] = $this->generateFrontendUrl($alias, "/../{$stagesAlias}/{$this->detailsKey}/" . $stage["id"]);
         }
         $stage["tournaments"] = $database->prepare("SELECT DISTINCT tl_beachcup_tournament_type.description_{$language} AS description \n                                                        FROM tl_beachcup_tournament JOIN tl_beachcup_tournament_type ON tl_beachcup_tournament.type_id = tl_beachcup_tournament_type.id \n                                                        WHERE tl_beachcup_tournament.stage_id = ?\n                                                        ORDER BY tl_beachcup_tournament_type.description_{$language}")->execute($stage["id"])->fetchAllAssoc();
     }
     $this->Template->translations = $translations;
     $this->Template->stages = $stages;
     $this->Template->registerLink = $registerLink;
     $this->Template->resultsLink = $resultsLink;
 }
 /**
  * label_callback
  * @param   array
  * @return  string
  */
 public function listRows($arrRow, $label, $dc)
 {
     $strBuffer = '<span style="color:#b3b3b3;padding-right:3px">[%s]</span>';
     $arrValues = array(\Date::parse(\Date::getNumericDatimFormat(), $arrRow['dateAdded']));
     $objQueuedMessage = QueuedMessage::findByPk($arrRow['id']);
     $arrStatusColorClasses = array('queued' => 'tl_orange', 'sent' => 'tl_green', 'error' => 'tl_red');
     $strBuffer .= ' <span class="%s">%s</span>';
     $arrValues[] = $arrStatusColorClasses[$objQueuedMessage->getStatus()];
     $arrValues[] =& $GLOBALS['TL_LANG']['tl_nc_queue']['status'][$objQueuedMessage->getStatus()];
     if (($objMessage = $objQueuedMessage->getRelated('message')) !== null) {
         $strBuffer .= ' <div class="tl_gray">%s: %s <a href="%s" class="tl_gray">[%s]</a></div>';
         $arrValues[] = $GLOBALS['TL_LANG']['tl_nc_queue']['source'];
         $arrValues[] = $objMessage->title;
         $arrValues[] = sprintf('contao/main.php?do=nc_notifications&table=tl_nc_message&act=edit&id=%s&rt=%s&ref=9b33cf83', $objMessage->id, REQUEST_TOKEN, TL_REFERER_ID);
         $arrValues[] = $objMessage->id;
     }
     return vsprintf($strBuffer, $arrValues);
 }