/** * Retreives all available domains in this installation (plus empty selection) * * @return array */ public function getDomains() { // options array $options = array('' => $GLOBALS['TL_LANG']['tl_short_urls']['noDomain']); // get the root pages and their dns settings if (version_compare(VERSION, '3.5', '>=')) { if (($objPages = \PageModel::findPublishedRootPages()) !== null) { while ($objPages->next()) { if ($objPages->dns) { $options[$objPages->id] = $objPages->dns; } } } } else { $t = \PageModel::getTable(); $arrColumns = array("{$t}.type=?"); if (!BE_USER_LOGGED_IN) { $time = time(); $arrColumns[] = "({$t}.start='' OR {$t}.start<='{$time}') AND ({$t}.stop='' OR {$t}.stop>'" . ($time + 60) . "') AND {$t}.published='1'"; } $objPages = \PageModel::findBy($arrColumns, 'root'); if ($objPages !== null) { while ($objPages->next()) { if ($objPages->dns) { $options[$objPages->id] = $objPages->dns; } } } } // return the options return $options; }
/** * Create the config cache files */ public function generateConfigCache() { // Generate the class/template laoder cache file $objCacheFile = new \File('system/cache/config/autoload.php', true); $objCacheFile->write('<?php '); // add one space to prevent the "unexpected $end" error foreach (\ModuleLoader::getActive() as $strModule) { $strFile = 'system/modules/' . $strModule . '/config/autoload.php'; if (file_exists(TL_ROOT . '/' . $strFile)) { $objCacheFile->append(static::readPhpFileWithoutTags($strFile)); } } // Close the file (moves it to its final destination) $objCacheFile->close(); // Generate the module loader cache file $objCacheFile = new \File('system/cache/config/modules.php', true); $objCacheFile->write("<?php\n\n"); $objCacheFile->append(sprintf("static::\$active = %s;\n", var_export(\ModuleLoader::getActive(), true))); $objCacheFile->append(sprintf("static::\$disabled = %s;", var_export(\ModuleLoader::getDisabled(), true))); // Close the file (moves it to its final destination) $objCacheFile->close(); // Generate the config cache file $objCacheFile = new \File('system/cache/config/config.php', true); $objCacheFile->write('<?php '); // add one space to prevent the "unexpected $end" error foreach (\ModuleLoader::getActive() as $strModule) { $strFile = 'system/modules/' . $strModule . '/config/config.php'; if (file_exists(TL_ROOT . '/' . $strFile)) { $objCacheFile->append(static::readPhpFileWithoutTags($strFile)); } } // Close the file (moves it to its final destination) $objCacheFile->close(); // Generate the page mapping array $arrMapper = array(); $objPages = \PageModel::findPublishedRootPages(); if ($objPages !== null) { while ($objPages->next()) { $strBase = $objPages->dns ?: '*'; if ($objPages->fallback) { $arrMapper[$strBase . '/empty.fallback'] = $strBase . '/empty.' . $objPages->language; } $arrMapper[$strBase . '/empty.' . $objPages->language] = $strBase . '/empty.' . $objPages->language; } } // Generate the page mapper file $objCacheFile = new \File('system/cache/config/mapping.php', true); $objCacheFile->write(sprintf("<?php\n\nreturn %s;\n", var_export($arrMapper, true))); $objCacheFile->close(); // Add a log entry $this->log('Generated the config cache', __METHOD__, TL_CRON); }
public function getSearchablePages($arrPages, $intRootId = null, $bln = true, $strLanguage = null) { if (!$intRootId) { $objRoots = \PageModel::findPublishedRootPages(); if (!$objRoots) { \System::log("Can't get any root page", __METHOD__, TL_ERROR); return $arrPages; } while ($objRoots->next()) { $arrPages = $this->getSearchablePages($arrPages, $objRoots->id, $bln, $objRoots->language); } return $arrPages; } // get the root page object $objRoot = \PageModel::findByPk($intRootId); if (!$objRoot) { \System::log("Can't get the root page", __METHOD__, TL_ERROR); return $arrPages; } // check for sitemap enabled if (!$objRoot->anystores_sitemap) { return $arrPages; } // get the domain $strDomain = ($objRoot->useSSL ? 'https://' : 'http://') . ($objRoot->dns ?: \Environment::get('host')) . TL_PATH . '/'; // get the details page $objPage = \PageModel::findByPk($objRoot->anystores_detailPage); if (!$objPage) { \System::log("Can't find the details page", __METHOD__, TL_ERROR); return $arrPages; } // get the locations $objLocations = AnyStoresModel::findPublishedByCategory(deserialize($objRoot->anystores_categories)); if (!$objLocations) { \System::log("Can't get the published locations", __METHOD__, TL_ERROR); return $arrPages; } while ($objLocations->next()) { $strAlias = \Controller::generateFrontendUrl($objLocations->row(), null, $strLanguage); $arrPages[] = $strDomain . $objPage->alias . '/' . $strAlias; } return $arrPages; }