From: <tr...@us...> - 2012-12-03 21:55:48
|
Revision: 10316 http://sourceforge.net/p/xoops/svn/10316 Author: trabis Date: 2012-12-03 21:55:44 +0000 (Mon, 03 Dec 2012) Log Message: ----------- Adding object dtypes to remove duplicate code in obejct and handler. It also allows to add new dtypes just by adding them to the folder. Perhaps in future we can allow developers to add their own dtypes without touching core. Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/write.php XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/object.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Debug.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Registry.php Added Paths: ----------- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Auth/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Cache/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Abstract.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Array.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Decimal.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Email.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Enum.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Float.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Int.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Ltime.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Mtime.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Other.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Source.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Stime.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Textarea.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Textbox.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Url.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype.php XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/index.html Removed Paths: ------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Cache/index.html 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 2012-12-03 01:04:45 UTC (rev 10315) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/model/write.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -35,146 +35,28 @@ { /** * Clean values of all variables of the object for storage. - * also add slashes and quote string whereever needed + * also add slashes and quote string wherever needed * * CleanVars only contains changed and cleaned variables * Reference is used for PHP4 compliance * - * @param XoopsObject$object + * @param XoopsObject $object * * @return bool true if successful * @access public */ public function cleanVars(XoopsObject &$object) { - $ts = MyTextSanitizer::getInstance(); - $errors = array(); - $vars = $object->getVars(); $object->cleanVars = array(); foreach ($vars as $k => $v) { if (!$v["changed"]) { continue; } - $cleanv = $v['value']; - switch ($v["data_type"]) { - - case XOBJ_DTYPE_TXTBOX: - if ($v['required'] && $cleanv != '0' && $cleanv == '') { - $errors[] = sprintf(_XOBJ_ERR_REQUIRED, $k); - continue; - } - if (isset($v['maxlength']) && strlen($cleanv) > intval($v['maxlength'])) { - $errors[] = sprintf(_XOBJ_ERR_SHORTERTHAN, $k, intval($v['maxlength'])); - continue; - } - if (!$v['not_gpc']) { - $cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv)); - } else { - $cleanv = $ts->censorString($cleanv); - } - $cleanv = str_replace('\\"', '"', $this->handler->db->quote($cleanv)); - break; - - case XOBJ_DTYPE_TXTAREA: - if ($v['required'] && $cleanv != '0' && $cleanv == '') { - $errors[] = sprintf(_XOBJ_ERR_REQUIRED, $k); - continue; - } - if (!$v['not_gpc']) { - if (!empty($vars['dohtml']['value'])) { - $cleanv = $ts->textFilter($cleanv); - } - $cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv)); - } else { - $cleanv = $ts->censorString($cleanv); - } - $cleanv = str_replace('\\"', '"', $this->handler->db->quote($cleanv)); - break; - - case XOBJ_DTYPE_SOURCE: - $cleanv = trim($cleanv); - if (!$v['not_gpc']) { - $cleanv = $ts->stripSlashesGPC($cleanv); - } - $cleanv = str_replace('\\"', '"', $this->handler->db->quote($cleanv)); - break; - - case XOBJ_DTYPE_EMAIL: - $cleanv = trim($cleanv); - if ($v['required'] && $cleanv == '') { - $errors[] = sprintf(_XOBJ_ERR_REQUIRED, $k); - continue; - } - if ($cleanv != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i", $cleanv)) { - $errors[] = "Invalid Email"; - continue; - } - if (!$v['not_gpc']) { - $cleanv = $ts->stripSlashesGPC($cleanv); - } - $cleanv = str_replace('\\"', '"', $this->handler->db->quote($cleanv)); - break; - - case XOBJ_DTYPE_URL: - $cleanv = trim($cleanv); - if ($v['required'] && $cleanv == '') { - $errors[] = 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); - } - $cleanv = str_replace('\\"', '"', $this->handler->db->quote($cleanv)); - break; - - case XOBJ_DTYPE_OTHER: - $cleanv = str_replace('\\"', '"', $this->handler->db->quote($cleanv)); - break; - - case XOBJ_DTYPE_INT: - $cleanv = intval($cleanv); - break; - - case XOBJ_DTYPE_FLOAT: - $cleanv = floatval($cleanv); - break; - - case XOBJ_DTYPE_DECIMAL: - $cleanv = doubleval($cleanv); - break; - - case XOBJ_DTYPE_ARRAY: - $cleanv = (array)$cleanv; - if (!$v['not_gpc']) { - $cleanv = array_map(array(&$ts, "stripSlashesGPC"), $cleanv); - } - foreach (array_keys($cleanv) as $key) { - $cleanv[$key] = str_replace('\\"', '"', addslashes($cleanv[$key])); - } - // TODO: Not encoding safe, should try base64_encode -- phppp - $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; - - default: - $cleanv = str_replace('\\"', '"', $this->handler->db->quote($cleanv)); - break; - } - $object->cleanVars[$k] = $cleanv; + $object->cleanVars[$k] = Xoops_Object_Dtype::cleanVar($object, $k); } - if (!empty($errors)) { - $object->setErrors($errors); - } $object->unsetDirty(); + $errors = $object->getErrors(); return empty($errors) ? true : false; } @@ -196,7 +78,7 @@ return $object->getVar($this->handler->keyName); } if (!$this->cleanVars($object)) { - trigger_error("Insert failed in method 'cleanVars' of object '" . get_class($object) . "'", E_USER_WARNING); + trigger_error("Insert failed in method 'cleanVars' of object '" . get_class($object) . "'" . $object->getHtmlErrors(), E_USER_WARNING); return $object->getVar($this->handler->keyName); } $queryFunc = empty($force) ? "query" : "queryF"; 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-12-03 01:04:45 UTC (rev 10315) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/kernel/object.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -318,128 +318,7 @@ 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; - } + $ret = Xoops_Object_Dtype::getVar($this, $key, $format); return $ret; } @@ -456,98 +335,10 @@ $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] = Xoops_Object_Dtype::cleanVar($this, $k); } - $this->cleanVars[$k] = str_replace('\\"', '"', $cleanv); - unset($cleanv); } if (count($this->_errors) > 0) { $this->_errors = array_merge($existing_errors, $this->_errors); @@ -616,10 +407,11 @@ $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'); + /* @var XoopsModule $module_obj */ + foreach ($modules_obj as $module_obj) { + $modules_active[] = $module_obj->getVar('dirname'); } - unset($modules_obj); + unset($modules_obj, $module_obj); Xoops_Cache::write('system_modules_active', $modules_active); } foreach ($modules_active as $dirname) { @@ -707,7 +499,7 @@ /** * 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 + * data access mechanisms to the data source of its corresponding data objects * * @package kernel * @abstract @@ -908,7 +700,7 @@ * @access protected * @param string $name handler name * @param mixed $args args - * @return object of handler {@link XoopsObjectAbstract} + * @return object of handler {@link XoopsModelAbstract} */ public function loadHandler($name, $args = null) { @@ -916,11 +708,14 @@ if (!isset($handlers[$name])) { $xmf = XoopsModelFactory::getInstance(); $handlers[$name] = $xmf->loadHandler($this, $name, $args); + $handler = $handlers[$name]; } else { - $handlers[$name]->setHandler($this); - $handlers[$name]->setVars($args); + /* @var $handler XoopsModelAbstract */ + $handler = $handlers[$name]; + $handler->setHandler($this); + $handler->setVars($args); } - return $handlers[$name]; + return $handler; /** * // Following code just kept as placeholder for PHP5 Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Auth/index.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Auth/index.html (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Auth/index.html 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Deleted: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Cache/index.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Cache/index.html 2012-12-03 01:04:45 UTC (rev 10315) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Cache/index.html 2012-12-03 21:55:44 UTC (rev 10316) @@ -1 +0,0 @@ - <script>history.go(-1);</script> \ No newline at end of file Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Cache/index.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Cache/index.html (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Cache/index.html 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Debug.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Debug.php 2012-12-03 01:04:45 UTC (rev 10315) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Debug.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -10,10 +10,12 @@ */ /** - * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ + * Debug + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license * @package class - * @since 2.6 + * @since 2.6.0 * @author trabis <lus...@gm...> * @version $Id$ */ Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Abstract.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Abstract.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Abstract.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,90 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +abstract class Xoops_Object_Dtype_Abstract +{ + /** + * @var XoopsDatabase + */ + protected $db; + + /** + * @var MytextSanitizer + */ + protected $ts; + + /** + * Sets database and sanitizer for easy access + */ + public function init() + { + $this->db = XoopsDatabaseFactory::getDatabaseConnection(); + $this->ts = MyTextSanitizer::getInstance(); + } + + /** + * @param XoopsObject $obj + * @param string $key + * + * @return mixed + */ + public function cleanVar(XoopsObject $obj, $key) + { + $value = $obj->vars[$key]['value']; + $value = str_replace('\\"', '"', $this->db->quote($value)); + return $value; + } + + /** + * @param XoopsObject $obj + * @param string $key + * @param string $format + * + * @return mixed + */ + public function getVar(XoopsObject $obj, $key, $format) + { + $value = $obj->vars[$key]['value']; + if ($obj->vars[$key]['options'] != '' && $value != '') { + switch (strtolower($format)) { + case 's': + case 'show': + $selected = explode('|', $value); + $options = explode('|', $obj->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': + return explode('|', $value); + default: + } + } + return $value; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Abstract.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Array.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Array.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Array.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,70 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class Xoops_Object_Dtype_Array extends Xoops_Object_Dtype_Abstract +{ + /** + * @param XoopsObject $obj + * @param string $key + * @param string $format + * + * @return array|mixed + */ + public function getVar(XoopsObject $obj, $key, $format) + { + $value = $obj->vars[$key]['value']; + switch (strtolower($format)) { + case 'n': + case 'none': + return $value; + default: + if (!is_array($value)) { + if ($value != '') { + $value = unserialize($value); + } + $value = is_array($value) ? $value : array(); + } + return $value; + } + } + + /** + * @param XoopsObject $obj + * @param string $key + * + * @return string + */ + public function cleanVar(XoopsObject $obj, $key) + { + $value = $obj->vars[$key]['value']; + $value = (array)$value; + if (!$obj->vars[$key]['not_gpc']) { + $value = array_map(array(&$this->ts, "stripSlashesGPC"), $value); + } + foreach (array_keys($value) as $key) { + $value[$key] = str_replace('\\"', '"', addslashes($value[$key])); + } + // TODO: Not encoding safe, should try base64_encode -- phppp + $value = "'" . serialize($value) . "'"; + return $value; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Array.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Decimal.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Decimal.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Decimal.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,38 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class Xoops_Object_Dtype_Decimal extends Xoops_Object_Dtype_Abstract +{ + + /** + * @param XoopsObject $obj + * @param string $key + * + * @return string + */ + public function cleanVar(XoopsObject $obj, $key) + { + $value = $obj->vars[$key]['value']; + $value = doubleval($value); + return $value; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Decimal.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Email.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Email.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Email.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,49 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class Xoops_Object_Dtype_Email extends Xoops_Object_Dtype_Abstract +{ + /** + * @param XoopsObject $obj + * @param string $key + * + * @return string + */ + public function cleanVar(XoopsObject $obj, $key) + { + $value = trim($obj->vars[$key]['value']); + + if ($obj->vars[$key]['required'] && $value == '') { + $obj->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $key)); + return $value; + } + if ($value != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i", $value)) { + $obj->setErrors("Invalid Email"); + return $value; + } + if (!$obj->vars[$key]['not_gpc']) { + $value = $this->ts->stripSlashesGPC($value); + } + $value = str_replace('\\"', '"', $this->db->quote($value)); + return $value; + } +} Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Email.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Enum.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Enum.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Enum.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,41 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class Xoops_Object_Dtype_Enumeration extends Xoops_Object_Dtype_Abstract +{ + /** + * @param XoopsObject $obj + * @param string $key + * + * @return string + */ + public function cleanVar(XoopsObject $obj, $key) + { + $value = $obj->vars[$key]['value']; + if (!in_array($value, $obj->vars[$key]['enumeration'])) { + $obj->setErrors("Invalid Enumeration"); + return $value; + } + $value = str_replace('\\"', '"', $this->db->quote($value)); + return $value; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Enum.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Float.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Float.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Float.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,38 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class Xoops_Object_Dtype_Float extends Xoops_Object_Dtype_Abstract +{ + + /** + * @param XoopsObject $obj + * @param string $key + * + * @return string + */ + public function cleanVar(XoopsObject $obj, $key) + { + $value = $obj->vars[$key]['value']; + $value = floatval($value); + return $value; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Float.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Int.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Int.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Int.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,65 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class Xoops_Object_Dtype_Int extends Xoops_Object_Dtype_Abstract +{ + /** + * @param XoopsObject $obj + * @param string $key + * @param string $format + * + * @return string + */ + public function getVar(XoopsObject $obj, $key, $format) + { + $value = $obj->vars[$key]['value']; + switch (strtolower($format)) { + case 's': + case 'show': + case 'e': + case 'edit': + return $this->ts->htmlSpecialChars($value); + case 'p': + case 'preview': + case 'f': + case 'formpreview': + return $this->ts->htmlSpecialChars($this->ts->stripSlashesGPC($value)); + case 'n': + case 'none': + default: + return $value; + } + } + + /** + * @param XoopsObject $obj + * @param string $key + * + * @return string + */ + public function cleanVar(XoopsObject $obj, $key) + { + $value = $obj->vars[$key]['value']; + $value = intval($value); + return $value; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Int.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Ltime.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Ltime.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Ltime.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,38 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class Xoops_Object_Dtype_Ltime extends Xoops_Object_Dtype_Abstract +{ + + /** + * @param XoopsObject $obj + * @param string $key + * + * @return string + */ + public function cleanVar(XoopsObject $obj, $key) + { + $value = $obj->vars[$key]['value']; + $value = !is_string($value) ? intval($value) : strtotime($value); + return $value; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Ltime.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Mtime.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Mtime.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Mtime.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,38 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class Xoops_Object_Dtype_Mtime extends Xoops_Object_Dtype_Abstract +{ + + /** + * @param XoopsObject $obj + * @param string $key + * + * @return string + */ + public function cleanVar(XoopsObject $obj, $key) + { + $value = $obj->vars[$key]['value']; + $value = !is_string($value) ? intval($value) : strtotime($value); + return $value; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Mtime.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Other.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Other.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Other.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,25 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class Xoops_Object_Dtype_Other extends Xoops_Object_Dtype_Abstract +{ +} Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Other.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Source.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Source.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Source.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,71 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class Xoops_Object_Dtype_Source extends Xoops_Object_Dtype_Abstract +{ + /** + * @param XoopsObject $obj + * @param string $key + * @param string $format + * + * @return string + */ + public function getVar(XoopsObject $obj, $key, $format) + { + $value = $obj->vars[$key]['value']; + switch (strtolower($format)) { + case 's': + case 'show': + return $value; + case 'e': + case 'edit': + return htmlspecialchars($value, ENT_QUOTES); + case 'p': + case 'preview': + return $this->ts->stripSlashesGPC($value); + case 'f': + case 'formpreview': + return htmlspecialchars($this->ts->stripSlashesGPC($value), ENT_QUOTES); + case 'n': + case 'none': + default: + return $value; + } + } + + /** + * @param XoopsObject $obj + * @param string $key + * + * @return string + */ + public function cleanVar(XoopsObject $obj, $key) + { + $value = trim($obj->vars[$key]['value']); + + if (!$obj->vars[$key]['not_gpc']) { + $value = $this->ts->stripSlashesGPC($value); + } + $value = str_replace('\\"', '"', $this->db->quote($value)); + return $value; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Source.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Stime.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Stime.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Stime.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,38 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class Xoops_Object_Dtype_Stime extends Xoops_Object_Dtype_Abstract +{ + + /** + * @param XoopsObject $obj + * @param string $key + * + * @return string + */ + public function cleanVar(XoopsObject $obj, $key) + { + $value = $obj->vars[$key]['value']; + $value = !is_string($value) ? intval($value) : strtotime($value); + return $value; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Stime.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Textarea.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Textarea.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Textarea.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,87 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class Xoops_Object_Dtype_Textarea extends Xoops_Object_Dtype_Abstract +{ + /** + * @param XoopsObject $obj + * @param string $key + * @param string $format + * + * @return mixed|string + */ + public function getVar(XoopsObject $obj, $key, $format) + { + $value = $obj->vars[$key]['value']; + switch (strtolower($format)) { + case 's': + case 'show': + $html = !empty($obj->vars['dohtml']['value']) ? 1 : 0; + $xcode = (!isset($obj->vars['doxcode']['value']) || $obj->vars['doxcode']['value'] == 1) ? 1 : 0; + $smiley = (!isset($obj->vars['dosmiley']['value']) || $obj->vars['dosmiley']['value'] == 1) ? 1 : 0; + $image = (!isset($obj->vars['doimage']['value']) || $obj->vars['doimage']['value'] == 1) ? 1 : 0; + $br = (!isset($obj->vars['dobr']['value']) || $obj->vars['dobr']['value'] == 1) ? 1 : 0; + return $this->ts->displayTarea($value, $html, $smiley, $xcode, $image, $br); + + case 'e': + case 'edit': + return htmlspecialchars($value, ENT_QUOTES); + case 'p': + case 'preview': + $html = !empty($obj->vars['dohtml']['value']) ? 1 : 0; + $xcode = (!isset($obj->vars['doxcode']['value']) || $obj->vars['doxcode']['value'] == 1) ? 1 : 0; + $smiley = (!isset($obj->vars['dosmiley']['value']) || $obj->vars['dosmiley']['value'] == 1) ? 1 : 0; + $image = (!isset($obj->vars['doimage']['value']) || $obj->vars['doimage']['value'] == 1) ? 1 : 0; + $br = (!isset($obj->vars['dobr']['value']) || $obj->vars['dobr']['value'] == 1) ? 1 : 0; + return $this->ts->previewTarea($value, $html, $smiley, $xcode, $image, $br); + case 'f': + case 'formpreview': + return htmlspecialchars($this->ts->stripSlashesGPC($value), ENT_QUOTES); + case 'n': + case 'none': + default: + return $value; + } + } + + /** + * @param XoopsObject $obj + * @param string $key + * + * @return string|void + */ + public function cleanVar(XoopsObject $obj, $key) + { + $value = $obj->vars[$key]['value']; + if ($obj->vars[$key]['required'] && $value != '0' && $value == '') { + $obj->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $key)); + return $value; + } + if (!$obj->vars[$key]['not_gpc']) { + $value = $this->ts->stripSlashesGPC($this->ts->censorString($value)); + } else { + $value = $this->ts->censorString($value); + } + $value = str_replace('\\"', '"', $this->db->quote($value)); + return $value; + } +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Textarea.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Textbox.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Textbox.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Textbox.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,78 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class Xoops_Object_Dtype_Textbox extends Xoops_Object_Dtype_Abstract +{ + /** + * @param XoopsObject $obj + * @param string $key + * @param string $format + * + * @return string + */ + public function getVar(XoopsObject $obj, $key, $format) + { + $value = $obj->vars[$key]['value']; + switch (strtolower($format)) { + case 's': + case 'show': + case 'e': + case 'edit': + return $this->ts->htmlSpecialChars($value); + case 'p': + case 'preview': + case 'f': + case 'formpreview': + return $this->ts->htmlSpecialChars($this->ts->stripSlashesGPC($value)); + case 'n': + case 'none': + default: + return $value; + } + } + + /** + * @param XoopsObject $obj + * @param string $key + * + * @return string + */ + public function cleanVar(XoopsObject $obj, $key) + { + $value = $obj->vars[$key]['value']; + if ($obj->vars[$key]['required'] && $value != '0' && $value == '') { + $obj->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $key)); + return $value; + } + if (isset($obj->vars[$key]['maxlength']) && strlen($value) > intval($obj->vars[$key]['maxlength'])) { + $obj->setErrors(sprintf(_XOBJ_ERR_SHORTERTHAN, $key, intval($obj->vars[$key]['maxlength']))); + return $value; + } + if (!$obj->vars[$key]['not_gpc']) { + $value = $this->ts->stripSlashesGPC($this->ts->censorString($value)); + } else { + $value = $this->ts->censorString($value); + } + $value = str_replace('\\"', '"', $this->db->quote($value)); + return $value; + } +} Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Textbox.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: svn:eol-style + native Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Url.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Url.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/xoops_lib/Xoops/Object/Dtype/Url.php 2012-12-03 21:55:44 UTC (rev 10316) @@ -0,0 +1,47 @@ +<?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. + */ + +/** + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package class + * @since 2.6.0 + * @author trabis <lus...@gm...> + * @version $Id$ + */ + +defined('XOOPS_ROOT_PATH') or die('Restricted access'); + +class Xoops_Object_Dtype_Url extends Xoops_Object_Dtype_Abstract +{ + /** + * @param XoopsObject $obj + * @param string $key + * + * @return string + */ + public function cleanVar(XoopsObject $obj, $key) + { + $value = trim($obj->vars[$key]['value']); + if ($obj->vars[$key]['required'] && $value == '') { + $obj->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $key)); + return $value; + } + if ($value != '' && !preg_match("/^http[s]*:\/\//i", $value)) { + $value = 'http://' . $value; + } + if (!$obj->vars[$key]['not_gpc']) { + $value = $this->ts->stripSlashesGPC($value); + } + $value = str_replace('\\"', '"', $this->db->quote($value)); + return $value; + } +} \ No newline at end of file Property changes on: XoopsCore/branc... [truncated message content] |