Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
1 + 2 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
     
target->getVar( 'title' ) ); $this->addElement( $elt ); } }[/code] and use your class by doing something like this: [code]if ( $we_have_to_show_form ) { include '/path/to/form_class.php'; $form = new SmartDownload_DownloadForm(); $form->target =& $my_dload_object; $form->createElements(); }[/code] [/quote] Trabis is doing it in Publisher, i.e. all forms are in class mode, receiving an object as parameter, which keeps the object itself smaller: You first define the Form class: [quote]class [color=FF0000]PublisherFileForm[/color] extends XoopsThemeForm { /** * @var PublisherPublisher * @access public */ var $publisher = null; [color=FF0000] var $targetObject = null;[/color] function __construct([color=FF0033]&$target[/color]) { $this->publisher = PublisherPublisher::getInstance(); [color=FF0000]$this->targetObject = $target;[/color] parent::__construct(_AM_PUBLISHER_UPLOAD_FILE, "form", xoops_getenv('PHP_SELF')); $this->setExtra('enctype="multipart/form-data"'); $this->createElements(); $this->createButtons(); } ... } [/quote] and then use it in the PublisherFile: [quote]class [color=FF0033]PublisherFile[/color] extends XoopsObject { /** * @var PublisherPublisher * @access public */ public $publisher = null; /** * @param null|int $id */ public function __construct($id = null) { $this->publisher = PublisherPublisher::getInstance(); $this->db = XoopsDatabaseFactory::getDatabaseConnection(); $this->initVar("fileid", XOBJ_DTYPE_INT, 0, false); $this->initVar("itemid", XOBJ_DTYPE_INT, null, true); $this->initVar("name", XOBJ_DTYPE_TXTBOX, null, true, 255); $this->initVar("description", XOBJ_DTYPE_TXTBOX, null, false, 255); $this->initVar("filename", XOBJ_DTYPE_TXTBOX, null, true, 255); $this->initVar("mimetype", XOBJ_DTYPE_TXTBOX, null, true, 64); $this->initVar("uid", XOBJ_DTYPE_INT, 0, false); $this->initVar("datesub", XOBJ_DTYPE_INT, null, false); $this->initVar("status", XOBJ_DTYPE_INT, 1, false); $this->initVar("notifypub", XOBJ_DTYPE_INT, 0, false); $this->initVar("counter", XOBJ_DTYPE_INT, null, false); if (isset($id)) { $file = $this->publisher->getHandler('file')->get($id); foreach ($file->vars as $k => $v) { $this->assignVar($k, $v['value']); } } } public function [color=FF0000]getForm()[/color] { [color=FF0000] include_once XOOPS_ROOT_PATH . '/modules/publisher/class/form/file.php'; $form = new PublisherFileForm($this); return $form;[/color] }[/quote] and you use it only when you needed, like this: [quote][color=FF0000]$fileObj = $publisher->getHandler('file')->get($fileid);[/color] switch ($op) { case "default": case "mod": include_once XOOPS_ROOT_PATH . '/header.php'; include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; // FILES UPLOAD FORM [color=FF0033] $files_form = $fileObj->getForm();[/color] $files_form->display(); break;[/quote] [/quote]" />

Re: How to write an standard module for xoops (div table, pagination , sort, order)
by bumciach on 2013/10/28 10:48:41

Quote:

irmtfan wrote:

Huum why not use this in xoops_version.php ?
le="color: #000000"><?php $modversion['dirmoduleadmin'] = XOOPS_ROOT_PATH . '/' . 'Frameworks/moduleclasses'; $modversion['icons16'] = XOOPS_URL . '/' . 'Frameworks/moduleclasses/icons/16'; $modversion['icons32'] = XOOPS_URL . '/' . 'Frameworks/moduleclasses/icons/32';



+1


And about my experience with Objects. For me the best topic was
https://xoops.org/modules/newbb/viewtopic.php?viewmode=flat&type=&topic_id=68782&forum=28
Trabis explanation was excellent and helped me a lot in understanding how the xoopsobject works. Thus after that I had more easy in analise rest of classes like:
https://xoops.org/modules/newbb/viewtopic.php?viewmode=flat&type=&topic_id=69368&forum=4
And also analysis of Catzwolf work helped in understanding how to use objects into xoops module - his modules code was very simple (too very simplified so sometimes multiplicate sql query though). But those codes are very old so should consider other examples.
Re: How to write an standard module for xoops (div table, pagination , sort, order)
by chco2 on 2013/10/27 9:09:45

If you could make a simple example (or some simple examples) related to XOOPS, I think I have a really nice guide lying around that explains the concept of classes, so I'll see if I can whip it into something we can use here.
Re: How to write an standard module for xoops (div table, pagination , sort, order)
by redheadedrod on 2013/10/27 8:03:50

I will see what I can do. It is hard to take a subject that takes a series of books to explain and make it into a short tutorial but I can at least setup a primer to allow people to understand why Objects are good to use.

Re: How to write an standard module for xoops (div table, pagination , sort, order)
by Mamba on 2013/10/27 1:12:08

Quote:
Perhaps some examples would help out.

Could you write a short tutorial on this?

That would be very helpful!
Re: How to write an standard module for xoops (div table, pagination , sort, order)
by redheadedrod on 2013/10/25 12:09:32

I understand chco2 I am in programming classes now and it is obvious to me how much easier things are to update with classes than procedural coding.

Perhaps some examples would help out. But yes object orientated is much nicer when it is used but there is a learning curve on them. (One of my instructors told me that a standard procedural programmer can take up to 5 years to get the full understanding of object and how they work.)

I have been using them for about 3-4 years now and I am almost there. But they are much easier to maintain. We only use classes/objects in my Java class.

Who's Online

173 user(s) are online (142 user(s) are browsing Support Forums)


Members: 0


Guests: 173


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits