-
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.
Some fixes + added i18n + added automatic redirection to CMPs
- Loading branch information
Romain Tripault
committed
Jun 24, 2011
1 parent
9e3af73
commit 95b8dcf
Showing
13 changed files
with
675 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* cmpLauncher | ||
* | ||
* Copyright 2011 by Romain Tripault // Melting Media <[email protected]> | ||
* | ||
* cmpLauncher is free software; you can redistribute it and/or modify it under the | ||
* terms of the GNU General Public License as published by the Free Software | ||
* Foundation; either version 2 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* cmpLauncher is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* cmpLauncher; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
* Place, Suite 330, Boston, MA 02111-1307 USA | ||
* | ||
* @package cmplauncher | ||
*/ | ||
/** | ||
* Define the MODX path constants necessary for installation | ||
* | ||
* @package cmplauncher | ||
* @subpackage build | ||
*/ | ||
define('MODX_BASE_PATH', dirname(dirname(dirname(dirname(__FILE__)))) . '/modx/'); | ||
define('MODX_CORE_PATH', MODX_BASE_PATH . 'core/'); | ||
define('MODX_MANAGER_PATH', MODX_BASE_PATH . 'manager/'); | ||
define('MODX_CONNECTORS_PATH', MODX_BASE_PATH . 'connectors/'); | ||
define('MODX_ASSETS_PATH', MODX_BASE_PATH . 'assets/'); | ||
|
||
define('MODX_BASE_URL','/modx/'); | ||
define('MODX_CORE_URL', MODX_BASE_URL . 'core/'); | ||
define('MODX_MANAGER_URL', MODX_BASE_URL . 'manager/'); | ||
define('MODX_CONNECTORS_URL', MODX_BASE_URL . 'connectors/'); | ||
define('MODX_ASSETS_URL', MODX_BASE_URL . 'assets/'); |
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,146 @@ | ||
<?php | ||
/** | ||
* cmpLauncher | ||
* | ||
* Copyright 2011 by Romain Tripault // Melting Media <[email protected]> | ||
* | ||
* cmpLauncher is free software; you can redistribute it and/or modify it under the | ||
* terms of the GNU General Public License as published by the Free Software | ||
* Foundation; either version 2 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* cmpLauncher is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* cmpLauncher; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
* Place, Suite 330, Boston, MA 02111-1307 USA | ||
* | ||
* @package cmplauncher | ||
*/ | ||
/** | ||
* cmpLauncher build script | ||
* | ||
* @package cmplauncher | ||
* @subpackage build | ||
*/ | ||
$mtime = microtime(); | ||
$mtime = explode(' ', $mtime); | ||
$mtime = $mtime[1] + $mtime[0]; | ||
$tstart = $mtime; | ||
set_time_limit(0); | ||
|
||
/* define package */ | ||
define('PKG_NAME','cmpLauncher'); | ||
define('PKG_NAME_LOWER',strtolower(PKG_NAME)); | ||
define('PKG_VERSION','1.0.0'); | ||
define('PKG_RELEASE','beta2'); | ||
|
||
/* define sources */ | ||
$root = dirname(dirname(__FILE__)).'/'; | ||
$sources = array( | ||
'root' => $root, | ||
'build' => $root . '_build/', | ||
'data' => $root . '_build/data/', | ||
'resolvers' => $root . '_build/resolvers/', | ||
'chunks' => $root.'core/components/'.PKG_NAME_LOWER.'/elements/chunks/', | ||
'snippets' => $root.'core/components/'.PKG_NAME_LOWER.'/elements/snippets/', | ||
'plugins' => $root.'core/components/'.PKG_NAME_LOWER.'/elements/plugins/', | ||
'lexicon' => $root . 'core/components/'.PKG_NAME_LOWER.'/lexicon/', | ||
'docs' => $root.'core/components/'.PKG_NAME_LOWER.'/docs/', | ||
'pages' => $root.'core/components/'.PKG_NAME_LOWER.'/elements/pages/', | ||
'source_assets' => $root.'assets/components/'.PKG_NAME_LOWER, | ||
'source_core' => $root.'core/components/'.PKG_NAME_LOWER, | ||
); | ||
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'; | ||
require_once $sources['build'] . '/includes/functions.php'; | ||
|
||
$modx= new modX(); | ||
$modx->initialize('mgr'); | ||
echo '<pre>'; /* 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.'/'); | ||
$modx->log(modX::LOG_LEVEL_INFO,'Created Transport Package and Namespace.'); | ||
|
||
/* create the plugin object */ | ||
$plugin= $modx->newObject('modPlugin'); | ||
$plugin->set('id',1); | ||
$plugin->set('name', PKG_NAME); | ||
$plugin->set('description', 'cmpLauncher allows you to display a link or redirect a user to a particular CMP.'); | ||
$plugin->set('plugincode', getSnippetContent($sources['plugins'] . '/plugin.cmplauncher.php')); | ||
$plugin->set('category', 0); | ||
|
||
/* add plugin events */ | ||
$events = include $sources['data'].'transport.plugin.events.php'; | ||
if (is_array($events) && !empty($events)) { | ||
$plugin->addMany($events); | ||
$modx->log(xPDO::LOG_LEVEL_INFO,'Packaged in '.count($events).' Plugin Events.'); flush(); | ||
} else { | ||
$modx->log(xPDO::LOG_LEVEL_ERROR,'Could not find plugin events!'); | ||
} | ||
unset($events); | ||
|
||
/* load plugin properties */ | ||
$properties = include $sources['build'].'properties/properties.cmpLauncher.php'; | ||
if (is_array($properties)) { | ||
$modx->log(xPDO::LOG_LEVEL_INFO,'Set '.count($properties).' plugin properties.'); flush(); | ||
$plugin->setProperties($properties); | ||
} else { | ||
$modx->log(xPDO::LOG_LEVEL_ERROR,'Could not set plugin properties.'); | ||
} | ||
|
||
$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'), | ||
), | ||
), | ||
); | ||
$vehicle = $builder->createVehicle($plugin, $attributes); | ||
$vehicle->resolve('file',array( | ||
'source' => $sources['source_assets'], | ||
'target' => "return MODX_ASSETS_PATH . 'components/';", | ||
)); | ||
$vehicle->resolve('file',array( | ||
'source' => $sources['source_core'], | ||
'target' => "return MODX_CORE_PATH . 'components/';", | ||
)); | ||
$builder->putVehicle($vehicle); | ||
|
||
/* now pack in the license file, readme and setup options */ | ||
$builder->setPackageAttributes(array( | ||
'license' => file_get_contents($sources['docs'] . 'license.txt'), | ||
'readme' => file_get_contents($sources['docs'] . 'readme.txt'), | ||
)); | ||
$modx->log(modX::LOG_LEVEL_INFO,'Added package attributes and setup options.'); | ||
|
||
/* zip up package */ | ||
$modx->log(modX::LOG_LEVEL_INFO,'Packing up transport package zip...'); | ||
$builder->pack(); | ||
|
||
$mtime= microtime(); | ||
$mtime= explode(" ", $mtime); | ||
$mtime= $mtime[1] + $mtime[0]; | ||
$tend= $mtime; | ||
$totalTime= ($tend - $tstart); | ||
$totalTime= sprintf("%2.4f s", $totalTime); | ||
|
||
$modx->log(modX::LOG_LEVEL_INFO,"\n<br />Package Built.<br />\nExecution time: {$totalTime}\n"); | ||
|
||
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,38 @@ | ||
<?php | ||
/** | ||
* cmpLauncher | ||
* | ||
* Copyright 2011 by Romain Tripault // Melting Media <[email protected]> | ||
* | ||
* cmpLauncher is free software; you can redistribute it and/or modify it under the | ||
* terms of the GNU General Public License as published by the Free Software | ||
* Foundation; either version 2 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* cmpLauncher is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* cmpLauncher; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
* Place, Suite 330, Boston, MA 02111-1307 USA | ||
* | ||
* @package cmplauncher | ||
*/ | ||
/** | ||
* Add plugins to build | ||
* | ||
* @package cmplauncher | ||
* @subpackage build | ||
*/ | ||
$events = array(); | ||
|
||
$events['OnDocFormPrerender']= $modx->newObject('modPluginEvent'); | ||
$events['OnDocFormPrerender']->fromArray(array( | ||
'event' => 'OnDocFormPrerender', | ||
'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,13 @@ | ||
<?php | ||
/** | ||
* Required function(s) to build transport packages | ||
* | ||
* Copyright 2011 by Shaun McCormick <[email protected]> | ||
*/ | ||
function getSnippetContent($filename) { | ||
$o = file_get_contents($filename); | ||
$o = str_replace('<?php','',$o); | ||
$o = str_replace('?>','',$o); | ||
$o = trim($o); | ||
return $o; | ||
} |
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,47 @@ | ||
<?php | ||
/** | ||
* cmpLauncher | ||
* | ||
* Copyright 2011 by Romain Tripault // Melting Media <[email protected]> | ||
* | ||
* cmpLauncher is free software; you can redistribute it and/or modify it under the | ||
* terms of the GNU General Public License as published by the Free Software | ||
* Foundation; either version 2 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* cmpLauncher is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* cmpLauncher; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
* Place, Suite 330, Boston, MA 02111-1307 USA | ||
* | ||
* @package cmplauncher | ||
*/ | ||
/** | ||
* Properties for the cmpLauncher plugin. | ||
* | ||
* @package cmplauncher | ||
* @subpackage build | ||
*/ | ||
$properties = array( | ||
array( | ||
'name' => 'debug', | ||
'desc' => 'Enable debugging', | ||
'type' => 'combo-boolean', | ||
'options' => '', | ||
'value' => '', | ||
//'lexicon' => 'cmplauncher:properties', | ||
), | ||
array( | ||
'name' => 'cmp', | ||
'desc' => 'Set your constraints here', | ||
'type' => 'textfield', | ||
'options' => '', | ||
'value' => '', | ||
//'lexicon' => 'cmplauncher:properties', | ||
), | ||
); | ||
|
||
return $properties; |
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,12 @@ | ||
Changelog for cmpLauncher. | ||
|
||
2011/06/24 1.0.0-beta2 | ||
======================================================== | ||
- Added support for i18n | ||
- Introduced automatic redirection to the CMPs | ||
- Refactored the CSS that was causin issues with MODX | ||
manager using a foreign language | ||
|
||
2011/06/24 1.0.0-beta1 | ||
======================================================== | ||
- Initial release. |
Oops, something went wrong.