- Timestamp:
- 10/01/08 07:39:26 (2 months ago)
- Location:
- events/phpframework/plain_php/trunk/core
- Files:
-
- 1 added
- 4 modified
-
Action.php (modified) (2 diffs)
-
JsonResponse.php (added)
-
ObjectBuilder.php (modified) (3 diffs)
-
RssRenderer.php (modified) (1 diff)
-
RssResponse.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
events/phpframework/plain_php/trunk/core/Action.php
r20040 r20336 13 13 $this->context = $c; 14 14 $this->baseUrl = $c->baseUrl; 15 if (in_array($req->REQUEST_METHOD, array('POST', 'GET'))) 16 return $this->{$req->REQUEST_METHOD}(); 15 if (in_array($req->REQUEST_METHOD, array('POST', 'GET'))) { 16 $_ = $this->{'before' . $req->REQUEST_METHOD}() 17 or $_ = $this->{$req->REQUEST_METHOD}(); 18 $this->{'after' . $req->REQUEST_METHOD}(); 19 return $_; 20 } 17 21 throw new Exception; 18 22 } 23 function beforePOST() { } 24 function beforeGET() { } 25 26 function afterGET() { } 27 function afterPOST() { } 28 19 29 function POST() 20 30 { … … 45 55 protected function hasExternalReferer() 46 56 { 47 return 48 strpos($this->req->HTTP_REFERER, $this->baseUrl . '/') !== 0 || 49 $this->req->HTTP_REFERER === $this->baseUrl; 57 if ($this->req->HTTP_REFERER === $this->baseUrl) return false; 58 return strpos($this->req->HTTP_REFERER, $this->baseUrl . '/') !== 0; 50 59 } 51 60 -
events/phpframework/plain_php/trunk/core/ObjectBuilder.php
r20040 r20336 40 40 function buildTimelineService() 41 41 { 42 return new TimelineService($this->pool->fetchPDO(), $this->pool->fetchApplicationContext());42 return new TimelineService($this->pool->fetchPDO(), self::$context->baseUrl); 43 43 } 44 44 … … 53 53 $o->page_limit = 15; 54 54 $o->cookie_timeout = 60 * 60 * 7; 55 $o->encoding = 'UTF-8'; 56 $o->mail_from = 'Phwittr'; 57 55 58 return $o; 56 59 } … … 58 61 function buildStatusService() 59 62 { 60 return new StatusService($this->pool->fetchPDO() );63 return new StatusService($this->pool->fetchPDO(), self::$context->baseUrl); 61 64 } 62 65 -
events/phpframework/plain_php/trunk/core/RssRenderer.php
r20040 r20336 1 1 <?php 2 2 3 class RssRenderer 4 { 5 function render(RssResponse $r) 6 { 7 header('Content-type: text/xml; charset=UTF-8'); 8 9 list($title, $link, $desc) = $r->getChannel(); 10 echo '<?xml version="1.0" encoding="UTF-8" ?> 11 <rss version="2.0"> 12 <channel> 13 <title>' . h($title) . '</title> 14 <link>' . h($link) . '</link> 15 <description>' . h($desc) . '</description> 16 '; 17 foreach ($r->getItems() as $item) { 18 list($title, $desc, $link, $author) = $item; 19 echo '<item> 20 <title>' . h($title) . '</title> 21 <description>' . $this->toCdata($desc) . '</description> 22 <link>' . h($link) . '</link> 23 <author>' . h($author) . '</author> 24 </item> 25 '; 26 } 27 28 echo '</channel> 29 </rss> 30 '; 31 } 32 protected function toCdata($v) 33 { 34 $v = str_replace(']]>', ']]>]]<![CDATA[>', $v); 35 return '<![CDATA[' . $v . ']]>'; 36 } 37 } -
events/phpframework/plain_php/trunk/core/RssResponse.php
r20040 r20336 1 1 <?php 2 2 3 class RssResponse implements IResponse 4 { 5 protected $channel, $items = array(); 6 function buildRenderer(RendererBuilder $b) 7 { 8 return $b->buildRssRenderer(); 9 } 10 function setChannel($title, $url, $desc) 11 { 12 $this->channel = func_get_args(); 13 } 14 function setDescription($d) 15 { 16 $this->desc = $d; 17 } 18 function addItem($title, $desc, $link, $author) 19 { 20 $this->items[] = func_get_args(); 21 } 22 function getChannel() 23 { 24 return $this->channel; 25 } 26 function getItems() 27 { 28 return $this->items; 29 } 30 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)