acf
This commit is contained in:
		
							
								
								
									
										63
									
								
								plugins/fields/acftwitter/acftwitter.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								plugins/fields/acftwitter/acftwitter.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,63 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * @package         Advanced Custom Fields | ||||
|  * @version         2.8.8 Pro | ||||
|  *  | ||||
|  * @author          Tassos Marinos <info@tassos.gr> | ||||
|  * @link            http://www.tassos.gr | ||||
|  * @copyright       Copyright © 2020 Tassos Marinos All Rights Reserved | ||||
|  * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later | ||||
| */ | ||||
|  | ||||
| defined('_JEXEC') or die; | ||||
|  | ||||
| use Joomla\CMS\Factory; | ||||
|  | ||||
| JLoader::register('ACF_Field', JPATH_PLUGINS . '/system/acf/helper/plugin.php'); | ||||
|  | ||||
| if (!class_exists('ACF_Field')) | ||||
| { | ||||
| 	Factory::getApplication()->enqueueMessage('Advanced Custom Fields System Plugin is missing', 'error'); | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| class PlgFieldsACFTwitter extends ACF_Field | ||||
| { | ||||
| 	/** | ||||
| 	 *  Field's Class | ||||
| 	 * | ||||
| 	 *  @var  string | ||||
| 	 */ | ||||
| 	protected $class = 'input-xlarge w-100'; | ||||
| 	 | ||||
| 	/** | ||||
| 	 *  Field's Hint Description | ||||
| 	 * | ||||
| 	 *  @var  string | ||||
| 	 */ | ||||
| 	protected $hint = 'ACF_TWITTER_TWTR_HANDLE'; | ||||
|  | ||||
| 	/** | ||||
| 	 * Update the label of the field in filters. | ||||
|      *  | ||||
|      * @param \Bluecoder\Component\Jfilters\Administrator\Model\Filter\Option\Collection $options | ||||
| 	 *  | ||||
|      * @return \Bluecoder\Component\Jfilters\Administrator\Model\Filter\Option\Collection | ||||
|      */ | ||||
|     public function onJFiltersOptionsAfterCreation(\Bluecoder\Component\Jfilters\Administrator\Model\Filter\Option\Collection $options)  | ||||
|     { | ||||
| 		// Make sure it is a field of that type | ||||
|         if ($options->getFilterItem()->getAttributes()->get('type') !== $this->_name) | ||||
| 		{ | ||||
|             return $options; | ||||
|         } | ||||
|  | ||||
|         foreach ($options as $option) | ||||
| 		{ | ||||
| 			$option->setLabel('@' . $option->getLabel()); | ||||
| 		} | ||||
|  | ||||
|         return $options; | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										21
									
								
								plugins/fields/acftwitter/acftwitter.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								plugins/fields/acftwitter/acftwitter.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | ||||
| <?xml version="1.0" encoding="utf-8" ?> | ||||
| <extension type="plugin" version="3.7.0" group="fields" method="upgrade"> | ||||
| 	<name>ACF_TWITTER</name> | ||||
| 	<description>ACF_TWITTER_DESC</description> | ||||
| 	<author>Tassos Marinos</author> | ||||
| 	<creationDate>July 2019</creationDate> | ||||
| 	<copyright>Copyright (C) 2019 Tassos Marinos. All rights reserved.</copyright> | ||||
| 	<license>GNU General Public License version 2 or later; see LICENSE.txt</license> | ||||
| 	<authorEmail>info@tassos.gr</authorEmail> | ||||
| 	<authorUrl>www.tassos.gr</authorUrl> | ||||
| 	<version>1.0</version> | ||||
| 	<scriptfile>script.install.php</scriptfile> | ||||
| 	<files> | ||||
| 		<filename plugin="acftwitter">acftwitter.php</filename> | ||||
| 		<filename>script.install.helper.php</filename> | ||||
| 		<filename>version.php</filename> | ||||
| 		<folder>language</folder> | ||||
| 		<folder>params</folder> | ||||
| 		<folder>tmpl</folder> | ||||
| 	</files> | ||||
| </extension> | ||||
| @ -0,0 +1,21 @@ | ||||
| ; @package      Advanced Custom Fields | ||||
| ; @version      2.8.8 Pro | ||||
| ; | ||||
| ; @author		Tassos Marinos - http://www.tassos.gr/joomla-extensions | ||||
| ; @copyright	Copyright (c) 2019 Tassos Marinos. All rights reserved. | ||||
| ; @license		http://www.tassos.gr | ||||
|  | ||||
| PLG_FIELDS_ACFTWITTER_LABEL="ACF - Twitter" | ||||
| ACF_TWITTER="Camps - ACF Twitter" | ||||
| ACF_TWITTER_VALUE_DESC="Escriu un usuari Twitter.<br><br>Exemple: tassosm" | ||||
| ACF_TWITTER_DESC="Aconsegueix més seguidors creant un botó de seguir i col·locant-lo al teu lloc." | ||||
| ACF_TWITTER_LB="Botó gran" | ||||
| ACF_TWITTER_LB_DESC="Mostra un botó seguir gran." | ||||
| ACF_TWITTER_SU="Mostrar nom d'usuari" | ||||
| ACF_TWITTER_SU_DESC="Mostra el teu nom d'usuari dins el botó seguir." | ||||
| ACF_TWITTER_SC="Mostrar recompte" | ||||
| ACF_TWITTER_SC_DESC="Mostra la quantitat de seguidors." | ||||
| ACF_TWITTER_TWTR_HANDLE="Escriu un nom d'usuari Twitter" | ||||
| ACF_TWITTER_WIDGET="Giny:" | ||||
| ACF_TWITTER_WIDGET_DESC="Escull el giny que vols mostrar." | ||||
| ACF_TWITTER_FOLLOW="Botó seguir" | ||||
| @ -0,0 +1,21 @@ | ||||
| ; @package      Advanced Custom Fields | ||||
| ; @version      2.8.8 Pro | ||||
| ; | ||||
| ; @author		Tassos Marinos - http://www.tassos.gr/joomla-extensions | ||||
| ; @copyright	Copyright (c) 2019 Tassos Marinos. All rights reserved. | ||||
| ; @license		http://www.tassos.gr | ||||
|  | ||||
| PLG_FIELDS_ACFTWITTER_LABEL="ACF - Twitter" | ||||
| ACF_TWITTER="Felter - ACF Twitter" | ||||
| ACF_TWITTER_VALUE_DESC="Angiv et twitter handle.<br><br>Eksempel: tassosm" | ||||
| ACF_TWITTER_DESC="Få flere Twitter følgere ved at oprette en Følg knap og placere den på dit websted." | ||||
| ACF_TWITTER_LB="Stor knap" | ||||
| ACF_TWITTER_LB_DESC="Vis en stor knap for Følg knappen." | ||||
| ACF_TWITTER_SU="Vis brugernavnUsername" | ||||
| ACF_TWITTER_SU_DESC="Vis dit brugernavn på Følg knappen." | ||||
| ACF_TWITTER_SC="Vis antal" | ||||
| ACF_TWITTER_SC_DESC="Vis antallet af følgere." | ||||
| ACF_TWITTER_TWTR_HANDLE="Angiv et Twitter Handle" | ||||
| ACF_TWITTER_WIDGET="Widget:" | ||||
| ACF_TWITTER_WIDGET_DESC="Vælg hvilket widget du ønsker at vise." | ||||
| ACF_TWITTER_FOLLOW="Følg knap" | ||||
| @ -0,0 +1,21 @@ | ||||
| ; @package      Advanced Custom Fields | ||||
| ; @version      2.8.8 Pro | ||||
| ; | ||||
| ; @author		Tassos Marinos - http://www.tassos.gr/joomla-extensions | ||||
| ; @copyright	Copyright (c) 2019 Tassos Marinos. All rights reserved. | ||||
| ; @license		http://www.tassos.gr | ||||
|  | ||||
| PLG_FIELDS_ACFTWITTER_LABEL="ACF - Twitter" | ||||
| ACF_TWITTER="Felder - ACF Twitter" | ||||
| ACF_TWITTER_VALUE_DESC="Geben Sie ein Twitter-Handle ein. <br> <br> Beispiel: Tassosm" | ||||
| ACF_TWITTER_DESC="Holen Sie sich mehr Twitter-Follower, indem Sie eine Schaltfläche\" Folgen \"erstellen und auf Ihrer Website platzieren." | ||||
| ACF_TWITTER_LB="Große Schaltfläche" | ||||
| ACF_TWITTER_LB_DESC="Große Schaltfläche der Schaltfläche\" Folgen \"anzeigen." | ||||
| ACF_TWITTER_SU="Benutzername anzeigen" | ||||
| ACF_TWITTER_SU_DESC="Zeigen Sie Ihren Benutzernamen über die Schaltfläche\" Folgen \"an." | ||||
| ACF_TWITTER_SC="Anzahl anzeigen" | ||||
| ACF_TWITTER_SC_DESC="Anzahl der Follower anzeigen." | ||||
| ACF_TWITTER_TWTR_HANDLE="Twitter-Handle eingeben" | ||||
| ACF_TWITTER_WIDGET="Widget:" | ||||
| ACF_TWITTER_WIDGET_DESC="Wählen Sie aus, welches Widget Sie anzeigen möchten." | ||||
| ACF_TWITTER_FOLLOW="Schaltfläche folgen" | ||||
| @ -0,0 +1,21 @@ | ||||
| ; @package      Advanced Custom Fields | ||||
| ; @version      2.8.8 Pro | ||||
| ; | ||||
| ; @author		Tassos Marinos - http://www.tassos.gr/joomla-extensions | ||||
| ; @copyright	Copyright (c) 2019 Tassos Marinos. All rights reserved. | ||||
| ; @license		http://www.tassos.gr | ||||
|  | ||||
| PLG_FIELDS_ACFTWITTER_LABEL="ACF - Twitter" | ||||
| ACF_TWITTER="Fields - ACF Twitter" | ||||
| ACF_TWITTER_VALUE_DESC="Enter a twitter handle.<br /><br />Example: tassosm" | ||||
| ACF_TWITTER_DESC="Get more Twitter followers by creating a Follow button and placing it onto your site." | ||||
| ACF_TWITTER_LB="Large Button" | ||||
| ACF_TWITTER_LB_DESC="Display a large button of the follow button." | ||||
| ACF_TWITTER_SU="Show Username" | ||||
| ACF_TWITTER_SU_DESC="Show your username within the follow button." | ||||
| ACF_TWITTER_SC="Show Count" | ||||
| ACF_TWITTER_SC_DESC="Show count of followers." | ||||
| ACF_TWITTER_TWTR_HANDLE="Enter a Twitter Handle" | ||||
| ACF_TWITTER_WIDGET="Widget:" | ||||
| ACF_TWITTER_WIDGET_DESC="Select which widget you want to display." | ||||
| ACF_TWITTER_FOLLOW="Follow Button" | ||||
| @ -0,0 +1,9 @@ | ||||
| ; @package      Advanced Custom Fields | ||||
| ; @version      2.8.8 Pro | ||||
| ; | ||||
| ; @author		Tassos Marinos - http://www.tassos.gr/joomla-extensions | ||||
| ; @copyright	Copyright (c) 2019 Tassos Marinos. All rights reserved. | ||||
| ; @license		http://www.tassos.gr | ||||
|  | ||||
| ACF_TWITTER="Fields - ACF Twitter" | ||||
| ACF_TWITTER_DESC="Get more Twitter followers by creating a Follow button and placing it onto your site." | ||||
| @ -0,0 +1,21 @@ | ||||
| ; @package      Advanced Custom Fields | ||||
| ; @version      2.8.8 Pro | ||||
| ; | ||||
| ; @author		Tassos Marinos - http://www.tassos.gr/joomla-extensions | ||||
| ; @copyright	Copyright (c) 2019 Tassos Marinos. All rights reserved. | ||||
| ; @license		http://www.tassos.gr | ||||
|  | ||||
| PLG_FIELDS_ACFTWITTER_LABEL="ACF - Twitter" | ||||
| ACF_TWITTER="Campos - ACF Twitter" | ||||
| ACF_TWITTER_VALUE_DESC="Introduzca un identificador de Twitter.<br><br>Ejemplo: tassosm" | ||||
| ACF_TWITTER_DESC="Obtenga más seguidores en Twitter creando un botón Seguir y colocándolo en su sitio." | ||||
| ACF_TWITTER_LB="Botón Grande" | ||||
| ACF_TWITTER_LB_DESC="Mostrar en grande el botón de seguimiento." | ||||
| ACF_TWITTER_SU="Mostrar Nombre de Usuario" | ||||
| ACF_TWITTER_SU_DESC="Muestre su nombre de usuario dentro del botón de seguimiento." | ||||
| ACF_TWITTER_SC="Mostrar Recuento" | ||||
| ACF_TWITTER_SC_DESC="Mostrar recuento de seguidores." | ||||
| ACF_TWITTER_TWTR_HANDLE="Ingrese un identificador de Twitter" | ||||
| ACF_TWITTER_WIDGET="Widget:" | ||||
| ACF_TWITTER_WIDGET_DESC="Seleccione qué widget desea mostrar." | ||||
| ACF_TWITTER_FOLLOW="Botón de Seguir." | ||||
| @ -0,0 +1,9 @@ | ||||
| ; @package      Advanced Custom Fields | ||||
| ; @version      2.8.8 Pro | ||||
| ; | ||||
| ; @author		Tassos Marinos - http://www.tassos.gr/joomla-extensions | ||||
| ; @copyright	Copyright (c) 2019 Tassos Marinos. All rights reserved. | ||||
| ; @license		http://www.tassos.gr | ||||
|  | ||||
| ACF_TWITTER="Campos - ACF Twitter" | ||||
| ACF_TWITTER_DESC="Obtenga más seguidores en Twitter creando un botón Seguir y colocándolo en su sitio." | ||||
| @ -0,0 +1,21 @@ | ||||
| ; @package      Advanced Custom Fields | ||||
| ; @version      2.8.8 Pro | ||||
| ; | ||||
| ; @author		Tassos Marinos - http://www.tassos.gr/joomla-extensions | ||||
| ; @copyright	Copyright (c) 2019 Tassos Marinos. All rights reserved. | ||||
| ; @license		http://www.tassos.gr | ||||
|  | ||||
| PLG_FIELDS_ACFTWITTER_LABEL="ACF - Twitter" | ||||
| ACF_TWITTER="Campi - ACF Twitter" | ||||
| ACF_TWITTER_VALUE_DESC="Inserisci un handle di Twitter.<br><br>Esempio: tassosm" | ||||
| ACF_TWITTER_DESC="Ottieni più follower su Twitter creando un pulsante Segui e inserendolo nel tuo sito." | ||||
| ACF_TWITTER_LB="Pulsante grande" | ||||
| ACF_TWITTER_LB_DESC="Visualizza la versione grande del pulsante Segui." | ||||
| ACF_TWITTER_SU="Mostra nome utente" | ||||
| ACF_TWITTER_SU_DESC="Mostra il tuo nome utente nel pulsante Segui." | ||||
| ACF_TWITTER_SC="Mostra conteggio" | ||||
| ACF_TWITTER_SC_DESC="Mostra il conteggio dei follower." | ||||
| ACF_TWITTER_TWTR_HANDLE="Inserisci un handle di Twitter" | ||||
| ACF_TWITTER_WIDGET="Widget:" | ||||
| ACF_TWITTER_WIDGET_DESC="Seleziona il widget che desideri visualizzare." | ||||
| ACF_TWITTER_FOLLOW="Pulsante Segui" | ||||
| @ -0,0 +1,21 @@ | ||||
| ; @package      Advanced Custom Fields | ||||
| ; @version      2.8.8 Pro | ||||
| ; | ||||
| ; @author		Tassos Marinos - http://www.tassos.gr/joomla-extensions | ||||
| ; @copyright	Copyright (c) 2019 Tassos Marinos. All rights reserved. | ||||
| ; @license		http://www.tassos.gr | ||||
|  | ||||
| PLG_FIELDS_ACFTWITTER_LABEL="ACF - Twitter" | ||||
| ACF_TWITTER="Velden - ACF Twitter" | ||||
| ACF_TWITTER_VALUE_DESC="Voer een Twitter-handle in. <br><br>Bijvoorbeeld: tassosm" | ||||
| ACF_TWITTER_DESC="Krijg meer Twitter-volgers door een volgknop te maken en op je website te plaatsen." | ||||
| ACF_TWITTER_LB="Grote Knop" | ||||
| ACF_TWITTER_LB_DESC="Toon een grote volg knop " | ||||
| ACF_TWITTER_SU="Toon Gebruikersnaam" | ||||
| ACF_TWITTER_SU_DESC="Toon jouw gebruikersnaam in de volg knop" | ||||
| ACF_TWITTER_SC="Telling weergeven" | ||||
| ACF_TWITTER_SC_DESC="Telling van volgers weergeven" | ||||
| ACF_TWITTER_TWTR_HANDLE="Vul een twitter-Handle in" | ||||
| ACF_TWITTER_WIDGET="Widget:" | ||||
| ACF_TWITTER_WIDGET_DESC="Selecteer welke plugin je wil tonen" | ||||
| ACF_TWITTER_FOLLOW="Volg Knop" | ||||
| @ -0,0 +1,21 @@ | ||||
| ; @package      Advanced Custom Fields | ||||
| ; @version      2.8.8 Pro | ||||
| ; | ||||
| ; @author		Tassos Marinos - http://www.tassos.gr/joomla-extensions | ||||
| ; @copyright	Copyright (c) 2019 Tassos Marinos. All rights reserved. | ||||
| ; @license		http://www.tassos.gr | ||||
|  | ||||
| PLG_FIELDS_ACFTWITTER_LABEL="ACF - Twitter" | ||||
| ACF_TWITTER="Поля - ACF Twitter" | ||||
| ACF_TWITTER_VALUE_DESC="Введите дескриптор твиттера. <br /> <br /> Пример: tassosm" | ||||
| ACF_TWITTER_DESC="Получите больше подписчиков в Твиттере, создав кнопку Follow и разместив ее на своем сайте." | ||||
| ACF_TWITTER_LB="Большая кнопка" | ||||
| ACF_TWITTER_LB_DESC="Показать большую кнопку следующей кнопки." | ||||
| ACF_TWITTER_SU="Показать имя пользователя" | ||||
| ACF_TWITTER_SU_DESC="Показывать ваше имя пользователя в следующей кнопке." | ||||
| ACF_TWITTER_SC="Показать счетчик" | ||||
| ACF_TWITTER_SC_DESC="Показать количество подписчиков." | ||||
| ACF_TWITTER_TWTR_HANDLE="Введите хэндл Twitter" | ||||
| ACF_TWITTER_WIDGET="Виджет:" | ||||
| ACF_TWITTER_WIDGET_DESC="Выберите, какой виджет вы хотите отобразить." | ||||
| ACF_TWITTER_FOLLOW="Кнопка"_QQ_" Follow " | ||||
| @ -0,0 +1,21 @@ | ||||
| ; @package      Advanced Custom Fields | ||||
| ; @version      2.8.8 Pro | ||||
| ; | ||||
| ; @author		Tassos Marinos - http://www.tassos.gr/joomla-extensions | ||||
| ; @copyright	Copyright (c) 2019 Tassos Marinos. All rights reserved. | ||||
| ; @license		http://www.tassos.gr | ||||
|  | ||||
| PLG_FIELDS_ACFTWITTER_LABEL="ACF - Twitter" | ||||
| ACF_TWITTER="Fält - ACF Twitter" | ||||
| ACF_TWITTER_VALUE_DESC="Ange en twitter handle.<br><br>Example: tassosm" | ||||
| ACF_TWITTER_DESC="Få fler Twitter-följare genom att skapa en Follow-knapp och placera den på din webbplats." | ||||
| ACF_TWITTER_LB="Stor knapp" | ||||
| ACF_TWITTER_LB_DESC="Visa en stor följ-knapp." | ||||
| ACF_TWITTER_SU="Visa användarnamn" | ||||
| ACF_TWITTER_SU_DESC="Visa ditt användarnamn i följ-knappen." | ||||
| ACF_TWITTER_SC="Visa antal" | ||||
| ACF_TWITTER_SC_DESC="Visa antal följare." | ||||
| ACF_TWITTER_TWTR_HANDLE="Ange en Twitter Handle" | ||||
| ACF_TWITTER_WIDGET="Widget:" | ||||
| ACF_TWITTER_WIDGET_DESC="Välj vilken widget du vill visa." | ||||
| ACF_TWITTER_FOLLOW="Följ-knapp" | ||||
| @ -0,0 +1,21 @@ | ||||
| ; @package      Advanced Custom Fields | ||||
| ; @version      2.8.8 Pro | ||||
| ; | ||||
| ; @author		Tassos Marinos - http://www.tassos.gr/joomla-extensions | ||||
| ; @copyright	Copyright (c) 2019 Tassos Marinos. All rights reserved. | ||||
| ; @license		http://www.tassos.gr | ||||
|  | ||||
| PLG_FIELDS_ACFTWITTER_LABEL="ACF - Twitter" | ||||
| ACF_TWITTER="Поля - ACF Twitter" | ||||
| ACF_TWITTER_VALUE_DESC="Введіть ім'я користувача. <br /> <br /> Приклад: Tassosm" | ||||
| ACF_TWITTER_DESC="Отримайте більше підписників у Twitter, створивши кнопку"_QQ_" Follow "_QQ_"та розмістивши її на своєму сайті." | ||||
| ACF_TWITTER_LB="Велика кнопка" | ||||
| ACF_TWITTER_LB_DESC="Відобразити велику кнопку кнопки"_QQ_". " | ||||
| ACF_TWITTER_SU="Показати ім'я користувача" | ||||
| ACF_TWITTER_SU_DESC="Показати своє ім'я користувача в межах кнопки"_QQ_"" | ||||
| ACF_TWITTER_SC="Показати кількість" | ||||
| ACF_TWITTER_SC_DESC="Показати кількість підписників." | ||||
| ACF_TWITTER_TWTR_HANDLE="Введіть ручку Twitter" | ||||
| ACF_TWITTER_WIDGET="Віджет:" | ||||
| ACF_TWITTER_WIDGET_DESC="Виберіть, який віджет ви хочете показати." | ||||
| ACF_TWITTER_FOLLOW="Кнопка Слідкувати за" | ||||
							
								
								
									
										35
									
								
								plugins/fields/acftwitter/params/acftwitter.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								plugins/fields/acftwitter/params/acftwitter.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <form> | ||||
| 	<fields name="fieldparams"> | ||||
| 		<fieldset name="fieldparams"> | ||||
| 		    <field name="widget_type" type="list"  | ||||
| 		        label="ACF_TWITTER_WIDGET" | ||||
| 				description="ACF_TWITTER_WIDGET_DESC" | ||||
| 		        class="btn-group btn-group-yesno" | ||||
| 		        default="follow"> | ||||
| 		            <option value="follow">ACF_TWITTER_FOLLOW</option> | ||||
| 		    </field> | ||||
| 			<fields name="follow" showon="fieldparams.widget_type:follow"> | ||||
| 				<field name="large_button" type="nrtoggle"  | ||||
| 					label="ACF_TWITTER_LB" | ||||
| 					description="ACF_TWITTER_LB_DESC" | ||||
| 					showon="fieldparams.widget_type:follow" | ||||
| 					checked="true" | ||||
| 				/> | ||||
| 				<field name="show_username" type="nrtoggle"  | ||||
| 					label="ACF_TWITTER_SU" | ||||
| 					description="ACF_TWITTER_SU_DESC" | ||||
| 					showon="fieldparams.widget_type:follow" | ||||
| 					checked="true" | ||||
| 				/> | ||||
| 				<field name="show_count" type="nrtoggle"  | ||||
| 					label="ACF_TWITTER_SC" | ||||
| 					description="ACF_TWITTER_SC_DESC" | ||||
| 					showon="fieldparams.widget_type:follow" | ||||
| 					checked="true" | ||||
| 				/> | ||||
| 			</fields> | ||||
| 		</fieldset> | ||||
| 	</fields> | ||||
| </form> | ||||
|  | ||||
							
								
								
									
										691
									
								
								plugins/fields/acftwitter/script.install.helper.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										691
									
								
								plugins/fields/acftwitter/script.install.helper.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,691 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Installer Script Helper | ||||
|  * | ||||
|  * @author          Tassos Marinos <info@tassos.gr> | ||||
|  * @link            http://www.tassos.gr | ||||
|  * @copyright       Copyright © 2016 Tassos Marinos All Rights Reserved | ||||
|  * @license         http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL | ||||
|  */ | ||||
|  | ||||
| defined('_JEXEC') or die; | ||||
|  | ||||
| use Joomla\CMS\Installer\Installer; | ||||
| use Joomla\CMS\Factory; | ||||
| use Joomla\CMS\Language\Text; | ||||
| use Joomla\Filesystem\File; | ||||
| use Joomla\Filesystem\Folder; | ||||
|  | ||||
| class PlgFieldsAcftwitterInstallerScriptHelper | ||||
| { | ||||
| 	public $name = ''; | ||||
| 	public $alias = ''; | ||||
| 	public $extname = ''; | ||||
| 	public $extension_type = ''; | ||||
| 	public $plugin_folder = 'system'; | ||||
| 	public $module_position = 'status'; | ||||
| 	public $client_id = 1; | ||||
| 	public $install_type = 'install'; | ||||
| 	public $show_message = true; | ||||
| 	public $autopublish = true; | ||||
| 	public $db = null; | ||||
| 	public $app = null; | ||||
| 	public $installedVersion; | ||||
|  | ||||
| 	public function __construct(&$params) | ||||
| 	{ | ||||
| 		$this->extname = $this->extname ?: $this->alias; | ||||
| 		$this->db = Factory::getDbo(); | ||||
| 		$this->app = Factory::getApplication(); | ||||
| 		$this->installedVersion = $this->getVersion($this->getInstalledXMLFile()); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 *  Preflight event | ||||
| 	 * | ||||
| 	 *  @param   string             | ||||
| 	 *  @param   JAdapterInstance | ||||
| 	 * | ||||
| 	 *  @return  boolean                       | ||||
| 	 */ | ||||
| 	public function preflight($route, $adapter) | ||||
| 	{ | ||||
| 		if (!in_array($route, array('install', 'update'))) | ||||
| 		{ | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		Factory::getLanguage()->load('plg_system_novaraininstaller', JPATH_PLUGINS . '/system/novaraininstaller'); | ||||
|  | ||||
| 		if ($this->show_message && $this->isInstalled()) | ||||
| 		{ | ||||
| 			$this->install_type = 'update'; | ||||
| 		} | ||||
|  | ||||
| 		if ($this->onBeforeInstall() === false) | ||||
| 		{ | ||||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 *  Preflight event | ||||
| 	 * | ||||
| 	 *  @param   string             | ||||
| 	 *  @param   JAdapterInstance | ||||
| 	 * | ||||
| 	 *  @return  boolean                       | ||||
| 	 */ | ||||
| 	public function postflight($route, $adapter) | ||||
| 	{ | ||||
| 		Factory::getLanguage()->load($this->getPrefix() . '_' . $this->extname, $this->getMainFolder()); | ||||
|  | ||||
| 		if (!in_array($route, array('install', 'update'))) | ||||
| 		{ | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		if ($this->onAfterInstall() === false) | ||||
| 		{ | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		if ($route == 'install' && $this->autopublish) | ||||
| 		{ | ||||
| 			$this->publishExtension(); | ||||
| 		} | ||||
|  | ||||
| 		if ($this->show_message) | ||||
| 		{ | ||||
| 			$this->addInstalledMessage(); | ||||
| 		} | ||||
|  | ||||
| 		Factory::getCache()->clean('com_plugins'); | ||||
| 		Factory::getCache()->clean('_system'); | ||||
| 	} | ||||
|  | ||||
| 	public function isInstalled() | ||||
| 	{ | ||||
| 		if (!is_file($this->getInstalledXMLFile())) | ||||
| 		{ | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		$query = $this->db->getQuery(true) | ||||
| 			->select('extension_id') | ||||
| 			->from('#__extensions') | ||||
| 			->where($this->db->quoteName('type') . ' = ' . $this->db->quote($this->extension_type)) | ||||
| 			->where($this->db->quoteName('element') . ' = ' . $this->db->quote($this->getElementName())); | ||||
| 		$this->db->setQuery($query, 0, 1); | ||||
| 		$result = $this->db->loadResult(); | ||||
|  | ||||
| 		return empty($result) ? false : true; | ||||
| 	} | ||||
|  | ||||
| 	public function getMainFolder() | ||||
| 	{ | ||||
| 		switch ($this->extension_type) | ||||
| 		{ | ||||
| 			case 'plugin' : | ||||
| 				return JPATH_SITE . '/plugins/' . $this->plugin_folder . '/' . $this->extname; | ||||
|  | ||||
| 			case 'component' : | ||||
| 				return JPATH_ADMINISTRATOR . '/components/com_' . $this->extname; | ||||
|  | ||||
| 			case 'module' : | ||||
| 				return JPATH_ADMINISTRATOR . '/modules/mod_' . $this->extname; | ||||
|  | ||||
| 			case 'library' : | ||||
| 				return JPATH_SITE . '/libraries/' . $this->extname; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public function getInstalledXMLFile() | ||||
| 	{ | ||||
| 		return $this->getXMLFile($this->getMainFolder()); | ||||
| 	} | ||||
|  | ||||
| 	public function getCurrentXMLFile() | ||||
| 	{ | ||||
| 		return $this->getXMLFile(__DIR__); | ||||
| 	} | ||||
|  | ||||
| 	public function getXMLFile($folder) | ||||
| 	{ | ||||
| 		switch ($this->extension_type) | ||||
| 		{ | ||||
| 			case 'module' : | ||||
| 				return $folder . '/mod_' . $this->extname . '.xml'; | ||||
| 			default : | ||||
| 				return $folder . '/' . $this->extname . '.xml'; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public function foldersExist($folders = array()) | ||||
| 	{ | ||||
| 		foreach ($folders as $folder) | ||||
| 		{ | ||||
| 			if (is_dir($folder)) | ||||
| 			{ | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	public function publishExtension() | ||||
| 	{ | ||||
| 		switch ($this->extension_type) | ||||
| 		{ | ||||
| 			case 'plugin' : | ||||
| 				$this->publishPlugin(); | ||||
|  | ||||
| 			case 'module' : | ||||
| 				$this->publishModule(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public function publishPlugin() | ||||
| 	{ | ||||
| 		$query = $this->db->getQuery(true) | ||||
| 			->update('#__extensions') | ||||
| 			->set($this->db->quoteName('enabled') . ' = 1') | ||||
| 			->where($this->db->quoteName('type') . ' = ' . $this->db->quote('plugin')) | ||||
| 			->where($this->db->quoteName('element') . ' = ' . $this->db->quote($this->extname)) | ||||
| 			->where($this->db->quoteName('folder') . ' = ' . $this->db->quote($this->plugin_folder)); | ||||
| 		$this->db->setQuery($query); | ||||
| 		$this->db->execute(); | ||||
| 	} | ||||
|  | ||||
| 	public function publishModule() | ||||
| 	{ | ||||
| 		// Get module id | ||||
| 		$query = $this->db->getQuery(true) | ||||
| 			->select('id') | ||||
| 			->from('#__modules') | ||||
| 			->where($this->db->quoteName('module') . ' = ' . $this->db->quote('mod_' . $this->extname)) | ||||
| 			->where($this->db->quoteName('client_id') . ' = ' . (int) $this->client_id); | ||||
| 		$this->db->setQuery($query, 0, 1); | ||||
| 		$id = $this->db->loadResult(); | ||||
|  | ||||
| 		if (!$id) | ||||
| 		{ | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		// check if module is already in the modules_menu table (meaning is is already saved) | ||||
| 		$query->clear() | ||||
| 			->select('moduleid') | ||||
| 			->from('#__modules_menu') | ||||
| 			->where($this->db->quoteName('moduleid') . ' = ' . (int) $id); | ||||
| 		$this->db->setQuery($query, 0, 1); | ||||
| 		$exists = $this->db->loadResult(); | ||||
|  | ||||
| 		if ($exists) | ||||
| 		{ | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		// Get highest ordering number in position | ||||
| 		$query->clear() | ||||
| 			->select('ordering') | ||||
| 			->from('#__modules') | ||||
| 			->where($this->db->quoteName('position') . ' = ' . $this->db->quote($this->module_position)) | ||||
| 			->where($this->db->quoteName('client_id') . ' = ' . (int) $this->client_id) | ||||
| 			->order('ordering DESC'); | ||||
| 		$this->db->setQuery($query, 0, 1); | ||||
| 		$ordering = $this->db->loadResult(); | ||||
| 		$ordering++; | ||||
|  | ||||
| 		// publish module and set ordering number | ||||
| 		$query->clear() | ||||
| 			->update('#__modules') | ||||
| 			->set($this->db->quoteName('published') . ' = 1') | ||||
| 			->set($this->db->quoteName('ordering') . ' = ' . (int) $ordering) | ||||
| 			->set($this->db->quoteName('position') . ' = ' . $this->db->quote($this->module_position)) | ||||
| 			->where($this->db->quoteName('id') . ' = ' . (int) $id); | ||||
| 		$this->db->setQuery($query); | ||||
| 		$this->db->execute(); | ||||
|  | ||||
| 		// add module to the modules_menu table | ||||
| 		$query->clear() | ||||
| 			->insert('#__modules_menu') | ||||
| 			->columns(array($this->db->quoteName('moduleid'), $this->db->quoteName('menuid'))) | ||||
| 			->values((int) $id . ', 0'); | ||||
| 		$this->db->setQuery($query); | ||||
| 		$this->db->execute(); | ||||
| 	} | ||||
|  | ||||
| 	public function addInstalledMessage() | ||||
| 	{ | ||||
| 		Factory::getApplication()->enqueueMessage( | ||||
| 			Text::sprintf( | ||||
| 				Text::_($this->install_type == 'update' ? 'NRI_THE_EXTENSION_HAS_BEEN_UPDATED_SUCCESSFULLY' : 'NRI_THE_EXTENSION_HAS_BEEN_INSTALLED_SUCCESSFULLY'), | ||||
| 				'<strong>' . Text::_($this->name) . '</strong>', | ||||
| 				'<strong>' . $this->getVersion() . '</strong>', | ||||
| 				$this->getFullType() | ||||
| 			) | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| 	public function getPrefix() | ||||
| 	{ | ||||
| 		switch ($this->extension_type) | ||||
| 		{ | ||||
| 			case 'plugin'; | ||||
| 				return Text::_('plg_' . strtolower($this->plugin_folder)); | ||||
|  | ||||
| 			case 'component': | ||||
| 				return Text::_('com'); | ||||
|  | ||||
| 			case 'module': | ||||
| 				return Text::_('mod'); | ||||
|  | ||||
| 			case 'library': | ||||
| 				return Text::_('lib'); | ||||
|  | ||||
| 			default: | ||||
| 				return $this->extension_type; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public function getElementName($type = null, $extname = null) | ||||
| 	{ | ||||
| 		$type = is_null($type) ? $this->extension_type : $type; | ||||
| 		$extname = is_null($extname) ? $this->extname : $extname; | ||||
|  | ||||
| 		switch ($type) | ||||
| 		{ | ||||
| 			case 'component' : | ||||
| 				return 'com_' . $extname; | ||||
|  | ||||
| 			case 'module' : | ||||
| 				return 'mod_' . $extname; | ||||
|  | ||||
| 			case 'plugin' : | ||||
| 			default: | ||||
| 				return $extname; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public function getFullType() | ||||
| 	{ | ||||
| 		return Text::_('NRI_' . strtoupper($this->getPrefix())); | ||||
| 	} | ||||
|  | ||||
| 	public function isPro() | ||||
| 	{ | ||||
| 		$versionFile = __DIR__ . "/version.php"; | ||||
|  | ||||
| 		// If version file does not exist we assume a PRO version | ||||
| 		if (!is_file($versionFile)) | ||||
| 		{ | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
| 		// Load version file | ||||
| 		require_once $versionFile; | ||||
| 		return (bool) $NR_PRO; | ||||
| 	} | ||||
|  | ||||
| 	public function getVersion($file = '') | ||||
| 	{ | ||||
| 		$file = $file ?: $this->getCurrentXMLFile(); | ||||
|  | ||||
| 		if (!is_file($file)) | ||||
| 		{ | ||||
| 			return ''; | ||||
| 		} | ||||
|  | ||||
| 		$xml = Installer::parseXMLInstallFile($file); | ||||
|  | ||||
| 		if (!$xml || !isset($xml['version'])) | ||||
| 		{ | ||||
| 			return ''; | ||||
| 		} | ||||
|  | ||||
| 		return $xml['version']; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 *  Checks wether the extension can be installed or not | ||||
| 	 * | ||||
| 	 *  @return  boolean   | ||||
| 	 */ | ||||
| 	public function canInstall() | ||||
| 	{ | ||||
| 		// The extension is not installed yet. Accept Install. | ||||
| 		if (!$installed_version = $this->getVersion($this->getInstalledXMLFile())) | ||||
| 		{ | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
| 		// Path to extension's version file | ||||
| 		$versionFile = $this->getMainFolder() . "/version.php"; | ||||
| 		$NR_PRO = true; | ||||
|  | ||||
| 		// If version file does not exist we assume we have a PRO version installed | ||||
| 		if (file_exists($versionFile)) | ||||
| 		{ | ||||
| 			require_once($versionFile); | ||||
| 		} | ||||
|  | ||||
| 		// The free version is installed. Accept install. | ||||
| 		if (!(bool)$NR_PRO) | ||||
| 		{ | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
| 		// Current package is a PRO version. Accept install. | ||||
| 		if ($this->isPro()) | ||||
| 		{ | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
| 		// User is trying to update from PRO version to FREE. Do not accept install. | ||||
| 		Factory::getLanguage()->load($this->getPrefix() . '_' . $this->extname, __DIR__); | ||||
|  | ||||
| 		Factory::getApplication()->enqueueMessage( | ||||
| 			Text::_('NRI_ERROR_PRO_TO_FREE'), 'error' | ||||
| 		); | ||||
|  | ||||
| 		Factory::getApplication()->enqueueMessage( | ||||
| 			html_entity_decode( | ||||
| 				Text::sprintf( | ||||
| 					'NRI_ERROR_UNINSTALL_FIRST', | ||||
| 					'<a href="http://www.tassos.gr/joomla-extensions/' . $this->getUrlAlias() . '" target="_blank">', | ||||
| 					'</a>', | ||||
| 					Text::_($this->name) | ||||
| 				) | ||||
| 			), 'error' | ||||
| 		);	 | ||||
|  | ||||
| 		return false;	 | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Returns the URL alias of the extension. | ||||
| 	 *  | ||||
| 	 * @return  string | ||||
| 	 */ | ||||
| 	private function getUrlAlias() | ||||
| 	{ | ||||
| 		$alias = $this->alias; | ||||
|  | ||||
| 		switch ($alias) | ||||
| 		{ | ||||
| 			case 'smilepack': | ||||
| 				$alias = 'smile-pack'; | ||||
| 				break; | ||||
| 			case 'convertforms': | ||||
| 				$alias = 'convert-forms'; | ||||
| 				break; | ||||
| 			case 'rstbox': | ||||
| 				$alias = 'engagebox'; | ||||
| 				break; | ||||
| 			case 'gsd': | ||||
| 				$alias = 'google-structured-data'; | ||||
| 				break; | ||||
| 		} | ||||
|  | ||||
| 		// ACF | ||||
| 		if ($this->plugin_folder === 'fields' && ($alias === 'acf' || $this->startsWith($alias, 'acf'))) | ||||
| 		{ | ||||
| 			$alias = 'advanced-custom-fields'; | ||||
| 		} | ||||
| 		 | ||||
| 		return $alias; | ||||
| 	} | ||||
|  | ||||
|     /** | ||||
|      * Checks whether string starts with substring. | ||||
|      *  | ||||
|      * @param   string  $string | ||||
|      * @param   string  $query | ||||
|      *  | ||||
|      * @return  bool | ||||
|      */ | ||||
|     public static function startsWith($string, $query) | ||||
|     { | ||||
|         return substr($string, 0, strlen($query)) === $query; | ||||
|     } | ||||
|  | ||||
| 	/** | ||||
| 	 *  Checks if current version is newer than the installed one | ||||
| 	 *  Used for Novarain Framework | ||||
| 	 * | ||||
| 	 *  @return  boolean  [description] | ||||
| 	 */ | ||||
| 	public function isNewer() | ||||
| 	{ | ||||
| 		if (!$installed_version = $this->getVersion($this->getInstalledXMLFile())) | ||||
| 		{ | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
| 		$package_version = $this->getVersion(); | ||||
|  | ||||
| 		return version_compare($installed_version, $package_version, '<='); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 *  Helper method triggered before installation | ||||
| 	 * | ||||
| 	 *  @return  bool | ||||
| 	 */ | ||||
| 	public function onBeforeInstall() | ||||
| 	{ | ||||
| 		if (!$this->canInstall()) | ||||
| 		{ | ||||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 *  Helper method triggered after installation | ||||
| 	 */ | ||||
| 	public function onAfterInstall() | ||||
| 	{ | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 *  Delete files | ||||
| 	 * | ||||
| 	 *  @param   array   $folders | ||||
| 	 */ | ||||
| 	public function deleteFiles($files = array()) | ||||
| 	{ | ||||
| 	    foreach ($files as $key => $file) | ||||
|         { | ||||
| 			if (!is_file($file)) | ||||
| 			{ | ||||
| 				continue; | ||||
| 			} | ||||
| 			 | ||||
|             File::delete($file); | ||||
|         } | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 *  Deletes folders | ||||
| 	 * | ||||
| 	 *  @param   array   $folders   | ||||
| 	 */ | ||||
| 	public function deleteFolders($folders = array()) | ||||
| 	{ | ||||
| 		foreach ($folders as $folder) | ||||
| 		{ | ||||
| 			if (!is_dir($folder)) | ||||
| 			{ | ||||
| 				continue; | ||||
| 			} | ||||
|  | ||||
| 			Folder::delete($folder); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public function dropIndex($table, $index) | ||||
| 	{	 | ||||
| 		$db = $this->db; | ||||
|  | ||||
| 		// Check if index exists first | ||||
| 		$query = 'SHOW INDEX FROM ' . $db->quoteName('#__' . $table) . ' WHERE KEY_NAME = ' . $db->quote($index); | ||||
|         $db->setQuery($query); | ||||
|         $db->execute(); | ||||
|  | ||||
|         if (!$db->loadResult()) | ||||
|         { | ||||
|         	return; | ||||
|         } | ||||
|  | ||||
|         // Remove index | ||||
|         $query = 'ALTER TABLE ' . $db->quoteName('#__' . $table) . ' DROP INDEX ' . $db->quoteName($index); | ||||
|         $db->setQuery($query); | ||||
|         $db->execute();  | ||||
| 	} | ||||
|  | ||||
|     public function dropUnwantedTables($tables) { | ||||
|  | ||||
|         if (!$tables) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         foreach ($tables as $table) { | ||||
|             $query = "DROP TABLE IF EXISTS #__".$this->db->escape($table); | ||||
|             $this->db->setQuery($query); | ||||
|             $this->db->execute(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| 	public function dropUnwantedColumns($table, $columns) { | ||||
|  | ||||
|         if (!$columns || !$table) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         $db = $this->db; | ||||
|  | ||||
|         // Check if columns exists in database | ||||
|         function qt($n) { | ||||
|             return(Factory::getDBO()->quote($n)); | ||||
|         } | ||||
|          | ||||
|         $query = 'SHOW COLUMNS FROM #__'.$table.' WHERE Field IN ('.implode(",", array_map("qt", $columns)).')'; | ||||
|         $db->setQuery($query); | ||||
|         $rows = $db->loadColumn(0); | ||||
|  | ||||
|         // Abort if we don't have any rows | ||||
|         if (!$rows) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         // Let's remove the columns | ||||
|         $q = ""; | ||||
|         foreach ($rows as $key => $column) { | ||||
|             $comma = (($key+1) < count($rows)) ? "," : ""; | ||||
|             $q .= "drop ".$this->db->escape($column).$comma; | ||||
|         } | ||||
|  | ||||
|         $query = "alter table #__".$table." $q"; | ||||
|  | ||||
|         $db->setQuery($query); | ||||
|         $db->execute(); | ||||
|     } | ||||
|  | ||||
|   	public function fetch($table, $columns = "*", $where = null, $singlerow = false) { | ||||
|         if (!$table) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         $db = $this->db; | ||||
|         $query = $db->getQuery(true); | ||||
|  | ||||
|         $query | ||||
|             ->select($columns) | ||||
|             ->from("#__$table"); | ||||
|          | ||||
|         if (isset($where)) { | ||||
|             $query->where("$where"); | ||||
|         } | ||||
|          | ||||
|         $db->setQuery($query); | ||||
|   | ||||
|         return ($singlerow) ? $db->loadObject() : $db->loadObjectList(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      *  Load the Novarain Framework | ||||
|      * | ||||
|      *  @return  boolean | ||||
|      */ | ||||
| 	public function loadFramework() | ||||
| 	{ | ||||
| 		if (is_file(JPATH_PLUGINS . '/system/nrframework/autoload.php')) | ||||
| 		{ | ||||
| 			include_once JPATH_PLUGINS . '/system/nrframework/autoload.php'; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 *  Re-orders plugin after passed array of plugins | ||||
| 	 * | ||||
| 	 *  @param   string  $plugin            Plugin element name | ||||
| 	 *  @param   array   $lowerPluginOrder  Array of plugin element names | ||||
| 	 * | ||||
| 	 *  @return  boolean | ||||
| 	 */ | ||||
| 	public function pluginOrderAfter($lowerPluginOrder) | ||||
|     { | ||||
|  | ||||
|         if (!is_array($lowerPluginOrder) || !count($lowerPluginOrder)) | ||||
|         { | ||||
|             return; | ||||
|         } | ||||
|          | ||||
|         $db = $this->db; | ||||
|  | ||||
|         // Get plugins max order | ||||
|         $query = $db->getQuery(true); | ||||
|         $query | ||||
|             ->select($db->quoteName('b.ordering')) | ||||
|             ->from($db->quoteName('#__extensions', 'b')) | ||||
|             ->where($db->quoteName('b.element') . ' IN ("'.implode("\",\"",$lowerPluginOrder).'")') | ||||
|             ->order('b.ordering desc'); | ||||
|  | ||||
|         $db->setQuery($query); | ||||
|         $maxOrder = $db->loadResult(); | ||||
|  | ||||
|         if (is_null($maxOrder)) | ||||
|         { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         // Get plugin details | ||||
|         $query | ||||
|             ->clear() | ||||
|             ->select(array($db->quoteName('extension_id'), $db->quoteName('ordering'))) | ||||
|             ->from($db->quoteName('#__extensions')) | ||||
|             ->where($db->quoteName('element') . ' = ' . $db->quote($this->alias)); | ||||
|  | ||||
|         $db->setQuery($query); | ||||
|         $pluginInfo = $db->loadObject(); | ||||
|  | ||||
|         if (!isset($pluginInfo->ordering) || $pluginInfo->ordering > $maxOrder) | ||||
|         { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         // Update the new plugin order | ||||
|         $object = new stdClass(); | ||||
|         $object->extension_id = $pluginInfo->extension_id; | ||||
|         $object->ordering = ($maxOrder + 1); | ||||
|  | ||||
| 		try { | ||||
| 			$db->updateObject('#__extensions', $object, 'extension_id'); | ||||
| 		} catch (Exception $e) { | ||||
| 			return $e->getMessage(); | ||||
| 		} | ||||
|     } | ||||
| } | ||||
							
								
								
									
										23
									
								
								plugins/fields/acftwitter/script.install.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								plugins/fields/acftwitter/script.install.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * @package         Advanced Custom Fields | ||||
|  * @version         2.8.8 Pro | ||||
|  *  | ||||
|  * @author          Tassos Marinos <info@tassos.gr> | ||||
|  * @link            http://www.tassos.gr | ||||
|  * @copyright       Copyright © 2019 Tassos Marinos All Rights Reserved | ||||
|  * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later | ||||
| */ | ||||
|  | ||||
| defined('_JEXEC') or die('Restricted access'); | ||||
|  | ||||
| require_once __DIR__ . '/script.install.helper.php'; | ||||
|  | ||||
| class PlgFieldsACFTwitterInstallerScript extends PlgFieldsACFTwitterInstallerScriptHelper | ||||
| { | ||||
| 	public $alias = 'acftwitter'; | ||||
| 	public $extension_type = 'plugin'; | ||||
| 	public $plugin_folder = "fields"; | ||||
| 	public $show_message = false; | ||||
| } | ||||
							
								
								
									
										23
									
								
								plugins/fields/acftwitter/tmpl/acftwitter.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								plugins/fields/acftwitter/tmpl/acftwitter.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * @package         Advanced Custom Fields | ||||
|  * @version         2.8.8 Pro | ||||
|  *  | ||||
|  * @author          Tassos Marinos <info@tassos.gr> | ||||
|  * @link            http://www.tassos.gr | ||||
|  * @copyright       Copyright © 2019 Tassos Marinos All Rights Reserved | ||||
|  * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later | ||||
| */ | ||||
|  | ||||
| defined('_JEXEC') or die; | ||||
|  | ||||
| // Grab the widget type | ||||
| $widget_type = $fieldParams->get('widget_type', true); | ||||
|  | ||||
| $file = __DIR__ . '/plugins/' . $widget_type . '.php'; | ||||
| if(file_exists($file)) | ||||
| { | ||||
| 	// Display selected widget | ||||
| 	require $file; | ||||
| } | ||||
							
								
								
									
										37
									
								
								plugins/fields/acftwitter/tmpl/plugins/follow.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								plugins/fields/acftwitter/tmpl/plugins/follow.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * @package         Advanced Custom Fields | ||||
|  * @version         2.8.8 Pro | ||||
|  *  | ||||
|  * @author          Tassos Marinos <info@tassos.gr> | ||||
|  * @link            http://www.tassos.gr | ||||
|  * @copyright       Copyright © 2019 Tassos Marinos All Rights Reserved | ||||
|  * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later | ||||
| */ | ||||
|  | ||||
| defined('_JEXEC') or die; | ||||
|  | ||||
| use Joomla\CMS\Factory; | ||||
|  | ||||
| if (!$twitter_handle = htmlentities($field->value, ENT_COMPAT, 'UTF-8')) | ||||
| { | ||||
| 	return; | ||||
| } | ||||
|  | ||||
| $large_button = $fieldParams->get('follow.large_button', true); | ||||
| $show_username = $fieldParams->get('follow.show_username', true); | ||||
| $show_count = $fieldParams->get('follow.show_count', true); | ||||
|  | ||||
| // Load twitter's widgets library | ||||
| $doc = Factory::getDocument(); | ||||
| $doc->addScript('https://platform.twitter.com/widgets.js'); | ||||
|  | ||||
| echo '<a href="https://twitter.com/' . $twitter_handle . '"  | ||||
| 		class="twitter-follow-button"  | ||||
| 		data-show-count="' . ($show_count ? "true" : "false") . '" | ||||
| 		data-size="' . ($large_button ? "large" : "") . '" | ||||
| 		data-show-screen-name="' . ($show_username ? "true" : "false") . '"> | ||||
|       </a>'; | ||||
|        | ||||
| ?> | ||||
							
								
								
									
										16
									
								
								plugins/fields/acftwitter/version.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								plugins/fields/acftwitter/version.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | ||||
| <?php | ||||
|  | ||||
| /** | ||||
|  * @package         Advanced Custom Fields | ||||
|  * @version         2.8.8 Pro | ||||
|  * | ||||
|  * @author          Tassos Marinos <info@tassos.gr> | ||||
|  * @link            http://www.tassos.gr | ||||
|  * @copyright       Copyright © 2019 Tassos Marinos All Rights Reserved | ||||
|  * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later | ||||
|  */ | ||||
|  | ||||
| defined('_JEXEC') or die('Restricted Access'); | ||||
| $NR_PRO = "1"; | ||||
|  | ||||
| ?> | ||||
		Reference in New Issue
	
	Block a user