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


PHP standardize函数代码示例

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


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

示例1: generateAlias

 public function generateAlias($varValue, DataContainer $dc)
 {
     $autoAlias = false;
     if (!strlen($varValue)) {
         $autoAlias = true;
         $varValue = standardize($dc->activeRecord->title);
     }
     $objAlias = $this->Database->prepare("SELECT id FROM tl_shop_category WHERE id=? OR alias=?")->execute($dc->id, $varValue);
     if ($objAlias->numRows > 1) {
         $arrDomains = array();
         while ($objAlias->next()) {
             $_pid = $objAlias->id;
             $_type = '';
             do {
                 $objParentPage = $this->Database->prepare("SELECT id, pid, alias, type, dns FROM tl_shop_category WHERE id=?")->limit(1)->execute($_pid);
                 if ($objParentPage->numRows < 1) {
                     break;
                 }
                 $_pid = $objParentPage->pid;
                 $_type = $objParentPage->type;
             } while ($_pid > 0 && $_type != 'catroot');
             $arrDomains[] = $objParentPage->numRows && ($objParentPage->type == 'catroot' || $objParentPage->pid > 0) ? $objParentPage->dns : '';
         }
         $arrUnique = array_unique($arrDomains);
         if (count($arrDomains) != count($arrUnique)) {
             if (!$autoAlias) {
                 throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue));
             }
             $varValue .= '-' . $dc->id;
         }
     }
     return $varValue;
 }
开发者ID:Acquisto,项目名称:acquisto_core,代码行数:33,代码来源:tl_shop_category.php

示例2: createName

 /**
  * Create the name.
  *
  * @param string         $value         Current name value.
  * @param \DataContainer $dataContainer The Dc_Table.
  *
  * @return string
  */
 public function createName($value, $dataContainer)
 {
     if (!$value) {
         $value = $dataContainer->activeRecord->label;
     }
     return standardize($value);
 }
开发者ID:netzmacht,项目名称:contao-workflow,代码行数:15,代码来源:Common.php

示例3: generateAlias

 /**
  * Autogenerate a taxonomy alias if it has not been set yet
  * @param mixed
  * @param object
  * @return string
  */
 public function generateAlias($varValue, DataContainer $dc)
 {
     $objField = $this->Database->prepare("SELECT pid FROM " . $dc->table . " WHERE id=?")->limit(1)->execute($dc->id);
     if (!$objField->numRows) {
         throw new Exception($GLOBALS['TL_LANG']['ERR']['aliasTitleMissing']);
     }
     $pid = $objField->pid;
     $autoAlias = false;
     // Generate alias if there is none
     if (!strlen($varValue)) {
         $objTitle = $this->Database->prepare("SELECT name FROM " . $dc->table . " WHERE id=?")->limit(1)->execute($dc->id);
         $autoAlias = true;
         $varValue = standardize($objTitle->name);
     }
     $objAlias = $this->Database->prepare("SELECT id FROM " . $dc->table . " WHERE alias=?")->execute($varValue, $dc->id);
     // Check whether the catalog alias exists
     if ($objAlias->numRows > 1 && !$autoAlias) {
         throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue));
     }
     // Add ID to alias
     if ($objAlias->numRows && $autoAlias) {
         $varValue .= '.' . $dc->id;
     }
     return $varValue;
 }
开发者ID:smohring,项目名称:taxonomy,代码行数:31,代码来源:tl_taxonomy.php

示例4: save

 /**
  * Autogenerate a product alias if it has not been set yet
  * @param mixed
  * @param \DataContainer
  * @return string
  * @throws \Exception
  */
 public function save($varValue, \DataContainer $dc)
 {
     $autoAlias = false;
     // Generate alias if there is none
     if ($varValue == '') {
         $autoAlias = true;
         $varValue = standardize(\Input::post('name'));
         if ($varValue == '') {
             $varValue = standardize(\Input::post('sku'));
         }
         if ($varValue == '') {
             $varValue = strlen($dc->activeRecord->name) ? standardize($dc->activeRecord->name) : standardize($dc->activeRecord->sku);
         }
         if ($varValue == '') {
             $varValue = $dc->id;
         }
     }
     $objAlias = \Database::getInstance()->prepare("SELECT id FROM tl_iso_product WHERE id=? OR alias=?")->execute($dc->id, $varValue);
     // Check whether the product alias exists
     if ($objAlias->numRows > 1) {
         if (!$autoAlias) {
             throw new \OverflowException(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue));
         }
         $varValue .= '.' . $dc->id;
     }
     return $varValue;
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:34,代码来源:Alias.php

示例5: modelSaved

 /**
  * {@inheritdoc}
  */
 public function modelSaved($objItem)
 {
     $arrValue = $objItem->get($this->getColName());
     // Alias already defined and no update forced, get out!
     if ($arrValue && !empty($arrValue['value']) && !$this->get('force_talias')) {
         return;
     }
     $arrAlias = array();
     foreach (deserialize($this->get('talias_fields')) as $strAttribute) {
         $arrValues = $objItem->parseAttribute($strAttribute['field_attribute'], 'text', null);
         $arrAlias[] = $arrValues['text'];
     }
     $dispatcher = $this->getMetaModel()->getServiceContainer()->getEventDispatcher();
     $replaceEvent = new ReplaceInsertTagsEvent(implode('-', $arrAlias));
     $dispatcher->dispatch(ContaoEvents::CONTROLLER_REPLACE_INSERT_TAGS, $replaceEvent);
     // Implode with '-', replace inserttags and strip HTML elements.
     $strAlias = standardize(strip_tags($replaceEvent->getBuffer()));
     // We need to fetch the attribute values for all attributes in the alias_fields and update the database
     // and the model accordingly.
     if ($this->get('isunique')) {
         // Ensure uniqueness.
         $strLanguage = $this->getMetaModel()->getActiveLanguage();
         $strBaseAlias = $strAlias;
         $arrIds = array($objItem->get('id'));
         $intCount = 2;
         while (array_diff($this->searchForInLanguages($strAlias, array($strLanguage)), $arrIds)) {
             $strAlias = $strBaseAlias . '-' . $intCount++;
         }
     }
     $arrData = $this->widgetToValue($strAlias, $objItem->get('id'));
     $this->setTranslatedDataFor(array($objItem->get('id') => $arrData), $this->getMetaModel()->getActiveLanguage());
     $objItem->set($this->getColName(), $arrData);
 }
开发者ID:designs2,项目名称:attribute_translatedalias,代码行数:36,代码来源:TranslatedAlias.php

示例6: replaceGlossaryTags

 public function replaceGlossaryTags($strTag)
 {
     $arrSplit = explode('::', $strTag);
     /*
            		{{glossary::ID}} / {{glossary::Term}}
     */
     if ($arrSplit[0] == 'glossary' && !empty($arrSplit[1])) {
         global $objPage;
         $this->import('Database');
         $arrGlossaries = array();
         $isGlossaryPage = false;
         $glossaryPageId = 0;
         /* look for glossary module on the current page */
         $objGlossaries = $this->Database->prepare("SELECT `glossaries` FROM `tl_module` WHERE `type`='glossaryList' AND `id` = (SELECT `module` FROM `tl_content` WHERE `type`='module' AND `pid`= (SELECT `id` FROM `tl_article` WHERE `pid`=?))")->limit(1)->execute($objPage->id);
         if ($objGlossaries->next()) {
             $arrValues = deserialize($objGlossaries->glossaries);
             $arrGlossaries = array_values($arrValues);
             $isGlossaryPage = true;
         }
         if (count($arrGlossaries) == 0) {
             /* find first glossary in page hierarchy */
             $objGlossaries = $this->Database->execute("SELECT `id`,`glossaries` FROM `tl_module` WHERE `type`='glossaryList'");
             while ($glossaryPageId == 0 && $objGlossaries->next()) {
                 $objArticles = $this->Database->prepare("SELECT `pid` FROM `tl_article` WHERE `published`=1 AND `id` IN (SELECT `pid` FROM `tl_content` WHERE `published`=1 AND `type`='module' AND `module` = ?)")->execute($objGlossaries->id);
                 while ($glossaryPageId == 0 && $objArticles->next()) {
                     if ($objPage->rootId == $this->getRootPage($objArticles->pid)) {
                         $arrValues = deserialize($objGlossaries->glossaries);
                         $arrGlossaries = array_values($arrValues);
                         $glossaryPageId = $objArticles->pid;
                     }
                 }
             }
             $objPages = $this->Database->execute("SELECT `pid` FROM `tl_article` WHERE `published`=1 AND `id` IN (SELECT `pid` FROM `tl_content` WHERE `published`=1 AND `type`='module' AND `module` = (SELECT `id` FROM `tl_module` WHERE `type`='glossaryList'))");
         }
         if (count($arrGlossaries) > 0) {
             if ((int) $arrSplit[1] > 0) {
                 $objTerm = $this->Database->prepare("SELECT `id`,`term` FROM `tl_glossary_term` WHERE `id`=?")->limit(1)->execute($arrSplit[1]);
             } else {
                 $objTerm = $this->Database->prepare("SELECT `id`,`term` FROM `tl_glossary_term` WHERE `term`=? AND `pid` IN (" . implode(',', $arrGlossaries) . ")")->limit(1)->execute($arrSplit[1]);
             }
             if ($objTerm->next()) {
                 $this->import('String');
                 if ($isGlossaryPage) {
                     return ampersand($this->Environment->request, true) . '#' . standardize($objTerm->term);
                 } elseif ($glossaryPageId > 0) {
                     $objGlossaryPage = $this->Database->prepare("SELECT * FROM `tl_page` WHERE `id`=?")->limit(1)->execute($glossaryPageId);
                     if ($objGlossaryPage->next()) {
                         if (version_compare(VERSION, '2.10', '>')) {
                             $strGlossaryUrl = $this->generateFrontendUrl($objGlossaryPage->row(), null, $objPage->rootLanguage);
                         } else {
                             $strGlossaryUrl = $this->generateFrontendUrl($objGlossaryPage->row());
                         }
                         return $strGlossaryUrl . '#' . standardize($objTerm->term);
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:4t2,项目名称:glossary2,代码行数:60,代码来源:GlossaryInsertTags.php

示例7: compile

 /**
  * Compile the current element
  */
 protected function compile($mode)
 {
     $alias = strlen($this->article->alias) ? $this->article->alias : $this->article->title;
     if (in_array($alias, array('header', 'container', 'left', 'main', 'right', 'footer'))) {
         $alias .= '-' . $this->article->id;
     }
     $alias = standardize($alias);
     $this->Template->column = $this->article->inColumn;
     // Add modification date
     $this->Template->timestamp = $this->article->tstamp;
     $this->Template->date = $this->parseDate($GLOBALS['TL_CONFIG']['datimFormat'], $this->article->tstamp);
     $this->Template->author = $this->article->author;
     // Override CSS ID and class
     $cssIdClass = deserialize($this->article->teaserCssID);
     if (is_array($cssIdClass) && count($cssIdClass) == 2) {
         if ($cssIdClass[0] == '') {
             $cssIdClass[0] = $alias;
         }
     }
     $this->cssID = $cssIdClass;
     $article = !$GLOBALS['TL_CONFIG']['disableAlias'] && strlen($this->article->alias) ? $this->article->alias : $this->article->id;
     $href = 'articles=' . ($this->article->inColumn != 'main' ? $this->article->inColumn . ':' : '') . $article;
     $GLOBALS['objPage'] = $this->getPageDetails($this->article->pid);
     $this->Template->headline = $this->article->title;
     $this->Template->href = $this->addToUrl($href, true);
     $this->Template->teaser = $mode == NL_PLAIN ? $this->getPlainFromHTML($this->article->teaser) : $this->article->teaser;
     $this->Template->readMore = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $this->article->headline), true);
     $this->Template->more = $GLOBALS['TL_LANG']['MSC']['more'];
 }
开发者ID:Ainschy,项目名称:contao-core,代码行数:32,代码来源:ArticleTeaser.php

示例8: 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')) !== null) {
             $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 = deserialize($objArticles->cssID, true);
         $alias = $objArticles->alias ?: $objArticles->title;
         $articles[] = array('link' => $objArticles->title, 'title' => specialchars($objArticles->title), 'id' => $cssID[0] ?: standardize($alias), 'articleId' => $objArticles->id);
     }
     $this->Template->articles = $articles;
 }
开发者ID:bytehead,项目名称:contao-core,代码行数:38,代码来源:ModuleArticleList.php

示例9: generateAlias

 /**
  * Auto-Generate an alias for an entity.
  *
  * @param string      $alias
  * @param \DC_General $dc
  *
  * @return string
  * @throws Exception
  */
 public static function generateAlias($alias, \DC_General $dc)
 {
     /** @var EntityInterface $entity */
     $entity = $dc->getCurrentModel()->getEntity();
     $autoAlias = false;
     // Generate alias if there is none
     if (!strlen($alias)) {
         $autoAlias = true;
         if ($entity->__has('title')) {
             $alias = standardize($entity->getTitle());
         } elseif ($entity->__has('name')) {
             $alias = standardize($entity->getName());
         } else {
             return '';
         }
     }
     $entityClass = new \ReflectionClass($entity);
     $keys = explode(',', $entityClass->getConstant('KEY'));
     $entityManager = EntityHelper::getEntityManager();
     $queryBuilder = $entityManager->createQueryBuilder();
     $queryBuilder->select('COUNT(e.' . $keys[0] . ')')->from($entityClass->getName(), 'e')->where($queryBuilder->expr()->eq('e.alias', ':alias'))->setParameter(':alias', $alias);
     static::extendQueryWhereId($queryBuilder, $dc->getCurrentModel()->getID(), $entity);
     $query = $queryBuilder->getQuery();
     $duplicateCount = $query->getResult(Query::HYDRATE_SINGLE_SCALAR);
     // Check whether the news alias exists
     if ($duplicateCount && !$autoAlias) {
         throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $alias));
     }
     // Add ID to alias
     if ($duplicateCount && $autoAlias) {
         $alias .= '-' . $dc->getCurrentModel()->getID();
     }
     return $alias;
 }
开发者ID:bit3,项目名称:contao-doctrine-orm,代码行数:43,代码来源:Helper.php

示例10: replaceForbiddenCharacters

 /**
  * Replaces all "forbidden" characters in the given filename
  *
  * @param string $strFile
  *
  * @return string
  */
 protected function replaceForbiddenCharacters($strFile)
 {
     $info = pathinfo($strFile);
     $newFilename = substr($info['filename'], 0, 32);
     $newFilename = standardize(\String::restoreBasicEntities($newFilename));
     $newFilename = $this->replaceUnderscores($newFilename);
     return $info['dirname'] . '/' . $newFilename . '.' . strtolower($info['extension']);
 }
开发者ID:numero2,项目名称:contao-proper-filenames,代码行数:15,代码来源:CheckFilenames.php

示例11: rename

 public function rename($varValue)
 {
     if (!$GLOBALS['TL_CONFIG']['checkFilenames']) {
         return $varValue;
     }
     $varValue = standardize(\String::restoreBasicEntities($varValue));
     return $varValue;
 }
开发者ID:numero2,项目名称:contao-proper-filenames,代码行数:8,代码来源:tl_files.php

示例12: getId

 /**
  * Generate an ID for this integrity check
  *
  * @return string
  */
 public function getId()
 {
     $className = get_called_class();
     if (($pos = strrpos($className, '\\')) !== false) {
         $className = substr($className, $pos + 1);
     }
     return standardize($className);
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:13,代码来源:AbstractIntegrityCheck.php

示例13: validateFieldName

 /**
  * Make sure the system columns are not added as attribute
  *
  * @param mixed $varValue
  *
  * @return mixed
  * @throws \Exception
  */
 public function validateFieldName($varValue)
 {
     $this->loadDataContainer('tl_iso_product');
     $varValue = str_replace('-', '_', standardize($varValue));
     if (isset($GLOBALS['TL_DCA']['tl_iso_product']['fields'][$varValue]) && $GLOBALS['TL_DCA']['tl_iso_product']['fields'][$varValue]['attributes']['systemColumn']) {
         throw new \InvalidArgumentException(sprintf($GLOBALS['TL_LANG']['ERR']['systemColumn'], $varValue));
     }
     return $varValue;
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:17,代码来源:Callback.php

示例14: normalizeUploadNames

 public function normalizeUploadNames()
 {
     if (is_array($_FILES['files'])) {
         $count = count($_FILES['files']['name']);
         for ($i = 0; $i < $count; $i++) {
             $pathinfo = pathinfo($_FILES['files']['name'][$i]);
             $_FILES['files']['name'][$i] = standardize($pathinfo['filename']) . '.' . $pathinfo['extension'];
         }
     }
 }
开发者ID:bit3,项目名称:contao-bit3basics,代码行数:10,代码来源:Hooks.php

示例15: autoGenerateAlias

 /**
  * Autogenerate an article alias from the title
  * @param mixed
  * @param object
  * @return string
  */
 public function autoGenerateAlias($varTitle)
 {
     $varAlias = standardize($varTitle);
     $objAlias = $this->Database->prepare("SELECT id FROM tl_article WHERE alias=?")->execute($varAlias);
     // Check whether the page alias exists
     if ($objAlias->numRows > 1) {
         $varAlias .= '.' . $dc->id;
     }
     return $varAlias;
 }
开发者ID:jens-wetzel,项目名称:use2,代码行数:16,代码来源:tl_page.php


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