1
chco2
qrcodes
  • 2011/4/26 17:08

  • chco2

  • Module Developer

  • Posts: 374

  • Since: 2004/3/5 1


Hi!

I have a a couple of functions I wrote for creating QRCodes.
Useally I emplement them into any new module I create, however I might guess other people would like to use or develop with it also.
How should I proceed?

1) Create 1 PHP file that can be called from any other module for creating QRCodes.

2) Create a module that needs to be installed for other modules to be able to use it.

When option 2.. How should I proceed here?
1. How can one module check to see if another module is installed?
2. Should e.g. the xoopsobjecthandler be extended after module installation so other modules can access them?
Ifso, How would I proceed here?

The codefunction basically except certain parameters (qrcode usage: text, phonenumber, sms, e-mail, url, businesscard, etc..) and returns an image to be displayed.

Guess it can be very handy for other developers, but I would like some guidelines as in how to best implement this.
“It's amazing the way people cling to insults. Or what they think are insults.”

2
Burning
Re: qrcodes
  • 2011/4/26 20:09

  • Burning

  • Theme Designer

  • Posts: 1163

  • Since: 2006/8/22


hi'

Quote:
1. How can one module check to see if another module is installed?

I believe MusS has done something like that with his Content module and Tellafriend... I'm not sure

May be another way to proceed : create plugins files, sitemap and rssfit modules use such method.
Still learning CSS and... english

3
redheadedrod
Re: qrcodes

You might want to look at this thread to see what I am working on...

https://xoops.org/modules/newbb/viewtopic.php?topic_id=73281&forum=75&post_id=338176#forumpost338176

I am in the very preliminary mode right now. But when I am further along it will make this sort of thing very easy to accomplish.

But for future reference (Without looking at your module) you want to consider making sure you make any of the useful features into objects so they are easier to use by other modules. As it is right now the other module has to be aware of your module being installed and going from there. As an example you can look at how CBB integrates xoopspoll. It will check for the modules existence then it has custom code to access the xoopspoll module stuff.

With my system you will be able to do this with most any module but it will require the use of objects by your code to make it easy to implement in other modules.

4
wishcraft
Re: qrcodes

chco you where saying you where using my APIs to spit out QRCodes which are Iching believe it or not, you can see them featured in the tao of chaos is rumoured a spin of from AntDB. Anyway, so for 1

$module_handler xoops_gethandler('module');
$xoModule $module_handler->getByDirname('qrcode');
if (!
is_object($xoModule)) {
     
$GLOBALS['qrcode_module'] = false;  // Module Not Installed Code
} else {
     if (
$xoModule->getVar('isactive')==true) {
          
$GLOBALS['qrcode_module'] = true// Module Installed Code
     
} else {
          
$GLOBALS['qrcode_module'] = false;  // Module Installed But Not Active Code
     
}
}


another method for 1 is

$module_handler xoops_gethandler('module');
$xoModule $module_handler->getByDirname('qrcode');
if (!
is_object($xoModule)) {
     
$GLOBALS['qrcode_module'] = false;  // Module Not Installed Code
} else {
     
$GLOBALS['qrcode_module'] = $xoModule->getVar('isactive'); // Module Installed Code whether active or not
}


You could try and set this one in a preloader somewhere in the common.php file like the end of it, so all further modules loading have to look for $GLOBALS['qrcode_module'] set to true for this module being installed.

Now 2..

There is no way of extending the main objects further with QCR Codes, however there was an ERM class for doing that which would also checksum the object for serialisation and object management with API Interactions of xoops and xoops.org for help systems and object identification.

However you could always provide your module with an install.txt that has how to make the hack or what files to replace in the structure of something like this:

/docs
/htdocs
   
/kernel
   
/modules
        
/qrcode


for distribution purposes. Do you need a hand, skype me I am up tonight!!
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

5
chco2
Re: qrcodes
  • 2011/4/27 16:25

  • chco2

  • Module Developer

  • Posts: 374

  • Since: 2004/3/5 1


Simon as always thanks a million for the response, very usefull!
Unfortunately I haven't used your API modules for spitting out the qrcodes, created my own as you didn't have them at that time :) I am looking into your api's currently for future projects.

"redheadedrod" I will keep my eye on your further development. Sounds promosing!

Burning: Thanks for the tip on plugins. Looking into that now!

“It's amazing the way people cling to insults. Or what they think are insults.”

6
wishcraft
Re: qrcodes

hey chco,

here is a pointer for what an Enumerator is used for with XOOPS, in the 'action' field in this log.php from xortify for the log runs plugins in the /plugins folder of Xortify..

if (!defined('XOOPS_ROOT_PATH')) {
    exit();
}
/**
 * Class for Blue Room Xortify Log
 * @author Simon Roberts 
 * @copyright copyright (c) 2009-2003 XOOPS.org
 * @package kernel
 */
class XortifyLog extends XoopsObject
{

    function 
XortifyLog($id null)
    {
        
$this->initVar('lid'XOBJ_DTYPE_INTnullfalse);
        
$this->initVar('uid'XOBJ_DTYPE_INTnullfalse);
        
$this->initVar('uname'XOBJ_DTYPE_TXTBOXfalsefalse64);
        
$this->initVar('email'XOBJ_DTYPE_TXTBOXfalsefalse255);
        
$this->initVar('ip4'XOBJ_DTYPE_TXTBOXfalsefalse15);
        
$this->initVar('ip6'XOBJ_DTYPE_TXTBOXfalsefalse128);
        
$this->initVar('proxy-ip4'XOBJ_DTYPE_TXTBOXfalsefalse15);
        
$this->initVar('proxy-ip6'XOBJ_DTYPE_TXTBOXfalsefalse128);
        
$this->initVar('network-addy'XOBJ_DTYPE_TXTBOXfalsefalse255);
        
$this->initVar('provider'XOBJ_DTYPE_TXTBOXfalsefalse128);
        
$this->initVar('agent'XOBJ_DTYPE_TXTBOXfalsefalse255);
        
$this->initVar('extra'XOBJ_DTYPE_OTHERfalsefalse);
        
$this->initVar('date'XOBJ_DTYPE_INTnullfalse);
        
$this->initVar('action'XOBJ_DTYPE_ENUM'monitored'falsefalsefalse, array('banned''blocked''monitored'));
    }

    function 
toArray() {
        
$ret parent::toArray();
        
$ret['date_datetime'] = date(_DATESTRING$this->getVar('date'));
        
$ret['action'] = ucfirst($this->getVar('action'));
        foreach(
$ret as $key => $value)
            
$ret[str_replace('-''_'$key)] = $value;
        return 
$ret;
    }
    
    function 
runPrePlugin($default true) {
        
        include_once(
$GLOBALS['xoops']->path('/modules/xortify/plugin/'.$this->getVar('provider').'.php'));
        
        switch (
$this->getVar('action')) {
            case 
'banned':
            case 
'blocked':
            case 
'monitored':
                
$func ucfirst($this->getVar('action')).'PreHook';
                break;
            default:
                return 
$default;
                break;
        }
        
        if (
function_exists($func))  {
            return @
$func($default$this);
        }
        return 
$default;
    }
    
    function 
runPostPlugin($lid) {
        
        include_once(
$GLOBALS['xoops']->path('/modules/xortify/plugin/'.$this->getVar('provider').'.php'));
        
        switch (
$this->getVar('action')) {
            case 
'banned':
            case 
'blocked':
            case 
'monitored':
                
$func ucfirst($this->getVar('action')).'PostHook';
                break;
            default:
                return 
$lid;
                break;
        }
        
        if (
function_exists($func))  {
            return @
$func($this);
        }
        return 
$lid;
    }
}


/**
* XOOPS Xortify Log handler class.
* This class is responsible for providing data access mechanisms to the data source
* of XOOPS user class objects.
*
* @author  Simon Roberts 
* @package kernel
*/
class XortifyLogHandler extends XoopsPersistableObjectHandler
{
    function 
__construct(&$db
    {
        
$this->db $db;
        
parent::__construct($db'xortify_log''XortifyLog'"lid""network-addy");
    }
    
    function 
insert($object$force true) {
        
$module_handler xoops_gethandler('module');
        
$config_handler xoops_gethandler('config');
        
$xoModule $module_handler->getByDirname('xortify');
        
$xoConfig $config_handler->getConfigList($xoModule->getVar('mid'));
        
        
$criteria = new Criteria('`date`'time()-$xoConfig['logdrops'], '<=');
        
$this->deleteAll($criteriatrue);
        
        if (
$object->isNew()) {
            
$object->setVar('date'time());
        }
        
$run_plugin_action=false;
        if (
$obj->vars['action']['changed']==true) {    
            
$run_plugin_action=true;
        }
        if (
$run_plugin_action){
            if (
$object->runPrePlugin($xoConfig['save_'.$object->getVar('action')])==true)
                
$lid parent::insert($object$force);
            else 
                return 
false;
        } else     
            
$lid parent::insert($object$force);        
        if (
$run_plugin_action)
            return 
$object->runPostPlugin($lid);
        else     
            return 
$lid;
    }
}

?>


In the function XortifyLogHandler::insert($object, $force) the following detection using the $this->vars[] of the XoopsObject allows for it to be checked if it changes then calls the plugin in the following code.

if ($obj->vars['action']['changed']==true) {    
            
$run_plugin_action=true;
        }

// then further down when the insert has been done so the object is complete.

        
if ($run_plugin_action){
            if (
$object->runPrePlugin($xoConfig['save_'.$object->getVar('action')])==true)
                
$lid parent::insert($object$force);
            else 
                return 
false;
        } else     
            
$lid parent::insert($object$force);        
        if (
$run_plugin_action)
            return 
$object->runPostPlugin($lid);
        else     
            return 
$lid;
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

7
wishcraft
Re: qrcodes

if your into the I-Ching like QRCodes Chco.. Try out my variable fractal checksums with bit sequencing for application on hardware.. You can explore (A) at 5 million checksum characters. I swear the physical effect of 5000 years of footfall since it was written this chinese 5000 year old fractal based binary system called the i-ching.. You might like these from php classes :- Here is two of them.

Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

8
chco2
Re: qrcodes
  • 2011/4/27 18:21

  • chco2

  • Module Developer

  • Posts: 374

  • Since: 2004/3/5 1


That is some seriously interesting stuff Simon!
And thanks for the pointers on plugins. I just finished the basic QRCode module and I'll post it to XOOPS to see if there's enough momentum for it. if the interest is there I'll start implementing features like the plugins etc.


Quote:

if your into the I-Ching like QRCodes Chco.. Try out my variable fractal checksums with bit sequencing for application on hardware.. You can explore (A) at 5 million checksum characters. I swear the physical effect of 5000 years of footfall since it was written this chinese 5000 year old fractal based binary system called the i-ching.. You might like these from php classes :- Here is two of them.
“It's amazing the way people cling to insults. Or what they think are insults.”

Login

Who's Online

420 user(s) are online (331 user(s) are browsing Support Forums)


Members: 0


Guests: 420


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits