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


PHP Convert::raw2json方法代码示例

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


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

示例1: transition

 public function transition($request)
 {
     if (!Member::currentUserID()) {
         return Security::permissionFailure($this, _t('AdvancedWorkflowActionController.ACTION_ERROR', "You must be logged in"));
     }
     $id = $this->request->requestVar('id');
     $transition = $this->request->requestVar('transition');
     $instance = DataObject::get_by_id('WorkflowInstance', (int) $id);
     if ($instance && $instance->canEdit()) {
         $transition = DataObject::get_by_id('WorkflowTransition', (int) $transition);
         if ($transition) {
             if ($this->request->requestVar('comments')) {
                 $action = $instance->CurrentAction();
                 $action->Comment = $this->request->requestVar('comments');
                 $action->write();
             }
             singleton('WorkflowService')->executeTransition($instance->getTarget(), $transition->ID);
             $result = array('success' => true, 'link' => $instance->getTarget()->AbsoluteLink());
             if (Director::is_ajax()) {
                 return Convert::raw2json($result);
             } else {
                 return $this->redirect($instance->getTarget()->Link());
             }
         }
     }
     if (Director::is_ajax()) {
         $result = array('success' => false);
         return Convert::raw2json($result);
     } else {
         $this->redirect($instance->getTarget()->Link());
     }
 }
开发者ID:Neumes,项目名称:advancedworkflow,代码行数:32,代码来源:AdvancedWorkflowActionController.php

示例2: Field

 public function Field($properties = array())
 {
     $config = array('timeformat' => $this->getConfig('timeformat'));
     $config = array_filter($config);
     $this->addExtraClass(Convert::raw2json($config));
     return parent::Field($properties);
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:7,代码来源:TimeField.php

示例3: respond

 /**
  * Out of the box, the handler "CurrentForm" value, which will return the rendered form.  
  * Non-Ajax calls will redirect back.
  * 
  * @param SS_HTTPRequest $request 
  * @param array $extraCallbacks List of anonymous functions or callables returning either a string
  * or SS_HTTPResponse, keyed by their fragment identifier. The 'default' key can
  * be used as a fallback for non-ajax responses.
  * @param array $fragmentOverride Change the response fragments.
  * @return SS_HTTPResponse
  */
 public function respond(SS_HTTPRequest $request, $extraCallbacks = array())
 {
     // Prepare the default options and combine with the others
     $callbacks = array_merge($this->callbacks, $extraCallbacks);
     $response = $this->getResponse();
     $responseParts = array();
     if (isset($this->fragmentOverride)) {
         $fragments = $this->fragmentOverride;
     } elseif ($fragmentStr = $request->getHeader('X-Pjax')) {
         $fragments = explode(',', $fragmentStr);
     } else {
         if ($request->isAjax()) {
             throw new SS_HTTPResponse_Exception("Ajax requests to this URL require an X-Pjax header.", 400);
         }
         $response->setBody(call_user_func($callbacks['default']));
         return $response;
     }
     // Execute the fragment callbacks and build the response.
     foreach ($fragments as $fragment) {
         if (isset($callbacks[$fragment])) {
             $responseParts[$fragment] = call_user_func($callbacks[$fragment]);
         } else {
             throw new SS_HTTPResponse_Exception("X-Pjax = '{$fragment}' not supported for this URL.", 400);
         }
     }
     $response->setBody(Convert::raw2json($responseParts));
     $response->addHeader('Content-Type', 'text/json');
     return $response;
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:40,代码来源:PjaxResponseNegotiator.php

示例4: upload

 /**
  * Action to handle upload of a single file
  *
  * @param SS_HTTPRequest $request
  * @return SS_HTTPResponse
  * @return SS_HTTPResponse
  */
 public function upload(SS_HTTPRequest $request)
 {
     if ($this->isDisabled() || $this->isReadonly() || !$this->canUpload()) {
         return $this->httpError(403);
     }
     // Protect against CSRF on destructive action
     $token = $this->getForm()->getSecurityToken();
     if (!$token->checkRequest($request)) {
         return $this->httpError(400);
     }
     // Get form details
     $name = $this->getName();
     $postVars = $request->postVar($name);
     // Save the temporary file into a File object
     $uploadedFiles = $this->extractUploadedFileData($postVars);
     $firstFile = reset($uploadedFiles);
     $file = $this->saveTemporaryFile($firstFile, $error);
     if (empty($file)) {
         $return = array('error' => $error);
     } else {
         $return = $this->encodeFileAttributes($file);
     }
     // Format response with json
     $response = new SS_HTTPResponse(Convert::raw2json(array($return)));
     $response->addHeader('Content-Type', 'text/plain');
     if (!empty($return['error'])) {
         $response->setStatusCode(200);
     }
     return $response;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:37,代码来源:CustomUploadField.php

示例5: convert

 public function convert(DataObject $object)
 {
     if ($object->hasMethod('toFilteredMap')) {
         return Convert::raw2json($object->toFilteredMap());
     }
     return Convert::raw2json($object->toMap());
 }
开发者ID:helpfulrobot,项目名称:silverstripe-webservices,代码行数:7,代码来源:DataObjectJsonConverter.php

示例6: Field

 public function Field($properties = array())
 {
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript(DYNAMICLIST_MODULE . '/javascript/DependentDynamicListDropdownField.js');
     $listItems = array();
     if (is_string($this->dependentLists)) {
         $list = DynamicList::get_dynamic_list($this->dependentLists);
         if ($list) {
             $this->dependentLists = $list->Items()->map('Title', 'Title')->toArray();
         }
     }
     if (!is_array($this->dependentLists)) {
         $this->dependentLists = array();
     }
     foreach ($this->dependentLists as $k => $v) {
         $list = DynamicList::get_dynamic_list($k);
         if ($list) {
             $listItems[$k] = $list->Items()->map('Title', 'Title')->toArray();
         }
     }
     $this->setAttribute('data-listoptions', Convert::raw2json($listItems));
     $this->setAttribute('data-dependentOn', $this->dependentOn);
     if ($this->value) {
         $this->setAttribute('data-initialvalue', $this->value);
     }
     return parent::Field();
 }
开发者ID:sheadawson,项目名称:silverstripe-dynamiclists,代码行数:28,代码来源:DependentDynamicListDropdownField.php

示例7: tree

 /**
  * @return string
  */
 public function tree($request)
 {
     $data = array();
     $class = $request->getVar('class');
     $id = $request->getVar('id');
     if ($id == 0) {
         $items = singleton('WorkflowService')->getDefinitions();
         $type = 'WorkflowDefinition';
     } elseif ($class == 'WorkflowDefinition') {
         $items = DataObject::get('WorkflowAction', '"WorkflowDefID" = ' . (int) $id);
         $type = 'WorkflowAction';
     } else {
         $items = DataObject::get('WorkflowTransition', '"ActionID" = ' . (int) $id);
         $type = 'WorkflowTransition';
     }
     if ($items) {
         foreach ($items as $item) {
             $new = array('data' => array('title' => $item->Title, 'attr' => array('href' => $this->Link("{$type}/{$item->ID}/edit")), 'icon' => $item->stat('icon')), 'attr' => array('id' => "{$type}_{$item->ID}", 'title' => Convert::raw2att($item->Title), 'data-id' => $item->ID, 'data-type' => $type, 'data-class' => $item->class));
             if ($item->numChildren() > 0) {
                 $new['state'] = 'closed';
             }
             $data[] = $new;
         }
     }
     return Convert::raw2json($data);
 }
开发者ID:rodneyway,项目名称:advancedworkflow,代码行数:29,代码来源:AdvancedWorkflowAdmin.php

示例8: batchaction

	/**
	 * Helper method for processing batch actions.
	 * Returns a set of status-updating JavaScript to return to the CMS.
	 *
	 * @param $objs The SS_List of objects to perform this batch action
	 * on.
	 * @param $helperMethod The method to call on each of those objects.
	 * @return JSON encoded map in the following format:
	 *  {
	 *     'modified': {
	 *       3: {'TreeTitle': 'Page3'},
	 *       5: {'TreeTitle': 'Page5'}
	 *     },
	 *     'deleted': {
	 *       // all deleted pages
	 *     }
	 *  }
	 */
	public function batchaction(SS_List $objs, $helperMethod, $successMessage, $arguments = array()) {
		$status = array('modified' => array(), 'error' => array());
		
		foreach($objs as $obj) {
			
			// Perform the action
			if (!call_user_func_array(array($obj, $helperMethod), $arguments)) {
				$status['error'][$obj->ID] = '';
			}
			
			// Now make sure the tree title is appropriately updated
			$publishedRecord = DataObject::get_by_id($this->managedClass, $obj->ID);
			if ($publishedRecord) {
				$status['modified'][$publishedRecord->ID] = array(
					'TreeTitle' => $publishedRecord->TreeTitle,
				);
			}
			$obj->destroy();
			unset($obj);
		}

		$response = Controller::curr()->getResponse();
		if($response) {
			$response->setStatusCode(
				200, 
				sprintf($successMessage, $objs->Count(), count($status['error']))
			);
		}

		return Convert::raw2json($status);
	}
开发者ID:redema,项目名称:sapphire,代码行数:49,代码来源:CMSBatchAction.php

示例9: include_js

    /**
     * This basically merges HtmlEditorField::include_js() and HTMLEditorConfig::generateJS() to output all
     * configuration sets to a customTinyMceConfigs javascript array.
     * This is output in addition to the standard ssTinyMceConfig because a) we can't stop the default output
     * with extensions; and b) the default setting is still used for any HTMLEditorField that doesn't specify
     * it's own config.
     *
     * Calls Requirements::javascript() to load the scripts.
     */
    public static function include_js()
    {
        require_once 'tinymce/tiny_mce_gzip.php';
        $availableConfigs = HtmlEditorConfig::get_available_configs_map();
        $pluginsForTag = array();
        $languages = array();
        //$allConfigs = array();
        $settingsJS = '';
        $externalPluginsForJS = array();
        $activeConfig = HtmlEditorConfig::get_active();
        foreach ($availableConfigs as $identifier => $friendlyName) {
            $configObj = CustomHtmlEditorConfig::get($identifier);
            $internalPluginsForJS = array();
            $configObj->getConfig()->setOption('language', i18n::get_tinymce_lang());
            if (!$configObj->getConfig()->getOption('content_css')) {
                $configObj->getConfig()->setOption('content_css', $activeConfig->getOption('content_css'));
            }
            $settings = $configObj->getSettings();
            foreach ($configObj->getPlugins() as $plugin => $path) {
                if (!$path) {
                    $pluginsForTag[$plugin] = $plugin;
                    $internalPluginsForJS[$plugin] = $plugin;
                } else {
                    $internalPluginsForJS[$plugin] = '-' . $plugin;
                    $externalPluginsForJS[$plugin] = sprintf('tinymce.PluginManager.load("%s", "%s");' . "\n", $plugin, $path);
                }
            }
            $language = $configObj->getConfig()->getOption('language');
            if ($language) {
                $languages[$language] = $language;
            }
            $settings['plugins'] = implode(',', $internalPluginsForJS);
            $buttons = $configObj->getButtons();
            foreach ($buttons as $i => $buttons) {
                $settings['theme_advanced_buttons' . $i] = implode(',', $buttons);
            }
            $settingsJS .= "customTinyMceConfigs['" . $identifier . "'] = " . Convert::raw2json($settings) . ";\n";
        }
        if (Config::inst()->get('HtmlEditorField', 'use_gzip')) {
            $tag = TinyMCE_Compressor::renderTag(array('url' => THIRDPARTY_DIR . '/tinymce/tiny_mce_gzip.php', 'plugins' => implode(',', $pluginsForTag), 'themes' => 'advanced', 'languages' => implode(',', $languages)), true);
            preg_match('/src="([^"]*)"/', $tag, $matches);
            Requirements::javascript($matches[1]);
        } else {
            Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
        }
        $externalPluginsJS = implode('', $externalPluginsForJS);
        $script = <<<JS
\t\t\tif((typeof tinyMCE != 'undefined')) {
\t\t\t\t{$externalPluginsJS}

\t\t\t\tif (typeof customTinyMceConfigs == 'undefined') {
\t\t\t\t\tvar customTinyMceConfigs = [];
\t\t\t\t}
\t\t\t\t{$settingsJS}
\t\t\t}

JS;
        Requirements::customScript($script, 'htmlEditorConfigs');
    }
开发者ID:helpfulrobot,项目名称:nathancox-customhtmleditorfield,代码行数:68,代码来源:CustomHTMLEditorLeftAndMainExtension.php

示例10: childnodes

 /**
  * Request nodes from the server
  *
  * @param SS_HTTPRequest $request
  * @return JSONString
  */
 public function childnodes($request)
 {
     $data = array();
     $rootObjectType = 'SiteTree';
     if ($request->param('ID')) {
         $rootObjectType = $request->param('ID');
     }
     if ($request->getVar('search')) {
         return $this->performSearch($request->getVar('search'), $rootObjectType);
     }
     $parentId = $request->getVar('id');
     if (!$parentId) {
         $parentId = $rootObjectType . '-0';
     }
     $selectable = null;
     if ($request->param('OtherID')) {
         $selectable = explode(',', $request->param('OtherID'));
     }
     list($type, $id) = explode('-', $parentId);
     if (!$type || $id < 0) {
         $data = array(0 => array('data' => 'An error has occurred'));
     } else {
         $children = null;
         if ($id == 0) {
             $children = DataObject::get($rootObjectType, 'ParentID = 0');
         } else {
             $object = DataObject::get_by_id($type, $id);
             $children = $this->childrenOfNode($object);
         }
         $data = array();
         if ($children && count($children)) {
             foreach ($children as $child) {
                 if ($child->ID < 0) {
                     continue;
                 }
                 $haskids = $child->numChildren() > 0;
                 $nodeData = array('title' => isset($child->MenuTitle) ? $child->MenuTitle : $child->Title);
                 if ($selectable && !in_array($child->ClassName, $selectable)) {
                     $nodeData['clickable'] = false;
                 }
                 $thumbs = null;
                 if ($child->ClassName == 'Image') {
                     $thumbs = $this->generateThumbnails($child);
                     $nodeData['icon'] = $thumbs['x16'];
                 } else {
                     if (!$haskids) {
                         $nodeData['icon'] = 'frontend-editing/images/page.png';
                     }
                 }
                 $nodeEntry = array('attributes' => array('id' => $child->ClassName . '-' . $child->ID, 'title' => Convert::raw2att($nodeData['title']), 'link' => $child->RelativeLink()), 'data' => $nodeData, 'state' => $haskids ? 'closed' : 'open');
                 if ($thumbs) {
                     $nodeEntry['thumbs'] = $thumbs;
                 }
                 $data[] = $nodeEntry;
             }
         }
     }
     return Convert::raw2json($data);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-frontend-editing,代码行数:65,代码来源:SimpleTreeController.php

示例11: WidgetSetupJSON

 function WidgetSetupJSON()
 {
     $settings = $this->WidgetSetup();
     $settings['type'] = $this->type;
     $settings['title'] = $this->FavesTitle;
     $settings['subject'] = $this->FavesSubject;
     return Convert::raw2json($settings);
 }
开发者ID:hamishcampbell,项目名称:silverstripe-twitter-widgets,代码行数:8,代码来源:TwitterFavesWidget.php

示例12: unLink

 /**
  * Unlink the selected records passed from the unlink bulk action.
  * 
  * @param SS_HTTPRequest $request
  *
  * @return SS_HTTPResponse List of affected records ID
  */
 public function unLink(SS_HTTPRequest $request)
 {
     $ids = $this->getRecordIDList();
     $this->gridField->list->removeMany($ids);
     $response = new SS_HTTPResponse(Convert::raw2json(array('done' => true, 'records' => $ids)));
     $response->addHeader('Content-Type', 'text/json');
     return $response;
 }
开发者ID:sumitnis,项目名称:GridFieldBulkEditingTools,代码行数:15,代码来源:GridFieldBulkActionUnlinkHandler.php

示例13: FieldHolder

 public function FieldHolder($properties = array())
 {
     $config = array('datetimeorder' => $this->getConfig('datetimeorder'));
     $config = array_filter($config);
     $this->addExtraClass('fieldgroup');
     $this->addExtraClass(Convert::raw2json($config));
     return parent::FieldHolder($properties);
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:8,代码来源:DatetimeField.php

示例14: WidgetSetupJSON

 function WidgetSetupJSON()
 {
     $settings = $this->WidgetSetup();
     $settings['type'] = $this->type;
     $settings['title'] = $this->SearchTitle;
     $settings['search'] = $this->SearchPhrase;
     $settings['subject'] = $this->SearchSubject;
     return Convert::raw2json($settings);
 }
开发者ID:hamishcampbell,项目名称:silverstripe-twitter-widgets,代码行数:9,代码来源:TwitterSearchWidget.php

示例15: jsonResponse

 /**
  * Handles returning a JSON response, makes sure Content-Type header is set
  *
  * @param array $array
  * @param bool $isJson Is the passed string already a json string
  * @return SS_HTTPResponse
  */
 public function jsonResponse($array, $isJson = false)
 {
     $json = $array;
     if (!$isJson) {
         $json = Convert::raw2json($array);
     }
     $response = new SS_HTTPResponse($json);
     $response->addHeader('Content-Type', 'application/json');
     $response->addHeader('Vary', 'Accept');
     return $response;
 }
开发者ID:webtorque7,项目名称:inpage-modules,代码行数:18,代码来源:ModuleController.php


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