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


PHP trimsplit函数代码示例

本文整理汇总了PHP中trimsplit函数的典型用法代码示例。如果您正苦于以下问题:PHP trimsplit函数的具体用法?PHP trimsplit怎么用?PHP trimsplit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: loadDetails

 /**
  * 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;
 }
开发者ID:richardhj,项目名称:contao-multidns,代码行数:12,代码来源:PageModel.php

示例2: compileDefinition

 /**
  * 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;
 }
开发者ID:jens-wetzel,项目名称:use2,代码行数:38,代码来源:tl_style.php

示例3: generate

 /**
  * 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&amp;table=tl_module&amp;act=edit&amp;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();
 }
开发者ID:rheintechnology,项目名称:core,代码行数:38,代码来源:ModuleRssReader.php

示例4: 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();
 }
开发者ID:bytehead,项目名称:contao-core,代码行数:31,代码来源:ContentDownload.php

示例5: getTemplate

 /**
  * 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);
 }
开发者ID:rburch,项目名称:core-1,代码行数:33,代码来源:IsotopeTemplate.php

示例6: generate

 /**
  * 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();
 }
开发者ID:rburch,项目名称:core,代码行数:31,代码来源:ContentDownload.php

示例7: getForTemplate

 /**
  * 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 . '&amp;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;
 }
开发者ID:rpquadrat,项目名称:core,代码行数:39,代码来源:ProductCollectionDownload.php

示例8: generate

 /**
  * 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();
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:41,代码来源:Media.php

示例9: run

 /**
  * 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");
 }
开发者ID:rburch,项目名称:core-1,代码行数:32,代码来源:runonce.php

示例10: cb_parseTemplate

 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);
         }
     }
 }
开发者ID:kikmedia,项目名称:contao,代码行数:25,代码来源:NewsSingleFile.php

示例11: getSliderConfig

 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;
 }
开发者ID:heimrichhannot,项目名称:contao-bootstrapper,代码行数:60,代码来源:FormSlider.php

示例12: build

 /**
  * {@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);
     }
 }
开发者ID:pfitz,项目名称:contao-leaflet-maps,代码行数:30,代码来源:PopupMapper.php

示例13: generate

 /**
  * 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&amp;table=tl_module&amp;act=edit&amp;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();
 }
开发者ID:rikaix,项目名称:core,代码行数:36,代码来源:ModuleRssReader.php

示例14: replaceTag

 /**
  * 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];
 }
开发者ID:delahaye,项目名称:dlh_replacetablerecord,代码行数:69,代码来源:ReplaceInsertTags.php

示例15: generate

 /**
  * 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();
 }
开发者ID:felixpfeiffer,项目名称:contao-downloadarchive,代码行数:61,代码来源:ModuleDownloadarchive.php


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