2017 © Pedro Peláez
 

library whmcs-easy-addons

Whmcs Addon Admin Page Controller

image

akerbel/whmcs-easy-addons

Whmcs Addon Admin Page Controller

  • Friday, September 23, 2016
  • by akerbel
  • Repository
  • 2 Watchers
  • 4 Stars
  • 105 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

WHMCS Easy Addons

WHMCS Easy Addons is a package for fast creating of addon admin pages., (*1)

Homepage: https://github.com/akerbel/whmcs-easy-addons, (*2)

How to install:

The recommended way to install WHMCS Easy Addons is through Composer., (*3)

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version of WHMCS Easy Addons:, (*4)

php composer.phar require akerbel/whmcs-easy-addons

How to use:

I. Admin tabs. - Install Composer, (*5)

curl -sS https://getcomposer.org/installer | php
  • Create composer.json file inside your addon:
{
    "name": "EasyAddonsSkeleton",
    "version": "1.0.0",
    "description": "An example addon for WHMCS Easy Addons",
    "autoload": {
        "psr-4": {
            "EasyAddonsSkeleton\\": "src/"
        }
    },
    "require": {
        "akerbel/whmcs-easy-addons": "1.*"
    }
}
  • Your "_output" function should look like this:
function EasyAddonsSkeleton_output($vars) {
    global $module;
    include_once(ROOTDIR."/modules/addons/".$module.'/src/output.php'); 
}
  • Create 'src' folder.
  • Create output.php file in 'src' folder.

output.php:, (*6)

namespace EasyAddonsSkeleton;
global $module;
include_once(ROOTDIR."/modules/addons/".$module.'/vendor/autoload.php');

$EasyAddonsSkeleton = new EasyAddonsSkeletonController($vars);
$EasyAddonsSkeleton->run();
  • Create EasyAddonsSkeletonController.php in 'src' folder.

EasyAddonsSkeletonController.php:, (*7)

namespace EasyAddonsSkeleton;

use whmcsEasyAddons;

class EasyAddonsSkeletonController extends whmcsEasyAddons\PageController {
    // This tab will be chosen by dafault
    public $action = 'firsttab';

    // This is array of your tabs and their names.
    public $menu = array(
        'First Tab' => 'firsttab',
        'Second Tab' => 'secondtab',
    );

    public function firsttabAction(){

        // Your code for "First tab"

    }

    public function secondtabAction(){

        // Your code for "Second tab"

    }
}
  • Create folder 'templates'.
  • Create .tpl file for each your tab in 'templates' folder with names like 'firsttab.tpl' and 'secondtab.tpl'.
  • You can assing your php variables in each 'Action' method:
$this->view->assign('smarty_variable', $your_php_variable);

==================== II. Fast item lists. - Example code:, (*8)

    $list = new whmcsEasyAddons\ItemList(

        // SQL params array. Read more in ItemList.php
        array(
            'SELECT' => '*',
            'FROM' => 'tblmodulelog',
        ),

        // Filters array. Read more in ItemList.php . Optional.
        array(
            array(
                'name' => 'module', 'value' => $_GET['filter']['module'], 'description' => 'module'
            ),
            array(
                'name' => 'action', 'value' => $_GET['filter']['action'], 'description' => 'action'
            ),
            array(
                'name' => 'request', 'value' => $_GET['filter']['request'], 'description' => 'request', 'type' => 'LIKE'
            ),
            array(
                'name' => 'response', 'value' => $_GET['filter']['response'], 'description' => 'response', 'type' => 'LIKE'
            ),
        ), 

        // Paginators type. Read more in a changelog for v1.2 . Optional.
        'dafault'
    );
    $this->view->assign('result', $list->result);
    $this->view->assign('paginator', $list->paginator);
    $this->view->assign('tablehead', $list->tablehead);
    $this->view->assign('filter', $list->filter);
  • Now you can use this variables in your .tpl file:
  1. $filter - show a filter form.
  2. $paginator - show a page navigation.
  3. $tablehead - show a tablehead with sort buttons.
  4. $result - show an array of items.

New in v1.1:

  1. Now JOIN parameters can be arrays. It means, now you can use few similar JOINs in your query.
  2. ORDER and SORT parameters was added . If you use JOINs in your query, you must define you ORDER parameter, because 'ORDER BY' statement will use default 'id' and it will not work with JOINs.

Fixes in v1.1:

  1. The bug with namespaces of Exception class was fixed.
  2. Spacebars was added between pages in a paginator.

New in v1.2:

  1. Types of the paginator added. Enabled 'default' and 'short'. 'default' type is an old paginator with numbers. 'short' type is a new fast paginator. Use it if you work with a very big table. It includes only two buttons: previous page and next page. Stylized as a default WHMCS module logs` paginator.

The Versions

23/09 2016

dev-master

9999999-dev https://github.com/akerbel/whmcs-easy-addons

Whmcs Addon Admin Page Controller

  Sources   Download

by Anton Kerbel

whmcs

23/09 2016

v1.2.0

1.2.0.0 https://github.com/akerbel/whmcs-easy-addons

Whmcs Addon Admin Page Controller

  Sources   Download

by Anton Kerbel

whmcs

28/08 2016

v1.1.0

1.1.0.0 https://github.com/akerbel/whmcs-easy-addons

Whmcs Addon Admin Page Controller

  Sources   Download

by Anton Kerbel

whmcs

24/04 2016

v1.0.3

1.0.3.0 https://github.com/akerbel/whmcs-easy-addons

Whmcs Addon Admin Page Controller

  Sources   Download

by Anton Kerbel

whmcs

24/04 2016

1.0.1

1.0.1.0 https://github.com/akerbel/whmcs-easy-addons

Whmcs Addon Admin Page Controller

  Sources   Download

by Anton Kerbel

whmcs

14/04 2016

1.0.0

1.0.0.0 https://github.com/akerbel/whmcsaddonadminpagecontroller

Whmcs Addon Admin Page Controller

  Sources   Download

by Anton Kerbel

whmcs