• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Modular Extensions - HMVC version 5.4

[eluser]@MaxG[/eluser]
Hey,

Is it possible to use a /language folder in a Module?

Greeets

[eluser]XMadMax[/eluser]
Hi MaxG,

Yes, you can have a .../modules/mymodule/language/english/example_lang.php

To load: $this->load->language('mymodule/example');


=====================================================================================
CI 2.1.2 + HMVC 5.4 + Common shared folder for multiple applications
http://ellislab.com/forums/viewthread/223678/

[eluser]@MaxG[/eluser]
Okay,

It works, thank you.


[eluser]katanama[/eluser]
Hi guys...

I'm a PHP noob and this questions might be trivial...

1, When I do var_dump($this) in two installation of CI, one is vanilla CI, the other is CI+HMVC, I get different result.
a. Can someone explain if this is on purpose or it's just inevitable...
b. Does this effect in any way the way someone code on CI.
c. Is it something that can be rectified by some code clean up? If yes, I'd like to try when I have the time.

2. In Base.php, the last line says
Code:
new CI
. A new object is instatiated without assigning it to a variable. How is it different from the common way ie.
Code:
$CI = new CI;

as I said, I'm a very novice programmer.

[eluser]dafreak[/eluser]
So I'm still new to CI and HMVC but I have been messing around a bit and was looking at hooks and noticed that there is no auto loading of hooks from the module's folder so here's what I came up with

MX/Hooks.php
Code:
class MX_Hooks extends CI_Hooks
{
    /**
     * Initialize the Hooks Preferences
     *
     * @access  private
     * @return  void
     */
    function _initialize()
    {
        $CFG =& load_class('Config', 'core');
        // If hooks are not enabled in the config file
        // there is nothing else to do
        if ($CFG->item('enable_hooks') == FALSE)
        {
            return;
        }
        // Grab the "hooks" definition file.
        // If there are no hooks, we're done.
       if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
        {
            include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
        }
        elseif (is_file(APPPATH.'config/hooks.php'))
        {
            include(APPPATH.'config/hooks.php');
       }
         $path = APPPATH . 'modules/';
         $modules = $this->directory_map($path, 3);
          foreach ($modules as $key => $value) {
                if (is_file(APPPATH."modules/{$key}/config/hooks.php")){
                    include(APPPATH."modules/{$key}/config/hooks.php");
                }

        }
        if ( ! isset($hook) OR ! is_array($hook))
        {
            return;
        }
  
        $this->hooks =& $hook;
        $this->enabled = TRUE;
  
    }
    public function directory_map($source_dir, $directory_depth = 0, $hidden = FALSE)
    {
        if ($fp = @opendir($source_dir))
        {
            $filedata   = array();
            $new_depth  = $directory_depth - 1;
            $source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;

            while (FALSE !== ($file = readdir($fp)))
            {
                // Remove '.', '..', and hidden files [optional]
                if ( ! trim($file, '.') OR ($hidden == FALSE && $file[0] == '.'))
                {
                    continue;
                }

                if (($directory_depth < 1 OR $new_depth > 0) && @is_dir($source_dir.$file))
                {
                    $filedata[$file] = $this->directory_map($source_dir.$file.DIRECTORY_SEPARATOR, $new_depth, $hidden);
                }
                else
                {
                    $filedata[] = $file;
                }
            }

            closedir($fp);
            return $filedata;
        }

        return FALSE;
    }
}

and in the Core folder a file name MY_Hooks.php
Code:
&lt;?php (defined('BASEPATH')) OR exit('No direct script access allowed');

/* load the MX_Hooks class */
require APPPATH."third_party/MX/Hooks.php";

class MY_Hooks extends MX_Hooks {}


its a quick and dirty solution so any (constructive) comments are welcomed

[eluser]ahmedmahmoudit[/eluser]
[quote author="wiredesignz" date="1296284337"]Modular Extensions - HMVC version 5.4 is available from Bitbucket. (see my signature below)

CodeIgniter version 1.7 is no longer supported.[/quote]

Thank you wiredesignz for Great Extension but i have question i'm already using the extension and now i want to integrate phpUnit and i don't know if this possible with HMVC extension?

[eluser]MainmanFR[/eluser]
Hello,

I've got a little problem with HMVC. I call directly the URL of my module, and I've got a memory limit error in :

Loader.php line 55

in the foreach loop.

The error shows after 1 ou 2 minutes ...

Never had such an error.
Any ideas please ?

Thanks,
Renaud

[eluser]ahmedmahmoudit[/eluser]
be sure that you extend MX not CI

[eluser]XMadMax[/eluser]
[quote author="katanama" date="1355316165"]Hi guys...

I'm a PHP noob and this questions might be trivial...

1, When I do var_dump($this) in two installation of CI, one is vanilla CI, the other is CI+HMVC, I get different result.
a. Can someone explain if this is on purpose or it's just inevitable...
b. Does this effect in any way the way someone code on CI.
c. Is it something that can be rectified by some code clean up? If yes, I'd like to try when I have the time.

2. In Base.php, the last line says
Code:
new CI
. A new object is instatiated without assigning it to a variable. How is it different from the common way ie.
Code:
$CI = new CI;

as I said, I'm a very novice programmer. [/quote]

katanama, HMVC isn't 'over' CI, then must to extend with CI::$APP, this is the major difference.

[eluser]XMadMax[/eluser]
[quote author="MainmanFR" date="1357579254"]Hello,

I've got a little problem with HMVC. I call directly the URL of my module, and I've got a memory limit error in :

Loader.php line 55

in the foreach loop.

The error shows after 1 ou 2 minutes ...

Never had such an error.
Any ideas please ?

Thanks,
Renaud[/quote]

Seem the line like .... /* references to ci loader variables */.

Would be that you have something in your code that makes recursive assignment of variables. This loop copy all vars from CI to Loader (this), then if there are variables that points one to other, then the loop never ends.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.