PEAK XOOPS - how to implement "duplicatable" in englishin japanese

how to implement "duplicatable"

  • You cannot open a new topic into this forum
  • Guests cannot post into this forum
Previous post - Next post | Parent - Children.1 | Posted on 2004/12/7 7:29
krobi  ¾åÅùʼ From: Austria  Posts: 38
hey

i'am on the way to clone the actually news 1.2.1 modul, and so i ask myself

why clone it by the normal way, why not use the duplicatable technologie from gijoe.

so here is my question
is there a how to how to include the duplicatable to a modul. or could you give an example how to do that?
Votes:8 Average:8.75
Previous post - Next post | Parent - Children.1 | Posted on 2004/12/7 12:57
JasonMR  °ìÅùʼ   Posts: 14
I would like to second krobi's request, GIJOE, if you find the time, could you give us newbee-dev's a brief tutorial, on how to make modules duplicatable?

I really love this feature, and would like to implement it, with my own projects.

Votes:37 Average:1.62
Previous post - Next post | Parent - Children.1 .2 | Posted on 2004/12/9 19:00
GIJOE  ÀèǤ·³Áâ   Posts: 4110
I love to write PHP code, but I don't love "how to" articles so much

The implementation of DUPLICATABLE V2...

- at first, you have to decide original "dirname"
- the "dirname" can't include character of 0-9

- the most important & essentially code is this:
$mydirname = basename( dirname( __FILE__ ) ) ;
if( ! preg_match( '/^(\D+)(\d*)$/' , $mydirname , $regs ) ) echo ( "invalid dirname: " . htmlspecialchars( $mydirname ) ) ;
$mydirnumber = $regs[2] === '' ? '' : intval( $regs[2] ) ;
- use $mydirname for physical&virtual paths
- use (your dirname).$mydirnumber for DB tables & templates

- the skelton of xoops_version.php (replace xhld to your "dirname")
if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;
$mydirname = basename( dirname( __FILE__ ) ) ;
if( ! preg_match( '/^(\D+)(\d*)$/' , $mydirname , $regs ) ) echo ( "invalid dirname: " . htmlspecialchars( $mydirname ) ) ;
$mydirnumber = $regs[2] === '' ? '' : intval( $regs[2] ) ;

$modversion['image'] = "images/xhld{$mydirnumber}_slogo.gif";
$modversion['dirname'] = $mydirname;

// Sql file (must contain sql generated by phpMyAdmin or phpPgAdmin)
$modversion['sqlfile']['mysql'] = "sql/mysql{$mydirnumber}.sql";

// Tables created by sql file (without prefix!)
$modversion['tables'][0] = "xhld{$mydirnumber}";
$modversion['tables'][1] = "xhld{$mydirnumber}_cat";
...

// Blocks
$modversion['blocks'][1]['file'] = "...";
$modversion['blocks'][1]['name'] = ...;
$modversion['blocks'][1]['description'] = ...;
$modversion['blocks'][1]['show_func'] = ...;
$modversion['blocks'][1]['edit_func'] = ...;
$modversion['blocks'][1]['template'] = "xhld{$mydirnumber}_block_(...).html";
$modversion['blocks'][1]['options'] = "{$mydirname}|(the other options)";

// Templates
$modversion['templates'][1]['file'] = "xhld{$mydirnumber}_(...).html";
$modversion['templates'][1]['description'] = '';
$modversion['templates'][2]['file'] = "xhld{$mydirnumber}_(...).html";
$modversion['templates'][2]['description'] = '';
...

// Search
$modversion['hasSearch'] = 1;
$modversion['search']['file'] = "include/search.inc.php";
$modversion['search']['func'] = "xhld{$mydirnumber}_search";

// Notification
$modversion['hasNotification'] = 1;
$modversion['notification']['lookup_file'] = 'include/notification.inc.php';
$modversion['notification']['lookup_func'] = "xhld{$mydirnumber}_notify_iteminfo";


- prepare a number of "mysql*.sql"s in sql/ folder.
- contens of mysql.sql
CREATE TABLE xhld (
...
) TYPE=MyISAM;

CREATE TABLE xhld_cat (
...
) TYPE=MyISAM;
- contens of mysql0.sql
CREATE TABLE xhld0 (
...
) TYPE=MyISAM;

CREATE TABLE xhld0_cat (
...
) TYPE=MyISAM;

-prepare a number of template files in templates/ folder
-eg) xhld_index.html, xhld0_index.html, xhld1_index.html ...
-eg) blocks/xhld_block.html, blocks/xhld0_block.html, blocks/xhld1_block.html ...

-edit all of front-end php files like this:
	require( '../../mainfile.php' ) ;

	// for "Duplicatable"
	$mydirname = basename( dirname( __FILE__ ) ) ;
	if( ! preg_match( '/^(\D+)(\d*)$/' , $mydirname , $regs ) ) echo ( "invalid dirname: " . htmlspecialchars( $mydirname ) ) ;
	$mydirnumber = $regs[2] === '' ? '' : intval( $regs[2] ) ;

	(original part)

-edit all of back-end php files like this:
	include_once( '../../../include/cp_header.php' ) ;

	// for "Duplicatable"
	$mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
	if( ! preg_match( '/^(\D+)(\d*)$/' , $mydirname , $regs ) ) echo ( "invalid dirname: " . htmlspecialchars( $mydirname ) ) ;
	$mydirnumber = $regs[2] === '' ? '' : intval( $regs[2] ) ;

	(original part)

-modify all of php files querying to db
	$xoopsDB->prefix("xhld")
	$xoopsDB->prefix("xhld{$mydirnumber}")
	$xoopsDB->prefix("xhld_cat")
	$xoopsDB->prefix("xhld{$mydirnumber}_cat")
	...

-sample skelton of search.inc.php
<?php

if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;

$mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
if( ! preg_match( '/^(\D+)(\d*)$/' , $mydirname , $regs ) ) die ( "invalid dirname: " . htmlspecialchars( $mydirname ) ) ;
$mydirnumber = $regs[2] === '' ? '' : intval( $regs[2] ) ;

eval( '

function xhld'.$mydirnumber.'_search( $keywords , $andor , $limit , $offset , $uid )
{
	...
	$xoopsDB->query( "...".$xoopsDB->prefix("xhld'.$mydirnumber.'")."..." ) ;
	...
}

' ) ;

?>
notice: don't use the character of ' inside eval()

- the way to modify notification.inc.php is almost same as search.inc.php

- sample skelton of blocks/*.php
<?php
if( ! defined( 'XHLD_BLOCK_FUNC_INCLUDED' ) ) {

define( 'XHLD_BLOCK_FUNC_INCLUDED' , 1 ) ;

function b_xhld_func_show( $options )
{
	$mydirname = empty( $options[0] ) ? basename( dirname( dirname( __FILE__ ) ) ) : $options[0] ;
	if( ! preg_match( '/^(\D+)(\d*)$/' , $mydirname , $regs ) ) die ( "invalid dirname: " . htmlspecialchars( $mydirname ) ) ;
	$mydirnumber = $regs[2] === '' ? '' : intval( $regs[2] ) ;

	(original code)
}


function b_xhld_func_edit( $options )
{
	$mydirname = empty( $options[0] ) ? basename( dirname( dirname( __FILE__ ) ) ) : $options[0] ;

	(original code)
	$form .= "<input type='hidden' size='4' name='options[0]' value='$mydirname' />\n" ;

	return $form ;
}

}
?>

-sample of language/(language)/admin.php
<?php
if( defined( 'FOR_XOOPS_LANG_CHECKER' ) || ! defined( 'XHLD_AM_LOADED' ) ) {

define( 'XHLD_AM_LOADED' , 1 ) ;

define("_AM_CONFIG","...");
....
....

}
?>

-sample of language/(language)/modinfo.php
<?php
if( defined( 'FOR_XOOPS_LANG_CHECKER' ) || ! defined( 'XHLD_MI_LOADED' ) ) {

define( 'XHLD_MI_LOADED' , 1 ) ;

define("_MI_CONFIG","...");
....
....

}
?>
- another language files are almost same as admin.php.

Don't forget that this article is just a sample.
There are many and difficult hurdles to implement DUPLICATABLE with working modules.
eg1) in myAlbum-P, a problem of the place of photo storing
eg2) in xhld, a problem of XoopsObject
eg3) in TinyD, a problem of sharing many files of SPAW or PEAR
*/
Votes:133 Average:9.17
Previous post - Next post | Parent - Children.1 | Posted on 2004/12/10 0:50
krobi  ¾åÅùʼ From: Austria  Posts: 38
waw thanks for your sample,
so i will start to work on a news modul (based on news 1.2.1) with your duplicatable technic
Votes:9 Average:7.78
Previous post - Next post | Parent - Children.1 | Posted on 2004/12/10 4:56
GIJOE  ÀèǤ·³Áâ   Posts: 4110
If you try to make news duplicatable, refer the codes of xhld.

XoopsObject module has a difficult problem about naming the class.
Votes:6 Average:10.00
Previous post - Next post | Parent - Children.1 | Posted on 2004/12/10 6:32
krobi  ¾åÅùʼ From: Austria  Posts: 38
Votes:7 Average:10.00
Previous post - Next post | Parent - Children.1 | Posted on 2004/12/12 5:30
krobi  ¾åÅùʼ From: Austria  Posts: 38
hey gijoe

i have insert your code into the news modul, my actually status is:

i can install the modul, some admin option also works but not all. and the user site dont work

so i made a rar file, uploaded it to our webspace.
maybe you can take a look at the code.

GET IT HERE
Votes:6 Average:10.00
Previous post - Next post | Parent - Children.1 | Posted on 2004/12/12 5:43
GIJOE  ÀèǤ·³Áâ   Posts: 4110
I'm sorry that I can't help you.

I'm not interested with "news" at all.
And I'm very very busy.

my TODO is...

modifying piCal, myAlbum-P, protector, TinyD...
and creating two revolutionary modules in my mind.

You can see that there are no time to touch "news" module.

I have to say that it is not so easy to implement "DUPLICATABLE".
Only well-skilled programmers can do that.
Votes:15 Average:5.33

question Re: how to implement "duplicatable"

msg# 1.1.1.1.1.1.1.1.1
Previous post - Next post | Parent - No child | Posted on 2004/12/12 6:36
krobi  ¾åÅùʼ From: Austria  Posts: 38
oh thats bad

maybe i can get it to run, when not i will simple make a clone
Votes:8 Average:0.00
Previous post - Next post | Parent - Children.1 | Posted on 2004/12/13 16:18
JasonMR  °ìÅùʼ   Posts: 14
Quote:
I love to write PHP code, but I don't love "how to" articles so much

I understand , so many thanks for your effort, it is really appreciated! I will try this out soon.
Votes:9 Average:10.00
Previous post - Next post | Parent - No child | Posted on 2005/6/13 20:39
gibaphp  ¾åÅùʼ From: Brasil - S  Posts: 22
One example of duplicatable module:

Translation by google

XT-Channel

You can generator module dinamics on-line

Direct link:

Clone on line XT-Channel

Credtis for Wf-Channel is correct
Votes:20 Average:9.00

  Advanced search


Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!