-
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.
Merge pull request #2 from SnowCreative/branch-1
Branch 1
- Loading branch information
Showing
9 changed files
with
920 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
// define the MODX path constants necessary for connecting to your core | ||
//define('MODX_BASE_PATH', dirname(dirname(dirname(dirname(__FILE__)))) . '/modx097/'); | ||
define('MODX_CORE_PATH', '/path/to/modx/core/'); | ||
define('MODX_CONFIG_KEY', 'config'); | ||
?> |
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,123 @@ | ||
<?php | ||
$tstart = explode(' ', microtime()); | ||
$tstart = $tstart[1] + $tstart[0]; | ||
set_time_limit(0); | ||
|
||
|
||
function getSnippetContent($filename) { | ||
$o = file_get_contents($filename); | ||
$o = str_replace('<?php','',$o); | ||
$o = str_replace('?>','',$o); | ||
$o = trim($o); | ||
return $o; | ||
} | ||
|
||
|
||
/* define package names */ | ||
define('PKG_NAME','FixTreeSorting'); | ||
define('PKG_NAME_LOWER',strtolower(PKG_NAME)); | ||
define('PKG_VERSION','1.0'); | ||
define('PKG_RELEASE','pl'); | ||
|
||
$root = dirname(dirname(__FILE__)).'/'; | ||
$sources= array ( | ||
'root' => $root, | ||
'build' => $root .'_build/', | ||
'resolvers' => $root . '_build/resolvers/', | ||
'data' => $root . '_build/data/', | ||
'events' => $root . '_build/data/events/', | ||
'elements' => $root.'core/components/'.PKG_NAME_LOWER.'/elements/', | ||
'source_core' => $root.'core/components/fixtreesorting', | ||
'docs' => $root.'core/components/fixtreesorting/docs/', | ||
); | ||
unset($root); | ||
|
||
/* override with your own defines here (see build.config.sample.php) */ | ||
require_once $sources['build'] . 'build.config.php'; | ||
require_once MODX_CORE_PATH . 'model/modx/modx.class.php'; | ||
|
||
$modx= new modX(); | ||
$modx->initialize('mgr'); | ||
echo ''; /* used for nice formatting of log messages */ | ||
$modx->setLogLevel(modX::LOG_LEVEL_INFO); | ||
$modx->setLogTarget('ECHO'); | ||
|
||
$modx->loadClass('transport.modPackageBuilder','',false, true); | ||
$builder = new modPackageBuilder($modx); | ||
$builder->createPackage(PKG_NAME_LOWER,PKG_VERSION,PKG_RELEASE); | ||
$builder->registerNamespace(PKG_NAME_LOWER,false,true,'{core_path}components/'.PKG_NAME_LOWER.'/'); | ||
|
||
$category= $modx->newObject('modCategory'); | ||
$category->set('id',1); | ||
$category->set('category',PKG_NAME); | ||
|
||
/* create category vehicle */ | ||
$attr = array( | ||
xPDOTransport::UNIQUE_KEY => 'category', | ||
xPDOTransport::PRESERVE_KEYS => false, | ||
xPDOTransport::UPDATE_OBJECT => true, | ||
xPDOTransport::RELATED_OBJECTS => true, | ||
xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array ( | ||
'Snippets' => array( | ||
xPDOTransport::PRESERVE_KEYS => false, | ||
xPDOTransport::UPDATE_OBJECT => true, | ||
xPDOTransport::UNIQUE_KEY => 'name', | ||
), | ||
), | ||
); | ||
$vehicle = $builder->createVehicle($category,$attr); | ||
$builder->putVehicle($vehicle); | ||
|
||
|
||
|
||
/* add plugins */ | ||
$plugins = include $sources['data'].'transport.plugins.php'; | ||
if (!is_array($plugins)) { $modx->log(modX::LOG_LEVEL_FATAL,'Adding plugins failed.'); } | ||
$attributes= array( | ||
xPDOTransport::UNIQUE_KEY => 'name', | ||
xPDOTransport::PRESERVE_KEYS => false, | ||
xPDOTransport::UPDATE_OBJECT => true, | ||
xPDOTransport::RELATED_OBJECTS => true, | ||
xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array ( | ||
'PluginEvents' => array( | ||
xPDOTransport::PRESERVE_KEYS => true, | ||
xPDOTransport::UPDATE_OBJECT => false, | ||
xPDOTransport::UNIQUE_KEY => array('pluginid','event'), | ||
), | ||
), | ||
); | ||
foreach ($plugins as $plugin) { | ||
$vehicle = $builder->createVehicle($plugin, $attributes); | ||
$builder->putVehicle($vehicle); | ||
} | ||
$modx->log(modX::LOG_LEVEL_INFO,'Packaged in '.count($plugins).' plugins.'); flush(); | ||
unset($plugins,$plugin,$attributes); | ||
|
||
|
||
|
||
$modx->log(modX::LOG_LEVEL_INFO,'Adding file resolvers to category...'); | ||
$vehicle->resolve('file',array( | ||
'source' => $sources['source_core'], | ||
'target' => "return MODX_CORE_PATH . 'components/';", | ||
)); | ||
|
||
|
||
$modx->log(modX::LOG_LEVEL_INFO,'Adding package attributes and setup options...'); | ||
$builder->setPackageAttributes(array( | ||
'license' => file_get_contents($sources['docs'] . 'license.txt'), | ||
'readme' => file_get_contents($sources['docs'] . 'readme.txt'), | ||
'changelog' => file_get_contents($sources['docs'] . 'changelog.txt'), | ||
)); | ||
|
||
/* zip up package */ | ||
$modx->log(modX::LOG_LEVEL_INFO,'Packing up transport package zip...'); | ||
$builder->pack(); | ||
|
||
$tend= explode(" ", microtime()); | ||
$tend= $tend[1] + $tend[0]; | ||
$totalTime= sprintf("%2.4f s",($tend - $tstart)); | ||
$modx->log(modX::LOG_LEVEL_INFO,"\n<br />Package Built.<br />\nExecution time: {$totalTime}\n"); | ||
|
||
|
||
session_write_close(); | ||
exit (); |
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,26 @@ | ||
<?php | ||
|
||
$events = array(); | ||
|
||
$events['OnDocFormSave']= $modx->newObject('modPluginEvent'); | ||
$events['OnDocFormSave']->fromArray(array( | ||
'event' => 'OnDocFormSave', | ||
'priority' => 0, | ||
'propertyset' => 0, | ||
),'',true,true); | ||
|
||
$events['OnDocFormDelete']= $modx->newObject('modPluginEvent'); | ||
$events['OnDocFormDelete']->fromArray(array( | ||
'event' => 'OnDocFormDelete', | ||
'priority' => 0, | ||
'propertyset' => 0, | ||
),'',true,true); | ||
|
||
$events['OnResourceSort']= $modx->newObject('modPluginEvent'); | ||
$events['OnResourceSort']->fromArray(array( | ||
'event' => 'OnResourceSort', | ||
'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,22 @@ | ||
<?php | ||
$plugins = array(); | ||
|
||
/* create the plugin object */ | ||
$plugins[0] = $modx->newObject('modPlugin'); | ||
$plugins[0]->set('id',1); | ||
$plugins[0]->set('name','FixTreeSorting'); | ||
$plugins[0]->set('description','Cleans up threads when a Resource is removed.'); | ||
$plugins[0]->set('plugincode', getSnippetContent($sources['elements'] . 'plugins/fixtreesorting.plugin.php')); | ||
$plugins[0]->set('category', 0); | ||
|
||
|
||
$events = include $sources['events'].'events.fixtreesorting.php'; | ||
if (is_array($events) && !empty($events)) { | ||
$plugins[0]->addMany($events); | ||
$modx->log(xPDO::LOG_LEVEL_INFO,'Packaged in '.count($events).' Plugin Events for FixTreeSorting.'); flush(); | ||
} else { | ||
$modx->log(xPDO::LOG_LEVEL_ERROR,'Could not find plugin events for FixTreeSorting!'); | ||
} | ||
unset($events); | ||
|
||
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,6 @@ | ||
FIX TREE SORTING | ||
|
||
|
||
FixTreeSorting 1.0-pl | ||
============================== | ||
- Initial commit |
Oops, something went wrong.