當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。