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


PHP Convert::array2json方法代码示例

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


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

示例1: FieldHolder

	function FieldHolder() {
		
		
		Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js');
		Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js');
		Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototype_improvements.js');
		Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js');
		Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
		Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableListField.js');
		
		// swap the js file
		Requirements::block(SAPPHIRE_DIR . '/javascript/TableField.js');
		Requirements::javascript('modifiedtablefield/javascript/ModifiedTableField.js');
		
		
		Requirements::css(SAPPHIRE_DIR . '/css/TableListField.css');
		

		$defaults = $this->fieldDefaults;
		if ($this->fieldDefaults == null && !is_array($this->fieldDefaults)) {
			$sourceClass = $this->sourceClass;
			
			$defaults = singleton($sourceClass)->stat('defaults');
		}
		
		if (count($defaults) > 0) {
			Requirements::customScript("var ".$this->name."_fieldDefaults = ".Convert::array2json($defaults));
		}
		
		
		return $this->renderWith($this->template);
	}
开发者ID:nathancox,项目名称:silverstripe-modifiedtablefield,代码行数:32,代码来源:ModifiedTableField.php

示例2: CreatePackageJson

 function CreatePackageJson()
 {
     $extensionData = ExtensionData::get();
     $count = 0;
     if ($extensionData && !empty($extensionData)) {
         $count = $extensionData->Count();
         $filename = 'packages.json';
         $repo = array('packages' => array());
         foreach ($extensionData as $extension) {
             // Include only Approved extensions
             if ($extension->Accepted == '1') {
                 $json = new JsonHandler($extension->Url);
                 $jsonData = $json->cloneJson();
                 $packages = $jsonData['AllRelease'];
                 $dumper = new ArrayDumper();
                 foreach ($packages as $package) {
                     $repo['packages'][$package->getPrettyName()][$package->getPrettyVersion()] = $dumper->dump($package);
                 }
             }
         }
         if (!empty($repo['packages'])) {
             $packagesJsonData = Convert::array2json($repo);
             $packageJsonFile = fopen(BASE_PATH . DIRECTORY_SEPARATOR . $filename, 'w');
             fwrite($packageJsonFile, $packagesJsonData);
             fclose($packageJsonFile);
             echo "<br /><br /><strong> package.json file created successfully...</strong><br />";
         } else {
             throw new InvalidArgumentException('package.json file could not be created');
         }
     }
 }
开发者ID:helpfulrobot,项目名称:vikas-srivastava-extensionmanager,代码行数:31,代码来源:CreatePackageJsonTask.php

示例3: doSearch

 public function doSearch($gridField, $request)
 {
     $dataClass = $gridField->getList()->dataClass();
     $allList = $this->searchList ? $this->searchList : DataList::create($dataClass);
     $searchFields = $this->getSearchFields() ? $this->getSearchFields() : $this->scaffoldSearchFields($dataClass);
     if (!$searchFields) {
         throw new LogicException(sprintf('GridFieldAddExistingAutocompleter: No searchable fields could be found for class "%s"', $dataClass));
     }
     $params = array();
     foreach ($searchFields as $searchField) {
         $name = strpos($searchField, ':') !== FALSE ? $searchField : "{$searchField}:StartsWith";
         $params[$name] = $request->getVar('gridfield_relationsearch');
     }
     if (!$gridField->getList() instanceof UnsavedRelationList) {
         $allList = $allList->subtract($gridField->getList());
     }
     $results = $allList->filterAny($params)->sort(strtok($searchFields[0], ':'), 'ASC')->limit($this->getResultsLimit());
     $json = array();
     $originalSourceFileComments = Config::inst()->get('SSViewer', 'source_file_comments');
     Config::inst()->update('SSViewer', 'source_file_comments', false);
     foreach ($results as $result) {
         $json[$result->ID] = html_entity_decode(SSViewer::fromString($this->resultsFormat)->process($result));
     }
     Config::inst()->update('SSViewer', 'source_file_comments', $originalSourceFileComments);
     return Convert::array2json($json);
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:26,代码来源:CustomGridFieldAddExistingAutocompleter.php

示例4: load

 public function load($request)
 {
     $response = new SS_HTTPResponse();
     $response->addHeader('Content-Type', 'application/json');
     $response->setBody(Convert::array2json(array("_memberID" => Member::currentUserID())));
     return $response;
 }
开发者ID:spekulatius,项目名称:silverstripe-bootstrap_extra_fields,代码行数:7,代码来源:KeepAliveField.php

示例5: load

 public function load($request)
 {
     $response = new SS_HTTPResponse();
     $response->addHeader('Content-Type', 'application/json');
     $response->setBody(Convert::array2json(call_user_func($this->source, $request->getVar('val'))));
     return $response;
 }
开发者ID:spekulatius,项目名称:silverstripe-bootstrap_extra_fields,代码行数:7,代码来源:BootstrapTypeaheadField.php

示例6: search

 public function search($request)
 {
     $list = DataList::create($this->getConfig('classToSearch'));
     $params = array();
     $searchFields = $this->getConfig('searchFields');
     foreach ($searchFields as $searchField) {
         $name = strpos($searchField, ':') !== false ? $searchField : "{$searchField}:partialMatch";
         $params[$name] = $request->getVar('term');
     }
     $start = (int) $request->getVar('id') ? (int) $request->getVar('id') * $this->getConfig('resultsLimit') : 0;
     $list = $list->filterAny($params)->exclude($this->getConfig('excludes'));
     $filter = $this->getConfig('filter');
     if (count($filter) > 0) {
         $list = $list->filter($filter);
     }
     $total = $list->count();
     $results = $list->sort(strtok($searchFields[0], ':'), 'ASC')->limit($this->getConfig('resultsLimit'), $start);
     $return = array('list' => array(), 'total' => $total);
     $originalSourceFileComments = Config::inst()->get('SSViewer', 'source_file_comments');
     Config::inst()->update('SSViewer', 'source_file_comments', false);
     foreach ($results as $object) {
         $return['list'][] = array('id' => $object->ID, 'resultsContent' => html_entity_decode(SSViewer::fromString($this->getConfig('resultsFormat'))->process($object)), 'selectionContent' => SSViewer::fromString($this->getConfig('selectionFormat'))->process($object));
     }
     Config::inst()->update('SSViewer', 'source_file_comments', $originalSourceFileComments);
     return Convert::array2json($return);
 }
开发者ID:sheadawson,项目名称:silverstripe-select2,代码行数:26,代码来源:AjaxSelect2Field.php

示例7: Field

 public function Field($properties = array())
 {
     $config = array('separator' => $this->getConfig('separator') ? $this->getConfig('separator') : ', ', 'showcalendar' => $this->getConfig('showcalendar'), 'isoDateformat' => $this->getConfig('dateformat'), 'jquerydateformat' => DateField_View_JQuery::convert_iso_to_jquery_format($this->getConfig('dateformat')), 'min' => $this->getConfig('min'), 'max' => $this->getConfig('max'));
     // Add other jQuery UI specific, namespaced options (only serializable, no callbacks etc.)
     // TODO Move to DateField_View_jQuery once we have a properly extensible HTML5 attribute system for FormField
     $jqueryUIConfig = array();
     foreach ($this->getConfig() as $k => $v) {
         if (preg_match('/^jQueryUI\\.(.*)/', $k, $matches)) {
             $jqueryUIConfig[$matches[1]] = $v;
         }
     }
     if ($jqueryUIConfig) {
         $config['jqueryuiconfig'] = Convert::array2json(array_filter($jqueryUIConfig));
     }
     $config = array_filter($config);
     foreach ($config as $k => $v) {
         $this->setAttribute('data-' . $k, $v);
     }
     // Three separate fields for day, month and year (not available for multidates)
     if ($this->getConfig('dmyfields')) {
         user_error("MultiDateField doen't work with separate fields for day/month/year");
     }
     // Default text input field
     $html = parent::Field();
     return $html;
 }
开发者ID:helpfulrobot,项目名称:micschk-silverstripe-multidatepicker,代码行数:26,代码来源:MultiDateField.php

示例8: formatJSON

 /**
  * Formats JSON so that it is usable by the JS component
  * 
  * @param  SS_List $list The list to format
  * @return string        JSON
  */
 protected function formatJSON(SS_List $list)
 {
     $ret = array();
     foreach ($list as $item) {
         $ret[] = array('id' => $item->{$this->idField}, 'label' => $item->{$this->labelField});
     }
     return Convert::array2json($ret);
 }
开发者ID:helpfulrobot,项目名称:unclecheese-bootstrap-tagfield,代码行数:14,代码来源:BootstrapTagField.php

示例9: getCartCustomizations

 protected function getCartCustomizations()
 {
     $config = self::$cart_config;
     if ($config && is_array($config)) {
         return Convert::array2json($config);
     }
     return;
 }
开发者ID:helpfulrobot,项目名称:rywa-silverstripe-minicart,代码行数:8,代码来源:MiniCart.php

示例10: process

 /**
  * @return string
  */
 public function process()
 {
     if (isset($_POST['SourceURL'])) {
         $sourceURL = $_POST['SourceURL'];
         $bIsCloudinary = CloudinaryVideo::isCloudinary($sourceURL);
         $bIsYoutube = YoutubeVideo::is_youtube($sourceURL);
         $bIsVimeo = VimeoVideo::is_vimeo($sourceURL);
         $video = null;
         if ($bIsYoutube || $bIsVimeo || $bIsCloudinary) {
             if ($bIsCloudinary) {
                 $filterClass = 'CloudinaryVideo';
                 $fileType = 'video';
             } elseif ($bIsYoutube) {
                 $filterClass = 'YoutubeVideo';
                 $fileType = 'youtube';
             } else {
                 $filterClass = 'VimeoVideo';
                 $fileType = 'vimeo';
             }
             $funcForID = $bIsYoutube ? 'youtube_id_from_url' : 'vimeo_id_from_url';
             $funcForDetails = $bIsYoutube ? 'youtube_video_details' : 'vimeo_video_details';
             if ($bIsCloudinary) {
                 $arr = Config::inst()->get('CloudinaryConfigs', 'settings');
                 if (isset($arr['CloudName']) && !empty($arr['CloudName'])) {
                     $arrPieces = explode('/', $sourceURL);
                     $arrFileName = array_slice($arrPieces, 7);
                     $fileName = implode('/', $arrFileName);
                     $publicID = substr($fileName, 0, strrpos($fileName, '.'));
                     $video = $filterClass::get()->filterAny(array('URL' => $sourceURL, 'PublicID' => $publicID))->first();
                     if (!$video) {
                         $api = new \Cloudinary\Api();
                         $resource = $api->resource($publicID, array("resource_type" => "video"));
                         //qoogjqs9ksyez7ch8sh5
                         $json = json_encode($resource);
                         $arrResource = Convert::json2array($json);
                         $video = new $filterClass(array('Title' => $arrResource['public_id'] . '.' . $arrResource['format'], 'PublicID' => $arrResource['public_id'], 'Version' => $arrResource['version'], 'URL' => $arrResource['url'], 'SecureURL' => $arrResource['secure_url'], 'FileType' => $arrResource['resource_type'], 'FileSize' => $arrResource['bytes'], 'Format' => $arrResource['format'], 'Signature' => isset($arrResource['signature']) ? $arrResource['signature'] : ''));
                         $video->write();
                     }
                 }
             } else {
                 $video = $filterClass::get()->filter('URL', $sourceURL)->first();
                 if (!$video) {
                     $sourceID = $filterClass::$funcForID($sourceURL);
                     $details = $filterClass::$funcForDetails($sourceID);
                     $video = new $filterClass(array('Title' => $details['title'], 'Duration' => $details['duration'], 'URL' => $sourceURL, 'secure_url' => $sourceURL, 'PublicID' => $sourceID, 'FileType' => $fileType));
                     $video->write();
                 }
             }
             if ($video) {
                 $this->value = $iVideoID = $video->ID;
                 $file = $this->customiseCloudinaryFile($video);
                 return Convert::array2json(array('colorselect_url' => $file->UploadFieldImageURL, 'thumbnail_url' => $file->UploadFieldThumbnailURL, 'fieldname' => $this->getName(), 'id' => $file->ID, 'url' => $file->URL, 'buttons' => $file->UploadFieldFileButtons, 'more_files' => $this->canUploadMany(), 'field_id' => $this->ID()));
             }
         }
     }
     return Convert::array2json(array());
 }
开发者ID:helpfulrobot,项目名称:mademedia-silverstripe-cloudinary,代码行数:60,代码来源:CloudinaryMediaField.php

示例11: removePresentation

 /**
  * Removes a presentation from the user's random list
  * @param  int $id The presentation ID     
  */
 public function removePresentation($id)
 {
     if (!$this->owner->PresentationList) {
         return;
     }
     $ids = Convert::json2array($this->owner->PresentationList);
     unset($ids[$id]);
     $this->owner->PresentationList = Convert::array2json($ids);
     $this->owner->write();
 }
开发者ID:rbowen,项目名称:openstack-org,代码行数:14,代码来源:PresentationMemberExtension.php

示例12: Field

 /**
  * @param array $properties
  * @return HTMLText
  */
 public function Field($properties = array())
 {
     $this->addExtraClass('prettycheckablefield')->setAttribute('data-prettycheckableconfig', Convert::array2json($this->pretty_checkable_config));
     //allow for not including default styles
     if ($this->config()->get('require_css') == true) {
         Requirements::css(PRETTY_CHECKABLE_FIELD_THIRDPARTY . '/prettyCheckable-2.1.2/dist/prettyCheckable.css');
     }
     Requirements::javascript(PRETTY_CHECKABLE_FIELD_THIRDPARTY . '/prettyCheckable-2.1.2/dist/prettyCheckable.min.js');
     Requirements::javascript(PRETTY_CHECKABLE_FIELD_JAVASCRIPT . '/pretty.checkable.box.field.js');
     return parent::Field($properties);
 }
开发者ID:muskie9,项目名称:silverstripe-pretty-checkable-field,代码行数:15,代码来源:PrettyCheckableBoxField.php

示例13: Field

 function Field($properties = array())
 {
     $this->addExtraClass('timepicker')->setAttribute('autocomplete', 'off')->setAttribute('data-jqueryuiconfig', Convert::array2json($this->timePickerConfig));
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
     Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
     Requirements::javascript(TIMEPICKERFIELD_MODULE . '/javascript/jquery.ui.timepicker.js');
     Requirements::javascript(TIMEPICKERFIELD_MODULE . '/javascript/timepickerfield.js');
     Requirements::css(TIMEPICKERFIELD_MODULE . '/css/jquery.ui.timepicker.css');
     return parent::Field($properties);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-timepickerfield,代码行数:11,代码来源:TimePickerField.php

示例14: Field

 /**
  * @param array $properties
  * @return HTMLText
  */
 public function Field($properties = array())
 {
     $this->addExtraClass('selectboxfield')->setAttribute('data-selectboxconfig', Convert::array2json($this->selectbox_config));
     //allow for not including default styles
     if ($this->config()->get('require_css') == true) {
         Requirements::css(SELECTBOX_DROPDOWN_FIELD_DIR_THIRD_PARTY_DIR . 'jquery.selectbox-0.2/css/jquery.selectbox.css');
     }
     Requirements::javascript(SELECTBOX_DROPDOWN_FIELD_DIR_THIRD_PARTY_DIR . 'jquery.selectbox-0.2/js/jquery.selectbox-0.2.min.js');
     Requirements::javascript(SELECTBOX_DROPDOWN_FIELD_JAVASCRIPT . '/selectbox.dropdown.field.js');
     return parent::Field($properties);
 }
开发者ID:muskie9,项目名称:silverstripe-selectboxfield,代码行数:15,代码来源:SelectboxDropdownField.php

示例15: getinfo

 public function getinfo()
 {
     $publicID = CloudinaryFile::get_public_id($_REQUEST['cloudinary_id']);
     $api = CloudinaryFile::get_api();
     $type = CloudinaryFile::get_resource_type($_REQUEST['cloudinary_id']);
     $data = $api->resource(urlencode($publicID), array('resource_type' => $type));
     if ($data) {
         $data = $data->getArrayCopy();
         return Convert::array2json($data);
     }
     return Convert::array2json(array('Error' => 1));
 }
开发者ID:silverstripers,项目名称:cloudinary,代码行数:12,代码来源:CloudinaryUpload.php


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