From: <tr...@us...> - 2011-10-08 20:35:47
|
Revision: 7814 http://xoops.svn.sourceforge.net/xoops/?rev=7814&view=rev Author: trabis Date: 2011-10-08 20:35:39 +0000 (Sat, 08 Oct 2011) Log Message: ----------- Finishing kernel and class/model refactoring Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/database/database.php 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/class/model/stats.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/sync.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/write.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/xoopsmodel.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/module.textsanitizer.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/smarty/xoops_plugins/resource.db.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/avatar.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/block.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/config.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/image.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/module.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/object.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/privmessage.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/session.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/tplfile.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/tplset.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/user.php Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/database/database.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/database/database.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/database/database.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -135,6 +135,7 @@ /** * @param $result + * @return array * @abstract */ function fetchArray($result) 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 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/joint.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -41,8 +41,9 @@ * Validate information for the linkship * * @access private + * @return bool|null */ - function validateLinks() + 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); @@ -57,14 +58,14 @@ /** * get a list of objects matching a condition joint with another related object * - * @param object $criteria {@link CriteriaElement} to match + * @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} */ - function getByLink($criteria = null, $fields = null, $asObject = true, $field_link = null, $field_object = null) + 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; @@ -125,10 +126,10 @@ /** * Count of objects matching a condition * - * @param object $criteria {@link CriteriaElement} to match + * @param CriteriaElement|null $criteria {@link CriteriaElement} to match * @return int count of objects */ - function getCountByLink($criteria = null) + public function getCountByLink(CriteriaElement $criteria = null) { if (!$this->validateLinks()) { return null; @@ -150,10 +151,10 @@ /** * array of count of objects matching a condition of, groupby linked object keyname * - * @param object $criteria {@link CriteriaElement} to match + * @param CriteriaElement $criteria {@link CriteriaElement} to match * @return int count of objects */ - function getCountsByLink($criteria = null) + public function getCountsByLink(CriteriaElement $criteria = null) { if (!$this->validateLinks()) { return null; @@ -179,10 +180,10 @@ * upate objects matching a condition against linked objects * * @param array $data array of key => value - * @param object $criteria {@link CriteriaElement} to match + * @param CriteriaElement|null $criteria {@link CriteriaElement} to match * @return int count of objects */ - function updateByLink($data, $criteria = null) + function updateByLink($data, CriteriaElement $criteria = null) { if (!$this->validateLinks()) { return null; @@ -203,10 +204,10 @@ /** * Delete objects matching a condition against linked objects * - * @param object $criteria {@link CriteriaElement} to match + * @param CriteriaElement|null $criteria {@link CriteriaElement} to match * @return int count of objects */ - function deleteByLink($criteria = null) + function deleteByLink(CriteriaElement $criteria = null) { if (!$this->validateLinks()) { return null; 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 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/read.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -32,13 +32,13 @@ /** * get all objects matching a condition * - * @param object $criteria {@link CriteriaElement} to match + * @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} */ - function getAll(CriteriaElement $criteria = null, $fields = null, $asObject = true, $id_as_key = true) + 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)) { @@ -99,12 +99,12 @@ * * For performance consideration, getAll() is recommended * - * @param object $criteria {@link CriteriaElement} conditions to be met + * @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 */ - function getObjects(CriteriaElement $criteria = null, $id_as_key = false, $as_object = true) + 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; @@ -113,12 +113,12 @@ /** * Retrieve a list of objects data * - * @param object $criteria {@link CriteriaElement} conditions to be met + * @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 */ - function getList(CriteriaElement $criteria = null, $limit = 0, $start = 0) + public function getList(CriteriaElement $criteria = null, $limit = 0, $start = 0) { $ret = array(); if ($criteria == null) { @@ -154,7 +154,7 @@ /** * get IDs of objects matching a condition * - * @param object $criteria {@link CriteriaElement} to match + * @param CriteriaElement|null $criteria {@link CriteriaElement} to match * @return array of object IDs */ function getIds(CriteriaElement $criteria = null) Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/stats.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/stats.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/stats.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -32,10 +32,10 @@ /** * count objects matching a condition * - * @param object $criteria {@link CriteriaElement} to match + * @param CriteriaElement|null $criteria {@link CriteriaElement} to match * @return int count of objects */ - function getCount($criteria = null) + public function getCount(CriteriaElement $criteria = null) { $field = ''; $groupby = false; @@ -69,10 +69,10 @@ /** * get counts matching a condition * - * @param object $criteria {@link CriteriaElement} to match - * @return array of conunts + * @param CriteriaElement|null $criteria {@link CriteriaElement} to match + * @return array of counts */ - function getCounts($criteria = null) + public function getCounts(CriteriaElement $criteria = null) { $ret = array(); $sql_where = ''; Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/sync.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/sync.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/sync.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -46,7 +46,7 @@ * @param string $field_object field of current object for JOIN; deprecated, for backward compat * @return bool true on success */ - function cleanOrphan($table_link = '', $field_link = '', $field_object = '') + public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') { if (!empty($table_link)) { $this->handler->table_link = $table_link; @@ -75,7 +75,7 @@ . " LEFT JOIN `{$this->handler->table_link}` AS aa ON `{$this->handler->table}`.`{$this->handler->field_object}` = aa.`{$this->handler->field_link}`" . " WHERE (aa.`{$this->handler->field_link}` IS NULL)"; } - if (!$result = $this->handler->db->queryF($sql)) { + if (!$this->handler->db->queryF($sql)) { return false; } return true; @@ -84,10 +84,10 @@ /** * Synchronizing objects * @deprecated - * + * * @return bool true on success */ - function synchronization() + public function synchronization() { $retval = $this->cleanOrphan(); return $retval; Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/write.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/write.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/write.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -37,10 +37,12 @@ * CleanVars only contains changed and cleaned variables * Reference is used for PHP4 compliance * + * @param XoopsObject$object + * * @return bool true if successful * @access public */ - function cleanVars(XoopsObject &$object) + public function cleanVars(XoopsObject &$object) { $ts = MyTextSanitizer::getInstance(); $errors = array(); @@ -91,8 +93,6 @@ $cleanv = trim($cleanv); if (!$v['not_gpc']) { $cleanv = $ts->stripSlashesGPC($cleanv); - } else { - $cleanv = $cleanv; } $cleanv = str_replace('\\"', '"', $this->handler->db->quote($cleanv)); break; @@ -178,11 +178,11 @@ /** * insert an object into the database * - * @param object $object {@link XoopsObject} reference to object + * @param XoopsObject $object {@link XoopsObject} reference to object * @param bool $force flag to force the query execution despite security settings * @return mixed object ID */ - function insert(XoopsObject &$object, $force = true) + public function insert(XoopsObject &$object, $force = true) { if (!(class_exists($this->handler->className) && $object instanceof $this->handler->className)) { trigger_error("Object '" . get_class($object) . "' is not an instance of '" . $this->handler->className . "'", E_USER_NOTICE); @@ -208,7 +208,7 @@ trigger_error("Data entry is not inserted - no variable is changed in object of '" . get_class($object) . "'", E_USER_NOTICE); return $object->getVar($this->handler->keyName); } - if (!$result = $this->handler->db->{$queryFunc}($sql)) { + if (!$this->handler->db->{$queryFunc}($sql)) { return false; } if (!$object->getVar($this->handler->keyName) && $object_id = $this->handler->db->getInsertId()) { @@ -220,7 +220,7 @@ $keys[] = " `{$k}` = {$v}"; } $sql = "UPDATE `" . $this->handler->table . "` SET " . implode(",", $keys) . " WHERE `" . $this->handler->keyName . "` = " . $this->handler->db->quote($object->getVar($this->handler->keyName)); - if (!$result = $this->handler->db->{$queryFunc}($sql)) { + if (!$this->handler->db->{$queryFunc}($sql)) { return false; } } @@ -230,11 +230,11 @@ /** * delete an object from the database * - * @param object $object {@link XoopsObject} reference to the object to delete + * @param XoopsObject $object {@link XoopsObject} reference to the object to delete * @param bool $force * @return bool FALSE if failed. */ - function delete(XoopsObject &$object, $force = false) + public function delete(XoopsObject &$object, $force = false) { if (!(class_exists($this->handler->className) && $object instanceof $this->handler->className)) { trigger_error("Object '" . get_class($object) . "' is not an instance of '" . $this->handler->className . "'", E_USER_NOTICE); @@ -258,12 +258,12 @@ /** * delete all objects matching the conditions * - * @param object $criteria {@link CriteriaElement} with conditions to meet + * @param CriteriaElement|null $criteria {@link CriteriaElement} with conditions to meet * @param bool $force force to delete * @param bool $asObject delete in object way: instantiate all objects and delte one by one * @return bool */ - function deleteAll(CriteriaElement $criteria = null, $force = true, $asObject = false) + public function deleteAll(CriteriaElement $criteria = null, $force = true, $asObject = false) { if ($asObject) { $objects = $this->handler->getAll($criteria); @@ -290,11 +290,11 @@ * * @param string $fieldname Name of the field * @param mixed $fieldvalue Value to write - * @param object $criteria {@link CriteriaElement} + * @param CriteriaElement|null $criteria {@link CriteriaElement} * @param bool $force force to query * @return bool */ - function updateAll($fieldname, $fieldvalue, CriteriaElement $criteria = null, $force = false) + public function updateAll($fieldname, $fieldvalue, CriteriaElement $criteria = null, $force = false) { $set_clause = "`{$fieldname}` = "; if (is_numeric($fieldvalue)) { Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/xoopsmodel.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/xoopsmodel.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/xoopsmodel.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -102,8 +102,7 @@ /** * holds referenced to handler object * - * @var object - * @param object $handler reference to {@link XoopsPersistableObjectHandler} + * @var XoopsPersistableObjectHandler $handler reference to {@link XoopsPersistableObjectHandler} * @access protected */ protected $handler; @@ -111,8 +110,8 @@ /** * XoopsModelAbstract::setHandler() * - * @param object $handler reference to {@link XoopsPersistableObjectHandler} - * @return + * @param XoopsPersistableObjectHandler $handler reference to {@link XoopsPersistableObjectHandler} + * @return true */ function setHandler(XoopsPersistableObjectHandler $handler) { @@ -124,7 +123,7 @@ * XoopsModelAbstract::setVars() * * @param mixed $args - * @return + * @return true */ function setVars($args) { Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/module.textsanitizer.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/module.textsanitizer.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/module.textsanitizer.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -532,7 +532,6 @@ * * @param string $text * @return string - * @deprecated */ function censorString(&$text) { Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/smarty/xoops_plugins/resource.db.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/smarty/xoops_plugins/resource.db.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/smarty/xoops_plugins/resource.db.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -21,6 +21,7 @@ return false; } if (is_object($tpl)) { + /* @var $tpl XoopsTplfile */ $tpl_source = $tpl->getVar('tpl_source', 'n'); } else { $fp = fopen($tpl, 'r'); @@ -37,6 +38,7 @@ return false; } if (is_object($tpl)) { + /* @var $tpl XoopsTplfile */ $tpl_timestamp = $tpl->getVar('tpl_lastmodified', 'n'); } else { $tpl_timestamp = filemtime($tpl); @@ -65,7 +67,8 @@ } $tplset = $xoopsConfig['template_set']; $theme = isset($xoopsConfig['theme_set']) ? $xoopsConfig['theme_set'] : 'default'; - $tplfile_handler =& xoops_gethandler('tplfile'); + /* @var $tplfile_handler XoopsTplfileHandler */ + $tplfile_handler = xoops_gethandler('tplfile'); // If we're not using the "default" template set, then get the templates from the DB if ($tplset != "default") { $tplobj = $tplfile_handler->find($tplset, null, null, null, $tpl_name, true); @@ -79,6 +82,7 @@ if (!count($tplobj)) { return $cache[$tpl_name] = false; } + /* @var $tplobj XoopsTplfile */ $tplobj = $tplobj[0]; $module = $tplobj->getVar('tpl_module', 'n'); $type = $tplobj->getVar('tpl_type', 'n'); Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/avatar.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/avatar.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/avatar.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -225,7 +225,7 @@ $sql = sprintf("DELETE FROM %s WHERE user_id = %u", $this->db->prefix('avatar_user_link'), $user_id); $this->db->query($sql); $sql = sprintf("INSERT INTO %s (avatar_id, user_id) VALUES (%u, %u)", $this->db->prefix('avatar_user_link'), $avatar_id, $user_id); - if (!$result = $this->db->query($sql)) { + if (!$this->db->query($sql)) { return false; } return true; Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/block.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/block.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/block.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -30,7 +30,7 @@ /** * Constructor * - * @param int $id + * @param int|array $id **/ public function __construct($id = null) { Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/config.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/config.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/config.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -92,6 +92,7 @@ */ public function getConfig($id, $withoptions = false) { + /* @var $config XoopsConfigItem */ $config = $this->_cHandler->get($id); if ($withoptions == true) { $config->setConfOptions($this->getConfigOptions(new Criteria('conf_id', $id))); @@ -162,11 +163,10 @@ * * @param CriteriaElement|null $criteria {@link CriteriaElement} * @param bool $id_as_key Use the configs' ID as keys? - * @param bool $with_options get the options now? * * @return array Array of {@link XoopsConfigItem} objects */ - public function getConfigs(CriteriaElement $criteria = null, $id_as_key = false, $with_options = false) + public function getConfigs(CriteriaElement $criteria = null, $id_as_key = false) { return $this->_cHandler->getObjects($criteria, $id_as_key); } Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/image.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/image.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/image.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -210,7 +210,7 @@ if ($image->isNew()) { $image_id = $this->db->genId('image_image_id_seq'); $sql = sprintf("INSERT INTO %s (image_id, image_name, image_nicename, image_mimetype, image_created, image_display, image_weight, imgcat_id) VALUES (%u, %s, %s, %s, %u, %u, %u, %u)", $this->db->prefix('image'), $image_id, $this->db->quoteString($image_name), $this->db->quoteString($image_nicename), $this->db->quoteString($image_mimetype), time(), $image_display, $image_weight, $imgcat_id); - if (!$result = $this->db->query($sql)) { + if (!$this->db->query($sql)) { return false; } if (empty($image_id)) { @@ -218,7 +218,7 @@ } if (isset($image_body) && $image_body != '') { $sql = sprintf("INSERT INTO %s (image_id, image_body) VALUES (%u, %s)", $this->db->prefix('imagebody'), $image_id, $this->db->quoteString($image_body)); - if (!$result = $this->db->query($sql)) { + if (!$this->db->query($sql)) { $sql = sprintf("DELETE FROM %s WHERE image_id = %u", $this->db->prefix('image'), $image_id); $this->db->query($sql); return false; @@ -227,12 +227,12 @@ $image->assignVar('image_id', $image_id); } else { $sql = sprintf("UPDATE %s SET image_name = %s, image_nicename = %s, image_display = %u, image_weight = %u, imgcat_id = %u WHERE image_id = %u", $this->db->prefix('image'), $this->db->quoteString($image_name), $this->db->quoteString($image_nicename), $image_display, $image_weight, $imgcat_id, $image_id); - if (!$result = $this->db->query($sql)) { + if (!$this->db->query($sql)) { return false; } if (isset($image_body) && $image_body != '') { $sql = sprintf("UPDATE %s SET image_body = %s WHERE image_id = %u", $this->db->prefix('imagebody'), $this->db->quoteString($image_body), $image_id); - if (!$result = $this->db->query($sql)) { + if (!$this->db->query($sql)) { $this->db->query(sprintf("DELETE FROM %s WHERE image_id = %u", $this->db->prefix('image'), $image_id)); return false; } @@ -258,7 +258,7 @@ $id = $image->getVar('image_id'); $sql = sprintf("DELETE FROM %s WHERE image_id = %u", $this->db->prefix('image'), $id); - if (!$result = $this->db->query($sql)) { + if (!$this->db->query($sql)) { return false; } $sql = sprintf("DELETE FROM %s WHERE image_id = %u", $this->db->prefix('imagebody'), $id); Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/module.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/module.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/module.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -452,7 +452,7 @@ * @param int $id ID of the module * @return XoopsModule|false on fail */ - function get($id) + function get($id = null) { static $_cachedModule_dirname; static $_cachedModule_mid; 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 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/object.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -826,9 +826,29 @@ /** * @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 Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/privmessage.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/privmessage.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/privmessage.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -31,9 +31,8 @@ /** * constructor **/ - function XoopsPrivmessage() + public function __construct() { - $this->XoopsObject(); $this->initVar('msg_id', XOBJ_DTYPE_INT, null, false); $this->initVar('msg_image', XOBJ_DTYPE_OTHER, null, false, 100); $this->initVar('subject', XOBJ_DTYPE_TXTBOX, null, true, 255); @@ -45,73 +44,82 @@ } /** - * Returns Class Base Variable msg_id + * @param string $format + * @return mixed */ - function id($format = 'N') + public function id($format = 'n') { return $this->getVar('msg_id', $format); } /** - * Returns Class Base Variable msg_id + * @param string $format + * @return mixed */ - function msg_id($format = '') + public function msg_id($format = '') { return $this->getVar('msg_id', $format); } /** - * Returns Class Base Variable msg_image + * @param string $format + * @return mixed */ - function msg_image($format = '') + public function msg_image($format = '') { return $this->getVar('msg_image', $format); } /** - * Returns Class Base Variable subject + * @param string $format + * @return mixed */ - function subject($format = '') + public function subject($format = '') { return $this->getVar('subject', $format); } /** - * Returns Class Base Variable not_id + * @param string $format + * @return mixed */ - function from_userid($format = '') + public function from_userid($format = '') { return $this->getVar('from_userid', $format); } /** - * Returns Class Base Variable to_userid + * @param string $format + * @return mixed */ - function to_userid($format = '') - { + public function to_userid($format = '') + { return $this->getVar('to_userid', $format); - } + } /** - * Returns Class Base Variable msg_time + * @param string $format + * @return mixed */ - function msg_time($format = '') + public function msg_time($format = '') { return $this->getVar('msg_time', $format); } /** - * Returns Class Base Variable msg_text + * @param string $format + * @return mixed */ - function msg_text($format = '') + public function msg_text($format = '') { return $this->getVar('msg_text', $format); } /** - * Returns Class Base Variable read_msg + * @param string $format + * @return mixed */ - function read_msg($format = '') + public function read_msg($format = '') { return $this->getVar('read_msg', $format); } @@ -124,131 +132,43 @@ * This class is responsible for providing data access mechanisms to the data source * of XOOPS private message class objects. * - * @package kernel + * @package kernel * - * @author Kazumi Ono <on...@xo...> - * @copyright copyright (c) 2000-2003 The XOOPS Project (http://www.xoops.org) + * @author Kazumi Ono <on...@xo...> + * @copyright copyright (c) 2000-2003 The XOOPS Project (http://www.xoops.org) * - * @version $Revision: 1217 $ - $Date: 2008-01-02 01:04:41 +0800 (星期三, 02 一月 2008) $ + * @version $Revision: 1217 $ - $Date: 2008-01-02 01:04:41 +0800 (星期三, 02 一月 2008) $ */ -class XoopsPrivmessageHandler extends XoopsObjectHandler +class XoopsPrivmessageHandler extends XoopsPersistableObjectHandler { /** - * Create a new {@link XoopsPrivmessage} object - * @param bool $isNew Flag as "new"? - * @return object - **/ - function create($isNew = true) - { - $pm = new XoopsPrivmessage(); - if ($isNew) { - $pm->setNew(); - } - return $pm; - } - - /** - * Load a {@link XoopsPrivmessage} object - * @param int $id ID of the message - * @return object - **/ - function get($id) - { - $pm = false; - $id = intval($id); - if ($id > 0) { - $sql = 'SELECT * FROM ' . $this->db->prefix('priv_msgs') . ' WHERE msg_id=' . $id; - if (!$result = $this->db->query($sql)) { - return $pm; - } - $numrows = $this->db->getRowsNum($result); - if ($numrows == 1) { - $pm = new XoopsPrivmessage(); - $pm->assignVars($this->db->fetchArray($result)); - } - } - return $pm; - } - - /** - * Insert a message in the database + * Constructor * - * @param object $pm {@link XoopsPrivmessage} object - * @param bool $force flag to force the query execution skip request method check, which might be required in some situations - * @return bool - **/ - function insert(&$pm, $force = false) + * @param XoopsDatabase|null $db {@link XoopsDatabase} + */ + public function __construct(XoopsDatabase $db = null) { - /** - * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 - */ - if (!is_a($pm, 'xoopsprivmessage')) { - return false; - } - - if (!$pm->isDirty()) { - return true; - } - if (!$pm->cleanVars()) { - return false; - } - foreach ($pm->cleanVars as $k => $v) { - ${$k} = $v; - } - if ($pm->isNew()) { - $msg_id = $this->db->genId('priv_msgs_msg_id_seq'); - $sql = sprintf("INSERT INTO %s (msg_id, msg_image, subject, from_userid, to_userid, msg_time, msg_text, read_msg) VALUES (%u, %s, %s, %u, %u, %u, %s, %u)", $this->db->prefix('priv_msgs'), $msg_id, $this->db->quoteString($msg_image), $this->db->quoteString($subject), $from_userid, $to_userid, time(), $this->db->quoteString($msg_text), 0); - } else { - $sql = sprintf("UPDATE %s SET msg_image = %s, subject = %s, from_userid = %u, to_userid = %u, msg_text = %s, read_msg = %u WHERE msg_id = %u", $this->db->prefix('priv_msgs'), $this->db->quoteString($msg_image), $this->db->quoteString($subject), $from_userid, $to_userid, $this->db->quoteString($msg_text), $read_msg, $msg_id); - } - $queryFunc = empty($force) ? "query" : "queryF"; - if (!$result = $this->db->{$queryFunc}($sql)) { - return false; - } - if (empty($msg_id)) { - $msg_id = $this->db->getInsertId(); - } - $pm->assignVar('msg_id', $msg_id); - return true; + parent::__construct($db, 'priv_msgs', 'XoopsPrivmessage', 'msg_id', 'subject'); } /** - * Delete from the database - * @param object $pm {@link XoopsPrivmessage} object - * @return bool - **/ - function delete(&$pm) - { - /** - * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 - */ - if (!is_a($pm, 'xoopsprivmessage')) { - return false; - } - - if (!$result = $this->db->query(sprintf("DELETE FROM %s WHERE msg_id = %u", $this->db->prefix('priv_msgs'), $pm->getVar('msg_id')))) { - return false; - } - return true; - } - - /** * Load messages from the database - * @param object $criteria {@link CriteriaElement} object - * @param bool $id_as_key use ID as key into the array? - * @return array Array of {@link XoopsPrivmessage} objects + * + * @param CriteriaElement|null $criteria {@link CriteriaElement} object + * @param bool $id_as_key use ID as key into the array? + * @return array Array of {@link XoopsPrivmessage} objects **/ - function getObjects($criteria = null, $id_as_key = false) + public function getObjects(CriteriaElement $criteria = null, $id_as_key = false) { $ret = array(); $limit = $start = 0; $sql = 'SELECT * FROM ' . $this->db->prefix('priv_msgs'); if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { $sql .= ' ' . $criteria->renderWhere(); - $sort = ! in_array($criteria->getSort(), array( - 'msg_id' , - 'msg_time' , - 'from_userid')) ? 'msg_id' : $criteria->getSort(); + $sort = !in_array($criteria->getSort(), array( + 'msg_id', + 'msg_time', + 'from_userid')) ? 'msg_id' : $criteria->getSort(); $sql .= ' ORDER BY ' . $sort . ' ' . $criteria->getOrder(); $limit = $criteria->getLimit(); $start = $criteria->getStart(); @@ -271,37 +191,13 @@ } /** - * Count message - * @param object $criteria = null {@link CriteriaElement} object - * @return int - **/ - function getCount($criteria = null) - { - $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('priv_msgs'); - if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { - $sql .= ' ' . $criteria->renderWhere(); - } - if (!$result = $this->db->query($sql)) { - return 0; - } - list ($count) = $this->db->fetchRow($result); - return $count; - } - - /** * Mark a message as read - * @param object $pm {@link XoopsPrivmessage} object - * @return bool + * + * @param XoopsPrivmessage $pm {@link XoopsPrivmessage} object + * @return bool **/ - function setRead(&$pm) + public function setRead(XoopsPrivmessage &$pm) { - /** - * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 - */ - if (!is_a($pm, 'xoopsprivmessage')) { - return false; - } - $sql = sprintf("UPDATE %s SET read_msg = 1 WHERE msg_id = %u", $this->db->prefix('priv_msgs'), $pm->getVar('msg_id')); if (!$this->db->queryF($sql)) { return false; @@ -309,4 +205,5 @@ return true; } } + ?> \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/session.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/session.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/session.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -36,7 +36,7 @@ * @var object * @access private */ - var $db; + private $db; /** * Security checking level @@ -51,7 +51,7 @@ * @var int * @access public */ - var $securityLevel = 3; + public $securityLevel = 3; /** * Enable regenerate_id @@ -59,15 +59,15 @@ * @var bool * @access public */ - var $enableRegenerateId = false; + public $enableRegenerateId = false; /** * Constructor * - * @param object $db reference to the {@link XoopsDatabase} object + * @param XoopsDatabase $db reference to the {@link XoopsDatabase} object * */ - function XoopsSessionHandler(&$db) + public function __construct($db) { $this->db = $db; } @@ -80,7 +80,7 @@ * * @return bool */ - function open($save_path, $session_name) + public function open($save_path, $session_name) { return true; } @@ -90,7 +90,7 @@ * * @return bool */ - function close() + public function close() { $this->gc_force(); return true; @@ -99,11 +99,11 @@ /** * Read a session from the database * - * @param string &sess_id ID of the session + * @param string $sess_id ID of the session * - * @return array Session data + * @return string Session data */ - function read($sess_id) + public function read($sess_id) { $sql = sprintf('SELECT sess_data, sess_ip FROM %s WHERE sess_id = %s', $this->db->prefix('session'), $this->db->quoteString($sess_id)); if (false != $result = $this->db->query($sql)) { @@ -128,7 +128,7 @@ * * @return bool **/ - function write($sess_id, $sess_data) + public function write($sess_id, $sess_data) { $sess_id = $this->db->quoteString($sess_id); $sql = sprintf('UPDATE %s SET sess_updated = %u, sess_data = %s WHERE sess_id = %s', $this->db->prefix('session'), time(), $this->db->quoteString($sess_data), $sess_id); @@ -147,10 +147,10 @@ * * @return bool **/ - function destroy($sess_id) + public function destroy($sess_id) { $sql = sprintf('DELETE FROM %s WHERE sess_id = %s', $this->db->prefix('session'), $this->db->quoteString($sess_id)); - if (!$result = $this->db->queryF($sql)) { + if (!$this->db->queryF($sql)) { return false; } return true; @@ -162,7 +162,7 @@ * @param int $expire Time in seconds until a session expires * @return bool **/ - function gc($expire) + public function gc($expire) { if (empty($expire)) { return true; @@ -176,7 +176,7 @@ /** * Force gc for situations where gc is registered but not executed **/ - function gc_force() + public function gc_force() { if (rand(1, 100) < 11) { $expire = @ini_get('session.gc_maxlifetime'); @@ -193,7 +193,7 @@ * @param bool $delete_old_session * @return bool **/ - function regenerate_id($delete_old_session = false) + public function regenerate_id($delete_old_session = false) { $phpversion = phpversion(); @@ -249,7 +249,7 @@ * @param int $expire Time in seconds until a session expires * @return bool **/ - function update_cookie($sess_id = null, $expire = null) + public function update_cookie($sess_id = null, $expire = null) { global $xoopsConfig; $session_name = ($xoopsConfig['use_mysession'] && $xoopsConfig['session_name'] != '') ? $xoopsConfig['session_name'] : session_name(); Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/tplfile.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/tplfile.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/tplfile.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -34,7 +34,7 @@ * * @return XoopsTplfile */ - function __construct() + public function __construct() { $this->initVar('tpl_id', XOBJ_DTYPE_INT, null, false); $this->initVar('tpl_refid', XOBJ_DTYPE_INT, 0, false); @@ -49,89 +49,100 @@ } /** - * Returns Class Base Variable tpl_id + * @param string $format + * @return mixed */ - function id($format = 'N') + public function id($format = 'n') { return $this->getVar('tpl_id', $format); } /** - * Returns Class Base Variable tpl_id + * @param string $format + * @return mixed */ - function tpl_id($format = '') + public function tpl_id($format = '') { return $this->getVar('tpl_id', $format); } /** - * Returns Class Base Variable tpl_refid + * @param string $format + * @return mixed */ - function tpl_refid($format = '') + public function tpl_refid($format = '') { return $this->getVar('tpl_refid', $format); } /** - * Returns Class Base Variable tpl_tplset + * @param string $format + * @return mixed */ - function tpl_tplset($format = '') + public function tpl_tplset($format = '') { return $this->getVar('tpl_tplset', $format); } /** - * Returns Class Base Variable tpl_file + * @param string $format + * @return mixed */ - function tpl_file($format = '') + public function tpl_file($format = '') { return $this->getVar('tpl_file', $format); } /** - * Returns Class Base Variable tpl_desc + * @param string $format + * @return mixed */ - function tpl_desc($format = '') + public function tpl_desc($format = '') { return $this->getVar('tpl_desc', $format); } /** - * Returns Class Base Variable tpl_lastmodified + * @param string $format + * @return mixed */ - function tpl_lastmodified($format = '') + public function tpl_lastmodified($format = '') { return $this->getVar('tpl_lastmodified', $format); } /** - * Returns Class Base Variable tpl_lastimported + * @param string $format + * @return mixed */ - function tpl_lastimported($format = '') + public function tpl_lastimported($format = '') { return $this->getVar('tpl_lastimported', $format); } /** - * Returns Class Base Variable tpl_module + * @param string $format + * @return mixed */ - function tpl_module($format = '') + public function tpl_module($format = '') { return $this->getVar('tpl_module', $format); } /** - * Returns Class Base Variable tpl_type + * @param string $format + * @return mixed */ - function tpl_type($format = '') + public function tpl_type($format = '') { return $this->getVar('tpl_type', $format); } /** - * Returns Class Base Variable tpl_source + * @param string $format + * @return mixed */ - function tpl_source($format = '') + public function tpl_source($format = '') { return $this->getVar('tpl_source', $format); } @@ -142,7 +153,7 @@ * * @return unknown */ - function getSource() + public function getSource() { return $this->getVar('tpl_source'); } @@ -152,7 +163,7 @@ * * @return unknown */ - function getLastModified() + public function getLastModified() { return $this->getVar('tpl_lastmodified'); } @@ -166,32 +177,27 @@ * * @author Kazumi Ono <on...@xo...> */ -class XoopsTplfileHandler extends XoopsObjectHandler +class XoopsTplfileHandler extends XoopsPersistableObjectHandler { + /** - * create a new Tplfile + * Constructor * - * @see XoopsBlock - * @param bool $isNew is the new Tplfile new?? - * @return object XoopsTplfile reference to the new Tplfile - **/ - function create($isNew = true) + * @param XoopsDatabase|null $db {@link XoopsDatabase} + */ + public function __construct(XoopsDatabase $db = null) { - $tplfile = new XoopsTplfile(); - if ($isNew) { - $tplfile->setNew(); - } - return $tplfile; + parent::__construct($db, 'tplfile', 'XoopsTplfile', 'tpl_id', 'tpl_refid'); } /** * retrieve a specific {@link XoopsTplfile} * - * @see XoopsBlock * @param int $id tpl_id of the block to retrieve - * @return object XoopsTplfile reference to the Tplfile - **/ - function get($id, $getsource = false) + * @param bool $getsource + * @return XoopsTplfile|false + */ + public function get($id, $getsource = false) { $tplfile = false; $id = intval($id); @@ -214,20 +220,11 @@ } /** - * Enter description here... - * - * @param unknown_type $tplfile - * @return unknown + * @param XoopsTplfile $tplfile + * @return bool */ - function loadSource(&$tplfile) + public function loadSource(XoopsTplFile &$tplfile) { - /** - * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 - */ - if (!is_a($tplfile, 'xoopstplfile')) { - return false; - } - if (!$tplfile->getVar('tpl_source')) { $sql = 'SELECT tpl_source FROM ' . $this->db->prefix('tplsource') . ' WHERE tpl_id=' . $tplfile->getVar('tpl_id'); if (!$result = $this->db->query($sql)) { @@ -242,17 +239,11 @@ /** * write a new Tplfile into the database * - * @param object XoopsTplfile $block reference to the Tplfile to insert - * @return bool TRUE if succesful - **/ - function insert(&$tplfile) + * @param XoopsTplfile $tplfile + * @return bool + */ + public function insert(XoopsTplfile &$tplfile) { - /** - * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 - */ - if (!is_a($tplfile, 'xoopstplfile')) { - return false; - } if (!$tplfile->isDirty()) { return true; } @@ -265,7 +256,7 @@ if ($tplfile->isNew()) { $tpl_id = $this->db->genId('tpltpl_file_id_seq'); $sql = sprintf("INSERT INTO %s (tpl_id, tpl_module, tpl_refid, tpl_tplset, tpl_file, tpl_desc, tpl_lastmodified, tpl_lastimported, tpl_type) VALUES (%u, %s, %u, %s, %s, %s, %u, %u, %s)", $this->db->prefix('tplfile'), $tpl_id, $this->db->quoteString($tpl_module), $tpl_refid, $this->db->quoteString($tpl_tplset), $this->db->quoteString($tpl_file), $this->db->quoteString($tpl_desc), $tpl_lastmodified, $tpl_lastimported, $this->db->quoteString($tpl_type)); - if (!$result = $this->db->query($sql)) { + if (!$this->db->query($sql)) { return false; } if (empty($tpl_id)) { @@ -273,7 +264,7 @@ } if (isset($tpl_source) && $tpl_source != '') { $sql = sprintf("INSERT INTO %s (tpl_id, tpl_source) VALUES (%u, %s)", $this->db->prefix('tplsource'), $tpl_id, $this->db->quoteString($tpl_source)); - if (!$result = $this->db->query($sql)) { + if (!$this->db->query($sql)) { $this->db->query(sprintf("DELETE FROM %s WHERE tpl_id = %u", $this->db->prefix('tplfile'), $tpl_id)); return false; } @@ -281,12 +272,12 @@ $tplfile->assignVar('tpl_id', $tpl_id); } else { $sql = sprintf("UPDATE %s SET tpl_tplset = %s, tpl_file = %s, tpl_desc = %s, tpl_lastimported = %u, tpl_lastmodified = %u WHERE tpl_id = %u", $this->db->prefix('tplfile'), $this->db->quoteString($tpl_tplset), $this->db->quoteString($tpl_file), $this->db->quoteString($tpl_desc), $tpl_lastimported, $tpl_lastmodified, $tpl_id); - if (!$result = $this->db->query($sql)) { + if (!$this->db->query($sql)) { return false; } if (isset($tpl_source) && $tpl_source != '') { $sql = sprintf("UPDATE %s SET tpl_source = %s WHERE tpl_id = %u", $this->db->prefix('tplsource'), $this->db->quoteString($tpl_source), $tpl_id); - if (!$result = $this->db->query($sql)) { + if (!$this->db->query($sql)) { return false; } } @@ -295,19 +286,11 @@ } /** - * Enter description here... - * - * @param unknown_type $tplfile - * @return unknown + * @param XoopsTplfile $tplfile + * @return bool */ - function forceUpdate(&$tplfile) + public function forceUpdate(XoopsTplfile &$tplfile) { - /** - * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 - */ - if (!is_a($tplfile, 'xoopstplfile')) { - return false; - } if (!$tplfile->isDirty()) { return true; } @@ -319,12 +302,12 @@ } if (!$tplfile->isNew()) { $sql = sprintf("UPDATE %s SET tpl_tplset = %s, tpl_file = %s, tpl_desc = %s, tpl_lastimported = %u, tpl_lastmodified = %u WHERE tpl_id = %u", $this->db->prefix('tplfile'), $this->db->quoteString($tpl_tplset), $this->db->quoteString($tpl_file), $this->db->quoteString($tpl_desc), $tpl_lastimported, $tpl_lastmodified, $tpl_id); - if (!$result = $this->db->queryF($sql)) { + if (!$this->db->queryF($sql)) { return false; } if (isset($tpl_source) && $tpl_source != '') { $sql = sprintf("UPDATE %s SET tpl_source = %s WHERE tpl_id = %u", $this->db->prefix('tplsource'), $this->db->quoteString($tpl_source), $tpl_id); - if (!$result = $this->db->queryF($sql)) { + if (!$this->db->queryF($sql)) { return false; } } @@ -337,17 +320,11 @@ /** * delete a block from the database * - * @param object XoopsBlock $block reference to the block to delete - * @return bool TRUE if succesful - **/ - function delete(&$tplfile) + * @param XoopsTplfile $tplfile + * @return bool + */ + public function delete(XoopsTplfile &$tplfile) { - /** - * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 - */ - if (!is_a($tplfile, 'xoopstplfile')) { - return false; - } $id = $tplfile->getVar('tpl_id'); $sql = sprintf("DELETE FROM %s WHERE tpl_id = %u", $this->db->prefix('tplfile'), $id); if (!$result = $this->db->query($sql)) { @@ -359,12 +336,12 @@ } /** - * retrieve array of {@link XoopsBlock}s meeting certain conditions - * @param object $criteria {@link CriteriaElement} with conditions for the blocks - * @param bool $id_as_key should the blocks' bid be the key for the returned array? - * @return array {@link XoopsBlock}s matching the conditions - **/ - function getObjects($criteria = null, $getsource = false, $id_as_key = false) + * @param CriteriaElement|null $criteria + * @param bool $getsource + * @param bool $id_as_key + * @return array + */ + public function getObjects(CriteriaElement $criteria = null, $getsource = false, $id_as_key = false) { $ret = array(); $limit = $start = 0; @@ -396,34 +373,15 @@ } /** - * Get count - * - * @param array $criteria - * @return int - */ - function getCount($criteria = null) - { - $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('tplfile'); - if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { - $sql .= ' ' . $criteria->renderWhere(); - } - if (!$result = $this->db->query($sql)) { - return 0; - } - list ($count) = $this->db->fetchRow($result); - return $count; - } - - /** * getModuleTplCount * * @param string $tplset * @return array */ - function getModuleTplCount($tplset) + public function getModuleTplCount($tplset) { $ret = array(); - $sql = "SELECT tpl_module, COUNT(tpl_id) AS count FROM " . $this->db->prefix('tplfile') . " WHERE tpl_tplset='" . $tplset . "' GROUP BY tpl_module"; + $sql = "SELECT tpl_module, COUNT(tpl_id) AS count FROM " . $this->db->prefix('tplfile') . " WHERE tpl_tplset='" . $this->db->quoteString($tplset) . "' GROUP BY tpl_module"; $result = $this->db->query($sql); if (!$result) { return $ret; @@ -439,15 +397,15 @@ /** * Find Template File * - * @param string $tplset - * @param string $type - * @param string $refid - * @param string $module - * @param string $file - * @param string $getsource - * @return object + * @param string|null $tplset + * @param string|null $type + * @param string|null $refid + * @param string|null $module + * @param string|null $file + * @param bool $getsource + * @return array */ - function find($tplset = null, $type = null, $refid = null, $module = null, $file = null, $getsource = false) + public function find($tplset = null, $type = null, $refid = null, $module = null, $file = null, $getsource = false) { $criteria = new CriteriaCompo(); if (isset($tplset)) { @@ -479,11 +437,11 @@ /** * Template Exists * - * @param string $tplname - * @param string $tplset_name - * @return unknown + * @param $tplname + * @param $tplset_name + * @return bool */ - function templateExists($tplname, $tplset_name) + public function templateExists($tplname, $tplset_name) { $criteria = new CriteriaCompo(new Criteria('tpl_file', trim($tplname))); $criteria->add(new Criteria('tpl_tplset', trim($tplset_name))); Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/tplset.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/tplset.php 2011-10-08 18:30:34 UTC (rev 7813) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/tplset.php 2011-10-08 20:35:39 UTC (rev 7814) @@ -29,6 +29,7 @@ **/ class XoopsTplset extends XoopsObject { + /** * constructor **/ @@ -42,15 +43,17 @@ } /** - * Returns Class Base Variable tplset_id + * @param string $format + * @return mixed */ - function id($format = 'N') + function id($format = 'n') { return $this->getVar('tplset_id', $format); } /** - * Returns Class Base Variable tplset_id + * @param string $format + * @return mixed */ function tplset_id($format = '') { @@ -58,7 +61,8 @@ } /** - * Returns Class Base Variable tplset_name + * @param string $format + * @return mixed */ function tplset_name($format = '') { @@ -66,7 +70,8 @@ } /** - * Returns Class Base Variable tplset_desc + * @param string $format + * @return mixed */ function tplset_desc($format = '') { @@ -74,7 +79,8 @@ } /** - * Returns Class Base Variable tplset_credits + * @param string $format + * @return mixed */ function tplset_credits($format = '') { @@ -82,7 +88,8 @@ } /** - * Returns Class Base Variable tplset_created + * @param string $format + * @return mixed */ function tplset_created($format = '') { @@ -98,64 +105,31 @@ * * @author Kazumi Ono <on...@xo...> */ -class XoopsTplsetHandler extends XoopsObjectHandler +class XoopsTplsetHandler extends XoopsPersistableObjectHandler { - /** - * create a new block - * - * @see XoopsTplset - * @param bool $isNew is the new tplsets new?? - * @return object XoopsTplset reference to the new tplsets - **/ - function create($isNew = true) - { - $tplset = new XoopsTplset(); - if ($isNew) { - $tplset->setNew(); - } - return $tplset; - } /** - * retrieve a specific {@link XoopsBlock} + * Constructor * - * @see XoopsTplset - * @param int $id tplset_id of the tplsets to retrieve - * @return object XoopsTplset reference to the tplsets - **/ - function get($id) + * @param XoopsDatabase|null $db {@link XoopsDatabase} + */ + public function __construct(XoopsDatabase $db = null) { - $tplset = false; - $id = intval($id); - if ($id > 0) { - $sql = 'SELECT * FROM ' . $this->db->prefix('tplset') . ' WHERE tplset_id=' . $id; - if (!$result = $this->db->query($sql)) { - return $tplset; - } - $numrows = $this->db->getRowsNum($result); - if ($numrows == 1) { - $tplset = new XoopsTplset(); - $tplset->assignVars($this->db->fetchArray($result)); - } - } - return $tplset; + parent::__construct($db, 'tplset', 'XoopsTplset', 'tplset_id', 'tplset_name'); } /** - * retrieve a specific {@link XoopsBlock} - * - * @see XoopsTplset - * @param int $id tplset_id of the block to retrieve - * @return object XoopsTplset reference to the tplsets - **/ - function getByName($tplset_name) + * @param string $tplset_name of the block to retrieve + * @return XoopsTplset|falsereference to the tplsets + */ + public function getByName($tplset_name) { $tplset = false; $tplset_name = trim($tplset_name); if ($tplset_name != '') { $sql = 'SELECT * FROM ' . $this->db->prefix('tplset') . ' WHERE tplset_name=' . $this->db->quoteString($tplset_name); if (!$result = $this->db->query($sql)) { - return $tplset; + return false; } $numrows = $this->db->getRowsNum($result); if ($numrows == 1) { @@ -167,127 +141,12 @@ } /** - * write a new block into the database + * get a list of tplsets matching certain conditions * - * @param object XoopsTplset $block reference to the tplsets to insert - * @return bool TRUE if succesful - **/ - function insert(&$tplset) - { - /** - * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 - */ - if (!is_a($tplset, 'xoopstplset')) { - return false; - } - if (!$tplset->isDirty()) { - return true; - } - i... [truncated message content] |