Page tree
Skip to end of metadata
Go to start of metadata

Requires: phpFox 4.5+

All configurations for your apps are set up in Install.php file. Below is an example (ToDoList app):

<?php

namespace Apps\TodoList;

use Core\App;

class Install extends App\App
{
    private $_app_phrases = [];

    protected function setId()
    {
        //Set ID for your app. This action is required.
        $this->id = 'TodoList';
    }
    protected function setSupportVersion()
    {
        //Start support version
        $this->start_support_version = '4.5.0';
    }

    protected function setAlias()
    {
        //Set alias for your app
        $this->alias = 'todo';
    }

    protected function setName()
    {
        //Set Name for your app, this name will display in manage apps (admincp)
        $this->name = 'TodoList';
    }

    protected function setVersion()
    {
        //Set version for your app
        $this->version = '4.1.2';
    }

    protected function setSettings()
    {
        //Define settings for your app
        $this->settings = [
            'td_can_user_privacy' => [
                'var_name' => 'td_can_user_privacy',
                'info' => 'Allow user add privacy',
                'description' => 'Enable this setting in case you want your user can use privacy during adding new todo list',
                'type' => 'boolean',
                'value' => '1',
            ],
            'td_feature_price' => [
                'var_name' => 'td_feature_price',
                'info' => 'How much does it cost to feature a todo list?',
                'type' => 'currency',
                'value' => serialize(['USD' => 1, 'EUR' => 1, 'GBP' => 1])
            ]
        ];
    }

    protected function setUserGroupSettings()
    {
        //Define user group settings for your app
        $this->user_group_settings = [
            'td_can_add_new_todo_list' => [
                'var_name' => 'td_can_add_new_todo_list',
                'info' => 'Can add new todo list?',
                'type' => 'boolean',
                'value' => [
                    "1" => "1",
                    "2" => "1",
                    "3" => "1",
                    "4" => "1",
                    "5" => "0"
                ],
                'ordering' => 1,
            ],
            'can_sponsor_todo' => [
                'info' => 'Can members of this user group mark a todo list as Sponsor without paying fee?',
                'type' => 'boolean',
                'value' => [
                    '1' => '1',
                    '2' => '0',
                    '3' => '0',
                    '4' => '0',
                    '5' => '0'
                ],
                'ordering' => 1,
            ],
            'todo_sponsor_price' => [
                'var_name' => 'td_user_sponsor_price',
                'info' => 'How much does it cost to sponsor a todo list',
                'type' => 'currency',
                'value' => [
                    '1' => ['USD' => 1],
                    '2' => ['USD' => 2],
                    '3' => ['USD' => 3],
                    '4' => ['USD' => 4],
                    '5' => ['USD' => 5],
                ],
            ],
            'auto_publish_sponsored_todo' => [
                'info' => 'Auto publish sponsored todo list?',
                'description' => 'After the user has purchased a sponsored space, should the todo list be published right away? If set to No, the admin will have to approve each new purchased sponsored todo list space before it is shown in the site.',
                'type' => 'boolean',
                'value' => [
                    '1' => '1',
                    '2' => '0',
                    '3' => '0',
                    '4' => '0',
                    '5' => '0'
                ],
            ],
        ];
    }

    protected function setComponent()
    {
        //Define component for your app
        $this->component = [
            "block" => [
                "recent_items" => "",
            ],
            "controller" => [
                "index" => "todo.index",
            ]
        ];
    }

    protected function setComponentBlock()
    {
        //Define component block for your app
        $this->component_block = [
            "Recent Items" => [
                "type_id"      => "0",
                "m_connection" => "todo.index",
                "component"    => "recent_items",
                "location"     => "3",
                "is_active"    => "1",
                "ordering"     => "1"
            ],
        ];
    }

    protected function setPhrase()
    {
        //Add more phrase for your app. However, for mow please define in phrase.json
        $this->phrase = $this->_app_phrases;
    }

    protected function setOthers()
    {
        //Default page of your app in AdminCP
        $this->admincp_route = {your_admincp_route};

        //Set action menu to your app in AdminCP
        $this->admincp_action_menu = [
            '{your_action_menu_link}' => {your_action_menu_name}
        ];

        //Set default menu when view app detail in AdminCP
        $this->admincp_menu = [
            'Manage To Do' => 'todo', // 'todo' is your app's alias
        ];

        //Add your app menu into main menu in frontend
        $this->menu = [
            "name" => "To Do List",  // Menu label
            "url" => "/to-do-list", // Menu Url
            "icon" => "tasks"      // Menu icons, see http://fontawesome.io/icons/
        ];

        //Your company name
        $this->_publisher = 'phpFox';

        //Your company website
        $this->_publisher_url = 'http://store.phpfox.com/';

        //Include your external paths
        $this->external_paths = [
            [
                'path' => 'PF.Base/example_folder'
                'removeable => true
            ],
            [
                'path' => 'PF.Base/example_file'
                'removeable => false
            ]
        ];

        //Include database class name
        $this->database = [
            'TodoTaskTable'
        ];
    }
}

These are all properties you can define for your app:

ID

Define

Type

Note

Version

In Function

Required?

1

id

String

This is your app ID, it must be the same folder name stored your app. Space is not allowed. This ID can't change.

4.5+

setId

Yes

2

name

String

The name of your app, it will display in manage app in admincp

4.5+

setName

Yes

3

version

String

Version of your app. It has to follow version naming convention.

4.5+

setVersion

Yes

4

alias

String

This value is used for: admincp url, block name, component name, ajax name,... This value must be lower case and no space. If your app is simple, this value can be empty.

4.5+

setAlias

No

5

icon

String

Define Icon of your app. We support 3 ways to define your app icon: Image link: Put image link of your icon here. Font awesome class: Put font awesome class here: it will display icon from font awsome. Icon image: Don't set or set empty this value, we will get file "icon.png"

4.5+

setOthers

No

6

admincp_route

String

Default page of your app in admincp

4.5+

setOthers

No

7

admincp_menu

String

Your app menu in admincp

4.5+

setOthers

No

8

admincp_help

String

You can help admin by providing your instructions external and add your url here.

4.5+

setOthers

No

9

admincp_action_menu

String

Action button of your app in admincp (The top right button)

4.5+

setOthers

No

10

map

String

Support search in feed

4.5+

setOthers

No

11

map_search

String

Support search in feed

4.5+

setOthers

No

12

menu

Array

Add a menu for your app on main menu bar

4.5+

setOthers

No

13

settings

Array

Your app's settings

4.5+

setSettings

No

14

user_group_settings

Array

Your app's user groups settings

4.5+

setUserGroupSettings

No

15

database

Array

Define database structure for your app

4.5+

setOthers

No

16

component

Array

App's components

4.5+

setComponent

No

17

component_block

Array

Default blocks

4.5+

setComponentBlock

No

18

component_block_remove

Array

Old blocks that you want to remove on upgrade your app

4.5.2+

component_block_remove

setComponentBlock

No

19

start_support_version

String

Oldest phpFox version your app can support

4.5+

setSupportVersion

No

20

end_support_version

String

Newest phpFox version your app can support

4.5+

setSupportVersion

No

21

phrase

Array

Advanced phrases

4.5+

setPhrase

No

22

_publisher

String

Your company name

4.5+

setOthers

No

23

_publisher_url

String

Your company home page

4.5+

setOthers

No

24

_apps_dir

String

Your app directory name

4.5+

setOthers

No

25

_admin_cp_menu_ajax

Boolean

Set true: menu in admincp will load by ajax; false: menu will load by refresh page. Default is true

4.5+

setOthers

No

26

_writable_dirs

Array

List all directories that your app need writable permission

4.5.3+

setOthers

No

27

external_paths

Array

List all your external directories/files that outside your app folder. You also can define which files/directories will be removed when uninstall your app.

4.5.3+

setOthers

No

28

store_id

Integer

Support to alert site admin when new version has been available in the store.

4.5+

setOthers

No

  • No labels