ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Modular Extensions - Version 4.3

March 03, 2008 6:10pm

Subscribe [48]
  • #436 / Jun 03, 2008 9:06am

    dfau

    17 posts

    No worries wiredesignz, noticed the change between 4.1.11 and 4.1.17 when doing some profiling.  Thanks again for all your hard work, looking forward to seeing .18.

    df

  • #437 / Jun 03, 2008 11:12am

    wiredesignz

    2882 posts

    Fixed 😉

    DEBUG - 2008-06-04 02:08:43 --> Config Class Initialized
    DEBUG - 2008-06-04 02:08:43 --> Hooks Class Initialized
    DEBUG - 2008-06-04 02:08:43 --> URI Class Initialized
    DEBUG - 2008-06-04 02:08:43 --> No URI present. Default controller set.
    DEBUG - 2008-06-04 02:08:43 --> Router Class Initialized
    DEBUG - 2008-06-04 02:08:43 --> Output Class Initialized
    DEBUG - 2008-06-04 02:08:43 --> Input Class Initialized
    DEBUG - 2008-06-04 02:08:43 --> Global POST and COOKIE data sanitized
    DEBUG - 2008-06-04 02:08:43 --> Language Class Initialized
    DEBUG - 2008-06-04 02:08:43 --> Loader Class Initialized
    DEBUG - 2008-06-04 02:08:43 --> Helpers loaded: debug, parser, url, form, html
    DEBUG - 2008-06-04 02:08:43 --> Database Driver Class Initialized
    DEBUG - 2008-06-04 02:08:43 --> Model Class Initialized
    DEBUG - 2008-06-04 02:08:43 --> Default Model initialised as 
    DEBUG - 2008-06-04 02:08:43 --> File loaded: application/config/autoload.php
    DEBUG - 2008-06-04 02:08:43 --> File loaded: application/modules/search/controllers/search.php
    DEBUG - 2008-06-04 02:08:43 --> File loaded: application/config/autoload.php
    DEBUG - 2008-06-04 02:08:43 --> Search Controller Initialized
    DEBUG - 2008-06-04 02:08:43 --> File loaded: application/models/vehicles_model.php
    DEBUG - 2008-06-04 02:08:43 --> Model Class Initialized
    DEBUG - 2008-06-04 02:08:43 --> Default Model initialised as stock
    DEBUG - 2008-06-04 02:08:43 --> Default_controller Controller Initialized
    DEBUG - 2008-06-04 02:08:43 --> File loaded: application/modules/home/controllers/home.php
    DEBUG - 2008-06-04 02:08:43 --> File loaded: application/config/autoload.php
    DEBUG - 2008-06-04 02:08:43 --> Home Controller Initialized
    DEBUG - 2008-06-04 02:08:43 --> File loaded: application/modules/home/views/hot_pick.php
    DEBUG - 2008-06-04 02:08:43 --> File loaded: application/modules/home/views/hot_pick.php
    DEBUG - 2008-06-04 02:08:43 --> File loaded: application/modules/home/views/hot_pick.php
    DEBUG - 2008-06-04 02:08:43 --> File loaded: application/modules/home/views/hot_pick.php
    DEBUG - 2008-06-04 02:08:43 --> File loaded: application/modules/home/views/home_content.php
    DEBUG - 2008-06-04 02:08:43 --> File loaded: application/modules/search/views/box.php
    DEBUG - 2008-06-04 02:08:43 --> File loaded: application/views/default_layout.php
    DEBUG - 2008-06-04 02:08:43 --> Final output sent to browser
    DEBUG - 2008-06-04 02:08:43 --> Total execution time: 0.0359
  • #438 / Jun 03, 2008 11:18am

    wiredesignz

    2882 posts

    Version 4.1.18 of Modular Extensions is available on the wiki

    Feature bugfix: controller autoload problem fixed.  Thanks dfau 😉

  • #439 / Jun 03, 2008 5:39pm

    freshface

    131 posts

    Is it possible to show an example in how this extensions is usefull?

  • #440 / Jun 03, 2008 6:31pm

    sophistry

    906 posts

    a quick answer is this (and this is by no means the whole picture):

    if you make a nice self-contained model-controller-view set of files and then you want to include that MVC in another project by copying one folder - everything is in one place instead of spread around model, view and controller folders.

    also, from another controller, you can get some of the nice output from the original, tidy MVC set without calling a controller via URI (i.e., another http call using file_get_contents() or curl). you can get controller output without having to go out through the http interface again.

    hope that’s clear - there are other advantages too. please share your thoughts.

  • #441 / Jun 03, 2008 10:08pm

    dfau

    17 posts

    Hi wiredesignz,

    Thanks for the new version - I’ve dropped .18 into my testing app and I get:

    Unable to locate the requested file: ../application/views/foobar/one.php

    My master controller (application/controllers/welcome.php):

    class Welcome extends Controller {
        function Welcome() {
            parent::Controller();
        }
        function index() {
            $data['content'] = modules::run('foobar', NULL, 'one', TRUE);
            $this->load->view('welcome_message', $data);
        }
    }

    My module (application/modules/foobar/controllers/foobar.php):

    class Foobar extends Controller {
        function
        Foobar() {
            parent::Controller();
        }
        function
        one() {
            return $this->load->view('one', NULL, TRUE);
        }
    }

    My module’s view for function “one” (application/modules/foobar/views/one.php):

    This is: /modules/foobar/views/one.php

    It looks like the search paths have gone funny - here is the debug that I put into modules_helper.php:

    diff --git a/application/helpers/modules_helper.php b/application/helpers/modules_helper.php
    index 756043f..3bd16de 100644
    --- a/application/helpers/modules_helper.php
    +++ b/application/helpers/modules_helper.php
    @@ -147,6 +140,7 @@
            **/
            function modules_find($file, $path = '', $base = 'controllers/', $subpath = '')
            {
    +echo "looking for {$file} path={$path} base={$base} subpath={$subpath}\n";
                    if (($pos = strrpos($file, '/')) !== FALSE)
                {
                            $path = substr($file, 0, $pos);
    @@ -180,6 +174,8 @@
     
                    $file_ext = strpos($file, '.') ? $file : $file.EXT;
     
    +echo "paths2scan: ";
    +print_r($paths2scan);
                    foreach ($paths2scan as $path2)
                    {
                            //echo '',$path2,$file_ext,'';
    @@ -188,7 +184,10 @@
                            {
                                    if (is_file($path2.$name))
                                    {
    +                                       $home = explode('/', $path2);
    +echo "found: ";
    +echo print_r(array($path2, $file, $home[2]), TRUE), "\n";
    +                                       return array($path2, $file, $home[2]);
                                    }
                            }
                    }

    and here are the results from loading the base url:

    looking for autoload path=welcome base=config/ subpath=welcome
    paths2scan: Array
    (
        [0] => ../application/modules/welcome/config/
        [1] => ../application/config/
        [2] => ../application/config/welcome/
    )
    found: Array
    (
        [0] => ../application/config/
        [1] => autoload
        [2] => config
    )
    
    looking for foobar path=foobar base=controllers/ subpath=welcome
    paths2scan: Array
    (
        [0] => ../application/modules/foobar/controllers/
        [1] => ../application/controllers/
        [2] => ../application/controllers/foobar/
        [3] => ../application/modules/foobar/controllers/welcome/
        [4] => ../application/controllers/welcome/
    )
    found: Array
    (
        [0] => ../application/modules/foobar/controllers/
        [1] => foobar
        [2] => modules
    )
    
    looking for autoload path=modules base=config/ subpath=foobar
    paths2scan: Array
    (
        [0] => ../application/modules/modules/config/
        [1] => ../application/config/
        [2] => ../application/config/modules/
    )
    found: Array
    (
        [0] => ../application/config/
        [1] => autoload
        [2] => config
    )
    
    looking for one path=modules base=views/ subpath=foobar
    paths2scan: Array
    (
        [0] => ../application/modules/modules/views/
        [1] => ../application/views/
        [2] => ../application/views/modules/
        [3] => ../application/modules/modules/views/foobar/
        [4] => ../application/views/foobar/
    )

    The last two searches include paths “../application/modules/modules/config”, “../application/modules/modules/views” and “../application/modules/modules/views/foobar” which don’t look right, and there is no “../application/modules/foobar/views” which is where the view lives.

    If you could have a look at this that would be grouse.

    Thanks,
    df

  • #442 / Jun 03, 2008 10:22pm

    wiredesignz

    2882 posts

    Yes thanks again dfau 😉

    Version 4.1.19 is on the wiki now.

    Bugfix for path searches.

  • #443 / Jun 03, 2008 11:30pm

    dfau

    17 posts

    Hi wiredesignz,

    Thanks for the quick fix.  If you’re interested:

    Test app: master controller, one module, one call from master to module, autoload database library, file and url helpers
    4.1.18: memory usage 1,476,680 bytes
    4.1.19: memory usage 1,470,820 bytes

    5k saving, fantastic stuff.  Thanks again,
    df

  • #444 / Jun 04, 2008 7:59am

    wiredesignz

    2882 posts

    Version 4.1.20 is available on the wiki now.

    Refactoring code to improve speed and reduce memory usage.

    Note* $this->load->contoller(); is now replaced with $this->load->module();

  • #445 / Jun 04, 2008 12:48pm

    sophistry

    906 posts

    just poking deeper into the code today…

    the MY_Router.php file has some unfamiliar code style. could you explain a few lines:

    function _validate_request($segments)
        {
            ( ! isset($segments[1])) AND $segments[1] = 'index';
    
            /* locate the module controller */
            list($path, $file, $home) = $this->find($segments[1], $segments[0]);
    
            if ($path === FALSE)
    
                list($path, $file) = $this->find($segments[0], $segments[0]);
    
            /* no controllers were found */
            if ($path === FALSE)
    
                show_404($file);
    
            // set the directory path
            $this->set_directory(str_replace(APPPATH, '', $path));
    
            /* remove the directory segment */
            ($segments[1] == $file) AND $segments = array_slice($segments, 1);
    
            /* set the module home */
            ($home) AND my_router::path($home) OR my_router::path($file);
    
            return $segments;
        }

    two lines i am curious about, the first line, what does this construction do? is it some kind of shortcut that works like an if statement because of the order of execution of the boolean?

    ( ! isset($segments[1])) AND $segments[1] = 'index';

    also is this the same technique (boolean evaluation order)? what is ($home) doing there?

    /* set the module home */
    ($home) AND my_router::path($home) OR my_router::path($file);

    finally, in the same line shouldn’t my_router::path() class function utilize the CI config setting in config.php:

    $config['subclass_prefix'] = 'MY_';

    thanks wired.

  • #446 / Jun 04, 2008 3:59pm

    Alex.

    29 posts

    two lines i am curious about, the first line, what does this construction do? is it some kind of shortcut that works like an if statement because of the order of execution of the boolean?

    ( ! isset($segments[1])) AND $segments[1] = 'index';

    Yes, pretty much.  It’s almost exactly the same as:

    if(!isset($segments[1])){
     $segments[1] = 'index';
    }

    also is this the same technique (boolean evaluation order)? what is ($home) doing there?

    /* set the module home */
    ($home) AND my_router::path($home) OR my_router::path($file);

    If the variable $home evaluates to true, then the function path() stores the value of $home as the path.  Else, it stores the value of $file as the path.
    You could say it is the same as :

    if($home){
     my_router::path($home);
    } else {
     my_router::path($file);
    }

    finally, in the same line shouldn’t my_router::path() class function utilize the CI config setting in config.php:

    $config['subclass_prefix'] = 'MY_';

    I’m confused - are saying that the name of the class should be dependent on the subclass prefix in the config file?
    If you change the value of $config[‘subclass_prefix’], then you will have to change all references to the my_ extension manually.

  • #447 / Jun 04, 2008 7:27pm

    wiredesignz

    2882 posts

    Thanks Alex, nice explanation 😉

    Yes, using my_router calls is an oversight, it will conflict with changes to subclass_prefix and should be noted in the docs.

  • #448 / Jun 04, 2008 7:46pm

    Sam Dark

    242 posts

    I’m back into HMVC again. Good to see initial idea grew into the powerful lib.

    Now about a bad thing…

    I have a problem loading views in v. 4120. Got this error:

    Unable to load the requested file: list.php

    my app structure:

    app/modules/files/
      controllers/files.php
      views/list.php

    controllers/files.php

    class Files extends Controller {
       function index($path = ''){        
           $this->load->view('list');
        }
    }

    Tried to put list.php into app/views/ and it works :(

  • #449 / Jun 04, 2008 7:56pm

    wiredesignz

    2882 posts

    Works for me Sam. 😉

    Try using the constructor parent::Controller(); so the module can find out where it lives.

  • #450 / Jun 05, 2008 5:12am

    Sam Dark

    242 posts

    Tried parent::__construct() but it doesn’t helped.
    btw, I’m trying to launch module directly with http://localhost/files/.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases