Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
billythekid committed Aug 18, 2018
0 parents commit f84d311
Show file tree
Hide file tree
Showing 25 changed files with 1,278 additions and 0 deletions.
1 change: 1 addition & 0 deletions .craftplugin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"pluginName":"EZMap","pluginDescription":"EZMap integration for Craft CMS","pluginVersion":"1.0.0","pluginAuthorName":"Billy Fagan","pluginVendorName":"billythekid","pluginAuthorUrl":"https://billyfagan.co.uk","pluginAuthorGithub":"billythekid","codeComments":"yes","pluginComponents":["fieldtypes","services","settings","variables"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# CRAFT ENVIRONMENT
.env.php
.env.sh
.env

# COMPOSER
/vendor

# BUILD FILES
/bower_components/*
/node_modules/*
/build/*
/yarn-error.log

# MISC FILES
.cache
.DS_Store
.idea
.project
.settings
*.esproj
*.sublime-workspace
*.sublime-project
*.tmproj
*.tmproject
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
config.codekit3
prepros-6.config
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# EZMap Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.0.0 - 2018-08-18
### Added
- Initial release
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2018 Billy Fagan

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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

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.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# EZMap plugin for Craft CMS 3.x

[EZ Map](https://ezmap.co) integration for Craft CMS

## Requirements

This plugin requires Craft CMS 3.0.20 or later.

## Installation

To install the plugin, follow these instructions.

1. Open your terminal and go to your Craft project:

cd /path/to/project

2. Then tell Composer to load the plugin:

composer require billythekid/ezmap

3. In the Control Panel, go to Settings → Plugins and click the “Install” button for EZMap.

## EZMap Overview

This plugin adds an EZ Map field for you to automatically position your EZ Map created maps on your site.

## Configuring EZMap

Add your EZ Map email address and API Key to the plugin's settings to connect your account.

## Using EZMap

Choose the EZ Map field type in your fieldlayout. You'll then be able to choose any of your saved maps from a dropdown.

To output a map in a twig template use `{{ craft.eZMap.map(yourFieldNameHere) }}`.

For example if you added a field with the handle ezMap to an entry: `{{ craft.eZMap.map(entry.ezMap) }}`

43 changes: 43 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "billythekid/ezmap",
"description": "EZMap integration for Craft CMS",
"type": "craft-plugin",
"version": "1.0.0",
"keywords": [
"craft",
"cms",
"craftcms",
"craft-plugin",
"ezmap"
],
"support": {
"docs": "https://github.com/billythekid/ezmap/blob/master/README.md",
"issues": "https://github.com/billythekid/ezmap/issues"
},
"license": "MIT",
"authors": [
{
"name": "Billy Fagan",
"homepage": "https://billyfagan.co.uk"
}
],
"require": {
"craftcms/cms": "^3.0.0-RC1"
},
"autoload": {
"psr-4": {
"billythekid\\ezmap\\": "src/"
}
},
"extra": {
"name": "EZMap",
"handle": "ezmap",
"hasCpSettings": true,
"hasCpSection": false,
"changelogUrl": "https://raw.githubusercontent.com/billythekid/ezmap/master/CHANGELOG.md",
"components": {
"eZMapService": "billythekid\\ezmap\\services\\EZMapService"
},
"class": "billythekid\\ezmap\\EZMap"
}
}
175 changes: 175 additions & 0 deletions src/EZMap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<?php
/**
* EZMap plugin for Craft CMS 3.x
*
* EZMap integration for Craft CMS
*
* @link https://billyfagan.co.uk
* @copyright Copyright (c) 2018 Billy Fagan
*/

namespace billythekid\ezmap;

use billythekid\ezmap\services\EZMapService as EZMapServiceService;
use billythekid\ezmap\variables\EZMapVariable;
use billythekid\ezmap\models\Settings;
use billythekid\ezmap\fields\EZMapField as EZMapFieldField;

use Craft;
use craft\base\Plugin;
use craft\services\Plugins;
use craft\events\PluginEvent;
use craft\services\Fields;
use craft\web\twig\variables\CraftVariable;
use craft\events\RegisterComponentTypesEvent;

use yii\base\Event;

/**
* Craft plugins are very much like little applications in and of themselves. We’ve made
* it as simple as we can, but the training wheels are off. A little prior knowledge is
* going to be required to write a plugin.
*
* For the purposes of the plugin docs, we’re going to assume that you know PHP and SQL,
* as well as some semi-advanced concepts like object-oriented programming and PHP namespaces.
*
* https://craftcms.com/docs/plugins/introduction
*
* @author Billy Fagan
* @package EZMap
* @since 1.0.0
*
* @property EZMapServiceService $eZMapService
* @property Settings $settings
* @method Settings getSettings()
*/
class EZMap extends Plugin
{
// Static Properties
// =========================================================================

/**
* Static property that is an instance of this plugin class so that it can be accessed via
* EZMap::$plugin
*
* @var EZMap
*/
public static $plugin;

// Public Properties
// =========================================================================

/**
* To execute your plugin’s migrations, you’ll need to increase its schema version.
*
* @var string
*/
public $schemaVersion = '1.0.0';

// Public Methods
// =========================================================================

/**
* Set our $plugin static property to this class so that it can be accessed via
* EZMap::$plugin
*
* Called after the plugin class is instantiated; do any one-time initialization
* here such as hooks and events.
*
* If you have a '/vendor/autoload.php' file, it will be loaded for you automatically;
* you do not need to load it in your init() method.
*
*/
public function init()
{
parent::init();
self::$plugin = $this;

// Register our fields
Event::on(
Fields::class,
Fields::EVENT_REGISTER_FIELD_TYPES,
function (RegisterComponentTypesEvent $event) {
$event->types[] = EZMapFieldField::class;
}
);

// Register our variables
Event::on(
CraftVariable::class,
CraftVariable::EVENT_INIT,
function (Event $event) {
/** @var CraftVariable $variable */
$variable = $event->sender;
$variable->set('eZMap', EZMapVariable::class);
}
);

// Do something after we're installed
Event::on(
Plugins::class,
Plugins::EVENT_AFTER_INSTALL_PLUGIN,
function (PluginEvent $event) {
if ($event->plugin === $this) {
// We were just installed
}
}
);

/**
* Logging in Craft involves using one of the following methods:
*
* Craft::trace(): record a message to trace how a piece of code runs. This is mainly for development use.
* Craft::info(): record a message that conveys some useful information.
* Craft::warning(): record a warning message that indicates something unexpected has happened.
* Craft::error(): record a fatal error that should be investigated as soon as possible.
*
* Unless `devMode` is on, only Craft::warning() & Craft::error() will log to `craft/storage/logs/web.log`
*
* It's recommended that you pass in the magic constant `__METHOD__` as the second parameter, which sets
* the category to the method (prefixed with the fully qualified class name) where the constant appears.
*
* To enable the Yii debug toolbar, go to your user account in the AdminCP and check the
* [] Show the debug toolbar on the front end & [] Show the debug toolbar on the Control Panel
*
* http://www.yiiframework.com/doc-2.0/guide-runtime-logging.html
*/
Craft::info(
Craft::t(
'ezmap',
'{name} plugin loaded',
['name' => $this->name]
),
__METHOD__
);
}

// Protected Methods
// =========================================================================

/**
* Creates and returns the model used to store the plugin’s settings.
*
* @return \craft\base\Model|null
*/
protected function createSettingsModel()
{
return new Settings();
}

/**
* Returns the rendered settings HTML, which will be inserted into the content
* block on the settings page.
*
* @return string The rendered settings HTML
*/
protected function settingsHtml(): string
{
return Craft::$app->view->renderTemplate(
'ezmap/settings',
[
'settings' => $this->getSettings()
]
);
}
}
65 changes: 65 additions & 0 deletions src/assetbundles/ezmap/EZMapAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/**
* EZMap plugin for Craft CMS 3.x
*
* EZMap integration for Craft CMS
*
* @link https://billyfagan.co.uk
* @copyright Copyright (c) 2018 Billy Fagan
*/

namespace billythekid\ezmap\assetbundles\EZMap;

use Craft;
use craft\web\AssetBundle;
use craft\web\assets\cp\CpAsset;

/**
* EZMapAsset AssetBundle
*
* AssetBundle represents a collection of asset files, such as CSS, JS, images.
*
* Each asset bundle has a unique name that globally identifies it among all asset bundles used in an application.
* The name is the [fully qualified class name](http://php.net/manual/en/language.namespaces.rules.php)
* of the class representing it.
*
* An asset bundle can depend on other asset bundles. When registering an asset bundle
* with a view, all its dependent asset bundles will be automatically registered.
*
* http://www.yiiframework.com/doc-2.0/guide-structure-assets.html
*
* @author Billy Fagan
* @package EZMap
* @since 1.0.0
*/
class EZMapAsset extends AssetBundle
{
// Public Methods
// =========================================================================

/**
* Initializes the bundle.
*/
public function init()
{
// define the path that your publishable resources live
$this->sourcePath = "@billythekid/ezmap/assetbundles/ezmap/dist";

// define the dependencies
$this->depends = [
CpAsset::class,
];

// define the relative path to CSS/JS files that should be registered with the page
// when this asset bundle is registered
$this->js = [
'js/EZMap.js',
];

$this->css = [
'css/EZMap.css',
];

parent::init();
}
}
11 changes: 11 additions & 0 deletions src/assetbundles/ezmap/dist/css/EZMap.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* EZMap plugin for Craft CMS
*
* EZMap CSS
*
* @author Billy Fagan
* @copyright Copyright (c) 2018 Billy Fagan
* @link https://billyfagan.co.uk
* @package EZMap
* @since 1.0.0
*/
Loading

0 comments on commit f84d311

Please sign in to comment.