/** * This function serializes and input passed to it. * * @access public * @param string $input The input to serialize. * @return string $input The serialized input. */ function serialize($input) { if ($this->_jsonext) { return json_encode($input); } else { return $this->_json->encode($input); } }
/** * This function serializes and input passed to it. * * @access public * @param string $input The input to serialize. * @return string $input The serialized input. */ function serialize($input) { if ($this->_jsonext) { /*@see Luis Balam*/ //if(json_encode($input) == false){ // $input = iconv(mb_detect_encoding($input), 'UTF-8//IGNORE', $input); //} //syslog(E_NOTICE, $input); $myvar = json_encode($input); return $myvar; } else { return $this->_json->encode($input); } }
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; }
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()); }