File manager - Edit - /home/jardides/www/Jardi-design/old/plugins/pagebuilderck/contact2/contact2.php
Back
<?php /** * @copyright Copyright (C) 2016 Cédric KEIFLIN alias ced1870 * https://www.template-creator.com * https://www.joomlack.fr * @license GNU/GPL * */ defined('_JEXEC') or die('Restricted access'); jimport('joomla.event.plugin'); class plgPagebuilderckContact2 extends JPlugin { private $context = 'PLG_PAGEBUILDERCK_CONTACT'; private $type = 'contact2'; function __construct(&$subject, $params) { $lang = JFactory::getLanguage(); $lang->load('plg_pagebuilderck_contact2', JPATH_ADMINISTRATOR, $lang->getTag(), false); $this->loadLanguage(); // loads the language files from the contact component // $lang->load('com_contact', JPATH_SITE, $lang->getTag(), false); $app = JFactory::getApplication(); if ($app->isClient('site') && $app->input->get('pagebuilderckoption', '', 'string') === 'plg_contact2' && $app->input->get('pagebuildercktask', '', 'cmd') === 'plg.contact2.submit') { $this->processSubmit(); } parent::__construct($subject, $params); } private function callAssets() { $css = '.contactck .contactck-label, .contactck .contactck-field { float: left; box-sizing: border-box; width: 50%; } .contactck.verticalck .contactck-label, .contactck.verticalck .contactck-field { float: none; width: 100%; } .contactck-field input[type="text"], .contactck-field select, .contactck-field input[type="email"], .contactck-field textarea { width: 100%; box-sizing: border-box; height: 100%; }'; // $doc = JFactory::getDocument(); PagebuilderckFrontHelper::addStyleDeclaration($css); PagebuilderckFrontHelper::addStylesheet(JUri::root(true) . '/plugins/pagebuilderck/contact2/assets/contact.css'); } private function processSubmit() { $this->loadLanguage(); require_once(JPATH_SITE . '/plugins/pagebuilderck/' . $this->type . '/contact2helper.php'); plgPagebuilderckContact2Helper::processSubmit(); } /* * Construct the Menu Item to drag into the interface * * Return Object with item data */ public function onPagebuilderckAddItemToMenu() { $this->callAssets(); // load the language files of the plugin $this->loadLanguage(); // create the menu item $menuitem = new stdClass(); $menuitem->type = $this->type; $menuitem->group = 'other'; $menuitem->title = JText::_($this->context . '_MENUITEM_TITLE'); $menuitem->description = JText::_($this->context . '_MENUITEM_DESC'); $menuitem->image = JUri::root(true) . '/plugins/pagebuilderck/contact2/assets/images/contact.png'; return $menuitem; } /* * Display the html code for the item to be used into the interface * * Return String the html code */ public function onPagebuilderckLoadItemContentContact2() { $this->loadLanguage(); // ckstyle and inner classes are needed to get the styles from the interface $input = JFactory::getApplication()->input; $id = $input->get('ckid', '', 'string'); ?> <div id="<?php echo $id; ?>" class="cktype" data-type="<?php echo $this->type ?>"> <div class="tab_rowstyles ckprops" contactckrowsmarginbottom="10" fieldslist="contactckrowsmarginbottom"></div> <div class="tab_inputstyles ckprops" contactckinputspaddingtop="6" contactckinputspaddingright="6" contactckinputspaddingbottom="6" contactckinputspaddingleft="6" fieldslist="contactckinputspaddingtop,contactckinputspaddingright,contactckinputspaddingbottom,contactckinputspaddingleft"></div> <div class="tab_contact ckprops" contactcklayout="vertical" contactckshowlabels="1" fieldslist="contactcklayout,contactckshowlabels"></div> <div class="tab_buttonstyles ckprops" contactckbuttonsbackgroundcolorstart="#e8e8e8" contactckbuttonspaddingtop="5" contactckbuttonspaddingright="12" contactckbuttonspaddingbottom="5" contactckbuttonspaddingleft="12" contactckbuttonsborderscolor="#c7c7c7" contactckbuttonsborderssize="1" contactckbuttonsbordersstyle="solid" fieldslist="contactckbuttonsbackgroundcolorstart,contactckbuttonspaddingtop,contactckbuttonspaddingright,contactckbuttonspaddingbottom,contactckbuttonspaddingleft,contactckbuttonsborderscolor,contactckbuttonsborderssize,contactckbuttonsbordersstyle"></div> <div class="ckstyle"> <style> #<?php echo $id; ?> .contactck .contactck-group { margin-bottom: 10px; } #<?php echo $id; ?> .contactck input, #<?php echo $id; ?> .contactck textarea { padding: 6px 6px; } #<?php echo $id; ?> .contactck .contactck-button { background: #e8e8e8; border: #c7c7c7 1px solid; padding-top: 5px; padding-right: 12px; padding-bottom: 5px; padding-left: 12px; } </style> </div> <div class="inner"> <div class="contactck verticalck"> <div id="contactck<?php echo $id ?>" class="form-horizontal"> <div class="contactck-column" style="width: calc(100%); margin-bottom: 10px;"> <div class="contactck-group clearfix"> <div class="contactck-label"> <label id="<?php echo $id ?>_name-lbl" class="" title="" for="<?php echo $id ?>_name" > Name </label> </div> <div class="contactck-field" data-placeholder="Name"> <input id="<?php echo $id ?>_name" data-id="<?php echo $id ?>_name" name="<?php echo $id ?>[name]" class="ckcontactfield" type="text" size="30" value="" data-name="name"> </div> </div> <div class="contactck-group clearfix"> <div class="contactck-label"> <label id="<?php echo $id ?>_email-lbl" class="" title="" for="<?php echo $id ?>_email" > E-mail </label> </div> <div class="contactck-field" data-placeholder="E-mail"> <input id="<?php echo $id ?>_email" data-id="<?php echo $id ?>_email" name="<?php echo $id ?>[email]" class="ckcontactfield" type="text" size="30" value=""data-name="email"> </div> </div> <div class="contactck-group clearfix"> <div class="contactck-label"> <label id="<?php echo $id ?>_subject-lbl" class="" title="" for="<?php echo $id ?>_subject" > Subject </label> </div> <div class="contactck-field" data-placeholder="Subject"> <input id="<?php echo $id ?>_subject" data-id="<?php echo $id ?>_subject" name="<?php echo $id ?>[subject]" class="ckcontactfield" type="text" size="30" value="" data-name="subject"> </div> </div> <div class="contactck-group clearfix"> <div class="contactck-label"> <label id="<?php echo $id ?>_message-lbl" class="" title="" for="<?php echo $id ?>_message" > Message <span class="star"> *</span> </label> </div> <div class="contactck-field" data-placeholder="Message"> <textarea id="<?php echo $id ?>_message" data-id="<?php echo $id ?>_message" name="<?php echo $id ?>[message]" class="ckcontactfield" type="textarea" size="30" value="" data-name="message" data-required="1" ></textarea> </div> </div> <div class="contactck-group clearfix captcha" data-type="captcha"> <div style="text-align: left;"> <img src="<?php echo JUri::root(true) ?>/plugins/pagebuilderck/contact2/assets/images/captcha.png" width="302" height="76" /> </div> </div> <div class="contactck-actions"> <button class="contactck-button" type="submit" onclick="javascript:void(0)"><?php echo JText::_('PLG_PAGEBUILDERCK_CONTACT_SEND'); ?></button> </div> </div> </div> </div> </div> </div> <?php } /* * Display the html code for the item to be used into the interface * * Return String the html code */ public function onPagebuilderckLoadItemOptionsContact2() { // load the language files of the plugin $this->loadLanguage(); // load the interface for the options $tpl = JPATH_SITE . '/plugins/pagebuilderck/contact2/layouts/edit_contact2.php'; return $tpl; } private function addPlaceholders() { $js = "jQuery(document).ready(function() { jQuery('.contactck-field').each(function() { jQuery(this).find('input, textarea').attr('placeholder', jQuery(this).attr('data-placeholder')); }); });"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); } /* * Display the html code for the item to be used into the frontend page * @param string the item object from simple_html_dom * * Return String the html code */ public function onPagebuilderckRenderItemContact2($item) { // load the language files of the plugin $this->loadLanguage(); $this->callAssets(); // load the helper to help us to use the parameters include_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/helpers/pagebuilderckfront.php'; // get params from page builder interface $attrs = $item->find('.tab_contact'); // this is the tab id in the interface which contains the map options $pbckParams = PagebuilderckFrontHelper::createParamsFromElement($attrs); // get params from page builder interface $attrs = $item->find('.tab_contactemail'); // this is the tab id in the interface which contains the map options $pbckParamsEmail = PagebuilderckFrontHelper::createParamsFromElement($attrs); $app = JFactory::getApplication(); // add the validation script $doc = JFactory::getDocument(); $doc->addScript(JURI::root(true) . '/media/system/js/validate.js'); if ($pbckParams->get('contactckshowlabels') == 'placeholder') { $this->addPlaceholders(); } $systemMessages = array(); $showLabels = $pbckParams->get('contactckshowlabels', '1'); $buttonAlign = 'left'; if ($pbckParams->get('buttonalignementleft', '') == 'checked') $buttonAlign = 'left'; if ($pbckParams->get('buttonalignementcenter', '') == 'checked') $buttonAlign = 'center'; if ($pbckParams->get('buttonalignementright', '') == 'checked') $buttonAlign = 'right'; // ckstyle and inner classes are needed to get the styles from the interface $ckstyle = $item->find('.ckstyle'); $styles = count($ckstyle) ? $ckstyle[0]->innertext : ''; $styles .= '@media only screen and (max-width:' . (int)$pbckParams->get('responsiveresolution', '640') . 'px){ #'.$item->attr['id'].' div.contactck > div { display: block; } #'.$item->attr['id'].' .contactck-column { width: 100% !important; } }'; // find all types in the page foreach($item->find('.contactck-label label') as $e) { $e->innertext = JText::_($e->innertext); } $item->find('.captcha')[0]->innertext = ''; // replace the captcha // get info from the plugin options $plugin = JPluginHelper::getPlugin('pagebuilderck', 'contact2'); $pluginParams = new JRegistry($plugin->params); $captcha = $pluginParams->get('enablecaptcha', '1'); if ($captcha == '1') { $plugin = JFactory::getConfig()->get('captcha'); if ($plugin !== '0') { $captcha = JCaptcha::getInstance($plugin, array('namespace' => 'plg_pagebuilderck_contact')); if ($captcha != null) { $item->find('.captcha')[0]->innertext = $captcha->display('contactck_captcha', 'contactck_captcha', 'g-recaptcha required'); } } else { $systemMessages[] = array(JText::_('PLG_PAGEBUILDERCK_CONTACT_CAPTCHA_NOT_LOADED'), 'danger'); } } // else { // $item->find('.captcha')[0]->innertext = ''; // } $input = JFactory::getApplication()->input; $id = $input->get('ckid', '', 'string'); // check if the recipient has been set if ($pbckParamsEmail->get('contactemail') == '') { $systemMessages[] = array(JText::_('PLG_PAGEBUILDERCK_CONTACT_RECIPIENT_EMPTY'), 'warning'); } ob_start(); ?> <div class="ckstyle"> <?php echo $styles ?> </div> <div class="inner"> <?php $session = JFactory::getSession(); $successMessage = $session->get('pagebuilderck_contact_successmessage_' . $item->attr['id']); if ($successMessage) $systemMessages[] = $successMessage; $session->set('pagebuilderck_contact_successmessage_' . $item->attr['id'], ''); foreach ($systemMessages as $m) { $text = $m[0]; $type = isset($m[1]) ? ' alert-' . $m[1] : ''; if ($text) { ?> <div class="alert<?php echo $type ?>"><?php echo $text ?></div> <?php } } ?> <form id="contactck<?php echo $item->attr['id'] ?>" method="post" class="form-validate form-horizontal"> <div class="contactck <?php echo ($pbckParams->get('contactcklayout') == 'vertical' ? 'verticalck' : ''); ?>"> <?php $text = $pbckParams->get('sendbuttontext') ? JText::_($pbckParams->get('sendbuttontext')) : JText::_('PLG_PAGEBUILDERCK_CONTACT_SEND'); $item->find('.contactck-button')[0]->innertext = $text; // store the labels names $labels = array(); foreach ($item->find('.contactck-field') as $f) { $fieldid = addslashes($f->find('.ckcontactfield')[0]->{'data-name'}); $labels[$fieldid] = addslashes($f->{'data-placeholder'}); } ?> <input type="hidden" id="labels" name="labels" value="<?php echo htmlspecialchars(serialize($labels)) ?>" /> <?php echo str_replace('data-required="1"', 'required', $item->find('.contactck')[0]->innertext) ?> <?php if ($pbckParamsEmail->get('show_email_copy_1', '') === 'checked' || $pbckParamsEmail->get('show_email_copy', '') === '1' ) { ?> <div class="contactck-group clearfix"> <div class="contactck-field" data-placeholder="<?php echo JText::_('PLG_PAGEBUILDERCK_CONTACT_EMAIL_A_COPY_LABEL') ?>"> <div> <label class="contactck-label-checkbox" style="display: inline-block;float: none;" for="<?php echo $item->attr['id'] ?>_copyemail"><?php echo JText::_('PLG_PAGEBUILDERCK_CONTACT_EMAIL_A_COPY_LABEL') ?></label> <input type="checkbox" data-name="copyemail" data-id="<?php echo $item->attr['id'] ?>_copyemail" name="<?php echo $item->attr['id'] ?>[copyemail][]" id="<?php echo $item->attr['id'] ?>_copyemail" class="ckcontactfield" value="1"> </div> </div> </div> <?php } else if ($pbckParamsEmail->get('show_email_copy', '') === '2') { ?> <input type="hidden" data-name="copyemail" data-id="<?php echo $item->attr['id'] ?>_copyemail" name="<?php echo $item->attr['id'] ?>[copyemail][]" id="<?php echo $item->attr['id'] ?>_copyemail" class="ckcontactfield" value="1"> <?php } ?> <input type="hidden" name="pagebuilderckoption" value="plg_contact2" /> <input type="hidden" name="pagebuildercktask" value="plg.contact2.submit" /> <input type="hidden" name="pagebuilderckid" value="<?php echo $item->attr['id'] ?>" /> <input type="hidden" name="return" value="" /> <?php echo JHtml::_('form.token'); ?> </div> </form> </div> <?php $html = ob_get_clean(); return $html; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.06 |
proxy
|
phpinfo
|
Settings