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

[eluser]hugle[/eluser]
[quote author="Jelmer" date="1272485518"]Try looking into PyroCMS on Github, worked perfectly for me to get me started.[/quote]

Hehe, same here Smile))

Link t PyroCMS: http://github.com/philsturgeon/pyrocms

[eluser]Phil Sturgeon[/eluser]
[quote author="ChazUK" date="1272480057"]I really wish there was better documentation for this.

Always seems the way with brilliant things like this. They do exactly what you want them to do, but getting them to work is a shed load of hassle.

Does anyone have a folder structure zip that they could upload?[/quote]

Dude there is a screenshot of the folder structure on the Wiki.

[eluser]Alfredor[/eluser]
I'm getting a weird error using Modular Separation, I had this module I made called manage, it was working so good before I made a second module, called gateway, at first I though I messed up with something so I got a CI fresh install and installed modular separation normally, but it keeps loading and once the page loads it just shows a unknow error by the browser not even CI, I'm connecting to 2 different databases on the same mysql server for testing I've tried everything but no results at all, any help appriciated.
modules/controllers/manage.php
Code:
<?php

class Manage extends Controller {
    function Manage()
    {
        parent::Controller();
        $this->load->model('manage/manage','',TRUE);
        $this->config->load('manage/manage');
    }
    
    function index()
    {
        $this->load->view('welcome_message');
    }
}

modules/config/manage.php
Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

/*
Defines Which Gateway Server Is Being Used.
For naming convention each server will be called S# where # is the asigned number of the gateway.
*/

$config['gateway'] = 'S1';

/*
Server Hardware & Access Settings.
$config['ram'] = '256';             Amount of Ram in MB
$config['hdd'] = '10';                 Amount Of Disk Space In GB
$config['connection'] = '100';        Total Connection Speed in MB/s
$config['user'] = 'user';             Access User
$config['password'] = 'password';     Access Password
*/

$config['ram'] = '256';
$config['hdd'] = '10';
$config['connection'] = '100';
$config['user'] = 'root';
$config['password'] = 'S1jnaz3as';

/*
Administrators IP Access
*/
$config['allowed'] = array('admin.dante-wsa.com');

/*
Email Configuration of Gateway
*/

$config['g_email'] = '[email protected]';

modules/config/routes.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$route['manage'] = 'manage';

modules/models/manage.php
Code:
<?php
class Manage extends Model{
    private $gateway;
    
    function Manage()
    {
    parent::Model();
    $this->gateway = $this->load->database('gateway', TRUE);
    $this->config->load('manage/manage');
    }
    
    function get($id)
    {
    
    $log = array(
    'gateway_id' => $this->config->item('gateway'),
    'server_id'=> $id,
    'user_id'=> $this->dx_auth->get_user_id()
    );
    $this->db->insert('log', $log);
    
    $q1 = $this->db->get_where('servers',array('id'=>$id));
    $q2 = $q1->row();
    $data1 = array(
    'name' => $q2->name,
    'identifier' => $q2->identifier,
    'owner_id' => $q2->owner_id,
    'server_id' => $q2->id
    );
    $this->gateway->insert('servers',$data1);
    $q1->free_result();
    
    $q3 = $this->db->get_where('server_instances', array('server_id'=>$id));
    $q4 = $q3->row();
    $data2 = array(
    'server_id' => $q4->server_id,
    'type' => $q4->type,
    'user' => $q4->user,
    'password' => $q4->password,
    'ip' => $q4->ip,
    'port' => $q4->port,
    'server_port' => $q4->server_port,
    'server_path' => $q4->server_path,
    'serveri_id' => $q4->id
    );
    $this->gateway->insert('server_instances',$data2);
    $q3->free_result();
    
    $q5 = $this->db->get_where('server_db', array('server_id'=>$id));
    $q6 = $q5->row();
    $data3 = array(
    'server_id' => $q6->server_id,
    'ip' => $q6->ip,
    'port' => $q6->port,
    'user' => $q6->user,
    'password' => $q6->password,
    'database' => $q6->database,
    'serverdb_id' => $q6->id
    );
    $this->gateway->insert('server_db', $data3);
    $q5->free_result();
    
    $q7 = $this->db->get_where('server_users', array('server_id'=>$id));
    $q8 = $q7->row();
    if(!$q7->num_rows() === 0){
    $data4 = array(
    'server_id' => $q8->server_id,
    'user_id' => $q8->user_id,
    'role_id' => $q8->role_id,
    'last_connection' => $q8->last_connection,
    'serveruser_id' => $q8->id
    );
    $this->gateway->insert('server_user', $data4);
    $q7->free_result();
    }
    else
    {
    return FALSE;
    }
    
    $q9 = $this->db->get_where('server_commands', array('server_id'=>$id));
    $q10 = $q9->row();
    if(!$q10->num_rows() === 0){
    $data5 = array(
    'serveri_id' => $q10->serveri_id,
    'text' => $q10->text,
    'name' => $q10->name,
    'type' => $q10->type,
    'serverc_id' => $q10->id
    );
    $this->gateway->insert('server_commands', $data5);
    $q9->free_result();
    }
    else
    {
    return FALSE;
    }
    }
    
    function destroy($id)
    {
    $this->gateway->delete('servers', array('server_id'=>$id));
    $this->gateway->delete('server_instances', array('server_id'=>$id));
    $this->gateway->delete('server_db', array('server_id'=>$id));
    $this->gateway->delete('server_user', array('server_id'=>$id));
    $this->gateway->delete('server_commands', array('server_id'=>$id));
    }
}


I got the following folder structure:
Folder Structure

[eluser]Johan André[/eluser]
[quote author="ChazUK" date="1272480057"]I really wish there was better documentation for this.

Always seems the way with brilliant things like this. They do exactly what you want them to do, but getting them to work is a shed load of hassle.

Does anyone have a folder structure zip that they could upload?[/quote]

Is it really that hard to get it working?

1. Install CI & copy the MS-files to application/library

2. Create application/modules-folder
3. In the modules-folder, create a folder (module).
4. In the module folder, create controller, model and views folder.

Hard? I figured it out by looking at the screenshot of the folder structure.

[eluser]Phil Sturgeon[/eluser]
[quote author="Alfredor" date="1272688328"]I'm getting a weird error using Modular Separation, I had this module I made called manage, it was working so good before I made a second module, called gateway, at first I though I messed up with something so I got a CI fresh install and installed modular separation normally, but it keeps loading and once the page loads it just shows a unknow error by the browser not even CI, I'm connecting to 2 different databases on the same mysql server for testing I've tried everything but no results at all, any help appriciated.[/quote]

Why are you calling everything Manage? Not only is that confusing it is going to throw fatal errors as you are defining multiple classes with the same name.

Also when you say "I'm getting a weird error using Modular Separation" it might be helpful if you actually provide us with an error. Otherwise it is a lot of guesswork for us!

[eluser]Alfredor[/eluser]
hehe, no look as you can see the only classes I'm defining are the model and the controller, I'll try changing them and also the weird error is that there is no error at all, the app just keeps on loading without any result. once its done loading it presents the browser default 302 error...

[eluser]Johan André[/eluser]
[quote author="Alfredor" date="1272829973"]hehe, no look as you can see the only classes I'm defining are the model and the controller, I'll try changing them and also the weird error is that there is no error at all, the app just keeps on loading without any result. once its done loading it presents the browser default 302 error...[/quote]

Hmm...

I try to name my files like this:

Controller - People.php (plural name of function)
Model - person_model.php (singular of function and append _model)

The model is then loaded like:

Code:
$this->load->model('person_model', 'person');

In my IDE it's easier with this kindof naming when using alot of tabs.
And as Phil points out, it does not break when using the objects at the same time. Smile

[eluser]Alfredor[/eluser]
You know something, I feel stupid now, you were right I added _model to the manage model and it worked wonderfully. Thanks a lot!.

[eluser]ChazUK[/eluser]
[quote author="Johan André" date="1272716888"][quote author="ChazUK" date="1272480057"]I really wish there was better documentation for this.

Always seems the way with brilliant things like this. They do exactly what you want them to do, but getting them to work is a shed load of hassle.

Does anyone have a folder structure zip that they could upload?[/quote]

Is it really that hard to get it working?

1. Install CI & copy the MS-files to application/library

2. Create application/modules-folder
3. In the modules-folder, create a folder (module).
4. In the module folder, create controller, model and views folder.

Hard? I figured it out by looking at the screenshot of the folder structure.[/quote]

I have it working, except for the module routing. Everything has to go in applications/config/routes.php for it to route properly.

I know it's annoying asking for help, but as with most external scripts the documentation isn't that great at explaining a lot of the functionality. Especially with this as you have to read up on Modular Extensions first. Working examples are always good to help people figure it out for themselves.

Thanks for the Github repo hugle

[eluser]ChazUK[/eluser]
Folders
Code:
application
- config
-- routes.php
- libraries
-- MY_Loader.php
-- MY_Router.php
- modules
-- home
--- config
--- controllers
---- default.php
--- models
--- views
---- dashboard.php
-- subsystem
--- config
--- controllers
---- default.php
--- models
--- views
---- dashboard.php
- etc

Do I have to put each modules default controller in application/config/routes.php?




Theme © iAndrew 2016 - Forum software by © MyBB