本文整理汇总了PHP中Horde_Serialize::serialize方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Serialize::serialize方法的具体用法?PHP Horde_Serialize::serialize怎么用?PHP Horde_Serialize::serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Serialize
的用法示例。
在下文中一共展示了Horde_Serialize::serialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _serializeAttribute
/**
* Returns a serialized value, if necessary.
*
* @param mixed The original value.
*
* @return string The JSON encoded value if not already a string.
*/
protected function _serializeAttribute($value)
{
if (!is_string($value)) {
return Horde_Serialize::serialize($value, Horde_Serialize::JSON);
}
return $value;
}
示例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: 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>';
}
示例4: 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) . ');});'));
}
示例5: _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;
}
示例6: 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)) . '})';
}
示例7: 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));
}
示例8: 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);
}
}
示例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: attach
/**
* Attach the object to a javascript event.
*/
public function attach()
{
global $page_output;
$result = $this->_attach(!$this->_init);
if (!$this->_init) {
$page_output->ajax = true;
$page_output->addScriptFile('imple.js', 'horde');
$this->_init = true;
}
if ($result === false) {
return;
}
$args = array('id' => $this->getDomId(), 'observe' => $this->_observe);
$args['params'] = is_array($result) ? array_merge($result, $this->_impleParams()) : $result;
$page_output->addInlineScript(array('HordeImple.add(' . Horde_Serialize::serialize($args, Horde_Serialize::JSON) . ')'), true);
}
示例11: 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) . ');'));
}
示例12: 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'] . ')');
}
}
示例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: editActions
//.........这里部分代码省略.........
if ($form->validate($vars)) {
$form->getInfo($vars, $info);
// Replacing photo
if (!empty($info['file0']['file'])) {
try {
$GLOBALS['browser']->wasFileUploaded('file0');
if (filesize($info['file0']['file'])) {
$data = file_get_contents($info['file0']['file']);
if (getimagesize($info['file0']['file']) === false) {
$notification->push(_("The file you uploaded does not appear to be a valid photo."), 'horde.error');
unset($data);
}
}
} catch (Horde_Browser_Exception $e) {
}
}
$image = $ansel_storage->getImage($image_id);
$image->caption = $vars->get('image_desc');
$image->setTags(explode(',', $vars->get('image_tags')));
$newDate = new Horde_Date($vars->get('image_originalDate'));
$image->originalDate = (int) $newDate->timestamp();
if (!empty($data)) {
try {
$image->replace($data);
} catch (Ansel_Exception $e) {
$notification->push(_("There was an error replacing the photo."), 'horde.error');
}
}
$image->save();
if ($vars->get('image_default')) {
if ($gallery->get('default') != $image_id) {
// Changing default - force refresh of stack
// If we have a default-pretty already, make sure we delete it
$ids = unserialize($gallery->get('default_prettythumb'));
if (is_array($ids)) {
foreach ($ids as $imageId) {
$gallery->removeImage($imageId, true);
}
}
$gallery->set('default_prettythumb', '');
}
$gallery->set('default', $image_id);
$gallery->set('default_type', 'manual');
} elseif ($gallery->get('default') == $image_id) {
// Currently set as default, but we no longer wish it.
$gallery->set('default', 0);
$gallery->set('default_type', 'auto');
// If we have a default-pretty already, make sure we delete it
$ids = unserialize($gallery->get('default_prettythumb'));
if (is_array($ids)) {
foreach ($ids as $imageId) {
$gallery->removeImage($imageId);
}
}
$gallery->set('default_prettythumb', '');
}
$gallery->save();
$imageurl = Ansel::getUrlFor('view', array_merge(array('gallery' => $gallery_id, 'image' => $image_id, 'view' => 'Image', 'page' => $page), $date), true);
if ($actionID == 'save') {
$imageurl->redirect();
} elseif ($actionID == 'saveclose') {
$page_output->addInlineScript(array('window.opener.location.href = window.opener.location.href;', 'window.close();'));
$page_output->outputInlineScript();
} else {
$page_output->addInlineScript(array('window.opener.location.href = "' . $imageurl . '";', 'window.close();'));
$page_output->outputInlineScript();
示例15: embed
/**
* Handle output of the embedded widget: allows embedding calendar widgets
* in external websites.
*
* The following arguments are required:
* - calendar: The share_name for the requested calendar.
* - container: The DOM node to populate with the widget.
* - view: The view (block) we want.
*
* The following are optional (and are not used for all views)
* - css
* - days
* - maxevents: The maximum number of events to show.
* - months: The number of months to include.
*/
public function embed()
{
global $page_output, $registry;
/* First, determine the type of view we are asking for */
$view = $this->vars->view;
/* The DOM container to put the HTML in on the remote site */
$container = $this->vars->container;
/* The share_name of the calendar to display */
$calendar = $this->vars->calendar;
/* Deault to showing only 1 month when we have a choice */
$count_month = $this->vars->get('months', 1);
/* Default to no limit for the number of events */
$max_events = $this->vars->get('maxevents', 0);
/* Default to one week */
$count_days = $this->vars->get('days', 7);
if ($this->vars->css == 'none') {
$nocss = true;
}
/* Build the block parameters */
$params = array('calendar' => $calendar, 'maxevents' => $max_events, 'months' => $count_month, 'days' => $count_days);
/* Call the Horde_Block api to get the calendar HTML */
$title = $registry->call('horde/blockTitle', array('kronolith', $view, $params));
$results = $registry->call('horde/blockContent', array('kronolith', $view, $params));
/* Some needed paths */
$js_path = $registry->get('jsuri', 'kronolith');
/* Local js */
$jsurl = Horde::url($js_path . '/embed.js', true);
/* Horde's js */
$hjs_path = $registry->get('jsuri', 'horde');
$hjsurl = Horde::url($hjs_path . '/tooltips.js', true);
$pturl = Horde::url($hjs_path . '/prototype.js', true);
/* CSS */
if (empty($nocss)) {
$page_output->addThemeStylesheet('embed.css');
Horde::startBuffer();
$page_output->includeStylesheetFiles(array('nobase' => true), true);
$css = Horde::endBuffer();
} else {
$css = '';
}
/* Escape the text and put together the javascript to send back */
$container = Horde_Serialize::serialize($container, Horde_Serialize::JSON);
$results = Horde_Serialize::serialize('<div class="kronolith_embedded"><div class="title">' . $title . '</div>' . $results . '</div>', Horde_Serialize::JSON);
$js = <<<EOT
if (typeof kronolith == 'undefined') {
if (typeof Prototype == 'undefined') {
document.write('<script type="text/javascript" src="{$pturl}"></script>');
}
if (typeof Horde_ToolTips == 'undefined') {
Horde_ToolTips_Autoload = false;
document.write('<script type="text/javascript" src="{$hjsurl}"></script>');
}
kronolith = new Object();
kronolithNodes = new Array();
document.write('<script type="text/javascript" src="{$jsurl}"></script>');
document.write('{$css}');
}
kronolithNodes[kronolithNodes.length] = {$container};
kronolith[{$container}] = {$results};
EOT;
return new Horde_Core_Ajax_Response_Raw($js, 'text/javascript');
}