示例#1
0
 /**
  * Constructor
  *
  * Just wraps the XMLOutputter constructor.
  *
  * @param string  $output URI to output to, default = stdout
  * @param boolean $indent Whether to indent output, default true
  */
 function __construct($output = 'php://output', $indent = null)
 {
     parent::__construct($output, $indent);
 }
示例#2
0
文件: util.php 项目: himmelex/NTW
function common_redirect($url, $code = 307)
{
    static $status = array(301 => "Moved Permanently", 302 => "Found", 303 => "See Other", 307 => "Temporary Redirect");
    header('HTTP/1.1 ' . $code . ' ' . $status[$code]);
    header("Location: {$url}");
    $xo = new XMLOutputter();
    $xo->startXML('a', '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd');
    $xo->element('a', array('href' => $url), $url);
    $xo->endXML();
    exit;
}
示例#3
0
 /**
  * Called when generating Atom XML ActivityStreams output from an
  * ActivityObject belonging to this plugin. Gives the plugin
  * a chance to add custom output.
  *
  * Note that you can only add output of additional XML elements,
  * not change existing stuff here.
  *
  * If output is already handled by the base Activity classes,
  * you can leave this base implementation as a no-op.
  *
  * @param ActivityObject $obj
  * @param XMLOutputter $out to add elements at end of object
  */
 function activityObjectOutputAtom(ActivityObject $obj, XMLOutputter $out)
 {
     if (isset($obj->pollQuestion)) {
         /**
          * <poll:poll xmlns:poll="http://apinamespace.org/activitystreams/object/poll">
          *   <poll:question>Who wants a poll question?</poll:question>
          *   <poll:option>Option one</poll:option>
          *   <poll:option>Option two</poll:option>
          *   <poll:option>Option three</poll:option>
          * </poll:poll>
          */
         $data = array('xmlns:poll' => self::POLL_OBJECT);
         $out->elementStart('poll:poll', $data);
         $out->element('poll:question', array(), $obj->pollQuestion);
         foreach ($obj->pollOptions as $opt) {
             $out->element('poll:option', array(), $opt);
         }
         $out->elementEnd('poll:poll');
     }
     if (isset($obj->pollSelection)) {
         /**
          * <poll:response xmlns:poll="http://apinamespace.org/activitystreams/object/poll">
          *                poll="http://..../poll/...."
          *                selection="3" />
          */
         $data = array('xmlns:poll' => self::POLL_OBJECT, 'poll' => $obj->pollUri, 'selection' => $obj->pollSelection);
         $out->element('poll:response', $data, '');
     }
 }