MyBB Community Forums

Full Version: MyBB Scratchboard – Post your random admin/dev stuff
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[Image: pluginmaker.png]
Nice and clean. Great icon.
Damn Shade, did you read my mind? I was thinking of writing something extremely similar recently.

As Brad said, loving the design. I especially like the button's look. I have a bit of a thing for nice buttons and input fields.
Add me into that. :p

I love the design too. What's it written in Shade? Or haven't you started actual creation yet?
TO add to Jordan's query, if you haven't started, might you be looking for a partner? I was going to add a few useful tools such as a plugin builder to MyBB Stuff.
(2013-09-17, 07:09 PM)Euan T Wrote: [ -> ]TO add to Jordan's query, if you haven't started, might you be looking for a partner? I was going to add a few useful tools such as a plugin builder to MyBB Stuff.

you finish the threaded PMs first damnit
So many ideas, so little time.

Though Vanilla were shouting about their conversation system on LinkedIn recently that gave me a few ideas...
I've started to build up the core class (since I'm not exploiting MyBB's core functions, I need to write down my own), which at the moment includes some useful variable cleaners - very similar to MyBB's ones you can find in inc/class_core.php - and a simply yet intuitive templating system.

// used to get templates
class PluginMaker {

	// the inputs received
	public $input = array();

	// the action, used to build every page
	public $action = array();
	
	// the method called
	public $request_method = "";
	
	// a comma-separated list of available pages
	public $allowed_pages = "plugin,settings";
	
	// init the class
	function __construct() {
		// clear the input
		$this->parse_incoming($_GET);
		$this->parse_incoming($_POST);
		if($_SERVER['REQUEST_METHOD'] == "POST") {
			$this->request_method = "post";
		} else if($_SERVER['REQUEST_METHOD'] == "GET") {
			$this->request_method = "get";
		}
		// validate the page
		$this->validate_page($this->input['action']);
	}
	
	// parses inputs
	function parse_incoming($array) {
		if(!is_array($array)) {
			return;
		}
		foreach($array as $key => $val) {
			$this->input[$key] = $val;
		}
	}
	
	// builds a page
	function build($page) {
		// header
		$this->get("header");
		// the actual page
		$this->get($page);
		// footer
		$this->get("footer");
	}
	
	// gets a template
	function get($template) {
		global $PM;
		$file = PM_CORE."/styles/templates/$template.php";
		if(file_exists($file)) require_once $file;
	}
	
	// echoes some page infos declared in every page such as icon class, page name, etc.
	function pageinfo($info) {
		global $page;
		if(!empty($info)) echo $page[$info];
	}
	
	// validates a page to output
	function validate_page($action) {
		$this->action = !empty($action) && in_array($action, explode(",", $this->allowed_pages)) ? $action : "index";
	}
	
	// debugs any kind of data
	function debug($data) {
		echo "<pre>";
		echo print_r($data);
		echo "</pre>";
		exit;
	}
}

This is what I got so far. It's in very early stages development but you can try it on the test board.

@Euan: yes, I'm a seer Wink

@Euan @Jordan: of course I'm always open to partners. I'll make a new repo on GitHub tomorrow with the code so you can help me building it with ease, and will provide by PM a FTP account for the test board to let you upload and test your versions!
Ah, looks like a good start. I'd started something basic, but was using the Silex framework to speed things up as there's no need for any MyBB integration.
The worst part we're gonna face is the editing files when making a new plugin. I thought about an option to revert things written on files (probably with file_put_contents) and I thought also to replicate PluginLibrary's edit_core function but it doesn't seem suitable for my intent.