Skip to content

gocom/rah_terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rah_terminal

Twitter | GitHub | Donate

Rah_terminal is a plugin for Textpattern CMS. It provides a terminal emulator interface for executing external applications, commands and evaluating PHP code, right from Textpattern’s admin-panel.

Installing

Using Composer:

$ composer.phar require rah/rah_terminal

Toolshed notice

This is a toolshed project. Experimental and not part of the main supported product line of Rah. Not yet at least. Please use at your own risk.

Requirements

  • Textpattern 4.5.0 or newer.

Modules

Modules can be used to extend rah_terminal’s functionality, adding additional terminal types. Modules are like any other Textpattern plugin, and can be installed the same way. The following modules are available.

Extending

The plugin comes small API which can be used to add additional terminal types to plugin. By default the plugin comes with options PHP, SQL and Shell, but that can be extended to include a Textile Generator among other things. These added terminal types act same as the built in ones do. A callback function is registered, and everything that the callback functions prints or returns to global scope, will be shown to the user. Thrown exceptions and errors are captured too.

API

rah_terminal::get() – Gets an instance of rah_terminal class

object rah_terminal::get();

get() is your standard factory method, following a loose singleton pattern. It returns an instance of the rah_terminal class. When creating an object, always use get() instead of creating new instance yourself.

rah_terminal::add_terminal() – Adds a new terminal option

object rah_terminal::add_terminal( string $name, string|null $label, callback $callback );

add_terminal() adds and registers a new terminal option. The first parameter $name is a unique name for the terminal option, $label is the label shown to users and $callback is the callback function.

When registering new labels, please use prefixes in the $name and the $callback function to avoid conflicts with other codebases, including Textpattern core and rah_terminal itself. For more information about prefixing please see Textpattern’s Plugin Development Guidelines.

To use add_terminal() you would first get an instance of rah_terminal using the static method get().

rah_terminal::get()
	->add_terminal('abc_example', gTxt('abc_example_label'), 'abc_example_function');

add_privs() – Grants user-groups privileges to a terminal option

mixed add_privs(string $event, string $groups);

add_privs() is a standard Textpattern function. In Textpattern it’s used to grant permission. Rah_terminal uses it for same thing, to grant users access to terminal options. This is to allow and limit from certain groups access to some terminals, while allowing access to others.

$event is the name of the “event” which the access is allowed, and $groups is comma-separated list of user-group numbers. Note that neither allow any whitespace.

Rah_terminal’s events are prefixed with rah_terminal.. And terminal event name would consist of the prefix, followed by the terminal options name, given with the add_terminal() methods first parameter. For terminal option named as abc_example, add_privs line would look like following:

add_privs('rah_terminal.abc_example', '1,2,3,4');

Changelog

Version 0.1.1 – 2013/05/07

Version 0.1.0 – 2013/04/24

  • Initial release.

About

A terminal for Textpattern CMS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages