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


PHP ArrayHelper::filterEmptyStringsFromArray方法代码示例

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


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

示例1: getRecipients

 /**
  * @param mixed|null $element
  *
  * @throws \Exception
  * @return array|string
  */
 public function getRecipients($element = null)
 {
     $recipientsString = $this->getAttribute('recipients');
     // Possibly called from entry edit screen
     if (is_null($element)) {
         return $recipientsString;
     }
     // Previously converted to array somehow?
     if (is_array($recipientsString)) {
         return $recipientsString;
     }
     // Previously stored as JSON string?
     if (stripos($recipientsString, '[') === 0) {
         return JsonHelper::decode($recipientsString);
     }
     // Still a string with possible twig generator code?
     if (stripos($recipientsString, '{') !== false) {
         try {
             $recipients = craft()->templates->renderObjectTemplate($recipientsString, $element);
             return array_unique(ArrayHelper::filterEmptyStringsFromArray(ArrayHelper::stringToArray($recipients)));
         } catch (\Exception $e) {
             throw $e;
         }
     }
     // Just a regular CSV list
     if (!empty($recipientsString)) {
         return ArrayHelper::filterEmptyStringsFromArray(ArrayHelper::stringToArray($recipientsString));
     }
     return array();
 }
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:36,代码来源:SproutEmail_EntryModel.php

示例2: slugify

 public function slugify($slug)
 {
     // Remove HTML tags
     $slug = preg_replace('/<(.*?)>/u', '', $slug);
     // Remove inner-word punctuation.
     $slug = preg_replace('/[\'"‘’“”]/u', '', $slug);
     // Make it lowercase
     $slug = mb_strtolower($slug, 'UTF-8');
     // Get the "words".  Split on anything that is not a unicode letter or number.
     // Periods are OK too.
     preg_match_all('/[\\p{L}\\p{N}\\.]+/u', $slug, $words);
     $words = ArrayHelper::filterEmptyStringsFromArray($words[0]);
     $slug = implode('-', $words);
     return $slug;
 }
开发者ID:royrobsen,项目名称:teambonus,代码行数:15,代码来源:SlugifyTwigExtension.php

示例3: createSlug

 /**
  * Creates a slug based on a given string.
  *
  * @param string $str
  *
  * @return string
  */
 public static function createSlug($str)
 {
     // Remove HTML tags
     $slug = preg_replace('/<(.*?)>/u', '', $str);
     // Remove inner-word punctuation.
     $slug = preg_replace('/[\'"‘’“”\\[\\]\\(\\)\\{\\}:]/u', '', $slug);
     if (craft()->config->get('allowUppercaseInSlug') === false) {
         // Make it lowercase
         $slug = StringHelper::toLowerCase($slug);
     }
     // Get the "words". Split on anything that is not alphanumeric, or a period, underscore, or hyphen.
     preg_match_all('/[\\p{L}\\p{N}\\._-]+/u', $slug, $words);
     $words = ArrayHelper::filterEmptyStringsFromArray($words[0]);
     $slug = implode(craft()->config->get('slugWordSeparator'), $words);
     return $slug;
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:23,代码来源:ElementHelper.php

示例4: _generateEntrySlug

 /**
  * Generates an entry slug based on its title.
  *
  * @access private
  * @param EntryModel $entry
  */
 private function _generateEntrySlug(EntryModel $entry)
 {
     $slug = $entry->slug ? $entry->slug : $entry->getTitle();
     // Remove HTML tags
     $slug = preg_replace('/<(.*?)>/', '', $slug);
     // Remove apostrophes
     $slug = str_replace(array('\'', '’'), array('', ''), $slug);
     // Make it lowercase
     $slug = strtolower($slug);
     // Convert extended ASCII characters to basic ASCII
     $slug = StringHelper::asciiString($slug);
     // Slug must start and end with alphanumeric characters
     $slug = preg_replace('/^[^a-z0-9]+/', '', $slug);
     $slug = preg_replace('/[^a-z0-9]+$/', '', $slug);
     // Get the "words"
     $words = preg_split('/[^a-z0-9]+/', $slug);
     $words = ArrayHelper::filterEmptyStringsFromArray($words);
     $slug = implode('-', $words);
     if ($slug) {
         // Make it unique
         $conditions = array('and', 'sectionId = :sectionId', 'locale = :locale', 'slug = :slug');
         $params = array(':sectionId' => $entry->sectionId, ':locale' => $entry->locale);
         if ($entry->id) {
             $conditions[] = 'id != :entryId';
             $params[':entryId'] = $entry->id;
         }
         for ($i = 0; true; $i++) {
             $testSlug = $slug . ($i != 0 ? "-{$i}" : '');
             $params[':slug'] = $testSlug;
             $totalEntries = craft()->db->createCommand()->select('count(id)')->from('entries_i18n')->where($conditions, $params)->queryScalar();
             if ($totalEntries == 0) {
                 break;
             }
         }
         $entry->slug = $testSlug;
     } else {
         $entry->slug = '';
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:45,代码来源:EntriesService.php

示例5: slugify

 /**
  * Function that (almost) mimics Craft's inner slugify process.
  * But... we allow forward slashes to stay, so we can create full uri's.
  *
  * @param string $slug
  *
  * @return string
  */
 public function slugify($slug)
 {
     // Remove HTML tags
     $slug = preg_replace('/<(.*?)>/u', '', $slug);
     // Remove inner-word punctuation.
     $slug = preg_replace('/[\'"‘’“”\\[\\]\\(\\)\\{\\}:]/u', '', $slug);
     if (craft()->config->get('allowUppercaseInSlug') === false) {
         // Make it lowercase
         $slug = StringHelper::toLowerCase($slug);
     }
     // Get the "words".  Split on anything that is not a unicode letter or number. Periods, underscores, hyphens and forward slashes get a pass.
     preg_match_all('/[\\p{L}\\p{N}\\.\\/_-]+/u', $slug, $words);
     $words = ArrayHelper::filterEmptyStringsFromArray($words[0]);
     $slug = implode(craft()->config->get('slugWordSeparator'), $words);
     return $slug;
 }
开发者ID:ianshea,项目名称:import,代码行数:24,代码来源:ImportService.php

示例6: splitOnWords

 /**
  * Splits a string into an array of the words in the string.
  *
  * @param string $string The string
  *
  * @return string[]
  */
 public static function splitOnWords($string)
 {
     // Split on anything that is not alphanumeric, or a period, underscore, or hyphen.
     // Reference: http://www.regular-expressions.info/unicode.html
     preg_match_all('/[\\p{L}\\p{N}\\p{M}\\._-]+/u', $string, $matches);
     return ArrayHelper::filterEmptyStringsFromArray($matches[0]);
 }
开发者ID:ericnormannn,项目名称:m,代码行数:14,代码来源:StringHelper.php

示例7: parseFieldData

 /**
  * Parse field values.
  *
  * @param string $handle
  * @param mixed  $data
  *
  * @return string
  */
 protected function parseFieldData($handle, $data)
 {
     // Do we have any data at all
     if (!is_null($data)) {
         // Get field info
         $field = craft()->fields->getFieldByHandle($handle);
         // If it's a field ofcourse
         if (!is_null($field)) {
             // For some fieldtypes the're special rules
             switch ($field->type) {
                 case ExportModel::FieldTypeEntries:
                 case ExportModel::FieldTypeCategories:
                 case ExportModel::FieldTypeAssets:
                 case ExportModel::FieldTypeUsers:
                     // Show names
                     $data = $data instanceof ElementCriteriaModel ? implode(', ', $data->find()) : $data;
                     break;
                 case ExportModel::FieldTypeLightswitch:
                     // Make data human readable
                     switch ($data) {
                         case '0':
                             $data = Craft::t('No');
                             break;
                         case '1':
                             $data = Craft::t('Yes');
                             break;
                     }
                     break;
                 case ExportModel::FieldTypeTable:
                     // Parse table checkboxes
                     $table = array();
                     foreach ($data as $row) {
                         // Keep track of column #
                         $i = 1;
                         // Loop through columns
                         foreach ($row as $column => $value) {
                             // Get column
                             $column = isset($field->settings['columns'][$column]) ? $field->settings['columns'][$column] : (isset($field->settings['columns']['col' . $i]) ? $field->settings['columns']['col' . $i] : array('type' => 'dummy'));
                             // Keep track of column #
                             $i++;
                             // Parse
                             $table[] = $column['type'] == 'checkbox' ? $value == 1 ? Craft::t('Yes') : Craft::t('No') : $value;
                         }
                     }
                     // Return parsed data as array
                     $data = $table;
                     break;
                 case ExportModel::FieldTypeRichText:
                 case ExportModel::FieldTypeDate:
                 case ExportModel::FieldTypeRadioButtons:
                 case ExportModel::FieldTypeDropdown:
                     // Resolve to string
                     $data = (string) $data;
                     break;
                 case ExportModel::FieldTypeCheckboxes:
                 case ExportModel::FieldTypeMultiSelect:
                     // Parse multi select values
                     $multi = array();
                     foreach ($data as $row) {
                         $multi[] = $row->value;
                     }
                     // Return parsed data as array
                     $data = $multi;
                     break;
             }
         }
         // Get other operations
         craft()->plugins->call('registerExportOperation', array(&$data, $handle));
     } else {
         // Don't return null, return empty
         $data = '';
     }
     // If it's an object or an array, make it a string
     if (is_array($data)) {
         $data = StringHelper::arrayToString(ArrayHelper::filterEmptyStringsFromArray(ArrayHelper::flattenArray($data)), ', ');
     }
     // If it's an object, make it a string
     if (is_object($data)) {
         $data = StringHelper::arrayToString(ArrayHelper::filterEmptyStringsFromArray(ArrayHelper::flattenArray(get_object_vars($data))), ', ');
     }
     return $data;
 }
开发者ID:rutgerbakker7,项目名称:export,代码行数:90,代码来源:ExportService.php

示例8: parseFieldData

 protected function parseFieldData($field, $data)
 {
     if (!is_null($data)) {
         if (!is_null($field)) {
             switch ($field->type) {
                 case ExportModel::FieldTypeEntries:
                 case ExportModel::FieldTypeCategories:
                 case ExportModel::FieldTypeAssets:
                 case ExportModel::FieldTypeUsers:
                     $data = $data instanceof ElementCriteriaModel ? implode(', ', $data->find()) : $data;
                     break;
                 case ExportModel::FieldTypeLightswitch:
                     switch ($data) {
                         case '0':
                             $data = Craft::t('No');
                             break;
                         case '1':
                             $data = Craft::t('Yes');
                             break;
                     }
                     break;
                 case ExportModel::FieldTypeTable:
                     $table = array();
                     foreach ($data as $row) {
                         $i = 1;
                         foreach ($row as $column => $value) {
                             $column = isset($field->settings['columns'][$column]) ? $field->settings['columns'][$column] : (isset($field->settings['columns']['col' . $i]) ? $field->settings['columns']['col' . $i] : array('type' => 'dummy'));
                             $i++;
                             $table[] = $column['type'] == 'checkbox' ? $value == 1 ? Craft::t('Yes') : Craft::t('No') : $value;
                         }
                     }
                     $data = $table;
                     break;
                 case ExportModel::FieldTypeRichText:
                 case ExportModel::FieldTypeDate:
                 case ExportModel::FieldTypeRadioButtons:
                 case ExportModel::FieldTypeDropdown:
                     $data = (string) $data;
                     break;
                 case ExportModel::FieldTypeCheckboxes:
                 case ExportModel::FieldTypeMultiSelect:
                     $multi = array();
                     foreach ($data as $row) {
                         $multi[] = $row->value;
                     }
                     $data = $multi;
                     break;
             }
         }
     } else {
         $data = '';
     }
     if (is_array($data)) {
         $data = StringHelper::arrayToString(ArrayHelper::filterEmptyStringsFromArray(ArrayHelper::flattenArray($data)), ', ');
     }
     if (is_object($data)) {
         $data = StringHelper::arrayToString(ArrayHelper::filterEmptyStringsFromArray(ArrayHelper::flattenArray(get_object_vars($data))), ', ');
     }
     return $data;
 }
开发者ID:transomdesign,项目名称:transom-craft-starter,代码行数:60,代码来源:SuperTableService.php

示例9: getHeadersToParse

 /**
  * Ensures that a valid list of parseable headers is returned
  *
  * @param string $headerString
  *
  * @return array
  */
 public function getHeadersToParse($headerString = '')
 {
     $allowedHeaders = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6');
     $headers = ArrayHelper::filterEmptyStringsFromArray(ArrayHelper::stringToArray($headerString));
     if (count($headers)) {
         foreach ($headers as $key => $header) {
             $header = strtolower($header);
             if (!in_array($header, $allowedHeaders)) {
                 unset($headers[$key]);
             }
         }
     }
     return $headers;
 }
开发者ID:kamicrafted,项目名称:designhub,代码行数:21,代码来源:DoxterService.php


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