Exemplo n.º 1
0
 public static function parse($name, $src, $docendpos = 0)
 {
     $info = new static();
     $info->name($name);
     if ($docendpos > 0) {
         $doc = trim(substr($src, 0, $docendpos));
         $startpos = strrpos($doc, '/**');
         if ($startpos !== false) {
             $doc = substr($doc, $startpos);
             if (preg_match('/\\/\\*\\*(.+?)\\*\\//s', $doc, $m)) {
                 $doc = preg_replace('/^[\\s]*\\*[\\s]{0,1}/m', '', $m[1]);
             } else {
                 $doc = '';
             }
         } else {
             $doc = '';
         }
     } else {
         $doc = $src;
     }
     $params = \ebi\Dt\DocParam::parse('param', $doc);
     if (!empty($params)) {
         $info->params($params);
     }
     if (preg_match("/@return\\s+([^\\s]+)(.*)/", $doc, $m)) {
         $info->return(new \ebi\Dt\DocParam('return', $m[1], $m[2]));
     }
     $info->document(trim(preg_replace('/@.+/', '', preg_replace("/^[\\s]*\\*[\\s]{0,1}/m", '', str_replace('*' . '/', '', $doc)))));
     return $info;
 }
Exemplo n.º 2
0
 public static function generate()
 {
     // create a dom xml object
     static::$document = new DOMDocument('1.0', 'UTF-8');
     // create our rss feed
     $rss = static::element('rss', null, array('version' => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom'));
     static::$document->appendChild($rss);
     // create channel
     $channel = static::element('channel');
     $rss->appendChild($channel);
     // title
     $title = static::element('title', Config::get('metadata.sitename'));
     $channel->appendChild($title);
     // link
     $url = 'http://' . $_SERVER['HTTP_HOST'];
     $link = static::element('link', $url);
     $channel->appendChild($link);
     // description
     $description = static::element('description', Config::get('metadata.description'));
     $channel->appendChild($description);
     // laguage
     // http://www.rssboard.org/rss-language-codes
     $language = static::element('language', Config::get('application.language', 'en'));
     $channel->appendChild($language);
     $ttl = static::element('ttl', 60);
     $channel->appendChild($ttl);
     $docs = static::element('docs', 'http://blogs.law.harvard.edu/tech/rss');
     $channel->appendChild($docs);
     $copyright = static::element('copyright', Config::get('metadata.sitename'));
     $channel->appendChild($copyright);
     // atom self link
     $atom = static::element('atom:link', null, array('href' => $url, 'rel' => 'self', 'type' => 'application/rss+xml'));
     $channel->appendChild($atom);
     // articles
     $params = array('status' => 'published', 'sortby' => 'id', 'sortmode' => 'desc');
     foreach (Posts::list_all($params) as $post) {
         $item = static::element('item');
         $channel->appendChild($item);
         // title
         $title = static::element('title', $post->title);
         $item->appendChild($title);
         // link
         $url = 'http://' . $_SERVER['HTTP_HOST'] . Url::make(IoC::resolve('posts_page')->slug . '/' . $post->slug);
         $link = static::element('link', $url);
         $item->appendChild($link);
         // description
         $description = static::element('description', $post->description);
         $item->appendChild($description);
         // date
         $date = static::element('pubDate', date(DATE_RSS, $post->created));
         $item->appendChild($date);
     }
     // dump xml tree
     return static::$document->saveXML();
 }
Exemplo n.º 3
0
 public static function _init($document)
 {
     if (!$document) {
         throw new NoDatabaseTableNameException();
     }
     $con = Config::getVal('database', 'host') . ":" . Config::getVal('database', 'port');
     static::$mongo = new Mongo($con);
     if (Config::getVal('database', 'user') != "" && Config::getVal('database', 'password') != "") {
         $ret = static::$mongo->authenticate(Config::getVal('database', 'user'), Config::getVal('database', 'password'));
         if ($ret['ok'] === 0) {
             throw new CantEtablishDatabaseConnectionException($ret['errmsg']);
         }
     }
     static::$document = static::$mongo->{$document};
 }
Exemplo n.º 4
0
 public static function generate()
 {
     // create a dom xml object
     static::$document = new DOMDocument('1.0', 'UTF-8');
     // create our rss feed
     $rss = static::element('rss', null, array('version' => '2.0'));
     static::$document->appendChild($rss);
     // create channel
     $channel = static::element('channel');
     $rss->appendChild($channel);
     // title
     $title = static::element('title', Config::get('metadata.sitename'));
     $channel->appendChild($title);
     // link
     $link = static::element('link', 'http://' . $_SERVER['HTTP_HOST']);
     $channel->appendChild($link);
     // description
     $description = static::element('description', Config::get('metadata.description'));
     $channel->appendChild($description);
     // articles
     $params = array('status' => 'published', 'sortby' => 'id', 'sortmode' => 'desc');
     foreach (Posts::list_all($params) as $post) {
         $item = static::element('item');
         $channel->appendChild($item);
         // title
         $title = static::element('title', $post->title);
         $item->appendChild($title);
         // link
         $url = 'http://' . $_SERVER['HTTP_HOST'] . Url::make(IoC::resolve('posts_page')->slug . '/' . $post->slug);
         $link = static::element('link', $url);
         $item->appendChild($link);
         // description
         $description = static::element('description', $post->description);
         $item->appendChild($description);
         // date
         $date = static::element('pubDate', date(DATE_RSS, $post->created));
         $item->appendChild($date);
     }
     // dump xml tree
     return static::$document->saveXML();
 }
Exemplo n.º 5
0
 /** Initializes a DOM element for the tests. */
 public static function setUpBeforeClass()
 {
     static::$document = new \DOMDocument("1.0", "UTF-8");
     static::$_ = static::$document->createElement('e');
 }