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


PHP FD::json方法代码示例

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


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

示例1: getResource

 /**
  * Processes .view and .language from the javascript calls.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function getResource()
 {
     $resources = JRequest::getVar('resource');
     if ($resources) {
         // Load language support for front end and back end.
         $lang = FD::language();
         $lang->loadSite();
         $lang->loadAdmin();
         foreach ($resources as &$resource) {
             $resource = (object) $resource;
             // Get the current method.
             $method = 'get' . ucfirst($resource->type);
             if (!method_exists($this, $method)) {
                 continue;
             }
             // Pass the resource over.
             $result = self::$method($resource->name);
             if ($result !== false) {
                 $resource->content = $result;
             }
         }
     }
     header('Content-type: text/x-json; UTF-8');
     echo FD::json()->encode($resources);
     exit;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:34,代码来源:foundry.php

示例2: main

 public function main()
 {
     $db = FD::db();
     $sql = $db->sql();
     $sql->select('#__social_fields_data', 'a')->column('a.*')->leftjoin('#__social_fields', 'b')->on('b.id', 'a.field_id')->leftjoin('#__social_apps', 'c')->on('c.id', 'b.app_id')->where('a.datakey', '')->where('c.type', 'fields')->where('c.element', 'joomla_fullname');
     $db->setQuery($sql);
     $result = $db->loadObjectList();
     $json = FD::json();
     foreach ($result as $row) {
         if ($json->isJsonString($row->data)) {
             $data = $json->decode($row->data);
             // Split json object into each individual row
             foreach ($data as $k => $v) {
                 if (!empty($v)) {
                     $table = $this->getTable($row->field_id, $row->uid, $row->type, $k);
                     $table->data = $v;
                     $table->raw = $v;
                     $table->store();
                 }
             }
         }
         // Remove the row with empty key
         $sql->clear();
         $sql->delete('#__social_fields_data')->where('id', $row->id);
         $db->setQuery($sql);
         $db->query();
     }
     return true;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:29,代码来源:UpdateFullnameFieldDataToMultirow.php

示例3: getCountries

 /**
  * Retrieves a list of countries from the manifest file.
  *
  * @since   1.0
  * @access  public
  * @return  Array    An array of countries.
  *
  * @author  Jason Rey <jasonrey@stackideas.com>
  */
 public static function getCountries($source = 'regions')
 {
     static $countries = array();
     if (!isset($countries[$source])) {
         $data = new stdClass();
         if ($source === 'file') {
             $file = JPATH_ADMINISTRATOR . '/components/com_easysocial/defaults/countries.json';
             $contents = JFile::read($file);
             $json = FD::json();
             $data = $json->decode($contents);
             $data = (array) $data;
             // Sort by alphabet
             asort($data);
             $data = (object) $data;
         }
         if ($source === 'regions') {
             $countries = FD::model('Regions')->getRegions(array('type' => SOCIAL_REGION_TYPE_COUNTRY, 'state' => SOCIAL_STATE_PUBLISHED, 'ordering' => 'ordering'));
             foreach ($countries as $country) {
                 $data->{$country->code} = $country->name;
             }
         }
         $countries[$source] = $data;
     }
     return $countries[$source];
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:34,代码来源:helper.php

示例4: getAjaxTemplate

 public function getAjaxTemplate()
 {
     $templateFiles = JRequest::getVar('names');
     // Ensure the integrity of each items submitted to be an array.
     if (!is_array($templateFiles)) {
         $templateFiles = array($templateFiles);
     }
     $result = array();
     $theme = FD::get('Themes');
     foreach ($templateFiles as $file) {
         // Remove any trailing .ejs in file name if exist.
         $file = str_replace('.ejs', '', $file);
         $template = $theme->getTemplate($file);
         ob_start();
         include $template->ejs;
         $output = ob_get_contents();
         ob_end_clean();
         $obj = new stdClass();
         $obj->name = $file;
         $obj->content = $output;
         $result[] = $obj;
     }
     if (!$result) {
         header('HTTP/1.1 404 Not Found');
         exit;
     }
     header('Content-type: text/x-json; UTF-8');
     $json = FD::json();
     echo $json->encode($result);
     exit;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:31,代码来源:themes.php

示例5: load

 /**
  * Loads a set of configuration given the type.
  *
  * @since	1.0
  * @access	public
  * @param	string		The unique type of configuration.
  * @return
  */
 public function load($key)
 {
     // Specifically if the key is 'joomla' , we only want to use JConfig.
     if ($key == 'joomla') {
         $codeName = FD::getInstance('Version')->getCodeName();
         $helper = dirname(__FILE__) . '/helpers/' . $codeName . '.php';
         require_once $helper;
         $className = 'SocialConfig' . $codeName;
         $config = new $className();
     } else {
         // Object construct happens here
         $default = SOCIAL_ADMIN . '/defaults/' . $key . '.json';
         $defaultData = '';
         // Read the default data.
         $defaultData = JFile::read($default);
         $json = FD::json();
         // Load a new copy of Registry
         $config = FD::registry($defaultData);
         if (!defined('SOCIAL_COMPONENT_CLI')) {
             // @task: Now we need to get the user defined configuration that is stored in the database.
             $model = FD::model('Config');
             $storedConfig = $model->getConfig($key);
             // Get stored config
             if ($storedConfig) {
                 $storedConfig = FD::registry($storedConfig->value);
                 // Merge configurations
                 $config->mergeObjects($storedConfig->getRegistry());
             }
         }
     }
     $this->configs[$key] = $config;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:40,代码来源:config.php

示例6: showProfile

 public function showProfile($view, &$params)
 {
     $userid = $view->profile->userid;
     $user = FD::user($userid);
     $gender = $user->getFieldData('GENDER');
     if (!empty($gender)) {
         $view->profile->gender = $gender;
     }
     $data = $user->getFieldData('BIRTHDAY');
     $json = FD::json();
     $birthday = null;
     // Legacy
     if (isset($data['date']) && $json->isJsonString($data['date']) && !$birthday) {
         $birthday = $this->getLegacyDate($data['date']);
     }
     // Legacy
     if ($json->isJsonString($data) && !$birthday) {
         $birthday = $this->getLegacyDate($data);
     }
     // New format
     if (isset($data['date']) && !$birthday) {
         $birthday = FD::date($data['date']);
     }
     if (!is_null($birthday)) {
         $view->profile->birthdate = $birthday->format('Y-m-d');
     }
 }
开发者ID:Ruud68,项目名称:Kunena-Forum,代码行数:27,代码来源:profile.php

示例7: fetch

 /**
  * Does a remote call to the server to fetch contents of a given url.
  *
  * @since	1.0
  * @access	public
  */
 public function fetch()
 {
     // Check for request forgeries!
     $urls = JRequest::getVar('urls');
     // Ensure that the urls are in an array
     FD::makeArray($urls);
     // Get the current view.
     $view = $this->getCurrentView();
     // Result placeholder
     $result = array();
     if (!$urls || empty($urls)) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_CRAWLER_INVALID_URL_PROVIDED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     $crawler = FD::get('Crawler');
     foreach ($urls as $url) {
         $hash = md5($url);
         $link = FD::table('Link');
         $exists = $link->load(array('hash' => $hash));
         // If it doesn't exist, store it.
         if (!$exists) {
             $crawler->crawl($url);
             $data = $crawler->getData();
             $link->hash = $hash;
             $link->data = FD::json()->encode($data);
             // Store the new link
             $link->store();
         }
         $result[$url] = FD::json()->decode($link->data);
     }
     return $view->call(__FUNCTION__, $result);
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:38,代码来源:crawler.php

示例8: main

 public function main()
 {
     $db = FD::db();
     $sql = $db->sql();
     $sql->select('#__social_fields_data', 'a');
     $sql->column('a.*');
     $sql->leftjoin('#__social_fields', 'b');
     $sql->on('a.field_id', 'b.id');
     $sql->leftjoin('#__social_apps', 'c');
     $sql->on('b.app_id', 'c.id');
     $sql->where('c.type', 'fields');
     $sql->where('c.element', array('birthday', 'datetime'), 'IN');
     $db->setQuery($sql);
     $result = $db->loadObjectList();
     $json = FD::json();
     foreach ($result as $row) {
         $table = FD::table('fielddata');
         $table->bind($row);
         if ($json->isJsonString($table->data)) {
             $table->datakey = 'date';
             $table->store();
         }
     }
     return true;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:25,代码来源:SetDatetimeFieldDataKey.php

示例9: main

 public function main()
 {
     $db = FD::db();
     $sql = $db->sql();
     // For country field
     $sql->select('#__social_fields_data', 'a')->column('a.*')->leftjoin('#__social_fields', 'b')->on('b.id', 'a.field_id')->leftjoin('#__social_apps', 'c')->on('c.id', 'b.app_id')->where('a.datakey', '')->where('c.type', 'fields')->where('c.element', 'country');
     $db->setQuery($sql);
     $result = $db->loadObjectList();
     $json = FD::json();
     // Load up the list of countries
     $file = SOCIAL_ADMIN_DEFAULTS . '/countries.json';
     $list = FD::makeObject($file);
     foreach ($result as $row) {
         if ($json->isJsonString($row->data)) {
             $data = $json->decode($row->data);
             // Split json object into each individual row
             foreach ($data as $k => $v) {
                 if (!empty($v)) {
                     $table = $this->getTable($row->field_id, $row->uid, $row->type, $k);
                     $country = $list->{$v};
                     $table->data = $country;
                     $table->raw = $country;
                     $table->store();
                 }
             }
         }
         // Remove the row with empty key
         $sql->clear();
         $sql->delete('#__social_fields_data')->where('id', $row->id);
         $db->setQuery($sql);
         $db->query();
     }
     return true;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:34,代码来源:UpdateCountryFieldData.php

示例10: display

 /**
  * This is the center of the brain to process all views.
  *
  * @since	1.0
  * @access	public
  * @param	array
  */
 public function display($cacheable = false, $urlparams = false)
 {
     $document = JFactory::getDocument();
     $type = $document->getType();
     $viewName = JRequest::getCmd('view', $this->getName());
     // Set the layout
     $viewLayout = JRequest::getCmd('layout', 'default');
     $view = $this->getView($viewName, $type, '');
     $view->setLayout($viewLayout);
     if ($type == 'ajax') {
         if (!method_exists($view, $viewLayout)) {
             $view->display();
         } else {
             $json = FD::json();
             $params = $json->decode(JRequest::getVar('params'));
             call_user_func_array(array($view, $viewLayout), $params);
         }
     } else {
         if ($viewLayout != 'default') {
             if (!method_exists($view, $viewLayout)) {
                 $view->display();
             } else {
                 call_user_func_array(array($view, $viewLayout), array());
             }
         } else {
             $view->display();
         }
     }
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:36,代码来源:controller.php

示例11: main

 public function main()
 {
     $db = FD::db();
     $sql = $db->sql();
     $sql->select('#__social_fields_data', 'a');
     $sql->column('a.id');
     $sql->column('a.data');
     $sql->leftjoin('#__social_fields', 'b');
     $sql->on('a.field_id', 'b.id');
     $sql->leftjoin('#__social_apps', 'c');
     $sql->on('b.app_id', 'c.id');
     $sql->where('c.type', 'fields');
     $sql->where('c.element', 'address');
     $sql->where('a.datakey', '');
     $db->setQuery($sql);
     $result = $db->loadObjectList();
     $json = FD::json();
     // Load up the list of countries
     $file = SOCIAL_ADMIN_DEFAULTS . '/countries.json';
     $list = FD::makeObject($file);
     foreach ($result as $row) {
         if (!$json->isJsonString($row->data)) {
             continue;
         }
         $data = $json->decode($row->data);
         if ($data->city) {
             $data->city = str_replace('`', '\'', $data->city);
         }
         if ($data->state) {
             $data->state = str_replace('`', '\'', $data->state);
         }
         if ($data->zip) {
             $data->zip = str_replace('`', '\'', $data->zip);
         }
         if (!empty($data->country) && strlen($data->country) === 2 && isset($list->{$data->country})) {
             $data->country = $list->{$data->country};
         }
         // Recreate the json string
         $string = $json->encode($data);
         // Recreate the raw data
         unset($data->latitude);
         unset($data->longitude);
         $raw = implode(array_values((array) $data), ' ');
         $raw = str_replace('`', '\'', $raw);
         $sql->clear();
         $sql->update('#__social_fields_data');
         $sql->set('data', $string);
         $sql->set('raw', $raw);
         $sql->where('id', $row->id);
         $db->setQuery($sql);
         $db->query();
     }
     return true;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:54,代码来源:UpdateAddressCountriesToLongName.php

示例12: __construct

 /**
  * Class constructor.
  *
  * @since	1.0
  * @access	public
  */
 public function __construct($params = array())
 {
     // Helper json library.
     $this->json = FD::json();
     // Field library
     $this->lib = FD::fields();
     // Field handlers
     $this->handler = $this->lib->getHandler();
     // Init params
     $this->init($params);
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:17,代码来源:triggers.php

示例13: onEditAfterSave

 public function onEditAfterSave(&$post, &$user)
 {
     $json = FD::json();
     $params = $json->decode($post[$this->inputName]);
     if (!isset($params->type)) {
         return false;
     }
     // We set it as array here to follow the standard of textboxlist passing in target as array even for single target
     if (!isset($params->target)) {
         $params->target = array(0);
     }
     $model = $this->model('relations');
     $relation = $model->getActorRelationship($user->id);
     // If no relationship data is found, then we init a new one
     if ($relation === false) {
         $relation = $this->table('relations');
     }
     $origType = $relation->type;
     $origTarget = $relation->getTargetUser()->id;
     $currentType = $params->type;
     // Do not use $relation->isConnect because the type might change
     $typeInfo = $relation->getType($currentType);
     $currentTarget = $typeInfo && $typeInfo->connect ? $params->target[0] : 0;
     // Only process if there is a change in type or target
     if ($origType !== $currentType || $origTarget !== $currentTarget) {
         // If original target is not empty, we need to find the target's relationship and change it to empty target since this person is no longer tied to that target
         if (!empty($origTarget)) {
             $targetRel = $model->getActorRelationship($origTarget, array('target' => $user->id));
             if ($targetRel) {
                 $targetRel->target = 0;
                 $targetRel->state = 1;
                 $targetRel->store();
             }
         }
         // If this relationship has an id, means it is from an existing record.
         // We need to delete and recreate it in order to have a new id.
         // When the target approves, the genereted stream needs to use the new id instead of the old id.
         if (!empty($relation->id)) {
             $relation->remove();
             $relation = $this->table('relations');
         }
         $relation->actor = $user->id;
         $relation->type = $currentType;
         $relation->target = $currentTarget;
         $state = $relation->request();
         if (!$state) {
             return false;
         }
     }
     return true;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:51,代码来源:relationship.php

示例14: main

 public function main()
 {
     // Only birthday field and datetime field is affected
     $birthdayTable = FD::table('app');
     $birthdayTable->load(array('type' => SOCIAL_APPS_TYPE_FIELDS, 'group' => SOCIAL_FIELDS_GROUP_USER, 'element' => 'birthday'));
     $datetimeTable = FD::table('app');
     $datetimeTable->load(array('type' => SOCIAL_APPS_TYPE_FIELDS, 'group' => SOCIAL_FIELDS_GROUP_USER, 'element' => 'datetime'));
     // $appid = array($birthdayTable->id, $datetimeTable->id);
     $db = FD::db();
     $sql = $db->sql();
     // $sql->select('#__social_fields_data')
     // 	->where('field_id', $appid, 'in')
     // 	->where('data', '', '!=');
     $query = "select a.* from `#__social_fields_data` as a";
     $query .= "\tinner join `#__social_fields` as b on a.`field_id` = b.`id`";
     $query .= " where b.`app_id` IN ({$birthdayTable->id}, {$datetimeTable->id})";
     $query .= " and a.`data` != ''";
     // echo $query;exit;
     $sql->raw($query);
     $db->setQuery($sql);
     $result = $db->loadObjectList();
     $json = FD::json();
     foreach ($result as $row) {
         if (empty($row->data)) {
             continue;
         }
         $table = FD::table('fielddata');
         $table->bind($row);
         if ($json->isJsonString($table->data)) {
             $val = $json->decode($table->data);
             if ($val->year && $val->month && $val->day) {
                 $dateVal = $val->year . '-' . $val->month . '-' . $val->day;
                 $table->raw = FD::date($val->year . '-' . $val->month . '-' . $val->day)->toSql();
             }
         } else {
             try {
                 $val = FD::date($table->data);
             } catch (Exception $e) {
                 $table->data = '';
                 $table->raw = '';
                 $table->store();
                 continue;
             }
             $table->data = $json->encode(array('year' => $val->toFormat('Y'), 'month' => $val->toFormat('n'), 'day' => $val->toFormat('j')));
             $table->raw = $val->toSql();
         }
         $table->store();
     }
     return true;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:50,代码来源:FixMigratorDatetime.php

示例15: getShareId

 public function getShareId()
 {
     $url = $this->getParamUrl();
     $params = FD::json()->encode($this->params);
     $table = FD::table('tmp');
     $table->type = 'sharing';
     $table->key = $url;
     $table->value = $params;
     $result = $table->store();
     if ($result === false) {
         return false;
     }
     return $table->id;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:14,代码来源:email.php


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