Actions

Difference between revisions of "Developer Area/Plugin migration between Mahara 1.3 and 1.4"

From Mahara Wiki

< Developer Area
 
(23 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Mahara 1.4 has some changes to the menu bars.  
+
Mahara 1.4 has some changes to the menu bars. For example the top level tabs 'Profile' and 'My Portfolio' have become 'Content' and 'Portfolio'.
  
The table below has examples of some code differences required for plugins in Mahara 1.3 and Mahara 1.4.  
+
Also, the 'My' has been dropped from some other tabs such that, for example, 'My Plans' becomes 'Plans' and has moved from under the 'My Portfolio' tab to 'Content'.  
  
This may help anyone upgrading a plugin to work in Mahara 1.4 or backport a plugin to Mahara 1.3
+
The table below has examples of the code differences required for plugins in Mahara 1.3 and Mahara 1.4.
 +
 
 +
This may help anyone upgrading a plugin to work in Mahara 1.4 or backporting a plugin to Mahara 1.3 and ensuring that the plugins are correctly located on the menu bar
  
 
It is not comprehensive. Feel free to add further examples
 
It is not comprehensive. Feel free to add further examples
 
This table outlines some
 
  
 
{| border="1"
 
{| border="1"
Line 20: Line 20:
 
|lib.php
 
|lib.php
 
|
 
|
    public static function get_categories() {
+
public static function get_categories() {
        return array(''''feeds'''');
+
    return array(''''feeds'''');
    }
+
}
 
|
 
|
    public static function get_categories() {
+
public static function get_categories() {
        return array(''''external'''');
+
    return array(''''external'''');
    }
+
}
 
|-
 
|-
 
|blocktype
 
|blocktype
Line 33: Line 33:
 
|lib.php
 
|lib.php
 
|
 
|
    public static function get_categories() {
+
public static function get_categories() {
        return array(''''fileimagevideo'''');
+
    return array(''''fileimagevideo'''');
    }
+
}
 
|
 
|
    public static function get_categories() {
+
public static function get_categories() {
        return array(''''external'''');
+
    return array(''''external'''');
    }
+
}
 
|-
 
|-
 
|artefact
 
|artefact
Line 45: Line 45:
 
|lib.php
 
|lib.php
 
|
 
|
    public static function menu_items() {
+
public static function menu_items() {
        return array(
+
    return array(
            array(
+
        array(
                'path' => ''''myportfolio'''/plans',
+
            'path' => ''''myportfolio'''/plans',
                'url'  => 'artefact/plans/',
+
            'url'  => 'artefact/plans/',
                'title' => get_string(''''myplans'''', 'artefact.plans'),
+
            'title' => get_string(''''myplans'''', 'artefact.plans'),
                'weight' => 40,
+
            'weight' => 40,
            ),
+
        ),
        );
+
    );
    }
+
}
 
|
 
|
    public static function menu_items() {
+
public static function menu_items() {
        return array(
+
    return array(
            'content/plans' => array(
+
        'content/plans' => array(
                'path' => ''''content'''/plans',
+
            'path' => ''''content'''/plans',
                'url'  => 'artefact/plans/',
+
            'url'  => 'artefact/plans/',
                'title' => get_string(''''Plans'''', 'artefact.plans'),
+
            'title' => get_string(''''Plans'''', 'artefact.plans'),
                'weight' => 60,
+
            'weight' => 60,
            ),
+
        ),
        );
+
    );
    }
+
}
 
|-
 
|-
 
|
 
|
Line 74: Line 74:
 
plan.php
 
plan.php
 
|
 
|
    define('MENUITEM', ''''myportfolio'''/plans');
+
define('MENUITEM', ''''myportfolio'''/plans');
 +
|
 +
define('MENUITEM', ''''content'''/plans');
 +
|-
 +
|
 +
artefact/learning
 +
|
 +
index.php
 +
|
 +
define('MENUITEM', ''''profile'''/mylearning');
 +
|
 +
define('MENUITEM', ''''content'''/mylearning');
 +
|-
 +
|
 +
artefact/learning
 +
|
 +
lib.php
 +
|
 +
public static function menu_items() {
 +
    return array(
 +
        array(
 +
            'path' => ''''profile'''/mylearning',
 +
            'title' => get_string('mylearning', 'artefact.learning'),
 +
            'url' => 'artefact/learning/',
 +
            'weight' => 20,
 +
        )
 +
    );
 +
}
 +
|
 +
public static function menu_items() {
 +
    return array(
 +
        array(
 +
            'path' => ''''content'''/mylearning',
 +
            'title' => get_string('mylearning', 'artefact.learning'),
 +
            'url' => 'artefact/learning/',
 +
            'weight' => 20,
 +
        )
 +
    );
 +
}
 +
|-
 +
|
 +
artefact/europass
 +
|
 +
index.php
 +
editlanguage.php
 +
|
 +
define('MENUITEM', ''''profile'''/europass');
 +
|
 +
define('MENUITEM', ''''content'''/europass');
 +
|-
 +
|
 +
artefact/europass
 +
|
 +
lib.php
 
|
 
|
     define('MENUITEM', ''''content'''/plans');
+
     public static function menu_items() {
 +
        return array(
 +
            array(
 +
                'path' => ''''profile'''/europass',
 +
                'title' => get_string('europass', 'artefact.europass'),
 +
                'url' => 'artefact/europass/',
 +
                'weight' => 90,
 +
        )
 +
    );
 +
}
 +
|
 +
    public static function menu_items() {
 +
        return array(
 +
            array(
 +
                'path' => ''''content'''/europass',
 +
                'title' => get_string('europass', 'artefact.europass'),
 +
                'url' => 'artefact/europass/',
 +
                'weight' => 90,
 +
        )
 +
    );
 +
}
 
|}
 
|}
 +
  
 
In some cases, it may be worth considering conditional statements to enable a plugin to work with either Mahara 1.3 or 1.4. For example
 
In some cases, it may be worth considering conditional statements to enable a plugin to work with either Mahara 1.3 or 1.4. For example
  
    public static function get_categories() {
+
public static function get_categories() {
        require_once(get_config('libroot') . 'version.php');
+
    require_once(get_config('libroot') . 'version.php');
        $release = $config->release;
+
    $release = $config->release;
            if ($release < 1.4) {
+
        if ($release < 1.4) {
                return array('feeds');
+
            return array('feeds');
            }
+
        }
        return array('external');
+
    return array('external');
    }
+
}
 +
[[Category:Plugins]]

Latest revision as of 07:15, 12 July 2011

Mahara 1.4 has some changes to the menu bars. For example the top level tabs 'Profile' and 'My Portfolio' have become 'Content' and 'Portfolio'.

Also, the 'My' has been dropped from some other tabs such that, for example, 'My Plans' becomes 'Plans' and has moved from under the 'My Portfolio' tab to 'Content'.

The table below has examples of the code differences required for plugins in Mahara 1.3 and Mahara 1.4.

This may help anyone upgrading a plugin to work in Mahara 1.4 or backporting a plugin to Mahara 1.3 and ensuring that the plugins are correctly located on the menu bar

It is not comprehensive. Feel free to add further examples

Plugin File Mahara 1.3 Mahara 1.4
blocktype

/externalfeed

lib.php
public static function get_categories() {
    return array('feeds');
}
public static function get_categories() {
    return array('external');
}
blocktype

/externalvideo

lib.php
public static function get_categories() {
    return array('fileimagevideo');
}
public static function get_categories() {
    return array('external');
}
artefact

/plans

lib.php
public static function menu_items() {
    return array(
        array(
            'path' => 'myportfolio/plans',
            'url'  => 'artefact/plans/',
            'title' => get_string('myplans', 'artefact.plans'),
            'weight' => 40,
        ),
    );
}
public static function menu_items() {
    return array(
        'content/plans' => array(
            'path' => 'content/plans',
            'url'  => 'artefact/plans/',
            'title' => get_string('Plans', 'artefact.plans'),
            'weight' => 60,
        ),
    );
}

artefact/plans

index.php new.php plan.php

define('MENUITEM', 'myportfolio/plans');
define('MENUITEM', 'content/plans');

artefact/learning

index.php

define('MENUITEM', 'profile/mylearning');
define('MENUITEM', 'content/mylearning');

artefact/learning

lib.php

public static function menu_items() {
    return array(
        array(
            'path' => 'profile/mylearning',
            'title' => get_string('mylearning', 'artefact.learning'),
            'url' => 'artefact/learning/',
            'weight' => 20,
        )
    );
}
public static function menu_items() {
    return array(
        array(
            'path' => 'content/mylearning',
            'title' => get_string('mylearning', 'artefact.learning'),
            'url' => 'artefact/learning/',
            'weight' => 20,
        )
    );
}

artefact/europass

index.php editlanguage.php

define('MENUITEM', 'profile/europass');
define('MENUITEM', 'content/europass');

artefact/europass

lib.php

   public static function menu_items() {
       return array(
           array(
               'path' => 'profile/europass',
               'title' => get_string('europass', 'artefact.europass'),
               'url' => 'artefact/europass/',
               'weight' => 90,
        )
    );
}
   public static function menu_items() {
       return array(
           array(
               'path' => 'content/europass',
               'title' => get_string('europass', 'artefact.europass'),
               'url' => 'artefact/europass/',
               'weight' => 90,
        )
    );
}


In some cases, it may be worth considering conditional statements to enable a plugin to work with either Mahara 1.3 or 1.4. For example

public static function get_categories() {
    require_once(get_config('libroot') . 'version.php');
    $release = $config->release;
        if ($release < 1.4) {
            return array('feeds');
        }
    return array('external');
}