File manager - Edit - /home/jardides/www/Jardi-design/old/plugins/pagebuilderck/contact/contact.php
Back
<?php /** * @copyright Copyright (C) 2016 Cédric KEIFLIN alias ced1870 * http://www.template-creator.com * http://www.joomlack.fr * @license GNU/GPL * */ defined('_JEXEC') or die('Restricted access'); jimport('joomla.event.plugin'); require_once JPATH_SITE . '/components/com_contact/models/category.php'; require_once JPATH_SITE . '/components/com_contact/models/contact.php'; class plgPagebuilderckContact extends JPlugin { private $context = 'PLG_PAGEBUILDERCK_CONTACT'; private $type = 'contact'; function __construct(&$subject, $params) { $lang = JFactory::getLanguage(); $lang->load('plg_pagebuilderck_contact', JPATH_SITE . '/plugins/pagebuilderck/contact', $lang->getTag(), false); $this->loadLanguage(); // loads the language files from the contact component $lang->load('com_contact', JPATH_SITE, $lang->getTag(), false); $this->callCss(); $app = JFactory::getApplication(); if ($app->isSite() && $app->input->get('pagebuidlerckoption', '', 'string') === 'plg_contact' && $app->input->get('pagebuidlercktask', '', 'cmd') === 'plg.contact.submit') { $this->processSubmit(); } parent::__construct($subject, $params); } private function callCss() { $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 input[type="email"], .contactck-field textarea { width: 100%; box-sizing: border-box; height: 100%; }'; // $doc = JFactory::getDocument(); PagebuilderckFrontHelper::addStyleDeclaration($css); } private function processSubmit() { require_once(JPATH_SITE . '/plugins/pagebuilderck/' . $this->type . '/contacthelper.php'); plgPagebuilderckContactHelper::processSubmit(); } /* * Construct the Menu Item to drag into the interface * * Return Object with item data */ public function onPagebuilderckAddItemToMenu() { // load the language files of the plugin $this->loadLanguage(); // create the menu item $menuitem = new stdClass(); $menuitem->type = $this->type; $menuitem->title = JText::_($this->context . '_MENUITEM_TITLE'); $menuitem->description = JText::_($this->context . '_MENUITEM_DESC'); $menuitem->image = JUri::root(true) . '/plugins/pagebuilderck/contact/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 onPagebuilderckLoadItemContentContact() { // 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"> <form id="contactck<?php echo $id ?>" action="javascript:void(0)" method="post" class="form-validate form-horizontal"> <fieldset> <div class="contactck-group clearfix"> <div class="contactck-label"> <label id="contactck<?php echo $id ?>_name-lbl" class="" title="" for="contactck<?php echo $id ?>_name" > Name <span class="star"> *</span> </label> </div> <div class="contactck-field" data-placeholder="Name"> <input id="contactck<?php echo $id ?>_name" class="" type="text" size="30" value="" name="contactck<?php echo $id ?>_name"> </div> </div> <div class="contactck-group clearfix"> <div class="contactck-label"> <label id="contactck<?php echo $id ?>_email-lbl" class="" title="" for="contactck<?php echo $id ?>_email" > E-mail <span class="star"> *</span> </label> </div> <div class="contactck-field" data-placeholder="E-mail"> <input id="contactck<?php echo $id ?>_email" class="" type="email" size="30" value="" name="contactck<?php echo $id ?>_email"> </div> </div> <div class="contactck-group clearfix"> <div class="contactck-label"> <label id="contactck<?php echo $id ?>_email-lbl" class="" title="" for="contactck<?php echo $id ?>_subject" > Subject <span class="star"> *</span> </label> </div> <div class="contactck-field" data-placeholder="Subject"> <input id="contactck<?php echo $id ?>_email" class="" type="text" size="30" value="" name="contactck<?php echo $id ?>_subject"> </div> </div> <div class="contactck-group clearfix"> <div class="contactck-label"> <label id="contactck<?php echo $id ?>_email-lbl" class="" title="" for="contactck<?php echo $id ?>_message" > Message <span class="star"> *</span> </label> </div> <div class="contactck-field" data-placeholder="Subject"> <textarea id="contactck<?php echo $id ?>_message" class="" type="text" size="30" value="" name="contactck<?php echo $id ?>_message"></textarea> </div> </div> <div class="contactck-actions"> <button class="contactck-button" type="submit" onclick="javascript:void(0)"><?php echo JText::_('COM_CONTACT_CONTACT_SEND'); ?></button> </div> </fieldset> </form> </div> </div> </div> <?php } /* * Display the html code for the item to be used into the interface * * Return String the html code */ public function onPagebuilderckLoadItemOptionsContact() { // load the language files of the plugin $this->loadLanguage(); // load the interface for the options $tpl = JPATH_SITE . '/plugins/pagebuilderck/contact/layouts/edit_contact.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 onPagebuilderckRenderItemContact($item) { // 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); $contactId = $pbckParams->get('contactid'); if (! $contactId) { return '<p style="color:red">PAGE BUILDER CK ERROR : Contact item : No contact found !</p>'; } // add the validation script $doc = JFactory::getDocument(); $doc->addScript(JURI::root(true) . '/media/system/js/validate.js'); if ($pbckParams->get('contactckshowlabels') == 'placeholder') { $this->addPlaceholders(); } $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 : ''; $app = JFactory::getApplication(); $input = JFactory::getApplication()->input; $id = $input->get('ckid', '', 'string'); // Get the parameters $params = JComponentHelper::getParams('com_contact'); $categoryModel = JModelLegacy::getInstance('Category', 'ContactModel', array('ignore_request' => true)); $contactModel = JModelLegacy::getInstance('Contact', 'ContactModel', array('ignore_request' => true)); // $categoryModel->setState('category.id', $item->catid); $categoryModel->setState('list.ordering', 'a.name'); $categoryModel->setState('list.direction', 'asc'); $categoryModel->setState('filter.published', 1); // $contacts = $categoryModel->getItems(); // $params->set('redirect', 'index.php/toto'); $contactModel->setState('params', $params); $contactModel->setState('contact.id', $contactId); $contact = $contactModel->getItem($contactId); // If we found an item, merge the item parameters $params->merge($contact->params); $com_path = JPATH_SITE . '/components/com_contact'; // Get the form. JForm::addFormPath($com_path . '/models/forms'); JForm::addFieldPath($com_path . '/models/fields'); JForm::addFormPath($com_path . '/model/form'); JForm::addFieldPath($com_path . '/model/field'); $form = JForm::getInstance('com_contact.contact', 'contact', array('control' => 'jform', 'load_data' => true)); $this->contact = &$contact; $this->params = &$params; $this->form = $form; // ckstyle and inner classes are needed to get the styles from the interface ob_start(); ?> <div class="ckstyle"> <?php echo $styles ?> </div> <div class="inner"> <div class="contactck <?php echo ($pbckParams->get('contactcklayout') == 'vertical' ? 'verticalck' : ''); ?>"> <form id="contactck<?php echo $item->attr['id'] ?>" action="<?php echo JUri::current(); ?>" method="post" class="form-validate form-horizontal"> <fieldset> <div class="contactck-group clearfix"> <?php if ($showLabels == '1') : ?><div class="contactck-label"><?php echo $this->form->getLabel('contact_name'); ?></div><?php endif; ?> <div class="contactck-field" data-placeholder="<?php echo JText::_('COM_CONTACT_CONTACT_EMAIL_NAME_LABEL') ?>"><?php echo $this->form->getInput('contact_name'); ?></div> </div> <div class="contactck-group clearfix"> <?php if ($showLabels == '1') : ?><div class="contactck-label"><?php echo $this->form->getLabel('contact_email'); ?></div><?php endif; ?> <div class="contactck-field" data-placeholder="<?php echo JText::_('COM_CONTACT_EMAIL_LABEL') ?>"><?php echo $this->form->getInput('contact_email'); ?></div> </div> <div class="contactck-group clearfix"> <?php if ($showLabels == '1') : ?><div class="contactck-label"><?php echo $this->form->getLabel('contact_subject'); ?></div><?php endif; ?> <div class="contactck-field" data-placeholder="<?php echo JText::_('COM_CONTACT_CONTACT_MESSAGE_SUBJECT_LABEL') ?>"><?php echo $this->form->getInput('contact_subject'); ?></div> </div> <div class="contactck-group clearfix"> <?php if ($showLabels == '1') : ?><div class="contactck-label"><?php echo $this->form->getLabel('contact_message'); ?></div><?php endif; ?> <div class="contactck-field" data-placeholder="<?php echo JText::_('COM_CONTACT_CONTACT_ENTER_MESSAGE_LABEL') ?>"><?php echo $this->form->getInput('contact_message'); ?></div> </div> <?php if ($this->params->get('show_email_copy')) : ?> <div class="contactck-group clearfix"> <?php if ($showLabels == '1') : ?><div class="contactck-label"><?php echo $this->form->getLabel('contact_email_copy'); ?></div><?php endif; ?> <div class="contactck-field" data-placeholder="<?php echo JText::_('COM_CONTACT_CONTACT_EMAIL_A_COPY_LABEL') ?>"><?php echo $this->form->getInput('contact_email_copy'); ?></div> </div> <?php endif; ?> <?php // captcha if ($params->get('captcha', JFactory::getConfig()->get('captcha')) !== '0') { $plugin = JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha')); $captcha = JCaptcha::getInstance($plugin, array('namespace' => 'plg_pagebuilderck_contact')); if ($captcha != null) echo $captcha->display('contactck_captcha', 'contactck_captcha', 'g-recaptcha required'); } ?> <div class="contactck-actions" style="text-align:<?php echo $buttonAlign ?>;"> <button class="btn contactck-button" type="submit"><?php echo JText::_('COM_CONTACT_CONTACT_SEND'); ?></button> <input type="hidden" name="pagebuidlerckoption" value="plg_contact" /> <input type="hidden" name="pagebuidlercktask" value="plg.contact.submit" /> <input type="hidden" name="return" value="" /> <input type="hidden" name="contactid" value="<?php echo $this->contact->slug; ?>" /> <?php echo JHtml::_('form.token'); ?> </div> </fieldset> </form> </div> </div> <?php $html = ob_get_clean(); return $html; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings