-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
208 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* @var modX $modx | ||
*/ | ||
$events = array(); | ||
|
||
$ventName = 'OnPluginEventBeforeSave'; | ||
$events[$ventName] = $modx->newObject('modPluginEvent'); | ||
$events[$ventName]->fromArray(array( | ||
'event' => $ventName, | ||
'priority' => 0, | ||
'propertyset' => 0, | ||
), '', true, true); | ||
|
||
$ventName = 'OnPluginEventRemove'; | ||
$events[$ventName] = $modx->newObject('modPluginEvent'); | ||
$events[$ventName]->fromArray(array( | ||
'event' => $ventName, | ||
'priority' => 0, | ||
'propertyset' => 0, | ||
), '', true, true); | ||
|
||
return $events; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* @var modX $modx | ||
* @var array $sources | ||
*/ | ||
$plugins = array(); | ||
$idx = 0; | ||
|
||
$plugins[$idx] = $modx->newObject('modPlugin'); | ||
$plugins[$idx]->fromArray(array( | ||
'id' => $idx + 1, | ||
'name' => 'Plugin Sorter', | ||
'description' => 'This plugin automatically sets (or fix) the plugins events rank.', | ||
'plugincode' => Helper::getPHPContent($sources['elements'] . 'plugins/pluginsorter.php'), | ||
'category' => 0, | ||
), '', true, true); | ||
|
||
$events = include $sources['data'].'events/pluginsorter.php'; | ||
if (is_array($events) && !empty($events)) { | ||
$plugins[$idx]->addMany($events); | ||
$modx->log(xPDO::LOG_LEVEL_INFO, 'Packaged in '.count($events).' Plugin Events for Plugin Sorter.'); | ||
flush(); | ||
} else { | ||
$modx->log(xPDO::LOG_LEVEL_ERROR, 'Could not find plugin events for Plugin Sorter!'); | ||
} | ||
unset($events); | ||
$idx += 1; | ||
|
||
return $plugins; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
class Helper | ||
{ | ||
/** @var \modX $modx An instance of the modX object */ | ||
public $modx; | ||
/** @var array $bench An array of running benches */ | ||
protected $bench = array(); | ||
/** @var array $providers An array of available transport package providers */ | ||
protected $providers = array(); | ||
|
||
/** | ||
* Construct the object | ||
* | ||
* @param modX $modx A modX instance | ||
* @param array $options | ||
*/ | ||
public function __construct(modX &$modx, array $options = array()) | ||
{ | ||
$this->modx =& $modx; | ||
} | ||
|
||
/** | ||
* Formats the given file to be used as snippet/plugin content | ||
* | ||
* @param string $filename The path the to snippet file | ||
* | ||
* @return string The PHP content | ||
*/ | ||
public static function getPHPContent($filename) | ||
{ | ||
$o = file_get_contents($filename); | ||
$o = str_replace('<?php', '', $o); | ||
$o = str_replace('?>', '', $o); | ||
$o = trim($o); | ||
|
||
return $o; | ||
} | ||
|
||
/** | ||
* Recursively unlink/rmdir the given folder | ||
* | ||
* @param string $dir The folder to empty | ||
* | ||
* @return void | ||
*/ | ||
public static function recursiveRmDir($dir) | ||
{ | ||
if ($handle = opendir($dir)) { | ||
while (false !== ($entry = readdir($handle))) { | ||
if ($entry != "." && $entry != "..") { | ||
if (is_dir($dir."/".$entry) === true){ | ||
self::recursiveRmDir($dir."/".$entry); | ||
} else { | ||
unlink($dir."/".$entry); | ||
} | ||
} | ||
} | ||
closedir($handle); | ||
rmdir($dir); | ||
} | ||
} | ||
|
||
/** | ||
* Copy the appropriate license model to the right place | ||
* | ||
* @param array $sources An array of options defined in the build script | ||
* @param string $type The license type | ||
* | ||
* @return void | ||
*/ | ||
public static function setLicense($sources, $type) | ||
{ | ||
$source = $sources['build'] . 'license/'. strtolower($type) .'.txt'; | ||
$destination = $sources['docs'] . 'license.txt'; | ||
copy($source, $destination); | ||
} | ||
|
||
/** | ||
* Format the given array of modAccessPolicy | ||
* | ||
* @param array $permissions | ||
* | ||
* @return string JSON encoded | ||
*/ | ||
public function buildPolicyFormatData(array $permissions) | ||
{ | ||
$data = array(); | ||
/** @var modAccessPolicy $permission */ | ||
foreach ($permissions as $permission) { | ||
$data[$permission->get('name')] = true; | ||
} | ||
|
||
$data = json_encode($data); | ||
|
||
return $data; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
-------------------------------------------------------------------------------- | ||
Changelog file for PluginSorter | ||
Changelog file for Plugin Sorter | ||
-------------------------------------------------------------------------------- | ||
|
||
2013/04/23 : PluginSorter 0.1.0-beta | ||
2013/05/01 : v0.1.1-beta | ||
============================================================================== | ||
- Added a plugin to automatically set ranks when an event is attached/removed | ||
from a plugin | ||
- The setup options now make use of lexicons | ||
- The menu/CMP is now only available to users with save_plugin right | ||
|
||
2013/04/23 : v0.1.0-beta | ||
============================================================================== | ||
- First release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
-------------------------------------------------------------------------------- | ||
Extra : PluginSorter | ||
Extra : Plugin Sorter | ||
-------------------------------------------------------------------------------- | ||
Since : April 23th, 2013 | ||
Author : Romain Tripault // Melting Media <[email protected]> | ||
-------------------------------------------------------------------------------- | ||
|
||
PluginSorter allows you to define the execution order of your plugins, per event. | ||
Plugin Sorter allows you to define the execution order of your plugins, per event. | ||
|
||
Feel free to suggest ideas/improvements/submit bug reports on GitHub: | ||
https://github.com/MeltingMedia/PluginSorter/issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters