[limb-svn] r5998 - 3.x/trunk/limb/cms/src/model
svn at limb-project.com
svn at limb-project.com
Mon Jun 18 16:28:49 MSD 2007
Author: pachanga
Date: 2007-06-18 16:28:49 +0400 (Mon, 18 Jun 2007)
New Revision: 5998
URL: http://fisheye.limb-project.com/changelog/limb/?cs=5998
Modified:
3.x/trunk/limb/cms/src/model/lmbCmsClassName.class.php
3.x/trunk/limb/cms/src/model/lmbCmsDocument.class.php
3.x/trunk/limb/cms/src/model/lmbCmsFileObject.class.php
3.x/trunk/limb/cms/src/model/lmbCmsImage.class.php
3.x/trunk/limb/cms/src/model/lmbCmsNode.class.php
Log:
-- changes due to AR-11: passing db connection to all levels
Modified: 3.x/trunk/limb/cms/src/model/lmbCmsClassName.class.php
===================================================================
--- 3.x/trunk/limb/cms/src/model/lmbCmsClassName.class.php 2007-06-18 12:27:21 UTC (rev 5997)
+++ 3.x/trunk/limb/cms/src/model/lmbCmsClassName.class.php 2007-06-18 12:28:49 UTC (rev 5998)
@@ -1,20 +1,20 @@
<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
*/
lmb_require('limb/active_record/src/lmbActiveRecord.class.php');
-lmb_require('limb/dbal/src/criteria/lmbSQLFieldCriteria.class.php');
-
+lmb_require('limb/dbal/src/criteria/lmbSQLFieldCriteria.class.php');
+
/**
* class lmbCmsClassName.
*
* @package cms
* @version $Id$
- */
+ */
class lmbCmsClassName extends lmbActiveRecord
{
protected $_db_table_name = 'class_name';
@@ -27,7 +27,9 @@
$title = $object;
$criteria = new lmbSQLFieldCriteria('title', $title);
- if($obj = lmbActiveRecord :: findFirst('lmbCmsClassName', array('criteria' => $criteria)))
+ if($obj = lmbActiveRecord :: findFirst('lmbCmsClassName',
+ array('criteria' => $criteria),
+ $this->_db_conn))
{
return $obj->id;
}
Modified: 3.x/trunk/limb/cms/src/model/lmbCmsDocument.class.php
===================================================================
--- 3.x/trunk/limb/cms/src/model/lmbCmsDocument.class.php 2007-06-18 12:27:21 UTC (rev 5997)
+++ 3.x/trunk/limb/cms/src/model/lmbCmsDocument.class.php 2007-06-18 12:28:49 UTC (rev 5998)
@@ -1,21 +1,21 @@
<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
*/
-lmb_require('limb/active_record/src/lmbActiveRecord.class.php');
-
+lmb_require('limb/active_record/src/lmbActiveRecord.class.php');
+
/**
* class lmbCmsDocument.
*
* @package cms
* @version $Id$
- */
+ */
class lmbCmsDocument extends lmbActiveRecord
{
protected $_db_table_name = 'document';
@@ -41,7 +41,7 @@
' FROM document LEFT JOIN node ON node.id = document.node_id '.
' WHERE node.parent_id = '. $parent_id;
- return lmbActiveRecord :: findBySql('lmbCmsDocument', $sql);
+ return lmbActiveRecord :: findBySql('lmbCmsDocument', $sql, $this->_db_conn);
}
function getPublishedKids()
@@ -51,7 +51,7 @@
' WHERE node.parent_id = '. $this->getNode()->id .
' AND document.is_published = 1';
- return lmbActiveRecord :: findBySql('lmbCmsDocument', $sql);
+ return lmbActiveRecord :: findBySql('lmbCmsDocument', $sql, $this->_db_conn);
}
}
Modified: 3.x/trunk/limb/cms/src/model/lmbCmsFileObject.class.php
===================================================================
--- 3.x/trunk/limb/cms/src/model/lmbCmsFileObject.class.php 2007-06-18 12:27:21 UTC (rev 5997)
+++ 3.x/trunk/limb/cms/src/model/lmbCmsFileObject.class.php 2007-06-18 12:28:49 UTC (rev 5998)
@@ -1,20 +1,20 @@
<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
*/
lmb_require('limb/active_record/src/lmbActiveRecord.class.php');
-lmb_require('limb/dbal/src/criteria/lmbSQLFieldCriteria.class.php');
-
+lmb_require('limb/dbal/src/criteria/lmbSQLFieldCriteria.class.php');
+
/**
* class lmbCmsFileObject.
*
* @package cms
* @version $Id$
- */
+ */
class lmbCmsFileObject extends lmbActiveRecord
{
protected $_has_one = array('node' => array('field' => 'node_id',
@@ -44,20 +44,24 @@
$this->generateAndSetUid();
}
- static function findByUid($class_name, $uid)
+ static function findByUid($class_name, $uid, $conn = null)
{
- $conn = lmbToolkit :: instance()->getDefaultDbConnection();
- return lmbActiveRecord :: findFirst($class_name, array('criteria' => new lmbSQLFieldCriteria('UID', $uid)));
+ return lmbActiveRecord :: findFirst($class_name,
+ array('criteria' => new lmbSQLFieldCriteria('UID', $uid)),
+ $conn);
}
- static function findForParentNode($parent)
+ static function findForParentNode($parent, $conn = null)
{
$sql = 'SELECT file_object.* '.
' FROM file_object LEFT JOIN node ON node.id = file_object.node_id '.
' WHERE node.parent_id = '. $parent->id;
- $stmt = lmbToolkit :: instance()->getDefaultDbConnection()->newStatement($sql);
- return lmbActiveRecord :: decorateRecordSet($stmt->getRecordSet(), 'FileObject');
+ if(!is_object($conn))
+ $conn = lmbActiveRecord :: getDefaultConnection();
+
+ $stmt = $conn->newStatement($sql);
+ return lmbActiveRecord :: decorateRecordSet($stmt->getRecordSet(), 'FileObject', $conn);
}
function generateUid()
Modified: 3.x/trunk/limb/cms/src/model/lmbCmsImage.class.php
===================================================================
--- 3.x/trunk/limb/cms/src/model/lmbCmsImage.class.php 2007-06-18 12:27:21 UTC (rev 5997)
+++ 3.x/trunk/limb/cms/src/model/lmbCmsImage.class.php 2007-06-18 12:28:49 UTC (rev 5998)
@@ -1,21 +1,21 @@
<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
*/
lmb_require('limb/active_record/src/lmbActiveRecord.class.php');
lmb_require('limb/cms/src/model/lmbCmsImageFileObject.class.php');
-lmb_require('limb/cms/src/model/lmbCmsNode.class.php');
-
+lmb_require('limb/cms/src/model/lmbCmsNode.class.php');
+
/**
* class lmbCmsImage.
*
* @package cms
* @version $Id$
- */
+ */
class lmbCmsImage extends lmbActiveRecord
{
protected $_has_one = array('original' => array('field' => 'original_id',
@@ -38,14 +38,17 @@
return $validator;
}
- static function findForParentNode($parent)
+ static function findForParentNode($parent, $conn = null)
{
$sql = 'SELECT image.* '.
' FROM image LEFT JOIN node ON node.id = image.node_id '.
' WHERE node.parent_id = '. $parent->id;
- $stmt = lmbToolkit :: instance()->getDefaultDbConnection()->newStatement($sql);
- return lmbActiveRecord :: decorateRecordSet($stmt->getRecordSet(), 'lmbCmsImage');
+ if(!is_object($conn))
+ $conn = lmbActiveRecord :: getDefaultConnection();
+
+ $stmt = $conn->newStatement($sql);
+ return lmbActiveRecord :: decorateRecordSet($stmt->getRecordSet(), 'lmbCmsImage', $conn);
}
}
?>
\ No newline at end of file
Modified: 3.x/trunk/limb/cms/src/model/lmbCmsNode.class.php
===================================================================
--- 3.x/trunk/limb/cms/src/model/lmbCmsNode.class.php 2007-06-18 12:27:21 UTC (rev 5997)
+++ 3.x/trunk/limb/cms/src/model/lmbCmsNode.class.php 2007-06-18 12:28:49 UTC (rev 5998)
@@ -134,8 +134,8 @@
if(!isset($this->object_id) || !$this->object_id)
return null;
- $class_name = lmbActiveRecord :: findById('lmbCmsClassName', $this->object_class_id);
- return lmbActiveRecord :: findById($class_name->title, $this->object_id);
+ $class_name = lmbActiveRecord :: findById('lmbCmsClassName', $this->object_class_id, true, $this->_db_conn);
+ return lmbActiveRecord :: findById($class_name->title, $this->object_id, true, $this->_db_conn);
}
function getControllerName()
@@ -145,7 +145,7 @@
if(!$this->controller_name)
{
- $class_name = lmbActiveRecord :: findById('lmbCmsClassName', $this->controller_id);
+ $class_name = lmbActiveRecord :: findById('lmbCmsClassName', $this->controller_id, true, $this->_db_conn);
$this->controller_name = $class_name->title;
}
@@ -181,30 +181,30 @@
return self :: getGatewayPath() . $this->getRelativeUrlPath();
}
- static function findByPath($path)
+ static function findByPath($path, $conn = null)
{
$tree = lmbToolkit :: instance()->getCmsTree();
$node = $tree->getNodeByPath($path);
if($node)
- return lmbActiveRecord :: findById('lmbCmsNode', $node['id']);
+ return lmbActiveRecord :: findById('lmbCmsNode', $node['id'], $conn);
}
- static function findById($node_id)
+ static function findById($node_id, $conn = null)
{
$tree = lmbToolkit :: instance()->getCmsTree();
if($node_id && $node = $tree->getNode($node_id))
- return lmbActiveRecord :: findById('lmbCmsNode', $node['id']);
+ return lmbActiveRecord :: findById('lmbCmsNode', $node['id'], true, $conn);
}
- static function findByIdOrPath($node_id, $path)
+ static function findByIdOrPath($node_id, $path, $conn = null)
{
- if($node_ar = lmbCmsNode :: findById($node_id))
+ if($node_ar = lmbCmsNode :: findById($node_id, $conn))
return $node_ar;
$tree = lmbToolkit :: instance()->getCmsTree();
if($node = $tree->getNodeByPath($path))
- return lmbActiveRecord :: findById('lmbCmsNode', $node['id']);
+ return lmbActiveRecord :: findById('lmbCmsNode', $node['id'], true, $conn);
}
static function findRequested()
@@ -213,23 +213,27 @@
return lmbCmsNode :: findByPath($path);
}
- static function findChildren($node_id, $depth = 1)
+ static function findChildren($node_id, $depth = 1, $conn = null)
{
if($node_id)
{
$tree = lmbToolkit :: instance()->getCmsTree();
- return lmbActiveRecord :: decorateRecordSet($tree->getChildren($node_id, $depth), 'lmbCmsNode');
+ return lmbActiveRecord :: decorateRecordSet($tree->getChildren($node_id, $depth),
+ 'lmbCmsNode',
+ $conn);
}
}
- static function findChildrenByPath($path, $depth = 1)
+ static function findChildrenByPath($path, $depth = 1, $conn = null)
{
$tree = lmbToolkit :: instance()->getCmsTree();
if($path && $parent = $tree->getNodeByPath($path))
- return lmbActiveRecord :: decorateRecordSet($tree->getChildren($parent['id'], $depth), 'lmbCmsNode');
+ return lmbActiveRecord :: decorateRecordSet($tree->getChildren($parent['id'], $depth),
+ 'lmbCmsNode',
+ $conn);
}
- static function findImmediateChildren($parent_id, $controller = '')
+ static function findImmediateChildren($parent_id, $controller = '', $conn = null)
{
$criteria = new lmbSQLRawCriteria("parent_id = " . (int)$this->parent_id);
if($controller)
@@ -237,22 +241,26 @@
$controller_id = lmbCmsClassName :: generateIdFor($controller);
$criteria->addAnd(new lmbSQLRawCriteria('controller_id ='. $controller_id));
}
- return lmbActiveRecord :: find('lmbCmsNode', array('criteria' => $criteria));
+ return lmbActiveRecord :: find('lmbCmsNode', array('criteria' => $criteria), $conn);
}
function getChildren($depth = 1)
{
- return lmbActiveRecord :: decorateRecordSet($this->_tree->getChildren($this->getId(), $depth), 'lmbCmsNode');
+ return lmbActiveRecord :: decorateRecordSet($this->_tree->getChildren($this->getId(), $depth),
+ 'lmbCmsNode',
+ $this->_db_conn);
}
function getParents()
{
- return $this->decorateRecordSet($this->_tree->getParents($this->getId()));
+ return $this->_decorateRecordSet($this->_tree->getParents($this->getId()));
}
function getRoots()
{
- return lmbActiveRecord :: decorateRecordSet($this->_tree->getChildren('/'), 'lmbCmsNode');
+ return lmbActiveRecord :: decorateRecordSet($this->_tree->getChildren('/'),
+ 'lmbCmsNode',
+ $this->_db_conn);
}
function getRootNodes()
More information about the limb-svn
mailing list