本文整理汇总了PHP中Horde_Serialize类的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Serialize类的具体用法?PHP Horde_Serialize怎么用?PHP Horde_Serialize使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Horde_Serialize类的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: _attach
/**
*/
protected function _attach($init)
{
if ($init) {
$this->_jsOnDoAction('$("faces_widget_content").update(' . Horde_Serialize::serialize(_("Loading..."), Horde_Serialize::JSON) . ')');
$this->_jsOnComplete('$("faces_widget_content").update(e.memo)');
$GLOBALS['page_output']->addScriptFile('editfaces.js');
}
return array('image_id' => $this->_params['image_id']);
}
示例3: notify
/**
* Outputs the status line if there are any messages on the 'status'
* message stack.
*
* @param array $events The list of events to handle.
* @param array $options An array of options. Not used.
*/
public function notify($events, $options = array())
{
if (empty($events)) {
return;
}
// TODO: Need to add delay to allow browser to correctly populate
// location of original page, or else closing notification reloads
// previous page (Ticket #11103).
$GLOBALS['injector']->getInstance('Horde_PageOutput')->addInlineScript(array('$(function() {HordeMobile.showNotifications(' . Horde_Serialize::serialize($events, Horde_Serialize::JSON) . ');});'));
}
示例4: getTree
/**
* Returns the tree.
*
* @param boolean $static If true the tree nodes can't be expanded and
* collapsed and the tree gets rendered expanded.
*
* @return string The HTML code of the rendered tree.
*/
public function getTree($static = false)
{
$this->_static = $static;
$opts = array('extraColsLeft' => $this->_colsLeft, 'extraColsRight' => $this->_colsRight, 'header' => $this->_header, 'nocookie' => !$this->getOption('session'), 'options' => $this->_options, 'target' => $this->_tree->instance, 'cookieDomain' => $GLOBALS['conf']['cookie']['domain'], 'cookiePath' => $GLOBALS['conf']['cookie']['path'], 'imgBlank' => $this->_images['blank'], 'imgFolder' => $this->_images['folder'], 'imgFolderOpen' => $this->_images['folderopen'], 'imgLine' => $this->_images['line'], 'imgJoin' => $this->_images['join'], 'imgJoinBottom' => $this->_images['join_bottom'], 'imgJoinTop' => $this->_images['join_top'], 'imgPlus' => $this->_images['plus'], 'imgPlusBottom' => $this->_images['plus_bottom'], 'imgPlusOnly' => $this->_images['plus_only'], 'imgMinus' => $this->_images['minus'], 'imgMinusBottom' => $this->_images['minus_bottom'], 'imgMinusOnly' => $this->_images['minus_only'], 'imgNullOnly' => $this->_images['null_only'], 'imgLeaf' => $this->_images['leaf'], 'initTree' => $this->renderNodeDefinitions());
if (!($js_var = $this->getOption('jsvar'))) {
$js_var = $this->_tree->instance;
}
$GLOBALS['injector']->getInstance('Horde_PageOutput')->addInlineScript(array('window.' . $js_var . ' = new Horde_Tree(' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON) . ')'), true);
return '<div id="' . $this->_tree->instance . '"></div>';
}
示例5: generate
/**
*/
public function generate(Horde_Core_Ajax_Imple_AutoCompleter $ac)
{
$dom_id = $ac->getDomId();
if (!isset($this->params['trigger'])) {
$this->params['trigger'] = $dom_id;
}
if (!isset($this->params['uri'])) {
$this->params['uri'] = strval($ac->getImpleUrl()->setRaw(true));
}
return 'new PrettyAutocompleter(' . Horde_Serialize::serialize($dom_id, Horde_Serialize::JSON) . ',' . '{' . implode(',', $this->_getOpts($ac)) . '})';
}
示例6: _getOpts
/**
* Return the encode list of options.
*
* @return array Options list.
*/
protected function _getOpts(Horde_Core_Ajax_Imple_AutoCompleter $ac)
{
$opts = array();
if (!isset($this->params['indicator'])) {
$this->params['indicator'] = $ac->getDomId() . '_loading_img';
}
foreach ($this->params as $key => $val) {
$opts[] = $key . ':' . (in_array($key, $this->_raw) ? $val : Horde_Serialize::serialize($val, Horde_Serialize::JSON));
}
return $opts;
}
示例7: store
/**
* Store the freebusy information for a given email address.
*
* @param string $email The email address to store fb info for.
* @param Horde_Icalendar_Vfreebusy $vfb TODO
* @param boolean $private_only (optional) TODO
*
* @throws Kronolith_Exception
*/
public function store($email, $vfb, $public = false)
{
/* Build the SQL query. */
$query = sprintf('INSERT INTO %s (vfb_owner, vfb_email, vfb_serialized) VALUES (?, ?, ?)', $this->_params['table']);
$values = array($public ? '' : $this->_user, $email, Horde_Serialize::serialize($vfb, Horde_Serialize::BASIC));
/* Execute the query. */
try {
$this->_db->insert($query, $values);
} catch (Horde_Db_Exception $e) {
throw new Kronolith_Exception($e);
}
}
示例8: send
/**
* Send response data to browser.
*/
public function send()
{
/* By default, the response is sent JSON encoded.
*
* Make sure no null bytes sneak into the JSON output stream. Null
* bytes cause IE to stop reading from the input stream, causing
* malformed JSON data and a failed request. These bytes don't
* seem to break any other browser, but might as well remove them
* anyway. */
header('Content-Type: application/json');
echo str_replace("", '', Horde_Serialize::serialize($this->data, Horde_Serialize::JSON));
}
示例9: _attach
/**
*/
protected function _attach($init)
{
global $page_output;
if ($init) {
$page_output->addScriptFile('spellchecker.js', 'horde');
$page_output->addScriptPackage('Horde_Core_Script_Package_Keynavlist');
$page_output->addInlineJsVars(array('HordeImple.SpellChecker' => new stdClass()));
}
$dom_id = $this->getDomId();
$opts = array('locales' => $this->_params['locales'], 'statusButton' => $dom_id, 'target' => $this->_params['targetId'], 'url' => strval($this->getImpleUrl()->setRaw(true)->add(array('input' => $this->_params['targetId']))));
if (isset($this->_params['states'])) {
$opts['bs'] = $this->_params['states'];
}
$page_output->addInlineScript(array('HordeImple.SpellChecker.' . $dom_id . '=new SpellChecker(' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON) . ')'), true);
return false;
}
示例10: init
/**
* Initialize a HordeMap.
*
* @param array $params
*/
public static function init(array $params = array())
{
global $browser, $conf, $language, $page_output, $registry;
// Language specific file needed?
$language = str_replace('_', '-', $language);
if (!file_exists($registry->get('jsfs', 'horde') . '/map/lang/' . $language . '.js')) {
$language = 'en-US';
}
$params = array_merge(array('conf' => array('language' => $language, 'markerImage' => strval(Horde_Themes::img('map/marker.png')), 'markerBackground' => strval(Horde_Themes::img('map/marker-shadow.png')), 'useMarkerLayer' => true), 'driver' => 'Horde', 'geocoder' => $conf['maps']['geocoder'], 'jsuri' => $registry->get('jsuri', 'horde') . '/map/', 'providers' => $conf['maps']['providers'], 'ssl' => $browser->usingSSLConnection()), $params);
foreach ($params['providers'] as $layer) {
switch ($layer) {
case 'Google':
$params['conf']['apikeys']['google'] = $conf['api']['googlemaps'];
break;
case 'Yahoo':
$params['conf']['apikeys']['yahoo'] = $conf['api']['yahoomaps'];
break;
case 'Cloudmade':
$params['conf']['apikeys']['cloudmade'] = $conf['api']['cloudmade'];
break;
case 'Mytopo':
/* Mytopo requires a hash of the *client* IP address and the
* key. Note that this also causes Mytopo to break if the
* client's IP address presented as an internal address. */
$params['conf']['apikeys']['mytopo'] = array('id' => $conf['api']['mytopo_partnerID'], 'hash' => strtoupper(md5($conf['api']['mytopo'] . $browser->getIpAddress())));
break;
}
}
if (!empty($params['geocoder'])) {
switch ($params['geocoder']) {
case 'Google':
$params['conf']['apikeys']['google'] = $conf['api']['googlemaps'];
break;
case 'Yahoo':
$params['conf']['apikeys']['yahoo'] = $conf['api']['yahoomaps'];
break;
case 'Cloudmade':
$params['conf']['apikeys']['cloudmade'] = $conf['api']['cloudmade'];
break;
}
}
$page_output->addScriptFile('map/map.js', 'horde');
$page_output->addInlineScript(array('HordeMap.initialize(' . Horde_Serialize::serialize($params, HORDE_SERIALIZE::JSON) . ');'));
}
示例11: initialize
/**
* @param array $params The following configuration parameters:
* - basic: (boolean) Load "basic" editor (a small javascript stub that
* will download the full code on demand)?
* - config: (mixed) If an array, the javascript config hash used to
* indiciate the config for this editor instance. If a string,
* will be used directly as the javascript config name to use
* when loading (must exist elsewhere in page).
* - id: (string) The ID of the text area to turn into an editor. If
* empty, won't automatically load the editor.
*/
public function initialize(array $params = array())
{
if (!$this->supportedByBrowser()) {
return;
}
$ck_file = empty($params['basic']) ? 'ckeditor/ckeditor.js' : 'ckeditor/ckeditor_basic.js';
if (isset($params['config'])) {
if (is_array($params['config'])) {
/* Globally disable spell check as you type. */
$params['config']['scayt_autoStartup'] = false;
$params['config'] = Horde_Serialize::serialize($params['config'], Horde_Serialize::JSON);
}
} else {
$params['config'] = array();
}
$this->_js = array('files' => array($ck_file), 'script' => array());
if (isset($params['id'])) {
$this->_js['script'] = array('CKEDITOR.replace("' . $params['id'] . '",' . $params['config'] . ')');
}
}
示例12: 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;
}
示例13: _content
/**
*/
protected function _content()
{
global $page_output, $registry, $injector, $prefs;
Horde::initMap();
$page_output->addScriptFile('map.js');
$page_output->addScriptFile('blocks/geotag.js');
try {
$images = $injector->getInstance('Ansel_Storage')->getRecentImagesGeodata(null, 0, min($this->_params['limit'], 100));
} catch (Ansel_Exception $e) {
return $e->getMessage();
}
$images = array_reverse($images);
foreach ($images as $key => $image) {
$id = $image['image_id'];
$gallery = $injector->getInstance('Ansel_Storage')->getGallery($image['gallery_id']);
// Don't show locked galleries in the block.
if (!$gallery->isOldEnough() || $gallery->hasPasswd()) {
continue;
}
$style = $gallery->getStyle();
// Generate the image view url
$url = Ansel::getUrlFor('view', array('view' => 'Image', 'slug' => $gallery->get('slug'), 'gallery' => $gallery->id, 'image' => $id, 'gallery_view' => $style->gallery_view), true);
$images[$key]['icon'] = strval(Ansel::getImageUrl($images[$key]['image_id'], 'mini', true));
$images[$key]['link'] = strval($url);
$images[$key]['markerOnly'] = false;
}
// URL for updating selected layer
$layerUrl = $registry->getServiceLink('ajax', 'ansel')->setRaw(true);
$layerUrl->url .= 'setPrefValue';
// And the current defaultLayer, if any.
$defaultLayer = $prefs->getValue('current_maplayer');
$opts = array('layerUpdateEndpoint' => strval($layerUrl), 'layerUpdatePref' => 'current_maplayer', 'defaultBaseLayer' => $defaultLayer);
$json = Horde_Serialize::serialize(array_values($images), Horde_Serialize::JSON);
$js = array('var opts = ' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON), 'new AnselBlockGeoTag(' . $json . ', opts);');
$page_output->addInlineScript($js, true);
return '<div id="ansel_map" style="height:' . $this->_params['height'] . 'px;"></div>';
}
示例14: 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');
}
示例15: _init
//.........这里部分代码省略.........
} else {
$condition['field'] = $val;
$f_label = $ingo_fields[$val]['label'];
$condition['type'] = $ingo_fields[$val]['type'];
}
$condition['match'] = isset($this->vars->match[$key]) ? $this->vars->match[$key] : '';
if ($actionID == 'rule_save' && empty($this->vars->value[$key]) && !in_array($condition['match'], array('exists', 'not exist'))) {
$notification->push(sprintf(_("You cannot create empty conditions. Please fill in a value for \"%s\"."), is_null($f_label) ? $condition['field'] : $f_label), 'horde.error');
$actionID = null;
}
$condition['value'] = isset($this->vars->value[$key]) ? $this->vars->value[$key] : '';
if (isset($casesensitive)) {
$condition['case'] = isset($casesensitive[$key]) ? $casesensitive[$key] : '';
}
$tmp = $rule->conditions;
$tmp[] = $condition;
$rule->conditions = $tmp;
}
if ($this->vars->action) {
switch ($rule->type) {
case Ingo_Rule_User::TYPE_MAILBOX:
switch ($actionID) {
case 'rule_save':
try {
$rule->value = $this->validateMbox('actionvalue');
} catch (Ingo_Exception $e) {
$notification->push($e, 'horde.error');
$actionID = null;
}
break;
default:
$rule->value = $this->vars->actionvalue;
if (!$this->vars->actionvalue && isset($this->vars->actionvalue_new)) {
$page_output->addInlineScript(array('IngoNewFolder.setNewFolder("actionvalue", ' . Horde_Serialize::serialize($this->vars->actionvalue_new, Horde_Serialize::JSON) . ')'), true);
}
break;
}
break;
default:
$rule->value = $this->vars->actionvalue;
break;
}
}
$flags = empty($this->vars->flags) ? array() : $this->vars->flags;
$tmp = $rule->flags;
foreach ($flags as $val) {
$tmp |= $val;
}
$rule->flags = $tmp;
/* Run through action handlers. */
switch ($actionID) {
case 'rule_save':
if (empty($rule->conditions)) {
$notification->push(_("You need to select at least one field to match."), 'horde.error');
break;
}
$ingo_storage->updateRule($rule);
$notification->push(_("Changes saved."), 'horde.success');
try {
$ingo_script_factory->activateAll();
} catch (Ingo_Exception $e) {
$notification->push($e, 'horde.error');
}
Ingo_Basic_Filters::url()->redirect();
case 'rule_delete':
if (isset($this->vars->conditionnumber)) {