本文整理汇总了PHP中Services_JSON::encode方法的典型用法代码示例。如果您正苦于以下问题:PHP Services_JSON::encode方法的具体用法?PHP Services_JSON::encode怎么用?PHP Services_JSON::encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Services_JSON
的用法示例。
在下文中一共展示了Services_JSON::encode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: del
function del($params)
{
$json = new Services_JSON();
$subcategory = DB_DataObject::factory("subcategory");
$subcategory->id = $params["id"];
print $subcategory->delete() ? $json->encode(array("error" => false)) : $json->encode(array("error" => true));
}
示例2: send
public function send()
{
// if( ob_get_length() !== false )
// {
// while (@ ob_end_clean());
// if( function_exists( 'ob_clean' ) )
// {
// @ob_clean();
// }
// }
header('Content-type: text/x-json; UTF-8');
require_once( KOMENTO_CLASSES . DIRECTORY_SEPARATOR . 'json.php' );
$json = new Services_JSON();
$callback = JRequest::getVar('callback');
if (isset($callback))
{
echo $callback . '(' . $json->encode( $this->commands ) . ');';
} else {
echo $json->encode( $this->commands );
}
exit;
}
示例3: run
public function run()
{
require_once _lms_ . '/lib/lib.kbres.php';
$kbres = new KbRes();
$data = false;
if ($this->res_id > 0) {
$data = $kbres->getResource($this->res_id, true, true);
} else {
if (!empty($this->r_item_id) && !empty($this->r_type)) {
$data = $kbres->getResourceFromItem($this->r_item_id, $this->r_type, $this->r_env, true, true);
}
}
if ($data == false) {
$data = array('res_id' => 0, 'r_name' => '', 'original_name' => '', 'r_desc' => '', 'r_item_id' => $this->r_item_id, 'r_type' => $this->r_type, 'r_env' => $this->r_env, 'r_env_parent_id' => $this->r_env_parent_id, 'r_param' => $this->r_param, 'r_alt_desc' => '', 'r_lang' => !empty($this->language) ? $this->language : getLanguage(), 'force_visible' => 0, 'is_mobile' => 0, 'folders' => array(), 'tags' => array());
}
if (!empty($this->original_name)) {
$data['original_name'] = $this->original_name;
}
$c_folders = array_keys($data['folders']);
unset($data['folders']);
$c_tags = $data['tags'];
unset($data['tags']);
$json = new Services_JSON();
$this->render('kbcategorize', array('selected_node' => $this->_getSelectedNode(), 'back_url' => $this->back_url, 'form_url' => $this->form_url, 'form_extra_hidden' => $this->form_extra_hidden, 'data' => $data, 'c_folders' => $c_folders, 'c_tags_json' => $json->encode(array_values($c_tags)), 'all_tags_json' => $json->encode(array_values($kbres->getAllTags()))));
}
示例4: getUserData
function getUserData($id)
{
$user = new AMP_User_Profile(AMP_registry::getDbcon(), $id);
if ($user) {
$data = array();
$data['Email'] = $user->getData('Email');
$data['First_Name'] = $user->getData('First_Name');
$data['Last_Name'] = $user->getData('Last_Name');
$data['Phone'] = $user->getData('Phone');
$data['Company'] = $user->getData('Company');
$data['City'] = $user->getData('City');
$data['Country'] = $user->getData('Country');
$data['custom1'] = $user->getData('custom1');
$data['custom3'] = $user->getData('custom3');
$data['custom4'] = $user->getData('custom4');
$message = array();
$message['type'] = 'good';
$message['text'] = 'Success';
$json = new Services_JSON();
$json_data = array('data' => $data, 'message' => $message, 'success' => true);
$output = $json->encode($json_data);
return $output;
} else {
$message = array();
$message['type'] = 'bad';
$message['text'] = 'Unrecognized User ID';
$json_data = array('message' => $message);
$output = $json->encode($json_data);
return $output;
}
}
示例5: doLogin
function doLogin($usu_login, $usu_senha)
{
$db = new db("../config.php");
$json = new Services_JSON();
$db->executa($db->getJoinRecord("funcionarios", "fun_nome='{$usu_login}' and fun_senha='{$usu_senha}'", '', 0), true, "user");
if ($db->num_rows == 1) {
$id = $db->user["usu_id"];
$login = $db->user["usu_login"];
$itens = array("usu_id" => $id, "usu_login" => $login, "status" => 1);
$str = $json->encode($itens);
session_register("usu_nome");
session_register("usu_id");
$_SESSION["usu_modulo"] = 0;
$_SESSION["usu_nome"] = $db->user["fun_nome"];
$_SESSION["usu_id"] = $db->user["fun_id"];
$_SESSION["sis_exerc"] = $exercicio;
$_SESSION["usu_grpid"] = $grp_id;
$_SESSION["bgcolor"] = "#EAE5DA";
$_SESSION["dtatend"] = date("d/m/Y");
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
} else {
$ip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
}
} else {
$itens = array("usu_id" => '', "usu_login" => $_GET["usu_login"], "status" => 2);
$str = $json->encode($itens);
}
return $str;
}
示例6: array
function handleJSON_getContent($smarty, $module_name, $appletlist)
{
$respuesta = array('status' => 'success', 'message' => '(no message)');
// Leer credenciales a partir del usuario y el perfil asociado
global $arrConf;
$dbAcl = new paloDB($arrConf["elastix_dsn"]["acl"]);
$pACL = new paloACL($dbAcl);
$userId = $pACL->getIdUser($_SESSION['elastix_user']);
$mailCred = $this->leerPropiedadesWebmail($dbAcl, $userId);
if (count($mailCred) <= 0) {
$respuesta['status'] = 'error';
$respuesta['message'] = _tr("You don't have a webmail account");
} elseif (!$this->_checkEmailPassword("{$mailCred['login']}@{$mailCred['domain']}", isset($mailCred['password']) ? $mailCred['password'] : '')) {
$respuesta['status'] = 'error';
$respuesta['message'] = "{$mailCred['login']}@{$mailCred['domain']} " . _tr("does not exist locally or password is incorrect");
} else {
$imap = @imap_open("{localhost:143/notls}", "{$mailCred['login']}@{$mailCred['domain']}", isset($mailCred['password']) ? $mailCred['password'] : '');
if (!$imap) {
$respuesta['status'] = 'error';
$respuesta['message'] = _tr('Imap: Connection error');
} else {
$this->leerInformacionImap($smarty, $module_name, $imap, $respuesta);
imap_close($imap);
}
}
$json = new Services_JSON();
Header('Content-Type: application/json');
return $json->encode($respuesta);
}
示例7: index
function index($params)
{
$search_criteria = array("sort" => "date DESC");
if (!empty($this->search_for_payments)) {
$search_criteria = array_merge($search_criteria, $this->search_for_payments);
}
$this->data->payments = Payment::getMany($search_criteria);
if (!empty($params['spokes'])) {
$spokes_data = $this->data->payments;
$rows = array();
foreach ($spokes_data as $data_item) {
$rows[] = $data_item->to_spokes();
}
$json = new Services_JSON();
$this->response = array('body' => $json->encode($rows));
if (!empty($params['callback'])) {
$this->response['body'] = $params['callback'] . '(' . $this->response['body'] . ')';
}
return;
}
$this->data->search_payment = new Payment();
$this->data->search_payment->set($search_criteria);
$this->data->new_payment = new Payment();
$this->data->new_payment->set(array('date' => date('Y-m-d')));
}
示例8: saveupload
public function saveupload()
{
$json = new Services_JSON();
$uploadpath = 'upload/goods/';
$filepath = '/upload/goods/';
$upload = new upload($uploadpath, array('gif', 'jpg', 'jpge', 'png'));
//upload
$file = $upload->getfile();
if ($upload->errno != 15 && $upload->errno != 0) {
$msg = $json->encode(array('error' => 1, 'message' => $upload->errmsg()));
} else {
$msg = $json->encode(array('error' => 0, 'url' => $filepath . $file[0][saveName], 'trueurl' => $upload->returninfo['name']));
}
echo $msg;
exit;
}
示例9: getData
/**
* It is specific implementation of ancestor method getData()
*
* @return <String> JSON represantation of given data.
*/
public function getData()
{
$attributes = $this->solveData();
$this->jsonObject['attributes'] = $attributes;
$interestMeasure = $this->solveInterestMeasures();
$this->jsonObject['interestMeasures'] = $interestMeasure;
$this->solveNumberBBA();
$this->solveDepthNesting();
$this->solveMoreRules();
$interestMeasure = $this->domFL->getElementsByTagName("InterestMeasures")->item(0);
$bba = $this->domFL->getElementsByTagName("BasicBooleanAttribute")->item(0);
$threshold = "optional";
$coefficient = "optional";
if ($interestMeasure->getAttribute("threshold") != "") {
$threshold = $interestMeasure->getAttribute("threshold");
}
if ($bba->getAttribute("coefficient") != "") {
$coefficient = $bba->getAttribute("coefficient");
}
$this->jsonObject['imThreshold'] = $threshold;
$this->jsonObject['attrCoef'] = $coefficient;
$posCoef = $this->solvePosCoef();
$this->jsonObject['possibleCoef'] = $posCoef;
if ($this->domER != null) {
$this->solveExistingRules();
} else {
$this->jsonObject['rules'] = 0;
}
$this->jsonObject['lang'] = $this->lang;
$json = new Services_JSON();
return $json->encode($this->jsonObject);
}
示例10: paloSantoJSON
function HTTP_GET()
{
$json = new paloSantoJSON();
$pCore_calendar = new core_Calendar();
$fields = isset($_GET["fields"]) ? $_GET["fields"] : NULL;
if (is_null($fields)) {
header("HTTP/1.1 400 Bad Request");
$error = "You need to specify by GET the parameter \"fields\"";
$json->set_status("ERROR");
$json->set_error($error);
return $json->createJSON();
}
$result = $pCore_calendar->getHash($fields);
if ($result === FALSE) {
$error = $pCore_calendar->getError();
if ($error["fc"] == "DBERROR") {
header("HTTP/1.1 500 Internal Server Error");
} else {
header("HTTP/1.1 400 Bad Request");
}
$json->set_status("ERROR");
$json->set_error($error);
return $json->createJSON();
} else {
$json = new Services_JSON();
return $json->encode($result);
}
}
示例11: send
public function send()
{
// If no commands were added, just resolve this ajax request.
if (empty($this->commands)) {
$nulldata = array();
$this->addCommand('resolve', $nulldata);
}
require_once DISCUSS_CLASSES . '/json.php';
$json = new Services_JSON();
$transport = JRequest::getVar('transport');
$response = $json->encode($this->commands);
switch ($transport) {
case "jsonp":
header('Content-type: text/javascript; UTF-8');
$callback = JRequest::getVar('callback');
echo $callback . '(' . $response . ');';
break;
case "iframe":
header('Content-type: text/html; UTF-8');
echo '<textarea data-type="application/json" data-status="200" data-statusText="OK">' . $response . '</textarea>';
break;
default:
header('Content-type: text/javascript; UTF-8');
echo $response;
}
exit;
}
示例12: display
function display($tpl = null)
{
$params =& JComponentHelper::getParams('com_mediasyndicator');
$basebrowserpath = $params->get('basebrowserpath', DS . 'images');
$dir = JRequest::getVar('dir', '');
$firephp = FirePHP::getInstance(true);
$firephp->log('%^' . preg_quote($basebrowserpath) . '%', 'regex');
$dir = preg_replace('%^' . preg_quote($basebrowserpath) . '%', '', $dir);
$document =& JFactory::getDocument();
//$document->setMimeEncoding('application/json');
$document->setMimeEncoding('application/x-javascript');
//TODO: verify that this is a logged in user in the backend of Joomla!
// include JSON service file
$JSONfile = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_mediasyndicator' . DS . 'libraries' . DS . 'JSON.php';
$includeFile = $this->includeFile($JSONfile);
if ($includeFile) {
print $includeFile;
return;
}
$directoryarray = $this->createDirectoryArray($dir, $basebrowserpath);
$directoryarray['requestdir'] = $dir;
$json = new Services_JSON();
$output = $json->encode($directoryarray);
print $output;
}
示例13:
function json_encode($content)
{
global $homedir;
require_once $homedir . "/classes/json/JSON.php";
$json = new Services_JSON();
return $json->encode($content);
}
示例14: output
private function output($response)
{
include_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'json.php';
$json = new Services_JSON();
echo $json->encode($response);
exit;
}
示例15: date
/**
* Outputs a Multipass token for the array provided. The array is a freeform
* array that should conform to the requirements set forth by TenderApp with
* regards to required and recommended values.
*
* It is not necessary to pass in the expiration date. This library will
* generate that for you automatically.
*
* @param data An associative array containing the data to be encoded.
* @return An encoded multipass token.
*/
function to_string($data)
{
require_once "JSON.php";
$json = new Services_JSON();
// error checking for key names
// unique_id, email required
$data['expires'] = date('D M d H:i:s e Y', time() + 60 * $this->expires);
$sso = $json->encode($data);
$salted = $this->site_key . $this->api_key;
$hash = hash('sha1', $salted, true);
$saltedHash = substr($hash, 0, 16);
$iv = "OpenSSL for PHP!";
for ($i = 0; $i < 16; $i++) {
$sso[$i] = $sso[$i] ^ $iv[$i];
}
$pad = 16 - strlen($sso) % 16;
$sso = $sso . str_repeat(chr($pad), $pad);
$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', '');
mcrypt_generic_init($cipher, $saltedHash, $iv);
$enc = mcrypt_generic($cipher, $sso);
mcrypt_generic_deinit($cipher);
$b64 = base64_encode($enc);
$b64 = preg_replace('/\\n/', '', $b64);
$b64 = preg_replace('/\\=*$/', '', $b64);
$b64 = preg_replace('/\\+/', '-', $b64);
$b64 = preg_replace('/\\//', '_', $b64);
return $b64;
}