From: <du...@us...> - 2012-10-07 11:33:53
|
Revision: 10196 http://sourceforge.net/p/xoops/svn/10196 Author: dugris Date: 2012-10-07 11:33:50 +0000 (Sun, 07 Oct 2012) Log Message: ----------- Keep toArray() function for the compatibility of modules, and customization of classes Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/joint.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/read.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/object.php Property Changed: ---------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/joint.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/read.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/object.php Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/joint.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/joint.php 2012-10-05 13:24:54 UTC (rev 10195) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/joint.php 2012-10-07 11:33:50 UTC (rev 10196) @@ -1,216 +1,216 @@ -<?php -/* - You may not change or alter any portion of this comment or credits - of supporting developers from this source code or any supporting source code - which is considered copyrighted (c) material of the original comment or credit authors. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -*/ - -/** - * Object joint handler class. - * - * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package class - * @subpackage model - * @since 2.3.0 - * @author Taiwen Jiang <ph...@us...> - * @version $Id$ - */ - -defined('XOOPS_ROOT_PATH') or die('Restricted access'); - -/** - * Object joint handler class. - * - * @author Taiwen Jiang <ph...@us...> - * - * {@link XoopsObjectAbstract} - * - * Usage of methods provided by XoopsModelJoint: - * - * Step #1: set linked table and adjoint fields through XoopsPersistableObjectHandler: - * $handler->table_link = $handler->db->prefix("the_linked_table"); // full name of the linked table that is used for the query - * $handler->field_link = "the_linked_field"; // name of field in linked table that will be used to link the linked table with current table - * $handler->field_object = "the_object_field"; // name of field in current table that will be used to link the linked table with current table; linked field name will be used if the field name is not set - * Step #2: fetch data - */ -class XoopsModelJoint extends XoopsModelAbstract -{ - /** - * Validate information for the linkship - * - * @access private - * @return bool|null - */ - private function validateLinks() - { - if (empty($this->handler->table_link) || empty($this->handler->field_link)) { - trigger_error("The linked table is not set yet.", E_USER_WARNING); - return null; - } - if (empty($this->handler->field_object)) { - $this->handler->field_object = $this->handler->field_link; - } - return true; - } - - /** - * get a list of objects matching a condition joint with another related object - * - * @param CriteriaElement|null $criteria {@link CriteriaElement} to match - * @param array $fields variables to fetch - * @param bool $asObject flag indicating as object, otherwise as array - * @param string $field_link field of linked object for JOIN; deprecated, for backward compat - * @param string $field_object field of current object for JOIN; deprecated, for backward compat - * @return array of objects {@link XoopsObject} - */ - public function getByLink(CriteriaElement $criteria = null, $fields = null, $asObject = true, $field_link = null, $field_object = null) - { - if (!empty($field_link)) { - $this->handler->field_link = $field_link; - } - if (!empty($field_object)) { - $this->handler->field_object = $field_object; - } - if (!$this->validateLinks()) { - return null; - } - - if (is_array($fields) && count($fields)) { - if (!in_array("o." . $this->handler->keyName, $fields)) { - $fields[] = "o." . $this->handler->keyName; - } - $select = implode(",", $fields); - } else { - $select = "o.*, l.*"; - } - $limit = null; - $start = null; - // $field_object = empty($field_object) ? $field_link : $field_object; - $sql = " SELECT {$select}" . " FROM {$this->handler->table} AS o" . " LEFT JOIN {$this->handler->table_link} AS l ON o.{$this->handler->field_object} = l.{$this->handler->field_link}"; - if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) { - $sql .= " " . $criteria->renderWhere(); - if ($sort = $criteria->getSort()) { - $sql .= " ORDER BY {$sort} " . $criteria->getOrder(); - $orderSet = true; - } - $limit = $criteria->getLimit(); - $start = $criteria->getStart(); - } - if (empty($orderSet)) { - $sql .= " ORDER BY o.{$this->handler->keyName} DESC"; - } - $result = $this->handler->db->query($sql, $limit, $start); - $ret = array(); - if ($asObject) { - while ($myrow = $this->handler->db->fetchArray($result)) { - $object = $this->handler->create(false); - $object->assignVars($myrow); - $ret[$myrow[$this->handler->keyName]] = $object; - unset($object); - } - } else { - $object = $this->handler->create(false); - while ($myrow = $this->handler->db->fetchArray($result)) { - $object->assignVars($myrow); - $ret[$myrow[$this->handler->keyName]] = $object->getValues(array_keys($myrow)); - } - unset($object); - } - return $ret; - } - - /** - * Count of objects matching a condition - * - * @param CriteriaElement|null $criteria {@link CriteriaElement} to match - * @return int count of objects - */ - public function getCountByLink(CriteriaElement $criteria = null) - { - if (!$this->validateLinks()) { - return null; - } - - $sql = " SELECT COUNT(DISTINCT {$this->handler->keyName}) AS count" . " FROM {$this->handler->table} AS o" . " LEFT JOIN {$this->handler->table_link} AS l ON o.{$this->handler->field_object} = l.{$this->handler->field_link}"; - if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) { - $sql .= " " . $criteria->renderWhere(); - } - if (!$result = $this->handler->db->query($sql)) { - return false; - } - $myrow = $this->handler->db->fetchArray($result); - return intval($myrow["count"]); - } - - /** - * array of count of objects matching a condition of, groupby linked object keyname - * - * @param CriteriaElement $criteria {@link CriteriaElement} to match - * @return int count of objects - */ - public function getCountsByLink(CriteriaElement $criteria = null) - { - if (!$this->validateLinks()) { - return null; - } - $sql = " SELECT l.{$this->handler->keyName_link}, COUNT(*)" . " FROM {$this->handler->table} AS o" . " LEFT JOIN {$this->handler->table_link} AS l ON o.{$this->handler->field_object} = l.{$this->handler->field_link}"; - if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) { - $sql .= " " . $criteria->renderWhere(); - } - $sql .= " GROUP BY l.{$this->handler->keyName_link}"; - if (!$result = $this->handler->db->query($sql)) { - return false; - } - $ret = array(); - while (list ($id, $count) = $this->handler->db->fetchRow($result)) { - $ret[$id] = $count; - } - return $ret; - } - - /** - * update objects matching a condition against linked objects - * - * @param array $data array of key => value - * @param CriteriaElement|null $criteria {@link CriteriaElement} to match - * @return int count of objects - */ - public function updateByLink($data, CriteriaElement $criteria = null) - { - if (!$this->validateLinks()) { - return null; - } - $set = array(); - foreach ($data as $key => $val) { - $set[] = "o.{$key}=" . $this->handler->db->quoteString($val); - } - $sql = " UPDATE {$this->handler->table} AS o" . " SET " . implode(", ", $set) . " LEFT JOIN {$this->handler->table_link} AS l ON o.{$this->handler->field_object} = l.{$this->handler->field_link}"; - if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) { - $sql .= " " . $criteria->renderWhere(); - } - return $this->handler->db->query($sql); - } - - /** - * Delete objects matching a condition against linked objects - * - * @param CriteriaElement|null $criteria {@link CriteriaElement} to match - * @return int count of objects - */ - public function deleteByLink(CriteriaElement $criteria = null) - { - if (!$this->validateLinks()) { - return null; - } - $sql = "DELETE FROM {$this->handler->table} AS o " . " LEFT JOIN {$this->handler->table_link} AS l ON o.{$this->handler->field_object} = l.{$this->handler->field_link}"; - if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) { - $sql .= " " . $criteria->renderWhere(); - } - return $this->handler->db->query($sql); - } +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * Object joint handler class. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package class + * @subpackage model + * @since 2.3.0 + * @author Taiwen Jiang <ph...@us...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +/** + * Object joint handler class. + * + * @author Taiwen Jiang <ph...@us...> + * + * {@link XoopsObjectAbstract} + * + * Usage of methods provided by XoopsModelJoint: + * + * Step #1: set linked table and adjoint fields through XoopsPersistableObjectHandler: + * $handler->table_link = $handler->db->prefix("the_linked_table"); // full name of the linked table that is used for the query + * $handler->field_link = "the_linked_field"; // name of field in linked table that will be used to link the linked table with current table + * $handler->field_object = "the_object_field"; // name of field in current table that will be used to link the linked table with current table; linked field name will be used if the field name is not set + * Step #2: fetch data + */ +class XoopsModelJoint extends XoopsModelAbstract +{ + /** + * Validate information for the linkship + * + * @access private + * @return bool|null + */ + private function validateLinks() + { + if (empty($this->handler->table_link) || empty($this->handler->field_link)) { + trigger_error("The linked table is not set yet.", E_USER_WARNING); + return null; + } + if (empty($this->handler->field_object)) { + $this->handler->field_object = $this->handler->field_link; + } + return true; + } + + /** + * get a list of objects matching a condition joint with another related object + * + * @param CriteriaElement|null $criteria {@link CriteriaElement} to match + * @param array $fields variables to fetch + * @param bool $asObject flag indicating as object, otherwise as array + * @param string $field_link field of linked object for JOIN; deprecated, for backward compat + * @param string $field_object field of current object for JOIN; deprecated, for backward compat + * @return array of objects {@link XoopsObject} + */ + public function getByLink(CriteriaElement $criteria = null, $fields = null, $asObject = true, $field_link = null, $field_object = null) + { + if (!empty($field_link)) { + $this->handler->field_link = $field_link; + } + if (!empty($field_object)) { + $this->handler->field_object = $field_object; + } + if (!$this->validateLinks()) { + return null; + } + + if (is_array($fields) && count($fields)) { + if (!in_array("o." . $this->handler->keyName, $fields)) { + $fields[] = "o." . $this->handler->keyName; + } + $select = implode(",", $fields); + } else { + $select = "o.*, l.*"; + } + $limit = null; + $start = null; + // $field_object = empty($field_object) ? $field_link : $field_object; + $sql = " SELECT {$select}" . " FROM {$this->handler->table} AS o" . " LEFT JOIN {$this->handler->table_link} AS l ON o.{$this->handler->field_object} = l.{$this->handler->field_link}"; + if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) { + $sql .= " " . $criteria->renderWhere(); + if ($sort = $criteria->getSort()) { + $sql .= " ORDER BY {$sort} " . $criteria->getOrder(); + $orderSet = true; + } + $limit = $criteria->getLimit(); + $start = $criteria->getStart(); + } + if (empty($orderSet)) { + $sql .= " ORDER BY o.{$this->handler->keyName} DESC"; + } + $result = $this->handler->db->query($sql, $limit, $start); + $ret = array(); + if ($asObject) { + while ($myrow = $this->handler->db->fetchArray($result)) { + $object = $this->handler->create(false); + $object->assignVars($myrow); + $ret[$myrow[$this->handler->keyName]] = $object; + unset($object); + } + } else { + $object = $this->handler->create(false); + while ($myrow = $this->handler->db->fetchArray($result)) { + $object->assignVars($myrow); + $ret[$myrow[$this->handler->keyName]] = $object->toArray(); + } + unset($object); + } + return $ret; + } + + /** + * Count of objects matching a condition + * + * @param CriteriaElement|null $criteria {@link CriteriaElement} to match + * @return int count of objects + */ + public function getCountByLink(CriteriaElement $criteria = null) + { + if (!$this->validateLinks()) { + return null; + } + + $sql = " SELECT COUNT(DISTINCT {$this->handler->keyName}) AS count" . " FROM {$this->handler->table} AS o" . " LEFT JOIN {$this->handler->table_link} AS l ON o.{$this->handler->field_object} = l.{$this->handler->field_link}"; + if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) { + $sql .= " " . $criteria->renderWhere(); + } + if (!$result = $this->handler->db->query($sql)) { + return false; + } + $myrow = $this->handler->db->fetchArray($result); + return intval($myrow["count"]); + } + + /** + * array of count of objects matching a condition of, groupby linked object keyname + * + * @param CriteriaElement $criteria {@link CriteriaElement} to match + * @return int count of objects + */ + public function getCountsByLink(CriteriaElement $criteria = null) + { + if (!$this->validateLinks()) { + return null; + } + $sql = " SELECT l.{$this->handler->keyName_link}, COUNT(*)" . " FROM {$this->handler->table} AS o" . " LEFT JOIN {$this->handler->table_link} AS l ON o.{$this->handler->field_object} = l.{$this->handler->field_link}"; + if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) { + $sql .= " " . $criteria->renderWhere(); + } + $sql .= " GROUP BY l.{$this->handler->keyName_link}"; + if (!$result = $this->handler->db->query($sql)) { + return false; + } + $ret = array(); + while (list ($id, $count) = $this->handler->db->fetchRow($result)) { + $ret[$id] = $count; + } + return $ret; + } + + /** + * update objects matching a condition against linked objects + * + * @param array $data array of key => value + * @param CriteriaElement|null $criteria {@link CriteriaElement} to match + * @return int count of objects + */ + public function updateByLink($data, CriteriaElement $criteria = null) + { + if (!$this->validateLinks()) { + return null; + } + $set = array(); + foreach ($data as $key => $val) { + $set[] = "o.{$key}=" . $this->handler->db->quoteString($val); + } + $sql = " UPDATE {$this->handler->table} AS o" . " SET " . implode(", ", $set) . " LEFT JOIN {$this->handler->table_link} AS l ON o.{$this->handler->field_object} = l.{$this->handler->field_link}"; + if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) { + $sql .= " " . $criteria->renderWhere(); + } + return $this->handler->db->query($sql); + } + + /** + * Delete objects matching a condition against linked objects + * + * @param CriteriaElement|null $criteria {@link CriteriaElement} to match + * @return int count of objects + */ + public function deleteByLink(CriteriaElement $criteria = null) + { + if (!$this->validateLinks()) { + return null; + } + $sql = "DELETE FROM {$this->handler->table} AS o " . " LEFT JOIN {$this->handler->table_link} AS l ON o.{$this->handler->field_object} = l.{$this->handler->field_link}"; + if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) { + $sql .= " " . $criteria->renderWhere(); + } + return $this->handler->db->query($sql); + } } \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/joint.php ___________________________________________________________________ Deleted: svn:eol-style - native Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/read.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/read.php 2012-10-05 13:24:54 UTC (rev 10195) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/read.php 2012-10-07 11:33:50 UTC (rev 10196) @@ -1,182 +1,182 @@ -<?php -/* - You may not change or alter any portion of this comment or credits - of supporting developers from this source code or any supporting source code - which is considered copyrighted (c) material of the original comment or credit authors. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -*/ - -/** - * Object render handler class. - * - * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package class - * @subpackage model - * @since 2.3.0 - * @author Taiwen Jiang <ph...@us...> - * @version $Id$ - */ - -defined('XOOPS_ROOT_PATH') or die('Restricted access'); - -/** - * Object render handler class. - * - * @author Taiwen Jiang <ph...@us...> - * - * {@link XoopsObjectAbstract} - */ -class XoopsModelRead extends XoopsModelAbstract -{ - /** - * get all objects matching a condition - * - * @param CriteriaElement|null $criteria {@link CriteriaElement} to match - * @param array $fields variables to fetch - * @param bool $asObject flag indicating as object, otherwise as array - * @param bool $id_as_key use the ID as key for the array - * @return array of objects/array {@link XoopsObject} - */ - public function getAll(CriteriaElement $criteria = null, $fields = null, $asObject = true, $id_as_key = true) - { - if (is_array($fields) && count($fields) > 0) { - if (!in_array($this->handler->keyName, $fields)) { - $fields[] = $this->handler->keyName; - } - $select = "`" . implode("`, `", $fields) . "`"; - } else { - $select = "*"; - } - $limit = null; - $start = null; - $sql = "SELECT {$select} FROM `{$this->handler->table}`"; - if (isset($criteria)) { - $sql .= " " . $criteria->renderWhere(); - if ($groupby = $criteria->getGroupby()) { - $sql .= $groupby; - } - if ($sort = $criteria->getSort()) { - $sql .= " ORDER BY {$sort} " . $criteria->getOrder(); - $orderSet = true; - } - $limit = $criteria->getLimit(); - $start = $criteria->getStart(); - } - if (empty($orderSet)) { - //$sql .= " ORDER BY `{$this->handler->keyName}` DESC"; - } - $result = $this->handler->db->query($sql, $limit, $start); - $ret = array(); - if ($asObject) { - while ($myrow = $this->handler->db->fetchArray($result)) { - $object = $this->handler->create(false); - $object->assignVars($myrow); - if ($id_as_key) { - $ret[$myrow[$this->handler->keyName]] = $object; - } else { - $ret[] = $object; - } - unset($object); - } - } else { - $object = $this->handler->create(false); - while ($myrow = $this->handler->db->fetchArray($result)) { - $object->assignVars($myrow); - if ($id_as_key) { - $ret[$myrow[$this->handler->keyName]] = $object->getValues(array_keys($myrow)); - } else { - $ret[] = $object->getValues(array_keys($myrow)); - } - } - unset($object); - } - return $ret; - } - - /** - * retrieve objects from the database - * - * For performance consideration, getAll() is recommended - * - * @param CriteriaElement|null $criteria {@link CriteriaElement} conditions to be met - * @param bool $id_as_key use the ID as key for the array - * @param bool $as_object return an array of objects? - * @return array - */ - public function getObjects(CriteriaElement $criteria = null, $id_as_key = false, $as_object = true) - { - $objects = $this->getAll($criteria, null, $as_object, $id_as_key); - return $objects; - } - - /** - * Retrieve a list of objects data - * - * @param CriteriaElement|null $criteria {@link CriteriaElement} conditions to be met - * @param int $limit Max number of objects to fetch - * @param int $start Which record to start at - * @return array - */ - public function getList(CriteriaElement $criteria = null, $limit = 0, $start = 0) - { - $ret = array(); - if ($criteria == null) { - $criteria = new CriteriaCompo(); - } - - $sql = "SELECT `{$this->handler->keyName}`"; - if (!empty($this->handler->identifierName)) { - $sql .= ", `{$this->handler->identifierName}`"; - } - $sql .= " FROM `{$this->handler->table}`"; - if (isset($criteria)) { - $sql .= ' ' . $criteria->renderWhere(); - if ($sort = $criteria->getSort()) { - $sql .= ' ORDER BY ' . $sort . ' ' . $criteria->getOrder(); - } - $limit = $criteria->getLimit(); - $start = $criteria->getStart(); - } - $result = $this->handler->db->query($sql, $limit, $start); - if (!$result) { - return $ret; - } - - $myts = MyTextSanitizer::getInstance(); - while ($myrow = $this->handler->db->fetchArray($result)) { - // identifiers should be textboxes, so sanitize them like that - $ret[$myrow[$this->handler->keyName]] = empty($this->handler->identifierName) ? 1 - : $myts->htmlSpecialChars($myrow[$this->handler->identifierName]); - } - return $ret; - } - - /** - * get IDs of objects matching a condition - * - * @param CriteriaElement|null $criteria {@link CriteriaElement} to match - * @return array of object IDs - */ - function getIds(CriteriaElement $criteria = null) - { - $ret = array(); - $sql = "SELECT `{$this->handler->keyName}` FROM `{$this->handler->table}`"; - $limit = $start = null; - if (isset($criteria)) { - $sql .= ' ' . $criteria->renderWhere(); - $limit = $criteria->getLimit(); - $start = $criteria->getStart(); - } - if (!$result = $this->handler->db->query($sql, $limit, $start)) { - return $ret; - } - while ($myrow = $this->handler->db->fetchArray($result)) { - $ret[] = $myrow[$this->handler->keyName]; - } - return $ret; - } +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * Object render handler class. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package class + * @subpackage model + * @since 2.3.0 + * @author Taiwen Jiang <ph...@us...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +/** + * Object render handler class. + * + * @author Taiwen Jiang <ph...@us...> + * + * {@link XoopsObjectAbstract} + */ +class XoopsModelRead extends XoopsModelAbstract +{ + /** + * get all objects matching a condition + * + * @param CriteriaElement|null $criteria {@link CriteriaElement} to match + * @param array $fields variables to fetch + * @param bool $asObject flag indicating as object, otherwise as array + * @param bool $id_as_key use the ID as key for the array + * @return array of objects/array {@link XoopsObject} + */ + public function getAll(CriteriaElement $criteria = null, $fields = null, $asObject = true, $id_as_key = true) + { + if (is_array($fields) && count($fields) > 0) { + if (!in_array($this->handler->keyName, $fields)) { + $fields[] = $this->handler->keyName; + } + $select = "`" . implode("`, `", $fields) . "`"; + } else { + $select = "*"; + } + $limit = null; + $start = null; + $sql = "SELECT {$select} FROM `{$this->handler->table}`"; + if (isset($criteria)) { + $sql .= " " . $criteria->renderWhere(); + if ($groupby = $criteria->getGroupby()) { + $sql .= $groupby; + } + if ($sort = $criteria->getSort()) { + $sql .= " ORDER BY {$sort} " . $criteria->getOrder(); + $orderSet = true; + } + $limit = $criteria->getLimit(); + $start = $criteria->getStart(); + } + if (empty($orderSet)) { + //$sql .= " ORDER BY `{$this->handler->keyName}` DESC"; + } + $result = $this->handler->db->query($sql, $limit, $start); + $ret = array(); + if ($asObject) { + while ($myrow = $this->handler->db->fetchArray($result)) { + $object = $this->handler->create(false); + $object->assignVars($myrow); + if ($id_as_key) { + $ret[$myrow[$this->handler->keyName]] = $object; + } else { + $ret[] = $object; + } + unset($object); + } + } else { + $object = $this->handler->create(false); + while ($myrow = $this->handler->db->fetchArray($result)) { + $object->assignVars($myrow); + if ($id_as_key) { + $ret[$myrow[$this->handler->keyName]] = $object->toArray(); + } else { + $ret[] = $object->toArray(); + } + } + unset($object); + } + return $ret; + } + + /** + * retrieve objects from the database + * + * For performance consideration, getAll() is recommended + * + * @param CriteriaElement|null $criteria {@link CriteriaElement} conditions to be met + * @param bool $id_as_key use the ID as key for the array + * @param bool $as_object return an array of objects? + * @return array + */ + public function getObjects(CriteriaElement $criteria = null, $id_as_key = false, $as_object = true) + { + $objects = $this->getAll($criteria, null, $as_object, $id_as_key); + return $objects; + } + + /** + * Retrieve a list of objects data + * + * @param CriteriaElement|null $criteria {@link CriteriaElement} conditions to be met + * @param int $limit Max number of objects to fetch + * @param int $start Which record to start at + * @return array + */ + public function getList(CriteriaElement $criteria = null, $limit = 0, $start = 0) + { + $ret = array(); + if ($criteria == null) { + $criteria = new CriteriaCompo(); + } + + $sql = "SELECT `{$this->handler->keyName}`"; + if (!empty($this->handler->identifierName)) { + $sql .= ", `{$this->handler->identifierName}`"; + } + $sql .= " FROM `{$this->handler->table}`"; + if (isset($criteria)) { + $sql .= ' ' . $criteria->renderWhere(); + if ($sort = $criteria->getSort()) { + $sql .= ' ORDER BY ' . $sort . ' ' . $criteria->getOrder(); + } + $limit = $criteria->getLimit(); + $start = $criteria->getStart(); + } + $result = $this->handler->db->query($sql, $limit, $start); + if (!$result) { + return $ret; + } + + $myts = MyTextSanitizer::getInstance(); + while ($myrow = $this->handler->db->fetchArray($result)) { + // identifiers should be textboxes, so sanitize them like that + $ret[$myrow[$this->handler->keyName]] = empty($this->handler->identifierName) ? 1 + : $myts->htmlSpecialChars($myrow[$this->handler->identifierName]); + } + return $ret; + } + + /** + * get IDs of objects matching a condition + * + * @param CriteriaElement|null $criteria {@link CriteriaElement} to match + * @return array of object IDs + */ + function getIds(CriteriaElement $criteria = null) + { + $ret = array(); + $sql = "SELECT `{$this->handler->keyName}` FROM `{$this->handler->table}`"; + $limit = $start = null; + if (isset($criteria)) { + $sql .= ' ' . $criteria->renderWhere(); + $limit = $criteria->getLimit(); + $start = $criteria->getStart(); + } + if (!$result = $this->handler->db->query($sql, $limit, $start)) { + return $ret; + } + while ($myrow = $this->handler->db->fetchArray($result)) { + $ret[] = $myrow[$this->handler->keyName]; + } + return $ret; + } } \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/read.php ___________________________________________________________________ Deleted: svn:eol-style - native Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/object.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/object.php 2012-10-05 13:24:54 UTC (rev 10195) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/object.php 2012-10-07 11:33:50 UTC (rev 10196) @@ -1,1308 +1,1313 @@ -<?php -/** - * XOOPS Kernel Object - * - * You may not change or alter any portion of this comment or credits - * of supporting developers from this source code or any supporting source code - * which is considered copyrighted (c) material of the original comment or credit authors. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel - * @since 2.0.0 - * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ - * @author Taiwen Jiang <ph...@us...> - * @version $Id$ - */ - -defined('XOOPS_ROOT_PATH') or die('Restricted access'); - -/** - * *#@+ - * Xoops object datatype - */ -define('XOBJ_DTYPE_TXTBOX', 1); -define('XOBJ_DTYPE_TXTAREA', 2); -define('XOBJ_DTYPE_INT', 3); -define('XOBJ_DTYPE_URL', 4); -define('XOBJ_DTYPE_EMAIL', 5); -define('XOBJ_DTYPE_ARRAY', 6); -define('XOBJ_DTYPE_OTHER', 7); -define('XOBJ_DTYPE_SOURCE', 8); -define('XOBJ_DTYPE_STIME', 9); -define('XOBJ_DTYPE_MTIME', 10); -define('XOBJ_DTYPE_LTIME', 11); -define('XOBJ_DTYPE_FLOAT', 13); -define('XOBJ_DTYPE_DECIMAL', 14); -define('XOBJ_DTYPE_ENUM', 15); - -/** - * Base class for all objects in the Xoops kernel (and beyond) - */ -class XoopsObject -{ - /** - * holds all variables(properties) of an object - * - * @var array - */ - public $vars = array(); - - /** - * variables cleaned for store in DB - * - * @var array - */ - public $cleanVars = array(); - - /** - * is it a newly created object? - * - * @var bool - */ - private $_isNew = false; - - /** - * has any of the values been modified? - * - * @var bool - */ - private $_isDirty = false; - - /** - * errors - * - * @var array - */ - private $_errors = array(); - - /** - * additional filters registered dynamically by a child class object - * - * @var array - */ - private $_filters = array(); - - /** - * @var string - */ - public $plugin_path; - - /** - * used for new/clone objects - * - * @access public - * @return void - */ - public function setNew() - { - $this->_isNew = true; - } - - /** - * @return void - */ - public function unsetNew() - { - $this->_isNew = false; - } - - /** - * @return bool - */ - public function isNew() - { - return $this->_isNew; - } - - /** - * mark modified objects as dirty - * - * used for modified objects only - * - * @access public - * @return void - */ - public function setDirty() - { - $this->_isDirty = true; - } - - /** - * @return void - */ - public function unsetDirty() - { - $this->_isDirty = false; - } - - /** - * @return bool - */ - public function isDirty() - { - return $this->_isDirty; - } - - /** - * initialize variables for the object - * - * @param string $key - * @param int $data_type set to one of XOBJ_DTYPE_XXX constants (set to XOBJ_DTYPE_OTHER if no data type ckecking nor text sanitizing is required) - * @param mixed $value - * @param bool $required require html form input? - * @param mixed $maxlength for XOBJ_DTYPE_TXTBOX type only - * @param string $options does this data have any select options? - * @return void - */ - public function initVar($key, $data_type, $value = null, $required = false, $maxlength = null, $options = '') - { - $this->vars[$key] = array('value' => $value, 'required' => $required, 'data_type' => $data_type, 'maxlength' => $maxlength, 'changed' => false, 'options' => $options); - } - - /** - * assign a value to a variable - * - * @param string $key name of the variable to assign - * @param mixed $value value to assign - */ - public function assignVar($key, $value) - { - if (isset($key) && isset($this->vars[$key])) { - $this->vars[$key]['value'] = $value; - } - } - - /** - * assign values to multiple variables in a batch - * - * @param array $var_arr associative array of values to assign - */ - public function assignVars($var_arr) - { - foreach ($var_arr as $key => $value) { - $this->assignVar($key, $value); - } - } - - /** - * assign a value to a variable - * - * @access public - * @param string $key name of the variable to assign - * @param mixed $value value to assign - * @param bool $not_gpc - */ - public function setVar($key, $value, $not_gpc = false) - { - if (!empty($key) && isset($value) && isset($this->vars[$key])) { - $this->vars[$key]['value'] = $value; - $this->vars[$key]['not_gpc'] = $not_gpc; - $this->vars[$key]['changed'] = true; - $this->setDirty(); - } - } - - /** - * assign values to multiple variables in a batch - * - * @access private - * @param array $var_arr associative array of values to assign - * @param bool $not_gpc - */ - public function setVars($var_arr, $not_gpc = false) - { - foreach ($var_arr as $key => $value) { - $this->setVar($key, $value, $not_gpc); - } - } - - /** - * unset variable(s) for the object - * - * @param mixed $var - * @return bool - */ - public function destroyVars($var) - { - if (empty($var)) { - return true; - } - $var = !is_array($var) ? array($var) : $var; - foreach ($var as $key) { - if (!isset($this->vars[$key])) { - continue; - } - $this->vars[$key]['changed'] = null; - } - return true; - } - - /** - * Assign values to multiple variables in a batch - * - * Meant for a CGI context: - * - prefixed CGI args are considered save - * - avoids polluting of namespace with CGI args - * - * @access private - * @param mixed $var_arr associative array of values to assign - * @param string $pref prefix (only keys starting with the prefix will be set) - * @param bool $not_gpc - */ - public function setFormVars($var_arr = null, $pref = 'xo_', $not_gpc = false) - { - $len = strlen($pref); - foreach ($var_arr as $key => $value) { - if ($pref == substr($key, 0, $len)) { - $this->setVar(substr($key, $len), $value, $not_gpc); - } - } - } - - /** - * returns all variables for the object - * - * @access public - * @return array associative array of key->value pairs - */ - public function getVars() - { - return $this->vars; - } - - /** - * Returns the values of the specified variables - * - * @param mixed $keys An array containing the names of the keys to retrieve, or null to get all of them - * @param string $format Format to use (see getVar) - * @param int $maxDepth Maximum level of recursion to use if some vars are objects themselves - * @return array associative array of key->value pairs - */ - public function getValues($keys = null, $format = 's', $maxDepth = 1) - { - if (!isset($keys)) { - $keys = array_keys($this->vars); - } - $vars = array(); - foreach ($keys as $key) { - if (isset($this->vars[$key])) { - if (is_object($this->vars[$key]) && is_a($this->vars[$key], 'XoopsObject')) { - if ($maxDepth) { - /* @var $obj XoopsObject */ - $obj = $this->vars[$key]; - $vars[$key] = $obj->getValues(null, $format, $maxDepth - 1); - } - } else { - $vars[$key] = $this->getVar($key, $format); - } - } - } - return $vars; - } - - /** - * returns a specific variable for the object in a proper format - * - * @access public - * @param string $key key of the object's variable to be returned - * @param string $format format to use for the output - * @return mixed formatted value of the variable - */ - public function getVar($key, $format = 's') - { - $ret = null; - if (!isset($this->vars[$key])) { - return $ret; - } - $ret = $this->vars[$key]['value']; - $ts = MyTextSanitizer::getInstance(); - switch ($this->vars[$key]['data_type']) { - case XOBJ_DTYPE_TXTBOX: - switch (strtolower($format)) { - case 's': - case 'show': - case 'e': - case 'edit': - return $ts->htmlSpecialChars($ret); - break 1; - case 'p': - case 'preview': - case 'f': - case 'formpreview': - return $ts->htmlSpecialChars($ts->stripSlashesGPC($ret)); - break 1; - case 'n': - case 'none': - default: - break 1; - } - break; - case XOBJ_DTYPE_TXTAREA: - switch (strtolower($format)) { - case 's': - case 'show': - $html = !empty($this->vars['dohtml']['value']) ? 1 : 0; - $xcode = (!isset($this->vars['doxcode']['value']) || $this->vars['doxcode']['value'] == 1) ? 1 : 0; - $smiley = (!isset($this->vars['dosmiley']['value']) || $this->vars['dosmiley']['value'] == 1) ? 1 : 0; - $image = (!isset($this->vars['doimage']['value']) || $this->vars['doimage']['value'] == 1) ? 1 : 0; - $br = (!isset($this->vars['dobr']['value']) || $this->vars['dobr']['value'] == 1) ? 1 : 0; - return $ts->displayTarea($ret, $html, $smiley, $xcode, $image, $br); - break 1; - case 'e': - case 'edit': - return htmlspecialchars($ret, ENT_QUOTES); - break 1; - case 'p': - case 'preview': - $html = !empty($this->vars['dohtml']['value']) ? 1 : 0; - $xcode = (!isset($this->vars['doxcode']['value']) || $this->vars['doxcode']['value'] == 1) ? 1 : 0; - $smiley = (!isset($this->vars['dosmiley']['value']) || $this->vars['dosmiley']['value'] == 1) ? 1 : 0; - $image = (!isset($this->vars['doimage']['value']) || $this->vars['doimage']['value'] == 1) ? 1 : 0; - $br = (!isset($this->vars['dobr']['value']) || $this->vars['dobr']['value'] == 1) ? 1 : 0; - return $ts->previewTarea($ret, $html, $smiley, $xcode, $image, $br); - break 1; - case 'f': - case 'formpreview': - return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES); - break 1; - case 'n': - case 'none': - default: - break 1; - } - break; - case XOBJ_DTYPE_ARRAY: - switch (strtolower($format)) { - case 'n': - case 'none': - break 1; - default: - if (!is_array($ret)) { - if ($ret != '') { - $ret = unserialize($ret); - } - $ret = is_array($ret) ? $ret : array(); - } - return $ret; - break 1; - } - break; - case XOBJ_DTYPE_SOURCE: - switch (strtolower($format)) { - case 's': - case 'show': - break 1; - case 'e': - case 'edit': - return htmlspecialchars($ret, ENT_QUOTES); - break 1; - case 'p': - case 'preview': - return $ts->stripSlashesGPC($ret); - break 1; - case 'f': - case 'formpreview': - return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES); - break 1; - case 'n': - case 'none': - default: - break 1; - } - break; - default: - if ($this->vars[$key]['options'] != '' && $ret != '') { - switch (strtolower($format)) { - case 's': - case 'show': - $selected = explode('|', $ret); - $options = explode('|', $this->vars[$key]['options']); - $i = 1; - $ret = array(); - foreach ($options as $op) { - if (in_array($i, $selected)) { - $ret[] = $op; - } - $i++; - } - return implode(', ', $ret); - case 'e': - case 'edit': - $ret = explode('|', $ret); - break 1; - default: - break 1; - } - } - break; - } - return $ret; - } - - /** - * clean values of all variables of the object for storage. - * also add slashes whereever needed - * - * @return bool true if successful - * @access public - */ - public function cleanVars() - { - $ts = MyTextSanitizer::getInstance(); - $existing_errors = $this->getErrors(); - $this->_errors = array(); - foreach ($this->vars as $k => $v) { - $cleanv = $v['value']; - if (!$v['changed']) { - } else { - $cleanv = is_string($cleanv) ? trim($cleanv) : $cleanv; - switch ($v['data_type']) { - case XOBJ_DTYPE_TXTBOX: - if ($v['required'] && $cleanv != '0' && $cleanv == '') { - $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k)); - continue; - } - if (isset($v['maxlength']) && strlen($cleanv) > intval($v['maxlength'])) { - $this->setErrors(sprintf(_XOBJ_ERR_SHORTERTHAN, $k, intval($v['maxlength']))); - continue; - } - if (!$v['not_gpc']) { - $cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv)); - } else { - $cleanv = $ts->censorString($cleanv); - } - break; - case XOBJ_DTYPE_TXTAREA: - if ($v['required'] && $cleanv != '0' && $cleanv == '') { - $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k)); - continue; - } - if (!$v['not_gpc']) { - $cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv)); - } else { - $cleanv = $ts->censorString($cleanv); - } - break; - case XOBJ_DTYPE_SOURCE: - if (!$v['not_gpc']) { - $cleanv = $ts->stripSlashesGPC($cleanv); - } - break; - case XOBJ_DTYPE_INT: - $cleanv = intval($cleanv); - break; - - case XOBJ_DTYPE_EMAIL: - if ($v['required'] && $cleanv == '') { - $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k)); - continue; - } - if ($cleanv != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i", $cleanv)) { - $this->setErrors("Invalid Email"); - continue; - } - if (!$v['not_gpc']) { - $cleanv = $ts->stripSlashesGPC($cleanv); - } - break; - case XOBJ_DTYPE_URL: - if ($v['required'] && $cleanv == '') { - $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k)); - continue; - } - if ($cleanv != '' && !preg_match("/^http[s]*:\/\//i", $cleanv)) { - $cleanv = 'http://' . $cleanv; - } - if (!$v['not_gpc']) { - $cleanv = $ts->stripSlashesGPC($cleanv); - } - break; - case XOBJ_DTYPE_ARRAY: - $cleanv = (array)$cleanv; - $cleanv = serialize($cleanv); - break; - case XOBJ_DTYPE_STIME: - case XOBJ_DTYPE_MTIME: - case XOBJ_DTYPE_LTIME: - $cleanv = !is_string($cleanv) ? intval($cleanv) : strtotime($cleanv); - break; - case XOBJ_DTYPE_FLOAT: - $cleanv = floatval($cleanv); - break; - case XOBJ_DTYPE_DECIMAL: - $cleanv = doubleval($cleanv); - break; - case XOBJ_DTYPE_ENUM: - if (!in_array($cleanv, $v['enumeration'])) { - $this->setErrors("Invalid Enumeration"); - continue; - } - break; - default: - break; - } - } - $this->cleanVars[$k] = str_replace('\\"', '"', $cleanv); - unset($cleanv); - } - if (count($this->_errors) > 0) { - $this->_errors = array_merge($existing_errors, $this->_errors); - return false; - } - $this->_errors = array_merge($existing_errors, $this->_errors); - $this->unsetDirty(); - return true; - } - - /** - * dynamically register additional filter for the object - * - * @param string $filtername name of the filter - * @access public - */ - public function registerFilter($filtername) - { - $this->_filters[] = $filtername; - } - - /** - * load all additional filters that have been registered to the object - * - * @access private - */ - private function _loadFilters() - { - static $loaded; - if (isset($loaded)) { - return; - } - $loaded = 1; - - $path = empty($this->plugin_path) ? dirname(__FILE__) . '/filters' : $this->plugin_path; - if (file_exists($file = $path . '/filter.php')) { - include_once $file; - foreach ($this->_filters as $f) { - if (file_exists($file = $path . '/' . strtolower($f) . 'php')) { - include_once $file; - } - } - } - } - - /** - * load all local filters for the object - * - * Filter distribution: - * In each module folder there is a folder "filter" containing filter files with, - * filename: [name_of_target_class][.][function/action_name][.php]; - * function name: [dirname][_][name_of_target_class][_][function/action_name]; - * parameter: the target object - * - * @param string $method function or action name - * @access public - */ - public function loadFilters($method) - { - $this->_loadFilters(); - - - $class = get_class($this); - if (!$modules_active = XoopsCache::read('system_modules_active')) { - $xoops = Xoops::getInstance(); - $module_handler = $xoops->getHandlerModule(); - $modules_obj = $module_handler->getObjectsArray(new Criteria('isactive', 1)); - $modules_active = array(); - foreach (array_keys($modules_obj) as $key) { - $modules_active[] = $modules_obj[$key]->getVar('dirname'); - } - unset($modules_obj); - XoopsCache::write('system_modules_active', $modules_active); - } - foreach ($modules_active as $dirname) { - if (file_exists($file = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/filter/' . $class . '.' . $method . '.php')) { - include_once $file; - if (function_exists($class . '_' . $method)) { - call_user_func_array($dirname . '_' . $class . '_' . $method, array(&$this)); - } - } - } - } - - /** - * create a clone(copy) of the current object - * - * @access public - * @return object clone - */ - public function xoopsClone() - { - /* @var $clone XoopsObject */ - $class = get_class($this); - $clone = null; - $clone = new $class(); - foreach ($this->vars as $k => $v) { - $clone->assignVar($k, $v['value']); - } - // need this to notify the handler class that this is a newly created object - $clone->setNew(); - return $clone; - } - - /** - * add an error - * - * @param string $err_str to add - * @access public - */ - public function setErrors($err_str) - { - if (is_array($err_str)) { - $this->_errors = array_merge($this->_errors, $err_str); - } else { - $this->_errors[] = trim($err_str); - } - } - - /** - * return the errors for this object as an array - * - * @return array an array of errors - * @access public - */ - public function getErrors() - { - return $this->_errors; - } - - /** - * return the errors for this object as html - * - * @return string html listing the errors - * @access public - * @todo remove harcoded strings - */ - public function getHtmlErrors() - { - $ret = '<h4>Errors</h4>'; - if (!empty($this->_errors)) { - foreach ($this->_errors as $error) { - $ret .= $error . '<br />'; - } - } else { - $ret .= 'None<br />'; - } - return $ret; - } -} - -/** - * XOOPS object handler class. - * This class is an abstract class of handler classes that are responsible for providing - * data access mechanisms to the data source of its corresponsing data objects - * - * @package kernel - * @abstract - * @author Kazumi Ono <on...@xo...> - * @copyright copyright © 2000 The XOOPS Project - */ -class XoopsObjectHandler -{ - /** - * holds referenced to {@link XoopsDatabase} class object - * - * @var XoopsDatabase - * @see XoopsDatabase - * @access protected - */ - public $db; - - /** - * called from child classes only - * - * @param XoopsDatabase $db reference to the {@link XoopsDatabase} object - * @access protected - */ - public function __construct($db) - { - $this->db = $db; - } - - /** - * creates a new object - * - * @abstract - */ - public function create() - { - - } - - /** - * gets a value object - * - * @param int $int_id - * @abstract - */ - public function get($int_id) - { - - } - - /** - * insert/update object - * - * @param object $object - * @abstract - */ - public function insert($object) - { - } - - /** - * delete object from database - * - * @param object $object - * @abstract - */ - public function delete($object) - { - } -} - -/** - * Persistable Object Handler class. - * - * @author Taiwen Jiang <ph...@us...> - * @author Jan Keller Pedersen <mit...@xo...> - * @copyright copyright (c) The XOOPS project - * @package kernel - */ -class XoopsPersistableObjectHandler extends XoopsObjectHandler -{ - /** - * holds reference to custom extended object handler - * - * var object - * - * @access private - */ - /** - * static protected - */ - protected $handler; - - /** - * holds reference to predefined extended object handlers: read, stats, joint, write, sync - * - * The handlers hold methods for different purposes, which could be all put together inside of current class. - * However, load codes only if they are necessary, thus they are now splitted out. - * - * var array of objects - * - * @access private - */ - private $handlers = array('read' => null, 'stats' => null, 'joint' => null, 'write' => null, 'sync' => null); - - /** - * Information about the class, the handler is managing - * - * @var string - * @access public - */ - public $table; - - /** - * @var string - */ - public $keyName; - - /** - * @var string - */ - public $className; - - /** - * @var string - */ - public $table_link; - - /** - * @var string - */ - public $identifierName; - - /** - * @var string - */ - public $field_link; - - /** - * @var string - */ - public $field_object; - - /** - * @var string - */ - public $keyName_link; - - /** - * Constructor - * - * @access protected - * @param null|XoopsDatabase $db {@link XoopsDatabase} object - * @param string $table Name of database table - * @param string $className Name of Class, this handler is managing - * @param string $keyName Name of the property holding the key - * @param string $identifierName Name of the property holding an identifier name (title, name ...), used on getList() - */ - public function __construct(XoopsDatabase $db = null, $table = '', $className = '', $keyName = '', $identifierName = '') - { - $db = XoopsDatabaseFactory::getDatabaseConnection(); - $table = $db->prefix($table); - parent::__construct($db); - $this->table = $table; - $this->keyName = $keyName; - $this->className = $className; - if ($identifierName) { - $this->identifierName = $identifierName; - } - } - - /** - * Set custom handler - * - * @access protected - * - * @param string|object $handler - * @param array|null $args - * @param string|null $path - * @return object|null - */ - public function setHandler($handler = null, $args = null, $path = null) - { - $this->handler = null; - if (is_object($handler)) { - $this->handler = $handler; - } else { - if (is_string($handler)) { - $xmf = XoopsModelFactory::getInstance(); - $this->handler = $xmf->loadHandler($this, $handler, $args, $path); - } - } -... [truncated message content] |