├── .gitignore
├── core
└── components
│ └── modxrepository
│ ├── docs
│ ├── license.txt
│ ├── readme.txt
│ └── changelog.txt
│ ├── elements
│ ├── .gitignore
│ └── plugins
│ │ └── modxrepository.plugin.php
│ ├── templates
│ └── default
│ │ └── index.tpl
│ └── processors
│ └── rest
│ ├── verify.class.php
│ ├── package
│ ├── update.class.php
│ ├── preparerow.class.php
│ └── getpackages.class.php
│ ├── download
│ └── index.class.php
│ ├── home.class.php
│ ├── response.class.php
│ ├── repository
│ ├── getnodes.class.php
│ └── getrepositories.class.php
│ ├── repository.class.php
│ └── package.class.php
├── assets
└── components
│ └── modxrepository
│ └── packages
│ └── .gitignore
└── _build
├── data
├── transport.plugins.events.php
├── transport.plugins.php
├── transport.settings.php
├── transport.mediasources.php
└── transport.templates.php
├── includes
└── functions.php
├── build.config.sample.php
├── resolvers
└── resolve.update_objects.php
├── build.transport.php
└── setup.options.php
/.gitignore:
--------------------------------------------------------------------------------
1 | .git
2 | /_build/build.config.php
--------------------------------------------------------------------------------
/core/components/modxrepository/docs/license.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/components/modxrepository/packages/.gitignore:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/core/components/modxrepository/elements/.gitignore:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/core/components/modxrepository/templates/default/index.tpl:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/core/components/modxrepository/docs/readme.txt:
--------------------------------------------------------------------------------
1 | modxRepository by Fi1osof
2 | http://community.modx-cms.ru/profile/Fi1osof/
3 | http://modxstore.ru
4 | ========================================================
5 |
6 | This MODX Extra allow to create own repository for MODX Revolution packages
7 |
--------------------------------------------------------------------------------
/_build/data/transport.plugins.events.php:
--------------------------------------------------------------------------------
1 | newObject('modPluginEvent');
13 | $events['OnHandleRequest']->fromArray(array(
14 | 'event' => 'OnHandleRequest',
15 | 'priority' => 0,
16 | 'propertyset' => 0,
17 | ),'',true,true);
18 |
19 | return $events;
--------------------------------------------------------------------------------
/core/components/modxrepository/processors/rest/verify.class.php:
--------------------------------------------------------------------------------
1 | ';
10 |
11 | public function process(){
12 | $result = array(
13 | 'verified' => 1,
14 | );
15 |
16 | return $this->toXML($result);
17 | }
18 | }
19 | return 'modxRepositoryVerify';
20 | ?>
21 |
--------------------------------------------------------------------------------
/core/components/modxrepository/docs/changelog.txt:
--------------------------------------------------------------------------------
1 | modxRepository-1.2.3-beta
2 | =============================================================
3 | 1. modxRepositoryProcessor::__construct bugfix
4 |
5 |
6 | modxRepository-1.2.2-beta
7 | =============================================================
8 | 1. Get packages DB-request bugfix
9 |
10 |
11 | modxRepository-1.2.1-beta
12 | =============================================================
13 | 1. getRepositories processor optimization
14 |
15 |
16 | modxRepository-1.2.0-beta
17 | =============================================================
18 | 1. Added multi-contexts solution
19 | 2. Install repository bugfix
20 | 3. Minor bugfix
21 |
22 |
23 | modxRepository-1.1.0-beta
24 | =============================================================
25 | First release
--------------------------------------------------------------------------------
/_build/data/transport.plugins.php:
--------------------------------------------------------------------------------
1 | newObject('modPlugin');
13 | $plugin->set('id', null);
14 | $plugin->set('name', 'modxRepository');
15 | $plugin->set('description', '');
16 | $plugin->set('plugincode', getSnippetContent($sources['source_core'].'/elements/plugins/modxrepository.plugin.php'));
17 |
18 |
19 | /* add plugin events */
20 | $events = include $sources['data'].'transport.plugins.events.php';
21 | if (is_array($events) && !empty($events)) {
22 | $plugin->addMany($events, 'PluginEvents');
23 | $modx->log(xPDO::LOG_LEVEL_INFO,'Packaged in '.count($events).' Plugin Events.'); flush();
24 | } else {
25 | $modx->log(xPDO::LOG_LEVEL_ERROR,'Could not find plugin events!');
26 | }
27 |
28 | $plugins[] = $plugin;
29 |
30 | return $plugins;
31 |
--------------------------------------------------------------------------------
/_build/data/transport.settings.php:
--------------------------------------------------------------------------------
1 | newObject('modSystemSetting');
14 | $settings['modxRepository.handler_doc_id']->fromArray(array(
15 | 'key' => 'modxRepository.handler_doc_id',
16 | 'value' => '',
17 | 'xtype' => 'textfield',
18 | 'namespace' => 'modxrepository',
19 | 'area' => 'site',
20 | ),'',true,true);
21 |
22 |
23 | $settings['modxRepository.request_path'] = $modx->newObject('modSystemSetting');
24 | $settings['modxRepository.request_path']->fromArray(array(
25 | 'key' => 'modxRepository.request_path',
26 | 'value' => 'extras/',
27 | 'xtype' => 'textfield',
28 | 'namespace' => 'modxrepository',
29 | 'area' => 'site',
30 | ),'',true,true);
31 |
32 |
33 | return $settings;
--------------------------------------------------------------------------------
/_build/data/transport.mediasources.php:
--------------------------------------------------------------------------------
1 | array(
14 | "name" => "basePath",
15 | "desc" => "prop_file.basePath_desc",
16 | "type" => "textfield",
17 | "options" => Array(),
18 | "value" => "assets/components/modxrepository/packages/",
19 | "lexicon" => "core:source",
20 | ),
21 | "baseUrl" => Array
22 | (
23 | "name" => "baseUrl",
24 | "desc" => "prop_file.baseUrl_desc",
25 | "type" => "textfield",
26 | "options" => Array(),
27 | "value" => "assets/components/modxrepository/packages/",
28 | "lexicon" => "core:source",
29 | )
30 | );
31 |
32 | $mediaSource = $modx->newObject('sources.modMediaSource', array(
33 | 'name' => 'Repository Packages',
34 | 'class_key' => 'sources.modFileMediaSource',
35 | 'description' => 'Source for Repository packages',
36 | 'properties' => $params,
37 | ));
38 |
39 | $mediaSources[] = $mediaSource;
40 |
41 |
42 | return $mediaSources;
43 |
44 | ?>
45 |
--------------------------------------------------------------------------------
/_build/includes/functions.php:
--------------------------------------------------------------------------------
1 |
6 | *
7 | * modExtra is free software; you can redistribute it and/or modify it under the
8 | * terms of the GNU General Public License as published by the Free Software
9 | * Foundation; either version 2 of the License, or (at your option) any later
10 | * version.
11 | *
12 | * modExtra is distributed in the hope that it will be useful, but WITHOUT ANY
13 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 | * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * modExtra; if not, write to the Free Software Foundation, Inc., 59 Temple
18 | * Place, Suite 330, Boston, MA 02111-1307 USA
19 | *
20 | * @package modextra
21 | */
22 | /**
23 | * Helper method for grabbing files
24 | *
25 | * @package modextra
26 | * @subpackage build
27 | */
28 |
29 | /**
30 | * @param string $filename
31 | * @return mixed|string
32 | */
33 | function getSnippetContent($filename) {
34 | // print "
Try to open file: {$filename}
\n";
35 | $o = file_get_contents($filename);
36 | $o = str_replace('','',$o);
38 | $o = trim($o);
39 | return $o;
40 | }
--------------------------------------------------------------------------------
/_build/build.config.sample.php:
--------------------------------------------------------------------------------
1 | $root,
28 | 'build' => $root . '_build/',
29 | 'data' => $root . '_build/data/',
30 | 'resolvers' => $root . '_build/resolvers/',
31 | 'chunks' => $root.'core/components/'.PKG_PATH.'/elements/chunks/',
32 | 'snippets' => $root.'core/components/'.PKG_PATH.'/elements/snippets/',
33 | 'plugins' => $root.'core/components/'.PKG_PATH.'/elements/plugins/',
34 | 'lexicon' => $root . 'core/components/'.PKG_PATH.'/lexicon/',
35 | 'docs' => $root.'core/components/'.PKG_PATH.'/docs/',
36 | 'pages' => $root.'core/components/'.PKG_PATH.'/elements/pages/',
37 | 'source_assets' => $root.'assets/components/'.PKG_PATH,
38 | 'source_core' => $root.'core/components/'.PKG_PATH,
39 | 'templates' => $root.'core/components/'.PKG_PATH.'/elements/templates/',
40 | 'model' => $root.'core/components/'.PKG_PATH.'/model/',
41 | );
42 | unset($root);
43 |
44 |
45 | require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
46 | require_once $sources['build'] . '/includes/functions.php';
47 |
48 | $modx= new modX();
49 | $modx->initialize('mgr');
--------------------------------------------------------------------------------
/core/components/modxrepository/processors/rest/package/update.class.php:
--------------------------------------------------------------------------------
1 | ';
10 |
11 | function process(){
12 | if(!$signature = $this->properties['signature']){
13 | $this->failure('Не была получена подпись пакета');
14 | return;
15 | }
16 |
17 | $updates = array();
18 |
19 |
20 | // Получаем список всех более новых версий пакета
21 | if(!$current = $this->modx->getObject('modResource', array(
22 | 'pagetitle' => $signature,
23 | 'published' => true,
24 | 'deleted' => false,
25 | ))){
26 | $this->failure('Не был получен текущий пакет');
27 | return;
28 | }
29 |
30 | /*
31 | * Получаем все более новые пакеты
32 | */
33 |
34 | $response = $this->runProcessor('package/getpackages', array(
35 | 'where' => array(
36 | 'r.parent' => $current->parent,
37 | 'r.id:!=' => $current->id,
38 | 'r.createdon:>' => $current->createdon,
39 | ),
40 | 'sort' => array('r.publishedon, DESC'),
41 | ));
42 |
43 | if($result = $response->getResponse()){
44 | foreach($result as $r){
45 | $updates[] = array(
46 | 'package' => $this->preparePackageRow($r),
47 | );
48 | }
49 | }
50 | return $this->toXML($updates, array(
51 | 'total' => ($result?count($result):0),
52 | ));
53 | }
54 |
55 |
56 | function preparePackageRow($data){
57 | $response = $this->runProcessor('package/preparerow', $data);
58 | return $response->getResponse();
59 | }
60 | }
61 |
62 | return 'modxRepositoryPackageUpdate';
63 | ?>
64 |
--------------------------------------------------------------------------------
/core/components/modxrepository/elements/plugins/modxrepository.plugin.php:
--------------------------------------------------------------------------------
1 | context->key == 'mgr') return;
10 | if(!$modx->checkSiteStatus()) return;
11 | if(!$request_path = $modx->getOption('modxRepository.request_path', $scriptProperties, false)){
12 | return;
13 | }
14 |
15 | $request = new modRequest($modx);
16 |
17 | $resourceIdentifier = $request->getResourceIdentifier("alias");
18 |
19 | /*
20 | * Check for repository path
21 | */
22 |
23 | if(strpos($resourceIdentifier, $request_path) !== 0){
24 | return;
25 | }
26 |
27 | if(!$action = substr($resourceIdentifier, strlen($request_path))){
28 | return;
29 | }
30 | // Get processors path
31 | if(!$ns = $modx->getObject('modNamespace', 'modxrepository')){
32 | $modx->log(xPDO::LOG_LEVEL_ERROR, "Не было пролучено пространство имен modxrepository");
33 | return;
34 | }
35 | $processors_path = $ns->getCorePath().'processors/';
36 |
37 | $options = array(
38 | 'processors_path' => $processors_path,
39 | 'location' => 'rest',
40 | );
41 |
42 | if (!isset($_POST)) $_POST = array();
43 | if (!isset($_GET)) $_GET = array();
44 | $scriptProperties = array_merge($_GET,$_POST, array(
45 | 'handler_doc_id' => $modx->getOption('modxRepository.handler_doc_id', null, false),
46 | ));
47 |
48 | $actionArray = explode('/', $action);
49 |
50 | if(count($actionArray) > 1){
51 | switch($actionArray[0]){
52 | case 'repository':;
53 | $action = 'repository/getnodes';
54 | $scriptProperties = array_merge($scriptProperties, array(
55 | 'repository_id' => $actionArray[1],
56 | ));
57 | break;
58 | case 'download':
59 | $action = 'download/index';
60 | break;
61 | default :;
62 | }
63 | }
64 |
65 | if(!$response = $modx->runProcessor($action, $scriptProperties, $options)){
66 | $modx->log(xPDO::LOG_LEVEL_ERROR, "Не было пролучено пространство имен modxrepository");
67 | return;
68 | }
69 |
70 | print $response->getResponse();
71 | exit;
--------------------------------------------------------------------------------
/core/components/modxrepository/processors/rest/download/index.class.php:
--------------------------------------------------------------------------------
1 | properties['getUrl'] == true){
13 | return $this->getFileUrl($this->properties['id']);
14 | }
15 | return;
16 | }
17 |
18 | function getFileUrl($id){
19 | if(empty($id)){
20 | $this->failure('Не был получен ID пакета');
21 | return;
22 | }
23 |
24 |
25 | $response = $this->runProcessor('package/getpackages', array(
26 | 'where' => array(
27 | 'r_object_id.value' => $id,
28 | ),
29 | 'limit' => 1,
30 | 'group' => array('package_id'),
31 | 'sort' => array('r.publishedon, DESC'),
32 | ));
33 |
34 | if(!$result = $response->getResponse()){
35 | $this->failure("Не был получен пакет");
36 | return;
37 | }
38 |
39 | $package = current($result);
40 |
41 | # $this->modx->log(1, print_r($id, 1));
42 | # $this->modx->log(1, print_r($package, 1));
43 |
44 | $url = $this->modx->getOption('site_url', null);
45 |
46 | $q = $this->modx->newQuery('modTemplateVar');
47 | $q->innerJoin('modTemplateVarResource', 'v', 'v.tmplvarid = modTemplateVar.id');
48 | $q->where(array(
49 | 'v.id' => $package['file_id'],
50 | ));
51 | $tv = $this->modx->getObject('modTemplateVar', $q);
52 | $package_url = $tv->renderOutput($package['r_content_id']);
53 | $package_url = preg_replace('/^\//','',$package_url);
54 | $url .= $package_url;
55 |
56 |
57 | // Count downloads
58 | if(
59 | !empty($package['r_content_id'])
60 | AND $resource = $this->modx->getObject('modResource', $package['r_content_id'])
61 | ){
62 | $count = (int)$resource->getTVValue('downloads');
63 | $resource->setTVValue('downloads', $count + 1);
64 | }
65 |
66 | return $url;
67 | }
68 | }
69 |
70 | return 'modxRepositoryDownload';
71 | ?>
72 |
--------------------------------------------------------------------------------
/core/components/modxrepository/processors/rest/package/preparerow.class.php:
--------------------------------------------------------------------------------
1 | preparePackageRow($this->properties);
9 | }
10 |
11 | function preparePackageRow($data){
12 | $varsArray = array();
13 | $vers = array(
14 | 'version_major',
15 | 'version_minor',
16 | 'version_patch'
17 | );
18 | foreach($vers as $v){
19 | if(isset($data[$v]))$varsArray[] = ($data[$v] ? $data[$v] : '0');
20 | }
21 | $version = implode(".", $varsArray);
22 |
23 | $vrelease = $data['release']. ($data['vrelease_index'] ? "-{$data['vrelease_index']}" : "");
24 |
25 | return array(
26 | 'id' => $data['release_id'],
27 | 'r_content_id' => $data['r_content_id'],
28 | 'package' => $data['object_id'],
29 | 'display_name' => $data['release_name'],
30 | 'name' => $data['pagetitle'],
31 | 'version' => $version,
32 | 'version_major' => $varsArray[0],
33 | 'version_minor' => $varsArray[1],
34 | 'version_patch' => $varsArray[2],
35 | 'release' => $data['release'],
36 | 'vrelease' => $vrelease,
37 | 'vrelease_index' => $data['vrelease_index'],
38 | 'author' => $data['author'],
39 | 'description' => "{$data['release_description']}",
40 | 'instructions' => "{$data['instructions']}",
41 | 'changelog' => "{$data['changelog']}",
42 | 'createdon' => date('Y-m-d H:i:s', $data['release_createdon']),
43 | 'createdby' => $data['author'],
44 | 'editedon' => date('Y-m-d H:i:s', $data['release_editedon']),
45 | 'approved' => 1,
46 | 'audited' => 1,
47 | 'featured' => 1,
48 | 'deprecated' => '',
49 | 'license' => '',
50 | 'smf_url' => '',
51 | 'repository' => '',
52 | 'supports' => '',
53 | 'supports' => '2.0',
54 | 'location' => $this->modx->getOption('site_url'). $this->modx->getOption('modxRepository.request_path')."download/?id={$data['release_id']}",
55 | 'signature' => $data['release_name'],
56 | 'supports_db' => 'mysql',
57 | 'minimum_supports' => '2.0',
58 | 'breaks_at' => 10000000.0,
59 | 'screenshot' => $data['screenshot'],
60 | 'releasedon' => date('Y-m-d H:i:s', $data['release_createdon']),
61 | 'downloads' => isset($data['downloads']) ? $data['downloads'] : 0,
62 | );
63 | }
64 | }
65 |
66 | return 'modxRepositoryPackagePrepareRow';
67 | ?>
68 |
--------------------------------------------------------------------------------
/core/components/modxrepository/processors/rest/home.class.php:
--------------------------------------------------------------------------------
1 | ';
10 |
11 | public function process(){
12 | $data = $this->getData();
13 |
14 | return $this->toXML($data);
15 | }
16 |
17 | public function getData(){
18 | $result = array( );
19 |
20 | $url = $this->modx->getOption('site_url', null);
21 | $url .= $this->modx->getOption('modxRepository.request_path', null).'package/';
22 | $result['url'] = $url;
23 |
24 | // Получаем новейшие пакеты
25 | if($newest = $this->getNewest()){
26 | foreach($newest as $n){
27 | $package = $this->preparePackageRow($n);
28 | $result[] = array(
29 | 'newest' => array(
30 | 'id' => $package['id'],
31 | 'name' => "{$package['name']} {$package['version']}-{$package['vrelease']} ",
32 | 'package_name' => $package['name'],
33 | 'releasedon' => $package['releasedon'],
34 | ),
35 | );
36 | }
37 | }
38 |
39 |
40 | // Получаем самые популярные
41 | if($popular = $this->getPopular()){
42 | foreach($popular as $n){
43 | $package = $this->preparePackageRow($n);
44 | $result[] = array(
45 | 'topdownloaded' => array(
46 | 'id' => $package['id'],
47 | 'name' => $package['name'],
48 | 'downloads' => $package['downloads'],
49 | ),
50 | );
51 | }
52 | }
53 |
54 |
55 | if(!empty($newest)) $result['packages'] = count($newest);
56 | return $result;
57 | }
58 |
59 | function getNewest(){
60 | $response = $this->runProcessor('package/getpackages', array(
61 | 'where' => array(
62 | ),
63 | 'sort' => array('releasedon, DESC'),
64 | 'group' => array('package_id'),
65 | 'limit' => 10,
66 | 'root' => $this->getProperty('handler_doc_id'),
67 | ));
68 |
69 | if($result = $response->getResponse()){
70 | foreach($result as $r){
71 | $updates[] = array(
72 | 'package' => $this->preparePackageRow($r),
73 | );
74 | }
75 | }
76 |
77 | return $result;
78 | }
79 |
80 | function getPopular(){
81 | return $this->getNewest();
82 | }
83 |
84 | function preparePackageRow($data){
85 | $response = $this->runProcessor('package/preparerow', $data);
86 | return $response->getResponse();
87 | }
88 | }
89 | return 'modxRepositoryHome';
90 | ?>
91 |
--------------------------------------------------------------------------------
/core/components/modxrepository/processors/rest/response.class.php:
--------------------------------------------------------------------------------
1 | getObject('modNamespace', 'modxrepository')){
15 | $err = "Не было получено пространство имен modxrepository";
16 | $modx->log(xPDO::LOG_LEVEL_ERROR, $err);
17 | $this->failure($err);
18 | return;
19 | }
20 |
21 | // Get processors params
22 | $this->processorsParams = array(
23 | 'processors_path' => $ns->getCorePath().'processors/',
24 | 'location' => 'rest/',
25 | );
26 |
27 | /*
28 | * Be sure you set system setting modxRepository.handler_doc_id
29 | */
30 | if(!$this->parent = $modx->getOption('modxRepository.handler_doc_id', null, false)){
31 | return $modx->log( xPDO::LOG_LEVEL_ERROR, 'Please, be sure you set system setting modxRepository.handler_doc_id');
32 | }
33 | }
34 |
35 | public function runProcessor($action, $scriptProperties = array()){
36 | if(!$this->processorsParams){
37 | $this->failure("Не были получены данные процессоров");
38 | return false;
39 | }
40 | return $this->modx->runProcessor($action, $scriptProperties, $this->processorsParams);
41 | }
42 | }
43 |
44 | abstract class modxRepositoryResponse extends modxRepositoryProcessor{
45 | var $root = '
'; flush();
38 |
39 | $modx->loadClass('transport.modPackageBuilder','',false, true);
40 | $builder = new modPackageBuilder($modx);
41 | $builder->createPackage(PKG_NAME_LOWER,PKG_VERSION,PKG_RELEASE);
42 | $builder->registerNamespace(PKG_NAME_LOWER,false,true,'{core_path}components/'.PKG_NAME_LOWER.'/');
43 | $modx->getService('lexicon','modLexicon');
44 | $modx->lexicon->load(PKG_NAME_LOWER.':properties');
45 |
46 | /* load action/menu */
47 | $attributes = array (
48 | xPDOTransport::PRESERVE_KEYS => true,
49 | xPDOTransport::UPDATE_OBJECT => true,
50 | xPDOTransport::UNIQUE_KEY => 'text',
51 | xPDOTransport::RELATED_OBJECTS => true,
52 | xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array (
53 | 'Action' => array (
54 | xPDOTransport::PRESERVE_KEYS => false,
55 | xPDOTransport::UPDATE_OBJECT => true,
56 | xPDOTransport::UNIQUE_KEY => array ('namespace','controller'),
57 | ),
58 | ),
59 | );
60 |
61 |
62 | /* add namespace */
63 | $namespace = $modx->newObject('modNamespace');
64 | $namespace->set('name', NAMESPACE_NAME);
65 | $namespace->set('path',"{core_path}components/".PKG_NAME_LOWER."/");
66 | $namespace->set('assets_path',"{assets_path}components/".PKG_NAME_LOWER."/");
67 | $vehicle = $builder->createVehicle($namespace,array(
68 | xPDOTransport::UNIQUE_KEY => 'name',
69 | xPDOTransport::PRESERVE_KEYS => true,
70 | xPDOTransport::UPDATE_OBJECT => true,
71 | ));
72 | $builder->putVehicle($vehicle);
73 | $modx->log(modX::LOG_LEVEL_INFO,"Packaged in ".NAMESPACE_NAME." namespace."); flush();
74 | unset($vehicle,$namespace);
75 |
76 | /* create category */
77 | $category= $modx->newObject('modCategory');
78 | $category->set('id',1);
79 | $category->set('category',PKG_NAME);
80 | $modx->log(modX::LOG_LEVEL_INFO,'Packaged in category.'); flush();
81 |
82 |
83 | /* create category vehicle */
84 | $attr = array(
85 | xPDOTransport::UNIQUE_KEY => 'category',
86 | xPDOTransport::PRESERVE_KEYS => false,
87 | xPDOTransport::UPDATE_OBJECT => true,
88 | xPDOTransport::RELATED_OBJECTS => true,
89 | xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array (
90 | 'Snippets' => array(
91 | xPDOTransport::PRESERVE_KEYS => false,
92 | xPDOTransport::UPDATE_OBJECT => true,
93 | xPDOTransport::UNIQUE_KEY => 'name',
94 | ),
95 | 'Plugins' => array(
96 | xPDOTransport::PRESERVE_KEYS => false,
97 | xPDOTransport::UPDATE_OBJECT => true,
98 | xPDOTransport::UNIQUE_KEY => 'name',
99 | ),
100 | 'PluginEvents' => array(
101 | xPDOTransport::PRESERVE_KEYS => true,
102 | xPDOTransport::UPDATE_OBJECT => false,
103 | xPDOTransport::UNIQUE_KEY => array('pluginid','event'),
104 | ),
105 | 'Templates' => array(
106 | xPDOTransport::PRESERVE_KEYS => false,
107 | xPDOTransport::UPDATE_OBJECT => true,
108 | xPDOTransport::UNIQUE_KEY => 'templatename',
109 | ),
110 | 'TemplateVars' => array(
111 | xPDOTransport::PRESERVE_KEYS => false,
112 | xPDOTransport::UPDATE_OBJECT => true,
113 | xPDOTransport::UNIQUE_KEY => 'name',
114 | ),
115 | )
116 | );
117 |
118 |
119 | /* add plugins */
120 | $plugins = include $sources['data'].'transport.plugins.php';
121 | if (!is_array($plugins)) { $modx->log(modX::LOG_LEVEL_FATAL,'Adding plugins failed.'); }
122 | else{
123 | $category->addMany($plugins);
124 | $modx->log(modX::LOG_LEVEL_INFO,'Packaged in '.count($plugins).' plugins.'); flush();
125 | }
126 |
127 | unset($plugins,$plugin,$attributes);
128 |
129 |
130 | /* Add templates */
131 | $templates = include $sources['data'].'transport.templates.php';
132 | if (!is_array($templates)) { $modx->log(modX::LOG_LEVEL_FATAL,'Adding templates failed.'); }
133 | else{
134 | $category->addMany($templates);
135 | $modx->log(modX::LOG_LEVEL_INFO,'Packaged in '.count($templates).' templates.'); flush();
136 | }
137 |
138 |
139 | /* Create mediaSources */
140 | $mediaSources = include $sources['data'].'transport.mediasources.php';
141 | if (!is_array($mediaSources)) { $modx->log(modX::LOG_LEVEL_ERROR,'Adding MediaSources failed.'); }
142 | else{
143 | $vehicleParams = array(
144 | xPDOTransport::PRESERVE_KEYS => false,
145 | xPDOTransport::UPDATE_OBJECT => false,
146 | xPDOTransport::UNIQUE_KEY => 'name',
147 | );
148 |
149 | foreach($mediaSources as & $mediaSource){
150 | $vehicle = $builder->createVehicle($mediaSource, $vehicleParams);
151 | $builder->putVehicle($vehicle);
152 | }
153 | $modx->log(modX::LOG_LEVEL_INFO,'Packaged in '.count($mediaSources).' MediaSources.'); flush();
154 | }
155 |
156 | /* load system settings */
157 | $settings = include_once $sources['data'].'transport.settings.php';
158 | $attributes= array(
159 | xPDOTransport::UNIQUE_KEY => 'key',
160 | xPDOTransport::PRESERVE_KEYS => true,
161 | xPDOTransport::UPDATE_OBJECT => false,
162 | );
163 | if (!is_array($settings)) { $modx->log(modX::LOG_LEVEL_ERROR,'Adding settings failed.'); }
164 | foreach ($settings as $setting) {
165 | $vehicle = $builder->createVehicle($setting,$attributes);
166 | $builder->putVehicle($vehicle);
167 | }
168 | $modx->log(modX::LOG_LEVEL_INFO,'Packaged in '.count($settings).' system settings.'); flush();
169 | unset($settings,$setting,$attributes);
170 |
171 |
172 | /* create main category */
173 | $vehicle = $builder->createVehicle($category,$attr);
174 | $vehicle->resolve('file',array(
175 | 'source' => $sources['source_core'],
176 | 'target' => "return MODX_CORE_PATH . 'components/';",
177 | ));
178 | $modx->log(modX::LOG_LEVEL_INFO,'Packaged in CorePath'); flush();
179 | $vehicle->resolve('file',array(
180 | 'source' => $sources['source_assets'],
181 | 'target' => "return MODX_ASSETS_PATH . 'components/';",
182 | ));
183 | $modx->log(modX::LOG_LEVEL_INFO,'Packaged in AssetsPath'); flush();
184 |
185 | $vehicle->resolve('php',array(
186 | 'source' => $sources['resolvers'] . 'resolve.update_objects.php',
187 | ));
188 |
189 |
190 | $modx->log(modX::LOG_LEVEL_INFO,'Packaged in resolvers.');
191 |
192 | flush();
193 |
194 | $builder->putVehicle($vehicle);
195 |
196 | /* now pack in the license file, readme and setup options */
197 | $builder->setPackageAttributes(array(
198 | 'license' => file_get_contents($sources['docs'] . 'license.txt'),
199 | 'readme' => file_get_contents($sources['docs'] . 'readme.txt'),
200 | 'changelog' => file_get_contents($sources['docs'] . 'changelog.txt'),
201 | 'setup-options' => array(
202 | 'source' => $sources['build'].'setup.options.php',
203 | ),
204 | ));
205 | $modx->log(modX::LOG_LEVEL_INFO,'Packaged in package attributes.'); flush();
206 |
207 | $modx->log(modX::LOG_LEVEL_INFO,'Packing...'); flush();
208 | $builder->pack();
209 |
210 | $mtime= microtime();
211 | $mtime= explode(" ", $mtime);
212 | $mtime= $mtime[1] + $mtime[0];
213 | $tend= $mtime;
214 | $totalTime= ($tend - $tstart);
215 | $totalTime= sprintf("%2.4f s", $totalTime);
216 |
217 | $modx->log(modX::LOG_LEVEL_INFO,"\n
Package Built.
\nExecution time: {$totalTime}\n");
218 |
219 | exit ();
220 |
221 | ?>
222 |
--------------------------------------------------------------------------------
/_build/setup.options.php:
--------------------------------------------------------------------------------
1 | Please, don`t forget set Extra_path document ID in system settings after create repository structure.';
11 |
12 | $img = "
";
13 |
14 | $output .= "{$img}
";
15 |
16 | return $output;
17 |
18 | break;
19 | case xPDOTransport::ACTION_UNINSTALL: break;
20 | }
21 |
--------------------------------------------------------------------------------