Skip to content

Commit 4fb9c9c

Browse files
committedFeb 4, 2019
Cross Copy Initial Push
1 parent 124f056 commit 4fb9c9c

27 files changed

+1298
-0
lines changed
 

‎.craftplugin

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"pluginName":"Cross Copy","pluginDescription":"Copy a matrix from one project to another","pluginVersion":"1.0.0","pluginAuthorName":"Michael Butler","pluginVendorName":"crossCopy","pluginAuthorUrl":"michael@ipopdigital.com","pluginAuthorGithub":"","codeComments":"yes","pluginComponents":["controllers","cpsection","models","records","services","settings"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}

‎.gitignore

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# CRAFT ENVIRONMENT
2+
.env.php
3+
.env.sh
4+
.env
5+
6+
# COMPOSER
7+
/vendor
8+
9+
# BUILD FILES
10+
/bower_components/*
11+
/node_modules/*
12+
/build/*
13+
/yarn-error.log
14+
15+
# MISC FILES
16+
.cache
17+
.DS_Store
18+
.idea
19+
.project
20+
.settings
21+
*.esproj
22+
*.sublime-workspace
23+
*.sublime-project
24+
*.tmproj
25+
*.tmproject
26+
.vscode/*
27+
!.vscode/settings.json
28+
!.vscode/tasks.json
29+
!.vscode/launch.json
30+
!.vscode/extensions.json
31+
config.codekit3
32+
prepros-6.config

‎CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Cross Copy Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
6+
7+
## 1.0.0 - 2019-01-15
8+
### Added
9+
- Initial release

‎LICENSE.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 Michael Butler
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

‎composer.json

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "crosscopy/cross-copy",
3+
"description": "Copy a matrix from one project to another",
4+
"type": "craft-plugin",
5+
"version": "1.0.0",
6+
"keywords": [
7+
"craft",
8+
"cms",
9+
"craftcms",
10+
"craft-plugin",
11+
"cross copy"
12+
],
13+
"support": {
14+
"docs": "???",
15+
"issues": "???"
16+
},
17+
"license": "MIT",
18+
"authors": [
19+
{
20+
"name": "Michael Butler",
21+
"homepage": "michael@ipopdigital.com"
22+
}
23+
],
24+
"require": {
25+
"craftcms/cms": "^3.0.0-RC1"
26+
},
27+
"autoload": {
28+
"psr-4": {
29+
"crosscopy\\crosscopy\\": "src/"
30+
}
31+
},
32+
"extra": {
33+
"name": "Cross Copy",
34+
"handle": "cross-copy",
35+
"hasCpSettings": true,
36+
"hasCpSection": true,
37+
"changelogUrl": "???",
38+
"components": {
39+
"crossCopyService": "crosscopy\\crosscopy\\services\\CrossCopyService"
40+
},
41+
"class": "crosscopy\\crosscopy\\CrossCopy"
42+
}
43+
}

‎resources/img/plugin-logo.png

3.06 KB
Loading

‎src/CrossCopy.php

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<?php
2+
/**
3+
* Cross Copy plugin for Craft CMS 3.x
4+
*
5+
* Copy a matrix from one project to another
6+
*
7+
* @link michael@ipopdigital.com
8+
* @copyright Copyright (c) 2019 Michael Butler
9+
*/
10+
11+
namespace crosscopy\crosscopy;
12+
13+
use crosscopy\crosscopy\services\CrossCopyService as CrossCopyServiceService;
14+
use crosscopy\crosscopy\models\Settings;
15+
16+
use Craft;
17+
use craft\base\Plugin;
18+
use craft\services\Plugins;
19+
use craft\events\PluginEvent;
20+
use craft\web\UrlManager;
21+
use craft\events\RegisterUrlRulesEvent;
22+
23+
use yii\base\Event;
24+
25+
/**
26+
* Craft plugins are very much like little applications in and of themselves. We’ve made
27+
* it as simple as we can, but the training wheels are off. A little prior knowledge is
28+
* going to be required to write a plugin.
29+
*
30+
* For the purposes of the plugin docs, we’re going to assume that you know PHP and SQL,
31+
* as well as some semi-advanced concepts like object-oriented programming and PHP namespaces.
32+
*
33+
* https://craftcms.com/docs/plugins/introduction
34+
*
35+
* @author Michael Butler
36+
* @package CrossCopy
37+
* @since 1.0.0
38+
*
39+
* @property CrossCopyServiceService $crossCopyService
40+
* @property Settings $settings
41+
* @method Settings getSettings()
42+
*/
43+
class CrossCopy extends Plugin
44+
{
45+
// Static Properties
46+
// =========================================================================
47+
48+
/**
49+
* Static property that is an instance of this plugin class so that it can be accessed via
50+
* CrossCopy::$plugin
51+
*
52+
* @var CrossCopy
53+
*/
54+
public static $plugin;
55+
56+
// Public Properties
57+
// =========================================================================
58+
59+
/**
60+
* To execute your plugin’s migrations, you’ll need to increase its schema version.
61+
*
62+
* @var string
63+
*/
64+
public $schemaVersion = '1.0.0';
65+
66+
// Public Methods
67+
// =========================================================================
68+
69+
/**
70+
* Set our $plugin static property to this class so that it can be accessed via
71+
* CrossCopy::$plugin
72+
*
73+
* Called after the plugin class is instantiated; do any one-time initialization
74+
* here such as hooks and events.
75+
*
76+
* If you have a '/vendor/autoload.php' file, it will be loaded for you automatically;
77+
* you do not need to load it in your init() method.
78+
*
79+
*/
80+
public function init()
81+
{
82+
parent::init();
83+
self::$plugin = $this;
84+
85+
// Register our site routes
86+
Event::on(
87+
UrlManager::class,
88+
UrlManager::EVENT_REGISTER_SITE_URL_RULES,
89+
function (RegisterUrlRulesEvent $event) {
90+
$event->rules['siteActionTrigger1'] = 'cross-copy/default';
91+
}
92+
);
93+
94+
// Register our CP routes
95+
Event::on(
96+
UrlManager::class,
97+
UrlManager::EVENT_REGISTER_CP_URL_RULES,
98+
function (RegisterUrlRulesEvent $event) {
99+
$event->rules['cpActionTrigger1'] = 'cross-copy/default/do-something';
100+
}
101+
);
102+
103+
// Do something after we're installed
104+
Event::on(
105+
Plugins::class,
106+
Plugins::EVENT_AFTER_INSTALL_PLUGIN,
107+
function (PluginEvent $event) {
108+
if ($event->plugin === $this) {
109+
// We were just installed
110+
}
111+
}
112+
);
113+
114+
/**
115+
* Logging in Craft involves using one of the following methods:
116+
*
117+
* Craft::trace(): record a message to trace how a piece of code runs. This is mainly for development use.
118+
* Craft::info(): record a message that conveys some useful information.
119+
* Craft::warning(): record a warning message that indicates something unexpected has happened.
120+
* Craft::error(): record a fatal error that should be investigated as soon as possible.
121+
*
122+
* Unless `devMode` is on, only Craft::warning() & Craft::error() will log to `craft/storage/logs/web.log`
123+
*
124+
* It's recommended that you pass in the magic constant `__METHOD__` as the second parameter, which sets
125+
* the category to the method (prefixed with the fully qualified class name) where the constant appears.
126+
*
127+
* To enable the Yii debug toolbar, go to your user account in the AdminCP and check the
128+
* [] Show the debug toolbar on the front end & [] Show the debug toolbar on the Control Panel
129+
*
130+
* http://www.yiiframework.com/doc-2.0/guide-runtime-logging.html
131+
*/
132+
Craft::info(
133+
Craft::t(
134+
'cross-copy',
135+
'{name} plugin loaded',
136+
['name' => $this->name]
137+
),
138+
__METHOD__
139+
);
140+
}
141+
142+
// Protected Methods
143+
// =========================================================================
144+
145+
/**
146+
* Creates and returns the model used to store the plugin’s settings.
147+
*
148+
* @return \craft\base\Model|null
149+
*/
150+
protected function createSettingsModel()
151+
{
152+
return new Settings();
153+
}
154+
155+
/**
156+
* Returns the rendered settings HTML, which will be inserted into the content
157+
* block on the settings page.
158+
*
159+
* @return string The rendered settings HTML
160+
*/
161+
protected function settingsHtml(): string
162+
{
163+
return Craft::$app->view->renderTemplate(
164+
'cross-copy/settings',
165+
[
166+
'settings' => $this->getSettings()
167+
]
168+
);
169+
}
170+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* Cross Copy plugin for Craft CMS 3.x
4+
*
5+
* Copy a matrix from one project to another
6+
*
7+
* @link michael@ipopdigital.com
8+
* @copyright Copyright (c) 2019 Michael Butler
9+
*/
10+
11+
namespace crosscopy\crosscopy\assetbundles\CrossCopy;
12+
13+
use Craft;
14+
use craft\web\AssetBundle;
15+
use craft\web\assets\cp\CpAsset;
16+
17+
/**
18+
* CrossCopyAsset AssetBundle
19+
*
20+
* AssetBundle represents a collection of asset files, such as CSS, JS, images.
21+
*
22+
* Each asset bundle has a unique name that globally identifies it among all asset bundles used in an application.
23+
* The name is the [fully qualified class name](http://php.net/manual/en/language.namespaces.rules.php)
24+
* of the class representing it.
25+
*
26+
* An asset bundle can depend on other asset bundles. When registering an asset bundle
27+
* with a view, all its dependent asset bundles will be automatically registered.
28+
*
29+
* http://www.yiiframework.com/doc-2.0/guide-structure-assets.html
30+
*
31+
* @author Michael Butler
32+
* @package CrossCopy
33+
* @since 1.0.0
34+
*/
35+
class CrossCopyAsset extends AssetBundle
36+
{
37+
// Public Methods
38+
// =========================================================================
39+
40+
/**
41+
* Initializes the bundle.
42+
*/
43+
public function init()
44+
{
45+
// define the path that your publishable resources live
46+
$this->sourcePath = "@crosscopy/crosscopy/assetbundles/crosscopy/dist";
47+
48+
// define the dependencies
49+
$this->depends = [
50+
CpAsset::class,
51+
];
52+
53+
// define the relative path to CSS/JS files that should be registered with the page
54+
// when this asset bundle is registered
55+
$this->js = [
56+
'js/CrossCopy.js',
57+
];
58+
59+
$this->css = [
60+
'css/CrossCopy.css',
61+
];
62+
63+
parent::init();
64+
}
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Cross Copy plugin for Craft CMS
3+
*
4+
* Cross Copy CSS
5+
*
6+
* @author Michael Butler
7+
* @copyright Copyright (c) 2019 Michael Butler
8+
* @link michael@ipopdigital.com
9+
* @package CrossCopy
10+
* @since 1.0.0
11+
*/

0 commit comments

Comments
 (0)
Please sign in to comment.