public function parseMap()
 {
     $objT = new \FrontendTemplate($this->strTemplate);
     $objT->setData($GLOBALS['TL_LANG']['imagemapster']);
     $objT->active = $this->active;
     return $objT->parse();
 }
 protected function parseJs()
 {
     $objT = new \FrontendTemplate($this->strTemplate);
     $objT->setData($this->arrData);
     $objT->id = '#ctrl_' . $this->strName;
     return $objT->parse();
 }
 protected function parseCredit($objItem)
 {
     global $objPage;
     $objCredit = new FileCreditHybridModel();
     $objCredit = $objCredit->findRelatedByCredit($objItem, $this->arrPids);
     if (is_null($objCredit)) {
         return null;
     }
     $objTemplate = new \FrontendTemplate('filecredit_default');
     $objTemplate->setData($objCredit->file->row());
     // TODO
     $objTemplate->link = $this->generateCreditUrl($objCredit);
     $objTemplate->linkText = $GLOBALS['TL_LANG']['MSC']['creditLinkText'];
     // TODO
     if ($objCredit->page === null && $objCredit->result->usage) {
         $objTemplate->pageTitle = $objCredit->result->usage;
     } else {
         $objTemplate->pageTitle = $objCredit->page->pageTitle ? $objCredit->page->pageTitle : $objCredit->page->title;
     }
     // colorbox support
     if ($objPage->outputFormat == 'xhtml') {
         $strLightboxId = 'lightbox';
     } else {
         $strLightboxId = 'lightbox[' . substr(md5($objTemplate->getName() . '_' . $objCredit->file->id), 0, 6) . ']';
     }
     $objTemplate->attribute = $strLightboxId ? ($objPage->outputFormat == 'html5' ? ' data-gallery="#gallery-' . $this->id . '" data-lightbox="' : ' rel="') . $strLightboxId . '"' : '';
     return $objTemplate->parse();
 }
 /**
  * Generate module
  */
 protected function compile()
 {
     // Get ID
     $strAlias = \Input::get('auto_item') ? \Input::get('auto_item') : \Input::get('store');
     // Find published store from ID
     if (($objStore = AnyStoresModel::findPublishedByIdOrAlias($strAlias)) !== null) {
         // load all details
         $objStore->loadDetails();
         // generate description
         $objDescription = \ContentModel::findPublishedByPidAndTable($objStore->id, $objStore->getTable());
         if ($objDescription !== null) {
             while ($objDescription->next()) {
                 $objStore->description .= \Controller::getContentElement($objDescription->current());
             }
         }
         // Get referer for back button
         $objStore->referer = $this->getReferer();
         // generate google map if template and geodata is set
         if ($this->anystores_mapTpl != '' && is_numeric($objStore->latitude) && is_numeric($objStore->longitude)) {
             $objMapTemplate = new \FrontendTemplate($this->anystores_mapTpl);
             $objMapTemplate->setData($objStore->row());
             $objStore->gMap = $objMapTemplate->parse();
         }
         // Template
         $objDetailTemplate = new \FrontendTemplate($this->anystores_detailTpl);
         $objDetailTemplate->setData($objStore->row());
         $this->Template->store = $objDetailTemplate->parse();
     } else {
         $this->_redirect404();
     }
 }
 public function parsePromoter($objPromoter, $index = null, array $arrPromoters = array())
 {
     $strTemplate = $this->cal_promoterTemplate ? $this->cal_promoterTemplate : 'cal_promoter_default';
     $objT = new \FrontendTemplate($strTemplate);
     $objT->setData($objPromoter->row());
     if ($objPromoter->room && ($objRoom = $objPromoter->getRelated('room')) !== null) {
         $objT->room = $objRoom;
     }
     $contact = new \stdClass();
     $hasContact = false;
     if ($objPromoter->website) {
         $objT->websiteUrl = \HeimrichHannot\Haste\Util\Url::addScheme($objPromoter->website);
     }
     foreach (static::$arrContact as $strField) {
         if (!$objT->{$strField}) {
             continue;
         }
         $hasContact = true;
         $contact->{$strField} = $objT->{$strField};
     }
     $objT->hasContact = $hasContact;
     $objT->contact = $contact;
     $objT->contactTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['contactTitle'];
     $objT->phoneTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['phoneTitle'];
     $objT->faxTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['faxTitle'];
     $objT->emailTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['emailTitle'];
     $objT->websiteTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['websiteTitle'];
     if (!empty($arrPromoters) && $index !== null) {
         $objT->cssClass = \HeimrichHannot\Haste\Util\Arrays::getListPositonCssClass($index, $arrPromoters);
     }
     return $objT->parse();
 }
 public static function parseCredit(FileCreditModel $objModel, array $arrPids = array(), $objModule)
 {
     global $objPage;
     $objTemplate = new \FrontendTemplate(!$objModule->creditsGroupBy ? 'filecredit_default' : 'filecredit_grouped');
     // skip if no files model exists
     if (($objFilesModel = $objModel->getRelated('uuid')) === null) {
         return null;
     }
     // cleanup: remove credits where copyright was deleted
     if ($objFilesModel->copyright == '') {
         FileCreditPageModel::deleteByPid($objModel->id);
         $objModel->delete();
         return null;
     }
     // skip if credit occurs on no page
     if (($objCreditPages = FileCreditPageModel::findPublishedByPids(array($objModel->id))) === null) {
         return null;
     }
     while ($objCreditPages->next()) {
         $arrCredit = $objCreditPages->row();
         // not a child of current root page
         if (!empty($arrPids) && !in_array($arrCredit['page'], $arrPids)) {
             continue;
         }
         if ($arrCredit['url'] == '' && ($objTarget = \PageModel::findByPk($arrCredit['page'])) !== null) {
             $arrCredit['url'] = \Controller::generateFrontendUrl($objTarget->row());
         }
         $arrPages[] = $arrCredit;
     }
     if ($arrPages === null) {
         return null;
     }
     $objTemplate->setData($objModel->row());
     $objTemplate->fileData = $objFilesModel->row();
     static::addCopyrightToTemplate($objTemplate, $objFilesModel, $objModule);
     $objTemplate->link = $GLOBALS['TL_LANG']['MSC']['creditLinkText'];
     $objTemplate->pagesLabel = $GLOBALS['TL_LANG']['MSC']['creditPagesLabel'];
     $objTemplate->path = $objFilesModel->path;
     $objTemplate->pages = $arrPages;
     $objTemplate->pageCount = count($arrPages);
     // colorbox support
     if ($objPage->outputFormat == 'xhtml') {
         $strLightboxId = 'lightbox';
     } else {
         $strLightboxId = 'lightbox[' . substr(md5($objTemplate->getName() . '_' . $objFilesModel->id), 0, 6) . ']';
     }
     $objTemplate->attribute = $strLightboxId ? ($objPage->outputFormat == 'html5' ? ' data-gallery="#gallery-' . $objModule->id . '" data-lightbox="' : ' rel="') . $strLightboxId . '"' : '';
     $objTemplate->addImage = false;
     // Add an image
     if (!is_file(TL_ROOT . '/' . $objModel->path)) {
         $arrData = array('singleSRC' => $objFilesModel->path, 'doNotIndex' => true);
         $size = deserialize($objModule->imgSize);
         if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
             $arrData['size'] = $objModule->imgSize;
         }
         \Controller::addImageToTemplate($objTemplate, $arrData);
     }
     return array('pages' => $arrPages, 'order' => static::getSortValue($objModule->creditsSortBy, $objTemplate), 'group' => static::getGroupValue($objModule->creditsGroupBy, $objTemplate), 'output' => $objTemplate->parse());
 }
Example #7
0
 /**
  * Parse an item and return it as string
  * @param object
  * @param boolean
  * @param string
  * @param integer
  * @return string
  */
 protected function parseEmployee($objEmployee, $blnAddStaff = false, $strClass = '', $intCount = 0)
 {
     global $objPage;
     $objTemplate = new \FrontendTemplate($this->staff_employee_template);
     $objTemplate->setData($objEmployee->row());
     $objTemplate->class = ($this->staff_employee_class != '' ? ' ' . $this->staff_employee_class : '') . $strClass;
     if (!empty($objEmployee->education)) {
         $objTemplate->education = deserialize($objEmployee->education);
     }
     $objTemplate->link = $this->generateEmployeeUrl($objEmployee, $blnAddStaff);
     $objTemplate->staff = $objEmployee->getRelated('pid');
     $objTemplate->txt_educations = $GLOBALS['TL_LANG']['MSC']['educations'];
     $objTemplate->txt_contact = $GLOBALS['TL_LANG']['MSC']['contact'];
     $objTemplate->txt_room = $GLOBALS['TL_LANG']['MSC']['room'];
     $objTemplate->txt_phone = $GLOBALS['TL_LANG']['MSC']['phone'];
     $objTemplate->txt_mobile = $GLOBALS['TL_LANG']['MSC']['mobile'];
     $objTemplate->txt_fax = $GLOBALS['TL_LANG']['MSC']['fax'];
     $objTemplate->txt_email = $GLOBALS['TL_LANG']['MSC']['email'];
     $objTemplate->txt_website = $GLOBALS['TL_LANG']['MSC']['website'];
     $objTemplate->txt_facebook = $GLOBALS['TL_LANG']['MSC']['facebook'];
     $objTemplate->txt_googleplus = $GLOBALS['TL_LANG']['MSC']['googleplus'];
     $objTemplate->txt_twitter = $GLOBALS['TL_LANG']['MSC']['twitter'];
     $objTemplate->txt_linkedin = $GLOBALS['TL_LANG']['MSC']['linkedin'];
     $objTemplate->count = $intCount;
     // see #5708
     $objTemplate->addImage = false;
     // Add an image
     if ($objEmployee->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($objEmployee->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($objEmployee->singleSRC)) {
                 $objTemplate->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             // Do not override the field now that we have a model registry (see #6303)
             $arrEmployee = $objEmployee->row();
             // Override the default image size
             if ($this->imgSize != '') {
                 $size = deserialize($this->imgSize);
                 if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
                     $arrEmployee['size'] = $this->imgSize;
                 }
             }
             $arrEmployee['singleSRC'] = $objModel->path;
             $strLightboxId = 'lightbox[lb' . $this->id . ']';
             $arrEmployee['fullsize'] = $this->fullsize;
             $this->addImageToTemplate($objTemplate, $arrEmployee, null, $strLightboxId);
         }
     }
     $objTemplate->enclosure = array();
     // Add enclosures
     if ($objEmployee->addEnclosure) {
         $this->addEnclosuresToTemplate($objTemplate, $objEmployee->row());
     }
     return $objTemplate->parse();
 }
 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;
 }
 protected function parseMember($objMember)
 {
     global $objPage;
     $objT = new \FrontendTemplate('memberlist_default');
     $objT->setData($objMember->row());
     $strUrl = $this->generateMemberUrl($objMember);
     $objT->addImage = false;
     // Add an image
     if ($objMember->addImage && $objMember->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($objMember->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($objMember->singleSRC)) {
                 $objMember->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             // Do not override the field now that we have a model registry (see #6303)
             $arrMember = $objMember->row();
             // Override the default image size
             if ($this->size != '') {
                 $size = deserialize($this->size);
                 if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
                     $arrMember['size'] = $this->size;
                 }
             }
             $arrMember['singleSRC'] = $objModel->path;
             \Controller::addImageToTemplate($objT, $arrMember);
         }
     }
     $arrTitle = array($objMember->academicTitle, $objMember->firstname, $objMember->lastname);
     $objT->titleCombined = empty($arrTitle) ? '' : implode(' ', $arrTitle);
     $arrLocation = array($objMember->postal, $objMember->city);
     $objT->locationCombined = empty($arrLocation) ? '' : implode(' ', $arrLocation);
     $objT->websiteLink = $objMember->website;
     $objT->websiteTitle = $GLOBALS['TL_LANG']['MSC']['memberlist']['websiteTitle'];
     // Add http:// to the website
     if ($objMember->website != '' && !preg_match('@^(https?://|ftp://|mailto:|#)@i', $objMember->website)) {
         $objT->websiteLink = 'http://' . $objMember->website;
     }
     if ($this->mlSource == 'external') {
         // Encode e-mail addresses
         if (substr($this->mlUrl, 0, 7) == 'mailto:') {
             $strUrl = \String::encodeEmail($this->mlUrl);
         } else {
             $strUrl = ampersand($this->mlUrl);
         }
     }
     $objT->link = $strUrl;
     $objT->linkTarget = $this->mlTarget ? $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"' : '';
     $objT->linkTitle = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['openMember'], $objT->titleCombined));
     return $objT->parse();
 }
 public function generate()
 {
     $objT = new \FrontendTemplate('fieldpalette_button_default');
     $objT->setData($this->arrOptions);
     $objT->href = $this->generateHref();
     $strAttribues = '';
     if (is_array($this->arrOptions['attributes'])) {
         foreach ($this->arrOptions['attributes'] as $key => $arrValues) {
             $strAttribues .= implode(' ', $this->arrOptions['attributes']);
         }
     }
     $objT->attributes = strlen($strAttribues) > 0 ? ' ' . $strAttribues : '';
     return $objT->parse();
 }
 /**
  * Generate the markup for the default uploader
  *
  * @return string
  */
 public function generateMarkup()
 {
     $arrValues = array_values($this->value ?: array());
     $objT = new \FrontendTemplate($this->strTemplate);
     $objT->setData($this->arrData);
     $objT->id = $this->strField;
     $objT->uploadMultiple = $this->uploadMultiple;
     $objT->initialFiles = json_encode($arrValues);
     $objT->initialFilesFormatted = $this->prepareValue();
     $objT->uploadedFiles = '[]';
     $objT->deletedFiles = '[]';
     $objT->attributes = $this->getAttributes($this->getDropZoneOptions());
     return $objT->parse();
 }
Example #12
0
 /**
  * Parse an item and return it as string
  * @param object
  * @param boolean
  * @param string
  * @param integer
  * @return string
  */
 protected function parseCarpet($objCarpet, $blnAddCategory = false, $strClass = '', $intCount = 0)
 {
     global $objPage;
     $objTemplate = new \FrontendTemplate($this->carpet_template);
     $objTemplate->setData($objCarpet->row());
     $objTemplate->class = ($this->carpet_Class != '' ? ' ' . $this->carpet_Class : '') . $strClass;
     $objTemplate->rate = $objCarpet->visit / 10;
     $objTemplate->rateid = $this->generateRandomString();
     $objTemplate->totalknots = $objCarpet->kwidth * $objCarpet->kheight;
     if ($objCarpet->knots > 0) {
         $objTemplate->widthcm = round($objCarpet->kwidth * 7 / $objCarpet->knots);
         $objTemplate->heightcm = round($objCarpet->kheight * 7 / $objCarpet->knots);
     } else {
         $objTemplate->widthcm = '-';
         $objTemplate->heightcm = '-';
     }
     if ($this->carpet_price) {
         $objTemplate->price = number_format($objCarpet->price);
         $objTemplate->show_price = $this->carpet_price;
     }
     $objTemplate->link = $this->generateCarpetUrl($objCarpet, $blnAddCategory);
     $objTemplate->category = $objCarpet->getRelated('pid');
     $objTemplate->count = $intCount;
     // see #5708
     // Add an image
     if ($objCarpet->singleSRC != '') {
         $objModel = \FilesModel::findByUuid($objCarpet->singleSRC);
         if ($objModel === null) {
             if (!\Validator::isUuid($objCarpet->singleSRC)) {
                 $objTemplate->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
             }
         } elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
             // Do not override the field now that we have a model registry (see #6303)
             $arrCarpet = $objCarpet->row();
             // Override the default image size
             if ($this->imgSize != '') {
                 $size = deserialize($this->imgSize);
                 if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
                     $arrCarpet['size'] = $this->imgSize;
                 }
             }
             $arrCarpet['singleSRC'] = $objModel->path;
             $strLightboxId = 'lightbox[lb' . $this->id . ']';
             $arrCarpet['fullsize'] = $this->fullsize;
             $this->addImageToTemplate($objTemplate, $arrCarpet, null, $strLightboxId);
         }
     }
     return $objTemplate->parse();
 }
 public static function getParsedActivities($intCompany, \Module $objModule = null)
 {
     $strResult = '';
     \Controller::loadDataContainer('tl_company_activity');
     \System::loadLanguageFile('tl_company_activity');
     if (($objActivities = static::getActivities($intCompany)) !== null) {
         while ($objActivities->next()) {
             $objTemplate = new \FrontendTemplate('company_activity_default');
             $objTemplate->setData($objActivities->row());
             $objTemplate->module = $objModule;
             $strResult .= $objTemplate->parse();
         }
     }
     return $strResult;
 }
 /**
  * Parse an item and return it as string
  * @param object
  * @param string
  * @param integer
  * @return string
  */
 protected function parseRecipe($objRecipe, $strClass = '', $intCount = 0)
 {
     global $objPage;
     $objTemplate = new \FrontendTemplate($this->item_template);
     $objTemplate->setData($objRecipe->row());
     $objTemplate->class = ($objRecipe->cssClass != '' ? ' ' . $objRecipe->cssClass : '') . $strClass;
     // $objTemplate->distance = $this->getCurrentOpenStatus($objRecipe);
     //Detail-Url
     if ($this->jumpTo) {
         $objDetailPage = \PageModel::findByPk($this->jumpTo);
         $objTemplate->detailUrl = ampersand($this->generateFrontendUrl($objDetailPage->row(), '/' . $objRecipe->alias));
         $objTemplate->teaser = \String::substr($objRecipe->preparation, 100);
     }
     return $objTemplate->parse();
 }
Example #15
0
 /**
  * Generate the module
  */
 protected function parseLink($objLink, $strClass = '', $intCount = 0)
 {
     $objTemplate = new \FrontendTemplate($this->links_template);
     $objTemplate->setData($objLink->row());
     $strImage = '';
     $objImage = \FilesModel::findByPk($objLink->singleSRC);
     $size = deserialize($this->imgSize);
     // Add image
     if ($objImage !== null) {
         $strImage = \Image::getHtml(\Image::get($objImage->path, $size[0], $size[1], $size[2]));
     }
     $objTemplate->class = $strClass;
     $objTemplate->linkTitle = $objLink->linkTitle ? $objLink->linkTitle : $objLink->title;
     $objTemplate->image = $strImage;
     return $objTemplate->parse();
 }
Example #16
0
 /**
  * Generate content element
  * @return string
  */
 protected function compile()
 {
     //Add in all JS/CSS
     $GLOBALS['TL_HEAD']['slickcss'] = '<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/jquery.slick/' . SLICK_VERSION . '/slick.css"/>';
     $GLOBALS['TL_BODY']['slickjs'] = '<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.slick/' . SLICK_VERSION . '/slick.min.js"></script>';
     if ($this->cssID[0] == '') {
         $this->cssID = array('slickslider' . $this->id, $this->cssID[1]);
     }
     //Load up the configuration
     if ($this->slick_jstemplate != '') {
         $this->jsTemplate = $this->slick_jstemplate;
     }
     $objTemplate = new \FrontendTemplate($this->jsTemplate);
     $objTemplate->setData($this->arrData);
     $objTemplate->id = $this->cssID[0];
     $GLOBALS['TL_BODY'][] = $objTemplate->parse();
 }
 public function parseMember($objMember)
 {
     global $objPage;
     $objT = new \FrontendTemplate($this->mlTemplate);
     $objT->setData($objMember->row());
     $arrSkipFields = deserialize($this->mlFields, true);
     if ($this->mlSkipFields) {
         $this->dropFieldsFromTemplate($objT, $arrSkipFields);
     }
     $strUrl = $this->generateMemberUrl($objMember);
     $objT->hasContent = false;
     $objElement = \ContentModel::findPublishedByPidAndTable($objMember->id, 'tl_member');
     if ($objElement !== null) {
         $objT->hasContent = true;
         if ($this->mlLoadContent) {
             while ($objElement->next()) {
                 $objT->text .= $this->getContentElement($objElement->current());
             }
         }
     }
     $objT->addImage = false;
     if (!$this->mlDisableImages) {
         $this->addMemberImageToTemplate($objT, $objMember);
     }
     $objT->titleCombined = $this->getCombinedTitle($objMember, $arrSkipFields);
     $arrLocation = array_filter(array($objMember->postal, $objMember->city));
     $objT->locationCombined = empty($arrLocation) ? '' : implode(' ', $arrLocation);
     $objT->websiteLink = $objMember->website;
     $objT->websiteTitle = $GLOBALS['TL_LANG']['MSC']['memberlist']['websiteTitle'];
     // Add http:// to the website
     if ($objMember->website != '' && !preg_match('@^(https?://|ftp://|mailto:|#)@i', $objMember->website)) {
         $objT->websiteLink = 'http://' . $objMember->website;
     }
     if ($this->mlSource == 'external') {
         // Encode e-mail addresses
         if (substr($this->mlUrl, 0, 7) == 'mailto:') {
             $strUrl = \String::encodeEmail($this->mlUrl);
         } else {
             $strUrl = ampersand($this->mlUrl);
         }
     }
     $objT->link = $strUrl;
     $objT->linkTarget = $this->mlTarget ? $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"' : '';
     $objT->linkTitle = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['openMember'], $objT->titleCombined));
     return $objT->parse();
 }
 public function generate(WatchlistItemModel $objItem, Watchlist $objWatchlist)
 {
     global $objPage;
     $objFileModel = \FilesModel::findById($objItem->uuid);
     if ($objFileModel === null) {
         return;
     }
     $file = \Input::get('file', true);
     // Send the file to the browser and do not send a 404 header (see #4632)
     if ($file != '' && $file == $objFileModel->path) {
         \Controller::sendFileToBrowser($file);
     }
     $objFile = new \File($objFileModel->path, true);
     $objContent = \ContentModel::findByPk($objItem->cid);
     $objT = new \FrontendTemplate('watchlist_view_download');
     $objT->setData($objFileModel->row());
     $linkTitle = specialchars($objFile->name);
     // use generate for download & downloads as well
     if ($objContent->type == 'download' && $objContent->linkTitle != '') {
         $linkTitle = $objContent->linkTitle;
     }
     $arrMeta = deserialize($objFileModel->meta);
     // Language support
     if (($arrLang = $arrMeta[$GLOBALS['TL_LANGUAGE']]) != '') {
         $linkTitle = $arrLang['title'] ? $arrLang['title'] : $linkTitle;
     }
     $strHref = \Controller::generateFrontendUrl($objPage->row());
     // Remove an existing file parameter (see #5683)
     if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
         $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
     }
     $strHref .= (\Config::get('disableAlias') || strpos($strHref, '?') !== false ? '&amp;' : '?') . 'file=' . \System::urlEncode($objFile->path);
     $objT->link = ($objItemTitle = $objItem->title) ? $objItemTitle : $linkTitle;
     $objT->title = specialchars($objContent->titleText ?: $linkTitle);
     $objT->href = $strHref;
     $objT->filesize = \System::getReadableSize($objFile->filesize, 1);
     $objT->icon = TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon;
     $objT->mime = $objFile->mime;
     $objT->extension = $objFile->extension;
     $objT->path = $objFile->dirname;
     $objT->actions = $this->generateEditActions($objItem, $objWatchlist);
     return $objT->parse();
 }
 public static function createConfigJs($objConfig, $debug = false)
 {
     if (!static::isJQueryEnabled()) {
         return false;
     }
     $cache = !$GLOBALS['TL_CONFIG']['debugMode'];
     $objT = new \FrontendTemplate('jquery.slick');
     $arrData = static::createConfig($objConfig);
     $objT->setData($arrData['config']);
     $objT->config = static::createConfigJSON($objConfig);
     $objT->selector = static::getSlickContainerSelectorFromModel($objConfig);
     $objT->wrapperClass = static::getSlickCssClassFromModel($objConfig);
     if ($objConfig->initCallback) {
         $objT->initCallback = $objConfig->initCallback;
     }
     if ($objConfig->afterInitCallback) {
         $objT->afterInitCallback = $objConfig->afterInitCallback;
     }
     $strFile = 'assets/js/' . $objT->wrapperClass . '.js';
     $strFileMinified = 'assets/js/' . $objT->wrapperClass . '.min.js';
     $objFile = new \File($strFile, file_exists(TL_ROOT . '/' . $strFile));
     $objFileMinified = new \File($strFileMinified, file_exists(TL_ROOT . '/' . $strFileMinified));
     $minify = $cache && class_exists('\\MatthiasMullie\\Minify\\JS');
     // simple file caching
     if (static::doRewrite($objConfig, $objFile, $objFileMinified, $cache, $debug)) {
         $strChunk = $objT->parse();
         $objFile->write($objT->parse());
         $objFile->close();
         // minify js
         if ($minify) {
             $objFileMinified = new \File($strFileMinified);
             $objMinify = new \MatthiasMullie\Minify\JS();
             $objMinify->add($strChunk);
             $objFileMinified->write(rtrim($objMinify->minify(), ";") . ";");
             // append semicolon, otherwise "(intermediate value)(...) is not a function"
             $objFileMinified->close();
         }
     }
     $GLOBALS['TL_JAVASCRIPT']['slick'] = 'system/modules/slick/assets/vendor/slick-carousel/slick/slick' . ($cache ? '.min.js|static' : '.js');
     $GLOBALS['TL_JAVASCRIPT']['slick-functions'] = 'system/modules/slick/assets/js/jquery.slick-functions' . ($cache ? '.min.js|static' : '.js');
     $GLOBALS['TL_JAVASCRIPT'][$objT->wrapperClass] = $minify ? $strFileMinified . '|static' : $strFile;
 }
Example #20
0
 private function getEntries()
 {
     $result = $this->Database->prepare("SELECT tl_shoutbox_entries.*, " . "tl_member.username AS username, CONCAT(tl_member.firstname, ' ', tl_member.lastname) AS fullname" . " FROM tl_shoutbox_entries, tl_member" . " WHERE pid = ? AND tl_shoutbox_entries.member = tl_member.id" . " ORDER BY datim DESC")->limit($this->shoutbox_entries)->execute($this->shoutbox_id);
     $strContent = "";
     $i = 0;
     $objPartial = new \FrontendTemplate($this->entryTemplate);
     while ($result->next()) {
         $row = $result->row();
         $format = $GLOBALS['TL_CONFIG']['datimFormat'];
         $row['date'] = \Date::parse($format, $row['datim']);
         $row['timesince'] = $this->timesince($row['datim']);
         $row['cssClass'] = 'entry ' . ($i++ % 2 == 0 ? 'even' : 'odd');
         $objPartial->setData($row);
         $strContent .= $objPartial->parse();
     }
     $strContent = $this->replaceEmoji($strContent);
     $strContent = $this->generateLinkIcons($strContent);
     $strContent = $this->replaceInsertTags($strContent);
     return $strContent;
 }
 /**
  * @param $content            string
  * @param $properties               array
  * @param $propertiesSet       array
  */
 public function modifySearchContent($content, $properties, &$propertiesSet)
 {
     $instance = $GLOBALS['container']['modify.search.content.container'];
     /** @var Database $database */
     $database = $GLOBALS['container']['database.connection'];
     /** @var ContainerElement $item */
     $item = $instance->pool->offsetGet(md5($properties['url']));
     if (!$item) {
         return;
     }
     $template = new \FrontendTemplate($item->getTemplate());
     $template->setData(array('data' => $item->getData(), 'module' => $item->getModule(), 'href' => $item->getUrl()));
     $alternativeContent = $template->parse();
     $search = $database->prepare("SELECT * FROM tl_search WHERE url=? AND pid=?")->limit(1)->execute($item->getUrl(), $properties['pid']);
     if ($search->numRows && $search->alternativeContent != $alternativeContent) {
         $database->prepare("UPDATE tl_search %s WHERE id=?")->set(array('checksum' => ''))->execute($search->fetchAllAssoc()[0]['id']);
         $propertiesSet['alternativeContent'] = $alternativeContent;
     }
     if (!$search->numRows) {
         $propertiesSet['alternativeContent'] = $alternativeContent;
     }
 }
 protected function parseOption(array $arrOption = array(), $strKey, $strOptionTemplate)
 {
     $objOptionTemplate = new \FrontendTemplate($strOptionTemplate);
     $objLabel = new \stdClass();
     $objLabel->id = 'lbl_' . $this->objWidget->id . '_' . $strKey;
     $objLabel->for = 'opt_' . $this->objWidget->id . '_' . $strKey;
     if ($this->blnUseAwesomeInputs) {
         $objLabel->class = $this->getSetting(BOOTSTRAPPER_OPTION_INLINE) ? $this->objWidget->type . '-inline' : '';
     } else {
         $objLabel->class = $this->getSetting(BOOTSTRAPPER_OPTION_INLINE) ? ' class="' . $this->objWidget->type . '-inline"' : '';
     }
     $objLabel->value = $arrOption['label'];
     $objLabel->attributes = array();
     $arrStrAttributes = trimsplit(' ', $this->objWidget->getAttributes());
     $arrData = array('label' => $objLabel, 'type' => $this->objWidget->type, 'name' => $this->objWidget->name . (count($this->objWidget->options) > 1 && $this->blnCanBeMultiple ? '[]' : ''), 'field' => $this->objWidget->name, 'id' => 'opt_' . $this->objWidget->id . '_' . $strKey, 'class' => $this->objWidget->type, 'value' => $arrOption['value'], 'checked' => $this->objWidget->isChecked($arrOption), 'attributes' => array(), 'tagEnding' => $this->strTagEnding);
     // Trigger option_callback
     if (is_array($this->arrDca['option_callback'])) {
         foreach ($this->arrDca['option_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $arrData = $this->{$callback[0]}->{$callback[1]}($strKey, $arrData);
             } elseif (is_callable($callback)) {
                 $arrData = $callback($strKey, $arrData);
             }
         }
     }
     $objOptionTemplate->setData($arrData);
     $objOptionTemplate->attributes = $this->objWidget->getAttributes();
     if (is_array($arrData['attributes'])) {
         $objOptionTemplate->attributes .= ' ' . $this->getHtmlAttributes($arrData['attributes']);
     }
     if (is_array($arrData['label']->attributes)) {
         $objOptionTemplate->labelAttributes = ' ' . $this->getHtmlAttributes($arrData['label']->attributes);
     }
     $objOptionTemplate->multiple = $this->objWidget->multiple;
     $objOptionTemplate->mandatory = $this->objWidget->mandatory;
     return $objOptionTemplate->parse();
 }
 protected function parseOption(array $arrOption = array(), $strKey, $strOptionTemplate)
 {
     $objOptionTemplate = new \FrontendTemplate($strOptionTemplate);
     $objLabel = new \stdClass();
     $objLabel->value = $arrOption['label'];
     $arrData = array('label' => $objLabel, 'type' => $this->objWidget->type, 'name' => $this->objWidget->name, 'id' => 'opt_' . $this->objWidget->id . '_' . $strKey, 'class' => $this->objWidget->type, 'value' => $arrOption['value'], 'selected' => $this->objWidget->isSelected($arrOption), 'tagEnding' => $this->strTagEnding, 'attributes' => array());
     // Trigger option_callback
     if (is_array($this->arrDca['option_callback'])) {
         foreach ($this->arrDca['option_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $arrData = $this->{$callback[0]}->{$callback[1]}($strKey, $arrData);
             } elseif (is_callable($callback)) {
                 $arrData = $callback($strKey, $arrData);
             }
         }
     }
     $objOptionTemplate->setData($arrData);
     if (is_array($arrData['attributes'])) {
         $objOptionTemplate->attributes = $this->getHtmlAttributes($arrData['attributes']);
     }
     return $objOptionTemplate->parse();
 }
 protected function getConfigJs()
 {
     $arrConfig = array();
     $strConfig = '';
     foreach ($this->objConfig->row() as $key => $data) {
         switch ($key) {
             case 'defaultFill':
                 $arrConfig['fills']['defaultFill'] = $data;
                 break;
             case 'fills':
                 $arrFills = deserialize($data, true);
                 foreach ($arrFills as $arrFill) {
                     if (!isset($arrFill['key']) && !isset($arrFill['color'])) {
                         continue;
                     }
                     $arrConfig['fills'][$arrFill['key']] = $arrFill['color'];
                 }
                 break;
             default:
                 continue;
         }
     }
     $jsonConfig = json_encode($arrConfig);
     $strConfig = preg_replace(array('/^{/', '/}$/'), array('', ''), $jsonConfig);
     // remove start and trailing brace
     $objT = new \FrontendTemplate($GLOBALS['TL_DATAMAPS'][$this->objConfig->type]);
     $objT->setData(static::getModelValuesAsStringArray($this->objConfig, array('title', 'type', 'fills', 'defaultFill')));
     $objT->config = \String::decodeEntities($strConfig);
     return $objT->parse();
 }
Example #25
0
 /**
  * Add comments to a template
  * @param FrontendTemplate
  * @param stdClass
  * @param string
  * @param integer
  * @param array
  */
 public function addCommentsToTemplate(FrontendTemplate $objTemplate, stdClass $objConfig, $strSource, $intParent, $arrNotifies)
 {
     global $objPage;
     $this->import('String');
     $limit = null;
     $arrComments = array();
     // Pagination
     if ($objConfig->perPage > 0) {
         // Get the total number of comments
         $objTotal = $this->Database->prepare("SELECT COUNT(*) AS count FROM tl_comments WHERE source=? AND parent=?" . (!BE_USER_LOGGED_IN ? " AND published=1" : ""))->execute($strSource, $intParent);
         $total = $objTotal->count;
         // Get the current page
         $page = $this->Input->get('page') ? $this->Input->get('page') : 1;
         // Do not index or cache the page if the page number is outside the range
         if ($page < 1 || $page > max(ceil($total / $objConfig->perPage), 1)) {
             global $objPage;
             $objPage->noSearch = 1;
             $objPage->cache = 0;
             // Send a 404 header
             header('HTTP/1.1 404 Not Found');
             $objTemplate->allowComments = false;
             $objTemplate->comments = array();
             // see #4064
             return;
         }
         // Set limit and offset
         $limit = $objConfig->perPage;
         $offset = ($page - 1) * $objConfig->perPage;
         // Initialize the pagination menu
         $objPagination = new Pagination($objTotal->count, $objConfig->perPage);
         $objTemplate->pagination = $objPagination->generate("\n  ");
     }
     $objTemplate->allowComments = true;
     // Get all published comments
     $objCommentsStmt = $this->Database->prepare("SELECT c.*, u.name as authorName FROM tl_comments c LEFT JOIN tl_user u ON c.author=u.id WHERE c.source=? AND c.parent=?" . (!BE_USER_LOGGED_IN ? " AND c.published=1" : "") . " ORDER BY c.date" . ($objConfig->order == 'descending' ? " DESC" : ""));
     if ($limit) {
         $objCommentsStmt->limit($limit, $offset);
     }
     $objComments = $objCommentsStmt->execute($strSource, $intParent);
     $total = $objComments->numRows;
     if ($total > 0) {
         $count = 0;
         if ($objConfig->template == '') {
             $objConfig->template = 'com_default';
         }
         $objPartial = new FrontendTemplate($objConfig->template);
         while ($objComments->next()) {
             $objPartial->setData($objComments->row());
             // Clean the RTE output
             if ($objPage->outputFormat == 'xhtml') {
                 $objComments->comment = $this->String->toXhtml($objComments->comment);
             } else {
                 $objComments->comment = $this->String->toHtml5($objComments->comment);
             }
             $objPartial->comment = trim(str_replace(array('{{', '}}'), array('&#123;&#123;', '&#125;&#125;'), $objComments->comment));
             $objPartial->datim = $this->parseDate($objPage->datimFormat, $objComments->date);
             $objPartial->date = $this->parseDate($objPage->dateFormat, $objComments->date);
             $objPartial->class = ($count < 1 ? ' first' : '') . ($count >= $total - 1 ? ' last' : '') . ($count % 2 == 0 ? ' even' : ' odd');
             $objPartial->by = $GLOBALS['TL_LANG']['MSC']['comment_by'];
             $objPartial->id = 'c' . $objComments->id;
             $objPartial->timestamp = $objComments->date;
             $objPartial->datetime = date('Y-m-d\\TH:i:sP', $objComments->date);
             $objPartial->addReply = false;
             // Reply
             if ($objComments->addReply && $objComments->reply != '' && $objComments->authorName != '') {
                 $objPartial->addReply = true;
                 $objPartial->rby = $GLOBALS['TL_LANG']['MSC']['reply_by'];
                 $objPartial->reply = $this->replaceInsertTags($objComments->reply);
                 // Clean the RTE output
                 if ($objPage->outputFormat == 'xhtml') {
                     $objPartial->reply = $this->String->toXhtml($objPartial->reply);
                 } else {
                     $objPartial->reply = $this->String->toHtml5($objPartial->reply);
                 }
             }
             $arrComments[] = $objPartial->parse();
             ++$count;
         }
     }
     $objTemplate->comments = $arrComments;
     $objTemplate->addComment = $GLOBALS['TL_LANG']['MSC']['addComment'];
     $objTemplate->name = $GLOBALS['TL_LANG']['MSC']['com_name'];
     $objTemplate->email = $GLOBALS['TL_LANG']['MSC']['com_email'];
     $objTemplate->website = $GLOBALS['TL_LANG']['MSC']['com_website'];
     $objTemplate->commentsTotal = $limit ? $objTotal->count : $total;
     // Get the front end user object
     $this->import('FrontendUser', 'User');
     // Access control
     if ($objConfig->requireLogin && !BE_USER_LOGGED_IN && !FE_USER_LOGGED_IN) {
         $objTemplate->requireLogin = true;
         return;
     }
     // Form fields
     $arrFields = array('name' => array('name' => 'name', 'label' => $GLOBALS['TL_LANG']['MSC']['com_name'], 'value' => trim($this->User->firstname . ' ' . $this->User->lastname), 'inputType' => 'text', 'eval' => array('mandatory' => true, 'maxlength' => 64)), 'email' => array('name' => 'email', 'label' => $GLOBALS['TL_LANG']['MSC']['com_email'], 'value' => $this->User->email, 'inputType' => 'text', 'eval' => array('rgxp' => 'email', 'mandatory' => true, 'maxlength' => 128, 'decodeEntities' => true)), 'website' => array('name' => 'website', 'label' => $GLOBALS['TL_LANG']['MSC']['com_website'], 'inputType' => 'text', 'eval' => array('rgxp' => 'url', 'maxlength' => 128, 'decodeEntities' => true)));
     // Captcha
     if (!$objConfig->disableCaptcha) {
         $arrFields['captcha'] = array('name' => 'captcha', 'inputType' => 'captcha', 'eval' => array('mandatory' => true));
     }
     // Comment field
     $arrFields['comment'] = array('name' => 'comment', 'label' => $GLOBALS['TL_LANG']['MSC']['com_comment'], 'inputType' => 'textarea', 'eval' => array('mandatory' => true, 'rows' => 4, 'cols' => 40, 'preserveTags' => true));
     $doNotSubmit = false;
     $arrWidgets = array();
     $strFormId = 'com_' . $strSource . '_' . $intParent;
     // Initialize widgets
     foreach ($arrFields as $arrField) {
         $strClass = $GLOBALS['TL_FFL'][$arrField['inputType']];
         // Continue if the class is not defined
         if (!$this->classFileExists($strClass)) {
             continue;
         }
         $arrField['eval']['required'] = $arrField['eval']['mandatory'];
         $objWidget = new $strClass($this->prepareForWidget($arrField, $arrField['name'], $arrField['value']));
         // Validate the widget
         if ($this->Input->post('FORM_SUBMIT') == $strFormId) {
             $objWidget->validate();
             if ($objWidget->hasErrors()) {
                 $doNotSubmit = true;
             }
         }
         $arrWidgets[$arrField['name']] = $objWidget;
     }
     $objTemplate->fields = $arrWidgets;
     $objTemplate->submit = $GLOBALS['TL_LANG']['MSC']['com_submit'];
     $objTemplate->action = ampersand($this->Environment->request);
     $objTemplate->messages = '';
     // Backwards compatibility
     $objTemplate->formId = $strFormId;
     $objTemplate->hasError = $doNotSubmit;
     // Do not index or cache the page with the confirmation message
     if ($_SESSION['TL_COMMENT_ADDED']) {
         global $objPage;
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         $objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['com_confirm'];
         $_SESSION['TL_COMMENT_ADDED'] = false;
     }
     // Add the comment
     if ($this->Input->post('FORM_SUBMIT') == $strFormId && !$doNotSubmit) {
         $this->import('String');
         $strWebsite = $arrWidgets['website']->value;
         // Add http:// to the website
         if ($strWebsite != '' && !preg_match('@^(https?://|ftp://|mailto:|#)@i', $strWebsite)) {
             $strWebsite = 'http://' . $strWebsite;
         }
         // Do not parse any tags in the comment
         $strComment = htmlspecialchars(trim($arrWidgets['comment']->value));
         $strComment = str_replace(array('&amp;', '&lt;', '&gt;'), array('[&]', '[lt]', '[gt]'), $strComment);
         // Remove multiple line feeds
         $strComment = preg_replace('@\\n\\n+@', "\n\n", $strComment);
         // Parse BBCode
         if ($objConfig->bbcode) {
             $strComment = $this->parseBbCode($strComment);
         }
         // Prevent cross-site request forgeries
         $strComment = preg_replace('/(href|src|on[a-z]+)="[^"]*(contao\\/main\\.php|typolight\\/main\\.php|javascript|vbscri?pt|script|alert|document|cookie|window)[^"]*"+/i', '$1="#"', $strComment);
         $time = time();
         // Prepare the record
         $arrSet = array('source' => $strSource, 'parent' => $intParent, 'tstamp' => $time, 'name' => $arrWidgets['name']->value, 'email' => $arrWidgets['email']->value, 'website' => $strWebsite, 'comment' => $this->convertLineFeeds($strComment), 'ip' => $this->anonymizeIp($this->Environment->ip), 'date' => $time, 'published' => $objConfig->moderate ? '' : 1);
         $insertId = $this->Database->prepare("INSERT INTO tl_comments %s")->set($arrSet)->execute()->insertId;
         // HOOK: add custom logic
         if (isset($GLOBALS['TL_HOOKS']['addComment']) && is_array($GLOBALS['TL_HOOKS']['addComment'])) {
             foreach ($GLOBALS['TL_HOOKS']['addComment'] as $callback) {
                 $this->import($callback[0]);
                 $this->{$callback}[0]->{$callback}[1]($insertId, $arrSet, $this);
             }
         }
         // Notification
         $objEmail = new Email();
         $objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
         $objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
         $objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['com_subject'], $this->Environment->host);
         // Convert the comment to plain text
         $strComment = strip_tags($strComment);
         $strComment = $this->String->decodeEntities($strComment);
         $strComment = str_replace(array('[&]', '[lt]', '[gt]'), array('&', '<', '>'), $strComment);
         // Add comment details
         $objEmail->text = sprintf($GLOBALS['TL_LANG']['MSC']['com_message'], $arrSet['name'] . ' (' . $arrSet['email'] . ')', $strComment, $this->Environment->base . $this->Environment->request, $this->Environment->base . 'contao/main.php?do=comments&act=edit&id=' . $insertId);
         // Do not send notifications twice
         if (is_array($arrNotifies)) {
             $arrNotifies = array_unique($arrNotifies);
         }
         $objEmail->sendTo($arrNotifies);
         // Pending for approval
         if ($objConfig->moderate) {
             $_SESSION['TL_COMMENT_ADDED'] = true;
         }
         $this->reload();
     }
 }
Example #26
0
	/**
	 * Parse one or more items and return them as array
	 * @param Database_Result
	 * @param boolean
	 * @return array
	 */
	protected function parseArticles(Database_Result $objArticles, $blnAddArchive=false)
	{
		if ($objArticles->numRows < 1)
		{
			return array();
		}

		global $objPage;
		$this->import('String');

		$arrArticles = array();
		$limit = $objArticles->numRows;
		$count = 0;
		$imgSize = false;

		// Override the default image size
		if ($this->imgSize != '')
		{
			$size = deserialize($this->imgSize);

			if ($size[0] > 0 || $size[1] > 0)
			{
				$imgSize = $this->imgSize;
			}
		}

		while ($objArticles->next())
		{
			$objTemplate = new FrontendTemplate($this->news_template);
			$objTemplate->setData($objArticles->row());

			$objTemplate->count = ++$count;
			$objTemplate->class = (($objArticles->cssClass != '') ? ' ' . $objArticles->cssClass : '') . (($count == 1) ? ' first' : '') . (($count == $limit) ? ' last' : '') . ((($count % 2) == 0) ? ' odd' : ' even');
			$objTemplate->newsHeadline = $objArticles->headline;
			$objTemplate->subHeadline = $objArticles->subheadline;
			$objTemplate->hasSubHeadline = $objArticles->subheadline ? true : false;
			$objTemplate->linkHeadline = $this->generateLink($objArticles->headline, $objArticles, $blnAddArchive);
			$objTemplate->more = $this->generateLink($GLOBALS['TL_LANG']['MSC']['more'], $objArticles, $blnAddArchive, true);
			$objTemplate->link = $this->generateNewsUrl($objArticles, $blnAddArchive);
			$objTemplate->archive = $objArticles->archive;

			// Clean the RTE output
			if ($objArticles->teaser != '')
			{
				if ($objPage->outputFormat == 'xhtml')
				{
					$objArticles->teaser = $this->String->toXhtml($objArticles->teaser);
				}
				else
				{
					$objArticles->teaser = $this->String->toHtml5($objArticles->teaser);
				}

				$objTemplate->teaser = $this->String->encodeEmail($objArticles->teaser);
			}

			// Display the "read more" button for external/article links
			if (($objArticles->source == 'external' || $objArticles->source == 'article') && $objArticles->text == '')
			{
				$objTemplate->text = true;
			}

			// Encode e-mail addresses
			else
			{
				// Clean the RTE output
				if ($objPage->outputFormat == 'xhtml')
				{
					$objArticles->text = $this->String->toXhtml($objArticles->text);
				}
				else
				{
					$objArticles->text = $this->String->toHtml5($objArticles->text);
				}

				$objTemplate->text = $this->String->encodeEmail($objArticles->text);
			}

			$arrMeta = $this->getMetaFields($objArticles);

			// Add meta information
			$objTemplate->date = $arrMeta['date'];
			$objTemplate->hasMetaFields = !empty($arrMeta);
			$objTemplate->numberOfComments = $arrMeta['ccount'];
			$objTemplate->commentCount = $arrMeta['comments'];
			$objTemplate->timestamp = $objArticles->date;
			$objTemplate->author = $arrMeta['author'];
			$objTemplate->datetime = date('Y-m-d\TH:i:sP', $objArticles->date);

			$objTemplate->addImage = false;

			// Add an image
			if ($objArticles->addImage && is_file(TL_ROOT . '/' . $objArticles->singleSRC))
			{
				if ($imgSize)
				{
					$objArticles->size = $imgSize;
				}

				$this->addImageToTemplate($objTemplate, $objArticles->row());
			}

			$objTemplate->enclosure = array();

			// Add enclosures
			if ($objArticles->addEnclosure)
			{
				$this->addEnclosuresToTemplate($objTemplate, $objArticles->row());
			}

			// HOOK: add custom logic
			if (isset($GLOBALS['TL_HOOKS']['parseArticles']) && is_array($GLOBALS['TL_HOOKS']['parseArticles']))
			{
				foreach ($GLOBALS['TL_HOOKS']['parseArticles'] as $callback)
				{
					$this->import($callback[0]);
					$this->$callback[0]->$callback[1]($objTemplate, $objArticles->row(), $this);
				}
			}

			$arrArticles[] = $objTemplate->parse();
		}

		return $arrArticles;
	}
Example #27
0
 /**
  * Insert a template
  *
  * @param string $name The template name
  * @param array  $data An optional data array
  */
 public function insert($name, array $data = null)
 {
     if ($this instanceof Template) {
         $tpl = new static($name);
     } elseif (TL_MODE == 'BE') {
         $tpl = new \BackendTemplate($name);
     } else {
         $tpl = new \FrontendTemplate($name);
     }
     if ($data !== null) {
         $tpl->setData($data);
     }
     echo $tpl->parse();
 }
 /**
  * getArticle hook
  *
  * insert custom template when
  * getArticle hook is called
  *
  */
 public function insertCustomTemplate($tpl, $data, $article)
 {
     global $objPage;
     $layoutID = $objPage->layout;
     $objLayout = \LayoutModel::findByID($layoutID);
     if ($objLayout->activateCArticles) {
         $template = new \FrontendTemplate('mod_customarticle');
         $count = count($tpl->elements);
         $containertype = 'container';
         $article_color = \Contao\StringUtil::deserialize($tpl->article_color);
         $article_width = \Contao\StringUtil::deserialize($tpl->article_width);
         $article_minheight = \Contao\StringUtil::deserialize($tpl->article_minheight);
         $article_image = $tpl->article_image;
         $article_image_position = $tpl->article_image_position;
         $article_image_repeat = $tpl->article_image_repeat;
         $article_image_cover = $tpl->article_image_cover;
         $article_image_fixed = $tpl->article_image_fixed;
         $inner_article_width = \Contao\StringUtil::deserialize($tpl->inner_article_width);
         $inner_article_space = $tpl->inner_article_space;
         $inner_article_overflow = $tpl->inner_article_overflow;
         $inner_article_color = \Contao\StringUtil::deserialize($tpl->inner_article_color);
         $inner_article_float = $tpl->inner_article_float;
         $inner_article_minheight = \Contao\StringUtil::deserialize($tpl->inner_article_minheight);
         if ($tpl->article_visible != '') {
             $tmpclasses = $article->cssID;
             $article_visible = @unserialize($tpl->article_visible);
             if ($article_visible === 'b:0;' || $article_visible !== false) {
                 foreach (\Contao\StringUtil::deserialize($tpl->article_hidden) as $key => $value) {
                     $tmpclasses[1] .= ' ' . $value;
                 }
             } else {
                 $tmpclasses[1] .= ' ' . $tpl->article_visible;
             }
             $article->cssID = $tmpclasses;
         }
         if ($tpl->article_hidden != '') {
             $tmpclasses = $article->cssID;
             $article_hidden = @unserialize($tpl->article_hidden);
             if ($article_hidden === 'b:0;' || $article_hidden !== false) {
                 foreach (\Contao\StringUtil::deserialize($tpl->article_hidden) as $key => $value) {
                     $tmpclasses[1] .= ' ' . $value;
                 }
             } else {
                 $tmpclasses[1] .= ' ' . $tpl->article_hidden;
             }
             $article->cssID = $tmpclasses;
         }
         $customstyle = ".mod_article.customarticle_{$tpl->id} { ";
         if (isset($article_width['value']) && $article_width['value'] != '') {
             if ($article_width['value'] == 100 && $article_width['unit'] == "%") {
                 $containertype = 'container-fluid';
             } else {
                 $containertype = 'container';
             }
             $customstyle .= "width:" . $article_width['value'] . $article_width['unit'] . " !important;";
             $customstyle .= "max-width:" . $article_width['value'] . $article_width['unit'] . " !important;";
         }
         if (isset($article_minheight['value']) && $article_minheight['value'] != '') {
             $customstyle .= "min-height:" . $article_minheight['value'] . $article_minheight['unit'] . " !important;";
         }
         if (isset($article_color[0]) && $article_color[0] != '') {
             $customstyle .= "background-color:" . $this->cHex2rgba($article_color[0], $article_color[1]) . " !important;";
         }
         if (isset($article_image) && $article_image != '') {
             $customstyle .= "background-image:url('" . $article_image . "') !important;";
         }
         if (isset($article_image_repeat) && $article_image_repeat != '') {
             $customstyle .= "background-repeat:" . $article_image_repeat . " !important;";
         }
         if (isset($article_image_position) && $article_image_position != '') {
             $customstyle .= "background-position:" . $article_image_position . " !important;";
         }
         if ($article_image_cover) {
             $customstyle .= "\n\t\t\t\t\t\t-webkit-background-size: cover;\n\t\t\t\t\t\t-moz-background-size: cover;\n\t\t\t\t\t\t-o-background-size: cover;\n\t\t\t\t\t\tbackground-size: cover;\n\t\t\t\t\t\tfilter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src={$img}-uri, sizingMethod='scale');\n\t\t\t\t\t\t-ms-filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src={$img}-uri, sizingMethod='scale') !important;";
             if ($article_image_fixed) {
                 $customstyle .= "background-attachment: fixed";
             } else {
                 $customstyle .= "background-attachment: initial";
             }
         }
         $customstyle .= "\t}";
         $customstyle .= ".mod_article.customarticle_{$tpl->id} .outer { ";
         if (isset($inner_article_color[0]) && $inner_article_color[0] != '') {
             $customstyle .= "background-color:" . $this->cHex2rgba($inner_article_color[0], $inner_article_color[1]) . " !important;";
         }
         if (isset($inner_article_width['value']) && $inner_article_width['value'] != '') {
             $customstyle .= "width:" . $inner_article_width['value'] . $inner_article_width['unit'] . " !important;";
             $customstyle .= "max-width:" . $inner_article_width['value'] . $inner_article_width['unit'] . " !important;";
         }
         if (isset($inner_article_height['value']) && $inner_article_height['value'] != '') {
             $customstyle .= "min-height:" . $inner_article_height['value'] . $inner_article_height['unit'] . " !important;";
         }
         $customstyle .= "\t}";
         $customstyle .= ".mod_article.customarticle_{$tpl->id} .inner { ";
         if (isset($inner_article_space) && $inner_article_space != '') {
             if ($inner_article_space == 'top_spaceing') {
                 $customstyle .= "padding-bottom:0 !important;";
             }
             if ($inner_article_space == 'bottom_spaceing') {
                 $customstyle .= "padding-top:0 !important;";
             }
             if ($inner_article_space == 'no_spaceing') {
                 $customstyle .= "padding-bottom:0 !important;";
                 $customstyle .= "padding-top:0 !important;";
             }
         }
         if (isset($inner_article_overflow) && $inner_article_overflow != '') {
             if ($inner_article_overflow == 'overflow_hidden') {
                 $customstyle .= "overflow:hidden !important;";
             }
             if ($inner_article_overflow == 'overflow_visible') {
                 $customstyle .= "overflow:visible !important;";
             }
         }
         $customstyle .= "\t}";
         $tpl->customstyle = $customstyle;
         $tpl->gridcount = $count;
         $tpl->containertype = $containertype;
         $template->setData($tpl->getData());
         $article->Template = $template;
     }
 }
 protected function generatePrivacy()
 {
     $objTemplate = new \FrontendTemplate($this->getConfigData('youtubeprivacy_template') != '' ? $this->getConfigData('youtubeprivacy_template') : static::$strPrivacyTemplate);
     $objTemplate->setData($GLOBALS['TL_LANG']['MSC']['youtube']['privacy']);
     $objTemplate->autoLabel = sprintf($objTemplate->autoLabel, \Environment::get('host'));
     return $objTemplate->parse();
 }
Example #30
0
 /**
  * Add comments to a template
  *
  * @param \FrontendTemplate|object $objTemplate
  * @param \stdClass                $objConfig
  * @param string                   $strSource
  * @param integer                  $intParent
  * @param mixed                    $varNotifies
  */
 public function addCommentsToTemplate(\FrontendTemplate $objTemplate, \stdClass $objConfig, $strSource, $intParent, $varNotifies)
 {
     /** @var \PageModel $objPage */
     global $objPage;
     $limit = 0;
     $offset = 0;
     $total = 0;
     $gtotal = 0;
     $arrComments = array();
     $objTemplate->comments = array();
     // see #4064
     // Pagination
     if ($objConfig->perPage > 0) {
         // Get the total number of comments
         $intTotal = \CommentsModel::countPublishedBySourceAndParent($strSource, $intParent);
         $total = $gtotal = $intTotal;
         // Calculate the key (e.g. tl_form_field becomes page_cff12)
         $key = '';
         $chunks = explode('_', substr($strSource, strncmp($strSource, 'tl_', 3) === 0 ? 3 : 0));
         foreach ($chunks as $chunk) {
             $key .= substr($chunk, 0, 1);
         }
         // Get the current page
         $id = 'page_c' . $key . $intParent;
         // see #4141
         $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 / $objConfig->perPage), 1)) {
             /** @var \PageError404 $objHandler */
             $objHandler = new $GLOBALS['TL_PTY']['error_404']();
             $objHandler->generate($objPage->id);
         }
         // Set limit and offset
         $limit = $objConfig->perPage;
         $offset = ($page - 1) * $objConfig->perPage;
         // Initialize the pagination menu
         $objPagination = new \Pagination($total, $objConfig->perPage, \Config::get('maxPaginationLinks'), $id);
         $objTemplate->pagination = $objPagination->generate("\n  ");
     }
     $objTemplate->allowComments = true;
     // Get all published comments
     if ($limit) {
         $objComments = \CommentsModel::findPublishedBySourceAndParent($strSource, $intParent, $objConfig->order == 'descending', $limit, $offset);
     } else {
         $objComments = \CommentsModel::findPublishedBySourceAndParent($strSource, $intParent, $objConfig->order == 'descending');
     }
     // Parse the comments
     if ($objComments !== null && ($total = $objComments->count()) > 0) {
         $count = 0;
         if ($objConfig->template == '') {
             $objConfig->template = 'com_default';
         }
         /** @var \FrontendTemplate|object $objPartial */
         $objPartial = new \FrontendTemplate($objConfig->template);
         while ($objComments->next()) {
             $objPartial->setData($objComments->row());
             // Clean the RTE output
             if ($objPage->outputFormat == 'xhtml') {
                 $objPartial->comment = \StringUtil::toXhtml($objComments->comment);
             } else {
                 $objPartial->comment = \StringUtil::toHtml5($objComments->comment);
             }
             $objPartial->comment = trim(str_replace(array('{{', '}}'), array('&#123;&#123;', '&#125;&#125;'), $objPartial->comment));
             $objPartial->datim = \Date::parse($objPage->datimFormat, $objComments->date);
             $objPartial->date = \Date::parse($objPage->dateFormat, $objComments->date);
             $objPartial->class = ($count < 1 ? ' first' : '') . ($count >= $total - 1 ? ' last' : '') . ($count % 2 == 0 ? ' even' : ' odd');
             $objPartial->by = $GLOBALS['TL_LANG']['MSC']['com_by'];
             $objPartial->id = 'c' . $objComments->id;
             $objPartial->timestamp = $objComments->date;
             $objPartial->datetime = date('Y-m-d\\TH:i:sP', $objComments->date);
             $objPartial->addReply = false;
             // Reply
             if ($objComments->addReply && $objComments->reply != '') {
                 if (($objAuthor = $objComments->getRelated('author')) !== null) {
                     $objPartial->addReply = true;
                     $objPartial->rby = $GLOBALS['TL_LANG']['MSC']['com_reply'];
                     $objPartial->reply = $this->replaceInsertTags($objComments->reply);
                     $objPartial->author = $objAuthor;
                     // Clean the RTE output
                     if ($objPage->outputFormat == 'xhtml') {
                         $objPartial->reply = \StringUtil::toXhtml($objPartial->reply);
                     } else {
                         $objPartial->reply = \StringUtil::toHtml5($objPartial->reply);
                     }
                 }
             }
             $arrComments[] = $objPartial->parse();
             ++$count;
         }
     }
     $objTemplate->comments = $arrComments;
     $objTemplate->addComment = $GLOBALS['TL_LANG']['MSC']['addComment'];
     $objTemplate->name = $GLOBALS['TL_LANG']['MSC']['com_name'];
     $objTemplate->email = $GLOBALS['TL_LANG']['MSC']['com_email'];
     $objTemplate->website = $GLOBALS['TL_LANG']['MSC']['com_website'];
     $objTemplate->commentsTotal = $limit ? $gtotal : $total;
     // Add a form to create new comments
     $this->renderCommentForm($objTemplate, $objConfig, $strSource, $intParent, $varNotifies);
 }