diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..727b337 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.git +/_build/build.config.php \ No newline at end of file diff --git a/_build/build.transport.php b/_build/build.transport.php new file mode 100644 index 0000000..eae822d --- /dev/null +++ b/_build/build.transport.php @@ -0,0 +1,141 @@ +'; +require_once dirname(__FILE__). '/build.config.php'; + + +$modx= new modX(); + + +$modx->initialize('mgr'); +$modx->setLogLevel(modX::LOG_LEVEL_INFO); +$modx->setLogTarget('ECHO'); echo '
'; flush(); + +$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->getService('lexicon','modLexicon'); +$modx->lexicon->load(PKG_NAME_LOWER.':properties'); + +/* load action/menu */ +$attributes = array ( + xPDOTransport::PRESERVE_KEYS => true, + xPDOTransport::UPDATE_OBJECT => true, + xPDOTransport::UNIQUE_KEY => 'text', + xPDOTransport::RELATED_OBJECTS => true, + xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array ( + 'Action' => array ( + xPDOTransport::PRESERVE_KEYS => false, + xPDOTransport::UPDATE_OBJECT => true, + xPDOTransport::UNIQUE_KEY => array ('namespace','controller'), + ), + ), +); + + +/* add namespace */ +$namespace = $modx->newObject('modNamespace'); +$namespace->set('name', NAMESPACE_NAME); +$namespace->set('path',"{core_path}components/".PKG_NAME_LOWER."/"); +$namespace->set('assets_path',"{assets_path}components/".PKG_NAME_LOWER."/"); +$vehicle = $builder->createVehicle($namespace,array( + xPDOTransport::UNIQUE_KEY => 'name', + xPDOTransport::PRESERVE_KEYS => true, + xPDOTransport::UPDATE_OBJECT => true, +)); +$builder->putVehicle($vehicle); +$modx->log(modX::LOG_LEVEL_INFO,"Packaged in ".NAMESPACE_NAME." namespace."); flush(); +unset($vehicle,$namespace); + +/* create category */ +$category= $modx->newObject('modCategory'); +$category->set('id',1); +$category->set('category',PKG_NAME); +$modx->log(modX::LOG_LEVEL_INFO,'Packaged in category.'); flush(); + +/* menus */ +$menus = include $sources['data'].'transport.menu.php'; +foreach($menus as $menu){ + $vehicle= $builder->createVehicle($menu, $attributes); + $builder->putVehicle($vehicle); + $modx->log(modX::LOG_LEVEL_INFO,"Packaged in ".$menu->text." menu."); +} +unset($vehicle,$action); + +/* 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', + ), + 'Plugins' => array( + xPDOTransport::PRESERVE_KEYS => false, + xPDOTransport::UPDATE_OBJECT => true, + xPDOTransport::UNIQUE_KEY => 'name', + ), + 'PluginEvents' => array( + xPDOTransport::PRESERVE_KEYS => true, + xPDOTransport::UPDATE_OBJECT => false, + xPDOTransport::UNIQUE_KEY => array('pluginid','event'), + ), + ) +); + + +$vehicle = $builder->createVehicle($category,$attr); +$vehicle->resolve('file',array( + 'source' => $sources['source_core'], + 'target' => "return MODX_CORE_PATH . 'components/';", +)); +$modx->log(modX::LOG_LEVEL_INFO,'Packaged in CorePath'); flush(); + +$vehicle->resolve('file',array( + 'source' => $sources['source_assets'], + 'target' => "return MODX_ASSETS_PATH . 'components/';", +)); +$modx->log(modX::LOG_LEVEL_INFO,'Packaged in AssetsPath'); flush(); + + +$modx->log(modX::LOG_LEVEL_INFO,'Packaged in resolvers.'); + +flush(); + +$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'), + 'changelog' => file_get_contents($sources['docs'] . 'changelog.txt'), +)); +$modx->log(modX::LOG_LEVEL_INFO,'Packaged in package attributes.'); flush(); + +$modx->log(modX::LOG_LEVEL_INFO,'Packing...'); flush(); +$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
Package Built.
\nExecution time: {$totalTime}\n"); + +exit (); + +?> diff --git a/_build/data/transport.menu.php b/_build/data/transport.menu.php new file mode 100644 index 0000000..48a3dc8 --- /dev/null +++ b/_build/data/transport.menu.php @@ -0,0 +1,41 @@ +newObject('modAction'); +$action->fromArray(array( + 'id' => 1, + 'namespace' => NAMESPACE_NAME, + 'parent' => 0, + 'controller' => 'console', + 'haslayout' => 1, + 'lang_topics' => 'console:default', + 'assets' => '', +),'',true,true); + +/* load action into menu */ +$menu= $modx->newObject('modMenu'); +$menu->fromArray(array( + 'text' => 'console', + 'parent' => 'components', + 'description' => 'console_desc', + 'icon' => 'images/icons/plugin.gif', + 'menuindex' => 0, + 'params' => '', + 'handler' => '', + 'permissions' => 'console', +),'',true,true); +$menu->addOne($action); +unset($action); + +$menus[] = $menu; + + + + +$menus[] = $menu; + +return $menus; \ No newline at end of file diff --git a/_build/includes/functions.php b/_build/includes/functions.php new file mode 100644 index 0000000..bb09fc1 --- /dev/null +++ b/_build/includes/functions.php @@ -0,0 +1,40 @@ + + * + * modExtra 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. + * + * modExtra 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 + * modExtra; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + * + * @package modextra + */ +/** + * Helper method for grabbing files + * + * @package modextra + * @subpackage build + */ + +/** + * @param string $filename + * @return mixed|string + */ +function getSnippetContent($filename) { + // print "
Try to open file: {$filename}
\n"; + $o = file_get_contents($filename); + $o = str_replace('','',$o); + $o = trim($o); + return $o; +} \ No newline at end of file diff --git a/assets/components/console/connectors/console.php b/assets/components/console/connectors/console.php new file mode 100644 index 0000000..6bb0fa1 --- /dev/null +++ b/assets/components/console/connectors/console.php @@ -0,0 +1,12 @@ +getOption('console.core_path', null, $modx->getOption('core_path').'components/console/').'processors/'; + +$modx->request->handleRequest(array( + 'processors_path' => $processor_path, + 'location' => '' +)); \ No newline at end of file diff --git a/core/components/console/console.class.php b/core/components/console/console.class.php new file mode 100644 index 0000000..518c120 --- /dev/null +++ b/core/components/console/console.class.php @@ -0,0 +1,16 @@ +config['namespace_assets_path'] = $modx->call('modNamespace','translatePath',array(&$modx, $this->config['namespace_assets_path'])); + $this->config['assets_url'] = $modx->getOption('console.assets_url', null, $modx->getOption('assets_url').'components/console/'); + $this->config['connector_url'] = $this->config['assets_url'].'connectors/'; + } + + function getTemplate($tpl) { + return $this->config['namespace_path']."templates/default/{$tpl}"; + } +} +?> diff --git a/core/components/console/controllers/.gitignore b/core/components/console/controllers/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/core/components/console/controllers/index.class.php b/core/components/console/controllers/index.class.php new file mode 100644 index 0000000..c421e56 --- /dev/null +++ b/core/components/console/controllers/index.class.php @@ -0,0 +1,16 @@ +modx->invokeEvent('OnSnipFormPrerender'); + return array( + "config" => $this->modx->toJSON($this->config), + ); + } + + function getTemplateFile() { + return $this->getTemplate('index.tpl'); + } +} +?> diff --git a/core/components/console/docs/changelog.txt b/core/components/console/docs/changelog.txt new file mode 100644 index 0000000..aa6ce31 --- /dev/null +++ b/core/components/console/docs/changelog.txt @@ -0,0 +1,3 @@ +Console-1.1.0-rc +============================================================= + diff --git a/core/components/console/docs/license.txt b/core/components/console/docs/license.txt new file mode 100644 index 0000000..e69de29 diff --git a/core/components/console/docs/readme.txt b/core/components/console/docs/readme.txt new file mode 100644 index 0000000..0941c0a --- /dev/null +++ b/core/components/console/docs/readme.txt @@ -0,0 +1,4 @@ +Console +===================================================== + +Console allow to execute php-code in front-end by simple interface. diff --git a/core/components/console/lexicon/en/default.inc.php b/core/components/console/lexicon/en/default.inc.php new file mode 100644 index 0000000..cab2027 --- /dev/null +++ b/core/components/console/lexicon/en/default.inc.php @@ -0,0 +1,5 @@ +modx->hasPermission($this->permission)){ + return false; + } + return true; + } + + public function process() { + $modx = & $this->modx; + $code = $this->getProperty('code'); + $code = preg_replace('/^ *(<\?php|<\?)/mi', '', $code); + return eval($code); + } +} + +return 'ConsoleExecProcessor'; +?> diff --git a/core/components/console/templates/default/index.tpl b/core/components/console/templates/default/index.tpl new file mode 100644 index 0000000..d6daa18 --- /dev/null +++ b/core/components/console/templates/default/index.tpl @@ -0,0 +1,86 @@ + + \ No newline at end of file