本文整理汇总了PHP中Contao\StringUtil类的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil类的具体用法?PHP StringUtil怎么用?PHP StringUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the controller and parse the login template
*
* @return Response
*/
public function run()
{
/** @var BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('be_login');
$strHeadline = sprintf($GLOBALS['TL_LANG']['MSC']['loginTo'], \Config::get('websiteTitle'));
$objTemplate->theme = \Backend::getTheme();
$objTemplate->messages = \Message::generate();
$objTemplate->base = \Environment::get('base');
$objTemplate->language = $GLOBALS['TL_LANGUAGE'];
$objTemplate->languages = \System::getLanguages(true);
$objTemplate->title = \StringUtil::specialchars($strHeadline);
$objTemplate->charset = \Config::get('characterSet');
$objTemplate->action = ampersand(\Environment::get('request'));
$objTemplate->userLanguage = $GLOBALS['TL_LANG']['tl_user']['language'][0];
$objTemplate->headline = $strHeadline;
$objTemplate->curLanguage = \Input::post('language') ?: str_replace('-', '_', $GLOBALS['TL_LANGUAGE']);
$objTemplate->curUsername = \Input::post('username') ?: '';
$objTemplate->uClass = $_POST && empty($_POST['username']) ? ' class="login_error"' : '';
$objTemplate->pClass = $_POST && empty($_POST['password']) ? ' class="login_error"' : '';
$objTemplate->loginButton = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['loginBT']);
$objTemplate->username = $GLOBALS['TL_LANG']['tl_user']['username'][0];
$objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
$objTemplate->feLink = $GLOBALS['TL_LANG']['MSC']['feLink'];
$objTemplate->default = $GLOBALS['TL_LANG']['MSC']['default'];
$objTemplate->jsDisabled = $GLOBALS['TL_LANG']['MSC']['jsDisabled'];
return $objTemplate->getResponse();
}
开发者ID:contao,项目名称:core-bundle,代码行数:32,代码来源:BackendIndex.php
示例2: 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']['rssReader'][0]) . ' ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
return $objTemplate->parse();
}
$this->objFeed = new \SimplePie();
$arrUrls = \StringUtil::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:contao,项目名称:core-bundle,代码行数:38,代码来源:ModuleRssReader.php
示例3: compile
/**
* 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')) instanceof PageModel) {
$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 = \StringUtil::deserialize($objArticles->cssID, true);
$articles[] = array('link' => $objArticles->title, 'title' => \StringUtil::specialchars($objArticles->title), 'id' => $cssID[0] ?: 'article-' . $objArticles->id, 'articleId' => $objArticles->id);
}
$this->Template->articles = $articles;
}
开发者ID:contao,项目名称:core-bundle,代码行数:37,代码来源:ModuleArticleList.php
示例4: split_and_fix
public function split_and_fix($size, $scss, $grid, $width, $paddingTop, $paddingBottom, $default)
{
if ($size == 'XS') {
$grid = '90';
$unitGrid = '%';
$width = '90';
$unitWidth = '%';
} else {
$gridvar = is_array($grid) ? $grid : \Contao\StringUtil::deserialize($grid);
$widthvar = is_array($width) ? $width : \Contao\StringUtil::deserialize($width);
$paddingTopvar = is_array($paddingTop) ? $paddingTop : \Contao\StringUtil::deserialize($paddingTop);
$paddingBottomvar = is_array($paddingBottom) ? $paddingBottom : \Contao\StringUtil::deserialize($paddingBottom);
$grid = empty($gridvar['value']) ? $default['Grid'][$size] : $gridvar['value'];
$unitGrid = empty($gridvar['unit']) ? $default['GridUnit'][$size] : $gridvar['unit'];
$width = empty($widthvar['value']) ? $default['Width'][$size] : $widthvar['value'];
$unitWidth = empty($widthvar['unit']) ? $default['WidthUnit'][$size] : $widthvar['unit'];
}
$paddingTop = empty($paddingTopvar['value']) ? $default['PaddingTop'][$size] : $paddingTopvar['value'];
$unitPadingTop = empty($paddingTopvar['unit']) ? $default['PaddingTopUnit'][$size] : $paddingTopvar['unit'];
$paddingBottom = empty($paddingBottomvar['value']) ? $default['PaddingBottom'][$size] : $paddingBottomvar['value'];
$unitPadingBottom = empty($paddingBottomvar['unit']) ? $default['PaddingBottomUnit'][$size] : $paddingBottomvar['unit'];
$grid1 = (int) $grid - 1;
$scss = str_replace('[[grid' . $size . ']]', $grid . $unitGrid, $scss);
$scss = str_replace('[[grid' . $size . '1]]', $grid1 . $unitGrid, $scss);
$scss = str_replace('[[width' . $size . ']]', $width . $unitWidth, $scss);
$scss = str_replace('[[paddingTop' . $size . ']]', $paddingTop . $unitPadingTop, $scss);
$scss = str_replace('[[paddingBottom' . $size . ']]', $paddingBottom . $unitPadingBottom, $scss);
return $scss;
}
开发者ID:christianromeni,项目名称:c-customarticles,代码行数:29,代码来源:SCSSGenerator.php
示例5: compile
/**
* Generate the module
*/
protected function compile()
{
$objFaq = \FaqModel::findPublishedByPids($this->faq_categories);
if ($objFaq === null) {
$this->Template->faq = array();
return;
}
$arrFaq = array_fill_keys($this->faq_categories, array());
// Add FAQs
while ($objFaq->next()) {
$arrTemp = $objFaq->row();
$arrTemp['title'] = \StringUtil::specialchars($objFaq->question, true);
$arrTemp['href'] = $this->generateFaqLink($objFaq);
/** @var FaqCategoryModel $objPid */
$objPid = $objFaq->getRelated('pid');
$arrFaq[$objFaq->pid]['items'][] = $arrTemp;
$arrFaq[$objFaq->pid]['headline'] = $objPid->headline;
$arrFaq[$objFaq->pid]['title'] = $objPid->title;
}
$arrFaq = array_values(array_filter($arrFaq));
$cat_count = 0;
$cat_limit = count($arrFaq);
// Add classes
foreach ($arrFaq as $k => $v) {
$count = 0;
$limit = count($v['items']);
for ($i = 0; $i < $limit; $i++) {
$arrFaq[$k]['items'][$i]['class'] = trim((++$count == 1 ? ' first' : '') . ($count >= $limit ? ' last' : '') . ($count % 2 == 0 ? ' odd' : ' even'));
}
$arrFaq[$k]['class'] = trim((++$cat_count == 1 ? ' first' : '') . ($cat_count >= $cat_limit ? ' last' : '') . ($cat_count % 2 == 0 ? ' odd' : ' even'));
}
$this->Template->faq = $arrFaq;
}
开发者ID:contao,项目名称:faq-bundle,代码行数:36,代码来源:ModuleFaqList.php
示例6: compile
/**
* Generate the module
*/
protected function compile()
{
/** @var PageModel $objPage */
global $objPage;
$arrJumpTo = array();
$arrNewsletter = array();
$strRequest = ampersand(\Environment::get('request'), true);
$objNewsletter = \NewsletterModel::findSentByPids($this->nl_channels);
if ($objNewsletter !== null) {
while ($objNewsletter->next()) {
/** @var NewsletterChannelModel $objTarget */
if (!($objTarget = $objNewsletter->getRelated('pid')) instanceof NewsletterChannelModel) {
continue;
}
$jumpTo = intval($objTarget->jumpTo);
// A jumpTo page is not mandatory for newsletter channels (see #6521) but required for the list module
if ($jumpTo < 1) {
throw new \Exception("Newsletter channels without redirect page cannot be used in a newsletter list");
}
$strUrl = $strRequest;
if (!isset($arrJumpTo[$objTarget->jumpTo])) {
if (($objJumpTo = $objTarget->getRelated('jumpTo')) instanceof PageModel) {
/** @var PageModel $objJumpTo */
$arrJumpTo[$objTarget->jumpTo] = $objJumpTo->getFrontendUrl(\Config::get('useAutoItem') ? '/%s' : '/items/%s');
} else {
$arrJumpTo[$objTarget->jumpTo] = $strUrl;
}
}
$strUrl = $arrJumpTo[$objTarget->jumpTo];
$strAlias = $objNewsletter->alias ?: $objNewsletter->id;
$arrNewsletter[] = array('subject' => $objNewsletter->subject, 'title' => \StringUtil::stripInsertTags($objNewsletter->subject), 'href' => sprintf($strUrl, $strAlias), 'date' => \Date::parse($objPage->dateFormat, $objNewsletter->date), 'datim' => \Date::parse($objPage->datimFormat, $objNewsletter->date), 'time' => \Date::parse($objPage->timeFormat, $objNewsletter->date), 'channel' => $objNewsletter->pid);
}
}
$this->Template->newsletters = $arrNewsletter;
}
开发者ID:contao,项目名称:newsletter-bundle,代码行数:38,代码来源:ModuleNewsletterList.php
示例7: 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']['newsarchive'][0]) . ' ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
return $objTemplate->parse();
}
$this->news_archives = $this->sortOutProtected(\StringUtil::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();
}
开发者ID:contao,项目名称:news-bundle,代码行数:32,代码来源:ModuleNewsArchive.php
示例8: compile
/**
* Generate the module
*/
protected function compile()
{
/** @var PageModel $objPage */
global $objPage;
// Set the trail and level
if ($this->defineRoot && $this->rootPage > 0) {
$trail = array($this->rootPage);
$level = 0;
} else {
$trail = $objPage->trail;
$level = $this->levelOffset > 0 ? $this->levelOffset : 0;
}
$lang = null;
$host = null;
// Overwrite the domain and language if the reference page belongs to a differnt root page (see #3765)
if ($this->defineRoot && $this->rootPage > 0) {
$objRootPage = \PageModel::findWithDetails($this->rootPage);
// Set the language
if (\Config::get('addLanguageToUrl') && $objRootPage->rootLanguage != $objPage->rootLanguage) {
$lang = $objRootPage->rootLanguage;
}
// Set the domain
if ($objRootPage->rootId != $objPage->rootId && $objRootPage->domain != '' && $objRootPage->domain != $objPage->domain) {
$host = $objRootPage->domain;
}
}
$this->Template->request = ampersand(\Environment::get('indexFreeRequest'));
$this->Template->skipId = 'skipNavigation' . $this->id;
$this->Template->skipNavigation = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']);
$this->Template->items = $this->renderNavigation($trail[$level], 1, $host, $lang);
}
开发者ID:contao,项目名称:core-bundle,代码行数:34,代码来源:ModuleNavigation.php
示例9: write
/**
* {@inheritdoc}
*/
protected function write(array $record)
{
$this->createStatement();
/** @var \DateTime $date */
$date = $record['datetime'];
/** @var ContaoContext $context */
$context = $record['extra']['contao'];
$this->statement->execute(['tstamp' => $date->format('U'), 'text' => StringUtil::specialchars((string) $record['formatted']), 'source' => (string) $context->getSource(), 'action' => (string) $context->getAction(), 'username' => (string) $context->getUsername(), 'func' => (string) $context->getFunc(), 'ip' => (string) $context->getIp(), 'browser' => (string) $context->getBrowser()]);
}
开发者ID:contao,项目名称:core-bundle,代码行数:12,代码来源:ContaoTableHandler.php
示例10: generate
/**
* Show the raw markdown code in the back end
*
* @return string
*/
public function generate()
{
if (TL_MODE == 'BE') {
$return = '<pre>' . \StringUtil::specialchars($this->code) . '</pre>';
if ($this->headline != '') {
$return = '<' . $this->hl . '>' . $this->headline . '</' . $this->hl . '>' . $return;
}
return $return;
}
return parent::generate();
}
开发者ID:contao,项目名称:core-bundle,代码行数:16,代码来源:ContentMarkdown.php
示例11: run
/**
* Run the controller and parse the template
*
* @return Response
*/
public function run()
{
/** @var BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('be_alerts');
$objTemplate->theme = \Backend::getTheme();
$objTemplate->base = \Environment::get('base');
$objTemplate->language = $GLOBALS['TL_LANGUAGE'];
$objTemplate->title = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['systemMessages']);
$objTemplate->charset = \Config::get('characterSet');
$objTemplate->messages = \Message::generateUnwrapped() . \Backend::getSystemMessages();
return $objTemplate->getResponse();
}
开发者ID:contao,项目名称:core-bundle,代码行数:17,代码来源:BackendAlerts.php
示例12: scopeUuid
public function scopeUuid(Builder $query, $uuid)
{
if (is_array($uuid)) {
$uuid = array_map(function ($uuid) {
return Validator::isStringUuid($uuid) ? StringUtil::uuidToBin($uuid) : $uuid;
}, $uuid);
return $query->whereIn('uuid', $uuid);
}
if (Validator::isStringUuid($uuid)) {
$uuid = StringUtil::uuidToBin($uuid);
}
return $query->where('uuid', $uuid);
}
开发者ID:fuzzyma,项目名称:contao-eloquent-bundle,代码行数:13,代码来源:File.php
示例13: setContaoFile
private function setContaoFile($file)
{
if (is_array($file)) {
return serialize(array_map([__CLASS__, 'setContaoFile'], $file));
}
if ($file instanceof FilesModel) {
return $file->uuid;
}
if (Validator::isStringUuid($file)) {
return StringUtil::uuidToBin($file);
}
return $file;
}
开发者ID:fuzzyma,项目名称:contao-eloquent-bundle,代码行数:13,代码来源:ContaoFilesModelTrait.php
示例14: onGeneratePage
/**
* Adds the feeds to the page header.
*
* @param PageModel $objPage
* @param LayoutModel|object $objLayout
*/
public function onGeneratePage(PageModel $objPage, LayoutModel $objLayout)
{
$newsfeeds = StringUtil::deserialize($objLayout->newsfeeds);
if (empty($newsfeeds) || !is_array($newsfeeds)) {
return;
}
$this->framework->initialize();
/** @var NewsFeedModel $adapter */
$adapter = $this->framework->getAdapter(NewsFeedModel::class);
if (!($feeds = $adapter->findByIds($newsfeeds)) instanceof Collection) {
return;
}
$this->addFeedMarkupToPageHeader($feeds);
}
开发者ID:contao,项目名称:news-bundle,代码行数:20,代码来源:GeneratePageListener.php
示例15: testExtractEmail
/**
* Tests the StringUtil::extactEmail() method.
*/
public function testExtractEmail()
{
$text = <<<EOF
This is a [email protected] and this a [email protected]. Another [email protected] and also a [email protected] or an [email protected]. There are "[email protected]"@example.com and "very.(),:;<>[]\\".VERY.\\"very@\\ \\"very\\".unusual"@strange.example.com and even !#\$%&'*+-/=?^_`{}|[email protected] or "()<>[]:,;@\\"!#\$%&'*+-/=?^_`{}|~.a"@example.org but they are all valid.
IP addresses as in user@[255.255.255.255], user@[IPv6:2001:db8:1ff::a0b:dbd0], user@[IPv6:2001:0db8:85a3:08d3:1319:8a2e:0370:7344], user@[IPv6:2001::7344] or user@[IPv6:1111:2222:3333:4444:5555:6666:255.255.255.255] are valid, too.
We also support IDNA domains as in test@exämple.com, test@ä-.xe, [email protected], test@wähwähwäh.ümläüts.de or "tes@t"@wähwähwäh.ümläüts.de. And we support new TLDs as in [email protected] or [email protected].
And we support unicode characters in the local part (RFC 6531) as in niceä[email protected], véry.ç[email protected], a.lîttle.lengthy.but.fiñ[email protected], dîsposable.style.é[email protected], other.é[email protected], "verî.uñ[email protected]ñusual.com"@example.com, "verî.(),:;<>[]\\".VERÎ.\\"verî@\\ \\"verî\\".unüsual"@strange.example.com, üñîçøðé@example.com, "üñîçøðé"@example.com or DžǼ੧ఘⅧ⒇৪@example.com.
Of course also with IP addresses: üser@[255.255.255.255], üser@[IPv6:2001:db8:1ff::a0b:dbd0], üser@[IPv6:2001:0db8:85a3:08d3:1319:8a2e:0370:7344], üser@[IPv6:2001::7344] or üser@[IPv6:1111:2222:3333:4444:5555:6666:255.255.255.255] and unicode characters in the local part: tést@exämple.com, tést@ä-.xe, té[email protected], tést@wähwähwäh.ümläüts.de, "tés@t"@wähwähwäh.ümläüts.de. New TLDs? No problem: té[email protected] or té[email protected].
And hopefully we do not match invalid addresses such as [email protected], [email protected], test@_smtp_.example.com, [email protected], test@subexamplecom, Abc.example.com, a"b(c)d,e:f;gi[j\\k][email protected], this is"not\\[email protected], this\\ still\\"not\\[email protected], (comment)[email protected], test@[1.2.3.4, @ or test@.
EOF;
$expected = ['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '"[email protected]"@example.com', '"very.(),:;<>[]\\".VERY.\\"very@\\ \\"very\\".unusual"@strange.example.com', '!#$%&\'*+-/=?^_`{}|[email protected]', '"()<>[]:,;@\\"!#$%&\'*+-/=?^_`{}|~.a"@example.org', 'user@[255.255.255.255]', 'user@[IPv6:2001:db8:1ff::a0b:dbd0]', 'user@[IPv6:2001:0db8:85a3:08d3:1319:8a2e:0370:7344]', 'user@[IPv6:2001::7344]', 'user@[IPv6:1111:2222:3333:4444:5555:6666:255.255.255.255]', 'test@exämple.com', 'test@ä-.xe', '[email protected]', 'test@wähwähwäh.ümläüts.de', '"tes@t"@wähwähwäh.ümläüts.de', '[email protected]', '[email protected]', 'niceä[email protected]', 'véry.ç[email protected]', 'a.lîttle.lengthy.but.fiñ[email protected]', 'dîsposable.style.é[email protected]', 'other.é[email protected]', '"verî.uñ[email protected]ñusual.com"@example.com', '"verî.(),:;<>[]\\".VERÎ.\\"verî@\\ \\"verî\\".unüsual"@strange.example.com', 'üñîçøðé@example.com', '"üñîçøðé"@example.com', 'DžǼ੧ఘⅧ⒇৪@example.com', 'üser@[255.255.255.255]', 'üser@[IPv6:2001:db8:1ff::a0b:dbd0]', 'üser@[IPv6:2001:0db8:85a3:08d3:1319:8a2e:0370:7344]', 'üser@[IPv6:2001::7344]', 'üser@[IPv6:1111:2222:3333:4444:5555:6666:255.255.255.255]', 'tést@exämple.com', 'tést@ä-.xe', 'té[email protected]', 'tést@wähwähwäh.ümläüts.de', '"tés@t"@wähwähwäh.ümläüts.de', 'té[email protected]', 'té[email protected]'];
$actual = StringUtil::extractEmail($text);
sort($actual);
sort($expected);
$this->assertEquals($expected, $actual);
}
开发者ID:Mozan,项目名称:core-bundle,代码行数:19,代码来源:ValidatorTest.php
示例16: 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']['newslist'][0]) . ' ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
return $objTemplate->parse();
}
$this->news_archives = $this->sortOutProtected(\StringUtil::deserialize($this->news_archives));
// Return if there are no archives
if (!is_array($this->news_archives) || empty($this->news_archives)) {
return '';
}
return parent::generate();
}
开发者ID:contao,项目名称:news-bundle,代码行数:24,代码来源:ModuleNewsList.php
示例17: compile
/**
* Generate the module
*/
protected function compile()
{
/** @var PageModel $objPage */
global $objPage;
$intActive = null;
$articles = array();
$intCount = 1;
foreach ($this->objArticles as $objArticle) {
$strAlias = $objArticle->alias ?: $objArticle->id;
// Active article
if (\Input::get('articles') == $strAlias) {
$articles[] = array('isActive' => true, 'href' => $objPage->getFrontendUrl('/articles/' . $strAlias), 'title' => \StringUtil::specialchars($objArticle->title, true), 'link' => $intCount);
$intActive = $intCount - 1;
} else {
$articles[] = array('isActive' => false, 'href' => $objPage->getFrontendUrl('/articles/' . $strAlias), 'title' => \StringUtil::specialchars($objArticle->title, true), 'link' => $intCount);
}
++$intCount;
}
$this->Template->articles = $articles;
$total = count($articles);
// Link to first element
if ($intActive > 1) {
$this->Template->first = array('href' => $articles[0]['href'], 'title' => $articles[0]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['first']);
}
$key = $intActive - 1;
// Link to previous element
if ($intCount > 1 && $key >= 0) {
$this->Template->previous = array('href' => $articles[$key]['href'], 'title' => $articles[$key]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['previous']);
}
$key = $intActive + 1;
// Link to next element
if ($intCount > 1 && $key < $total) {
$this->Template->next = array('href' => $articles[$key]['href'], 'title' => $articles[$key]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['next']);
}
$key = $total - 1;
// Link to last element
if ($intCount > 1 && $intActive < $key - 1) {
$this->Template->last = array('href' => $articles[$key]['href'], 'title' => $articles[$key]['title'], 'link' => $GLOBALS['TL_LANG']['MSC']['last']);
}
}
开发者ID:contao,项目名称:core-bundle,代码行数:43,代码来源:ModuleArticlenav.php
示例18: run
/**
* Run the controller and parse the template
*
* @return Response
*/
public function run()
{
/** @var BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('be_preview');
$objTemplate->base = \Environment::get('base');
$objTemplate->language = $GLOBALS['TL_LANGUAGE'];
$objTemplate->title = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['fePreview']);
$objTemplate->charset = \Config::get('characterSet');
$objTemplate->site = \Input::get('site', true);
$objTemplate->switchHref = \System::getContainer()->get('router')->generate('contao_backend_switch');
$strUrl = null;
if (\Input::get('url')) {
$strUrl = \Environment::get('base') . \Input::get('url');
} elseif (\Input::get('page')) {
$strUrl = $this->redirectToFrontendPage(\Input::get('page'), \Input::get('article'), true);
} else {
$event = new PreviewUrlConvertEvent();
\System::getContainer()->get('event_dispatcher')->dispatch(ContaoCoreEvents::PREVIEW_URL_CONVERT, $event);
$strUrl = $event->getUrl();
}
if ($strUrl === null) {
$strUrl = \System::getContainer()->get('router')->generate('contao_root', [], UrlGeneratorInterface::ABSOLUTE_URL);
}
$objTemplate->url = $strUrl;
// Switch to a particular member (see #6546)
if (\Input::get('user') && $this->User->isAdmin) {
$objUser = \MemberModel::findByUsername(\Input::get('user'));
if ($objUser !== null) {
$strHash = $this->getSessionHash('FE_USER_AUTH');
// Remove old sessions
$this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute(time() - \Config::get('sessionTimeout'), $strHash);
// Insert the new session
$this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute($objUser->id, time(), 'FE_USER_AUTH', \System::getContainer()->get('session')->getId(), \Environment::get('ip'), $strHash);
// Set the cookie
$this->setCookie('FE_USER_AUTH', $strHash, time() + \Config::get('sessionTimeout'), null, null, false, true);
$objTemplate->user = \Input::post('user');
}
}
return $objTemplate->getResponse();
}
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:45,代码来源:BackendPreview.php
示例19: run
/**
* Run the controller and parse the password template
*
* @return Response
*/
public function run()
{
/** @var BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('be_password');
if (\Input::post('FORM_SUBMIT') == 'tl_password') {
$pw = \Input::postUnsafeRaw('password');
$cnf = \Input::postUnsafeRaw('confirm');
// The passwords do not match
if ($pw != $cnf) {
\Message::addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
} elseif (Utf8::strlen($pw) < \Config::get('minPasswordLength')) {
\Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], \Config::get('minPasswordLength')));
} elseif ($pw == $this->User->username) {
\Message::addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
} else {
// Make sure the password has been changed
if (\Encryption::verify($pw, $this->User->password)) {
\Message::addError($GLOBALS['TL_LANG']['MSC']['pw_change']);
} else {
$this->loadDataContainer('tl_user');
// Trigger the save_callback
if (is_array($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback'])) {
foreach ($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback'] as $callback) {
if (is_array($callback)) {
$this->import($callback[0]);
$pw = $this->{$callback[0]}->{$callback[1]}($pw);
} elseif (is_callable($callback)) {
$pw = $callback($pw);
}
}
}
$objUser = \UserModel::findByPk($this->User->id);
$objUser->pwChange = '';
$objUser->password = \Encryption::hash($pw);
$objUser->save();
\Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
$this->redirect('contao/main.php');
}
}
$this->reload();
}
$objTemplate->theme = \Backend::getTheme();
$objTemplate->messages = \Message::generate();
$objTemplate->base = \Environment::get('base');
$objTemplate->language = $GLOBALS['TL_LANGUAGE'];
$objTemplate->title = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']);
$objTemplate->charset = \Config::get('characterSet');
$objTemplate->action = ampersand(\Environment::get('request'));
$objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pw_change'];
$objTemplate->submitButton = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
$objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0];
return $objTemplate->getResponse();
}
开发者ID:contao,项目名称:core-bundle,代码行数:59,代码来源:BackendPassword.php
示例20: insertCustomTemplate
/**
* getArticle hook
*
* insert custom template when
* getArticle hook is called
*
*/
public function insertCustomTemplate($tpl, $data, $article)
{
global $objPage;
$layoutID = $objPage->layout;
$objLayout = \LayoutModel::findByID($layoutID);
if ($objLayout->activateCArticles) {
$template = new \FrontendTemplate('mod_customarticle');
$count = count($tpl->elements);
$containertype = 'container';
$article_color = \Contao\StringUtil::deserialize($tpl->article_color);
$article_width = \Contao\StringUtil::deserialize($tpl->article_width);
$article_minheight = \Contao\StringUtil::deserialize($tpl->article_minheight);
$article_image = $tpl->article_image;
$article_image_position = $tpl->article_image_position;
$article_image_repeat = $tpl->article_image_repeat;
$article_image_cover = $tpl->article_image_cover;
$article_image_fixed = $tpl->article_image_fixed;
$inner_article_width = \Contao\StringUtil::deserialize($tpl->inner_article_width);
$inner_article_space = $tpl->inner_article_space;
$inner_article_overflow = $tpl->inner_article_overflow;
$inner_article_color = \Contao\StringUtil::deserialize($tpl->inner_article_color);
$inner_article_float = $tpl->inner_article_float;
$inner_article_minheight = \Contao\StringUtil::deserialize($tpl->inner_article_minheight);
if ($tpl->article_visible != '') {
$tmpclasses = $article->cssID;
$article_visible = @unserialize($tpl->article_visible);
if ($article_visible === 'b:0;' || $article_visible !== false) {
foreach (\Contao\StringUtil::deserialize($tpl->article_hidden) as $key => $value) {
$tmpclasses[1] .= ' ' . $value;
}
} else {
$tmpclasses[1] .= ' ' . $tpl->article_visible;
}
$article->cssID = $tmpclasses;
}
if ($tpl->article_hidden != '') {
$tmpclasses = $article->cssID;
$article_hidden = @unserialize($tpl->article_hidden);
if ($article_hidden === 'b:0;' || $article_hidden !== false) {
foreach (\Contao\StringUtil::deserialize($tpl->article_hidden) as $key => $value) {
$tmpclasses[1] .= ' ' . $value;
}
} else {
$tmpclasses[1] .= ' ' . $tpl->article_hidden;
}
$article->cssID = $tmpclasses;
}
$customstyle = ".mod_article.customarticle_{$tpl->id} { ";
if (isset($article_width['value']) && $article_width['value'] != '') {
if ($article_width['value'] == 100 && $article_width['unit'] == "%") {
$containertype = 'container-fluid';
} else {
$containertype = 'container';
}
$customstyle .= "width:" . $article_width['value'] . $article_width['unit'] . " !important;";
$customstyle .= "max-width:" . $article_width['value'] . $article_width['unit'] . " !important;";
}
if (isset($article_minheight['value']) && $article_minheight['value'] != '') {
$customstyle .= "min-height:" . $article_minheight['value'] . $article_minheight['unit'] . " !important;";
}
if (isset($article_color[0]) && $article_color[0] != '') {
$customstyle .= "background-color:" . $this->cHex2rgba($article_color[0], $article_color[1]) . " !important;";
}
if (isset($article_image) && $article_image != '') {
$customstyle .= "background-image:url('" . $article_image . "') !important;";
}
if (isset($article_image_repeat) && $article_image_repeat != '') {
$customstyle .= "background-repeat:" . $article_image_repeat . " !important;";
}
if (isset($article_image_position) && $article_image_position != '') {
$customstyle .= "background-position:" . $article_image_position . " !important;";
}
if ($article_image_cover) {
$customstyle .= "\n\t\t\t\t\t\t-webkit-background-size: cover;\n\t\t\t\t\t\t-moz-background-size: cover;\n\t\t\t\t\t\t-o-background-size: cover;\n\t\t\t\t\t\tbackground-size: cover;\n\t\t\t\t\t\tfilter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src={$img}-uri, sizingMethod='scale');\n\t\t\t\t\t\t-ms-filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src={$img}-uri, sizingMethod='scale') !important;";
if ($article_image_fixed) {
$customstyle .= "background-attachment: fixed";
} else {
$customstyle .= "background-attachment: initial";
}
}
$customstyle .= "\t}";
$customstyle .= ".mod_article.customarticle_{$tpl->id} .outer { ";
if (isset($inner_article_color[0]) && $inner_article_color[0] != '') {
$customstyle .= "background-color:" . $this->cHex2rgba($inner_article_color[0], $inner_article_color[1]) . " !important;";
}
if (isset($inner_article_width['value']) && $inner_article_width['value'] != '') {
$customstyle .= "width:" . $inner_article_width['value'] . $inner_article_width['unit'] . " !important;";
$customstyle .= "max-width:" . $inner_article_width['value'] . $inner_article_width['unit'] . " !important;";
}
if (isset($inner_article_height['value']) && $inner_article_height['value'] != '') {
$customstyle .= "min-height:" . $inner_article_height['value'] . $inner_article_height['unit'] . " !important;";
}
$customstyle .= "\t}";
//.........这里部分代码省略.........
开发者ID:christianromeni,项目名称:c-customarticles,代码行数:101,代码来源:ArticleHook.php
注:本文中的Contao\StringUtil类示例整理自Github/MSDocs等源码及文档管 |
请发表评论