public function getInput($name, $group = null, $value = null) { $dispatcher = JDispatcher::getInstance(); $formname = $this->getName(); $formname = explode('.', $formname); $formname = $formname[count($formname) - 1]; $html = ''; $dispatcher->trigger('onBeforeGet' . strtoupper($this->ext_prefix) . 'FormInput' . ucfirst($formname) . ucfirst($name), array(&$this, &$name, &$html)); if ($name != 'empty' && ($field = $this->getField($name, $group, $value))) { $element = $this->findField($name, $group); $field_html = $field->input; if (isset($element['wrap']) && !empty($element['wrap'])) { $field_html = KSSystem::wrapFormField($element['wrap'], $element, $field_html); } $html .= $field_html; } $dispatcher->trigger('onAfterGet' . strtoupper($this->ext_prefix) . 'FormInput' . ucfirst($formname) . ucfirst($name), array(&$this, &$name, &$html)); return $html; }
public function getInput() { $db = JFactory::getDBO(); $res_html = ''; $query = $db->getQuery(true); $query->select('*')->from('#__ksenmart_countries')->where('published=1')->order('ordering'); $db->setQuery($query); $countries = $db->loadObjectList('id'); foreach ($countries as &$country) { $query = $db->getQuery(true); $query->select('*')->from('#__ksenmart_regions')->where('published=1')->where('country_id=' . $country->id)->order('ordering'); $db->setQuery($query); $country->regions = $db->loadObjectList('id'); } unset($country); $html = ''; $html .= '<div class="row countries">'; $html .= ' <ul>'; foreach ($this->value as $country_id => $regions) { if (isset($countries[$country_id])) { $html .= ' <li country_id="' . $country_id . '"><span>' . $countries[$country_id]->title . '</span><i></i><input type="hidden" name="' . $this->name . '[' . $country_id . '][]"></li>'; } } $html .= ' <li class="no-countries" style="' . (count($this->value) > 0 ? 'display:none;' : '') . '"><span>' . JText::_('ksm_shippings_shipping_no_countries') . '</span></li>'; $html .= ' </ul>'; $html .= '</div>'; $html .= '<div class="row">'; $html .= ' <a href="#" id="add-country" class="add">' . JText::_('ksm_add') . '</a>'; $html .= '</div>'; $html .= '<div id="popup-window3" class="popup-window" style="display: none;">'; $html .= ' <div style="width: 460px;height: 260px;margin-left: -230px;margin-top: -130px;">'; $html .= ' <div class="popup-window-inner">'; $html .= ' <div class="heading">'; $html .= ' <h3>' . JText::_('ksm_shippings_shipping_countries') . '</h3>'; $html .= ' <div class="save-close">'; $html .= ' <button class="close" onclick="return false;"></button>'; $html .= ' </div>'; $html .= ' </div>'; $html .= ' <div class="contents">'; $html .= ' <div class="contents-inner">'; $html .= ' <div class="slide_module">'; $html .= ' <div class="row">'; $html .= ' <ul>'; $html .= ' <li class="all-countries"><span>' . JText::_('ksm_shippings_shipping_all_countries') . '</span></li>'; foreach ($countries as $country) { $html .= ' <li country_id="' . $country->id . '" class="' . (array_key_exists($country->id, $this->value) ? 'active' : '') . '"><span>' . $country->title . '</span></li>'; } $html .= ' </ul>'; $html .= ' </div>'; $html .= ' </div>'; $html .= ' </div>'; $html .= ' </div>'; $html .= ' </div>'; $html .= ' </div>'; $html .= '</div>'; $this->element['label'] = 'KSM_SHIPPINGS_SHIPPING_COUNTRIES'; $this->element['type'] = 'countries'; $res_html .= KSSystem::wrapFormField('slidemodule', $this->element, $html); $html = ''; $html .= '<div class="row regions">'; $html .= ' <ul>'; $count_regions = 0; foreach ($this->value as $country_id => $regions) { $count_regions += count($regions); foreach ($regions as $region_id) { if (isset($countries[$country_id]) && isset($countries[$country_id]->regions[$region_id])) { $html .= ' <li region_id="' . $region_id . '"><span>' . $countries[$country_id]->regions[$region_id]->title . '</span><i></i><input type="hidden" name="' . $this->name . '[' . $country_id . '][]" value="' . $region_id . '"></li>'; } } } $html .= ' <li class="no-regions" style="' . ($count_regions > 0 ? 'display:none;' : '') . '"><span>' . JText::_('ksm_shippings_shipping_no_regions') . '</span></li>'; $html .= ' </ul>'; $html .= '</div>'; $html .= '<div class="row">'; $html .= ' <a href="#" id="add-city" class="add">' . JText::_('ksm_add') . '</a>'; $html .= '</div>'; $html .= '<div id="popup-window4" class="popup-window" style="display: none;">'; $html .= ' <div style="width: 460px;height: 260px;margin-left: -230px;margin-top: -130px;">'; $html .= ' <div class="popup-window-inner">'; $html .= ' <div class="heading">'; $html .= ' <h3>' . JText::_('ksm_shippings_shipping_regions') . '</h3>'; $html .= ' <div class="save-close">'; $html .= ' <button class="close" onclick="return false;"></button>'; $html .= ' </div>'; $html .= ' </div>'; $html .= ' <div class="contents">'; $html .= ' <div class="contents-inner">'; $html .= ' <div class="slide_module">'; $html .= ' <div class="row no-countries" style="' . (count($this->value) > 0 ? 'display:none;' : '') . '">'; $html .= ' <ul>'; $html .= ' <li><span>' . JText::_('ksm_shippings_shipping_no_countries') . '</span></li>'; $html .= ' </ul>'; $html .= ' </div>'; foreach ($countries as $country) { $html .= ' <div class="row regions-row regions-row-' . $country->id . '" style="' . (array_key_exists($country->id, $this->value) ? '' : 'display:none;') . '">'; $html .= ' <h3>' . $country->title . '</h3>'; $html .= ' <ul>'; $html .= ' <li class="all-regions"><span>' . JText::_('ksm_shippings_shipping_all_regions') . '</span></li>'; foreach ($country->regions as $region) { $html .= ' <li region_id="' . $region->id . '" country_id="' . $country->id . '" class="' . (isset($this->value[$country->id]) && in_array($region->id, $this->value[$country->id]) ? 'active' : '') . '"><span>' . $region->title . '</span></li>'; } $html .= ' </ul>'; $html .= ' </div>'; } $html .= ' </div>'; $html .= ' </div>'; $html .= ' </div>'; $html .= ' </div>'; $html .= ' </div>'; $html .= '</div>'; $this->element['label'] = 'KSM_SHIPPINGS_SHIPPING_REGIONS'; $this->element['type'] = 'regions'; $script = ' jQuery(document).ready(function(){ jQuery(".all-countries").click(function(){ if (jQuery(this).is(".active")) { jQuery(this).removeClass("active"); jQuery("#popup-window3 li").each(function(){ if (!jQuery(this).is(".all-countries") && jQuery(this).is(".active")) removeCountry(jQuery(this).attr("country_id")); }); } else { jQuery(this).addClass("active"); jQuery("#popup-window3 li").each(function(){ if (!jQuery(this).is(".all-countries") && !jQuery(this).is(".active")) addCountry(jQuery(this).attr("country_id")); }); } }); jQuery("#popup-window3 li").click(function(){ if (!jQuery(this).is(".all-countries") && jQuery(this).is(".active")) removeCountry(jQuery(this).attr("country_id")); else if (!jQuery(this).is(".all-countries") && !jQuery(this).is(".active")) addCountry(jQuery(this).attr("country_id")); }); jQuery("body").on("click", ".ksm-slidemodule-countries .countries li i", function(){ var country_id=jQuery(this).parents("li").attr("country_id"); removeCountry(country_id); }); jQuery(".all-regions").click(function(){ if (jQuery(this).is(".active")) { jQuery(this).removeClass("active"); jQuery(this).parent().find("li").each(function(){ if (!jQuery(this).is(".all-regions") && jQuery(this).is(".active")) removeRegion(jQuery(this).attr("region_id")); }); } else { jQuery(this).addClass("active"); jQuery(this).parent().find("li").each(function(){ if (!jQuery(this).is(".all-regions") && !jQuery(this).is(".active")) addRegion(jQuery(this).attr("region_id")); }); } }); jQuery("#popup-window4 .regions-row li").click(function(){ if (!jQuery(this).is(".all-regions") && jQuery(this).is(".active")) removeRegion(jQuery(this).attr("region_id")); else if (!jQuery(this).is(".all-regions") && !jQuery(this).is(".active")) addRegion(jQuery(this).attr("region_id")); }); jQuery("body").on("click", ".ksm-slidemodule-regions .regions li i", function(){ var region_id=jQuery(this).parents("li").attr("region_id"); removeRegion(region_id); }); }); function addCountry(country_id) { var html=""; var title=jQuery("#popup-window3 li[country_id="+country_id+"] span").text(); html+="<li country_id="+country_id+">"; html+=" <span>"+title+"</span>"; html+=" <i></i>"; html+=" <input type=\'hidden\' name=\'' . $this->name . '["+country_id+"][]\'>"; html+="</li>"; jQuery("#popup-window3 li[country_id="+country_id+"]").addClass("active"); jQuery(".ksm-slidemodule-countries .countries .no-countries").hide(); jQuery(".ksm-slidemodule-countries .countries ul").append(html); jQuery("#popup-window4 .no-countries").hide(); jQuery("#popup-window4 .regions-row-"+country_id).show(); } function removeCountry(country_id) { jQuery(".ksm-slidemodule-countries .countries li[country_id="+country_id+"]").remove(); if (jQuery(".ksm-slidemodule-countries .countries li").length==1) jQuery(".ksm-slidemodule-countries .countries .no-countries").show(); jQuery("#popup-window3 li[country_id="+country_id+"]").removeClass("active"); jQuery("#popup-window4 .regions-row-"+country_id+" li").each(function(){ if (!jQuery(this).is(".all-regions") && jQuery(this).is(".active")) removeRegion(jQuery(this).attr("region_id")); }); jQuery("#popup-window4 .regions-row-"+country_id).hide(); if (jQuery("#popup-window4 .regions-row:visible").length==0) jQuery("#popup-window4 .no-countries").show(); } function addRegion(region_id) { var html=""; var title=jQuery("#popup-window4 li[region_id="+region_id+"] span").text(); var country_id=jQuery("#popup-window4 li[region_id="+region_id+"]").attr("country_id"); html+="<li region_id="+region_id+">"; html+=" <span>"+title+"</span>"; html+=" <i></i>"; html+=" <input type=\'hidden\' name=\'' . $this->name . '["+country_id+"][]\' value=\'"+region_id+"\'>"; html+="</li>"; jQuery("#popup-window4 li[region_id="+region_id+"]").addClass("active"); jQuery(".ksm-slidemodule-regions .regions .no-regions").hide(); jQuery(".ksm-slidemodule-regions .regions ul").append(html); } function removeRegion(region_id) { jQuery(".ksm-slidemodule-regions .regions li[region_id="+region_id+"]").remove(); if (jQuery(".ksm-slidemodule-regions .regions li").length==1) jQuery(".ksm-slidemodule-regions .regions .no-regions").show(); jQuery("#popup-window4 li[region_id="+region_id+"]").removeClass("active"); } '; $document = JFactory::getDocument(); $document->addScriptDeclaration($script); $res_html .= KSSystem::wrapFormField('slidemodule', $this->element, $html); return $res_html; }
public function getInput() { $document = JFactory::getDocument(); $document->addScript(JURI::base() . 'components/com_ksen/assets/js/swfupload/swfupload.js'); $document->addScript(JURI::base() . 'components/com_ksen/assets/js/swfupload/swfupload.queue.js'); $document->addScript(JURI::base() . 'components/com_ksen/assets/js/swfupload/js/fileprogress.js'); $document->addScript(JURI::base() . 'components/com_ksen/assets/js/swfupload/js/handlers.js'); $document->addScript(JURI::base() . 'components/com_ksen/assets/js/swfupload/config_image.js'); $extension = (string) $this->element['extension']; $html = ''; $keys = array_keys($this->value); if (count($keys) == 0 || $keys[0] > 0) { $html .= '<div class="thumb-img photos">'; $html .= ' <div class="photos-row">'; } foreach ($this->value as $file) { $cparams = JComponentHelper::getParams($extension); $source_filename = JPATH_ROOT . DS . 'media' . DS . $extension . DS . $file->media_type . 's' . DS . $file->folder . DS . 'original' . DS . $file->filename; JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_ksen/models/forms/'); $form = JForm::getInstance('com_ksen.image' . $file->id, 'image', array('control' => $this->name . '[' . $file->id . '][params]')); $params = (array) json_decode($file->params); $keys = array('title', 'watermark', 'displace', 'halign', 'valign'); foreach ($keys as $k) { if (array_key_exists($k, $params)) { $v = $params[$k]; } else { $v = $cparams->get($k, null); } if ($v !== null) { $form->setValue($k, null, $v); } } $thumb_url = KSMedia::resizeImage($source_filename, $file->folder, $cparams->get('admin_product_medium_image_width', 120), $cparams->get('admin_product_medium_image_height', 120), $params, $extension); $dst_filename = basename($thumb_url); $html .= '<div class="photo">'; $html .= '<span class="del-img"></span>'; $html .= ' <div> <img class="image-preview" src="' . $thumb_url . '"> </div> '; $html .= '<div class="popupForm"> <div class="form"> <div class="heading"> <h3>Параметры изображения</h3> <div class="save-close"> <input type="button" class="close" onclick="iparamClose(this);return false;" /> </div> </div> <div class="edit"> <table width="100%"> <tr> <td class="onecol" id="iparamscontent">'; $html .= ' <div id="images-preview"> <div class="leftcol">'; foreach ($keys as $k) { $html .= '<div class="row">' . $form->getLabel($k) . $form->getInput($k) . '</div>'; } $html .= ' </div> <div class="rightcol"> <div class="preview"> <table> <tr> <td style="text-align: center;vertical-align: middle;"> <img src="' . $thumb_url . '" alt="" class="previewxa" /> </td> </tr> </table> </div> </div> </div>'; $html .= '</td> </tr> </table> </div> </div>'; $html .= '</div>'; $html .= '<input type="hidden" value="' . $file->ordering . '" class="ordering" name="' . $this->name . '[' . $file->id . '][ordering]" />'; $html .= '<input type="hidden" class="task" value="save" name="' . $this->name . '[' . $file->id . '][task]" >'; $html .= '<input type="hidden" class="task filename" value="' . basename($file->filename) . '" name="' . $this->name . '[' . $file->id . '][filename]" >'; $html .= '</div>'; } $keys = array_keys($this->value); if (count($keys) == 0 || $keys[0] > 0) { $html .= ' </div>'; $html .= '</div>'; $html .= '<br clear="both">'; $html .= '<div class="uploadButtons">'; $html .= ' <span id="spanButtonPlaceHolder"></span>'; $html .= ' <input id="btnCancel" type="button" value="Cancel All Uploads" onclick="swfu.cancelQueue();" disabled="disabled" style="margin-left: 2px; font-size: 8pt; height: 29px;" />'; $html .= '</div>'; $html .= '<div class="fieldset flash" id="fsUploadProgress">'; $html .= '</div>'; $html = KSSystem::wrapFormField('slidemodule', $this->element, $html); } $session = JFactory::getSession(); $script = ' var session_id="' . $session->getId() . '"; var session_name="' . $session->getName() . '"; var token="' . JSession::getFormToken() . '"; var upload_to="' . $this->element['upload_to'] . '"; var upload_folder="' . $this->element['upload_folder'] . '"; '; $document->addScriptDeclaration($script); return $html; }