public function getInput() { EventgalleryHelpersBackendmedialoader::load(); /** * @var EventgalleryLibraryManagerFoldertype $foldertypeMgr */ $foldertypeMgr = EventgalleryLibraryManagerFoldertype::getInstance(); $foldertypes = $foldertypeMgr->getFolderTypes(true); if ($this->value == null && $foldertypeMgr->getDefaultFolderType(false) != null) { $this->value = $foldertypeMgr->getDefaultFolderType(false)->getId(); } $return = array(); $onchange = "eventgallery.jQuery('.foldertype-input').css('display', 'none'); eventgallery.jQuery('.foldertype-' + this.options[this.selectedIndex].value ).css('display', 'block');"; $return[] = '<select onchange="' . $onchange . '" name=' . $this->name . ' id=' . $this->id . '>'; foreach ($foldertypes as $foldertype) { /** * @var EventgalleryLibraryFoldertype $foldertype */ $this->value == $foldertype->getId() ? $selected = 'selected="selected"' : ($selected = ''); $return[] = '<option ' . $selected . ' value="' . $foldertype->getId() . '">' . $foldertype->getDisplayName() . '</option>'; } $return[] = "</select>"; $return[] = $this->getLocalInput(); $return[] = $this->getPicasaInput(); $currentFolderType = 0; if (isset($this->value)) { $currentFolderType = $this->value; } $return[] = "<script>eventgallery.jQuery('.foldertype-input').css('display', 'none'); eventgallery.jQuery('.foldertype-{$currentFolderType}').css('display', 'block');</script>"; return implode('', $return); }
public static function load() { if (self::$loaded) { return; } self::$loaded = true; include_once JPATH_ROOT . '/administrator/components/com_eventgallery/version.php'; $document = JFactory::getDocument(); JHtml::_('behavior.formvalidation'); $CSSs = array(); $JSs = array(); if (version_compare(JVERSION, '3.0', 'gt')) { JHtml::_('jquery.framework'); } else { $JSs[] = 'common/js/jquery/jquery.min.js'; $JSs[] = 'common/js/jquery/jquery-migrate-1.2.1.min.js'; } $JSs[] = 'common/js/jquery/namespace.js'; $CSSs[] = 'backend/css/eventgallery.css'; $joomlaVersion = new JVersion(); if (!$joomlaVersion->isCompatible('3.0')) { $CSSs[] = 'backend/css/legacy.css'; } $JSs = array_merge($JSs, array()); foreach ($CSSs as $css) { $script = JURI::root() . 'media/com_eventgallery/' . $css . '?v=' . EVENTGALLERY_VERSION; $document->addStyleSheet($script); } foreach ($JSs as $js) { $script = JURI::root() . 'media/com_eventgallery/' . $js . '?v=' . EVENTGALLERY_VERSION; $document->addScript($script); } }
public function getInput() { EventgalleryHelpersBackendmedialoader::load(); $name = (string) $this->element['name']; $inputtype = (string) $this->element['inputtype']; $class = $this->element['class'] ? ' class=" lc_' . $name . ' ' . (string) $this->element['class'] . '"' : ' class="lc_' . $name . '" '; $rows = $this->element['rows'] ? $this->element['rows'] : 4; $required = $this->required ? ' required="required" aria-required="true"' : ''; $langs = JFactory::getLanguage()->getKnownLanguages(); $defaultLanguageTag = JComponentHelper::getParams('com_languages')->get('site'); $defaultLanguage = $langs[$defaultLanguageTag]; if ($defaultLanguage != null) { unset($langs[$defaultLanguageTag]); $langs = array_merge(array($defaultLanguageTag => $defaultLanguage), $langs); } $result = ""; $lt = json_decode($this->value); if ($lt == null) { $lt = new stdClass(); // added fallback logic in case the current value is not in JSON format // this might be because in older versions there where no multilanguage fields. if (!empty($this->value) && json_last_error() == JSON_ERROR_SYNTAX) { foreach ($langs as $tag => $lang) { $lt->{$tag} = $this->value; } } } foreach ($langs as $tag => $lang) { $defaultLangMarker = $tag == $defaultLanguageTag ? " *" : ""; $result .= '<div class="input-prepend" style="display:block; margin-bottom:10px;">'; $result .= '<span class="add-on">' . $tag . $defaultLangMarker . '</span>'; $value = htmlspecialchars(isset($lt->{$tag}) === true ? $lt->{$tag} : '', ENT_COMPAT, 'UTF-8'); if ($inputtype == 'textarea') { $result .= '<textarea data-tag="' . $tag . '" rows="' . $rows . '" type="text" ' . $class . '>' . $value . '</textarea>'; } else { $result .= '<input data-tag="' . $tag . '" type="text" value="' . $value . '" ' . $class . '>'; } $result .= '</div>'; } $hiddenField = '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $required . '/>'; // Initialize JavaScript field attributes. $script = '<script type="text/javascript">'; // the script searches all the lc text fields and creates a json string for the hidden input field. $script .= ' eventgallery.jQuery(".lc_' . $name . '").blur(function() { var data = {}; eventgallery.jQuery(".lc_' . $name . '").each(function(){ data[eventgallery.jQuery(this).data("tag")] = this.value; }); document.getElementById("' . $this->id . '").value = JSON.encode(data); }); '; $script .= '</script>'; return $result . $hiddenField . $script; }
?> </div> <?php } elseif (EVENTGALLERY_EXTENDED && version_compare(JVERSION, '2.5.999', 'lt') && !EventgalleryLibraryHelperCheckupdateplugin::isUpdatePluginEnabled()) { ?> <div class="alert alert-warning"> <?php echo JText::_('COM_EVENTGALLERY_ERR_NOPLUGINNOUPDATES'); ?> </div> <?php } } if (!JFactory::getUser()->authorise('core.manage', 'com_eventgallery')) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } JLoader::register('JHtmlEventgalleryBatch', JPATH_ADMINISTRATOR . '/components/com_eventgallery/helpers/html/eventgallerybatch.php'); // Load necessary media files EventgalleryHelpersBackendmedialoader::load(); $version = new JVersion(); if (!$version->isCompatible('3.0')) { require_once JPATH_COMPONENT . '/helpers/legacy_layout.php'; require_once JPATH_COMPONENT . '/helpers/legacy_base.php'; require_once JPATH_COMPONENT . '/helpers/legacy_file.php'; require_once JPATH_COMPONENT . '/helpers/legacy_sidebar.php'; } //JObserverMapper::addObserverClassToClass('JTableObserverTags', 'TableEvent', array('typeAlias' => 'com_eventgallery.event')); // Execute the task. $controller = JControllerLegacy::getInstance('Eventgallery'); $controller->execute(JFactory::getApplication()->input->get('task')); $controller->redirect();
/** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ protected function getInput() { // Load necessary media files EventgalleryHelpersBackendmedialoader::load(); $allowEdit = (string) $this->element['edit'] == 'true' ? true : false; $allowClear = (string) $this->element['clear'] != 'false' ? true : false; // Load language JFactory::getLanguage()->load('com_eventgallery', JPATH_ADMINISTRATOR); // Load the modal behavior script. JHtml::_('behavior.modal', 'a.modal'); // Build the script. $script = array(); // Select button script $script[] = ' function jSelectEvent_' . $this->id . '(id, title) {'; $script[] = ' document.getElementById("' . $this->id . '_id").value = id;'; $script[] = ' document.getElementById("' . $this->id . '_name").value = title;'; if ($allowEdit) { $script[] = ' eventgallery.jQuery("#' . $this->id . '_edit").removeClass("hidden");'; } if ($allowClear) { $script[] = ' eventgallery.jQuery("#' . $this->id . '_clear").removeClass("hidden");'; } $script[] = ' SqueezeBox.close();'; $script[] = ' }'; // Clear button script static $scriptClear; if ($allowClear && !$scriptClear) { $scriptClear = true; $script[] = ' function jClearEvent(id) {'; $script[] = ' document.getElementById(id + "_id").value = "";'; $script[] = ' document.getElementById(id + "_name").value = "' . htmlspecialchars(JText::_('COM_EVENTGALLERY_SELECT_AN_EVENT', true), ENT_COMPAT, 'UTF-8') . '";'; $script[] = ' eventgallery.jQuery("#" + id + "_clear").addClass("hidden");'; $script[] = ' if (document.getElementById("#" + id + "_edit")) {'; $script[] = ' eventgallery.jQuery("#" + id + "_edit").addClass("hidden");'; $script[] = ' }'; $script[] = ' return false;'; $script[] = ' }'; } // Add the script to the document head. JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); // Setup variables for display. $html = array(); $link = 'index.php?option=com_eventgallery&view=events&layout=modal&tmpl=component&function=jSelectEvent_' . $this->id; if (strlen($this->value) > 0) { /** * @var EventgalleryLibraryManagerFolder $folderMgr */ $folderMgr = EventgalleryLibraryManagerFolder::getInstance(); $folder = $folderMgr->getFolder($this->value); if (null == $folder) { JError::raiseWarning(500, JText::sprintf('COM_EVENTGALLERY_EVENT_NOT_FOUND', $this->value)); } else { $title = $folder->getDisplayName(); } } if (empty($title)) { $title = JText::_('COM_EVENTGALLERY_SELECT_AN_EVENT'); } $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); // The active event id field. if (strlen($this->value) == 0) { $value = ''; } else { $value = $this->value; } // The current event display field. $html[] = '<span class="input-append">'; $html[] = '<input type="text" class="input-medium" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="35" />'; $html[] = '<a class="modal btn hasTooltip" title="' . JText::_('COM_EVENTGALLERY_CHANGE_EVENT') . '" href="' . $link . '&' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-file"></i> ' . JText::_('JSELECT') . '</a>'; // Clear event button if ($allowClear) { $html[] = '<button id="' . $this->id . '_clear" class="btn' . ($value ? '' : ' hidden') . '" onclick="return jClearEvent(\'' . $this->id . '\')"><span class="icon-remove"></span> ' . JText::_('JCLEAR') . '</button>'; } $html[] = '</span>'; // class='required' for client side validation $class = ''; if ($this->required) { $class = ' class="required modal-value"'; } $html[] = '<input type="hidden" id="' . $this->id . '_id"' . $class . ' name="' . $this->name . '" value="' . $value . '" />'; return implode("\n", $html); }