本文整理汇总了PHP中Horde_Serialize::unserialize方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Serialize::unserialize方法的具体用法?PHP Horde_Serialize::unserialize怎么用?PHP Horde_Serialize::unserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Serialize
的用法示例。
在下文中一共展示了Horde_Serialize::unserialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDataValue
/**
* Retrieves the txt_datavalue or int_datavalue depending on context
*/
public function getDataValue()
{
/* These field-specific handlers should better be delegated to field
* definitions. */
switch ($this->property->datatype) {
case 'date':
case 'datetime':
case 'hourminutesecond':
case 'monthdayyear':
case 'monthyear':
case 'time':
if (is_int($this->txt_datavalue)) {
return new Horde_Date($this->txt_datavalue);
}
$dt = new Horde_Date();
foreach (Horde_Serialize::unserialize($this->txt_datavalue, Horde_Serialize::BASIC) as $marker => $content) {
if (strlen($content)) {
$dt->{$marker} = $content;
}
}
return $dt;
case 'image':
return array('hash' => $this->txt_datavalue);
default:
return $this->txt_datavalue;
}
}
示例2: search
/**
* Search for a user's free/busy information.
*
* @param string $email The email address to lookup
* @param boolean $private_only (optional) Only return free/busy
* information owned by this used.
*
* @return Horde_Icalendar_Vfreebusy
* @throws Kronolith_Exception
*/
public function search($email, $private_only = false)
{
/* Build the SQL query. */
$query = sprintf('SELECT vfb_serialized FROM %s WHERE vfb_email = ? AND (vfb_owner = ?', $this->_params['table']);
$values = array($email, $this->_user);
if ($private_only) {
$query .= ')';
} else {
$query .= " OR vfb_owner = '')";
}
/* Execute the query. */
try {
$result = $this->_db->selectValue($query, $values);
if (empty($result)) {
throw new Horde_Exception_NotFound();
}
return Horde_Serialize::unserialize($result, Horde_Serialize::BASIC);
} catch (Horde_Db_Exception $e) {
throw new Kronolith_Exception($e);
}
}
示例3: minisearch
/**
* AJAX action: Return Turba minisearch information.
*
* Variables used:
* - abooks: (array) UIDs of source addressbook.
* - search: (string) Search string.
*
* @return object HTML search output in the 'html' parameter.
*/
public function minisearch()
{
global $attributes, $injector, $registry;
$ob = new stdClass();
$results = array();
$search = trim($this->vars->search);
if (!is_null($search)) {
foreach (Horde_Serialize::unserialize($this->vars->abooks, Horde_Serialize::JSON) as $val) {
try {
$res = $injector->getInstance('Turba_Factory_Driver')->create($val)->search(array('name' => $search));
while ($ob = $res->next()) {
if ($ob->isGroup()) {
continue;
}
foreach ($ob->getAttributes() as $k => $v) {
if (!empty($attributes[$k]['type']) && $attributes[$k]['type'] == 'email') {
if (!empty($v)) {
try {
$mail_link = $registry->call('mail/compose', array(array('to' => $v)));
} catch (Horde_Exception $e) {
$mail_link = 'mailto:' . urlencode($v);
}
}
$link = empty($v) ? htmlspecialchars($ob->getValue('name')) : htmlspecialchars($ob->getValue('name') . ' <' . $v . '>');
$results[] = '<li class="linedRow">' . Horde::link(Horde::url($ob->url()), _("View Contact"), '', '_parent') . Horde_Themes_Image::tag('contact.png', array('alt' => _("View Contact"))) . '</a> ' . (!empty($v) ? '<a href="' . $mail_link . '">' : '') . $link . (!empty($v) ? '</a>' : '') . '</li>';
break;
}
}
}
} catch (Turba_Exception $e) {
}
}
}
if (count($results)) {
$ob->html = '<ul>' . implode('', $results) . '</ul>';
} elseif (!is_null($search)) {
$ob->html = _("No contacts found");
}
return $ob;
}
示例4: display
/**
*/
public function display(Horde_Core_Prefs_Ui $ui)
{
global $injector, $prefs, $registry, $session;
$twitter = $injector->getInstance('Horde_Service_Twitter');
$token = unserialize($prefs->getValue('twitter'));
/* Check for an existing token */
if (!empty($token['key']) && !empty($token['secret'])) {
$auth_token = new Horde_Oauth_Token($token['key'], $token['secret']);
$twitter->auth->setToken($auth_token);
}
try {
$profile = Horde_Serialize::unserialize($twitter->account->verifyCredentials(), Horde_Serialize::JSON);
} catch (Horde_Service_Twitter_Exception $e) {
}
$view = new Horde_View(array('templatePath' => HORDE_TEMPLATES . '/prefs'));
$view->addHelper('Text');
$view->appname = $registry->get('name');
/* Could not find a valid auth token, and we are not in the process of
* getting one */
if (empty($profile)) {
try {
$results = $twitter->auth->getRequestToken();
} catch (Horde_Service_Twitter_Exception $e) {
throw new Horde_Exception(sprintf(_("Error connecting to Twitter: %s Details have been logged for the administrator."), $e->getMessage()));
}
$session->store($results->secret, false, 'twitter_request_secret');
$view->link = new Horde_Url(Horde::externalUrl($twitter->auth->getUserAuthorizationUrl($results), false));
} else {
$view->haveSession = true;
$view->profile_image_url = $profile->profile_image_url;
$view->profile_screenname = $profile->screen_name;
$view->profile_name = $profile->name;
$view->profile_location = $profile->location;
}
return $view->render('twitter');
}
示例5: array
#!/usr/bin/env php
<?php
/**
* Simple Twitter client.
*
* Copyright 2009-2015 Horde LLC (http://www.horde.org/)
*
* @author Jan Schneider <jan@horde.org>
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @license http://www.horde.org/licenses/bsd BSD
* @category Horde
* @package Service_Twitter
*/
/* Keys - these are obtained when registering for the service */
$keys = array('consumer_key' => '*****', 'consumer_secret' => '*****', 'access_token' => '*****-*****', 'access_token_secret' => '*****');
/* Enable autoloading. */
require 'Horde/Autoloader/Default.php';
/* Create the Twitter client */
$twitter = Horde_Service_Twitter::create(array('oauth' => $keys));
/* Do something cool.... */
try {
$result = $twitter->statuses->update('Testing Horde/Twitter integration 2');
print_r(Horde_Serialize::unserialize($result, Horde_Serialize::JSON));
} catch (Horde_Service_Twitter_Exception $e) {
$error = Horde_Serialize::unserialize($e->getMessage(), Horde_Serialize::JSON);
echo "{$error->error}\n";
}
示例6: importData
public function importData($contents, $header = false)
{
$data = array();
$json = Horde_Serialize::unserialize($contents, Horde_Serialize::JSON);
return $this->_parseJson($json->children, null);
}
示例7: _makeRequest
/**
* Make the remote API call.
*
* @param Horde_Url $url The endpoint.
*
* @return mixed The unserialized results form the remote API call.
* @throws Horde_Service_Weather_Exception
*/
protected function _makeRequest(Horde_Url $url)
{
$url->add(array('format' => 'json', 'key' => $this->_key))->setRaw(true);
$cachekey = md5('hordeweather' . $url);
if (!empty($this->_cache) && !($results = $this->_cache->get($cachekey, $this->_cache_lifetime)) || empty($this->_cache)) {
$response = $this->_http->get((string) $url);
if (!$response->code == '200') {
throw new Horde_Service_Weather_Exception($response->code);
}
$results = $response->getBody();
if (!empty($this->_cache)) {
$this->_cache->set($cachekey, $results);
}
}
$results = Horde_Serialize::unserialize($results, Horde_Serialize::JSON);
if (!$results instanceof StdClass) {
throw new Horde_Service_Weather_Exception(sprintf('Error, unable to decode response: %s', $results));
}
return $results;
}
示例8: getFields
/**
* Fetches the fields for a particular form.
*
* @param integer $form_id The form id of the form to return.
*
* @return array The fields.
* @throws Ulaform_Exception
*/
public function getFields($form_id, $field_id = null)
{
$values = array($form_id);
$sql = 'SELECT field_id, form_id, field_name, field_order, field_label, field_type, ' . ' field_params, field_required, field_readonly, field_desc FROM ulaform_fields ' . ' WHERE form_id = ?';
if (!is_null($field_id)) {
$sql .= ' AND field_id = ?';
$values[] = (int) $field_id;
}
$sql .= ' ORDER BY field_order';
try {
$results = $this->_db->select($sql, $values);
} catch (Horde_Db_Exception $e) {
throw new Ulaform_Exception($e);
}
$fields = array();
foreach ($results as $field) {
/* If no internal name set, generate one using field_id. */
if (empty($field['field_name'])) {
$field['field_name'] = 'field_' . $field['field_id'];
}
/* Check if any params and unserialize, otherwise return null. */
if (!empty($field['field_params'])) {
$field['field_params'] = Horde_Serialize::unserialize($field['field_params'], Horde_Serialize::UTF7_BASIC);
} else {
$field['field_params'] = null;
}
$fields[] = $field;
}
return $fields;
}
示例9: _getAllTicketAttributesWithNames
/**
* Returns attribute values and information of a ticket.
*
* @param integer $ticket_id A ticket IDs.
*
* @return array A list of hashes with attribute information and attribute
* value.
* @throws Whups_Exception
*/
protected function _getAllTicketAttributesWithNames($ticket_id)
{
try {
$attributes = $this->_db->selectAll('SELECT d.attribute_id, d.attribute_name, ' . 'd.attribute_description, d.attribute_type, ' . 'd.attribute_params, d.attribute_required, ' . 'a.attribute_value FROM whups_attributes_desc d ' . 'LEFT JOIN whups_tickets t ON (t.ticket_id = ?) ' . 'LEFT OUTER JOIN whups_attributes a ' . 'ON (d.attribute_id = a.attribute_id AND a.ticket_id = ?) ' . 'WHERE d.type_id = t.type_id ORDER BY d.attribute_name', array($ticket_id, $ticket_id));
} catch (Horde_Db_Exception $e) {
throw new Whups_Exception($e);
}
foreach ($attributes as &$attribute) {
$attribute['attribute_name'] = $this->_fromBackend($attribute['attribute_name']);
$attribute['attribute_description'] = $this->_fromBackend($attribute['attribute_description']);
$attribute['attribute_type'] = empty($attribute['attribute_type']) ? 'text' : $attribute['attribute_type'];
$attribute['attribute_params'] = $this->_fromBackend(@unserialize($attribute['attribute_params']));
$attribute['attribute_required'] = (bool) $attribute['attribute_required'];
try {
$attribute['attribute_value'] = Horde_Serialize::unserialize($attribute['attribute_value'], Horde_Serialize::JSON);
} catch (Horde_Serialize_Exception $e) {
}
}
return $attributes;
}
示例10: testJsonSpaces
public function testJsonSpaces()
{
$obj = new stdClass();
$obj->a_string = "\"he\":llo}:{world";
$obj->an_array = array(1, 2, 3);
$obj->obj = new stdClass();
$obj->obj->a_number = 123;
$obj_js = '{"a_string": "\\"he\\":llo}:{world",
"an_array":[1, 2, 3],
"obj": {"a_number":123}}';
// checking whether notation with spaces works
$this->assertEquals($obj, Horde_Serialize::unserialize($obj_js, Horde_Serialize::JSON));
}
示例11: listFolder
/**
* List the current folder.
*
* @param string $dir The directory name.
*
* @return array The sorted list of files.
* @throws Gollem_Exception
*/
public static function listFolder($dir)
{
global $conf;
if (!empty($conf['foldercache']['use_cache']) && !empty($conf['cache']['driver']) && $conf['cache']['driver'] != 'none') {
$key = self::_getCacheID($dir);
$cache = $GLOBALS['injector']->getInstance('Horde_Cache');
$res = $cache->get($key, $conf['foldercache']['lifetime']);
if ($res !== false) {
$res = Horde_Serialize::unserialize($res, Horde_Serialize::BASIC);
if (is_array($res)) {
return $res;
}
}
}
try {
$files = $GLOBALS['injector']->getInstance('Gollem_Vfs')->listFolder($dir, isset(self::$backend['filter']) ? self::$backend['filter'] : null, $GLOBALS['prefs']->getValue('show_dotfiles'));
} catch (Horde_Vfs_Exception $e) {
throw new Gollem_Exception($e);
}
$sortcols = array(self::SORT_TYPE => 'sortType', self::SORT_NAME => 'sortName', self::SORT_DATE => 'sortDate', self::SORT_SIZE => 'sortSize');
usort($files, array('Gollem', $sortcols[$GLOBALS['prefs']->getValue('sortby')]));
if (isset($cache)) {
$cache->set($key, Horde_Serialize::serialize($files, Horde_Serialize::BASIC), $conf['foldercache']['lifetime']);
}
return $files;
}
示例12: getHistory
/**
* Fetch ticket history
*
* @param integer $ticket_id The ticket to fetch history for.
*
* @return array
*/
public function getHistory($ticket_id, Horde_Form $form = null)
{
$rows = $this->_getHistory($ticket_id);
$attributes = $attributeDetails = array();
foreach ($rows as $row) {
if ($row['log_type'] == 'attribute' && strpos($row['log_value'], ':')) {
$attributes[(int) $row['log_value']] = $row['attribute_name'];
}
if ($row['log_type'] == 'type') {
$attributeDetails += $this->getAttributesForType($row['log_value']);
}
}
$renderer = new Horde_Core_Ui_VarRenderer_Html();
$history = array();
foreach ($rows as $row) {
$label = null;
$human = $value = $row['log_value'];
$type = $row['log_type'];
$transaction = $row['transaction_id'];
$history[$transaction]['timestamp'] = $row['timestamp'];
$history[$transaction]['user_id'] = $row['user_id'];
$history[$transaction]['ticket_id'] = $row['ticket_id'];
switch ($type) {
case 'comment':
$history[$transaction]['comment'] = $row['comment_text'];
$history[$transaction]['changes'][] = array('type' => 'comment', 'value' => $row['log_value'], 'comment' => $row['comment_text']);
continue 2;
case 'queue':
$label = $row['queue_name'];
break;
case 'version':
$label = $row['version_name'];
break;
case 'type':
$label = $row['type_name'];
break;
case 'state':
$label = $row['state_name'];
break;
case 'priority':
$label = $row['priority_name'];
break;
case 'attribute':
continue 2;
case 'due':
$label = $row['log_value_num'];
break;
default:
if (strpos($type, 'attribute_') === 0) {
if (is_string($value) && defined('JSON_BIGINT_AS_STRING')) {
$value = json_decode($value, true, 512, constant('JSON_BIGINT_AS_STRING'));
} else {
try {
$value = Horde_Serialize::unserialize($value, Horde_Serialize::JSON);
} catch (Horde_Serialize_Exception $e) {
}
}
$attribute = substr($type, 10);
if (isset($attributes[$attribute])) {
$label = $attributes[$attribute];
if ($form) {
if (isset($form->attributes[$attribute])) {
/* Attribute is part of the current type, so we
* have the form field in the current form. */
$field = $form->attributes[$attribute];
} else {
/* Attribute is from a different type, create
* the form field manually. */
$detail = $attributeDetails[$attribute];
$field = new Horde_Form_Variable($detail['human_name'], $type, $form->getType($detail['type'], $detail['params']), $detail['required'], $detail['readonly'], $detail['desc']);
}
$human = $renderer->render($form, $field, new Horde_Variables(array($type => $value)));
}
$type = 'attribute';
} else {
$label = sprintf(_("Attribute %d"), $attribute);
}
}
break;
}
$history[$transaction]['changes'][] = array('type' => $type, 'value' => $value, 'human' => $human, 'label' => $label);
}
return $history;
}
示例13: _outputError
_outputError($e);
}
/* Clear the temporary request secret */
$session->purge('twitter_request_secret');
if ($auth_token === false || empty($auth_token)) {
// We had a request secret, but something went wrong. maybe navigated
// back here between requests?
// fall through? Display message? What?....
//'echo';
//
} else {
/* Successfully obtained an auth token, save it to prefs etc... */
$prefs->setValue('twitter', serialize(array('key' => $auth_token->key, 'secret' => $auth_token->secret)));
/* Now try again */
$twitter->auth->setToken($auth_token);
try {
$profile = Horde_Serialize::unserialize($twitter->account->verifyCredentials(), Horde_Serialize::JSON);
} catch (Horde_Service_Twitter_Exception $e) {
_outputError($e);
}
if (!empty($profile->error)) {
_outputError($profile->error);
}
if (!empty($profile)) {
$page_output->header();
echo '<script type="text/javascript">window.opener.location.reload(true);window.close();</script>';
$page_output->footer();
exit;
}
}
}
示例14: array
/**
* Fetches a gateway from the backend.
*
* @param int $gateway_id The gateway id to fetch.
*
* @return array An array containing the gateway settings and parameters.
*/
function &getGateway($gateway_id)
{
/* Get the gateways. */
$sql = 'SELECT * FROM swoosh_gateways WHERE gateway_id = ?';
$values = array((int) $gateway_id);
Horde::log('SQL Query by Hylax_Storage_sql::getGateway(): ' . $sql, 'DEBUG');
$gateway = $this->_db->getRow($sql, $values, DB_FETCHMODE_ASSOC);
if (is_a($gateway, 'PEAR_Error')) {
Horde::log($gateway, 'ERR');
return $gateway;
}
/* Unserialize the gateway params. */
$gateway['gateway_params'] = Horde_Serialize::unserialize($gateway['gateway_params'], Horde_Serialize::UTF7_BASIC);
/* Unserialize the gateway send params. */
$gateway['gateway_sendparams'] = Horde_Serialize::unserialize($gateway['gateway_sendparams'], Horde_Serialize::UTF7_BASIC);
return $gateway;
}
示例15: request
/**
* Builds an JSON-RPC request and sends it to the server.
*
* This statically called method is actually the JSON-RPC client.
*
* @param string|Horde_Url $url The path to the JSON-RPC server on the
* called host.
* @param string $method The method to call.
* @param Horde_Http_Client $client
* @param array $params A hash containing any necessary parameters
* for the method call.
*
* @return mixed The returned result from the method.
* @throws Horde_Rpc_Exception
*/
public static function request($url, $method, $client, $params = null)
{
$headers = array('User-Agent' => 'Horde RPC client', 'Accept' => 'application/json', 'Content-Type' => 'application/json');
$data = array('version' => '1.1', 'method' => $method);
if (!empty($params)) {
$data['params'] = $params;
}
$data = Horde_Serialize::serialize($data, Horde_Serialize::JSON);
try {
$result = $client->post($url, $data, $headers);
} catch (Horde_Http_Exception $e) {
throw new Horde_Rpc_Exception($e->getMessage());
}
if ($result->code == 500) {
$response = Horde_Serialize::unserialize($result->getBody(), Horde_Serialize::JSON);
if (is_a($response, 'stdClass') && isset($response->error) && is_a($response->error, 'stdClass') && isset($response->error->name) && $response->error->name == 'JSONRPCError') {
throw new Horde_Rpc_Exception($response->error->message);
/* @todo: Include more information if we have an Exception that can handle this.
return PEAR::raiseError($response->error->message,
$response->error->code,
null, null,
isset($response->error->error) ? $response->error->error : null);
*/
}
throw new Horde_Rpc_Exception($http->getResponseBody());
} elseif ($result->code != 200) {
throw new Horde_Rpc_Exception('Request couldn\'t be answered. Returned errorcode: "' . $result->code);
}
return Horde_Serialize::unserialize($result->getBody(), Horde_Serialize::JSON);
}