/**
  * {@inheritdoc}
  */
 public function handle(\Input $input)
 {
     $this->handleRunOnce();
     // PATCH
     if ($input->post('FORM_SUBMIT') == 'database-update') {
         $count = 0;
         $sql = deserialize($input->post('sql'));
         if (is_array($sql)) {
             foreach ($sql as $key) {
                 if (isset($_SESSION['sql_commands'][$key])) {
                     $this->Database->query(str_replace('DEFAULT CHARSET=utf8;', 'DEFAULT CHARSET=utf8 COLLATE ' . $GLOBALS['TL_CONFIG']['dbCollation'] . ';', $_SESSION['sql_commands'][$key]));
                     $count++;
                 }
             }
         }
         $_SESSION['sql_commands'] = array();
         Messages::addConfirmation(sprintf($GLOBALS['TL_LANG']['composer_client']['databaseUpdated'], $count));
         $this->reload();
     }
     /** @var \Contao\Database\Installer $installer */
     $installer = \System::importStatic('Database\\Installer');
     $form = $installer->generateSqlForm();
     if (empty($form)) {
         Messages::addInfo($GLOBALS['TL_LANG']['composer_client']['databaseUptodate']);
         $this->redirect('contao/main.php?do=composer');
     }
     $form = preg_replace('#(<label for="sql_\\d+")>(CREATE TABLE)#', '$1 class="create_table">$2', $form);
     $form = preg_replace('#(<label for="sql_\\d+")>(ALTER TABLE `[^`]+` ADD)#', '$1 class="alter_add">$2', $form);
     $form = preg_replace('#(<label for="sql_\\d+")>(ALTER TABLE `[^`]+` DROP)#', '$1 class="alter_drop">$2', $form);
     $form = preg_replace('#(<label for="sql_\\d+")>(DROP TABLE)#', '$1 class="drop_table">$2', $form);
     $template = new \BackendTemplate('be_composer_client_update');
     $template->composer = $this->composer;
     $template->form = $form;
     return $template->parse();
 }
 protected function compile()
 {
     $this->newsletters = deserialize($this->newsletters);
     parent::compile();
     // add custom newsletter subscription Checkbox to the Form
     if (in_array('newsletter', $this->Config->getActiveModules())) {
         // newsletter subscription
         if (is_array($this->newsletters) && !empty($this->newsletters)) {
             $objChannels = $this->Database->execute('SELECT * FROM tl_newsletter_channel WHERE id IN (' . implode(',', $this->newsletters) . ')');
             if ($objChannels->numRows) {
                 $strForm = '<label for="ctrl_channels_' . $this->id . '" class="invisible">' . $this->channelsLabel . '</label>';
                 $strForm .= '<div id="ctrl_channels_' . $this->id . '" class="checkbox_container">';
                 if ($objChannels->numRows == 1) {
                     $strForm .= '<span><input type="checkbox" name="newsletter" id="opt_newsletter_' . $this->id . '_' . $objChannels->id . '" value="' . $objChannels->id . '" class="checkbox"><label for="opt_newsletter_' . $this->id . '_' . $objChannels->id . '">' . $objChannels->checkbox_label . '</label></span>';
                 } else {
                     while ($objChannels->next()) {
                         $strForm .= '<span><input type="checkbox" name="newsletter[]" id="opt_newsletter_' . $this->id . '_' . $objChannels->id . '" value="' . $objChannels->id . '" class="checkbox"><label for="opt_newsletter_' . $this->id . '_' . $objChannels->id . '">' . $objChannels->checkbox_label . '</label></span>';
                     }
                 }
                 $strForm .= '</div>';
             }
         }
         $this->Template->fields .= $strForm;
     }
 }
 /**
  * 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']['newsreader'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     // Set the item from the auto_item parameter
     if (!isset($_GET['items']) && \Config::get('useAutoItem') && isset($_GET['auto_item'])) {
         \Input::setGet('items', \Input::get('auto_item'));
     }
     // Do not index or cache the page if no news item has been specified
     if (!\Input::get('items')) {
         /** @var \PageModel $objPage */
         global $objPage;
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         return '';
     }
     $this->news_archives = $this->sortOutProtected(deserialize($this->news_archives));
     // Do not index or cache the page if there are no archives
     if (!is_array($this->news_archives) || empty($this->news_archives)) {
         /** @var \PageModel $objPage */
         global $objPage;
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         return '';
     }
     return parent::generate();
 }
Example #4
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     $this->Template->size = '';
     // Set the size
     if ($this->playerSize != '') {
         $size = deserialize($this->playerSize);
         if (is_array($size)) {
             $this->Template->size = ' width="' . $size[0] . 'px" height="' . $size[1] . 'px"';
         }
     }
     $this->Template->poster = false;
     // Optional poster
     if ($this->posterSRC != '') {
         if (($objFile = \FilesModel::findByPk($this->posterSRC)) !== null) {
             $this->Template->poster = $objFile->path;
         }
     }
     // Pre-sort the array by preference
     if (in_array($this->objFiles->extension, array('mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv'))) {
         $this->Template->isVideo = true;
         $arrFiles = array('mp4' => null, 'm4v' => null, 'mov' => null, 'wmv' => null, 'webm' => null, 'ogv' => null);
     } else {
         $this->Template->isVideo = false;
         $arrFiles = array('m4a' => null, 'mp3' => null, 'wma' => null, 'mpeg' => null, 'wav' => null);
     }
     $this->objFiles->reset();
     // Pass File objects to the template
     while ($this->objFiles->next()) {
         $objFile = new \File($this->objFiles->path);
         $arrFiles[$objFile->extension] = $objFile;
     }
     $this->Template->files = array_values(array_filter($arrFiles));
     $this->Template->autoplay = $this->autoplay;
 }
 /**
  * Run the controller
  */
 public function run()
 {
     $objInstalledTabControl = $this->Database->query("SELECT version FROM tl_repository_installs WHERE extension='tabcontrol' LIMIT 1");
     if ($objInstalledTabControl->version <= '30000009') {
         if (!$this->Database->fieldExists('tab_tabs', 'tl_content')) {
             $this->Database->query("ALTER TABLE tl_content ADD tab_tabs blob NULL");
         }
         if (!$this->Database->fieldExists('tab_template', 'tl_content')) {
             $this->Database->query("ALTER TABLE tl_content ADD tab_template varchar(64) NOT NULL default 'ce_tabcontrol_tab'");
         }
         if (!$this->Database->fieldExists('tab_template_start', 'tl_content')) {
             $this->Database->query("ALTER TABLE tl_content ADD tab_template_start varchar(64) NOT NULL default 'ce_tabcontrol_start'");
         }
         if (!$this->Database->fieldExists('tab_template_stop', 'tl_content')) {
             $this->Database->query("ALTER TABLE tl_content ADD tab_template_stop varchar(64) NOT NULL default 'ce_tabcontrol_stop'");
         }
         if (!$this->Database->fieldExists('tab_template_end', 'tl_content')) {
             $this->Database->query("ALTER TABLE tl_content ADD tab_template_end varchar(64) NOT NULL default 'ce_tabcontrol_end'");
         }
         $objTabControl = $this->Database->query("SELECT * FROM tl_content WHERE type='tabcontrol' AND tabType='tabcontroltab'");
         while ($objTabControl->next()) {
             if ($this->Database->fieldExists('tabTitles', 'tl_content')) {
                 $arrTabs = array();
                 $arrTabTitles = deserialize($objTabControl->tabTitles);
                 foreach ($arrTabTitles as $title) {
                     $arrTabs[] = array('tab_tabs_name' => $title, 'tab_tabs_cookies_value' => '', 'tab_tabs_default' => '');
                 }
                 $this->Database->query("UPDATE tl_content SET tab_tabs='" . serialize($arrTabs) . "' WHERE id=" . $objTabControl->id . "");
             }
         }
     }
 }
 /**
  * Multiple-fields (e.g. select or checkbox) with numberic keys are stored as CSV to improve filters.
  */
 private function convertSerializedValues()
 {
     $t = Attribute::getTable();
     $fields = array();
     $attributes = Attribute::findBy(array("{$t}.multiple='1' AND {$t}.optionsSource='foreignKey'"), null);
     if (null !== $attributes) {
         /** @var Attribute $attribute */
         foreach ($attributes as $attribute) {
             if ($attribute instanceof IsotopeAttributeWithOptions) {
                 $fields[] = $attribute->field_name;
             }
         }
     }
     if (!empty($fields)) {
         /** @var \Database\Result|object $products */
         $products = $this->db->execute("\n                SELECT id, " . implode(', ', $fields) . "\n                FROM tl_iso_product\n                WHERE " . implode(" IS NOT NULL OR ", $fields) . " IS NOT NULL\n            ");
         while ($products->next()) {
             $set = array();
             foreach ($fields as $field) {
                 $value = deserialize($products->{$field});
                 if (!empty($value) && is_array($value)) {
                     $set[$field] = implode(',', $value);
                 }
             }
             if (!empty($set)) {
                 $this->db->prepare("UPDATE tl_iso_product %s WHERE id=?")->set($set)->execute($products->id);
             }
         }
     }
 }
Example #7
0
 /**
  * Save layer relations.
  *
  * @param mixed          $layerId       The layer id values.
  * @param \DataContainer $dataContainer The dataContainer driver.
  *
  * @return null
  */
 public function saveLayerRelations($layerId, $dataContainer)
 {
     $new = deserialize($layerId, true);
     $values = array();
     $result = $this->database->prepare('SELECT * FROM tl_leaflet_map_layer WHERE mid=? order BY sorting')->execute($dataContainer->id);
     while ($result->next()) {
         $values[$result->lid] = $result->row();
     }
     $sorting = 0;
     foreach ($new as $layerId) {
         if (!isset($values[$layerId])) {
             $this->database->prepare('INSERT INTO tl_leaflet_map_layer %s')->set(array('tstamp' => time(), 'lid' => $layerId, 'mid' => $dataContainer->id, 'sorting' => $sorting))->execute();
             $sorting += 128;
         } else {
             if ($values[$layerId]['sorting'] <= $sorting - 128 || $values[$layerId]['sorting'] >= $sorting + 128) {
                 $this->database->prepare('UPDATE tl_leaflet_map_layer %s WHERE id=?')->set(array('tstamp' => time(), 'sorting' => $sorting))->execute($values[$layerId]['id']);
             }
             $sorting += 128;
             unset($values[$layerId]);
         }
     }
     $ids = array_map(function ($item) {
         return $item['id'];
     }, $values);
     if ($ids) {
         $this->database->query('DELETE FROM tl_leaflet_map_layer WHERE id IN(' . implode(',', $ids) . ')');
     }
     return null;
 }
Example #8
0
 /**
  * Returns true if the product is available
  * ALMOST THE SAME AS THE PARENT, EXCEPT WE DON'T CHECK FOR PRICE
  *
  * @param IsotopeProductCollection|\Isotope\Model\ProductCollection $objCollection
  *
  * @return bool
  */
 public function isAvailableForCollection(IsotopeProductCollection $objCollection)
 {
     if ($objCollection->isLocked()) {
         return true;
     }
     if (BE_USER_LOGGED_IN !== true && !$this->isPublished()) {
         return false;
     }
     // Show to guests only
     if ($this->arrData['guests'] && $objCollection->member > 0 && BE_USER_LOGGED_IN !== true && !$this->arrData['protected']) {
         return false;
     }
     // Protected product
     if (BE_USER_LOGGED_IN !== true && $this->arrData['protected']) {
         if ($objCollection->member == 0) {
             return false;
         }
         $groups = deserialize($this->arrData['groups']);
         $memberGroups = deserialize($objCollection->getRelated('member')->groups);
         if (!is_array($groups) || empty($groups) || !is_array($memberGroups) || empty($memberGroups) || !count(array_intersect($groups, $memberGroups))) {
             return false;
         }
     }
     // Check that the product is in any page of the current site
     if (count(\Isotope\Frontend::getPagesInCurrentRoot($this->getCategories(), $objCollection->getRelated('member'))) == 0) {
         return false;
     }
     // Check if "advanced price" is available
     //if (null === $this->getPrice($objCollection) && (in_array('price', $this->getAttributes()) || $this->hasVariantPrices())) {
     //    return false;
     //}
     return true;
 }
Example #9
0
 /**
  * Add specific attributes
  *
  * @param string $strKey   The attribute name
  * @param mixed  $varValue The attribute value
  */
 public function __set($strKey, $varValue)
 {
     switch ($strKey) {
         case 'mandatory':
             if ($varValue) {
                 $this->arrAttributes['required'] = 'required';
             } else {
                 unset($this->arrAttributes['required']);
             }
             parent::__set($strKey, $varValue);
             break;
         case 'mSize':
             if ($this->multiple) {
                 $this->arrAttributes['size'] = $varValue;
             }
             break;
         case 'multiple':
             if ($varValue != '') {
                 $this->arrAttributes['multiple'] = 'multiple';
             }
             break;
         case 'options':
             $this->arrOptions = deserialize($varValue);
             break;
         case 'rgxp':
         case 'minlength':
         case 'maxlength':
             // Ignore
             break;
         default:
             parent::__set($strKey, $varValue);
             break;
     }
 }
Example #10
0
 /**
  * Validate input and set value
  */
 public function validate()
 {
     $mandatory = $this->mandatory;
     $options = deserialize($this->getPost($this->strName));
     // Check keys only (values can be empty)
     if (is_array($options)) {
         foreach ($options as $key => $option) {
             // Unset empty rows
             if ($option['key'] == '') {
                 unset($options[$key]);
                 continue;
             }
             $options[$key]['key'] = trim($option['key']);
             $options[$key]['value'] = trim($option['value']);
             if ($options[$key]['key'] != '') {
                 $this->mandatory = false;
             }
         }
     }
     $options = array_values($options);
     $varInput = $this->validator($options);
     if (!$this->hasErrors()) {
         $this->varValue = $varInput;
     }
     // Reset the property
     if ($mandatory) {
         $this->mandatory = true;
     }
 }
 /**
  * Validate input and set value
  */
 public function validate()
 {
     $mandatory = $this->mandatory;
     $options = deserialize($this->getPost($this->strName));
     // Check labels only (values can be empty)
     if (is_array($options)) {
         foreach ($options as $key => $option) {
             // Unset empty rows
             if ($option['label'] == '') {
                 $this->addError($GLOBALS['TL_LANG']['FFL']['tl_form_field']['nlChannels']['error']['emptyDescription']);
                 unset($options[$key]);
                 continue;
             }
             $options[$key]['label'] = trim($option['label']);
             $options[$key]['value'] = trim($option['value']);
             if ($options[$key]['label'] != '') {
                 $this->mandatory = false;
             }
         }
     }
     $options = array_values($options);
     $varInput = $this->validator($options);
     if (!$this->hasErrors()) {
         $this->varValue = $varInput;
     }
     // Reset the property
     if ($mandatory) {
         $this->mandatory = true;
     }
 }
Example #12
0
 /**
  * {@inheritdoc}
  */
 public function modelSaved($objItem)
 {
     // Alias already defined and no update forced, get out!
     if ($objItem->get($this->getColName()) && !$this->get('force_alias')) {
         return;
     }
     // Item is a variant but no overriding allowed, get out!
     if ($objItem->isVariant() && !$this->get('isvariant')) {
         return;
     }
     $arrAlias = '';
     foreach (deserialize($this->get('alias_fields')) as $strAttribute) {
         $arrValues = $objItem->parseAttribute($strAttribute['field_attribute'], 'text', null);
         $arrAlias[] = $arrValues['text'];
     }
     $dispatcher = $this->getMetaModel()->getServiceContainer()->getEventDispatcher();
     $replaceEvent = new ReplaceInsertTagsEvent(implode('-', $arrAlias));
     $dispatcher->dispatch(ContaoEvents::CONTROLLER_REPLACE_INSERT_TAGS, $replaceEvent);
     // Implode with '-', replace inserttags and strip HTML elements.
     $strAlias = standardize(strip_tags($replaceEvent->getBuffer()));
     // We need to fetch the attribute values for all attributes in the alias_fields and update the database and the
     // model accordingly.
     if ($this->get('isunique')) {
         // Ensure uniqueness.
         $strBaseAlias = $strAlias;
         $arrIds = array($objItem->get('id'));
         $intCount = 2;
         while (array_diff($this->searchFor($strAlias), $arrIds)) {
             $strAlias = $strBaseAlias . '-' . $intCount++;
         }
     }
     $this->setDataFor(array($objItem->get('id') => $strAlias));
     $objItem->set($this->getColName(), $strAlias);
 }
Example #13
0
 /**
  * Return if there are no files
  * @return string
  */
 public function generate()
 {
     // Use the home directory of the current user as file source
     if ($this->useHomeDir && FE_USER_LOGGED_IN) {
         $this->import('FrontendUser', 'User');
         if ($this->User->assignDir && is_dir(TL_ROOT . '/' . $this->User->homeDir)) {
             $this->multiSRC = array($this->User->homeDir);
         }
     } else {
         $this->multiSRC = deserialize($this->multiSRC);
     }
     // Return if there are no files
     if (!is_array($this->multiSRC) || empty($this->multiSRC)) {
         return '';
     }
     // Check for version 3 format
     if (!is_numeric($this->multiSRC[0])) {
         return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
     }
     // Get the file entries from the database
     $this->objFiles = \FilesModel::findMultipleByIds($this->multiSRC);
     if ($this->objFiles === null) {
         return '';
     }
     return parent::generate();
 }
 /**
  * {@inheritdoc}
  */
 public function modelSaved($objItem)
 {
     // combined values already defined and no update forced, get out!
     if ($objItem->get($this->getColName()) && !$this->get('force_combinedvalues')) {
         return;
     }
     $arrCombinedValues = array();
     foreach (deserialize($this->get('combinedvalues_fields')) as $strAttribute) {
         if ($this->isMetaField($strAttribute['field_attribute'])) {
             $strField = $strAttribute['field_attribute'];
             $arrCombinedValues[] = $objItem->get($strField);
         } else {
             $arrValues = $objItem->parseAttribute($strAttribute['field_attribute'], 'text', null);
             $arrCombinedValues[] = $arrValues['text'];
         }
     }
     $strCombinedValues = vsprintf($this->get('combinedvalues_format'), $arrCombinedValues);
     $strCombinedValues = trim($strCombinedValues);
     // we need to fetch the attribute values for all attribs in the combinedvalues_fields and update the database
     // and the model accordingly.
     if ($this->get('isunique')) {
         // ensure uniqueness.
         $strLanguage = $this->getMetaModel()->getActiveLanguage();
         $strBaseCombinedValues = $strCombinedValues;
         $arrIds = array($objItem->get('id'));
         $intCount = 2;
         while (array_diff($this->searchForInLanguages($strCombinedValues, array($strLanguage)), $arrIds)) {
             $intCount++;
             $strCombinedValues = $strBaseCombinedValues . ' (' . $intCount . ')';
         }
     }
     $arrData = $this->widgetToValue($strCombinedValues, $objItem->get('id'));
     $this->setTranslatedDataFor(array($objItem->get('id') => $arrData), $this->getMetaModel()->getActiveLanguage());
     $objItem->set($this->getColName(), $arrData);
 }
Example #15
0
 public function disableOldClientHook()
 {
     // disable the repo client
     $reset = false;
     $activeModules = $this->Config->getActiveModules();
     $inactiveModules = deserialize($GLOBALS['TL_CONFIG']['inactiveModules']);
     if (in_array('rep_base', $activeModules)) {
         $inactiveModules[] = 'rep_base';
         $reset = true;
     }
     if (in_array('rep_client', $activeModules)) {
         $inactiveModules[] = 'rep_client';
         $reset = true;
     }
     if (in_array('repository', $activeModules)) {
         $inactiveModules[] = 'repository';
         $skipFile = new \File('system/modules/repository/.skip');
         $skipFile->write('Remove this file to enable the module');
         $skipFile->close();
         $reset = true;
     }
     if ($reset) {
         $this->Config->update("\$GLOBALS['TL_CONFIG']['inactiveModules']", serialize($inactiveModules));
         $this->reload();
     }
     unset($GLOBALS['TL_HOOK']['loadLanguageFiles']['composer']);
 }
 /**
  * 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']['newsarchive'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     $this->news_archives = $this->sortOutProtected(deserialize($this->news_archives));
     // No news archives available
     if (!is_array($this->news_archives) || empty($this->news_archives)) {
         return '';
     }
     // Show the news reader if an item has been selected
     if ($this->news_readerModule > 0 && (isset($_GET['items']) || \Config::get('useAutoItem') && isset($_GET['auto_item']))) {
         return $this->getFrontendModule($this->news_readerModule, $this->strColumn);
     }
     // Hide the module if no period has been selected
     if ($this->news_jumpToCurrent == 'hide_module' && !isset($_GET['year']) && !isset($_GET['month']) && !isset($_GET['day'])) {
         return '';
     }
     return parent::generate();
 }
 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     if (!strlen($this->inColumn)) {
         $this->inColumn = 'main';
     }
     $intCount = 0;
     $articles = array();
     $id = $objPage->id;
     $this->Template->request = \Environment::get('request');
     // Show the articles of a different page
     if ($this->defineRoot && $this->rootPage > 0) {
         if (($objTarget = $this->objModel->getRelated('rootPage')) !== null) {
             $id = $objTarget->id;
             /** @var \PageModel $objTarget */
             $this->Template->request = $objTarget->getFrontendUrl();
         }
     }
     // Get published articles
     $objArticles = \ArticleModel::findPublishedByPidAndColumn($id, $this->inColumn);
     if ($objArticles === null) {
         return;
     }
     while ($objArticles->next()) {
         // Skip first article
         if (++$intCount <= intval($this->skipFirst)) {
             continue;
         }
         $cssID = deserialize($objArticles->cssID, true);
         $alias = $objArticles->alias ?: $objArticles->title;
         $articles[] = array('link' => $objArticles->title, 'title' => specialchars($objArticles->title), 'id' => $cssID[0] ?: standardize($alias), 'articleId' => $objArticles->id);
     }
     $this->Template->articles = $articles;
 }
Example #18
0
 /**
  * Generate the content element
  */
 protected function compile()
 {
     $rows = deserialize($this->tableitems);
     $this->Template->id = 'table_' . $this->id;
     $this->Template->summary = specialchars($this->summary);
     $this->Template->useHeader = $this->thead ? true : false;
     $this->Template->useFooter = $this->tfoot ? true : false;
     $this->Template->useLeftTh = $this->tleft ? true : false;
     $this->Template->sortable = $this->sortable ? true : false;
     $arrHeader = array();
     $arrBody = array();
     $arrFooter = array();
     // Table header
     if ($this->thead) {
         foreach ($rows[0] as $i => $v) {
             // Set table sort cookie
             if ($this->sortable && $i == $this->sortIndex) {
                 $co = 'TS_TABLE_' . $this->id;
                 $so = $this->sortOrder == 'descending' ? 'desc' : 'asc';
                 if (\Input::cookie($co) == '') {
                     \System::setCookie($co, $i . '|' . $so, 0);
                 }
             }
             // Add cell
             $arrHeader[] = array('class' => 'head_' . $i . ($i == 0 ? ' col_first' : '') . ($i == count($rows[0]) - 1 ? ' col_last' : '') . ($i == 0 && $this->tleft ? ' unsortable' : ''), 'content' => $v != '' ? nl2br_html5($v) : '&nbsp;');
         }
         array_shift($rows);
     }
     $this->Template->header = $arrHeader;
     $limit = $this->tfoot ? count($rows) - 1 : count($rows);
     // Table body
     for ($j = 0; $j < $limit; $j++) {
         $class_tr = '';
         if ($j == 0) {
             $class_tr .= ' row_first';
         }
         if ($j == $limit - 1) {
             $class_tr .= ' row_last';
         }
         $class_eo = $j % 2 == 0 ? ' odd' : ' even';
         foreach ($rows[$j] as $i => $v) {
             $class_td = '';
             if ($i == 0) {
                 $class_td .= ' col_first';
             }
             if ($i == count($rows[$j]) - 1) {
                 $class_td .= ' col_last';
             }
             $arrBody['row_' . $j . $class_tr . $class_eo][] = array('class' => 'col_' . $i . $class_td, 'content' => $v != '' ? nl2br_html5($v) : '&nbsp;');
         }
     }
     $this->Template->body = $arrBody;
     // Table footer
     if ($this->tfoot) {
         foreach ($rows[count($rows) - 1] as $i => $v) {
             $arrFooter[] = array('class' => 'foot_' . $i . ($i == 0 ? ' col_first' : '') . ($i == count($rows[count($rows) - 1]) - 1 ? ' col_last' : ''), 'content' => $v != '' ? nl2br_html5($v) : '&nbsp;');
         }
     }
     $this->Template->footer = $arrFooter;
 }
 /**
  * Display a wildcard in the back end
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         $objTemplate = new BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### NEWS READER ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     // Return if no news item has been specified
     if (!$this->Input->get('items')) {
         global $objPage;
         // Do not index the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         return '';
     }
     $this->news_archives = $this->sortOutProtected(deserialize($this->news_archives));
     // Return if there are no archives
     if (!is_array($this->news_archives) || count($this->news_archives) < 1) {
         global $objPage;
         // Do not index the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         return '';
     }
     return parent::generate();
 }
Example #20
0
 /**
  * Display a wildcard in the back end
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         $objTemplate = new BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### FAQ READER ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     // Set the item from the auto_item parameter
     if ($GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) {
         $this->Input->setGet('items', $this->Input->get('auto_item'));
     }
     // Do not index or cache the page if no FAQ has been specified
     if (!$this->Input->get('items')) {
         global $objPage;
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         return '';
     }
     $this->faq_categories = deserialize($this->faq_categories);
     // Do not index or cache the page if there are no categories
     if (!is_array($this->faq_categories) || empty($this->faq_categories)) {
         global $objPage;
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         return '';
     }
     return parent::generate();
 }
    public function injectStyles($objPage, &$objLayout, $objPageRegular)
    {
        $arrStylesheets = deserialize($objLayout->stylesheet);
        if (is_array($arrStylesheets) && count($arrStylesheets)) {
            $arrStyles = array();
            $objStyles = $this->Database->execute("SELECT * FROM tl_style WHERE pid IN (" . implode(',', $arrStylesheets) . ") AND invisible='' AND grayscaleimagehover='1'");
            while ($objStyles->next()) {
                $GLOBALS['TL_JAVASCRIPT'][] = 'plugins/grayscaleimagehover/grayscalehover.js';
                $arrOptions = array();
                if (strlen($objStyles->grayscaleimagehover_duration)) {
                    $arrOptions[] = "duration: '" . $objStyles->grayscaleimagehover_duration . "'";
                }
                if ($objStyles->grayscaleimagehover_luminance) {
                    $luminance = "true";
                } else {
                    $luminance = "false";
                }
                $arrOptions[] = "luminance: " . $luminance;
                $arrStyles[] = "new GrayscaleImages('" . $objStyles->selector . "'" . (count($arrOptions) ? ', {' . implode(', ', $arrOptions) . '}' : '') . ");";
            }
            if (count($arrStyles)) {
                $GLOBALS['TL_HEAD'][] = '<script type="text/javascript">
<!--//--><![CDATA[//><!--
window.addEvent("domready",function(){
' . implode("\n", $arrStyles) . '
});
//--><!]]>
</script>';
            }
        }
    }
 /**
  * Generate the list in related categories mode
  *
  * Use the categories of the current news item. The module must be
  * on the same page as news reader module.
  *
  * @return string
  */
 protected function generateRelated()
 {
     // Set the item from the auto_item parameter
     if (!isset($_GET['items']) && $GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) {
         \Input::setGet('items', \Input::get('auto_item'));
     }
     // Return if there is no item specified
     if (!\Input::get('items')) {
         return '';
     }
     $this->news_archives = $this->sortOutProtected(deserialize($this->news_archives));
     // Return if there are no archives
     if (!is_array($this->news_archives) || empty($this->news_archives)) {
         return '';
     }
     $news = \NewsModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->news_archives);
     // Return if the news item was not found
     if ($news === null) {
         return '';
     }
     $GLOBALS['NEWS_FILTER_CATEGORIES'] = false;
     $GLOBALS['NEWS_FILTER_DEFAULT'] = deserialize($news->categories, true);
     $GLOBALS['NEWS_FILTER_EXCLUDE'] = array($news->id);
     return parent::generate();
 }
Example #23
0
 /**
  * Do not show the module if no calendar has been selected
  *
  * @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']['calendar'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     $this->cal_calendar = $this->sortOutProtected(deserialize($this->cal_calendar, true));
     // Return if there are no calendars
     if (!is_array($this->cal_calendar) || empty($this->cal_calendar)) {
         return '';
     }
     $this->strUrl = preg_replace('/\\?.*$/', '', \Environment::get('request'));
     $this->strLink = $this->strUrl;
     if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) !== null) {
         /** @var \PageModel $objTarget */
         $this->strLink = $objTarget->getFrontendUrl();
     }
     return parent::generate();
 }
Example #24
0
 /**
  * Generate the content element
  */
 protected function compile()
 {
     global $objPage;
     // Contao framework sets images to max-width 100%, which collides with Google's CSS
     if (!$this->dlh_googlemap_nocss) {
         \delahaye\googlemaps\Googlemap::CssInjection();
     }
     // get the map data
     $arrParams = array('mapSize' => deserialize($this->dlh_googlemap_size), 'zoom' => $this->dlh_googlemap_zoom);
     $arrParams['mapSize'][2] = $arrParams['mapSize'][2] == 'pcnt' ? '%' : $arrParams['mapSize'][2];
     $arrMap = \delahaye\googlemaps\Googlemap::getMapData($this->dlh_googlemap, $objPage->outputFormat, $arrParams);
     // static map
     if ($this->dlh_googlemap_static) {
         $this->Template = new \FrontendTemplate('ce_dlh_googlemapsstatic');
         if ($this->dlh_googlemap_url) {
             $arrMap['staticMap'] = '<a href="' . $this->dlh_googlemap_url . '"' . ($this->rel ? ($objPage->outputFormat == 'html5' ? ' data-lightbox="' : ' rel="') . $this->rel . '"' : '') . ' title="' . addslashes($this->linkTitle) . '"' . ($this->target ? ' onclick="window.open(this.href); return false;"' : '') . '>' . $arrMap['staticMap'] . '</a>';
         }
     } else {
         if ($this->dlh_googlemap_template && $this->dlh_googlemap_template != 'ce_dlh_googlemaps_default') {
             $this->Template = new \FrontendTemplate($this->dlh_googlemap_template);
         }
         $GLOBALS['TL_JAVASCRIPT'][] = 'http' . (\Environment::get('ssl') ? 's' : '') . '://maps.google.com/maps/api/js?language=' . $arrMap['language'] . '&amp;sensor=' . ($arrMap['sensor'] ? 'true' : 'false');
     }
     $this->Template->map = $arrMap;
     $this->Template->tabs = $this->dlh_googlemap_tabs;
     $this->Template->labels = $GLOBALS['TL_LANG']['dlh_googlemaps']['labels'];
 }
 /**
  * Display a wildcard in the back end
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['newslist_plus'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
         return $objTemplate->parse();
     }
     $this->news_archives = $this->sortOutProtected(deserialize($this->news_archives));
     // Return if there are no archives
     if (!is_array($this->news_archives) || empty($this->news_archives)) {
         return '';
     }
     $this->news_featured = 'featured';
     // unset search string for highlighted section
     \Input::setGet('searchKeywords', null);
     $this->objArticles = NewsPlusModel::findPublishedByPids($this->news_archives, array(), array(), $this->news_featured == 'featured', $this->numberOfItems, 0);
     if ($this->objArticles === null) {
         return '';
     }
     return parent::generate();
 }
Example #26
0
 public function checkPermission()
 {
     if ($this->User->isAdmin) {
         return;
     }
     if (is_array($this->User->finanzen_archiv_rechte) && $this->User->finanzen_archiv_rechte[0] == 'edit' && $this->User->inherit != 'group') {
         return;
     }
     if ($this->User->inherit != 'custom') {
         foreach ($this->User->groups as $intGroup) {
             $objGroup = $this->Database->prepare("SELECT finanzen_archiv_rechte FROM tl_user_group WHERE id=?")->limit(1)->execute($intGroup);
             $arrRights = deserialize($objGroup->finanzen_archiv_rechte);
             if ($arrRights[0] == 'edit') {
                 return;
             }
         }
     }
     $GLOBALS['TL_DCA']['tl_finanzen']['config']['closed'] = true;
     $GLOBALS['TL_DCA']['tl_finanzen']['config']['notEditable'] = true;
     $GLOBALS['TL_DCA']['tl_finanzen']['config']['notDeletable'] = true;
     $GLOBALS['TL_DCA']['tl_finanzen']['config']['notCopyable'] = true;
     $GLOBALS['TL_DCA']['tl_finanzen']['config']['notCreatable'] = true;
     unset($GLOBALS['TL_DCA']['tl_finanzen']['list']['global_operations']['all']);
     unset($GLOBALS['TL_DCA']['tl_finanzen']['list']['global_operations']['category']);
     unset($GLOBALS['TL_DCA']['tl_finanzen']['list']['operations']);
 }
 /**
  * Create/Update ldap group as tl_member_group
  * @param serialized array $varValue
  * @return serialized array $varValue
  */
 public static function updateMemberGroups($varValue)
 {
     $arrSelectedLdapMemberGroups = deserialize($varValue, true);
     if (!empty($arrSelectedLdapMemberGroups)) {
         $arrLdapMemberGroups = LdapMemberGroupModel::getLdapMemberGroups();
         if (!is_array($arrLdapMemberGroups) || empty($arrLdapMemberGroups)) {
             return $varValue;
         }
         // ldap groups
         foreach ($arrLdapMemberGroups as $k => $v) {
             // selected ldap groups in settings
             foreach ($arrSelectedLdapMemberGroups as $gid) {
                 if (isset($v['gidnumber']) && $v['gidnumber'][0] == $gid) {
                     $objMemberGroup = \MemberGroupModel::findBy('ldapGid', $gid);
                     if ($objMemberGroup === null) {
                         $objMemberGroup = new \MemberGroupModel();
                         $objMemberGroup->ldapGid = $gid;
                     }
                     $objMemberGroup->tstamp = time();
                     // name
                     if (isset($v['cn'])) {
                         $objMemberGroup->name = $v['cn'][0];
                     } else {
                         $objMemberGroup->name = $gid;
                     }
                     $objMemberGroup->save();
                 }
             }
         }
         LdapMember::updateMembers($arrSelectedLdapMemberGroups);
     }
     return $varValue;
 }
 /**
  * generate function.
  *
  * @access public
  * @return void
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### PHOTOALBUMS 2 MODULE ###';
         return $objTemplate->parse();
     }
     // Set Pa2 Type
     $this->pa2type = 'MOD';
     // Deserialize vars
     $this->groups = deserialize($this->groups);
     $this->pa2Archives = deserialize($this->pa2Archives);
     $this->pa2AlbumSort = deserialize($this->pa2AlbumSort);
     $this->pa2AlbumsMetaFields = deserialize($this->pa2AlbumsMetaFields);
     $this->pa2ImagesMetaFields = deserialize($this->pa2ImagesMetaFields);
     $this->pa2TimeFilterStart = deserialize($this->pa2TimeFilterStart);
     $this->pa2TimeFilterEnd = deserialize($this->pa2TimeFilterEnd);
     // Set true and false on checkboxes
     $this->pa2ImagesShowHeadline = $this->pa2ImagesShowHeadline == 1 ? true : false;
     $this->pa2ImagesShowTitle = $this->pa2ImagesShowTitle == 1 ? true : false;
     $this->pa2ImagesShowTeaser = $this->pa2ImagesShowTeaser == 1 ? true : false;
     $this->pa2AlbumsShowHeadline = $this->pa2AlbumsShowHeadline == 1 ? true : false;
     $this->pa2AlbumsShowTitle = $this->pa2AlbumsShowTitle == 1 ? true : false;
     $this->pa2AlbumsShowTeaser = $this->pa2AlbumsShowTeaser == 1 ? true : false;
     $this->pa2AlbumLightbox = $this->pa2Mode == 'pa2_only_album_view' ? true : false;
     $this->pa2DetailPage = $this->pa2Mode == 'pa2_with_detail_page' ? $this->pa2DetailPage : '';
     // Set the item from the auto_item parameter
     if ($GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) {
         $this->Input->setGet('album', $this->Input->get('auto_item'));
     }
     return parent::generate();
 }
Example #29
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     // Also check owner (see #126)
     if (($objOrder = Order::findOneBy('uniqid', (string) \Input::get('uid'))) === null || FE_USER_LOGGED_IN === true && $objOrder->member > 0 && \FrontendUser::getInstance()->id != $objOrder->member) {
         $this->Template = new \Isotope\Template('mod_message');
         $this->Template->type = 'error';
         $this->Template->message = $GLOBALS['TL_LANG']['ERR']['orderNotFound'];
         return;
     }
     // Order belongs to a member but not logged in
     if (TL_MODE == 'FE' && $this->iso_loginRequired && $objOrder->member > 0 && FE_USER_LOGGED_IN !== true) {
         global $objPage;
         $objHandler = new $GLOBALS['TL_PTY']['error_403']();
         $objHandler->generate($objPage->id);
         exit;
     }
     Isotope::setConfig($objOrder->getRelated('config_id'));
     $objTemplate = new \Isotope\Template($this->iso_collectionTpl);
     $objTemplate->linkProducts = true;
     $objOrder->addToTemplate($objTemplate, array('gallery' => $this->iso_gallery, 'sorting' => $objOrder->getItemsSortingCallable($this->iso_orderCollectionBy)));
     $this->Template->collection = $objOrder;
     $this->Template->products = $objTemplate->parse();
     $this->Template->info = deserialize($objOrder->checkout_info, true);
     $this->Template->date = Format::date($objOrder->locked);
     $this->Template->time = Format::time($objOrder->locked);
     $this->Template->datim = Format::datim($objOrder->locked);
     $this->Template->orderDetailsHeadline = sprintf($GLOBALS['TL_LANG']['MSC']['orderDetailsHeadline'], $objOrder->document_number, $this->Template->datim);
     $this->Template->orderStatus = sprintf($GLOBALS['TL_LANG']['MSC']['orderStatusHeadline'], $objOrder->getStatusLabel());
     $this->Template->orderStatusKey = $objOrder->getStatusAlias();
 }
Example #30
0
 function updateComObject(DataContainer $dc)
 {
     $session = $this->Session->getData();
     if (!$dc->id) {
         $id = $this->Input->get('id');
     } else {
         $id = $dc->id;
     }
     $obj = $this->Database->prepare("SELECT c.pid, c.cssID, c.id FROM tl_content as c WHERE c.id=?")->limit(1)->execute($id);
     $cssID = "extJs_content_" . $id;
     $des = deserialize($obj->cssID);
     if (!$des[0]) {
         $des[0] = $cssID;
         $cssID = serialize($des);
         $this->Database->execute("update tl_content set cssID='{$cssID}' WHERE id=" . $id);
     }
     // Return if there is no result
     $pid = 0;
     if ($obj->numRows >= 1) {
         $pid = $obj->pid;
     }
     $node = (object) array();
     $node->id = $id;
     $node->pid = $pid;
     $node->parentType = "article";
     $node->type = "content";
     $node->action = $this->Input->get('act');
     $node->table = $this->Input->get('table');
     $node->saveNclose = $this->Input->post('saveNclose');
     $session['comObject']['dirtyNodes'][] = $node;
     $this->Session->setData($session);
 }