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


PHP StringHelper::arrayToString方法代码示例

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


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

示例1: _end

 private function _end()
 {
     $settings = $this->getSettings();
     craft()->content->contentTable = $this->_originalContentTable;
     craft()->content->fieldColumnPrefix = $this->_originalFieldColumnPrefix;
     craft()->content->fieldContext = $this->_originalFieldContext;
     $keywords = StringHelper::arrayToString($this->_keywords, ' ');
     craft()->search->indexElementFields($settings->ownerId, $settings->locale, [$settings->fieldId => $keywords]);
 }
开发者ID:benjamminf,项目名称:craft-neo,代码行数:9,代码来源:Neo_GetSearchKeywordsTask.php

示例2: determineRobotsOutput

 protected function determineRobotsOutput($robotsArray)
 {
     $robotsMap = array("noindex" => "index", "nofollow" => "follow", "noarchive" => "archive", "noimageindex" => "imageindex", "nosnippet" => "snippet", "noodp" => "odp", "noydir" => "ydir");
     $robotOutputValues = "";
     foreach ($robotsMap as $negativeValue => $positiveValue) {
         $robotString = StringHelper::arrayToString($robotsArray);
         if (stristr($robotString, $negativeValue) === FALSE) {
             $robotOutputValues .= $robotsMap[$negativeValue] . ",";
         } else {
             $robotOutputValues .= $negativeValue . ",";
         }
     }
     // Remove the trailing comma from our string
     $robotOutputValues = rtrim($robotOutputValues, ",");
     return $robotOutputValues;
 }
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:16,代码来源:SproutSeo_RobotsMetaFieldModel.php

示例3: indexElementAttributes

 /**
  * Indexes the attributes of a given element defined by its element type.
  *
  * @param BaseElementModel $element
  * @param string|null      $localeId
  * @return bool Whether the indexing was a success.
  */
 public function indexElementAttributes(BaseElementModel $element, $localeId = null)
 {
     // Get the element type
     $elementTypeClass = $element->getElementType();
     $elementType = craft()->elements->getElementType($elementTypeClass);
     // Does it have any searchable attributes?
     $searchableAttributes = $elementType->defineSearchableAttributes();
     if ($elementType->hasTitles()) {
         $searchableAttributes[] = 'title';
     }
     foreach ($searchableAttributes as $attribute) {
         $value = $element->{$attribute};
         $value = StringHelper::arrayToString($value);
         $this->_indexElementKeywords($element->id, $attribute, '0', $localeId, $value);
     }
     return true;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:24,代码来源:SearchService.php

示例4: getSearchKeywords

 /**
  * @inheritDoc IFieldType::getSearchKeywords()
  *
  * @param mixed $value
  *
  * @return string
  */
 public function getSearchKeywords($value)
 {
     return StringHelper::arrayToString($value, ' ');
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:11,代码来源:BaseFieldType.php

示例5: fields

 /**
  * Parse category fields.
  *
  * @param CategoryModel $category
  * @param bool          $empty
  *
  * @return array
  */
 public function fields(CategoryModel $category, $empty = false)
 {
     // Always save id
     $fields = array('id' => array('label' => Craft::t('ID'), 'value' => $category->id), 'title' => array('label' => Craft::t('Title'), 'value' => (string) $category->getTitle()), 'group' => array('label' => Craft::t('Group'), 'value' => (string) $category->getGroup()));
     // Get element type
     $elementType = craft()->elements->getElementType(ElementType::Category);
     // Get nice attributes
     $availableAttributes = $elementType->defineAvailableTableAttributes();
     // Make 'em fit
     $attributes = array();
     foreach ($availableAttributes as $key => $result) {
         $attributes[$key] = $result['label'];
     }
     // Get static "fields"
     foreach ($category->getAttributes() as $handle => $value) {
         // Only show nice attributes
         if (array_key_exists($handle, $attributes)) {
             $fields[$handle] = array('label' => $attributes[$handle], 'value' => StringHelper::arrayToString(is_array($value) ? array_filter(ArrayHelper::flattenArray($value), 'strlen') : $value, ', '));
         }
     }
     // Get fieldlayout
     foreach (craft()->fields->getLayoutByType(ElementType::Category)->getFields() as $field) {
         // Get field values
         $field = $field->getField();
         $handle = $field->handle;
         $label = $field->name;
         $value = $empty ? '' : craft()->auditLog->parseFieldData($handle, $category->{$handle});
         // Set on fields
         $fields[$handle] = array('label' => $label, 'value' => $value);
     }
     // Return
     return $fields;
 }
开发者ID:boboldehampsink,项目名称:auditlog,代码行数:41,代码来源:AuditLog_CategoryService.php

示例6: 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

示例7: actionRestoreForms

 /**
  * Restore Forms
  *
  */
 public function actionRestoreForms()
 {
     $this->requirePostRequest();
     $restoreFile = craft()->request->getPost('restoreForms');
     $filePath = \CUploadedFile::getInstanceByName('restoreForms');
     $sqlFileContents = StringHelper::arrayToString(IOHelper::getFileContents($filePath->getTempName(), true), '');
     $result = craft()->db->createCommand()->setText($sqlFileContents)->queryAll();
 }
开发者ID:roundhouse,项目名称:FormBuilder-2-Craft-CMS,代码行数:12,代码来源:FormBuilder2Controller.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: parseFieldData

 /**
  * Parse field values.
  *
  * @param string $handle
  * @param mixed  $data
  *
  * @return string
  */
 public 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 AuditLogModel::FieldTypeEntries:
                 case AuditLogModel::FieldTypeCategories:
                 case AuditLogModel::FieldTypeAssets:
                 case AuditLogModel::FieldTypeUsers:
                     // Show names
                     $data = implode(', ', $data->find());
                     break;
                 case AuditLogModel::FieldTypeLightswitch:
                     // Make data human readable
                     switch ($data) {
                         case '0':
                             $data = Craft::t('No');
                             break;
                         case '1':
                             $data = Craft::t('Yes');
                             break;
                     }
                     break;
             }
         }
     } else {
         // Don't return null, return empty
         $data = '';
     }
     // If it's an array, make it a string
     if (is_array($data)) {
         $data = StringHelper::arrayToString(array_filter(ArrayHelper::flattenArray($data), 'strlen'), ', ');
     }
     // If it's an object, make it a string
     if (is_object($data)) {
         $data = StringHelper::arrayToString(array_filter(ArrayHelper::flattenArray(get_object_vars($data)), 'strlen'), ', ');
     }
     return $data;
 }
开发者ID:boboldehampsink,项目名称:auditlog,代码行数:52,代码来源:AuditLogService.php

示例10: fields

 /**
  * Parse user fields.
  *
  * @param UserModel $user
  * @param bool      $empty
  *
  * @return array
  */
 public function fields(UserModel $user, $empty = false)
 {
     // Check if we are saving new groups
     $groupIds = craft()->request->getPost('groups', false);
     // If this is before saving, or no groups have changed
     if (!count($this->before) || !$groupIds) {
         // Get user's groups
         $groups = craft()->userGroups->getGroupsByUserId($user->id);
     } else {
         // This is after saving
         // Get posted groups
         $groups = array();
         foreach ($groupIds as $id) {
             $groups[] = craft()->userGroups->getGroupById($id);
         }
     }
     // Always save id
     $fields = array('id' => array('label' => Craft::t('ID'), 'value' => $user->id), 'groups' => array('label' => Craft::t('Groups'), 'value' => implode(', ', $groups)));
     // Get element type
     $elementType = craft()->elements->getElementType(ElementType::User);
     // Get nice attributes
     $availableAttributes = $elementType->defineAvailableTableAttributes();
     // Make 'em fit
     $attributes = array();
     foreach ($availableAttributes as $key => $result) {
         $attributes[$key] = $result['label'];
     }
     // Get static "fields"
     foreach ($user->getAttributes() as $handle => $value) {
         // Only show nice attributes
         if (array_key_exists($handle, $attributes)) {
             $fields[$handle] = array('label' => $attributes[$handle], 'value' => StringHelper::arrayToString(is_array($value) ? array_filter(ArrayHelper::flattenArray($value), 'strlen') : $value, ', '));
         }
     }
     // Get fieldlayout
     foreach (craft()->fields->getLayoutByType(ElementType::User)->getFields() as $field) {
         // Get field values
         $field = $field->getField();
         $handle = $field->handle;
         $label = $field->name;
         $value = $empty ? '' : craft()->auditLog->parseFieldData($handle, $user->{$handle});
         // Set on fields
         $fields[$handle] = array('label' => $label, 'value' => $value);
     }
     // Return
     return $fields;
 }
开发者ID:boboldehampsink,项目名称:auditlog,代码行数:55,代码来源:AuditLog_UserService.php

示例11: prepRobotsAsString

 public static function prepRobotsAsString($robotsArray)
 {
     return StringHelper::arrayToString($robotsArray);
 }
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:4,代码来源:SproutSeoMetaHelper.php

示例12: fields

 /**
  * Parse entry fields.
  *
  * @param EntryModel $entry
  * @param bool       $empty
  *
  * @return array
  */
 public function fields(EntryModel $entry, $empty = false)
 {
     // Always save id and title
     $fields = array('id' => array('label' => Craft::t('ID'), 'value' => $entry->id), 'title' => array('label' => Craft::t('Title'), 'value' => $entry->title), 'section' => array('label' => Craft::t('Section'), 'value' => $entry->section->name));
     // Get element type
     $elementType = craft()->elements->getElementType(ElementType::Entry);
     // Get nice attributes
     $attributes = $elementType->defineTableAttributes();
     // Get static "fields"
     foreach ($entry->getAttributes() as $handle => $value) {
         // Only show nice attributes
         if (array_key_exists($handle, $attributes)) {
             $fields[$handle] = array('label' => $attributes[$handle], 'value' => StringHelper::arrayToString(is_array($value) ? array_filter(ArrayHelper::flattenArray($value), 'strlen') : $value, ', '));
         }
     }
     // Get fieldlayout
     $entrytype = $entry->getType();
     $tabs = craft()->fields->getLayoutById($entrytype->fieldLayoutId)->getTabs();
     foreach ($tabs as $tab) {
         foreach ($tab->getFields() as $field) {
             // Get field values
             $field = $field->getField();
             $handle = $field->handle;
             $label = $field->name;
             $value = $empty ? '' : craft()->auditLog->parseFieldData($handle, $entry->{$handle});
             // Set on fields
             $fields[$handle] = array('label' => $label, 'value' => $value);
         }
     }
     // Return
     return $fields;
 }
开发者ID:webremote,项目名称:auditlog,代码行数:40,代码来源:AuditLog_EntryService.php


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