[limb-svn] r7111 - in 3.x/trunk/limb: cms/src/controller net/src net/tests/cases tests_runner/bin web_app/src/controller

svn at limb-project.com svn at limb-project.com
Thu Jul 10 13:34:18 MSD 2008


Author: korchasa
Date: 2008-07-10 13:34:17 +0400 (Thu, 10 Jul 2008)
New Revision: 7111
URL: http://fisheye.limb-project.com/changelog/limb/?cs=7111

Modified:
   3.x/trunk/limb/cms/src/controller/AdminTreeController.class.php
   3.x/trunk/limb/net/src/lmbHttpCache.class.php
   3.x/trunk/limb/net/src/lmbHttpRedirectStrategy.class.php
   3.x/trunk/limb/net/src/lmbHttpResponse.class.php
   3.x/trunk/limb/net/tests/cases/lmbHttpCacheTest.class.php
   3.x/trunk/limb/net/tests/cases/lmbHttpResponseTest.class.php
   3.x/trunk/limb/tests_runner/bin/limb_unit.php
   3.x/trunk/limb/web_app/src/controller/NotFoundController.class.php
   3.x/trunk/limb/web_app/src/controller/ServerErrorController.class.php
Log:
-- lmbHttpResponce::header(), lmbHttpResponce::headersSent(), lmbHttpResponce::fileSent() mark as deprecated and replaced by lmbHttpResponce::addHeader(),  lmbHttpResponce::isHeadersSent(), lmbHttpResponce::isFileSent()

Modified: 3.x/trunk/limb/cms/src/controller/AdminTreeController.class.php
===================================================================
--- 3.x/trunk/limb/cms/src/controller/AdminTreeController.class.php	2008-07-10 09:29:34 UTC (rev 7110)
+++ 3.x/trunk/limb/cms/src/controller/AdminTreeController.class.php	2008-07-10 09:34:17 UTC (rev 7111)
@@ -94,8 +94,8 @@
       $parent_id = $this->request->get('parent_id');
       foreach($this->request->getArray('ids') as $id)
       {
-        $tree = lmbToolkit :: instance()->getCmsTree();  
-        $tree->moveNode($id, $parent_id); 
+        $tree = lmbToolkit :: instance()->getCmsTree();
+        $tree->moveNode($id, $parent_id);
       }
       $this->closePopup();
     }
@@ -126,12 +126,12 @@
 
   protected function _setXmlHeaders()
   {
-    $this->response->header('Expires: Mon, 26 Jul 1997 05:00:00 GMT') ;
-    $this->response->header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT') ;
-    $this->response->header('Cache-Control: no-store, no-cache, must-revalidate') ;
-    $this->response->header('Cache-Control: post-check=0, pre-check=0', false) ;
-    $this->response->header('Pragma: no-cache') ;
-    $this->response->header( 'Content-Type:text/xml; charset=utf-8' ) ;
+    $this->response->addHeader('Expires: Mon, 26 Jul 1997 05:00:00 GMT') ;
+    $this->response->addHeader('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT') ;
+    $this->response->addHeader('Cache-Control: no-store, no-cache, must-revalidate') ;
+    $this->response->addHeader('Cache-Control: post-check=0, pre-check=0', false) ;
+    $this->response->addHeader('Pragma: no-cache') ;
+    $this->response->addHeader( 'Content-Type:text/xml; charset=utf-8' ) ;
   }
 }
 

Modified: 3.x/trunk/limb/net/src/lmbHttpCache.class.php
===================================================================
--- 3.x/trunk/limb/net/src/lmbHttpCache.class.php	2008-07-10 09:29:34 UTC (rev 7110)
+++ 3.x/trunk/limb/net/src/lmbHttpCache.class.php	2008-07-10 09:34:17 UTC (rev 7111)
@@ -2,9 +2,9 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 //inspired by http://alexandre.alapetite.net/doc-alex/php-http-304/
 
@@ -91,30 +91,30 @@
 
   protected function _write412Response($response)
   {
-    $response->header('HTTP/1.1 412 Precondition Failed');
-    $response->header('Cache-Control: protected, max-age=0, must-revalidate');
-    $response->header('Content-Type: text/plain');
+    $response->addHeader('HTTP/1.1 412 Precondition Failed');
+    $response->addHeader('Cache-Control: protected, max-age=0, must-revalidate');
+    $response->addHeader('Content-Type: text/plain');
 
     $response->write("HTTP/1.1 Error 412 Precondition Failed: Precondition request failed positive evaluation\n");
   }
 
   protected function _write304Response($response)
   {
-    $response->header('HTTP/1.0 304 Not Modified');
-    $response->header('Etag: ' . $this->getEtag());
-    $response->header('Pragma: ');
-    $response->header('Cache-Control: ');
-    $response->header('Last-Modified: ');
-    $response->header('Expires: ');
+    $response->addHeader('HTTP/1.0 304 Not Modified');
+    $response->addHeader('Etag: ' . $this->getEtag());
+    $response->addHeader('Pragma: ');
+    $response->addHeader('Cache-Control: ');
+    $response->addHeader('Last-Modified: ');
+    $response->addHeader('Expires: ');
   }
 
   protected function _writeCachingResponse($response)
   {
-    $response->header('Cache-Control: ' . $this->_getCacheControl()); //rfc2616-sec14.html#sec14.9
-    $response->header('Last-Modified: ' . $this->formatLastModifiedTime());
-    $response->header('Etag: ' . $this->getEtag());
-    $response->header('Pragma: ');
-    $response->header('Expires: ');
+    $response->addHeader('Cache-Control: ' . $this->_getCacheControl()); //rfc2616-sec14.html#sec14.9
+    $response->addHeader('Last-Modified: ' . $this->formatLastModifiedTime());
+    $response->addHeader('Etag: ' . $this->getEtag());
+    $response->addHeader('Pragma: ');
+    $response->addHeader('Expires: ');
   }
 
   protected function _getCacheControl()

Modified: 3.x/trunk/limb/net/src/lmbHttpRedirectStrategy.class.php
===================================================================
--- 3.x/trunk/limb/net/src/lmbHttpRedirectStrategy.class.php	2008-07-10 09:29:34 UTC (rev 7110)
+++ 3.x/trunk/limb/net/src/lmbHttpRedirectStrategy.class.php	2008-07-10 09:34:17 UTC (rev 7111)
@@ -2,9 +2,9 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 
 /**
@@ -17,7 +17,7 @@
 {
   function redirect($response, $path)
   {
-    $response->header("Location: {$path}");
+    $response->addHeader("Location: {$path}");
   }
 }
 

Modified: 3.x/trunk/limb/net/src/lmbHttpResponse.class.php
===================================================================
--- 3.x/trunk/limb/net/src/lmbHttpResponse.class.php	2008-07-10 09:29:34 UTC (rev 7110)
+++ 3.x/trunk/limb/net/src/lmbHttpResponse.class.php	2008-07-10 09:34:17 UTC (rev 7111)
@@ -156,28 +156,64 @@
       ($status != 304 &&  $status != 412));//???
   }
 
-  function headersSent()
+  function isHeadersSent()
   {
     return sizeof($this->headers) > 0;
   }
 
-  function fileSent()
+  /**
+   *@deprecated
+   *@see self::isHeadersSent()
+   *@return bool
+   */
+  function headersSent()
   {
+    return $this->isHeadersSent();
+  }
+
+  function isFileSent()
+  {
     return !empty($this->response_file_path);
   }
 
+  /**
+   *@deprecated
+   *@see self::isFileSent()
+   *@return bool
+   */
+  function fileSent()
+  {
+    return $this->isFileSent();
+  }
+
   function reload()
   {
     $this->redirect($_SERVER['PHP_SELF']);
   }
 
-  function header($header)
+
+  /**
+   * Add header
+   * @param string $header
+   */
+  function addHeader($header)
   {
     $this->_ensureTransactionStarted();
 
     $this->headers[] = $header;
   }
 
+  /**
+   * Add header
+   * @deprecated
+   * @see self::addHeader
+   * @param string $header
+   */
+  function header($header)
+  {
+    $this->addHeader($header);
+  }
+
   function setCookie($name, $value, $expire = 0, $path = '/', $domain = '', $secure = false)
   {
     $this->_ensureTransactionStarted();

Modified: 3.x/trunk/limb/net/tests/cases/lmbHttpCacheTest.class.php
===================================================================
--- 3.x/trunk/limb/net/tests/cases/lmbHttpCacheTest.class.php	2008-07-10 09:29:34 UTC (rev 7110)
+++ 3.x/trunk/limb/net/tests/cases/lmbHttpCacheTest.class.php	2008-07-10 09:34:17 UTC (rev 7111)
@@ -2,9 +2,9 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 lmb_require('limb/net/src/lmbHttpResponse.class.php');
 lmb_require('limb/net/src/lmbHttpCache.class.php');
@@ -174,10 +174,10 @@
 
     $this->cache->setEtag('etag');
 
-    $this->response->expectCallCount('header', 3);
-    $this->response->expectArgumentsAt(0, 'header', array('HTTP/1.1 412 Precondition Failed'));
-    $this->response->expectArgumentsAt(1, 'header', array('Cache-Control: protected, max-age=0, must-revalidate'));
-    $this->response->expectArgumentsAt(2, 'header', array('Content-Type: text/plain'));
+    $this->response->expectCallCount('addHeader', 3);
+    $this->response->expectArgumentsAt(0, 'addHeader', array('HTTP/1.1 412 Precondition Failed'));
+    $this->response->expectArgumentsAt(1, 'addHeader', array('Cache-Control: protected, max-age=0, must-revalidate'));
+    $this->response->expectArgumentsAt(2, 'addHeader', array('Content-Type: text/plain'));
 
     $this->response->expectOnce('write', array(new WantedPatternExpectation("~^HTTP/1.1 Error 412~")));
 
@@ -190,13 +190,13 @@
 
     $this->cache->setEtag('etag');
 
-    $this->response->expectCallCount('header', 6);
-    $this->response->expectArgumentsAt(0, 'header', array('HTTP/1.0 304 Not Modified'));
-    $this->response->expectArgumentsAt(1, 'header', array('Etag: etag'));
-    $this->response->expectArgumentsAt(2, 'header', array('Pragma: '));
-    $this->response->expectArgumentsAt(3, 'header', array('Cache-Control: '));
-    $this->response->expectArgumentsAt(4, 'header', array('Last-Modified: '));
-    $this->response->expectArgumentsAt(5, 'header', array('Expires: '));
+    $this->response->expectCallCount('addHeader', 6);
+    $this->response->expectArgumentsAt(0, 'addHeader', array('HTTP/1.0 304 Not Modified'));
+    $this->response->expectArgumentsAt(1, 'addHeader', array('Etag: etag'));
+    $this->response->expectArgumentsAt(2, 'addHeader', array('Pragma: '));
+    $this->response->expectArgumentsAt(3, 'addHeader', array('Cache-Control: '));
+    $this->response->expectArgumentsAt(4, 'addHeader', array('Last-Modified: '));
+    $this->response->expectArgumentsAt(5, 'addHeader', array('Expires: '));
 
     $this->assertTrue($this->cache->checkAndWrite($this->response));
   }
@@ -213,12 +213,12 @@
 
     $this->cache->setLastModifiedTime($time = time());
 
-    $this->response->expectCallCount('header', 5);
-    $this->response->expectArgumentsAt(0, 'header', array('Cache-Control: protected, must-revalidate, max-age=0'));
-    $this->response->expectArgumentsAt(1, 'header', array('Last-Modified: ' . $this->cache->formatLastModifiedTime()));
-    $this->response->expectArgumentsAt(2, 'header', array('Etag: ' . $this->cache->getEtag()));
-    $this->response->expectArgumentsAt(3, 'header', array('Pragma: '));
-    $this->response->expectArgumentsAt(4, 'header', array('Expires: '));
+    $this->response->expectCallCount('addHeader', 5);
+    $this->response->expectArgumentsAt(0, 'addHeader', array('Cache-Control: protected, must-revalidate, max-age=0'));
+    $this->response->expectArgumentsAt(1, 'addHeader', array('Last-Modified: ' . $this->cache->formatLastModifiedTime()));
+    $this->response->expectArgumentsAt(2, 'addHeader', array('Etag: ' . $this->cache->getEtag()));
+    $this->response->expectArgumentsAt(3, 'addHeader', array('Pragma: '));
+    $this->response->expectArgumentsAt(4, 'addHeader', array('Expires: '));
 
     $this->assertTrue($this->cache->checkAndWrite($this->response));
   }
@@ -230,12 +230,12 @@
     $this->cache->setLastModifiedTime($time = time());
     $this->cache->setCacheTime(100);
 
-    $this->response->expectCallCount('header', 5);
-    $this->response->expectArgumentsAt(0, 'header', array('Cache-Control: protected, max-age=100'));
-    $this->response->expectArgumentsAt(1, 'header', array('Last-Modified: ' . $this->cache->formatLastModifiedTime()));
-    $this->response->expectArgumentsAt(2, 'header', array('Etag: ' . $this->cache->getEtag()));
-    $this->response->expectArgumentsAt(3, 'header', array('Pragma: '));
-    $this->response->expectArgumentsAt(4, 'header', array('Expires: '));
+    $this->response->expectCallCount('addHeader', 5);
+    $this->response->expectArgumentsAt(0, 'addHeader', array('Cache-Control: protected, max-age=100'));
+    $this->response->expectArgumentsAt(1, 'addHeader', array('Last-Modified: ' . $this->cache->formatLastModifiedTime()));
+    $this->response->expectArgumentsAt(2, 'addHeader', array('Etag: ' . $this->cache->getEtag()));
+    $this->response->expectArgumentsAt(3, 'addHeader', array('Pragma: '));
+    $this->response->expectArgumentsAt(4, 'addHeader', array('Expires: '));
 
     $this->assertTrue($this->cache->checkAndWrite($this->response));
   }
@@ -248,12 +248,12 @@
     $this->cache->setCacheTime(100);
     $this->cache->setCacheType(LIMB_HTTP_CACHE_TYPE_PUBLIC);
 
-    $this->response->expectCallCount('header', 5);
-    $this->response->expectArgumentsAt(0, 'header', array('Cache-Control: public, max-age=100'));
-    $this->response->expectArgumentsAt(1, 'header', array('Last-Modified: ' . $this->cache->formatLastModifiedTime()));
-    $this->response->expectArgumentsAt(2, 'header', array('Etag: ' . $this->cache->getEtag()));
-    $this->response->expectArgumentsAt(3, 'header', array('Pragma: '));
-    $this->response->expectArgumentsAt(4, 'header', array('Expires: '));
+    $this->response->expectCallCount('addHeader', 5);
+    $this->response->expectArgumentsAt(0, 'addHeader', array('Cache-Control: public, max-age=100'));
+    $this->response->expectArgumentsAt(1, 'addHeader', array('Last-Modified: ' . $this->cache->formatLastModifiedTime()));
+    $this->response->expectArgumentsAt(2, 'addHeader', array('Etag: ' . $this->cache->getEtag()));
+    $this->response->expectArgumentsAt(3, 'addHeader', array('Pragma: '));
+    $this->response->expectArgumentsAt(4, 'addHeader', array('Expires: '));
 
     $this->assertTrue($this->cache->checkAndWrite($this->response));
   }

Modified: 3.x/trunk/limb/net/tests/cases/lmbHttpResponseTest.class.php
===================================================================
--- 3.x/trunk/limb/net/tests/cases/lmbHttpResponseTest.class.php	2008-07-10 09:29:34 UTC (rev 7110)
+++ 3.x/trunk/limb/net/tests/cases/lmbHttpResponseTest.class.php	2008-07-10 09:34:17 UTC (rev 7111)
@@ -2,9 +2,9 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 lmb_require('limb/net/src/lmbHttpRedirectStrategy.class.php');
 
@@ -35,7 +35,7 @@
 
   function testIsEmptyHeadersSent()
   {
-    $this->response->header('test');
+    $this->response->addHeader('test');
     $this->assertTrue($this->response->isEmpty());
   }
 
@@ -59,36 +59,36 @@
 
   function testNotEmpty304Status()
   {
-    $this->response->header('HTTP/1.0 304 Not Modified');
+    $this->response->addHeader('HTTP/1.0 304 Not Modified');
     $this->assertFalse($this->response->isEmpty());
   }
 
   function testNotEmpty412Status()
   {
-    $this->response->header('HTTP/1.1 412 Precondition Failed');
+    $this->response->addHeader('HTTP/1.1 412 Precondition Failed');
     $this->assertFalse($this->response->isEmpty());
   }
 
   function testHeadersNotSent()
   {
-    $this->assertFalse($this->response->headersSent());
+    $this->assertFalse($this->response->isHeadersSent());
   }
 
   function testFileNotSent()
   {
-    $this->assertFalse($this->response->fileSent());
+    $this->assertFalse($this->response->isFileSent());
   }
 
   function testFileSent()
   {
     $this->response->readfile('somefile');
-    $this->assertTrue($this->response->fileSent());
+    $this->assertTrue($this->response->isFileSent());
   }
 
   function testHeadersSent()
   {
-    $this->response->header("Location:to-some-place");
-    $this->assertTrue($this->response->headersSent());
+    $this->response->addHeader("Location:to-some-place");
+    $this->assertTrue($this->response->isHeadersSent());
   }
 
   function testRedirect()
@@ -119,8 +119,8 @@
 
   function testSendHeadersOnCommit()
   {
-    $this->response->header("Location:to-some-place");
-    $this->response->header("Location:to-some-place2");
+    $this->response->addHeader("Location:to-some-place");
+    $this->response->addHeader("Location:to-some-place2");
 
     $this->response->expectCallCount('_sendHeader', 2);
     $this->response->expectArgumentsAt(0, '_sendHeader', array("Location:to-some-place"));
@@ -173,10 +173,10 @@
 
   function testGetResponseStatusHttp()
   {
-    $this->response->header('HTTP/1.0  304 ');
+    $this->response->addHeader('HTTP/1.0  304 ');
     $this->assertEqual($this->response->getStatus(), 304);
 
-    $this->response->header('HTTP/1.1  412');
+    $this->response->addHeader('HTTP/1.1  412');
     $this->assertEqual($this->response->getStatus(), 412);
   }
 
@@ -187,10 +187,10 @@
 
   function testGetDirective()
   {
-    $this->response->header('Cache-Control: protected, max-age=0, must-revalidate');
+    $this->response->addHeader('Cache-Control: protected, max-age=0, must-revalidate');
     $this->assertEqual($this->response->getDirective('cache-control'), 'protected, max-age=0, must-revalidate');
 
-    $this->response->header('Cache-Control :    protected, max-age=10  ');
+    $this->response->addHeader('Cache-Control :    protected, max-age=10  ');
     $this->assertEqual($this->response->getDirective('cache-control'), 'protected, max-age=10');
   }
 
@@ -201,16 +201,16 @@
 
   function testGetContentType()
   {
-    $this->response->header('Content-Type: image/png');
+    $this->response->addHeader('Content-Type: image/png');
     $this->assertEqual($this->response->getContentType(), 'image/png');
 
-    $this->response->header('Content-Type: application/rss+xml');
+    $this->response->addHeader('Content-Type: application/rss+xml');
     $this->assertEqual($this->response->getContentType(), 'application/rss+xml');
   }
 
   function testGetContentTypeWithDelimiter()
   {
-    $this->response->header('Content-Type: text/html; charset=UTF-8');
+    $this->response->addHeader('Content-Type: text/html; charset=UTF-8');
     $this->assertEqual($this->response->getContentType(), 'text/html');
   }
 }

Modified: 3.x/trunk/limb/tests_runner/bin/limb_unit.php
===================================================================
--- 3.x/trunk/limb/tests_runner/bin/limb_unit.php	2008-07-10 09:29:34 UTC (rev 7110)
+++ 3.x/trunk/limb/tests_runner/bin/limb_unit.php	2008-07-10 09:34:17 UTC (rev 7111)
@@ -1,3 +1,4 @@
+#!/usr/bin/php
 <?php
 /*
  * Limb PHP Framework

Modified: 3.x/trunk/limb/web_app/src/controller/NotFoundController.class.php
===================================================================
--- 3.x/trunk/limb/web_app/src/controller/NotFoundController.class.php	2008-07-10 09:29:34 UTC (rev 7110)
+++ 3.x/trunk/limb/web_app/src/controller/NotFoundController.class.php	2008-07-10 09:34:17 UTC (rev 7111)
@@ -2,9 +2,9 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 
 lmb_require('limb/web_app/src/controller/lmbController.class.php');
@@ -19,7 +19,7 @@
 {
   function doDisplay()
   {
-    $this->response->header('HTTP/1.x 404 Not Found');
+    $this->response->addHeader('HTTP/1.x 404 Not Found');
     $this->setTemplate($this->findTemplateByAlias('not_found'));
   }
 }

Modified: 3.x/trunk/limb/web_app/src/controller/ServerErrorController.class.php
===================================================================
--- 3.x/trunk/limb/web_app/src/controller/ServerErrorController.class.php	2008-07-10 09:29:34 UTC (rev 7110)
+++ 3.x/trunk/limb/web_app/src/controller/ServerErrorController.class.php	2008-07-10 09:34:17 UTC (rev 7111)
@@ -2,9 +2,9 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 
 lmb_require('limb/web_app/src/controller/lmbController.class.php');
@@ -19,7 +19,7 @@
 {
   function doDisplay()
   {
-    $this->response->header('HTTP/1.x 500 Server Error');
+    $this->response->addHeader('HTTP/1.x 500 Server Error');
     $this->resetView();
     $this->setTemplate('server_error.html');
   }



More information about the limb-svn mailing list