function execute(&$controller, &$request, &$user) { $member = $user->getAttribute('member', GLU_NS); // my feeds $source = DB_DataObject::factory('source'); $source->whereAdd('member_id = ' . $source->escape($member->id)); if ($request->hasParameter('id')) { $source->whereAdd('id = ' . $source->escape($request->getParameter('id'))); } $source->find(); $feeds = array(); while ($source->fetch()) { $rss = new FeedParser($source->uri); $rss->parse(); foreach ($rss->getItems() as $item) { $feed['id'] = $source->id; $feed['title'] = $item['title']; $feed['link'] = $item['link']; $feed['description'] = isset($item['description']) ? $item['description'] : ''; $feed['date'] = isset($item['dc:date']) ? $item['dc:date'] : (isset($item['date']) ? $item['date'] : ''); $feeds[] = $feed; } } $haj = new HTML_AJAX_JSON(); $output = $haj->encode($feeds); header('Content-Type: application/x-javascript; charset=utf-8'); echo $output; return VIEW_NONE; }
/** * this function unserializes the input passed to it. * * @access public * @param string $input The input to unserialize * @return string $input The unserialized input. */ function unserialize($input) { if ($this->_jsonext) { return json_decode($input, $this->loose_type); } else { return $this->_json->decode($input); } }
function execute(&$controller, &$request, &$user) { $messages = $request->getAttribute('messages'); $haj = new HTML_AJAX_JSON(); $m = $haj->encode($messages); header('Content-Type: text/javascript; charset=utf-8'); echo "function msg(n){var m={$m};return m[n]}"; return VIEW_NONE; }
function execute(&$controller, &$request, &$user) { $member = $user->getAttribute('member', GLU_NS); unset($member->photo); Utils::remove_private_property(&$member); $haj = new HTML_AJAX_JSON(); $m = $haj->encode($member); $output = "if (typeof 'Plnet' == 'undefined') Plnet = {}\n"; $output .= "Plnet.Member = {$m}"; header('Content-Type: text/javascript; charset=utf-8'); echo $output; return VIEW_NONE; }
function execute(&$controller, &$request, &$user) { $member_id = $request->getParameter('member_id'); // my feeds $source = DB_DataObject::factory('source'); $source->whereAdd('member_id = ' . $source->escape($member_id)); $source->find(); $feeds = array(); while ($source->fetch()) { $feeds[] = array('id' => $source->id, 'title' => $source->name, 'uri' => $source->uri); } $haj = new HTML_AJAX_JSON(); $output = $haj->encode($feeds); header('Content-Type: application/x-javascript; charset=utf-8'); echo $output; return VIEW_NONE; }
function execute(&$controller, &$request, &$user) { $member = $user->getAttribute('member', GLU_NS); // my contents $source = DB_DataObject::factory('source'); $source->whereAdd('member_id = ' . $source->escape($member->id)); $source->find(); $my_contents = array(); while ($source->fetch()) { if (mb_strlen($source->name) > GLUE_CONTENTNAME_LENGTH_MAX) { $source->name = mb_substr($source->name, 0, GLUE_CONTENTNAME_LENGTH_MAX) . '...'; } $c = array('id' => $source->id, 'name' => $source->name, 'uri' => $source->uri, 'link' => $source->link, 'icon' => $source->icon); $my_contents[] = $c; } $haj = new HTML_AJAX_JSON(); $output = $haj->encode($my_contents); header('Content-Type: application/x-javascript; charset=utf-8'); echo $output; return VIEW_NONE; }
function toJSON() { $haj = new HTML_AJAX_JSON(); return $haj->encode($this->toArray()); }
/** * Encode a given value with PEAR::HTML_AJAX. * * @param mixed $value * @return string JSON string representation of a given value * or false if error ocurrs. * @throws PIECE_UNITY_ERROR_INVOCATION_FAILED * @static */ function encodeWithHTMLAJAX($value) { include_once 'PEAR.php'; $encoder =& new HTML_AJAX_JSON(); PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); $json = $encoder->encode($value); PEAR::staticPopErrorHandling(); if (HTML_AJAX_JSON::isError($json)) { Piece_Unity_Error::pushPEARError($json, PIECE_UNITY_ERROR_INVOCATION_FAILED, "Failed to invoke the plugin [ {$this->_name} ]."); return; } return $json; }