/** * Alter the "domain" key * * @return static The page model */ public function loadDetails() { parent::loadDetails(); // Return the current host if in dns list or the full dns list to have a domain restriction at all $this->domain = in_array(\Environment::get('host'), trimsplit(',', $this->domain)) ? \Environment::get('host') : $this->domain; return $this; }
/** * Compile format definitions and return them as string * @param array * @param boolean * @return string */ public function compileDefinition($row, $blnWriteToFile = false) { $this->import("StyleSheets"); $result = $this->StyleSheets->compileDefinition($row, $blnWriteToFile); if (preg_match("/>(.*?)\\{(.*?)\\}/is", $result, $matches)) { $attrib = $GLOBALS['TL_CONFIG']['showSingleStyles'] ? 'class' : 'style'; $styles = array_filter(trimsplit(";", $matches[2]), 'strlen'); $inline = array_filter($styles, 'removenastycss'); $names = trimsplit(",", $matches[1]); $result = ""; if (count($inline)) { $i = 1; $result .= '<div id="id' . $row['id'] . '">'; foreach ($names as $name) { $result .= '<div ' . $attrib . '="' . str_replace("\"", "", join($inline, '!important;')) . '">' . $name . ($i < count($names) ? ',' : '') . '</div>'; $i++; } $result .= '</div>'; } else { $i = 1; $result .= '<div id="id' . $row['id'] . '">'; foreach ($names as $name) { $result .= '<div>' . $name . ($i < count($names) ? ',' : '') . '</div>'; $i++; } $result .= '</div>'; } $result .= '<pre>{' . "\n " . join($styles, "\n ") . "\n}</pre>"; $result = str_replace("!important!important", "!important", $result); } return $result; }
/** * Display a wildcard in the back end * * @return string */ public function generate() { if (TL_MODE == 'BE') { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['rss_reader'][0]) . ' ###'; $objTemplate->title = $this->headline; $objTemplate->id = $this->id; $objTemplate->link = $this->name; $objTemplate->href = '' . $GLOBALS['TL_CONFIG']['backendPath'] . '/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; return $objTemplate->parse(); } $this->objFeed = new \SimplePie(); $arrUrls = trimsplit('[\\n\\t ]', trim($this->rss_feed)); if (count($arrUrls) > 1) { $this->objFeed->set_feed_url($arrUrls); } else { $this->objFeed->set_feed_url($arrUrls[0]); } $this->objFeed->set_output_encoding(\Config::get('characterSet')); $this->objFeed->set_cache_location(TL_ROOT . '/system/tmp'); $this->objFeed->enable_cache(false); if ($this->rss_cache > 0) { $this->objFeed->enable_cache(true); $this->objFeed->set_cache_duration($this->rss_cache); } if (!$this->objFeed->init()) { $this->log('Error importing RSS feed "' . $this->rss_feed . '"', __METHOD__, TL_ERROR); return ''; } $this->objFeed->handle_content_type(); return parent::generate(); }
/** * Return if the file does not exist * * @return string */ public function generate() { // Return if there is no file if ($this->singleSRC == '') { return ''; } $objFile = \FilesModel::findByUuid($this->singleSRC); if ($objFile === null) { if (!\Validator::isUuid($this->singleSRC)) { return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } return ''; } $allowedDownload = trimsplit(',', strtolower(\Config::get('allowedDownload'))); // Return if the file type is not allowed if (!in_array($objFile->extension, $allowedDownload)) { return ''; } $file = \Input::get('file', true); // Send the file to the browser and do not send a 404 header (see #4632) if ($file != '' && $file == $objFile->path) { \Controller::sendFileToBrowser($file); } $this->singleSRC = $objFile->path; return parent::generate(); }
/** * Check the Isotope config directory for a particular template * @param string * @return string * @throws Exception */ protected function getTemplate($strTemplate, $strFormat = 'html5') { $arrAllowed = trimsplit(',', $GLOBALS['TL_CONFIG']['templateFiles']); if (is_array($GLOBALS['TL_CONFIG']['templateFiles']) && !in_array($strFormat, $arrAllowed)) { throw new Exception("Invalid output format {$strFormat}"); } $strKey = $strTemplate . '.' . $strFormat; $strPath = TL_ROOT . '/templates'; $strTemplate = basename($strTemplate); // Check the templates subfolder if (TL_MODE == 'FE') { global $objPage; $strTemplateGroup = str_replace(array('../', 'templates/'), '', $this->Isotope->Config->templateGroup); if ($strTemplateGroup != '') { $strFile = $strPath . '/' . $strTemplateGroup . '/' . $strKey; if (file_exists($strFile)) { return $strFile; } // Also check for .tpl files (backwards compatibility) $strFile = $strPath . '/' . $strTemplateGroup . '/' . $strTemplate . '.tpl'; if (file_exists($strFile)) { return $strFile; } } } return parent::getTemplate($strTemplate, $strFormat); }
/** * Return if the file does not exist * @return string */ public function generate() { // Return if there is no file if ($this->singleSRC == '') { return ''; } // Check for version 3 format if (!is_numeric($this->singleSRC)) { return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } $objFile = \FilesModel::findByPk($this->singleSRC); if ($objFile === null) { return ''; } $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload'])); // Return if the file type is not allowed if (!in_array($objFile->extension, $allowedDownload)) { return ''; } $file = \Input::get('file', true); // Send the file to the browser and do not send a 404 header (see #4632) if ($file != '' && $file == $objFile->path) { $this->sendFileToBrowser($file); } $this->singleSRC = $objFile->path; return parent::generate(); }
/** * Generate array representation for download * * @param bool $blnOrderPaid * * @return array */ public function getForTemplate($blnOrderPaid = false) { global $objPage; $objDownload = $this->getRelated('download_id'); if (null === $objDownload) { return array(); } $arrDownloads = array(); $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload'])); foreach ($objDownload->getFiles() as $objFileModel) { $objFile = new \File($objFileModel->path, true); if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) { continue; } // Send file to the browser if ($blnOrderPaid && $this->canDownload() && \Input::get('download') == $objDownload->id && \Input::get('file') == $objFileModel->path) { $this->download($objFileModel->path); } $arrMeta = \Frontend::getMetaData($objFileModel->meta, $objPage->language); // Use the file name as title if none is given if ($arrMeta['title'] == '') { $arrMeta['title'] = specialchars(str_replace('_', ' ', preg_replace('/^[0-9]+_/', '', $objFile->filename))); } $strHref = ''; if (TL_MODE == 'FE') { $strHref = \Haste\Util\Url::addQueryString('download=' . $objDownload->id . '&file=' . $objFileModel->path); } // Add the image $arrDownloads[] = array('id' => $this->id, 'name' => $objFile->basename, 'title' => $arrMeta['title'], 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => \System::getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname, 'remaining' => $objDownload->downloads_allowed > 0 ? sprintf($GLOBALS['TL_LANG']['MSC']['downloadsRemaining'], intval($this->downloads_remaining)) : '', 'downloadable' => $blnOrderPaid && $this->canDownload()); } return $arrDownloads; }
/** * Generate media attribute * * @param \Isotope\Interfaces\IsotopeProduct $objProduct * @param array $arrOptions * @return string */ public function generate(IsotopeProduct $objProduct, array $arrOptions = array()) { $strPoster = null; $arrFiles = deserialize($objProduct->{$this->field_name}, true); // Return if there are no files if (empty($arrFiles) || !is_array($arrFiles)) { return ''; } // Get the file entries from the database $objFiles = \FilesModel::findMultipleByIds($arrFiles); if (null === $objFiles) { return ''; } // Find poster while ($objFiles->next()) { if (in_array($objFiles->extension, trimsplit(',', $GLOBALS['TL_CONFIG']['validImageTypes']))) { $strPoster = $objFiles->uuid; $arrFiles = array_diff($arrFiles, array($objFiles->uuid)); } } $objContentModel = new \ContentModel(); $objContentModel->type = 'media'; $objContentModel->cssID = serialize(array('', $this->field_name)); $objContentModel->playerSRC = serialize($arrFiles); $objContentModel->posterSRC = $strPoster; if ($arrOptions['autoplay']) { $objContentModel->autoplay = '1'; } if ($arrOptions['width'] || $arrOptions['height']) { $objContentModel->playerSize = serialize(array($arrOptions['width'], $arrOptions['height'])); } $objElement = new \ContentMedia($objContentModel); return $objElement->generate(); }
/** * Run the controller */ public function run() { // Cancel if shop has not yet been installed if (!$this->Database->tableExists('tl_iso_config') && !$this->Database->tableExists('tl_store')) { return; } $this->exec('createIsotopeFolder'); $this->exec('renameTables'); $this->exec('renameFields'); $this->exec('updateStoreConfigurations'); $this->exec('updateOrders'); $this->exec('updateImageSizes'); $this->exec('updateAttributes'); $this->exec('updateFrontendModules'); $this->exec('updateFrontendTemplates'); $this->exec('updateProductTypes'); $this->exec('updateRules'); $this->exec('generateCategoryGroups'); $this->exec('refreshDatabaseFile'); // Make sure file extension .imt (Isotope Mail Template) is allowed for up- and download if (!in_array('imt', trimsplit(',', $GLOBALS['TL_CONFIG']['uploadTypes']))) { $this->Config->update('$GLOBALS[\'TL_CONFIG\'][\'uploadTypes\']', $GLOBALS['TL_CONFIG']['uploadTypes'] . ',imt'); } // Just make sure no variant or translation has any categories assigned $this->Database->query("DELETE FROM tl_iso_product_categories WHERE pid IN (SELECT id FROM tl_iso_products WHERE pid>0)"); // Delete caches $this->Database->query("TRUNCATE TABLE tl_iso_productcache"); $this->Database->query("TRUNCATE TABLE tl_iso_requestcache"); }
public function cb_parseTemplate(\Template &$objTemplate) { global $objPage; if (strpos($objTemplate->getName(), 'news_') === 0) { if ($objTemplate->source == 'singlefile') { $modelFile = \FilesModel::findByUuid($objTemplate->singlefileSRC); try { if ($modelFile === null) { throw new \Exception("no file"); } $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload'])); if (!in_array($modelFile->extension, $allowedDownload)) { throw new Exception("download not allowed by extension"); } $objFile = new \File($modelFile->path, true); $strHref = \System::urlEncode($objFile->value); } catch (\Exception $e) { $strHref = ""; } $target = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"'; $objTemplate->more = sprintf('<a %s href="%s" title="%s">%s</a>', $target, $strHref, specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['open'], $objFile->basename)), $GLOBALS['TL_LANG']['MSC']['more']); $objTemplate->linkHeadline = sprintf('<a %s href="%s" title="%s">%s</a>', $target, $strHref, specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['open'], $objFile->basename)), $objTemplate->headline); } } }
protected function getSliderConfig($arrConfig = array()) { if (!is_array($arrConfig)) { $arrConfig = array(); } $arrDefaults = array('id' => 'slider-' . $this->strName, 'min' => 0, 'max' => 10, 'step' => 1, 'precision' => 0, 'orientation' => 'horizontal', 'value' => 5, 'range' => false, 'selection' => 'before', 'tooltip' => 'show', 'tooltip_split' => false, 'handle' => 'round', 'reversed' => false, 'enabled' => true, 'natural_arrow_keys' => false, 'ticks' => array(), 'ticks_positions' => array(), 'ticks_labels' => array(), 'ticks_snap_bounds' => 0, 'scale' => 'linear', 'focus' => false, 'labelledby' => null, 'rangeLabels' => array('min' => array('mode' => 'sync', 'prefix' => '', 'suffix' => ''), 'max' => array('mode' => 'sync', 'prefix' => '', 'suffix' => ''))); $arrConfig = array_merge($arrDefaults, $arrConfig); $min = $arrConfig['min']; $max = $arrConfig['max']; if ($this->varValue) { $arrConfig['value'] = $this->varValue; $arrRange = trimsplit(',', $this->varValue); $max = $this->varValue; if (is_array($arrRange) && count($arrRange) > 1) { if ($arrConfig['range'] == true) { $arrConfig['value'] = $arrRange; $min = $arrRange[0]; $max = $arrRange[1]; } else { $max = $arrRange[1]; $arrConfig['value'] = $arrRange[1]; } } } foreach ($arrConfig as $key => $varValue) { switch ($key) { case 'min_callback': $arrConfig['min'] = $this->getConfigValue($varValue); break; case 'max_callback': $arrConfig['max'] = $this->getConfigValue($varValue); break; case 'value_callback': $arrConfig['value'] = $this->getConfigValue($varValue); break; case 'step_callback': $arrConfig['step'] = $this->getConfigValue($varValue); break; case 'rangeLabels': if (!is_array($arrConfig['rangeLabels'])) { unset($arrConfig['rangeLabels']); break; } if (isset($arrConfig['rangeLabels']['min'])) { $this->minRangeLabel = sprintf('<span id="%s" class="slider-label-from"%s>%s<span class="value">%s</span>%s</span>', $arrConfig['id'] . '-label-from', $arrConfig['rangeLabels']['min']['mode'] == 'sync' ? ' data-sync="true"' : '', $arrConfig['rangeLabels']['min']['prefix'] ? '<span class="prefix">' . $arrConfig['rangeLabels']['min']['prefix'] . '</span>' : '', $min, $arrConfig['rangeLabels']['min']['suffix'] ? '<span class="suffix">' . $arrConfig['rangeLabels']['min']['suffix'] . '</span>' : ''); $arrConfig['range-label-from'] = '#' . $arrConfig['id'] . '-label-from'; } if (isset($arrConfig['rangeLabels']['max'])) { $this->maxRangeLabel = sprintf('<span id="%s" class="slider-label-to"%s>%s<span class="value">%s</span>%s</span>', $arrConfig['id'] . '-label-to', $arrConfig['rangeLabels']['max']['mode'] == 'sync' ? ' data-sync="true"' : '', $arrConfig['rangeLabels']['max']['prefix'] ? '<span class="prefix">' . $arrConfig['rangeLabels']['max']['prefix'] . '</span>' : '', $max, $arrConfig['rangeLabels']['max']['suffix'] ? '<span class="suffix">' . $arrConfig['rangeLabels']['max']['suffix'] . '</span>' : ''); $arrConfig['range-label-to'] = '#' . $arrConfig['id'] . '-label-to'; } unset($arrConfig['rangeLabels']); break; default: $arrConfig[$key] = $varValue; break; } } return $arrConfig; }
/** * {@inheritdoc} */ protected function build(Definition $definition, \Model $model, DefinitionMapper $mapper, Filter $filter = null, Definition $parent = null) { parent::build($definition, $model, $mapper, $filter, $parent); /** @var Popup $definition */ /** @var PopupModel $model */ $this->deserializePoint('offset', $definition, $model); if ($model->autoPan) { $padding = array_map(function ($value) { return array_map('intval', trimsplit(',', $value)); }, deserialize($model->autoPanPadding, true)); if ($padding[0] === $padding[1]) { if (!empty($padding[0])) { $definition->setAutoPanPadding($padding[0]); } } else { if ($padding[0]) { $definition->setAutoPanPaddingTopLeft($padding[0]); } if ($padding[1]) { $definition->setAutoPanPaddingBottomRight($padding[1]); } } } if (!$model->closeOnClick) { $definition->setCloseOnClick(false); } }
/** * Display a wildcard in the back end * @return string */ public function generate() { if (TL_MODE == 'BE') { $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### RSS READER ###'; $objTemplate->title = $this->headline; $objTemplate->id = $this->id; $objTemplate->link = $this->name; $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; return $objTemplate->parse(); } $this->objFeed = new \SimplePie(); $arrUrls = trimsplit('[\\n\\t ]', trim($this->rss_feed)); if (count($arrUrls) > 1) { $this->objFeed->set_feed_url($arrUrls); } else { $this->objFeed->set_feed_url($arrUrls[0]); } $this->objFeed->set_output_encoding($GLOBALS['TL_CONFIG']['characterSet']); $this->objFeed->set_cache_location(TL_ROOT . '/system/tmp'); $this->objFeed->enable_cache(false); if ($this->rss_cache > 0) { $this->objFeed->enable_cache(true); $this->objFeed->set_cache_duration($this->rss_cache); } if (!$this->objFeed->init()) { $this->log('Error importing RSS feed "' . $this->rss_feed . '"', 'ModuleRssReader generate()', TL_ERROR); return ''; } $this->objFeed->handle_content_type(); return parent::generate(); }
/** * Replaces an insert tag with the record data from the table * Insert tags like {{tabledata::|field|::|table|::|parameterfield|::|urlparameter|}} * Insert tags for the fixed field 'id' like * {{tabledata::id::|table|::|parameterfield|::|urlparameter|}} * or {{tabledata::id::|table|::|parameterfield|::|urlparameter|::member::|memberfield|}} * or {{tabledata::id::|table|::|parameterfield|::|urlparameter|::groups::|groupsfield|::|groups like 1,2,3 or serialized|}} * * @param $strTag * @return bool|string */ public function replaceTag($strTag) { $arrTag = trimsplit('::', $strTag); // key 'tabledata' if ($arrTag[0] != 'tabledata') { // divert to other insert tags return false; } // get table record only if all parameters are present if (!$arrTag[1] || !$arrTag[2] || !$arrTag[3] || !$arrTag[4]) { // return empty string return ''; } // check if record is restricted to a member or a membergroup $isRestricted = $arrTag[1] == 'id' && ($arrTag[5] == 'member' || $arrTag[5] == 'groups') ? true : false; // get record data $objResult = Database::getInstance()->prepare("SELECT " . $arrTag[1] . ($isRestricted ? ',' . $arrTag[6] : '') . " FROM " . $arrTag[2] . " WHERE " . $arrTag[3] . "=?")->execute(Input::get($arrTag[4])); // no record found if (!$objResult->{$arrTag}[1]) { // if is id then return 404 page if ($arrTag[1] == 'id' && \Input::get('id')) { global $objPage; $objP = PageModel::find404ByPid($objPage->rootId); $this->redirect($this->generateFrontendUrl($objP->row())); } // else return empty string return ''; } // check if record is restricted to a member or a membergroup if ($isRestricted) { $isAllowed = false; // get frontend user $this->import('FrontendUser', 'User'); switch ($arrTag[5]) { // check for member groups - doesn't work in MetaModels etc. because of data in spread tables case 'groups': $arrGroups1 = deserialize($objResult->{$arrTag}[6]); $arrGroups1 = is_array($arrGroups1) ? $arrGroups1 : explode(',', $objResult->{$arrTag}[6]); $arrGroups1 = is_array($arrGroups1) ? !$arrGroups1[0] ? array() : $arrGroups1 : array(); $arrGroups2 = explode(',', $arrTag[7]); $arrGroups2 = is_array($arrGroups2) ? !$arrGroups2[0] ? array() : $arrGroups2 : array(); $isAllowed = FE_USER_LOGGED_IN && count(array_intersect($this->User->groups, array_intersect($arrGroups1, $arrGroups2))) > 0 ? true : false; break; // check for a member // check for a member default: $isAllowed = FE_USER_LOGGED_IN && $this->User->id == $objResult->{$arrTag}[6] ? true : false; break; } // record can't be loaded - redirect to the blank form if (!$isAllowed) { global $objPage; $this->redirect($this->generateFrontendUrl($objPage->row())); } } // pre-fill form field return $objResult->{$arrTag}[1]; }
/** * Return if the file does not exist * @return string */ public function generate() { $this->arrDownloadarchives = unserialize($this->downloadarchive); if ($this->downloadarchive != null && !is_array($this->arrDownloadarchives)) { $this->arrDownloadarchives = array($this->downloadarchive); } // Return if there are no categories if (count($this->arrDownloadarchives) < 1) { return ''; } if (TL_MODE == 'BE') { $title = array(); foreach ($this->arrDownloadarchives as $archive) { $objDownloadarchivee = \FelixPfeiffer\Downloadarchive\DownloadarchiveModel::findByPk($archive); $title[] = $objDownloadarchivee->title; } $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['downloadarchive'][0]) . ' - ' . implode(", ", $title) . ' ###'; return $objTemplate->parse(); } $this->checkForPublishedArchives(); $this->import('FrontendUser', 'User'); foreach ($this->arrDownloadarchives as $archive) { $objFiles = \FelixPfeiffer\Downloadarchive\DownloadarchiveitemsModel::findPublishedByPid($archive); if ($objFiles === null) { continue; } while ($objFiles->next()) { $objFile = \FilesModel::findByUuid($objFiles->singleSRC); if (!file_exists(TL_ROOT . '/' . $objFile->path) || $objFiles->guests && FE_USER_LOGGED_IN || $objFiles->protected == 1 && !FE_USER_LOGGED_IN && !BE_USER_LOGGED_IN) { continue; } $arrGroups = deserialize($objFiles->groups); if ($objFiles->protected == 1 && is_array($arrGroups) && count(array_intersect($this->User->groups, $arrGroups)) < 1 && !BE_USER_LOGGED_IN) { continue; } $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload'])); if (!in_array($objFile->extension, $allowedDownload)) { continue; } $arrFile = $objFiles->row(); $filename = $objFile->path; $arrFile['filename'] = $filename; $this->arrDownloadfiles[$archive][$filename] = $arrFile; } } $file = \Input::get('file', true); // Send the file to the browser and do not send a 404 header (see #4632) if ($file != '' && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', basename($file))) { foreach ($this->arrDownloadfiles as $k => $archive) { if (array_key_exists($file, $archive)) { \Controller::sendFileToBrowser($file); } } } return parent::generate(); }
/** * Convert the comma delimited value to a native MultiColumnWizard value * * @param string $varValue * @param \DataContainer $dc * * @return array The dns entries MCW adapted */ public function loadMultiDns($varValue, $dc) { $varValue = $dc->activeRecord->dns; $varValue = trimsplit(',', $varValue); $varValue = array_map(function ($entry) { return array('dns' => $entry); }, $varValue); return $varValue; }
/** * Exempt folders from the synchronisation (see #4522) * * @param \RecursiveIterator $iterator The iterator object */ public function __construct(\RecursiveIterator $iterator) { if (\Config::get('fileSyncExclude') != '') { $this->arrExempt = array_map(function ($e) { return \Config::get('uploadPath') . '/' . $e; }, trimsplit(',', \Config::get('fileSyncExclude'))); } parent::__construct($iterator); }
public static function doImportMember($strUsername, $arrSelectedLdapMemberGroups) { $objLdapUser = LdapMemberModel::findLdapMember($strUsername); $arrSkipUids = trimsplit(',', $GLOBALS['TL_CONFIG']['ldap_uid_skip']); // skip uids from config if (in_array($objLdapUser->uid[0], $arrSkipUids)) { return false; } // no null check necessary (already checked beforehands) LdapMemberModel::addMember($objLdapUser->givenname['count'] > 0 ? $objLdapUser->givenname[0] : '', $objLdapUser->sn['count'] > 0 ? $objLdapUser->sn[0] : '', $objLdapUser->uid['count'] > 0 ? $objLdapUser->uid[0] : '', $objLdapUser->mail['count'] > 0 ? $objLdapUser->mail[0] : '', $strUsername, LdapMemberGroupModel::getLocalMemberGroupIds(array_intersect(LdapMemberModel::getLdapMemberGroupsByUid($objLdapUser->uid[0]), $arrSelectedLdapMemberGroups)), $objLdapUser->c[0] ? strtolower($objLdapUser->c[0]) : 'de'); }
public function __construct($name) { parent::__construct(); $this->setName($name); $this->extensions = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['uploadTypes'])); $this->maxFileSize = $GLOBALS['TL_CONFIG']['maxFileSize']; $this->imageWidth = $GLOBALS['TL_CONFIG']['imageWidth']; $this->imageHeight = $GLOBALS['TL_CONFIG']['imageHeight']; $this->gdMaxImgWidth = $GLOBALS['TL_CONFIG']['gdMaxImgWidth']; $this->gdMaxImgHeight = $GLOBALS['TL_CONFIG']['gdMaxImgHeight']; }
/** * Send the e-mail reminders */ public function sendEmailReminders() { $now = mktime(date('H'), 0, 0, 1, 1, 1970); $objCalendars = $this->Database->execute("SELECT * FROM tl_calendar WHERE subscription_reminders=1 AND ((subscription_time >= {$now}) AND (subscription_time <= {$now} + 3600))"); // Return if there are no calendars with subscriptions if (!$objCalendars->numRows) { return; } $intReminders = 0; $objToday = new \Date(); // Send the e-mails while ($objCalendars->next()) { $arrDays = array_map('intval', trimsplit(',', $objCalendars->subscription_days)); if (empty($arrDays)) { continue; } $arrWhere = array(); // Bulid a WHERE statement foreach ($arrDays as $intDay) { $objDateEvent = new \Date(strtotime('+' . $intDay . ' days')); $arrWhere[] = "((e.startTime BETWEEN " . $objDateEvent->dayBegin . " AND " . $objDateEvent->dayEnd . ") AND ((es.lastEmail = 0) OR (es.lastEmail NOT BETWEEN " . $objToday->dayBegin . " AND " . $objToday->dayEnd . ")))"; } $objSubscriptions = $this->Database->prepare("SELECT e.*, es.member FROM tl_calendar_events_subscriptions es JOIN tl_calendar_events e ON e.id=es.pid WHERE e.pid=?" . (!empty($arrWhere) ? " AND (" . implode(" OR ", $arrWhere) . ")" : ""))->execute($objCalendars->id); // Continue if there are no subscriptions to send if (!$objSubscriptions->numRows) { continue; } $arrWildcards = $this->generateWildcards($objCalendars->row(), 'calendar'); while ($objSubscriptions->next()) { // Get the member if it is not in cache if (!isset(self::$arrMembers[$objSubscriptions->member])) { $objMember = $this->Database->prepare("SELECT * FROM tl_member WHERE id=? AND email!=''")->limit(1)->execute($objSubscriptions->member); // Continue if member was not found if (!$objMember->numRows) { continue; } self::$arrMembers[$objSubscriptions->member] = $objMember->row(); } $arrWildcards = array_merge($arrWildcards, $this->generateWildcards($objSubscriptions->row(), 'event'), $this->generateWildcards(self::$arrMembers[$objSubscriptions->member], 'member')); // Generate an e-mail $objEmail = new \Email(); $objEmail->from = $GLOBALS['TL_ADMIN_EMAIL']; $objEmail->fromName = $GLOBALS['TL_ADMIN_NAME']; $objEmail->subject = \String::parseSimpleTokens($objCalendars->subscription_subject, $arrWildcards); $objEmail->text = \String::parseSimpleTokens($objCalendars->subscription_message, $arrWildcards); // Send an e-mail if ($objEmail->sendTo(self::$arrMembers[$objSubscriptions->member]['email'])) { $intReminders++; $this->Database->prepare("UPDATE tl_calendar_events_subscriptions SET lastEmail=? WHERE pid=? AND member=?")->execute(time(), $objSubscriptions->id, $objSubscriptions->member); } } } self::log('A total number of ' . $intReminders . ' event reminders have been sent', 'EventsSubscriptions sendEmailReminders()', TL_INFO); }
/** * Change the palette of the current table and switch to edit mode * @return string */ public function generate() { $this->import('BackendUser', 'User'); $GLOBALS['TL_DCA'][$this->table]['config']['closed'] = true; $GLOBALS['TL_DCA'][$this->table]['config']['enableVersioning'] = false; $GLOBALS['TL_DCA'][$this->table]['palettes'] = array('__selector__' => $GLOBALS['TL_DCA'][$this->table]['palettes']['__selector__'], 'default' => $GLOBALS['TL_DCA'][$this->table]['palettes']['login']); $arrFields = trimsplit('[,;]', $GLOBALS['TL_DCA'][$this->table]['palettes']['default']); foreach ($arrFields as $strField) { $GLOBALS['TL_DCA'][$this->table]['fields'][$strField]['exclude'] = false; } return $this->objDc->edit($this->User->id); }
/** * Parse news categories insert tags * * @param string $tag * * @return string|bool */ public function parseCategoriesTags($tag) { $chunks = trimsplit('::', $tag); if ($chunks[0] === 'news_categories') { $className = \NewsCategories\NewsCategories::getModelClass(); $param = NewsCategories::getParameterName(); if (($newsModel = $className::findPublishedByIdOrAlias(\Input::get($param))) !== null) { return $newsModel->{$chunks[1]}; } } return false; }
/** * Initialize the object * @param string * @param integer */ public function __construct($strTable, $intPid) { parent::__construct(); $this->strTable = $strTable; $this->intPid = $intPid; // Store the path if it is an editable file if ($strTable == 'tl_files') { $objFile = \FilesModel::findByPk($intPid); if ($objFile !== null && in_array($objFile->extension, trimsplit(',', \Config::get('editableFiles')))) { $this->strPath = $objFile->path; } } }
public function replacePageInsertTags($strTag) { $arrTag = trimsplit('::', $strTag); switch ($arrTag[1]) { case 'taxonomyid': global $objPage; if ($objPage->taxonomyid) { return $objPage->taxonomyid; } break; } return false; }
/** * Replace the insert tags * * @param string $tag * * @return string|bool */ public function replace($tag) { $chunks = trimsplit('::', $tag); if ($chunks[0] === 'cfg_link_registry') { try { $value = $this->parse($chunks[1], $chunks[2]); } catch (\Exception $e) { return false; } return $value; } return false; }
/** * Generate the widget and return it as string * @param array * @return string */ public function parse($arrAttributes = null) { if ($this->varValue != '') { $blnTemporaryFile = $this->isTemporaryFile($this->varValue); // If the file is temporary but has the exact avatar dimensions // there is no need to crop it just treat it as a ready avatar if ($blnTemporaryFile) { $arrSize = @getimagesize(TL_ROOT . '/' . $this->varValue); if ($arrSize[0] == $this->arrAvatarSize[0] && $arrSize[1] == $this->arrAvatarSize[1]) { $strNew = $this->getThumbnailPath($this->varValue); // Copy the file if (\Files::getInstance()->rename($this->varValue, $strNew)) { $this->varValue = $strNew; $blnTemporaryFile = false; } } } // Temporary file if ($blnTemporaryFile) { // Crop the file if (\Input::post('crop') != '') { list($intPositionX, $intPositionY) = explode(',', \Input::post('crop')); $this->varValue = $this->cropImage($this->varValue, $intPositionX, $intPositionY); $this->thumbnail = \Image::getHtml($this->varValue); $this->imgSize = @getimagesize(TL_ROOT . '/' . $this->varValue); $this->set = $this->varValue; $this->noCrop = true; } else { // Crop mode $strThumbnail = $this->getThumbnail($this->varValue); $this->thumbnail = \Image::getHtml($strThumbnail); $this->imgSize = @getimagesize(TL_ROOT . '/' . $strThumbnail); } } else { // Avatar $this->avatar = \Image::getHtml(\Image::get($this->varValue, $this->arrAvatarSize[0], $this->arrAvatarSize[1], 'center_center')); $this->set = $this->varValue; } } $this->ajax = \Environment::get('isAjaxRequest'); $this->delete = $GLOBALS['TL_LANG']['MSC']['delete']; $this->deleteTitle = specialchars($GLOBALS['TL_LANG']['MSC']['delete']); $this->crop = $GLOBALS['TL_LANG']['MSC']['avatar_crop']; $this->cropTitle = specialchars($GLOBALS['TL_LANG']['MSC']['avatar_crop']); $this->extensions = json_encode(trimsplit(',', $this->getAllowedExtensions())); $this->sizeLimit = $this->getMaximumFileSize(); $this->avatarSize = json_encode($this->arrAvatarSize); $this->texts = json_encode(array('text' => array('formatProgress' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_formatProgress'], 'failUpload' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_failUpload'], 'waitingForResponse' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_waitingForResponse'], 'paused' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_paused']), 'messages' => array('tooManyFilesError' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_tooManyFilesError'], 'unsupportedBrowser' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_unsupportedBrowser']), 'retry' => array('autoRetryNote' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_autoRetryNote']), 'deleteFile' => array('confirmMessage' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_confirmMessage'], 'deletingStatusText' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_deletingStatusText'], 'deletingFailedText' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_deletingFailedText']), 'paste' => array('namePromptMessage' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_namePromptMessage']))); $this->labels = array('drop' => $GLOBALS['TL_LANG']['MSC']['avatar_drop'], 'upload' => $GLOBALS['TL_LANG']['MSC']['avatar_upload'], 'processing' => $GLOBALS['TL_LANG']['MSC']['avatar_processing']); return parent::parse($arrAttributes); }
public function setLinkAttributes($arrData, $delimiter = " ") { // set from string if (!is_array($arrData)) { $arrData = trimsplit($delimiter, $arrData); if (is_array($arrData)) { foreach (array_keys($this->arrLinkAttributes) as $strKey) { $this->arrLinkAttributes[$strKey] = $arrData[$strKey]; } } return; } $this->arrLinkAttributes = $arrData; }
/** * Save the coordinates. * * @param string $value The raw data. * @param \DataContainer $dataContainer The data container driver. * * @return string */ public function saveCoordinates($value, $dataContainer) { $combined = array('latitude' => null, 'longitude' => null, 'altitude' => null); $values = trimsplit(',', $value); $keys = array_keys($combined); $count = count($values); if ($count >= 2 && $count <= 3) { for ($i = 0; $i < $count; $i++) { $combined[$keys[$i]] = $values[$i]; } } \Database::getInstance()->prepare('UPDATE tl_leaflet_marker %s WHERE id=?')->set($combined)->execute($dataContainer->id); return null; }
/** * Remove isotope js, as we dont want to use mootools * * @param $strBuffer * * @return mixed */ public function hookReplaceDynamicScriptTags($strBuffer) { if (!is_array($GLOBALS['TL_JAVASCRIPT'])) { return $strBuffer; } $arrJs = $GLOBALS['TL_JAVASCRIPT']; foreach ($arrJs as $key => $strValue) { $arrData = trimsplit('|', $strValue); if (\HeimrichHannot\Haste\Util\StringUtil::endsWith($arrData[0], 'system/modules/isotope/assets/js/isotope.min.js')) { unset($GLOBALS['TL_JAVASCRIPT'][$key]); break; } } return $strBuffer; }
/** * Add an image to each record * @param array * @param string * @return string */ public function listRows($row) { $strCategory = RelatedCategory::findByPk($row['category'])->name; $strBuffer = '<div class="cte_type" style="color:#666966"><strong>' . $GLOBALS['TL_LANG']['tl_iso_related_product']['category'][0] . ':</strong> ' . $strCategory . '</div>'; $arrProducts = trimsplit(',', $row['products']); if (!empty($arrProducts) && is_array($arrProducts)) { $strBuffer .= '<div class="limit_height' . (!$GLOBALS['TL_CONFIG']['doNotCollapse'] ? ' h0' : '') . ' block"><ul>'; $objProducts = \Database::getInstance()->execute("SELECT * FROM tl_iso_product WHERE " . \Database::getInstance()->findInSet('id', $arrProducts) . " ORDER BY name"); while ($objProducts->next()) { $strBuffer .= '<li>' . $objProducts->name . '</li>'; } $strBuffer .= '</ul></div>' . "\n"; } return $strBuffer; }