Welcome Guest, Not a member yet? Register   Sign In
Modular Separation - PHP5 (Modules)
#71

[eluser]wiredesignz[/eluser]
@the_yk, I have to agree with AgentPhoenix your idea does not really work with the CI naming conventions. But I can assure you if the CodeIgniter developers adopt your idea then Modular Separation will get it too. Wink
#72

[eluser]crnalajna[/eluser]
I will try to repeat question...
@wiredesignz: In ME I can call module/method with Module::run('...') but how can I do similar with Modular Separation?

thanks for your time
#73

[eluser]wiredesignz[/eluser]
[quote author="bOkI" date="1260313534"]....In ME I can call module/method with Module::run('...') but how can I do similar with Modular Separation?[/quote]

You cannot. This is a single controller per request only.

Use Modular Extensions if you need HMVC + modules.
#74

[eluser]Abu eldahab[/eluser]
Nice work wiredesignz, thank you very much.
#75

[eluser]haydenp[/eluser]
First up ... thanks wiredesignz. Will be testing this in a few projects!

Request:

I am currently working on a project that makes use of your URI Language Identifier class extension.

What would be the best way (how would I) accommodate a 2 char ISO Language Identifier with your Modular Seperation system?

Could this not be a great feature to include in Modular Separation 2.0? ;o)

Many thanks

[EDITED]

Sorry ... I'm being stupid here! To answer my own question ... use routing!
#76

[eluser]Alface[/eluser]
to use DMZ with HMVC I hacked datamapper libraries (system\application\libraries)
I couldn't extend without losing the functionality to make a custom datamapper's extended class for each module
actily, I think it is not even possible to extend autoload datamapper native class.

Code:
static function autoload($class)
    {
        // Don't attempt to autoload CI_ or MY_ prefixed classes
        if (in_array(substr($class, 0, 3), array('CI_', 'MY_')))
        {
            return;
        }

        // Prepare class
        $class = strtolower($class);

        // Seach on application folder
        // Prepare path
        $path = APPPATH . 'models';

        // Prepare file
        $file = $path . '/' . $class . EXT;
        
        
        // Check if file exists, require_once if it does
        if (file_exists($file))
        {
            require_once($file);
        }
        else
        {
            // Do a recursive search of the path for the class
            DataMapper::recursive_require_once($class, $path);
        }
        
        
        
        // Seach on Modules folders
        
        // Prepare path
        $path = APPPATH . 'modules';
        
        if(is_dir($path) ){
            if ($handle = opendir($path)){
                while (FALSE !== ($dir = readdir($handle))){
                    // If dir does not contain a dot
                    if (strpos($dir, '.') === FALSE){
                        $modules[] = $dir;
                    }
                }
            }
        }
        
        foreach($modules as $module){
            // Prepare path
            $path = APPPATH . 'modules/'.$module.'/models';
            
            // Verify if there is a models folder on Module folder
            if(is_dir($path) ){
                // Prepare file
                $file = $path . '/' . $class . EXT;
    
                // Check if file exists, require_once if it does
                if (file_exists($file))
                {
                    require_once($file);
                }
                else
                {
                    // Do a recursive search of the path for the class
                    DataMapper::recursive_require_once($class, $path);
                }
            }
        }
    }

I needed to edit system\application\datamapper\htmlform.php too
turn it
Code:
// this is the default template (view) to use for the overall form
    var $form_template = 'dmz_htmlform/form';
    // this is the default template (view) to use for the individual rows
    var $row_template = 'dmz_htmlform/row';
    // this is the default template (view) to use for the individual rows
    var $section_template = 'dmz_htmlform/section';
intro this
Code:
// this is the default template (view) to use for the overall form
    var $form_template = '../dmz_htmlform/form';
    // this is the default template (view) to use for the individual rows
    var $row_template = '../dmz_htmlform/row';
    // this is the default template (view) to use for the individual rows
    var $section_template = '../dmz_htmlform/section';

I think it will work with any Modular Extension (ME) like Matchbox.
I didn't find any post about it on the forum, if anyone know a better way to do it, let me know
#77

[eluser]zorrito[/eluser]
I have a class current_user.php in my modules/login/models directory, Current_user is a Singleton Pattern.

in my controller (mymodules/login/controllers) i load my model.
Code:
$this->load->model('login/current_user');

Code:
<?php
class Current_User {
private static $user;
private function __construct() {}
public static function user() {
.......

I can't call private method.

Fatal error: Call to private Current_User::__construct() from context 'MY_Loader' in C:\wamp\www\ci_doctrine\system\application\libraries\MY_Loader.php on line 147

How do you solve this?

After that i made a public constructor, and then i have this error.

Fatal error: Call to undefined method Current_User::_assign_libraries() in C:\wamp\www\ci_doctrine\system\application\libraries\MY_Loader.php on line 192


Any ideas?

If i put current_user.php on normal models rep all is good (if i don't load model in my controller (mymodules/login/controllers) )

Cheers.

P.S : sorry for my english
#78

[eluser]hugle[/eluser]
Hello wiredesignz!
big thanks at first Smile

Certainly I came across one problem,
somehow, MY_Router.php tries to load lover-case library name.
The file itself exists, but starts from upper case, it's named Settings.php

The error I get is:
Code:
A PHP Error was encountered
Severity: Warning
Message: Modules::include_once(application/modules/core/settings/libraries/settings.php) [function.Modules-include-once]: failed to open stream: No such file or directory
Filename: libraries/MY_Router.php
Line Number: 158

and if I add:
Code:
$location = str_replace('settings.php', 'Settings.php', $location);
before the:
Code:
include_once $location; //line 158, MY_Router.php
It starts working...

I can't reproduce it myself.. can you help me or someone else?
Thank you for your time and thoughts!Smile
#79

[eluser]wiredesignz[/eluser]
@hugle, Thanks, there is a bug in Modules::find() that incorrectly returns the lowercase filename for module/libraries to the loader.

Try altering the two lines in MY_Router.php after line 182
Code:
// line 182
$file = array_pop($segments);
if ($base == 'libraries/') $file = ucfirst($file);
$file_ext = strpos($file, '.') ? $file : $file.EXT;

If that fixes the issue I will post a proper update.
#80

[eluser]hugle[/eluser]
[quote author="wiredesignz" date="1263807062"]@hugle, Thanks, there is a bug in Modules::find() that incorrectly returns the lowercase filename for module/libraries to the loader.

Try altering the two lines in MY_Router.php after line 182
Code:
// line 182
$file = array_pop($segments);
if ($base == 'libraries/') $file = ucfirst($file);
$file_ext = strpos($file, '.') ? $file : $file.EXT;

If that fixes the issue I will post a proper update.[/quote]

Hello, you are fast Smile
I confirm, replacing these lines:
Code:
$file = array_pop($segments);
$file_ext = strpos($file, '.') ? $file : $file.EXT;
if ($base == 'libraries/') $file_ext = ucfirst($file_ext);

With yours:
Code:
$file = array_pop($segments);
if ($base == 'libraries/') $file = ucfirst($file);
$file_ext = strpos($file, '.') ? $file : $file.EXT;

Works with no problem!Smile
Thank you very much, cause my solution was was pretty uglySmile))))))




Theme © iAndrew 2016 - Forum software by © MyBB