当前位置: 首页>>代码示例>>PHP>>正文


PHP System::importStatic方法代码示例

本文整理汇总了PHP中Contao\System::importStatic方法的典型用法代码示例。如果您正苦于以下问题:PHP System::importStatic方法的具体用法?PHP System::importStatic怎么用?PHP System::importStatic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contao\System的用法示例。


在下文中一共展示了System::importStatic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeCallback

 /**
  * @param \Closure|array $callback
  * @param array $args
  *
  * @return mixed
  */
 private function executeCallback($callback, array $args)
 {
     // Support Contao's getInstance() method when callback is an array
     if (is_array($callback)) {
         return call_user_func_array([System::importStatic($callback[0]), $callback[1]], $args);
     }
     return call_user_func_array($callback, $args);
 }
开发者ID:terminal42,项目名称:contao-changelanguage,代码行数:14,代码来源:LabelCallback.php

示例2: executeResize

 /**
  * {@inheritdoc}
  */
 protected function executeResize(ImageInterface $image, ResizeCoordinatesInterface $coordinates, $path, ResizeOptionsInterface $options)
 {
     if (isset($GLOBALS['TL_HOOKS']['getImage']) && is_array($GLOBALS['TL_HOOKS']['getImage']) && $this->legacyImage) {
         foreach ($GLOBALS['TL_HOOKS']['getImage'] as $callback) {
             $return = System::importStatic($callback[0])->{$callback[1]}($this->legacyImage->getOriginalPath(), $this->legacyImage->getTargetWidth(), $this->legacyImage->getTargetHeight(), $this->legacyImage->getResizeMode(), $this->legacyImage->getCacheName(), new File($this->legacyImage->getOriginalPath()), $this->legacyImage->getTargetPath(), $this->legacyImage);
             if (is_string($return)) {
                 return $this->createImage($image, TL_ROOT . '/' . $return);
             }
         }
     }
     if ($image->getImagine() instanceof GdImagine) {
         /** @var Config $config */
         $config = $this->framework->getAdapter(Config::class);
         $dimensions = $image->getDimensions();
         // Return the path to the original image if it cannot be handled
         if ($dimensions->getSize()->getWidth() > $config->get('gdMaxImgWidth') || $dimensions->getSize()->getHeight() > $config->get('gdMaxImgHeight') || $coordinates->getSize()->getWidth() > $config->get('gdMaxImgWidth') || $coordinates->getSize()->getHeight() > $config->get('gdMaxImgHeight')) {
             return $this->createImage($image, $image->getPath());
         }
     }
     return parent::executeResize($image, $coordinates, $path, $options);
 }
开发者ID:contao,项目名称:core-bundle,代码行数:24,代码来源:LegacyResizer.php

示例3: applyLegacyLogic

 /**
  * Modifies a URL from the URL generator.
  *
  * @param string $strUrl
  * @param string $strParams
  *
  * @return string
  */
 private function applyLegacyLogic($strUrl, $strParams)
 {
     // Decode sprintf placeholders
     if (strpos($strParams, '%') !== false) {
         @trigger_error('Using sprintf placeholders in URLs has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);
         $arrMatches = array();
         preg_match_all('/%([sducoxXbgGeEfF])/', $strParams, $arrMatches);
         foreach (array_unique($arrMatches[1]) as $v) {
             $strUrl = str_replace('%25' . $v, '%' . $v, $strUrl);
         }
     }
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['generateFrontendUrl']) && is_array($GLOBALS['TL_HOOKS']['generateFrontendUrl'])) {
         @trigger_error('Using the "generateFrontendUrl" hook has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);
         foreach ($GLOBALS['TL_HOOKS']['generateFrontendUrl'] as $callback) {
             $strUrl = \System::importStatic($callback[0])->{$callback[1]}($this->row(), $strParams, $strUrl);
         }
         return $strUrl;
     }
     return $strUrl;
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:29,代码来源:PageModel.php

示例4: triggerInitializeSystemHook

 /**
  * Triggers the initializeSystem hook (see #5665).
  */
 private function triggerInitializeSystemHook()
 {
     if (isset($GLOBALS['TL_HOOKS']['initializeSystem']) && is_array($GLOBALS['TL_HOOKS']['initializeSystem'])) {
         foreach ($GLOBALS['TL_HOOKS']['initializeSystem'] as $callback) {
             System::importStatic($callback[0])->{$callback}[1]();
         }
     }
     if (file_exists($this->rootDir . '/system/config/initconfig.php')) {
         include $this->rootDir . '/system/config/initconfig.php';
     }
 }
开发者ID:jamesdevine,项目名称:core-bundle,代码行数:14,代码来源:ContaoFramework.php

示例5: getSystemMessages

 /**
  * Return the system messages as HTML
  *
  * @return string The messages HTML markup
  */
 public static function getSystemMessages()
 {
     $strMessages = '';
     // HOOK: add custom messages
     if (isset($GLOBALS['TL_HOOKS']['getSystemMessages']) && is_array($GLOBALS['TL_HOOKS']['getSystemMessages'])) {
         $arrMessages = array();
         foreach ($GLOBALS['TL_HOOKS']['getSystemMessages'] as $callback) {
             $strBuffer = \System::importStatic($callback[0])->{$callback[1]}();
             if ($strBuffer != '') {
                 $arrMessages[] = $strBuffer;
             }
         }
         if (!empty($arrMessages)) {
             $strMessages .= implode("\n", $arrMessages);
         }
     }
     return $strMessages;
 }
开发者ID:contao,项目名称:core-bundle,代码行数:23,代码来源:Backend.php

示例6: getResponseFromCache

 /**
  * Check whether there is a cached version of the page and return a response object
  *
  * @return Response|null
  */
 public static function getResponseFromCache()
 {
     // Build the page if a user is (potentially) logged in or there is POST data
     if (!empty($_POST) || \Input::cookie('BE_USER_AUTH') || \Input::cookie('FE_USER_AUTH') || \Input::cookie('FE_AUTO_LOGIN') || $_SESSION['DISABLE_CACHE'] || isset($_SESSION['LOGIN_ERROR']) || \Message::hasMessages() || \Config::get('debugMode')) {
         return null;
     }
     $strCacheDir = \System::getContainer()->getParameter('kernel.cache_dir');
     // Try to map the empty request
     if (\Environment::get('relativeRequest') == '') {
         // Return if the language is added to the URL and the empty domain will be redirected
         if (\Config::get('addLanguageToUrl') && !\Config::get('doNotRedirectEmpty')) {
             return null;
         }
         $strCacheKey = null;
         $arrLanguage = \Environment::get('httpAcceptLanguage');
         $strMappingFile = $strCacheDir . '/contao/config/mapping.php';
         // Try to get the cache key from the mapper array
         if (file_exists($strMappingFile)) {
             $arrMapper = (include $strMappingFile);
             $arrPaths = array(\Environment::get('host'), '*');
             // Try the language specific keys
             foreach ($arrLanguage as $strLanguage) {
                 foreach ($arrPaths as $strPath) {
                     $strKey = $strPath . '/empty.' . $strLanguage;
                     if (isset($arrMapper[$strKey])) {
                         $strCacheKey = $arrMapper[$strKey];
                         break;
                     }
                 }
             }
             // Try the fallback key
             if ($strCacheKey === null) {
                 foreach ($arrPaths as $strPath) {
                     $strKey = $strPath . '/empty.fallback';
                     if (isset($arrMapper[$strKey])) {
                         $strCacheKey = $arrMapper[$strKey];
                         break;
                     }
                 }
             }
         }
         // Fall back to the first accepted language
         if ($strCacheKey === null) {
             $strCacheKey = \Environment::get('host') . '/empty.' . $arrLanguage[0];
         }
     } else {
         $strCacheKey = \Environment::get('host') . '/' . \Environment::get('relativeRequest');
     }
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['getCacheKey']) && is_array($GLOBALS['TL_HOOKS']['getCacheKey'])) {
         foreach ($GLOBALS['TL_HOOKS']['getCacheKey'] as $callback) {
             $strCacheKey = \System::importStatic($callback[0])->{$callback[1]}($strCacheKey);
         }
     }
     $blnFound = false;
     $strCacheFile = null;
     // Check for a mobile layout
     if (\Input::cookie('TL_VIEW') == 'mobile' || \Environment::get('agent')->mobile && \Input::cookie('TL_VIEW') != 'desktop') {
         $strMd5CacheKey = md5($strCacheKey . '.mobile');
         $strCacheFile = $strCacheDir . '/contao/html/' . substr($strMd5CacheKey, 0, 1) . '/' . $strMd5CacheKey . '.html';
         if (file_exists($strCacheFile)) {
             $blnFound = true;
         }
     } else {
         $strMd5CacheKey = md5($strCacheKey . '.desktop');
         $strCacheFile = $strCacheDir . '/contao/html/' . substr($strMd5CacheKey, 0, 1) . '/' . $strMd5CacheKey . '.html';
         if (file_exists($strCacheFile)) {
             $blnFound = true;
         }
     }
     // Check for a regular layout
     if (!$blnFound) {
         $strMd5CacheKey = md5($strCacheKey);
         $strCacheFile = $strCacheDir . '/contao/html/' . substr($strMd5CacheKey, 0, 1) . '/' . $strMd5CacheKey . '.html';
         if (file_exists($strCacheFile)) {
             $blnFound = true;
         }
     }
     // Return if the file does not exist
     if (!$blnFound) {
         return null;
     }
     $expire = null;
     $content = null;
     $type = null;
     $files = null;
     $assets = null;
     // Include the file
     ob_start();
     require_once $strCacheFile;
     // The file has expired
     if ($expire < time()) {
         ob_end_clean();
         return null;
     }
//.........这里部分代码省略.........
开发者ID:bytehead,项目名称:core-bundle,代码行数:101,代码来源:Frontend.php

示例7: exportTheme

 /**
  * Export a theme
  *
  * @param DataContainer $dc
  */
 public function exportTheme(DataContainer $dc)
 {
     // Get the theme meta data
     $objTheme = $this->Database->prepare("SELECT * FROM tl_theme WHERE id=?")->limit(1)->execute($dc->id);
     if ($objTheme->numRows < 1) {
         return;
     }
     // Romanize the name
     $strName = Utf8::toAscii($objTheme->name);
     $strName = strtolower(str_replace(' ', '_', $strName));
     $strName = preg_replace('/[^A-Za-z0-9._-]/', '', $strName);
     $strName = basename($strName);
     // Create a new XML document
     $xml = new \DOMDocument('1.0', 'UTF-8');
     $xml->formatOutput = true;
     // Root element
     $tables = $xml->createElement('tables');
     $tables = $xml->appendChild($tables);
     // Add the tables
     $this->addTableTlTheme($xml, $tables, $objTheme);
     $this->addTableTlStyleSheet($xml, $tables, $objTheme);
     $this->addTableTlImageSize($xml, $tables, $objTheme);
     $this->addTableTlModule($xml, $tables, $objTheme);
     $this->addTableTlLayout($xml, $tables, $objTheme);
     // Generate the archive
     $strTmp = md5(uniqid(mt_rand(), true));
     $objArchive = new \ZipWriter('system/tmp/' . $strTmp);
     // Add the files
     $this->addTableTlFiles($xml, $tables, $objTheme, $objArchive);
     // Add the template files
     $this->addTemplatesToArchive($objArchive, $objTheme->templates);
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['exportTheme']) && is_array($GLOBALS['TL_HOOKS']['exportTheme'])) {
         foreach ($GLOBALS['TL_HOOKS']['exportTheme'] as $callback) {
             \System::importStatic($callback[0])->{$callback[1]}($xml, $objArchive, $objTheme->id);
         }
     }
     // Add the XML document
     $objArchive->addString($xml->saveXML(), 'theme.xml');
     // Close the archive
     $objArchive->close();
     // Open the "save as …" dialogue
     $objFile = new \File('system/tmp/' . $strTmp);
     $objFile->sendToBrowser($strName . '.cto');
 }
开发者ID:contao,项目名称:core-bundle,代码行数:50,代码来源:Theme.php

示例8: importFromPath

 /**
  * Import files from selected folder
  *
  * @param string $strPath
  */
 protected function importFromPath($strPath)
 {
     $arrFiles = scan(TL_ROOT . '/' . $strPath);
     if (empty($arrFiles)) {
         Message::addError($GLOBALS['TL_LANG']['MSC']['noFilesInFolder']);
         Controller::reload();
     }
     $blnEmpty = true;
     $arrDelete = array();
     $objProducts = \Database::getInstance()->prepare("SELECT * FROM tl_iso_product WHERE pid=0")->execute();
     while ($objProducts->next()) {
         $arrImageNames = array();
         $arrImages = deserialize($objProducts->images);
         if (!is_array($arrImages)) {
             $arrImages = array();
         } else {
             foreach ($arrImages as $row) {
                 if ($row['src']) {
                     $arrImageNames[] = $row['src'];
                 }
             }
         }
         $arrPattern = array();
         $arrPattern[] = $objProducts->alias ? standardize($objProducts->alias) : null;
         $arrPattern[] = $objProducts->sku ? $objProducts->sku : null;
         $arrPattern[] = $objProducts->sku ? standardize($objProducts->sku) : null;
         $arrPattern[] = !empty($arrImageNames) ? implode('|', $arrImageNames) : null;
         // !HOOK: add custom import regex patterns
         if (isset($GLOBALS['ISO_HOOKS']['addAssetImportRegexp']) && is_array($GLOBALS['ISO_HOOKS']['addAssetImportRegexp'])) {
             foreach ($GLOBALS['ISO_HOOKS']['addAssetImportRegexp'] as $callback) {
                 $objCallback = System::importStatic($callback[0]);
                 $arrPattern = $objCallback->{$callback}[1]($arrPattern, $objProducts);
             }
         }
         $strPattern = '@^(' . implode('|', array_filter($arrPattern)) . ')@i';
         $arrMatches = preg_grep($strPattern, $arrFiles);
         if (!empty($arrMatches)) {
             $arrNewImages = array();
             foreach ($arrMatches as $file) {
                 if (is_dir(TL_ROOT . '/' . $strPath . '/' . $file)) {
                     $arrSubfiles = scan(TL_ROOT . '/' . $strPath . '/' . $file);
                     if (!empty($arrSubfiles)) {
                         foreach ($arrSubfiles as $subfile) {
                             if (is_file($strPath . '/' . $file . '/' . $subfile)) {
                                 $objFile = new File($strPath . '/' . $file . '/' . $subfile);
                                 if ($objFile->isGdImage) {
                                     $arrNewImages[] = $strPath . '/' . $file . '/' . $subfile;
                                 }
                             }
                         }
                     }
                 } elseif (is_file(TL_ROOT . '/' . $strPath . '/' . $file)) {
                     $objFile = new \File($strPath . '/' . $file);
                     if ($objFile->isGdImage) {
                         $arrNewImages[] = $strPath . '/' . $file;
                     }
                 }
             }
             if (!empty($arrNewImages)) {
                 foreach ($arrNewImages as $strFile) {
                     $pathinfo = pathinfo(TL_ROOT . '/' . $strFile);
                     // Will recursively create the folder
                     $objFolder = new \Folder('isotope/' . strtolower(substr($pathinfo['filename'], 0, 1)));
                     $strCacheName = $pathinfo['filename'] . '-' . substr(md5_file(TL_ROOT . '/' . $strFile), 0, 8) . '.' . $pathinfo['extension'];
                     \Files::getInstance()->copy($strFile, $objFolder->path . '/' . $strCacheName);
                     $arrImages[] = array('src' => $strCacheName);
                     $arrDelete[] = $strFile;
                     Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['MSC']['assetImportConfirmation'], $pathinfo['filename'] . '.' . $pathinfo['extension'], $objProducts->name));
                     $blnEmpty = false;
                 }
                 \Database::getInstance()->prepare("UPDATE tl_iso_product SET images=? WHERE id=?")->execute(serialize($arrImages), $objProducts->id);
             }
         }
     }
     if (!empty($arrDelete)) {
         $arrDelete = array_unique($arrDelete);
         foreach ($arrDelete as $file) {
             \Files::getInstance()->delete($file);
         }
     }
     if ($blnEmpty) {
         \Message::addInfo($GLOBALS['TL_LANG']['MSC']['assetImportNoFilesFound']);
     }
     \Controller::reload();
 }
开发者ID:Aziz-JH,项目名称:isotope_attribute_option_import,代码行数:90,代码来源:Attribute.php

示例9: triggerInitializeSystemHook

 /**
  * Triggers the initializeSystem hook (see #5665).
  */
 private function triggerInitializeSystemHook()
 {
     if (isset($GLOBALS['TL_HOOKS']['initializeSystem']) && is_array($GLOBALS['TL_HOOKS']['initializeSystem'])) {
         foreach ($GLOBALS['TL_HOOKS']['initializeSystem'] as $callback) {
             System::importStatic($callback[0])->{$callback[1]}();
         }
     }
     if (file_exists($this->rootDir . '/../system/config/initconfig.php')) {
         @trigger_error('Using the initconfig.php file has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);
         include $this->rootDir . '/../system/config/initconfig.php';
     }
 }
开发者ID:contao,项目名称:core-bundle,代码行数:15,代码来源:ContaoFramework.php

示例10: fetchItems

 /**
  * Fetch the matching items
  *
  * @param  array   $newsArchives
  * @param  boolean $blnFeatured
  * @param  integer $limit
  * @param  integer $offset
  *
  * @return Model\Collection|NewsModel|null
  */
 protected function fetchItems($newsArchives, $blnFeatured, $limit, $offset)
 {
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['newsListFetchItems']) && is_array($GLOBALS['TL_HOOKS']['newsListFetchItems'])) {
         foreach ($GLOBALS['TL_HOOKS']['newsListFetchItems'] as $callback) {
             if (($objCollection = \System::importStatic($callback[0])->{$callback[1]}($newsArchives, $blnFeatured, $limit, $offset, $this)) === false) {
                 continue;
             }
             if ($objCollection === null || $objCollection instanceof Model\Collection) {
                 return $objCollection;
             }
         }
     }
     return \NewsModel::findPublishedByPids($newsArchives, $blnFeatured, $limit, $offset);
 }
开发者ID:contao,项目名称:news-bundle,代码行数:25,代码来源:ModuleNewsList.php

示例11: indexPage

 /**
  * Index a page
  *
  * @param array $arrData The data array
  *
  * @return boolean True if a new record was created
  */
 public static function indexPage($arrData)
 {
     $objDatabase = \Database::getInstance();
     $arrSet['tstamp'] = time();
     $arrSet['url'] = $arrData['url'];
     $arrSet['title'] = $arrData['title'];
     $arrSet['protected'] = $arrData['protected'];
     $arrSet['filesize'] = $arrData['filesize'];
     $arrSet['groups'] = $arrData['groups'];
     $arrSet['pid'] = $arrData['pid'];
     $arrSet['language'] = $arrData['language'];
     // Get the file size from the raw content
     if (!$arrSet['filesize']) {
         $arrSet['filesize'] = number_format(strlen($arrData['content']) / 1024, 2, '.', '');
     }
     // Replace special characters
     $strContent = str_replace(array("\n", "\r", "\t", '&#160;', '&nbsp;', '&shy;'), array(' ', ' ', ' ', ' ', ' ', ''), $arrData['content']);
     // Strip script tags
     while (($intStart = strpos($strContent, '<script')) !== false) {
         if (($intEnd = strpos($strContent, '</script>', $intStart)) !== false) {
             $strContent = substr($strContent, 0, $intStart) . substr($strContent, $intEnd + 9);
         } else {
             break;
             // see #5119
         }
     }
     // Strip style tags
     while (($intStart = strpos($strContent, '<style')) !== false) {
         if (($intEnd = strpos($strContent, '</style>', $intStart)) !== false) {
             $strContent = substr($strContent, 0, $intStart) . substr($strContent, $intEnd + 8);
         } else {
             break;
             // see #5119
         }
     }
     // Strip non-indexable areas
     while (($intStart = strpos($strContent, '<!-- indexer::stop -->')) !== false) {
         if (($intEnd = strpos($strContent, '<!-- indexer::continue -->', $intStart)) !== false) {
             $intCurrent = $intStart;
             // Handle nested tags
             while (($intNested = strpos($strContent, '<!-- indexer::stop -->', $intCurrent + 22)) !== false && $intNested < $intEnd) {
                 if (($intNewEnd = strpos($strContent, '<!-- indexer::continue -->', $intEnd + 26)) !== false) {
                     $intEnd = $intNewEnd;
                     $intCurrent = $intNested;
                 } else {
                     break;
                     // see #5119
                 }
             }
             $strContent = substr($strContent, 0, $intStart) . substr($strContent, $intEnd + 26);
         } else {
             break;
             // see #5119
         }
     }
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['indexPage']) && is_array($GLOBALS['TL_HOOKS']['indexPage'])) {
         foreach ($GLOBALS['TL_HOOKS']['indexPage'] as $callback) {
             \System::importStatic($callback[0])->{$callback[1]}($strContent, $arrData, $arrSet);
         }
     }
     // Free the memory
     unset($arrData['content']);
     $arrMatches = array();
     preg_match('/<\\/head>/', $strContent, $arrMatches, PREG_OFFSET_CAPTURE);
     $intOffset = strlen($arrMatches[0][0]) + $arrMatches[0][1];
     // Split page in head and body section
     $strHead = substr($strContent, 0, $intOffset);
     $strBody = substr($strContent, $intOffset);
     unset($strContent);
     $tags = array();
     // Get the description
     if (preg_match('/<meta[^>]+name="description"[^>]+content="([^"]*)"[^>]*>/i', $strHead, $tags)) {
         $arrData['description'] = trim(preg_replace('/ +/', ' ', \StringUtil::decodeEntities($tags[1])));
     }
     // Get the keywords
     if (preg_match('/<meta[^>]+name="keywords"[^>]+content="([^"]*)"[^>]*>/i', $strHead, $tags)) {
         $arrData['keywords'] = trim(preg_replace('/ +/', ' ', \StringUtil::decodeEntities($tags[1])));
     }
     // Read the title and alt attributes
     if (preg_match_all('/<* (title|alt)="([^"]*)"[^>]*>/i', $strBody, $tags)) {
         $arrData['keywords'] .= ' ' . implode(', ', array_unique($tags[2]));
     }
     // Add a whitespace character before line-breaks and between consecutive tags (see #5363)
     $strBody = str_ireplace(array('<br', '><'), array(' <br', '> <'), $strBody);
     $strBody = strip_tags($strBody);
     // Put everything together
     $arrSet['text'] = $arrData['title'] . ' ' . $arrData['description'] . ' ' . $strBody . ' ' . $arrData['keywords'];
     $arrSet['text'] = trim(preg_replace('/ +/', ' ', \StringUtil::decodeEntities($arrSet['text'])));
     // Calculate the checksum
     $arrSet['checksum'] = md5($arrSet['text']);
     $objIndex = $objDatabase->prepare("SELECT id, url FROM tl_search WHERE checksum=? AND pid=?")->limit(1)->execute($arrSet['checksum'], $arrSet['pid']);
     // Update the URL if the new URL is shorter or the current URL is not canonical
//.........这里部分代码省略.........
开发者ID:contao,项目名称:core-bundle,代码行数:101,代码来源:Search.php

示例12: executeResize

 /**
  * Resize the image
  *
  * @return $this The image object
  */
 public function executeResize()
 {
     $image = $this->prepareImage();
     $resizeConfig = $this->prepareResizeConfig();
     if (!System::getContainer()->getParameter('contao.image.bypass_cache') && $this->getTargetPath() && !$this->getForceOverride() && file_exists(TL_ROOT . '/' . $this->getTargetPath()) && $this->fileObj->mtime <= filemtime(TL_ROOT . '/' . $this->getTargetPath())) {
         // HOOK: add custom logic
         if (isset($GLOBALS['TL_HOOKS']['executeResize']) && is_array($GLOBALS['TL_HOOKS']['executeResize'])) {
             foreach ($GLOBALS['TL_HOOKS']['executeResize'] as $callback) {
                 $return = \System::importStatic($callback[0])->{$callback[1]}($this);
                 if (is_string($return)) {
                     $this->resizedPath = \System::urlEncode($return);
                     return $this;
                 }
             }
         }
         $this->resizedPath = \System::urlEncode($this->getTargetPath());
         return $this;
     }
     $image = \System::getContainer()->get('contao.image.resizer')->resize($image, $resizeConfig, (new ResizeOptions())->setImagineOptions(\System::getContainer()->getParameter('contao.image.imagine_options'))->setTargetPath($this->targetPath ? TL_ROOT . '/' . $this->targetPath : null)->setBypassCache(\System::getContainer()->getParameter('contao.image.bypass_cache')));
     $this->resizedPath = $image->getPath();
     if (strpos($this->resizedPath, TL_ROOT . '/') === 0 || strpos($this->resizedPath, TL_ROOT . '\\') === 0) {
         $this->resizedPath = substr($this->resizedPath, strlen(TL_ROOT) + 1);
     }
     $this->resizedPath = \System::urlEncode($this->resizedPath);
     return $this;
 }
开发者ID:contao,项目名称:core-bundle,代码行数:31,代码来源:Image.php

示例13: executeHook

 /**
  * Returns false if navigation item should be skipped
  *
  * @param NavigationItem  $navigationItem
  * @param UrlParameterBag $urlParameterBag
  *
  * @return bool
  */
 protected function executeHook(NavigationItem $navigationItem, UrlParameterBag $urlParameterBag)
 {
     // HOOK: allow extensions to modify url parameters
     if (isset($GLOBALS['TL_HOOKS']['changelanguageNavigation']) && is_array($GLOBALS['TL_HOOKS']['changelanguageNavigation'])) {
         $event = new ChangelanguageNavigationEvent($navigationItem, $urlParameterBag);
         foreach ($GLOBALS['TL_HOOKS']['changelanguageNavigation'] as $callback) {
             System::importStatic($callback[0])->{$callback[1]}($event);
             if ($event->isPropagationStopped()) {
                 break;
             }
         }
         return !$event->isSkipped();
     }
     return true;
 }
开发者ID:terminal42,项目名称:contao-changelanguage,代码行数:23,代码来源:ChangeLanguageModule.php

示例14: generateLabel

 /**
  * Generate the label
  *
  * @param array         $row
  * @param string        $label
  * @param DataContainer $dc
  * @param string        $imageAttribute
  * @param boolean       $blnReturnImage
  * @param boolean       $blnProtected
  *
  * @return string
  */
 public function generateLabel(array $row, $label = null, DataContainer $dc = null, $imageAttribute = '', $blnReturnImage = false, $blnProtected = false)
 {
     $default = '';
     if ($GLOBALS['TL_DCA'][$this->table]['list']['sorting']['mode'] === 4) {
         $callback = $GLOBALS['TL_DCA'][$this->table]['list']['sorting']['default_child_record_callback'];
     } else {
         $callback = $GLOBALS['TL_DCA'][$this->table]['list']['label']['default_label_callback'];
     }
     // Get the default label
     if (is_array($callback)) {
         $default = System::importStatic($callback[0])->{$callback[1]}($row, $label, $dc, $imageAttribute, $blnReturnImage, $blnProtected);
     } elseif (is_callable($callback)) {
         $default = $callback($row, $label, $dc, $imageAttribute, $blnReturnImage, $blnProtected);
     }
     $template = new BackendTemplate('be_seo_serp_tests');
     $template->setData($this->generateTests($row));
     $template->label = $default;
     // Add assets
     $GLOBALS['TL_CSS'][] = 'system/modules/seo_serp_preview/assets/css/tests.min.css';
     $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/seo_serp_preview/assets/js/tests.min.js';
     return $template->parse();
 }
开发者ID:derhaeuptling,项目名称:contao-seo-serp-preview,代码行数:34,代码来源:AbstractHandler.php

示例15: addFileMetaInformationToRequest

 /**
  * Add the file meta information to the request
  *
  * @param string  $strUuid
  * @param string  $strPtable
  * @param integer $intPid
  */
 public static function addFileMetaInformationToRequest($strUuid, $strPtable, $intPid)
 {
     $objFile = \FilesModel::findByUuid($strUuid);
     if ($objFile === null) {
         return;
     }
     $arrMeta = deserialize($objFile->meta);
     if (empty($arrMeta)) {
         return;
     }
     $objPage = null;
     $db = \Database::getInstance();
     switch ($strPtable) {
         case 'tl_article':
             $objPage = $db->prepare("SELECT * FROM tl_page WHERE id=(SELECT pid FROM tl_article WHERE id=?)")->execute($intPid);
             break;
         case 'tl_news':
             $objPage = $db->prepare("SELECT * FROM tl_page WHERE id=(SELECT jumpTo FROM tl_news_archive WHERE id=(SELECT pid FROM tl_news WHERE id=?))")->execute($intPid);
             break;
         case 'tl_news_archive':
             $objPage = $db->prepare("SELECT * FROM tl_page WHERE id=(SELECT jumpTo FROM tl_news_archive WHERE id=?)")->execute($intPid);
             break;
         case 'tl_calendar_events':
             $objPage = $db->prepare("SELECT * FROM tl_page WHERE id=(SELECT jumpTo FROM tl_calendar WHERE id=(SELECT pid FROM tl_calendar_events WHERE id=?))")->execute($intPid);
             break;
         case 'tl_calendar':
             $objPage = $db->prepare("SELECT * FROM tl_page WHERE id=(SELECT jumpTo FROM tl_calendar WHERE id=?)")->execute($intPid);
             break;
         case 'tl_faq_category':
             $objPage = $db->prepare("SELECT * FROM tl_page WHERE id=(SELECT jumpTo FROM tl_faq_category WHERE id=?)")->execute($intPid);
             break;
         default:
             // HOOK: support custom modules
             if (isset($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest']) && is_array($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest'])) {
                 foreach ($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest'] as $callback) {
                     if (($val = \System::importStatic($callback[0])->{$callback[1]}($strPtable, $intPid)) !== false) {
                         $objPage = $val;
                     }
                 }
             }
             break;
     }
     if ($objPage === null || $objPage->numRows < 1) {
         return;
     }
     $objModel = new \PageModel();
     $objModel->setRow($objPage->row());
     $objModel->loadDetails();
     // Convert the language to a locale (see #5678)
     $strLanguage = str_replace('-', '_', $objModel->rootLanguage);
     if (isset($arrMeta[$strLanguage])) {
         if (\Input::post('alt') == '' && !empty($arrMeta[$strLanguage]['title'])) {
             \Input::setPost('alt', $arrMeta[$strLanguage]['title']);
         }
         if (\Input::post('caption') == '' && !empty($arrMeta[$strLanguage]['caption'])) {
             \Input::setPost('caption', $arrMeta[$strLanguage]['caption']);
         }
     }
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:66,代码来源:Backend.php


注:本文中的Contao\System::importStatic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。