-
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
7 changed files
with
185 additions
and
5 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 = 'OnTVFormSave'; | ||
$events[$ventName] = $modx->newObject('modPluginEvent'); | ||
$events[$ventName]->fromArray(array( | ||
'event' => $ventName, | ||
'priority' => 0, | ||
'propertyset' => 0, | ||
), '', true, true); | ||
|
||
$ventName = 'OnTVFormDelete'; | ||
$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' => 'TV Sorter', | ||
'description' => 'This plugin automatically sets (or fix) the TVs ranks when adding or removing a TV.', | ||
'plugincode' => Helper::getPHPContent($sources['elements'] . 'plugins/tvsorter.php'), | ||
'category' => 0, | ||
), '', true, true); | ||
|
||
$events = include $sources['data'].'events/tvsorter.php'; | ||
if (is_array($events) && !empty($events)) { | ||
$plugins[$idx]->addMany($events); | ||
$modx->log(xPDO::LOG_LEVEL_INFO, 'Packaged in '.count($events).' Plugin Events for TV Sorter.'); | ||
flush(); | ||
} else { | ||
$modx->log(xPDO::LOG_LEVEL_ERROR, 'Could not find plugin events for TV 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