From f4f134a3aae5e0795265ccd5842c517a5a6667a3 Mon Sep 17 00:00:00 2001 From: Marion Newlevant Date: Tue, 7 May 2019 18:34:45 -0700 Subject: [PATCH] initial commit --- CHANGELOG.md | 9 ++ LICENSE.md | 9 ++ README.md | 33 +++++++ composer.json | 43 +++++++++ resources/screenshots/ElementLink.png | Bin 0 -> 10961 bytes src/ElementLink.php | 87 ++++++++++++++++++ .../elementlink/ElementLinkAsset.php | 58 ++++++++++++ .../elementlink/dist/css/elementlink.css | 66 +++++++++++++ .../dist/img/elementLink-focus.svg | 10 ++ .../elementlink/dist/img/elementLink.svg | 10 ++ .../elementlink/dist/js/elementlink.js | 39 ++++++++ src/controllers/DefaultController.php | 79 ++++++++++++++++ src/icon.svg | 13 +++ src/services/ElementLinkService.php | 54 +++++++++++ src/translations/en/element-link.php | 25 +++++ 15 files changed, 535 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 composer.json create mode 100644 resources/screenshots/ElementLink.png create mode 100644 src/ElementLink.php create mode 100644 src/assetbundles/elementlink/ElementLinkAsset.php create mode 100644 src/assetbundles/elementlink/dist/css/elementlink.css create mode 100644 src/assetbundles/elementlink/dist/img/elementLink-focus.svg create mode 100644 src/assetbundles/elementlink/dist/img/elementLink.svg create mode 100644 src/assetbundles/elementlink/dist/js/elementlink.js create mode 100644 src/controllers/DefaultController.php create mode 100644 src/icon.svg create mode 100644 src/services/ElementLinkService.php create mode 100644 src/translations/en/element-link.php diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..cfcbb4d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Element Link 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 - 2019-05-07 +### Added +- Initial release diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..80fd4b9 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,9 @@ +The MIT License (MIT) + +Copyright (c) 2019 Marion Newlevant + +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. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..fee8b3c --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# Element Link plugin for Craft CMS 3.x + +Add a link to the CP edit page for Entries, Categories, and other Elements + +![Screenshot](resources/screenshots/ElementLink.png) + +## Requirements + +This plugin requires Craft CMS 3.0.0-beta.23 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 craft-element_link/element-link + +3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Element Link. + +or + +1. Install via the Plugin Store + +Brought to you by [Marion Newlevant](http://marion.newlevant.com) + +Inspired in part by the [Download Assets](https://plugins.craftcms.com/download-assets) plugin. + +Icon: link by Gregor Cresnar from the Noun Project diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..e65714a --- /dev/null +++ b/composer.json @@ -0,0 +1,43 @@ +{ + "name": "marionnewlevant/element-link", + "description": "Add a link to the CP edit page for Entries, Categories, and other Elements", + "type": "craft-plugin", + "version": "1.0.0", + "keywords": [ + "craft", + "cms", + "craftcms", + "craft-plugin", + "element link" + ], + "support": { + "docs": "https://github.com/craft-element_link/element-link/blob/master/README.md", + "issues": "https://github.com/craft-element_link/element-link/issues" + }, + "license": "MIT", + "authors": [ + { + "name": "Marion Newlevant", + "homepage": "http://marion.newlevant.com" + } + ], + "require": { + "craftcms/cms": "^3.0.0-RC1" + }, + "autoload": { + "psr-4": { + "marionnewlevant\\elementlink\\": "src/" + } + }, + "extra": { + "name": "Element Link", + "handle": "element-link", + "hasCpSettings": false, + "hasCpSection": false, + "changelogUrl": "https://raw.githubusercontent.com/craft-element_link/element-link/master/CHANGELOG.md", + "components": { + "elementLinkService": "marionnewlevant\\elementlink\\services\\ElementLinkService" + }, + "class": "marionnewlevant\\elementlink\\ElementLink" + } +} diff --git a/resources/screenshots/ElementLink.png b/resources/screenshots/ElementLink.png new file mode 100644 index 0000000000000000000000000000000000000000..3029b2d16253f5ad1f7f68208834f6eb7f98697c GIT binary patch literal 10961 zcmdUUWmH{FvnFzIcejJPyZZ_5?yd&{1b26bkl?OCgG+FC3+@mcf;+?e-8=Vwv*zdg zxwC)t>RtWRQ@g6yUR_lkrJ^K@f=Gx60Re&X2_&Tk0RajBF%N-<{TM&rg{eS5AQsw6 zN~(O4lq6Siak8>?u!MjBMWv;~X{hTG4qf;h#o@wB%N=$i0TPX%;X!aj6p)y5vGkEk zDg?wqb>u*4=^pXuU~@tH#jjL=ptR)%Ke6WfOawoG0^JP%gUh70ngi~nfyrnI*v0ZoS2dfvc6izwQ?h3w3me_nOZ-! z_VaK$5EAEl@l_Io?w%o94$!=A1#m-rPwLE*%a}SMff3_@4J>hJlFDGulvI88#+F)-b?(->ZkiC)of>hZEv_iQ}pqDVMx=EeM zi6L1dQnnYIakHQ=0_C^l9`M%y#=%bAewXAgm^osQ*a*^+wuR%W$fVyL^T z*wKHbSEkFgDC5B8P#}mO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iqz3vn3CM#DU>!lu4pOD)NUk?yPJJ@l*c$P z941onD~Hspi&0xKVsu?!;K2=TolGU-#v%%bCJ0zU%YFTg-fC$TL1k`dpM)VUw_gg) z9L>Kfi=i?Q+`=k8dgV){4iE*aqKCrd&7cN{cSQ(S^vQj%dPq<*dEty1*2^P_5Br(o zT!Kt}1EH}sN^($6Hjhx~kfETa=nh+X1OHbUl#`R1zUsR)eOFJ!{b0{Z=I zN9SZ6F<>6|7fc?c1t9#i!NQZ8n;i1eFc1prRPCAWWJ9xNZYHie)Bp{+65m=A!4Q{s zUdlO?io-`|BE7zm>=`{!ayb_{s#coysP-hMR-7vHaio1W;}*VkpkMV^ogcC6cm4Z?)u}S|iOOSdfwNeBhs$bb7uh&3=JK z^v4SscJuBse?Y`0){|3Kbz}bf%f|zyd1K|De=IsUHH(-isK-c|lEO;(hRi*ixF7!U zliW~_b)!$|C`-6A`{_q9=|f&sBMdNLr;c@ZS;5*Ckm*K*s?b5#x^Yn@lMejI0^H0T zk>%6yLkY#@h+cQiKJE`&68^O_b??5%q%t26VdMutk!%JQSUCENYo@!cBYx0wh>2i# zxduffqjvSyB#9syrCVT+E8eNBNjHS%&dObGhW;8JK;tvJot@oBmn!n3JQVAv#Ey|T zb%+euJ7%=pIWK={NUo`=xrvvvW^i?Nm2`Au77{uPFyP~d`R9yRCm#s00A!&getRequest()->getIsCpRequest() && !Craft::$app->getUser()->getIsGuest() && !Craft::$app->getRequest()->getIsAjax()) + { + // Register our asset bundle + Craft::$app->getView()->registerAssetBundle(ElementLinkAsset::class); + } + + Craft::info( + Craft::t( + 'element-link', + '{name} plugin loaded', + ['name' => $this->name] + ), + __METHOD__ + ); + } + + // Protected Methods + // ========================================================================= + +} diff --git a/src/assetbundles/elementlink/ElementLinkAsset.php b/src/assetbundles/elementlink/ElementLinkAsset.php new file mode 100644 index 0000000..4bfe508 --- /dev/null +++ b/src/assetbundles/elementlink/ElementLinkAsset.php @@ -0,0 +1,58 @@ +sourcePath = "@marionnewlevant/elementlink/assetbundles/elementlink/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/elementlink.js', + ]; + + $this->css = [ + 'css/elementlink.css', + ]; + + parent::init(); + } +} diff --git a/src/assetbundles/elementlink/dist/css/elementlink.css b/src/assetbundles/elementlink/dist/css/elementlink.css new file mode 100644 index 0000000..6f85702 --- /dev/null +++ b/src/assetbundles/elementlink/dist/css/elementlink.css @@ -0,0 +1,66 @@ +/* +positioning with css. The .linked class is from download assets plugin. +*/ +/* styles to make space on the label */ +body.ltr .element.elementLinkYes .label { + padding-right: 20px; +} +body.ltr .element.elementLinkYes.linked .label { + padding-right: 40px; +} + +body.ltr .element.removable.elementLinkYes .label { + padding-right: 40px; +} +body.ltr .element.removable.elementLinkYes.linked .label { + padding-right: 60px; +} + +body.rtl .element.elementLinkYes .label { + padding-left: 20px; +} +body.rtl .element.elementLinkYes.linked .label { + padding-left: 40px; +} + +body.rtl .element.removable.elementLinkYes .label { + padding-left: 40px; +} +body.rtl .element.removable.elementLinkYes.linked .label { + padding-left: : 60px; +} + +/* anchor styles */ +body.ltr .element .elementLink { + position: absolute; + right: 22px; +} + +body.ltr .element.linked .elementLink { + right: 42px; +} + +body.rtl .element .elementLink { + position: absolute; + left: 22px; +} + +body.rtl .element.linked .elementLink { + left: 42px; +} + +.element .elementLink::before { + content: ''; + display: inline-block; + width: 19px; + height: 14px; + background-image: url('../img/elementLink.svg'); + background-size: 19px 14px; + line-height: 1; + vertical-align: middle; +} + +.element .elementLink:hover::before { + background-image: url('../img/elementLink-focus.svg'); +} + diff --git a/src/assetbundles/elementlink/dist/img/elementLink-focus.svg b/src/assetbundles/elementlink/dist/img/elementLink-focus.svg new file mode 100644 index 0000000..57535a0 --- /dev/null +++ b/src/assetbundles/elementlink/dist/img/elementLink-focus.svg @@ -0,0 +1,10 @@ + + + + Links + Created with Sketch. + + + + + \ No newline at end of file diff --git a/src/assetbundles/elementlink/dist/img/elementLink.svg b/src/assetbundles/elementlink/dist/img/elementLink.svg new file mode 100644 index 0000000..eb3a46a --- /dev/null +++ b/src/assetbundles/elementlink/dist/img/elementLink.svg @@ -0,0 +1,10 @@ + + + + Links + Created with Sketch. + + + + + \ No newline at end of file diff --git a/src/assetbundles/elementlink/dist/js/elementlink.js b/src/assetbundles/elementlink/dist/js/elementlink.js new file mode 100644 index 0000000..c866d9e --- /dev/null +++ b/src/assetbundles/elementlink/dist/js/elementlink.js @@ -0,0 +1,39 @@ +$(function () { // for namespacing if nothing else... + var g_lastRequest = null; + + // called every second to look for new elements to add the cp link to + var addLinks = function() { + // find the elements not yet tagged w/ class .elementLink + var $elements = $('.field .input .element:not(.elementLink)'); + + $elements.each(function() { + var $thisElement = $(this); + var $label = $thisElement.find('.label'); + $thisElement.addClass('elementLink'); + // phone home to get the cpEditUrl for the element + g_lastRequest = Craft.postActionRequest( + 'element-link/default/element-edit-url', + { + elementType: $thisElement.data('type'), + elementId: $thisElement.data('id'), + siteId: $thisElement.data('site-id') + }, + function(response, textStatus) { + if (textStatus == 'success' && response && response['editUrl']) { + // add the link to the dom + $thisElement.addClass('elementLinkYes'); + var $a = $('', { + class: 'elementLink', + target: '_blank', + href: response['editUrl'] + }); + $a.insertBefore($label); + } + } + ); + }); + }; + + addLinks(); + window.setInterval(addLinks, 1000); +}); \ No newline at end of file diff --git a/src/controllers/DefaultController.php b/src/controllers/DefaultController.php new file mode 100644 index 0000000..54d33cb --- /dev/null +++ b/src/controllers/DefaultController.php @@ -0,0 +1,79 @@ +requireAcceptsJson(); + + $elementId = (int)(Craft::$app->getRequest()->getBodyParam('elementId')); + $elementType = Craft::$app->getRequest()->getBodyParam('elementType'); + $siteId = (int)(Craft::$app->getRequest()->getBodyParam('siteId')); + + $editUrl = ElementLink::$plugin->elementLinkService->editUrl($elementId, $elementType, $siteId); + + if ($editUrl) + { + $json = $this->asJson([ + 'success' => true, + 'editUrl' => $editUrl, + ]); + return $json; + + } + else + { + $json = $this->asJson([ + 'success' => false, + 'error' => 'no cpEditUrl', + ]); + return $json; + } + } +} diff --git a/src/icon.svg b/src/icon.svg new file mode 100644 index 0000000..dc678da --- /dev/null +++ b/src/icon.svg @@ -0,0 +1,13 @@ + + + + ElementLink Icon + Created with Sketch. + + + + + + + + \ No newline at end of file diff --git a/src/services/ElementLinkService.php b/src/services/ElementLinkService.php new file mode 100644 index 0000000..3acec86 --- /dev/null +++ b/src/services/ElementLinkService.php @@ -0,0 +1,54 @@ +elementLinkService->editUrl() + * + * @return mixed + */ + public function editUrl(int $elementId, string $elementType, int $siteId) + { + $element = Craft::$app->elements->getElementById($elementId, $elementType, $siteId); + if ($element) + { + return $element->cpEditUrl; + } + return null; + } +} diff --git a/src/translations/en/element-link.php b/src/translations/en/element-link.php new file mode 100644 index 0000000..d9321d7 --- /dev/null +++ b/src/translations/en/element-link.php @@ -0,0 +1,25 @@ + 'Element Link plugin loaded', +];