summaryrefslogtreecommitdiff
path: root/includes/edit_help_inc.php
blob: 1eb73134b3d5c2602665bd1138993b67f994d985 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
 * $Id$
 * edit_help_inc
 *
 * @author   spider <spider@steelsun.com>
 * @version  $Revision$
 * @package  liberty
 * @subpackage functions
 */

/**
 * required setup
 */
use Bitweaver\KernelTools;
global $gLibertySystem, $gBitSmarty;

$inEditor = true; // Required by PluginHelp to Determin Executed in an Editor

$dataplugins = array_merge( $gLibertySystem->getPluginsOfType( DATA_PLUGIN ), $gLibertySystem->getPluginsOfType( FILTER_PLUGIN ));
$formatplugins = $gLibertySystem->getPluginsOfType( FORMAT_PLUGIN );
$mimeplugins = $gLibertySystem->getPluginsOfType( MIME_PLUGIN );

// allow mime plugins to append help to the attachment plugin
foreach( $mimeplugins as $guid => $plugin ) {
	if( $func = $gLibertySystem->getPluginFunction( $guid, 'help_function' )) {
		$plugin['exthelp'] = $func();
		$mimeplugins[$guid]= $plugin;
	} else {
		unset( $mimeplugins[$guid] );
	}
}

// refine data plugins and add help where available
foreach( $dataplugins as $guid => $plugin ) {
	if( !empty( $plugin['description'] ) && !empty( $plugin['syntax'] )) {
		$plugin["plugin_guid"] = preg_replace( "/^(data|filter)/", "", $guid );
		$plugin["exthelp"]     = !empty( $plugin['help_function'] ) && $gLibertySystem->getPluginFunction( $guid, 'help_function' ) ? $plugin['help_function']() : '';
		$dataplugins[$guid]    = $plugin;
	} else {
		unset( $dataplugins[$guid] );
	}
}

foreach( array_keys( $formatplugins ) as $guid ) {
	// check to see if we have some format syntax help
	if( is_file( LIBERTY_PKG_PATH."templates/help_format_{$guid}_inc.tpl" )) {
		$formatplugins[$guid]['format_help'] = "bitpackage:liberty/help_format_{$guid}_inc.tpl";
		if( is_file( LIBERTY_PKG_INCLUDE_PATH.'help_format_{$guid}_inc.php' )) {
			include_once LIBERTY_PKG_INCLUDE_PATH . 'help_format_{$guid}_inc.php';
		}
	}
}

if( !empty( $formatplugins ) ) {
	usort( $formatplugins, [KernelTools::class, 'usort_by_title'] );
	$gBitSmarty->assign( 'formatplugins', $formatplugins );
}

if( !empty( $mimeplugins ) ) {
	usort( $mimeplugins, [KernelTools::class, 'usort_by_title'] );
	$gBitSmarty->assign( 'mimeplugins', $mimeplugins );
}

if( !empty( $dataplugins ) ) {
	usort( $dataplugins, [KernelTools::class, 'usort_by_title'] );
	$gBitSmarty->assign( 'dataplugins', $dataplugins );
}