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


PHP StringUtil::substr方法代码示例

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


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

示例1: getAlias

 /**
  * Get all content elements and return them as array (content element alias)
  */
 public function getAlias()
 {
     $arrPids = array();
     $arrAlias = array();
     if (!$this->User->isAdmin) {
         foreach ($this->User->pagemounts as $id) {
             $arrPids[] = $id;
             $arrPids = array_merge($arrPids, $this->Database->getChildRecords($id, 'tl_page'));
         }
         if (empty($arrPids)) {
             return $arrAlias;
         }
         $objAlias = $this->Database->prepare("SELECT c.id, c.pid, c.type, (CASE c.type WHEN 'module' THEN m.name WHEN 'form' THEN f.title WHEN 'table' THEN c.summary ELSE c.headline END) AS headline, c.text, a.title FROM tl_content c LEFT JOIN tl_page a ON a.id=c.pid LEFT JOIN tl_module m ON m.id=c.module LEFT JOIN tl_form f on f.id=c.form WHERE a.pid IN(" . implode(',', array_map('intval', array_unique($arrPids))) . ") AND (c.ptable='tl_page') AND c.id!=? ORDER BY a.title, c.sorting")->execute(Input::get('id'));
     } else {
         $objAlias = $this->Database->prepare("SELECT c.id, c.pid, c.type, (CASE c.type WHEN 'module' THEN m.name WHEN 'form' THEN f.title WHEN 'table' THEN c.summary ELSE c.headline END) AS headline, c.text, a.title FROM tl_content c LEFT JOIN tl_page a ON a.id=c.pid LEFT JOIN tl_module m ON m.id=c.module LEFT JOIN tl_form f on f.id=c.form WHERE (c.ptable='tl_page') AND c.id!=? ORDER BY a.title, c.sorting")->execute(Input::get('id'));
     }
     while ($objAlias->next()) {
         $arrHeadline = deserialize($objAlias->headline, true);
         if (isset($arrHeadline['value'])) {
             $headline = StringUtil::substr($arrHeadline['value'], 32);
         } else {
             $headline = StringUtil::substr(preg_replace('/[\\n\\r\\t]+/', ' ', $arrHeadline[0]), 32);
         }
         $text = StringUtil::substr(strip_tags(preg_replace('/[\\n\\r\\t]+/', ' ', $objAlias->text)), 32);
         $strText = $GLOBALS['TL_LANG']['CTE'][$objAlias->type][0] . ' (';
         if ($headline != '') {
             $strText .= $headline . ', ';
         } elseif ($text != '') {
             $strText .= $text . ', ';
         }
         $key = $objAlias->title . ' (ID ' . $objAlias->pid . ')';
         $arrAlias[$key][$objAlias->id] = $strText . 'ID ' . $objAlias->id . ')';
     }
     return $arrAlias;
 }
开发者ID:alarstyle,项目名称:contao-no_more_articles,代码行数:38,代码来源:tl_content.php

示例2: run

 /**
  * Generate the module
  *
  * @return string
  */
 public function run()
 {
     if (!\Config::get('enableSearch')) {
         return '';
     }
     $time = time();
     /** @var \BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_rebuild_index');
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->indexHeadline = $GLOBALS['TL_LANG']['tl_maintenance']['searchIndex'];
     $objTemplate->isActive = $this->isActive();
     // Add the error message
     if ($_SESSION['REBUILD_INDEX_ERROR'] != '') {
         $objTemplate->indexMessage = $_SESSION['REBUILD_INDEX_ERROR'];
         $_SESSION['REBUILD_INDEX_ERROR'] = '';
     }
     // Rebuild the index
     if (\Input::get('act') == 'index') {
         // Check the request token (see #4007)
         if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) {
             $this->Session->set('INVALID_TOKEN_URL', \Environment::get('request'));
             $this->redirect('contao/confirm.php');
         }
         $arrPages = $this->findSearchablePages();
         // HOOK: take additional pages
         if (isset($GLOBALS['TL_HOOKS']['getSearchablePages']) && is_array($GLOBALS['TL_HOOKS']['getSearchablePages'])) {
             foreach ($GLOBALS['TL_HOOKS']['getSearchablePages'] as $callback) {
                 $this->import($callback[0]);
                 $arrPages = $this->{$callback[0]}->{$callback[1]}($arrPages);
             }
         }
         // Return if there are no pages
         if (empty($arrPages)) {
             $_SESSION['REBUILD_INDEX_ERROR'] = $GLOBALS['TL_LANG']['tl_maintenance']['noSearchable'];
             $this->redirect($this->getReferer());
         }
         // Truncate the search tables
         $this->import('Automator');
         $this->Automator->purgeSearchTables();
         // Hide unpublished elements
         $this->setCookie('FE_PREVIEW', 0, $time - 86400);
         // Calculate the hash
         $strHash = sha1(session_id() . (!\Config::get('disableIpCheck') ? \Environment::get('ip') : '') . 'FE_USER_AUTH');
         // Remove old sessions
         $this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute($time - \Config::get('sessionTimeout'), $strHash);
         // Log in the front end user
         if (is_numeric(\Input::get('user')) && \Input::get('user') > 0) {
             // Insert a new session
             $this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute(\Input::get('user'), $time, 'FE_USER_AUTH', session_id(), \Environment::get('ip'), $strHash);
             // Set the cookie
             $this->setCookie('FE_USER_AUTH', $strHash, $time + \Config::get('sessionTimeout'), null, null, false, true);
         } else {
             // Unset the cookies
             $this->setCookie('FE_USER_AUTH', $strHash, $time - 86400, null, null, false, true);
             $this->setCookie('FE_AUTO_LOGIN', \Input::cookie('FE_AUTO_LOGIN'), $time - 86400, null, null, false, true);
         }
         $strBuffer = '';
         $rand = rand();
         // Display the pages
         for ($i = 0, $c = count($arrPages); $i < $c; $i++) {
             $strBuffer .= '<span class="page_url" data-url="' . $arrPages[$i] . '#' . $rand . $i . '">' . \StringUtil::substr($arrPages[$i], 100) . '</span><br>';
             unset($arrPages[$i]);
             // see #5681
         }
         $objTemplate->content = $strBuffer;
         $objTemplate->note = $GLOBALS['TL_LANG']['tl_maintenance']['indexNote'];
         $objTemplate->loading = $GLOBALS['TL_LANG']['tl_maintenance']['indexLoading'];
         $objTemplate->complete = $GLOBALS['TL_LANG']['tl_maintenance']['indexComplete'];
         $objTemplate->indexContinue = $GLOBALS['TL_LANG']['MSC']['continue'];
         $objTemplate->theme = \Backend::getTheme();
         $objTemplate->isRunning = true;
         return $objTemplate->parse();
     }
     $arrUser = array('' => '-');
     // Get active front end users
     $objUser = $this->Database->execute("SELECT id, username FROM tl_member WHERE disable!='1' AND (start='' OR start<='{$time}') AND (stop='' OR stop>'" . ($time + 60) . "') ORDER BY username");
     while ($objUser->next()) {
         $arrUser[$objUser->id] = $objUser->username . ' (' . $objUser->id . ')';
     }
     // Default variables
     $objTemplate->user = $arrUser;
     $objTemplate->indexLabel = $GLOBALS['TL_LANG']['tl_maintenance']['frontendUser'][0];
     $objTemplate->indexHelp = \Config::get('showHelp') && strlen($GLOBALS['TL_LANG']['tl_maintenance']['frontendUser'][1]) ? $GLOBALS['TL_LANG']['tl_maintenance']['frontendUser'][1] : '';
     $objTemplate->indexSubmit = $GLOBALS['TL_LANG']['tl_maintenance']['indexSubmit'];
     return $objTemplate->parse();
 }
开发者ID:bytehead,项目名称:contao-core,代码行数:91,代码来源:RebuildIndex.php

示例3: addToTemplate

 /**
  * Add a list of versions to a template
  *
  * @param \BackendTemplate|object $objTemplate
  */
 public static function addToTemplate(\BackendTemplate $objTemplate)
 {
     $arrVersions = array();
     $objUser = \BackendUser::getInstance();
     $objDatabase = \Database::getInstance();
     // Get the total number of versions
     $objTotal = $objDatabase->prepare("SELECT COUNT(*) AS count FROM tl_version WHERE version>1" . (!$objUser->isAdmin ? " AND userid=?" : ""))->execute($objUser->id);
     $intLast = ceil($objTotal->count / 30);
     $intPage = \Input::get('vp') !== null ? \Input::get('vp') : 1;
     $intOffset = ($intPage - 1) * 30;
     // Validate the page number
     if ($intPage < 1 || $intLast > 0 && $intPage > $intLast) {
         header('HTTP/1.1 404 Not Found');
     }
     // Create the pagination menu
     $objPagination = new \Pagination($objTotal->count, 30, 7, 'vp', new \BackendTemplate('be_pagination'));
     $objTemplate->pagination = $objPagination->generate();
     // Get the versions
     $objVersions = $objDatabase->prepare("SELECT pid, tstamp, version, fromTable, username, userid, description, editUrl, active FROM tl_version" . (!$objUser->isAdmin ? " WHERE userid=?" : "") . " ORDER BY tstamp DESC, pid, version DESC")->limit(30, $intOffset)->execute($objUser->id);
     while ($objVersions->next()) {
         $arrRow = $objVersions->row();
         // Add some parameters
         $arrRow['from'] = max($objVersions->version - 1, 1);
         // see #4828
         $arrRow['to'] = $objVersions->version;
         $arrRow['date'] = date(\Config::get('datimFormat'), $objVersions->tstamp);
         $arrRow['description'] = \StringUtil::substr($arrRow['description'], 32);
         $arrRow['shortTable'] = \StringUtil::substr($arrRow['fromTable'], 18);
         // see #5769
         if ($arrRow['editUrl'] != '') {
             $arrRow['editUrl'] = preg_replace('/&(amp;)?rt=[a-f0-9]+/', '&amp;rt=' . REQUEST_TOKEN, ampersand($arrRow['editUrl']));
         }
         $arrVersions[] = $arrRow;
     }
     $intCount = -1;
     $arrVersions = array_values($arrVersions);
     // Add the "even" and "odd" classes
     foreach ($arrVersions as $k => $v) {
         $arrVersions[$k]['class'] = ++$intCount % 2 == 0 ? 'even' : 'odd';
         try {
             // Mark deleted versions (see #4336)
             $objDeleted = $objDatabase->prepare("SELECT COUNT(*) AS count FROM " . $v['fromTable'] . " WHERE id=?")->execute($v['pid']);
             $arrVersions[$k]['deleted'] = $objDeleted->count < 1;
         } catch (\Exception $e) {
             // Probably a disabled module
             --$intCount;
             unset($arrVersions[$k]);
         }
     }
     $objTemplate->versions = $arrVersions;
 }
开发者ID:Jobu,项目名称:core,代码行数:56,代码来源:Versions.php

示例4: prepareMetaDescription

 /**
  * Prepare a text to be used in the meta description tag
  *
  * @param string $strText
  *
  * @return string
  */
 protected function prepareMetaDescription($strText)
 {
     $strText = $this->replaceInsertTags($strText, false);
     $strText = strip_tags($strText);
     $strText = str_replace("\n", ' ', $strText);
     $strText = \StringUtil::substr($strText, 180);
     return trim($strText);
 }
开发者ID:StephenGWills,项目名称:sample-contao-app,代码行数:15,代码来源:Frontend.php

示例5: importCsv


//.........这里部分代码省略.........
                             $fieldValue = $fieldValue != '' ? explode($arrDelim, $fieldValue) : null;
                         }
                         \Input::setPost($fieldname, $fieldValue);
                         $objWidget->value = $fieldValue;
                     }
                 }
                 // validate input
                 $objWidget->validate();
                 $fieldValue = $objWidget->value;
                 // Convert date formats into timestamps
                 $rgxp = $arrDCA['eval']['rgxp'];
                 if (($rgxp == 'date' || $rgxp == 'time' || $rgxp == 'datim') && $fieldValue != '' && !$objWidget->hasErrors()) {
                     try {
                         $strTimeFormat = $GLOBALS['TL_CONFIG'][$rgxp . 'Format'];
                         $objDate = new \Date($fieldValue, $strTimeFormat);
                         $fieldValue = $objDate->tstamp;
                     } catch (\OutOfBoundsException $e) {
                         $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $fieldValue));
                     }
                 }
                 // Make sure that unique fields are unique
                 if ($arrDCA['eval']['unique'] && $fieldValue != '' && !$this->Database->isUniqueValue($strTable, $fieldname, $fieldValue, null)) {
                     $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['unique'], $arrDCA['label'][0] ?: $fieldname));
                 }
                 // Do not save the field if there are errors
                 if ($objWidget->hasErrors()) {
                     $doNotSave = true;
                     $fieldValue = sprintf('"%s" => <span class="errMsg">%s</span>', $fieldValue, $objWidget->getErrorsAsString());
                 } else {
                     // Set the correct empty value
                     if ($fieldValue === '') {
                         $fieldValue = $objWidget->getEmptyValue();
                     }
                 }
             }
             $set[$fieldname] = is_array($fieldValue) ? serialize($fieldValue) : $fieldValue;
         }
         // insert data record
         if (!$doNotSave) {
             // insert tstamp
             if ($this->Database->fieldExists('tstamp', $strTable)) {
                 if (!$set['tstamp'] > 0) {
                     $set['tstamp'] = time();
                 }
             }
             // insert dateAdded (tl_member)
             if ($this->Database->fieldExists('dateAdded', $strTable)) {
                 if (!$set['dateAdded'] > 0) {
                     $set['dateAdded'] = time();
                 }
             }
             // add new member to newsletter recipient list
             if ($strTable == 'tl_member' && $set['email'] != '' && $set['newsletter'] != '') {
                 foreach (deserialize($set['newsletter'], true) as $newsletterId) {
                     // check for unique email-address
                     $objRecipient = $this->Database->prepare("SELECT * FROM tl_newsletter_recipients WHERE email=? AND pid=(SELECT pid FROM tl_newsletter_recipients WHERE id=?) AND id!=?")->execute($set['email'], $newsletterId, $newsletterId);
                     if (!$objRecipient->numRows) {
                         $arrRecipient = array();
                         $arrRecipient['tstamp'] = time();
                         $arrRecipient['pid'] = $newsletterId;
                         $arrRecipient['email'] = $set['email'];
                         $arrRecipient['active'] = '1';
                         if ($blnTestMode !== true) {
                             $this->Database->prepare('INSERT INTO tl_newsletter_recipients %s')->set($arrRecipient)->execute();
                         }
                     }
                 }
             }
             try {
                 if ($blnTestMode !== true) {
                     // insert entry into database
                     $this->Database->prepare('INSERT INTO ' . $strTable . ' %s')->set($set)->execute();
                 }
             } catch (\Exception $e) {
                 $set['insertError'] = $e->getMessage();
                 $doNotSave = true;
             }
         }
         // generate html markup for the import report table
         $htmlReport = '';
         $cssClass = 'allOk';
         if ($doNotSave) {
             $cssClass = 'error';
             $htmlReport .= sprintf('<tr class="%s"><td class="tdTitle" colspan="2">#%s Datensatz konnte nicht angelegt werden!</td></tr>', $cssClass, $line);
             // increment error counter if necessary
             $insertError++;
         } else {
             $htmlReport .= sprintf('<tr class="%s"><td class="tdTitle" colspan="2">#%s Datensatz erfolgreich angelegt!</td></tr>', $cssClass, $line);
         }
         foreach ($set as $k => $v) {
             if (is_array($v)) {
                 $v = serialize($v);
             }
             $htmlReport .= sprintf('<tr class="%s"><td>%s</td><td>%s</td></tr>', $cssClass, \StringUtil::substr($k, 30), \StringUtil::substrHtml($v, 90));
         }
         $htmlReport .= '<tr class="delim"><td>&nbsp;</td><td>&nbsp;</td></tr>';
         $_SESSION['import_from_csv']['report'][] = $htmlReport;
     }
     $_SESSION['import_from_csv']['status'] = array('blnTestMode' => $blnTestMode, 'rows' => $rows, 'success' => $rows - $insertError, 'errors' => $insertError);
 }
开发者ID:markocupic,项目名称:import-from-csv-bundle,代码行数:101,代码来源:ImportFromCsv.php

示例6: replaceInsertTagsHooks

 public function replaceInsertTagsHooks($strTag, $blnCache, $strCache, $flags, $tags, $arrCache, $index, $count)
 {
     $params = preg_split('/::/', $strTag);
     if (is_array($params) && !empty($params)) {
         if (strpos($params[0], 'small') === 0) {
             return '<small>';
         }
         if (strpos($params[0], '/small') === 0) {
             return '</small>';
         }
         if (strpos($params[0], 'u') === 0) {
             return '<u>';
         }
         if (strpos($params[0], '/u') === 0) {
             return '</u>';
         }
         if (strpos($params[0], 'i') === 0) {
             $strClass = $params[1] ? ' class="' . $params[1] . '"' : '';
             return '<i' . $strClass . '>';
         }
         if (strpos($params[0], '/i') === 0) {
             return '</i>';
         }
         if (strpos($params[0], 'loremipsum') === 0) {
             $text = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.
             Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
             Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.
             Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet
             a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus.
             Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu,
             consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus.
             Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi
             vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus
             eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam
             nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus.
             Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros
             faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna.
             Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,';
             // trim length
             if (is_numeric($params[1])) {
                 $text = \StringUtil::substr($text, $params[1]);
             }
             return $text;
         }
         if (strpos($params[0], 'btn-dropdown') === 0) {
             $objTag = new \HeimrichHannot\Bootstrapper\BootstrapperButtonDropdown($strTag, $params);
             return $objTag->generate();
         }
         if (strpos($params[0], 'btn') === 0) {
             $objTag = new \HeimrichHannot\Bootstrapper\BootstrapperButton($strTag, $params);
             return $objTag->generate();
         }
     }
     return false;
 }
开发者ID:heimrichhannot,项目名称:contao-bootstrapper,代码行数:55,代码来源:BootstrapperHooks.php

示例7: sprintf

    $count = \Netzmacht\Contao\Leaflet\Model\MarkerModel::countBy('pid', $row['id']);
    $label .= sprintf('<span class="tl_gray"> (%s %s)</span>', $count, $GLOBALS['TL_LANG']['tl_leaflet_layer']['countEntries']);
    return $label;
}), 'vectors' => array('children' => false, 'icon' => 'system/modules/leaflet/assets/img/vectors.png', 'vectors' => true, 'boundsMode' => array('extend' => true), 'label' => function ($row, $label) {
    $count = \Netzmacht\Contao\Leaflet\Model\VectorModel::countBy('pid', $row['id']);
    $label .= sprintf('<span class="tl_gray"> (%s %s)</span>', $count, $GLOBALS['TL_LANG']['tl_leaflet_layer']['countEntries']);
    return $label;
}), 'reference' => array('children' => false, 'icon' => 'system/modules/leaflet/assets/img/reference.png', 'label' => function ($row, $label) {
    $reference = \Netzmacht\Contao\Leaflet\Model\LayerModel::findByPk($row['reference']);
    if ($reference) {
        $label .= '<span class="tl_gray"> (' . $reference->title . ')</span>';
    }
    return $label;
}), 'markercluster' => array('children' => true, 'icon' => 'system/modules/leaflet/assets/img/cluster.png'), 'tile' => array('children' => false, 'icon' => 'system/modules/leaflet/assets/img/tile.png'), 'overpass' => array('children' => false, 'icon' => 'system/modules/leaflet/assets/img/overpass.png', 'label' => function ($row, $label) {
    if ($row['overpassQuery']) {
        $label .= '<span class="tl_gray"> ' . \StringUtil::substr($row['overpassQuery'], 50) . '</span>';
    }
    return $label;
}, 'boundsMode' => array('extend' => true, 'fit' => true)));
/*
 * leaflet controls.
 *
 * Supported leaflet control types. Register your type for the database driven definition here.
 */
$GLOBALS['LEAFLET_CONTROLS'] = array('zoom', 'layers', 'scale', 'attribution', 'loading', 'fullscreen');
/*
 * Leaflet icons.
 *
 * Supported leaflet icon types. Register you type for the database driven definition here.
 */
$GLOBALS['LEAFLET_ICONS'] = array('image', 'div', 'extra');
开发者ID:netzmacht,项目名称:contao-leaflet-maps,代码行数:31,代码来源:config.php

示例8: run

 /**
  * Generate the module
  *
  * @return string
  */
 public function run()
 {
     $this->import('BackendUser', 'User');
     $this->registerEvents();
     $time = time();
     /** @var \BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_filecredits_sync');
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->syncHeadline = $GLOBALS['TL_LANG']['tl_filecredit']['syncHeadline'];
     $objTemplate->isActive = $this->isActive();
     $objTemplate->pageSelection = $this->generatePageSelection();
     if (!\Config::get('headerAddXFrame') || !\Config::get('headerAllowOrigins')) {
         $objTemplate->originInfo = $GLOBALS['TL_LANG']['tl_filecredit']['originInfo'];
     }
     // Add the error message
     if ($_SESSION['REBUILD_FILECREDIT_ERROR'] != '') {
         $objTemplate->indexMessage = $_SESSION['REBUILD_FILECREDIT_ERROR'];
         $_SESSION['REBUILD_FILECREDIT_ERROR'] = '';
     }
     // Rebuild the index
     if (\Input::get('act') == 'index') {
         // Check the request token (see #4007)
         if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) {
             $this->Session->set('INVALID_TOKEN_URL', \Environment::get('request'));
             $this->redirect('contao/confirm.php');
         }
         $arrPages = static::findFileCreditPages();
         // HOOK: take additional pages (news, events…)
         if (isset($GLOBALS['TL_HOOKS']['getSearchablePages']) && is_array($GLOBALS['TL_HOOKS']['getSearchablePages'])) {
             foreach ($GLOBALS['TL_HOOKS']['getSearchablePages'] as $callback) {
                 $this->import($callback[0]);
                 $arrPages = $this->{$callback}[0]->{$callback}[1]($arrPages);
             }
         }
         $blnTruncateTable = true;
         if (\Input::get('limitfilecreditpages')) {
             $arrSelectedPages = \Input::get('filecreditpages');
             if (is_array($arrSelectedPages) && !empty($arrSelectedPages)) {
                 $arrPages = array_keys(array_intersect(array_flip($arrPages), $arrSelectedPages));
                 $blnTruncateTable = false;
             }
         }
         // Return if there are no pages
         if (empty($arrPages)) {
             $_SESSION['REBUILD_FILECREDIT_ERROR'] = $GLOBALS['TL_LANG']['tl_filecredit']['noSearchable'];
             \Controller::redirect(\System::getReferer());
         }
         // Truncate the search tables
         if ($blnTruncateTable) {
             Automator::purgeFileCreditTables();
         }
         // Hide unpublished elements
         $this->setCookie('FE_PREVIEW', 0, $time - 86400);
         // Calculate the hash
         $strHash = sha1(session_id() . (!\Config::get('disableIpCheck') ? \Environment::get('ip') : '') . 'FE_USER_AUTH');
         // Remove old sessions
         $this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute($time - \Config::get('sessionTimeout'), $strHash);
         // Log in the front end user
         if (is_numeric(\Input::get('user')) && \Input::get('user') > 0) {
             // Insert a new session
             $this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute(\Input::get('user'), $time, 'FE_USER_AUTH', session_id(), \Environment::get('ip'), $strHash);
             // Set the cookie
             $this->setCookie('FE_USER_AUTH', $strHash, $time + \Config::get('sessionTimeout'), null, null, false, true);
         } else {
             // Unset the cookies
             $this->setCookie('FE_USER_AUTH', $strHash, $time - 86400, null, null, false, true);
             $this->setCookie('FE_AUTO_LOGIN', \Input::cookie('FE_AUTO_LOGIN'), $time - 86400, null, null, false, true);
         }
         $strBuffer = '';
         $rand = rand();
         // Display the pages
         for ($i = 0, $c = count($arrPages); $i < $c; $i++) {
             if (!\Validator::isUrl($arrPages[$i])) {
                 continue;
             }
             $strBuffer .= '<span class="page_url" data-url="' . $arrPages[$i] . '#' . $rand . $i . '">' . \StringUtil::substr($arrPages[$i], 100) . '</span><br>';
             unset($arrPages[$i]);
             // see #5681
         }
         $objTemplate->content = $strBuffer;
         $objTemplate->note = $GLOBALS['TL_LANG']['tl_filecredit']['indexNote'];
         $objTemplate->loading = $GLOBALS['TL_LANG']['tl_filecredit']['indexLoading'];
         $objTemplate->complete = $GLOBALS['TL_LANG']['tl_filecredit']['indexComplete'];
         $objTemplate->indexContinue = $GLOBALS['TL_LANG']['MSC']['continue'];
         $objTemplate->theme = \Backend::getTheme();
         $objTemplate->isRunning = true;
     }
     // Default variables
     $objTemplate->indexSubmit = $GLOBALS['TL_LANG']['tl_filecredit']['syncSubmit'];
     $objTemplate->backHref = \System::getReferer(true);
     $objTemplate->backTitle = specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']);
     $objTemplate->backButton = $GLOBALS['TL_LANG']['MSC']['backBT'];
     return $objTemplate->parse();
 }
开发者ID:heimrichhannot,项目名称:contao-filecredits,代码行数:99,代码来源:FileCredit.php


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