📝
xoops-modules-cookbook
  • Read me
  • Introduction
  • Templates
  • Database
  • Coding Standards
    • Our Recommendations
      • PSR-12 Style Guide
      • Clean Code
      • Module Structure
  • Best Practices
    • Best Practices
      • Convention over Configuration
      • Add namespaces
      • Add Sample Buttons
      • Add Comment Notification
      • Add Comments
      • How to handle AND/OR in CriteriaCompo
  • Core Classes
    • Classes
      • Key Classes
      • Helper Class
      • Criteria
      • XoopsObject
      • XoopsObject & XoopsObjectHandler
      • XoopsObjectHandler & XoopsPersistableObjectHandler
  • Working with Database
    • Using Criteria classes
  • Common Classes/Traits
    • Common Classes
      • Breadcrumb
      • Configurator
      • Migrate
    • Traits
      • FilesManagement
      • ServerStats
      • VersionChecks
      • ModuleStats
  • Form Classes
    • Form Classes
      • XoopsButtonTray
      • XoopsForm
      • XoopsFormButton
      • XoopsFormButtonTray
      • XoopsFormCaptcha
      • XoopsFormCheckBox
      • XoopsFormColorPicker
      • XoopsFormDateTime
      • XoopsFormDhtmlTextArea
      • XoopsFormEditor
      • XoopsFormElement
      • XoopsFormElementTray
      • XoopsFormFile
      • XoopsFormHidden
      • XoopsFormHiddenToken
      • XoopsFormLabel
      • XoopsFormPassword
      • XoopsFormRadio
      • XoopsFormRadioYN
      • XoopsFormSelect
      • XoopsFormSelectCheckGroup
      • XoopsFormSelectCountry
      • XoopsFormSelectEditor
      • XoopsFormSelectGroup
      • XoopsFormSelectLang
      • XoopsFormSelectMatchOption
      • XoopsFormSelectTheme
      • XoopsFormSelectTimeZone
      • XoopsFormSelectUser
      • XoopsFormText
      • XoopsFormTextArea
      • XoopsFormTextDateSelect
      • XoopsSimpleForm
      • XoopsTableForm
      • XoopsThemeForm
      • XoopsGroupPermForm
      • XoopsGroupFormCheckBox
  • Migration
    • Namespaces/Autoload
  • Configuration
    • ModuleConfiguration
      • Configuration files
  • Testing
    • Testing Checklist
    • Testing
  • About
    • Credits
    • About XOOPS CMS
Powered by GitBook
On this page
  • Definition
  • Usage

Was this helpful?

  1. Core Classes
  2. Classes

XoopsObject

PreviousCriteriaNextXoopsObject & XoopsObjectHandler

Last updated 5 years ago

Was this helpful?

Definition

XoopsObject is an Abstract class, a base class for all objects in the Xoops kernel (and beyond)

Usage

XoopsObject should be handled as an abstract class and has the following useful functions:

  • initVar($key,$data_type,$value,$required,$maxlength,$options) : initialize a variable. Use this, when extending XoopsObject instead of declaring variables the normal way. for $data_type, see below. $options is string for select options

  • getVar($key,$format) - retrieves an object variable ($format is 's' for display on page, 'f' for form info, or 'n' for no cleaning.

  • getVars() - retrieves array of key=>value pairs

  • cleanVars() - "cleans" the object variables, which have changed, according to their type set in initVar()

  • clone() - create a clone(copy) of the current object

  • setVar($key,$value,$not_gpc) - assign a value $value to a variable $key; sets object dirty

  • setVars($var_array) - assign values to variables from a key=>value pair array; sets object dirty

  • assignVar($key,$value) - assign a value to a variable

  • assignVars($var_array) - assign values to variables from a key => value pair array

The last two functions are for new(-ly instantiated) objects. For existing objects, which are subsequently modified, you should use setVar() and setVars() - this will set the object status to "dirty" i.e. that it has been modified and variable values not sanitized.

Data Types (for initVar function above):

  • XOBJ_DTYPE_TXTBOX - Text Box

  • XOBJ_DTYPE_TXTAREA - Text Area

  • XOBJ_DTYPE_INT - Integer

  • XOBJ_DTYPE_URL - URLs

  • XOBJ_DTYPE_EMAIL - E-mails

  • XOBJ_DTYPE_ARRAY - Arrays

  • XOBJ_DTYPE_OTHER - Others (won't be cleaned)

  • XOBJ_DTYPE_SOURCE -

  • XOBJ_DTYPE_STIME - Short Time

  • XOBJ_DTYPE_MTIME - Medium Time

  • XOBJ_DTYPE_LTIME - Long Time**

Note Don't give, to a field's name of your table, the table's name or you will have a problem in the XoopsObject class while saving the datas