protected function getInput() { $helper = new BTBgSlideShowHelper(); if ($helper->checkPhocaComponent()) { $db = JFactory::getDBO(); //build the list of categories $query = 'SELECT a.title AS text, a.id AS value, a.parent_id as parentid' . ' FROM #__phocagallery_categories AS a' . ' WHERE a.published = 1' . ' ORDER BY a.ordering'; $db->setQuery($query); $phocagallerys = $db->loadObjectList(); // TODO - check for other views than category edit $view = JRequest::getVar('view'); $catId = -1; if ($view == 'phocagalleryc') { $id = $this->form->getValue('id'); // id of current category if ((int) $id > 0) { $catId = $id; } } $tree = array(); $text = ''; if (method_exists('PhocaGalleryRenderAdmin', 'CategoryTreeOption')) { $tree = PhocaGalleryRenderAdmin::CategoryTreeOption($phocagallerys, $tree, 0, $text, $catId); } else { if (method_exists('PhocaGalleryCategory', 'CategoryTreeOption')) { $tree = PhocaGalleryCategory::CategoryTreeOption($phocagallerys, $tree, 0, $text, $catId); } else { $class = $this->element['class'] ? (string) $this->element['class'] : ''; return "<div class='{$class}'>" . JText::_('MOD_BTBGSLIDESHOW_PHOCA_ALERT') . "</div>"; } } array_unshift($tree, JHTML::_('select.option', '', '- ' . JText::_('MOD_BTBGSLIDESHOW_PHOCA_ALL_CATEGORIES') . ' -', 'value', 'text')); // Initialize JavaScript field attributes. $class = $this->element['class'] ? (string) $this->element['class'] : ''; $attr = ''; $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; $attr .= ' class="inputbox ' . $class . '"'; $document = JFactory::getDocument(); $document->addCustomTag('<script type="text/javascript"> function changeCatid() { var catid = document.getElementById(\'jform_catid\').value; var href = document.getElementById(\'pgselectytb\').href; href = href.substring(0, href.lastIndexOf("&")); href += \'&catid=\' + catid; document.getElementById(\'pgselectytb\').href = href; } </script>'); return JHTML::_('select.genericlist', $tree, $this->name, trim($attr), 'value', 'text', $this->value, $this->id); } else { $class = $this->element['class'] ? (string) $this->element['class'] : ''; return "<div class='{$class}'>" . JText::_('MOD_BTBGSLIDESHOW_PHOCA_ALERT') . "</div>"; } }
/** * Returns the HTML for a category select box form field. * * @access protected * @return object The category select box form field. * @since 2.0 */ function getInput() { require_once JPATH_ROOT . '/modules/mod_bt_backgroundslideshow/helpers/helper.php'; $helper = new BTBgSlideShowHelper(); if ($helper->checkJGalleryComponent()) { require_once JPATH_ADMINISTRATOR . '/components/com_joomgallery/includes/defines.php'; JLoader::register('JoomExtensions', JPATH_ADMINISTRATOR . '/components/' . _JOOM_OPTION . '/helpers/extensions.php'); JLoader::register('JoomHelper', JPATH_BASE . '/components/' . _JOOM_OPTION . '/helpers/helper.php'); JLoader::register('JoomConfig', JPATH_BASE . '/components/' . _JOOM_OPTION . '/helpers/config.php'); JLoader::register('JoomAmbit', JPATH_BASE . '/components/' . _JOOM_OPTION . '/helpers/ambit.php'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . _JOOM_OPTION . '/tables'); JHTML::addIncludePath(JPATH_BASE . '/components/' . _JOOM_OPTION . '/helpers/html'); $class = $this->element['class'] ? (string) $this->element['class'] : ''; if ($this->element['required'] && $this->element['required'] == true && strpos($class, 'required') === false) { if (!empty($class)) { $class .= ' '; } $class .= 'required'; } if ($this->element['validate'] && (string) $this->element['validate'] == 'joompositivenumeric') { $doc =& JFactory::getDocument(); // Add a validation script for form validation $js_validate = "\n window.addEvent('domready', function() {\n document.formvalidator.setHandler('joompositivenumeric', function(value) {\n regex=/^[1-9]+[0-9]*\$/;\n return regex.test(value);\n })\n });"; $doc->addScriptDeclaration($js_validate); // Element class needs attribute validate-... if (!empty($class)) { $class .= ' '; } $class .= 'validate-' . (string) $this->element['validate']; // Add some style to make the slect box red bordered when invalid $css = ' select.invalid { border: 1px solid red; }'; $doc->addStyleDeclaration($css); } $attr = ''; $attr .= !empty($class) ? ' class="' . $class . '"' : ''; $attr .= (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : ''; $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; $action = $this->element['action'] ? (string) $this->element['action'] : 'core.create'; $exclude = $this->element['exclude'] ? (int) $this->element['exclude'] : null; $task = $this->element['task'] ? (int) $this->element['task'] : null; $html = JHTML::_('joomselect.categorylist', $this->value, $this->name, $attr, $exclude, '- ', $task, $action, $this->id); return $html; } else { $class = $this->element['class'] ? (string) $this->element['class'] : ''; return "<div class='{$class}'>" . JText::_('MOD_BTBGSLIDESHOW_JOOMGALLERY_ALERT') . "</div>"; } }
BTImageHelper::resize($originalFile, $file, $thumbWidth, $thumbHeight, true, $params->get('jpeg_compression')); } } } $caption = $params->get('caption', 0); $showTitle = false; $showDesc = false; $showLink = false; switch ($caption) { case '1': $showTitle = true; break; case '2': $showTitle = true; $showLink = true; break; case '3': $showDesc = true; break; case '4': $showTitle = true; $showDesc = true; break; case '5': $showTitle = true; $showDesc = true; $showLink = true; break; } BTBgSlideShowHelper::fetchHead($params); require JModuleHelper::getLayoutPath('mod_bt_backgroundslideshow', $params->get('layout', 'default'));
protected function _build($moduleID, $name, $value) { /* @var JDocument $document */ $document = JFactory::getDocument(); $document->addStyleSheet(JURI::root() . "modules/mod_bt_backgroundslideshow/assets/css/btslideshow.css"); if (version_compare(JVERSION, '1.6.0', 'ge')) { $document->addScript(JURI::root() . "modules/mod_bt_backgroundslideshow/assets/js/btslideshow.min.js"); $document->addScript(JURI::root() . "modules/mod_bt_backgroundslideshow/assets/js/btbase64.min.js"); $document->addScriptDeclaration('jQuery(document).ready(function(){initGallery();})'); } else { $document->addScript(JURI::root() . "modules/mod_bt_backgroundslideshow/assets/js/btloader.min.js"); // Hack, replace mootools by newer foreach ($document->_scripts as $key => $tmp) { if (preg_match('#media/system/js/mootools.js#is', $key)) { unset($document->_scripts[$key]); } } $mootools = array(JURI::root() . "modules/mod_bt_backgroundslideshow/assets/js/mootools-core.js" => 'text/javascript', JURI::root() . "modules/mod_bt_backgroundslideshow/assets/js/mootools-more.js" => 'text/javascript'); $document->_scripts = $mootools + $document->_scripts; ?> <script> (function(){ var libs = [ '<?php echo JURI::root(); ?> modules/mod_bt_backgroundslideshow/assets/js/mootools-core.js', '<?php echo JURI::root(); ?> modules/mod_bt_backgroundslideshow/assets/js/mootools-more.js', '<?php echo JURI::root(); ?> modules/mod_bt_backgroundslideshow/assets/js/btslideshow.min.js', '<?php echo JURI::root(); ?> modules/mod_bt_backgroundslideshow/assets/js/btbase64.min.js', '<?php echo JURI::root(); ?> modules/mod_bt_backgroundslideshow/assets/squeezebox/squeezebox.min.js' ]; BT.Loader.js(libs, function(){ initGallery(); }); BT.Loader.css('<?php echo JURI::root(); ?> modules/mod_bt_backgroundslideshow/assets/squeezebox/assets/squeezebox.css'); window.addEvent('load', function() { document.combobox = null; var combobox = new JCombobox(); document.combobox = combobox; }); })(); </script> <?php } // Remove temp files $items = json_decode(base64_decode($value)); //check if 0 folder exists $saveDir = JPATH_SITE . '/modules/mod_bt_backgroundslideshow/images'; if ($moduleID != 0 && JFolder::exists($saveDir . '/0')) { JFolder::move($saveDir . '/0', $saveDir . '/' . $moduleID); } //load file if miss save $originalDir = $saveDir . '/' . $moduleID . '/original'; if (is_dir($originalDir)) { $open = opendir($originalDir); $arrFiles = array(); $filename = readdir($open); while ($filename !== false) { //check validated file if (filetype($originalDir . '/' . $filename) == "file") { $existed = false; if (count($items) > 0) { foreach ($items as $item) { if ($item->file == $filename) { $existed = true; break; } } } if (!$existed) { $objFile = new stdClass(); $objFile->file = $filename; $objFile->title = ''; $items[] = $objFile; } } $filename = readdir($open); } } $value = base64_encode(json_encode($items)); $html = ' <div id="btss-message" class="clearfix"></div> <ul id="btss-upload-list"></ul> <div id="btss-file-uploader"> <noscript> <p>' . JText::_('MOD_BTBGSLIDESHOW_NOTICE_JAVASCRIPT') . '</p> </noscript> </div> <input id="btss-gallery-hidden" type="hidden" name="' . $name . '" value="" /> <ul id="btss-gallery-container" class="clearfix"></ul> '; ?> <script type="text/javascript"> function openFrame(a){ var jQ = jQuery.noConflict(); if(jQ("#ifK2Articles").css('display') != 'none') return false; if(jQ(a).attr('rel') == 0){ jQ(a).html('Back'); jQ(a).attr('rel', 1); jQ("#sbox-window .adminform").hide(); jQ("#sbox-window").animate({height: 450}, 300); jQ("#ifArticles").show(); }else{ jQ(a).html('Select Article'); jQ(a).attr('rel', 0); jQ("#sbox-window .adminform").show(); jQ("#sbox-window").animate({height: 380}, 300); jQ("#ifArticles").hide(); } return false; } function jSelectArticle_jform_params_id(id, title, order){ var jQ = jQuery.noConflict(); jQ("#btss-article").html('Select Article'); jQ("#btss-article").attr('rel', 0); jQ("#ifArticles").hide(); jQ("#sbox-window").animate({height: 380}, 300); jQ("#sbox-window .adminform").show(); jQ.ajax({ type: "post", url: location.href, data: {action: "get_article",article_id : id}, success: function(response){ var data = jQ.parseJSON(response); if(data!= null && data.success){ jQ("#sbox-window .btss-title").val(title); jQ("#sbox-window .btss-link").val(data.link); jQ("#sbox-window .btss-desc").val(data.desc); }else{ jQ("#sbox-window .adminform").prepend( "<div style='color: red; font-size: 10px;'>Importing article is failed. Have some errors.</div>" ); } }, error: function(jqXHR, textStatus, errorThrown){ //alert('Sending ajax request is failed. Check ajax.php, please.') } }); } <?php require_once JPATH_ROOT . '/modules/mod_bt_backgroundslideshow/helpers/helper.php'; if (BTBgSlideShowHelper::checkK2Component()) { ?> function openK2Frame(a){ var jQ = jQuery.noConflict(); if(jQ("#ifArticles").css('display') != 'none') return false; if(jQ(a).attr('rel') == 0){ jQ(a).html('Back'); jQ(a).attr('rel', 1); jQ("#sbox-window .adminform").hide(); jQ("#sbox-window").animate({height: 450}, 300); jQ("#ifK2Articles").show(); }else{ jQ(a).html('Select K2 Article'); jQ(a).attr('rel', 0); jQ("#sbox-window .adminform").show(); jQ("#sbox-window").animate({height: 380}, 300); jQ("#ifK2Articles").hide(); } return false; } function jSelectItem(id, title, objectname){ var jQ = jQuery.noConflict(); jQ("#btss-k2article").html('Select K2 Article'); jQ("#btss-k2article").attr('rel', 0); jQ("#ifK2Articles").hide(); jQ("#sbox-window").animate({height: 350}, 300); jQ("#sbox-window .adminform").show(); jQ.ajax({ type: "post", url: location.href, data: {action: "get_article", article_id : id, k2 : 1}, success: function(response){ var data = jQ.parseJSON(response); if(data!= null && data.success){ jQ("#sbox-window .btss-title").val(title); jQ("#sbox-window .btss-link").val(data.link); jQ("#sbox-window .btss-desc").val(data.desc); }else{ jQ("#sbox-window .adminform").prepend( "<div style='color: red; font-size: 10px;'>Importing k2 article is failed. Have some errors.</div>" ); } }, error: function(jqXHR, textStatus, errorThrown){ //alert('Sending ajax request is failed. Check ajax.php, please.') } }); } <?php } ?> function initGallery(){ BTSlideshow = new BT.Slideshow({ liveUrl: '<?php echo JURI::root(); ?> ', encodedItems: '<?php echo $value; ?> ', moduleID: '<?php echo $moduleID; ?> ', galleryContainer: 'btss-gallery-container', dialogTemplate: '<div style="margin: 10px 0px 10px 10px;" class="button2-left">'+ ' <div class="blank">'+ ' <a id="btss-article" onclick="openFrame(this);" title="Import from article" class="btn btn-small" rel="0">Select Article</a>' + ' </div>'+ '</div>'+ <?php if (BTBgSlideShowHelper::checkK2Component()) { ?> '<div style="margin: 10px 0px 10px 10px;" class="button2-left">'+ ' <div class="blank">'+ ' <a id="btss-k2article" onclick="openK2Frame(this);" title="Import from K2 article" class="btn btn-small" rel="0">Select K2 Article</a>' + ' </div>'+ '</div>'+ <?php } ?> '<fieldset style="clear: both;" class="adminform">' + '<legend><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_CAPTION'); ?> </legend>'+ '<ul class="adminformlist">' + '<li>' + '<label class="btss-title-lbl" class="hasTip" title="<?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_TITLE_DESC'); ?> " for="btss-title"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_TITLE_LABEL'); ?> </label>' + '<input class="btss-title" type="text" name="btss-title" size="90" />' + '</li>' + '<li>' + '<label class="btss-link-lbl" class="hasTip" title="<?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_LINK_DESC'); ?> " for="btss-link"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_LINK_LABEL'); ?> </label>' + '<input class="btss-link" type="text" name="btss-link" size="90" />' + '</li>' + '<li>' + '<label class="btss-target-lbl" class="hasTip" title="<?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_TARGET_DESC'); ?> " for="btss-target"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_TARGET_LABEL'); ?> </label>' + '<select class="btss-target" name="btss-link">' + ' <option value=""><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_TARGET_CURRENT'); ?> </option>' + ' <option value="_blank"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_TARGET_BLANK'); ?> </option>' + ' <option value="window"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_TARGET_WINDOW'); ?> </option>' + '</select>'+ '</li>' + '<li>' + '<label class="btss-desc-lbl" class="hasTip" title="<?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_DESCRIPTION_DESC'); ?> " for="btss-desc"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_DESCRIPTION_LABEL'); ?> </label>' + '<textarea style="width: 375px;" class="btss-desc" name="btss-desc" rows="2" cols="20"></textarea>' + '</li>' + '</ul>' + '</fieldset>' + '<fieldset style="clear: both;" class="adminform" > '+ '<legend title="<?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_URL_DESC'); ?> "><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_URL_LABEL'); ?> </legend>'+ '<ul class="embledvideo">' + '<li>'+ '<label class="btss-youid-lbl" class="hasTip" for="btss-youid"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_ID_LABEL'); ?> </label>'+ '<input class="btss-youid" type="text" name="btss-youid" size="40" title="<?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_YOUID_TITLE'); ?> " />' + '</li>'+ '</ul>'+ '<ul>'+ '<li>'+ '<label class="btss-quality-lbl" class="hasTip" for="btss-quality"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_QUANLITY_LABEL'); ?> </label>'+ '<select class="btss-quality" name="btss-quality" style="width:150px;">' + '<option value="global" selected><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_GLOBAL'); ?> </option>'+ '<option value="default"><?php echo JText::_('JDEFAULT'); ?> </option>'+ '<option value="small"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_240P'); ?> </option>'+ '<option value="medium"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_360P'); ?> </option>'+ '<option value="large"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_480P'); ?> </option>'+ '<option value="hd720"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_720P'); ?> </option>'+ '<option value="hd1080"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_1080P'); ?> </option>'+ '</select>' + '</li>'+ '</ul>'+ '<ul>'+ '<li>'+ '<label class="btss-autoplay-lbl" class="hasTip" for="btss-autoplay"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_AUTOPLAY_LABEL'); ?> </label>'+ '<select class="btss-autoplay" name="btss-auto" style="width:150px;">' + '<option value="-1" selected><?php echo JText::_('Use Global'); ?> </option>'+ '<option value="0"><?php echo JText::_('JNO'); ?> </option>'+ '<option value="1"><?php echo JText::_('JYES'); ?> </option>'+ '</select>'+ '</li>'+ '<li>' + '<label class="btss-volume-lbl" class="hasTip" for="btss-volume"><?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_VOLUME_LABEL'); ?> </label>' + '<input class="btss-volume" type="text" name="btss-volume" size="40" value="100" title="<?php echo JText::_('MOD_BTBGSLIDESHOW_FIELD_VOLUME_TITLE'); ?> " />' + '</li>' + '</ul>'+ '</fieldset>'+ '<div style="clear: both;">' + '<label> </label><button class="btss-dialog-ok btn btn-small" style="margin-left: 10px;"><?php echo JText::_('MOD_BTBGSLIDESHOW_BTN_OK'); ?> </button><button class="btss-dialog-cancel btn btn-small" style="margin-left: 10px;"><?php echo JText::_('MOD_BTBGSLIDESHOW_BTN_CANCEL'); ?> </button>'+ '</div>' + '<iframe style="display: none" id="ifArticles" height="400" frameborder="0" width="775" src="index.php?option=com_content&view=articles&layout=modal&tmpl=component&function=jSelectArticle_jform_params_id"></iframe>'+ '<iframe style="display: none" id="ifK2Articles" height="400" frameborder="0" width="775" src="index.php?option=com_k2&view=items&task=element&tmpl=component"></iframe>' }); }; </script> <?php return $html; }
/** * Get images from JoomGallery Component */ function getImagesFromJoomGallery(&$photos) { if (!is_array($photos)) { $photos = array(); } require_once JPATH_ROOT . '/modules/mod_bt_backgroundslideshow/helpers/helper.php'; $helper = new BTBgSlideShowHelper(); if (!$helper->checkJGalleryComponent()) { $this->result["success"] = false; $this->result["message"] = JText::_('MOD_BTBGSLIDESHOW_COM_JOOMGALLERY_NOT_EXIST'); } else { $rs = $helper->getJoomGalleryPhotos(JRequest::getString('jgallery_catid')); if (count($rs) > 0) { foreach ($rs as $photo) { $file = JURI::root() . "images/joomgallery/originals/" . $photo->cat_name . '/' . $photo->filename; $fileInfo = pathinfo($file); $hashedName = md5($this->moduleID . '-' . 'jgallery-' . $photo->cat_name . '-' . $fileInfo['filename']); if ($file && !JFile::exists($this->saveDir . "/tmp/manager/{$hashedName}.{$fileInfo["extension"]}") && !in_array($hashedName . '.' . $fileInfo["extension"], $this->items)) { $objFile = new stdClass(); $objFile->file = $file; $objFile->title = $photo->title; $objFile->source = 'jgallery-' . $photo->cat_name; $photos[] = $objFile; } } } } }