Example #1
0
 /**
  * Initializes the box by adding all necessary iamge group independent JavaScript and CSS files.
  * This is done only once per page load.
  *
  * @return  void
  * @since   3.0
  */
 protected function init()
 {
     JHtml::_('behavior.framework');
     $doc = JFactory::getDocument();
     $this->loadLanguage();
     // Add variables to forward color theme and some translations to Lytebox
     $script = array();
     $script[] = "    var lyteboxTheme         = '" . $this->params->get('cfg_theme') . "';";
     $script[] = "    var lyteboxCloseLabel    = '" . JText::_('PLG_JOOMGALLERY_JOOMLYTEBOX_CLOSE_LBL') . "';";
     $script[] = "    var lyteboxPrevLabel     = '" . JText::_('PLG_JOOMGALLERY_JOOMLYTEBOX_PREV_LBL') . "';";
     $script[] = "    var lyteboxNextLabel     = '" . JText::_('PLG_JOOMGALLERY_JOOMLYTEBOX_NEXT_LBL') . "';";
     $script[] = "    var lyteboxPlayLabel     = '" . JText::_('PLG_JOOMGALLERY_JOOMLYTEBOX_PLAY_LBL') . "';";
     $script[] = "    var lyteboxPauseLabel    = '" . JText::_('PLG_JOOMGALLERY_JOOMLYTEBOX_PAUSE_LBL') . "';";
     $script[] = "    var lyteboxPrintLabel    = '" . JText::_('PLG_JOOMGALLERY_JOOMLYTEBOX_PRINT_LBL') . "';";
     $script[] = "    var lyteboxImageLabel    = '" . JText::_('PLG_JOOMGALLERY_JOOMLYTEBOX_IMAGE_LBL') . "';";
     $script[] = "    var lyteboxPageLabel     = '" . JText::_('PLG_JOOMGALLERY_JOOMLYTEBOX_PAGE_LBL') . "';";
     $script[] = "    window.addEvent('domready', function() {";
     $script[] = "      var sstr = '" . strtolower($this->title) . "';";
     $script[] = "      \$\$('a[rel^=' + sstr + ']').each(function(el) {";
     $script[] = "        el.addClass(sstr);";
     $script[] = "      });";
     $script[] = "    });";
     $doc->addScriptDeclaration(implode("\n", $script));
     // Add lytebox css and js
     $doc->addStyleSheet(JURI::root() . 'media/plg_joomgallery_joomlytebox/lytebox.css');
     $doc->addScript(JURI::root() . 'media/plg_joomgallery_joomlytebox/lytebox.js');
     // Get JoomGallery configuration
     $this->_jg_config = JoomConfig::getInstance();
 }
Example #2
0
 /**
  * Constructor
  *
  * @access  protected
  * @return  void
  * @since   1.5.5
  */
 function __construct($config = array())
 {
     parent::__construct($config);
     $this->_ambit = JoomAmbit::getInstance();
     $this->_config = JoomConfig::getInstance();
     $this->_mainframe = JFactory::getApplication('administrator');
     $this->_user = JFactory::getUser();
     $this->_doc = JFactory::getDocument();
     $this->_doc->addStyleSheet($this->_ambit->getStyleSheet('admin.joomgallery.css'));
     JHtmlBehavior::framework();
     $this->_doc->addScript($this->_ambit->getScript('admin.js'));
     JoomHelper::addSubmenu();
     JHTML::addIncludePath(JPATH_COMPONENT . '/helpers/html');
     // Check for available updates
     if (!($checked = $this->_mainframe->getUserState('joom.update.checked'))) {
         $controller = JRequest::getCmd('controller');
         if ($this->_config->get('jg_checkupdate') && $controller && $controller != 'control') {
             $dated_extensions = JoomExtensions::checkUpdate();
             if (count($dated_extensions)) {
                 $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_ADMENU_SYSTEM_NOT_UPTODATE'), 'warning');
                 $this->_mainframe->setUserState('joom.update.checked', -1);
             } else {
                 $this->_mainframe->setUserState('joom.update.checked', 1);
             }
         }
     } else {
         if ($checked == -1) {
             $controller = JRequest::getCmd('controller');
             if ($controller && $controller != 'control') {
                 $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_ADMENU_SYSTEM_NOT_UPTODATE'), 'warning');
             }
         }
     }
 }
Example #3
0
 /**
  * Constructor
  *
  * @access  protected
  * @return  void
  * @since   1.5.5
  */
 function __construct($config = array())
 {
     parent::__construct($config);
     $this->_ambit = JoomAmbit::getInstance();
     $this->_config = JoomConfig::getInstance();
     $this->_mainframe = JFactory::getApplication('administrator');
     $this->_user = JFactory::getUser();
 }
Example #4
0
 /**
  * Method to get the field input markup
  *
  * @return  string  The field input markup
  * @since 2.0
  */
 protected function getInput()
 {
     // Initialize variables.
     $html = array();
     $groups = $this->getGroups();
     $excluded = $this->getExcluded();
     $link = 'index.php?option=com_users&view=users&layout=modal&tmpl=component&field=' . $this->id . (isset($groups) ? '&groups=' . base64_encode(json_encode($groups)) : '') . (isset($excluded) ? '&excluded=' . base64_encode(json_encode($excluded)) : '');
     // Initialize some field attributes.
     $attr = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     // Initialize JavaScript field attributes.
     $onchange = (string) $this->element['onchange'];
     // Load the modal behavior script.
     JHtml::_('behavior.modal', 'a.modal_' . $this->id);
     // Build the script.
     $script = array();
     $script[] = ' function jSelectUser_' . $this->id . '(id, title) {';
     $script[] = '   var old_id = document.getElementById("' . $this->id . '_id").value;';
     $script[] = '   if (old_id != id) {';
     $script[] = '     document.getElementById("' . $this->id . '_id").value = id;';
     $script[] = '     if (id == "") {';
     $script[] = '       document.getElementById("' . $this->id . '_name").value = "' . JText::_('COM_JOOMGALLERY_COMMON_NO_USER', true) . '";';
     $script[] = '     }';
     $script[] = '     else {';
     $script[] = '       document.getElementById("' . $this->id . '_name").value = title;';
     $script[] = '     }';
     $script[] = '     ' . $onchange;
     $script[] = '   }';
     $script[] = '   SqueezeBox.close();';
     $script[] = ' }';
     // Add the script to the document head.
     JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
     // Load the current user if available.
     $config = JoomConfig::getInstance();
     $type = $config->get('jg_realname') ? 'name' : 'username';
     $table = JTable::getInstance('user');
     if ($this->value) {
         $table->load($this->value);
     } else {
         $table->{$type} = JText::_('COM_JOOMGALLERY_COMMON_NO_USER');
     }
     // Create a dummy text field with the user name.
     $html[] = '<div class="fltlft">';
     $html[] = ' <input type="text" id="' . $this->id . '_name"' . ' value="' . htmlspecialchars($table->{$type}, ENT_COMPAT, 'UTF-8') . '"' . ' disabled="disabled"' . $attr . ' />';
     $html[] = '</div>';
     // Create the user select button.
     $html[] = '<div class="button2-left">';
     $html[] = '  <div class="blank">';
     if ($this->element['readonly'] != 'true') {
         $html[] = '   <a class="modal_' . $this->id . '" title="' . JText::_('JLIB_FORM_CHANGE_USER') . '"' . ' href="' . $link . '"' . ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}">';
         $html[] = '     ' . JText::_('JLIB_FORM_CHANGE_USER') . '</a>';
     }
     $html[] = '  </div>';
     $html[] = '</div>';
     // Create the real field, hidden, that stored the user id.
     $html[] = '<input type="hidden" id="' . $this->id . '_id" name="' . $this->name . '" value="' . (int) $this->value . '" />';
     return implode("\n", $html);
 }
Example #5
0
 /**
  * Constructor
  *
  * @access  protected
  * @return  void
  * @since   1.5.5
  */
 function __construct($config = array())
 {
     parent::__construct($config);
     $this->_ambit = JoomAmbit::getInstance();
     $this->_config = JoomConfig::getInstance();
     /*$this->_mainframe = JFactory::getApplication('site');
       $this->_user      = JFactory::getUser();*/
     $this->_db = JFactory::getDBO();
     // Uncomment following line to disable update check
     // $this->_config->set('jg_checkupdate', 0);
 }
Example #6
0
 /**
  * Constructor
  *
  * @return  void
  * @since   1.5.5
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     $this->_ambit = JoomAmbit::getInstance();
     $this->_config = JoomConfig::getInstance();
     $this->_mainframe = JFactory::getApplication('site');
     $this->_user = JFactory::getUser();
     $this->_doc = JFactory::getDocument();
     JHtml::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/helpers/html');
     // If we are just displaying an image we don't need anything else
     if (JRequest::getCmd('format') == 'raw' || JRequest::getCmd('format') == 'jpg' || JRequest::getCmd('format') == 'json' || JRequest::getCmd('format') == 'feed') {
         return;
     }
     // Add the CSS file generated from backend settings
     $this->_doc->addStyleSheet($this->_ambit->getStyleSheet($this->_config->getStyleSheetName()));
     // Add the main CSS file
     $this->_doc->addStyleSheet($this->_ambit->getStyleSheet('joomgallery.css'));
     // Add the RTL CSS file if an RTL language is used
     if (JFactory::getLanguage()->isRTL()) {
         $this->_doc->addStyleSheet($this->_ambit->getStyleSheet('joomgallery_rtl.css'));
     }
     // Add individual CSS file if it exists
     if (file_exists(JPATH_ROOT . '/media/joomgallery/css/joom_local.css')) {
         $this->_doc->addStyleSheet($this->_ambit->getStyleSheet('joom_local.css'));
     }
     $pngbehaviour = "  <!-- Do not edit IE conditional style below -->" . "\n" . "  <!--[if lte IE 6]>" . "\n" . "  <style type=\"text/css\">\n" . "    .pngfile {\n" . "      behavior:url('" . JURI::root() . "media/joomgallery/js/pngbehavior.htc') !important;\n" . "    }\n" . "  </style>\n" . "  <![endif]-->" . "\n" . "  <!-- End Conditional Style -->";
     $this->_doc->addCustomTag($pngbehaviour);
     // Set documents meta data taken from menu entry definition
     $params = $this->_mainframe->getParams();
     if ($params->get('menu-meta_description')) {
         $this->_doc->setDescription($params->get('menu-meta_description'));
     }
     if ($params->get('menu-meta_keywords')) {
         $this->_doc->setMetadata('keywords', $params->get('menu-meta_keywords'));
     }
     if ($params->get('robots')) {
         $this->_doc->setMetadata('robots', $params->get('robots'));
     }
     // Page title
     $pagetitle = JoomHelper::addSitenameToPagetitle($this->_doc->getTitle());
     $this->_doc->setTitle($pagetitle);
     // Check for alternative layout only if this is not the active menu item
     $active = $this->_mainframe->getMenu()->getActive();
     if (!$active || strpos($active->link, 'view=' . $this->getName()) === false) {
         // Get the default layout from the configuration
         if ($layout = $this->_config->get('jg_alternative_layout')) {
             $this->setLayout($layout);
         }
     }
 }
 /**
  * Initializes the box by adding all necessary iamge group independent JavaScript and CSS files.
  * This is done only once per page load.
  *
  * @return  void
  * @since   3.0
  */
 protected function init()
 {
     JHtml::_('jquery.framework');
     $doc = JFactory::getDocument();
     // Add Colorbox CSS and JS
     $colorboxstyle = (int) $this->params->get('cfg_style', '1');
     $doc->addStyleSheet(JURI::root() . 'media/plg_joomcolorbox/style' . $colorboxstyle . '/colorbox.css');
     $doc->addScript(JURI::root() . 'media/plg_joomcolorbox/jquery.colorbox-min.js');
     // Get JoomGallery configuration
     $this->_jg_config = JoomConfig::getInstance();
     $this->loadLanguage();
     $script = array();
     $script[] = "    var joomcolorbox_onkeydownsave = null;";
     $script[] = "    var style                      = " . $colorboxstyle . ";";
     $script[] = "    var joomcolorbox_resizeJsImage = " . $this->_jg_config->get('jg_resize_js_image') . ";";
     $script[] = "    var joomcolorbox_image         = '" . JText::_('PLG_JOOMGALLERY_JOOMCOLORBOX_POPUP_IMAGE', true) . "';";
     $script[] = "    var joomcolorbox_of            = '" . JText::_('PLG_JOOMGALLERY_JOOMCOLORBOX_POPUP_OF', true) . "';";
     $script[] = "    var joomcolorbox_close         = '" . JText::_('PLG_JOOMGALLERY_JOOMCOLORBOX_POPUP_CLOSE', true) . "';";
     $script[] = "    var joomcolorbox_prev          = '" . JText::_('PLG_JOOMGALLERY_JOOMCOLORBOX_POPUP_PREVIOUS', true) . "';";
     $script[] = "    var joomcolorbox_next          = '" . JText::_('PLG_JOOMGALLERY_JOOMCOLORBOX_POPUP_NEXT', true) . "';";
     $script[] = "    var joomcolorbox_startsld      = '" . JText::_('PLG_JOOMGALLERY_JOOMCOLORBOX_POPUP_STARTSLD', true) . "';";
     $script[] = "    var joomcolorbox_stopsld       = '" . JText::_('PLG_JOOMGALLERY_JOOMCOLORBOX_POPUP_STOPSLD', true) . "';";
     $script[] = "    jQuery(document).bind('cbox_complete', function(){";
     $script[] = "      if(jQuery('#cboxTitle').height() > 0 && (style == 1 || style == 4 || style == 5)){";
     $script[] = "        jQuery('#cboxTitle').hide();";
     $script[] = "        jQuery('#cboxTitleLong').remove();";
     $script[] = "        jQuery('<div id=\"cboxTitleLong\">' + jQuery('#cboxTitle').html() + '</div>').insertAfter('.cboxPhoto');";
     $script[] = "        jQuery.fn.colorbox.resize();";
     $script[] = "      }";
     $script[] = "    });";
     $script[] = "    jQuery(document).bind('cbox_open', function(){";
     $script[] = "      joomcolorbox_onkeydownsave = document.onkeydown;";
     $script[] = "      document.onkeydown         = null;";
     $script[] = "    });";
     $script[] = "    jQuery(document).bind('cbox_closed', function(){";
     $script[] = "      document.onkeydown = joomcolorbox_onkeydownsave;";
     $script[] = "    });";
     $script[] = "    jQuery(document).ready(function(){";
     $script[] = "      var sstr = 'colorbox';";
     $script[] = "      jQuery('a[rel^=' + sstr + ']').each(function(){";
     $script[] = "        this.rel = this.rel.substr(sstr.length + 1 );";
     $script[] = "        jQuery(this).addClass(sstr + '-' + this.rel);";
     $script[] = "      });";
     $script[] = "    });";
     $doc->addScriptDeclaration(implode("\n", $script));
 }
Example #8
0
 /**
  * Attempts to determine if ImageMagick is configured, and if so,
  * what version is installed
  *
  * @return  string  The result of request
  * @since   1.0.0
  */
 public function getIMVersion()
 {
     $config = JoomConfig::getInstance();
     $status = null;
     $output = array();
     if (!empty($config->jg_impath)) {
         $execstring = $config->get('jg_impath') . 'convert -version';
     } else {
         $execstring = 'convert -version';
     }
     @exec($execstring, $output, $status);
     if (count($output) == 0) {
         return 0;
     } else {
         return $output[0];
     }
 }
Example #9
0
 /**
  * Constructor
  *
  * @return  void
  * @since   1.5.5
  */
 public function __construct()
 {
     parent::__construct();
     $config = JoomConfig::getInstance();
     $this->realname = $config->get('jg_realname') ? true : false;
     $this->globalfrom = $config->get('jg_msg_global_from') ? true : false;
     // Predefined message send modes
     $this->addMode(array('name' => 'upload', 'recipients' => explode(',', $config->get('jg_msg_upload_recipients')), 'type' => $config->get('jg_msg_upload_type')));
     $this->addMode(array('name' => 'download', 'recipients' => explode(',', $config->get('jg_msg_download_recipients')), 'type' => $config->get('jg_msg_download_type')));
     $this->addMode(array('name' => 'zipdownload', 'recipients' => explode(',', $config->get('jg_msg_download_recipients')), 'type' => $config->get('jg_msg_download_type')));
     $this->addMode(array('name' => 'comment', 'recipients' => explode(',', $config->get('jg_msg_comment_recipients')), 'type' => $config->get('jg_msg_comment_type')));
     $this->addMode(array('name' => 'nametag', 'recipients' => explode(',', $config->get('jg_msg_nametag_recipients')), 'type' => $config->get('jg_msg_nametag_type')));
     $this->addMode(array('name' => 'report', 'recipients' => explode(',', $config->get('jg_msg_report_recipients')), 'type' => $config->get('jg_msg_report_type')));
     $this->_modes['send2friend']['recipients'] = array();
     $this->_modes['send2friend']['type'] = 1;
     $this->_modes['rejectimg']['recipients'] = array();
     $this->_modes['rejectimg']['type'] = $config->get('jg_msg_rejectimg_type');
     $this->_modes['default']['recipients'] = array();
     $this->_modes['default']['type'] = 2;
 }
Example #10
0
 /**
  * Handles results of the java upload
  *
  * @return  void
  * @since   1.5.7
  */
 public function concludejavaupload()
 {
     $this->_mainframe = JFactory::getApplication();
     $this->_config = JoomConfig::getInstance();
     // Send a message if setted in configuration manager
     if ($this->_config->get('jg_msg_upload_type') != 0) {
         require_once JPATH_COMPONENT . '/helpers/messenger.php';
         $this->_user =& JFactory::getUser();
         $counter = $this->_mainframe->getUserState('joom.upload.java.counter', 0);
         $messenger = new JoomMessenger();
         $message = array('from' => $this->_user->get('id'), 'subject' => JText::_('COM_JOOMGALLERY_MESSAGE_NEW_IMAGES_SUBMITTED_SUBJECT'), 'body' => JText::sprintf('COM_JOOMGALLERY_MESSAGE_NEW_IMAGES_SUBMITTED_BODY', $this->_config->get('jg_realname') ? $this->_user->get('name') : $this->_user->get('username'), $counter), 'mode' => 'upload');
         $messenger->send($message);
     }
     $this->_mainframe->setUserState('joom.upload.java.counter', 0);
     $msg = JText::_('COM_JOOMGALLERY_UPLOAD_MSG_SUCCESSFULL');
     // Set a redirect according to the correspondent setting in configuration manager
     $model = $this->getModel('upload');
     $url = $model->getRedirectUrlAfterUpload('java', 'java');
     if (!empty($url)) {
         $this->setRedirect($url, $msg);
     }
 }
Example #11
0
 /**
  * Returns the HTML output of a tooltip if showing tooltips is enabled
  *
  * @param   string  $text       The text of the tooltip
  * @param   string  $title      The title of the tooltip
  * @param   boolean $addclass   True, if the class attribute shall be added and false if it's already there
  * @param   boolean $translate  True, if the text and the title shall be translated
  * @param   string  $class      The name of the class used by Mootools to detect the tooltips
  * @return  string  The HTML output created
  * @since   1.5.5
  */
 public static function tip($text = 'Tooltip', $title = null, $addclass = false, $translate = true, $class = 'hasHint')
 {
     $config = JoomConfig::getInstance();
     $html = '';
     if ($config->get('jg_tooltips')) {
         static $loaded = false;
         if (!$loaded) {
             $params = array();
             if ($config->get('jg_tooltips') == 2) {
                 $params['template'] = '<div class="tooltip jg-tooltip-wrap" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>';
             }
             JHtml::_('bootstrap.tooltip', '.' . $class, $params);
             $loaded = true;
         }
         if ($addclass) {
             $html = ' class="' . $class . '" title="' . JHtml::tooltipText($title, $text, $translate, $translate) . '"';
         } else {
             $html = ' ' . $class . '" title="' . JHtml::tooltipText($title, $text, $translate, $translate);
         }
     }
     return $html;
 }
Example #12
0
 /**
  * Construct HTML list of users
  *
  * @param   string  $name       Name of the HTML select list to use
  * @param   array   $active     Array of selected users
  * @param   boolean $nouser     True, if 'No user' should be included on top of the list
  * @param   array   $additional Additional entries to add
  * @param   string  $javascript Additional code in the select list
  * @param   int     $multiple   Size of the box if it shall be a multiple select box, 0 otherwise
  * @param   mixed   $idtag      String to use as id tag for the select box
  * @return  string  The HTML output
  * @since   1.5.5
  */
 public static function users($name, $active, $nouser = false, $additional = array(), $javascript = null, $multiple = 6, $idtag = false)
 {
     static $users = null;
     if (is_null($users)) {
         $db = JFactory::getDbo();
         $config = JoomConfig::getInstance();
         $type = $config->get('jg_realname') ? 'name' : 'username';
         $query = $db->getQuery(true)->select('COUNT(id)')->from('#__users')->where('block = 0');
         $db->setQuery($query);
         self::$count = $db->loadResult();
         if (self::$count <= self::$max_count || !$multiple) {
             $users = array();
             $query->clear()->select('id AS value')->select($type . ' AS text')->from('#__users')->where('block = 0')->order($type . ' ASC');
             $db->setQuery($query);
             $users = $db->loadObjectList();
         }
     }
     if (self::$count > self::$max_count && $multiple) {
         return '<input type="text" name="' . $name . '" value="' . implode(',', $active) . '" class="inputbox"' . ($idtag ? ' id="' . $idtag . '"' : '') . '/>';
     }
     $options = array();
     foreach ($additional as $key => $value) {
         $options[] = JHtml::_('select.option', $key, $value);
     }
     if ($nouser) {
         if (JFactory::getApplication()->isSite()) {
             $options[] = JHtml::_('select.option', '0', JText::_('COM_JOOMGALLERY_DETAIL_NAMETAGS_SELECT_USER'));
         } else {
             $options[] = JHtml::_('select.option', '0', JText::_('COM_JOOMGALLERY_COMMON_NO_USER'));
         }
     }
     $options = array_merge($options, $users);
     $multiple_box = '';
     if ($multiple > 1) {
         $multiple_box = ' multiple="multiple" size="' . $multiple . '"';
     }
     if ($javascript) {
         $javascript = ' onchange="' . $javascript . '"';
     }
     return JHtml::_('select.genericlist', $options, $name, 'class="inputbox"' . $multiple_box . $javascript, 'value', 'text', $active, $idtag);
 }
Example #13
0
 /**
  * Creates the HTML output to display a minithumb for a category
  *
  * @param   object  $cat          Category object holding the category data
  * @param   string  $class        CSS class name for minithumb styling
  * @param   boolean $linkattribs  Link attributes for creating a link on the minithumb, if false no link will created
  * @param   boolean $showtip      Shows the thumbnail as tip on hoovering above minithumb
  * @return  string  The HTML output
  * @since   1.5.7
  */
 public static function minithumbcat($cat, $class = null, $linkattribs = null, $showtip = true)
 {
     $ambit = JoomAmbit::getInstance();
     $config = JoomConfig::getInstance();
     $html = '';
     $linked = $linkattribs ? true : false;
     if (isset($cat->thumbnail) && !empty($cat->thumbnail)) {
         $thumb = $ambit->getImg('thumb_path', $cat->thumbnail, null, $cat->cid);
         jimport('joomla.filesystem.file');
         if (JFile::exists($thumb)) {
             $isSite = JFactory::getApplication()->isSite();
             $imginfo = getimagesize($thumb);
             $url = $ambit->getImg('thumb_url', $cat->thumbnail, null, $cat->cid);
             // Clean category name
             $catname = str_replace('&nbsp;', '', $cat->name);
             $catname = trim(str_replace('&raquo;', '', $catname));
             if ($showtip) {
                 if ($isSite) {
                     $html .= '<span' . JHtml::_('joomgallery.tip', htmlspecialchars('<img src="' . $url . '" width="' . $imginfo[0] . '" height="' . $imginfo[1] . '" alt="' . $cat->name . '" />', ENT_QUOTES, 'UTF-8'), null, true, false) . '>';
                 } else {
                     $html .= '<span class="hasTooltip" title="' . htmlspecialchars('<img src="' . $url . '" width="' . $imginfo[0] . '" height="' . $imginfo[1] . '" alt="' . $catname . '" />', ENT_QUOTES, 'UTF-8') . '">';
                 }
             }
             if ($linked) {
                 if ($isSite) {
                     $html .= '<a href="' . JRoute::_('index.php?view=category&catid=' . $cat->cid) . '">';
                 } else {
                     $html .= '<a ' . $linkattribs . '">';
                 }
             }
             $html .= '<img src="' . $url . '" alt="' . htmlspecialchars($catname, ENT_QUOTES, 'UTF-8') . '"';
             if ($class !== null) {
                 $html .= ' class="' . $class . '"';
             }
             $html .= '>';
             if ($linked) {
                 $html .= '</a>';
             }
             if ($showtip) {
                 $html .= '</span>';
             }
         }
     }
     return $html;
 }
Example #14
0
    /**
     * Fetches an update zip file from JoomGallery server and extracts it
     *
     * @param   string  $url  The URL to the zip to fetch and extract
     * @return  void
     * @since   1.5.0
     */
    public static function autoUpdate($url)
    {
        $mainframe = JFactory::getApplication();
        if (!$url || !extension_loaded('curl')) {
            $mainframe->redirect('index.php?option=' . _JOOM_OPTION, JText::_('COM_JOOMGALLERY_ADMENU_MSG_ERROR_FETCHING_ZIP'), 'error');
        }
        $ambit = JoomAmbit::getInstance();
        // Create curl resource
        $ch = curl_init(strtolower($url));
        // Some settings for curl
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent: JoomGallery v3'));
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // Create the zip file
        jimport('joomla.filesystem.file');
        $config = JoomConfig::getInstance();
        $output = curl_exec($ch);
        JFile::write($ambit->get('temp_path') . 'update.zip', $output);
        // Close curl resource to free up system resources
        curl_close($ch);
        // Delete files and folders from previous updates
        $folder = $ambit->get('temp_path') . 'update';
        if (JFolder::exists($folder)) {
            JFolder::delete($folder);
        }
        // Extract the zip file
        jimport('joomla.filesystem.archive');
        if (!JArchive::extract($ambit->get('temp_path') . 'update.zip', $folder)) {
            $mainframe->redirect('index.php?option=' . _JOOM_OPTION, JText::_('Error extracting the zip'), 'error');
        }
        // Copy an index.html into the created folder if there isn't already one
        if (!JFile::exists($folder . '/index.html')) {
            $src = JPATH_ROOT . '/media/joomgallery/index.html';
            $dest = $folder . '/index.html';
            JFile::copy($src, $dest);
        }
        $mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_ADMENU_REDIRECT_NOTE'), 'notice');
        // Let's redirect to do the rest
        ?>
    <form action="index.php" method="post" name="JoomUpdateForm">
      <input type="hidden" name="option" value="<?php 
        echo _JOOM_OPTION;
        ?>
" />
      <input type="hidden" name="controller" value="control" />
      <input type="hidden" name="task" value="doinstallation" />
      <?php 
        echo JHtml::_('form.token');
        ?>
    </form>
    <script type="text/javascript">
      document.JoomUpdateForm.submit();
    </script>
<?php 
    }
Example #15
0
 /**
  * Removes one or more config rows
  *
  * @return  void
  * @since   2.0
  */
 public function remove()
 {
     $config = JoomConfig::getInstance('admin');
     $cid = JRequest::getVar('cid', array(), 'post', 'array');
     if (!count($cid)) {
         $this->setRedirect($this->_ambit->getRedirectUrl(), JText::_('COM_JOOMGALLERY_CONFIGS_NO_ROWS_SELECTED'), 'notice');
         return;
     }
     $count = 0;
     foreach ($cid as $config_id) {
         if ($config->delete($config_id)) {
             $count++;
         } else {
             JError::raiseWarning(500, $config->getError());
         }
     }
     if (!$count) {
         $msg = JText::_('COM_JOOMGALLERY_CONFIGS_MSG_ERROR_DELETING');
         $type = 'error';
     } else {
         $type = 'message';
         $msg = JText::plural('COM_JOOMGALLERY_CONFIGS_MSG_ROWS_DELETED', $count);
     }
     $this->setRedirect($this->_ambit->getRedirectUrl(), $msg, $type);
 }
 /**
  * Migrates configuration settings (where possible)
  *
  * @return  void
  * @since   1.0
  */
 protected function migrateConfig()
 {
     if (!$this->checkTime()) {
         $this->refresh('config');
     }
     $migrateable_settings = array('jg_use_real_paths', 'jg_dateformat', 'jg_checkupdate', 'jg_thumbcreation', 'jg_fastgd2thumbcreation', 'jg_impath', 'jg_resizetomaxwidth', 'jg_maxwidth', 'jg_picturequality', 'jg_useforresizedirection', 'jg_cropposition', 'jg_thumbwidth', 'jg_thumbheight', 'jg_thumbquality', 'jg_uploadorder', 'jg_useorigfilename', 'jg_filenamenumber', 'jg_delete_original', 'jg_wrongvaluecolor', 'jg_msg_upload_type', 'jg_msg_upload_recipients', 'jg_msg_download_type', 'jg_msg_zipdownload', 'jg_msg_download_recipients', 'jg_msg_comment_type', 'jg_msg_comment_recipients', 'jg_msg_comment_toowner', 'jg_msg_nametag_type', 'jg_msg_nametag_recipients', 'jg_msg_nametag_totaggeduser', 'jg_msg_nametag_toowner', 'jg_msg_report_type', 'jg_msg_report_recipients', 'jg_msg_report_toowner', 'jg_realname', 'jg_cooliris', 'jg_coolirislink', 'jg_contentpluginsenabled', 'jg_itemid', 'jg_userspace', 'jg_approve', 'jg_maxusercat', 'jg_maxuserimage', 'jg_maxfilesize', 'jg_usercatacc', 'jg_maxuploadfields', 'jg_useruploadsingle', 'jg_useruploadbatch', 'jg_useruploadjava', 'jg_useruseorigfilename', 'jg_useruploadnumber', 'jg_special_gif_upload', 'jg_delete_original_user', 'jg_newpiccopyright', 'jg_newpicnote', 'jg_redirect_after_upload', 'jg_downloadfile', 'jg_downloadwithwatermark', 'jg_showrating', 'jg_maxvoting', 'jg_ratingcalctype', 'jg_ratingdisplaytype', 'jg_ajaxrating', 'jg_onlyreguservotes AS jg_votingonlyonce', 'jg_showcomment', 'jg_anoncomment', 'jg_namedanoncomment', 'jg_approvecom', 'jg_bbcodesupport', 'jg_smiliesupport', 'jg_anismilie', 'jg_smiliescolor', 'jg_anchors', 'jg_tooltips', 'jg_dyncrop', 'jg_dyncropposition', 'jg_dyncropwidth', 'jg_dyncropheight', 'jg_dyncropbgcol', 'jg_hideemptycats', 'jg_imgalign', 'jg_firstorder', 'jg_secondorder', 'jg_thirdorder', 'jg_showgalleryhead', 'jg_showpathway', 'jg_completebreadcrumbs', 'jg_showallpics', 'jg_showallhits', 'jg_showbacklink', 'jg_suppresscredits', 'jg_showrmsmcats AS jg_showrestrictedcats', 'jg_rmsm AS jg_showrestrictedhint', 'jg_showallpicstoadmin', 'jg_showminithumbs', 'jg_openjs_padding', 'jg_openjs_background', 'jg_dhtml_border', 'jg_show_title_in_dhtml AS jg_show_title_in_popup', 'jg_show_description_in_dhtml AS jg_show_description_in_popup', 'jg_lightbox_speed', 'jg_lightbox_slide_all', 'jg_resize_js_image', 'jg_disable_rightclick_original', 'jg_showgallerysubhead', 'jg_showallcathead', 'jg_colcat', 'jg_catperpage', 'jg_ordercatbyalpha', 'jg_showgallerypagenav', 'jg_showcatcount', 'jg_showcatthumb', 'jg_showrandomcatthumb', 'jg_ctalign', 'jg_showtotalcatimages', 'jg_showtotalcathits', 'jg_showcatasnew', 'jg_catdaysnew', 'jg_showdescriptioningalleryview', 'jg_showsubsingalleryview', 'jg_category_rss', 'jg_showcathead', 'jg_usercatorder', 'jg_usercatorderlist', 'jg_showcatdescriptionincat', 'jg_showpagenav', 'jg_showpiccount', 'jg_perpage', 'jg_catthumbalign', 'jg_colnumb', 'jg_detailpic_open', 'jg_lightboxbigpic', 'jg_showtitle', 'jg_showpicasnew', 'jg_daysnew', 'jg_showhits', 'jg_showauthor', 'jg_showowner', 'jg_showcatcom', 'jg_showcatrate', 'jg_showcatdescription', 'jg_showcategoryfavourite', 'jg_showcategoryeditorlinks', 'jg_showsubcathead', 'jg_showsubcatcount', 'jg_colsubcat', 'jg_subperpage', 'jg_showpagenavsubs', 'jg_subcatthumbalign', 'jg_showsubthumbs', 'jg_showrandomsubthumb', 'jg_showdescriptionincategoryview', 'jg_ordersubcatbyalpha', 'jg_showtotalsubcatimages', 'jg_showtotalsubcathits', 'jg_showdetailpage', 'jg_disabledetailpage', 'jg_showdetailnumberofpics', 'jg_cursor_navigation', 'jg_disable_rightclick_detail', 'jg_showdetaileditorlinks', 'jg_showdetailtitle', 'jg_showdetail', 'jg_showdetailaccordion', 'jg_showdetaildescription', 'jg_showdetaildatum', 'jg_showdetailhits', 'jg_showdetailrating', 'jg_showdetailfilesize', 'jg_showdetailauthor', 'jg_showoriginalfilesize', 'jg_watermark', 'jg_watermarkpos', 'jg_bigpic', 'jg_bigpic_open', 'jg_bbcodelink', 'jg_showcommentsunreg', 'jg_showcommentsarea', 'jg_send2friend', 'jg_minis', 'jg_motionminis', 'jg_motionminiWidth', 'jg_motionminiHeight', 'jg_miniWidth', 'jg_miniHeight', 'jg_minisprop', 'jg_nameshields', 'jg_nameshields_others', 'jg_nameshields_unreg', 'jg_show_nameshields_unreg', 'jg_nameshields_height', 'jg_nameshields_width', 'jg_slideshow', 'jg_slideshow_timer', 'jg_slideshow_transition', 'jg_slideshow_transtime', 'jg_slideshow_maxdimauto', 'jg_slideshow_width', 'jg_slideshow_heigth', 'jg_slideshow_infopane', 'jg_slideshow_carousel', 'jg_slideshow_arrows', 'jg_slideshow_repeat', 'jg_showexifdata', 'jg_geotagging', 'jg_subifdtags', 'jg_ifdotags', 'jg_gpstags', 'jg_showiptcdata', 'jg_iptctags', 'jg_showtoplist', 'jg_toplist', 'jg_topthumbalign', 'jg_toptextalign', 'jg_toplistcols', 'jg_whereshowtoplist', 'jg_showrate', 'jg_showlatest', 'jg_showcom', 'jg_showthiscomment', 'jg_showmostviewed', 'jg_showtoplistfavourite', 'jg_showtoplisteditorlinks', 'jg_favourites', 'jg_favouritesshownotauth', 'jg_maxfavourites', 'jg_zipdownload', 'jg_usefavouritesforpubliczip', 'jg_usefavouritesforzip', 'jg_showfavouriteseditorlinks', 'jg_search', 'jg_searchcols', 'jg_searchthumbalign', 'jg_searchtextalign', 'jg_showsearchfavourite', 'jg_showsearcheditorlinks');
     $this->writeLogfile('Start migrating configuration');
     $query = $this->_db2->getQuery(true)->select($migrateable_settings)->from($this->table_config)->where('id = 1');
     $this->_db2->setQuery($query);
     if (!($settings = $this->runQuery('loadObject', $this->_db2))) {
         $this->setError('Old configuration settings not found');
         return;
     }
     $config = JoomConfig::getInstance('admin');
     if (!$config->save($settings, 1)) {
         $this->setError('Unable to store migrated settings');
         return;
     }
     $this->writeLogfile('Configuration successfully migrated');
     $query->clear()->select('COUNT(id)')->from(_JOOM_TABLE_CONFIG);
     $this->_db->setQuery($query);
     if ($this->runQuery('loadResult') > 1) {
         // Propagate global settings to all config rows
         $this->writeLogfile('Propagate migrated settings to all other config rows');
         $model = JModel::getInstance('Configs', 'JoomGalleryModel');
         if (!$model->propagateChanges($settings)) {
             $this->setError($model->getError());
             return;
         }
         $this->writeLogfile('Settings were successfully propagated');
     }
 }
Example #17
0
    /**
     * Returns the HTML for the FineUploader inclusion
     *
     * @return  string  The HTML for the FineUploader inclusion
     * @since   3.2
     */
    protected function getInput()
    {
        $app = JFactory::getApplication();
        $config = JoomConfig::getInstance();
        $url = JRoute::_('index.php?option=' . _JOOM_OPTION . '&controller=ajaxupload&task=upload', false);
        if ($app->isSite()) {
            $url = JRoute::_('index.php?option=' . _JOOM_OPTION . '&task=ajaxupload.upload', false);
        }
        $fileSizeLimit = $app->isSite() ? $config->get('jg_maxfilesize') : 0;
        $chunkSize = 0;
        $post_max_size = @ini_get('post_max_size');
        if (!empty($post_max_size)) {
            $post_max_size = JoomHelper::iniToBytes($post_max_size);
            $chunkSize = (int) min(500000, (int) (0.8 * $post_max_size));
        }
        $upload_max_filesize = @ini_get('upload_max_filesize');
        if (!empty($upload_max_filesize)) {
            $upload_max_filesize = JoomHelper::iniToBytes($upload_max_filesize);
            if ($fileSizeLimit <= 0 || $fileSizeLimit > $upload_max_filesize) {
                $fileSizeLimit = $upload_max_filesize;
            }
        }
        $editFilename = $app->isSite() ? $config->get('jg_useruseorigfilename') : $config->get('jg_useorigfilename');
        $prefix = $this->element['field_id_prefix'];
        $isMini = $this->element['mini'] && $this->element['mini'] != 'false';
        $redirect = $this->element['redirect'];
        $insertOptions = $this->element['insert_options'] && $this->element['insert_options'] != 'false';
        $formId = $this->element['form_id'];
        $catidField = $this->element['catid_field'] ? $this->element['catid_field'] : 'catid';
        if (!$formId) {
            throw new RuntimeException('Attribute \'form_id\' is required for the fineuploader field.');
        }
        ob_start();
        ?>
<div id="fine-uploader"></div>
<script type="text/javascript">
  jQuery(document).ready(function() {
    var uploader = new qq.FineUploader({
      element: jQuery('#fine-uploader')[0],
      request: {
        endpoint: '<?php 
        echo $url . '&format=raw';
        ?>
',
        paramsInBody: true
      },
      chunking: {
        enabled: true,
        partSize: <?php 
        echo $chunkSize;
        ?>
      },
      autoUpload: false,
      display: {
        fileSizeOnSubmit: true
      },
      text: {
        failUpload: '<?php 
        echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_UPLOAD_FAILED', true);
        ?>
',
        formatProgress: '{percent}% ' + '<?php 
        echo JText::_('COM_JOOMGALLERY_COMMON_OF', true);
        ?>
' +'  {total_size}',
        waitingForResponse: '<?php 
        echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_PROCESSING', true);
        ?>
'
      },
      failedUploadTextDisplay: {
        mode: 'custom'
      },
      dragAndDrop: {
        extraDropzones: []
      },
      fileTemplate: 'qq-template',
      classes: {
          success: 'alert-success',
          fail: 'alert-error',
          debugText: 'qq-upload-debug-text',
          thumb: 'qq-upload-thumb',
          options: 'qq-upload-options',
          note: 'qq-upload-note'
      },
      validation: {
        allowedExtensions: ['jpg', 'jpeg', 'jpe', 'gif', 'png'],
        acceptFiles: 'image/*',
        sizeLimit: <?php 
        echo $fileSizeLimit;
        ?>
      },
      messages: {
        typeError: '{file}: ' + '<?php 
        echo JText::_('COM_JOOMGALLERY_COMMON_ALERT_WRONG_EXTENSION', true);
        ?>
',
        sizeError: '{file}: ' + '<?php 
        echo JText::sprintf('COM_JOOMGALLERY_UPLOAD_OUTPUT_MAX_ALLOWED_FILESIZE', $fileSizeLimit, array('jsSafe' => true));
        ?>
',
        fileNameError: '{file}: ' + '<?php 
        echo JText::_('COM_JOOMGALLERY_COMMON_ALERT_WRONG_FILENAME', true);
        ?>
',
        fileNameDouble: '{file}: ' + '<?php 
        echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_ALERT_FILENAME_DOUBLE', true);
        ?>
',
        minSizeError: '{file}: ' + '<?php 
        echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_ALERT_FILE_TOO_SMALL', true);
        ?>
' + ' {minSizeLimit}.',
        emptyError: '{file} : '  + '<?php 
        echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_ALERT_FILE_EMPTY', true);
        ?>
',
        noFilesError: '<?php 
        echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_ALERT_NO_FILES', true);
        ?>
',
        onLeave: '<?php 
        echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_ALERT_ON_LEAVE', true);
        ?>
'
      },
      debug: true,
      maxConnections: 1,
      disableCancelForFormUploads: true,
      callbacks: {
        onComplete: function(id, fileName, response) {
          var item = this.getItemByFileId(id);
<?php 
        if ($isMini) {
            if ($insertOptions) {
                ?>
          // Display options if the upload was successful and if the image is published
          if(response.success && !document.id('published0').checked) {
            displayInsertOptions(this, item, fileName, response);
          }
<?php 
            } else {
                ?>
          // Reload the page if published images were uploaded (so the user can see them instantly on the page)
          if(response.success && !document.id('published0').checked) {
            window.parent.SqueezeBox.addEvent('onClose', function(){window.parent.location.reload();});
          }
<?php 
            }
        }
        ?>
          if(response.debug_output) {
            var element = item.getElementsByClassName("qq-upload-debug-text-selector")[0];
            element.innerHTML = response.debug_output;
          }
          if(this.requestParams.hasOwnProperty("filecounter")) {
            this.requestParams.filecounter =  this.requestParams.filecounter + 1;
            this.setParams(this.requestParams);
          }
          if(jQuery('#<?php 
        echo $prefix;
        ?>
generictitle').length > 0) {
            if(!jQuery('#<?php 
        echo $prefix;
        ?>
generictitle').prop('checked')) {
              jQuery('#<?php 
        echo $prefix;
        ?>
imgtitleid-' + id)<?php 
        echo $isMini ? '.remove();' : ".attr('readonly', 'true');";
        ?>
            }
          }
          <?php 
        if ($redirect) {
            ?>
          if(response.success) {
            uploader.fileCount--;
            var redirect = '<?php 
            echo $redirect;
            ?>
';
            if(uploader.fileCount == 0 && redirect != '') {
              // Redirect only if all file uploads were successful
              location.href = redirect;
            }
          }
          <?php 
        }
        ?>
        },
        onValidate: function(fileData) {
          if(!jg_filenamewithjs) {
            var searchwrongchars = /[^a-zA-Z0-9_-]/;
            if(searchwrongchars.test(fileData.name.substr(0, fileData.name.lastIndexOf('.')))) {
              this._itemError('fileNameError', fileData.name);
              return false;
            }
          }
          for (var i = 0; i < this._storedIds.length; i++) {
            var fileName = this.getName(this._storedIds[i]);
            if(fileName && fileName == fileData.name) {
              this._itemError('fileNameDouble', fileData.name);
              return false;
            }
          }
        },
        onSubmitted: function(id, fileName) {
          if(jQuery('#<?php 
        echo $prefix;
        ?>
generictitle').length > 0) {
            if(!jQuery('#<?php 
        echo $prefix;
        ?>
generictitle').prop('checked')) {
              var fileItemContainer = this.getItemByFileId(id);
              jQuery(fileItemContainer).find('.qq-upload-cancel').after('<input id="<?php 
        echo $prefix;
        ?>
imgtitleid-' + id +'" class="qq-edit-imgtitle qq-editing" tabindex="0" type="text" value="" placeholder="' + '<?php 
        echo JText::_('COM_JOOMGALLERY_COMMON_ENTER_IMAGE_TITLE', true);
        ?>
' + '" required aria-required="true">');
              jQuery('#<?php 
        echo $prefix;
        ?>
imgtitleid-' + id).change(function() {
                if(jQuery(this).val().trim() != '') {
                  jQuery(this).removeClass('invalid').attr('aria-invalid', 'false');
                }
              });
            }
          }
        },
        onUpload: function(id, fileName) {
          if(jQuery('#<?php 
        echo $prefix;
        ?>
generictitle').length > 0) {
            if(!jQuery('#<?php 
        echo $prefix;
        ?>
generictitle').prop('checked')) {
              this.requestParams.imgtitle = jQuery('#<?php 
        echo $prefix;
        ?>
imgtitleid-' + id).val();
              this.setParams(this.requestParams);
            }
          }
        }
      }
    });
    jQuery('#triggerClearUploadList').click(function() {
      uploader.reset();
      jQuery('#triggerClearUploadList').addClass('hidden');
    });
    jQuery('#triggerUpload').click(function() {
      Joomla.removeMessages();

      if(uploader._storedIds.length == 0) {
        alert('<?php 
        echo JText::_('COM_JOOMGALLERY_COMMON_ALERT_YOU_MUST_SELECT_ONE_IMAGE', true);
        ?>
');
        return false;
      }
      var form = document.getElementById('<?php 
        echo $formId;
        ?>
');
      if(!document.formvalidator.isValid(form)) {
        var msg = new Array();
        msg.push('<?php 
        echo JText::_('JGLOBAL_VALIDATION_FORM_FAILED', true);
        ?>
');
        if(form.imgtitle && form.imgtitle.hasClass('invalid')) {
            msg.push('<?php 
        echo JText::_("COM_JOOMGALLERY_COMMON_ALERT_IMAGE_MUST_HAVE_TITLE", true);
        ?>
');
        }
        if(form.catid.hasClass('invalid')) {
          msg.push('<?php 
        echo JText::_("COM_JOOMGALLERY_COMMON_ALERT_YOU_MUST_SELECT_CATEGORY", true);
        ?>
');
        }
        alert(msg.join('\n'));
        return false;
      }

      <?php 
        if ($isMini) {
            ?>
      // For new upload procedure scrolling is allowed for the first image
      jg_scrolled = false;
      <?php 
        }
        ?>

      if(jQuery('#<?php 
        echo $prefix;
        ?>
generictitle').length > 0) {
        if(!jQuery('#<?php 
        echo $prefix;
        ?>
generictitle').prop('checked')) {
          var valid = true;
          for(var i = 0; i < uploader._storedIds.length; i++) {
            if(jQuery('#<?php 
        echo $prefix;
        ?>
imgtitleid-' + uploader._storedIds[i]).val().trim() == '') {
              valid = false;
              jQuery('#<?php 
        echo $prefix;
        ?>
imgtitleid-' + uploader._storedIds[i]).addClass('invalid').attr('aria-invalid', 'true');
            }
          }
          if(!valid) {
            alert('<?php 
        echo JText::_("COM_JOOMGALLERY_COMMON_ALERT_IMAGE_MUST_HAVE_TITLE", true);
        ?>
');
            return valid;
          }
        }
      }

      // Prepare request parameters
      uploader.requestParams = new Object();
      uploader.requestParams.catid = jQuery('#<?php 
        echo $prefix . $catidField;
        ?>
').val();
      if(jQuery('#<?php 
        echo $prefix;
        ?>
imgtitle').length > 0) {
        if(jQuery('#<?php 
        echo $prefix;
        ?>
generictitle').prop('checked')) {
          uploader.requestParams.imgtitle = jQuery('#<?php 
        echo $prefix;
        ?>
imgtitle').val();
        }
      }
      if(jQuery('#<?php 
        echo $prefix;
        ?>
filecounter').length > 0) {
        var filecounter = parseInt(jQuery('#<?php 
        echo $prefix;
        ?>
filecounter').val());
        if(!isNaN(filecounter)) {
          uploader.requestParams.filecounter = filecounter;
        }
      }
      <?php 
        if (!$isMini) {
            ?>
      uploader.requestParams.imgtext = jQuery('#<?php 
            echo $prefix;
            ?>
imgtext').val();
      uploader.requestParams.debug = jQuery('#<?php 
            echo $prefix;
            ?>
debug').prop('checked') ? 1 : 0;
      <?php 
            if ($app->isSite()) {
                ?>
      uploader.requestParams.published = jQuery('#<?php 
                echo $prefix;
                ?>
published').val();
      <?php 
            } else {
                ?>
      uploader.requestParams.published = jQuery('#<?php 
                echo $prefix;
                ?>
published0').prop('checked') ? 0 : 1;
      uploader.requestParams.imgauthor = jQuery('#<?php 
                echo $prefix;
                ?>
imgauthor').val();
      uploader.requestParams.access = jQuery('#<?php 
                echo $prefix;
                ?>
access').val();
      <?php 
            }
        } else {
            ?>
      uploader.requestParams.published = jQuery('#<?php 
            echo $prefix;
            ?>
published0').prop('checked') ? 0 : 1;
      <?php 
        }
        ?>
      if(jQuery('#<?php 
        echo $prefix;
        ?>
original_delete').length > 0) {
        uploader.requestParams.original_delete = jQuery('#<?php 
        echo $prefix;
        ?>
original_delete').prop('checked') ? 1 : 0;
      }
      uploader.requestParams.create_special_gif = jQuery('#<?php 
        echo $prefix;
        ?>
create_special_gif').prop('checked') ? 1 : 0;
      uploader.setParams(uploader.requestParams);
      uploader.fileCount = uploader._storedIds.length;
      uploader.uploadStoredFiles();
      jQuery('#triggerClearUploadList').removeClass('hidden');
    });
    if(jQuery('#<?php 
        echo $prefix;
        ?>
generictitle').length > 0) {
      jQuery('#<?php 
        echo $prefix;
        ?>
generictitle').change(function() {
        if(jQuery(this).prop('checked')) {
          jQuery('#<?php 
        echo $prefix;
        ?>
imgtitle').addClass('required');
          jQuery('#<?php 
        echo $prefix;
        ?>
imgtitle').attr('aria-required', 'true').attr('required', 'required');
          jQuery('#<?php 
        echo $prefix;
        ?>
imgtitle-lbl').attr('aria-invalid', 'false');
          jQuery('#<?php 
        echo $prefix;
        ?>
imgtitle').parent().parent().show(750);
          if(jQuery('#<?php 
        echo $prefix;
        ?>
filecounter').length > 0 ) {
            jQuery('#<?php 
        echo $prefix;
        ?>
filecounter').val('1');
            jQuery('#<?php 
        echo $prefix;
        ?>
filecounter').parent().parent().show(750);
          }
          for(var i = 0; i < uploader._storedIds.length; i++) {
            jQuery('#<?php 
        echo $prefix;
        ?>
imgtitleid-' + uploader._storedIds[i]).remove();
          }
        }
        else {
          jQuery('#<?php 
        echo $prefix;
        ?>
imgtitle').val('');
          if(jQuery('#<?php 
        echo $prefix;
        ?>
filecounter').length > 0 ) {
            jQuery('#<?php 
        echo $prefix;
        ?>
filecounter').val('');
          }
          jQuery('#<?php 
        echo $prefix;
        ?>
imgtitle').removeClass('required');
          jQuery('#<?php 
        echo $prefix;
        ?>
imgtitle').removeAttr('aria-required').removeAttr('aria-invalid').removeAttr('required');
          jQuery('#<?php 
        echo $prefix;
        ?>
imgtitle-lbl').removeAttr('aria-invalid');
          jQuery('#<?php 
        echo $prefix;
        ?>
imgtitle').removeClass('invalid');
          jQuery('#<?php 
        echo $prefix;
        ?>
imgtitle-lbl').removeClass('invalid');
          jQuery('#<?php 
        echo $prefix;
        ?>
imgtitle').parent().parent().hide(750);
          if(jQuery('#<?php 
        echo $prefix;
        ?>
filecounter').length > 0 ) {
            jQuery('#<?php 
        echo $prefix;
        ?>
filecounter').parent().parent().hide(750);
          }
          for(var i = 0; i < uploader._storedIds.length; i++) {
            var fileItemContainer = uploader.getItemByFileId(uploader._storedIds[i]);
            jQuery(fileItemContainer).find('.qq-upload-cancel').after('<input id="<?php 
        echo $prefix;
        ?>
imgtitleid-' + uploader._storedIds[i] +'" class="qq-edit-imgtitle qq-editing" tabindex="0" type="text" value="" placeholder="' + '<?php 
        echo JText::_('COM_JOOMGALLERY_COMMON_ENTER_IMAGE_TITLE', true);
        ?>
' + '" required aria-required="true">');
            jQuery('#<?php 
        echo $prefix;
        ?>
imgtitleid-' + uploader._storedIds[i]).change(function() {
              if(jQuery(this).val().trim() != '') {
                jQuery(this).removeClass('invalid').attr('aria-invalid', 'false');
              }
            });
          }
        }
      });
    }
  });
</script>
<script type="text/template" id="qq-template">
  <div class="qq-uploader-selector qq-uploader span12">
    <div class="qq-upload-drop-area-selector qq-upload-drop-area span12" qq-hide-dropzone>
      <span><?php 
        echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_DRAGZONETEXT', true);
        ?>
</span>
    </div>
    <div class="qq-upload-button-selector qq-upload-button btn btn-large btn-success">
      <div><i class="icon-plus icon-plus"></i> <?php 
        echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_SELECT_IMAGES', true);
        ?>
</div>
    </div>
    <div class="small"><?php 
        echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_DRAGNDROPHINT');
        ?>
</div>
    <span class="qq-drop-processing-selector qq-drop-processing">
      <span><?php 
        echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_DROPPROCESSINGTEXT', true);
        ?>
</span>
      <span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span>
    </span>
    <ul class="qq-upload-list-selector qq-upload-list">
      <li class="alert">
        <div class="qq-progress-bar-container-selector">
          <div class="qq-progress-bar-selector qq-progress-bar"></div>
        </div>
        <span class="qq-upload-spinner-selector qq-upload-spinner"></span>
        <img class="qq-thumbnail-selector thumbnail" qq-max-size="50" qq-server-scale="<?php 
        echo !$isMini ? 'true' : 'false';
        ?>
">
        <?php 
        if ($editFilename) {
            echo '<span class="qq-edit-filename-icon-selector qq-edit-filename-icon"></span>';
        }
        ?>
        <span class="qq-upload-file-selector qq-upload-file"></span>
        <?php 
        if ($editFilename) {
            echo '<input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text">';
        }
        ?>
        <span class="qq-upload-size-selector qq-upload-size badge"></span>
        <a class="qq-upload-cancel-selector qq-upload-cancel btn btn-mini" href="#"><?php 
        echo JText::_('COM_JOOMGALLERY_COMMON_CANCEL', true);
        ?>
</a>
        <span class="qq-upload-status-text-selector qq-upload-status-text"></span>
        <span class="qq-upload-debug-text-selector qq-upload-debug-text"></span>
        <?php 
        if ($isMini) {
            ?>
        <div class="qq-upload-options-selector qq-upload-options form-horizontal hide"></div>
        <div class="qq-upload-note-selector qq-upload-note hide small center"><?php 
            echo JText::_('COM_JOOMGALLERY_MINI_AJAX_UPLOAD_NOTE', true);
            ?>
</div>
        <?php 
        }
        ?>
      </li>
    </ul>
  </div>
</script>
<?php 
        $html = ob_get_contents();
        ob_end_clean();
        return $html;
    }
Example #18
0
 /**
  * Constructor
  *
  * Presets all variables
  *
  * @return  void
  * @since   1.5.5
  */
 public function __construct()
 {
     $config = JoomConfig::getInstance();
     $this->_config = $config;
     // Fill all variables
     $this->icon_url = JURI::root() . 'media/joomgallery/images/';
     $this->css_url = JURI::root() . 'media/joomgallery/css/';
     $this->js_url = JURI::root() . 'media/joomgallery/js/';
     $this->_external['thumb'] = false;
     $this->thumb_url = JURI::root() . $config->get('jg_paththumbs');
     $this->thumb_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_paththumbs'));
     jimport('joomla.filesystem.folder');
     if (!JFolder::exists($this->thumb_path)) {
         $this->_external['thumb'] = true;
         $this->thumb_url = '';
         $this->thumb_path = JPath::clean($config->get('jg_paththumbs'));
     }
     $this->_external['img'] = false;
     $this->img_url = JURI::root() . $config->get('jg_pathimages');
     $this->img_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_pathimages'));
     if (!JFolder::exists($this->img_path)) {
         $this->_external['img'] = true;
         $this->img_url = '';
         $this->img_path = JPath::clean($config->get('jg_pathimages'));
     }
     $this->_external['orig'] = false;
     $this->orig_url = JURI::root() . $config->get('jg_pathoriginalimages');
     $this->orig_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_pathoriginalimages'));
     if (!JFolder::exists($this->orig_path)) {
         $this->_external['orig'] = true;
         $this->orig_url = '';
         $this->orig_path = JPath::clean($config->get('jg_pathoriginalimages'));
     }
     $this->temp_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_pathtemp'));
     if (!JFolder::exists($this->temp_path)) {
         $this->temp_path = JPath::clean($config->get('jg_pathtemp'));
     }
     $this->ftp_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_pathftpupload'));
     if (!JFolder::exists($this->ftp_path)) {
         $this->ftp_path = JPath::clean($config->get('jg_pathftpupload'));
     }
     $this->wtm_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_wmpath'));
     if (!JFolder::exists($this->wtm_path)) {
         $this->wtm_path = JPath::clean($config->get('jg_wmpath'));
     }
 }
Example #19
0
 /**
  * Method to get the field input markup
  *
  * @return  string  The field input markup
  * @since 2.0
  */
 protected function getInput()
 {
     // Initialize variables.
     $html = array();
     $groups = $this->getGroups();
     $excluded = $this->getExcluded();
     $link = 'index.php?option=com_users&amp;view=users&amp;layout=modal&amp;tmpl=component&amp;field=' . $this->id . (isset($groups) ? '&amp;groups=' . base64_encode(json_encode($groups)) : '') . (isset($excluded) ? '&amp;excluded=' . base64_encode(json_encode($excluded)) : '');
     $required = '';
     if ($this->required) {
         $required = ' required';
         if (!empty($this->class)) {
             $this->class .= ' ';
         }
         $this->class .= 'validate-SelectUser_' . $this->id;
     }
     $attr = !empty($this->class) ? ' class="' . $this->class . '"' : '';
     $attr .= !empty($this->size) ? ' size="' . $this->size . '"' : '';
     $attr .= $this->required ? ' required' : '';
     JHtml::_('bootstrap.tooltip');
     // Build the script.
     $script = array();
     if ($this->required) {
         $script[] = '  jQuery(document).ready(function() {';
         $script[] = '    document.formvalidator.setHandler("SelectUser_' . $this->id . '", function(value) {';
         $script[] = '      if (value == "" || value == "' . JText::_('COM_JOOMGALLERY_COMMON_NO_USER') . '") {';
         $script[] = '        return false;';
         $script[] = '      }';
         $script[] = '      return true;';
         $script[] = '    })';
         $script[] = '  });';
     }
     $script[] = '  function jSelectUser_' . $this->id . '(id, title) {';
     $script[] = '    var old_id = document.getElementById("' . $this->id . '").value;';
     $script[] = '    if (old_id != id) {';
     $script[] = '      document.getElementById("' . $this->id . '").value = id;';
     $script[] = '      if (id == "") {';
     $script[] = '        document.getElementById("' . $this->id . '_name").value = "' . JText::_('COM_JOOMGALLERY_COMMON_NO_USER', true) . '";';
     $script[] = '      }';
     $script[] = '      else {';
     $script[] = '        document.getElementById("' . $this->id . '_name").value = title;';
     $script[] = '      }';
     $script[] = '      ' . $this->onchange;
     if ($this->required) {
         $script[] = '      document.formvalidator.validate(document.getElementById("' . $this->id . '"));';
         $script[] = '      document.formvalidator.validate(document.getElementById("' . $this->id . '_name"));';
     }
     $script[] = '    }';
     $script[] = '    jQuery("#modalJoomuser").modal("hide");';
     $script[] = '  }';
     // Add the script to the document head.
     JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
     // Load the current user name if available.
     $config = JoomConfig::getInstance();
     $type = $config->get('jg_realname') ? 'name' : 'username';
     $table = JTable::getInstance('user');
     if ($this->value) {
         $table->load($this->value);
     } else {
         $table->{$type} = JText::_('COM_JOOMGALLERY_COMMON_NO_USER');
         $this->value = '';
     }
     // Create a dummy text field with the user name.
     $html[] = '<div class="input-append">';
     $html[] = '  <input type="text" id="' . $this->id . '_name"' . ' value="' . htmlspecialchars($table->{$type}, ENT_COMPAT, 'UTF-8') . '"' . ' readonly' . $attr . ' />';
     // Create the user select button.
     if ($this->readonly === false) {
         $html[] = '<a href="#modalJoomuser" class="btn hasTooltip" role="button" data-toggle="modal"' . ' title="' . JHtml::tooltipText('JLIB_FORM_CHANGE_USER') . '">' . '<i class="icon-user"></i></a>';
         $html[] = JHtmlBootstrap::renderModal('modalJoomuser', array('url' => $link . '&amp;' . JSession::getFormToken() . '=1"', 'title' => JText::_('JLIB_FORM_CHANGE_USER'), 'width' => '800px', 'height' => '300px', 'footer' => '<button class="btn" data-dismiss="modal" aria-hidden="true">' . JText::_("JLIB_HTML_BEHAVIOR_CLOSE") . '</button>'));
     }
     $html[] = '</div>';
     // Create the real field, hidden, that stores the user id.
     $html[] = '<input type="hidden" id="' . $this->id . '" name="' . $this->name . '" value="' . $this->value . '"' . $required . ' />';
     return implode("\n", $html);
 }
Example #20
0
 /**
  * Construct input field and button for selecting a user in a popup
  *
  * @param   string  $name       Name of the HTML select list to use
  * @param   array   $active     Array of selected users
  * @param   string  $javascript Additional code in the select list
  * @return  string  The HTML output
  * @since   2.1.2
  */
 public static function usersPopup($name, $active, $javascript = null)
 {
     // Use simple select box if there aren't too many users
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('COUNT(id)')->from('#__users')->where('block = 0');
     $db->setQuery($query);
     if ($db->loadResult() <= self::$max_count) {
         return JHtml::_('joomselect.users', $name, $active, false, array('' => JText::_('COM_JOOMGALLERY_COMMON_OPTION_SELECT_OWNER')), $javascript, false, false, $name);
     }
     $html = array();
     $link = JRoute::_('index.php?option=com_users&view=users&layout=modal&tmpl=component&field=' . $name);
     $active = (int) $active;
     $type = JoomConfig::getInstance()->get('jg_realname') ? 'name' : 'username';
     // Load the modal behavior script
     JHtml::_('behavior.modal', 'a.modal_' . $name);
     // Build the script
     $script = array();
     $script[] = '  function jSelectUser_' . $name . '(id, title) {';
     $script[] = '    var old_id = document.getElementById("' . $name . '_id").value;';
     $script[] = '    if(old_id != id) {';
     $script[] = '      document.getElementById("' . $name . '_id").value = id;';
     $script[] = '      document.getElementById("' . $name . '_name").value = title;';
     $script[] = '      ' . $javascript;
     $script[] = '    }';
     $script[] = '    SqueezeBox.close();';
     $script[] = '  }';
     // Add the script to the document head
     JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
     // Load the current user name if available
     $table = JTable::getInstance('user');
     if ($active) {
         $table->load($active);
     } else {
         $table->{$type} = JText::_('JLIB_FORM_SELECT_USER');
     }
     // Create a dummy text field with the user name
     $html[] = '<div class="fltlft">';
     $html[] = '  <input type="text" id="' . $name . '_name" value="' . htmlspecialchars($table->{$type}, ENT_COMPAT, 'UTF-8') . '" disabled="disabled" class="inputbox" />';
     $html[] = '</div>';
     // Create the user select button
     $html[] = '<div class="button2-left">';
     $html[] = '  <div class="blank">';
     $html[] = '    <a class="modal_' . $name . '" title="' . JText::_('JLIB_FORM_CHANGE_USER') . '" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 500}}">';
     $html[] = '      ' . JText::_('JLIB_FORM_CHANGE_USER') . '</a>';
     $html[] = '  </div>';
     $html[] = '</div>';
     // Create the real field, hidden, that stores the user id
     $html[] = '<input type="hidden" id="' . $name . '_id" name="' . $name . '" value="' . $active . '" />';
     return implode("\n", $html);
 }
Example #21
0
 /**
  * Constructor
  *
  * @return  void
  * @since   1.5.5
  */
 public function JoomInterface()
 {
     // Load JoomGallery defines
     require_once JPATH_ADMINISTRATOR . '/components/com_joomgallery/includes/defines.php';
     // Register some classes
     JLoader::register('JoomConfig', JPATH_ADMINISTRATOR . '/components/' . _JOOM_OPTION . '/helpers/config.php');
     JLoader::register('JoomHelper', JPATH_ROOT . '/components/' . _JOOM_OPTION . '/helpers/helper.php');
     JLoader::register('JoomAmbit', JPATH_ROOT . '/components/' . _JOOM_OPTION . '/helpers/ambit.php');
     // Add include path for JoomGallery tables
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . _JOOM_OPTION . '/tables');
     // Add include path for JoomGallery HTML functions
     JHtml::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . _JOOM_OPTION . '/helpers/html');
     $this->_mainframe = JFactory::getApplication();
     $this->_db = JFactory::getDBO();
     $this->_ambit = JoomAmbit::getInstance();
     $this->_jg_config = JoomConfig::getInstance();
     $this->_user = JFactory::getUser();
     // Include language for display
     $language = JFactory::getLanguage();
     $language->load(_JOOM_OPTION);
     // Load JoomGallery plugins
     JPluginHelper::importPlugin('joomgallery');
     // Set some default values for options given in global JG config (may be overridden)
     $this->_config['showhits'] = $this->_jg_config->get('jg_showhits');
     $this->_config['showdownloads'] = $this->_jg_config->get('jg_showdownloads');
     $this->_config['showpicasnew'] = $this->_jg_config->get('jg_showpicasnew');
     $this->_config['showtitle'] = $this->_jg_config->get('jg_showtitle');
     $this->_config['showauthor'] = $this->_jg_config->get('jg_showauthor');
     $this->_config['showrate'] = $this->_jg_config->get('jg_showcatrate');
     $this->_config['shownumcomments'] = $this->_jg_config->get('jg_showcatcom');
     $this->_config['showdescription'] = $this->_jg_config->get('jg_showcatdescription');
     $this->_config['openimage'] = $this->_jg_config->get('jg_detailpic_open');
     // Further defaults (not given by JG config)
     // - Category path links to category
     $this->_config['showcatlink'] = 1;
     // - Comma-separated list of categories to filter from (empty: all categories, default)
     $this->_config['categoryfilter'] = '';
     // - Display last comment (see Module JoomImages) not implemented yet!
     $this->_config['showlastcomment'] = 0;
     // - Make use of hidden images and images in hidden categories
     $this->_config['showhidden'] = 0;
     // Store the config for being able to reset it later on (if useful)
     $this->storeConfig();
 }
Example #22
0
    /**
     * Returns the HTML for the JUpload applet inclusion
     *
     * @return  string  The HTML for the JUpload applet inclusion
     * @since   2.1
     */
    protected function getInput()
    {
        $app = JFactory::getApplication();
        $config = JoomConfig::getInstance();
        // Check the php.ini setting 'session.cookie_httponly'
        // If set and = 1 then build the parameter 'readCookieFrom Navigator=false'
        // in Applet (new since V 4.2.1c)
        // and provide the cookie with sessionname=token in parameter 'specificHeaders'
        $cookieNavigator = true;
        $sesscook = @ini_get('session.cookie_httponly');
        if (!empty($sesscook) && $sesscook == 1) {
            $cookieNavigator = false;
            // Get the current session
            $currentSession = JSession::getInstance('', array());
            $sessionname = $currentSession->getName();
            // Function getToken() delivers wrong token, so get the right one
            // from $_COOKIE array (since PHP 4.1.0)
            $sessiontoken = $_COOKIE[$sessionname];
        }
        ob_start();
        ?>
<!-- --------------------------------------------------------------------------------------------------- -->
<!-- --------     A DUMMY APPLET, THAT ALLOWS THE NAVIGATOR TO CHECK THAT JAVA IS INSTALLED   ---------- -->
<!-- --------               If no Java: Java installation is prompted to the user.            ---------- -->
<!-- --------------------------------------------------------------------------------------------------- -->
<!--"CONVERTED_APPLET"-->
<!-- HTML CONVERTER -->
<script language="JavaScript" type="text/javascript"><!--
    var _info = navigator.userAgent;
    var _ns = false;
    var _ns6 = false;
    var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
//--></script>
    <comment>
        <script language="JavaScript" type="text/javascript"><!--
        var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0) || (_info.indexOf("AIX") > 0) || (_info.indexOf("OS/2") > 0) || (_info.indexOf("IRIX") > 0)));
        var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0));
//--></script>
    </comment>

<script language="JavaScript" type="text/javascript"><!--
    if (_ie == true) document.writeln('<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "0" HEIGHT = "0" NAME = "JUploadApplet"  codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=5,0,0,3"><noembed><xmp>');
    else if (_ns == true && _ns6 == false) document.writeln('<embed ' +
      'type="application/x-java-applet;version=1.5" \
            CODE = "wjhk.jupload2.EmptyApplet" \
            ARCHIVE = "<?php 
        echo JURI::root();
        ?>
media/joomgallery/java/wjhk.jupload.jar" \
            NAME = "JUploadApplet" \
            WIDTH = "0" \
            HEIGHT = "0" \
            type ="application/x-java-applet;version=1.6" \
            scriptable ="false" ' +
      'scriptable=false ' +
      'pluginspage="http://java.sun.com/products/plugin/index.html#download"><noembed><xmp>');
//--></script>
<applet  code = "wjhk.jupload2.EmptyApplet" ARCHIVE = "<?php 
        echo JURI::root();
        ?>
media/joomgallery/java/wjhk.jupload.jar" WIDTH = "0" HEIGHT = "0" NAME = "JUploadApplet"></xmp>
    <param name = CODE VALUE = "wjhk.jupload2.EmptyApplet" >
    <param name = ARCHIVE VALUE = "<?php 
        echo JURI::root();
        ?>
media/joomgallery/java/wjhk.jupload.jar" >
    <param name = NAME VALUE = "JUploadApplet" >
    <param name = "type" value="application/x-java-applet;version=1.5">
    <param name = "scriptable" value="false">
    <param name = "type" VALUE="application/x-java-applet;version=1.6">
    <param name = "scriptable" VALUE="false">
</xmp>
Java 1.5 or higher plugin required.
</applet>
</noembed>
</embed>
</object>

<applet name="JUpload" code="wjhk.jupload2.JUploadApplet" archive="<?php 
        echo JURI::root();
        ?>
media/joomgallery/java/wjhk.jupload.jar" width="100%" height="400" mayscript>
<?php 
        if ($app->isSite()) {
            ?>
  <param name="postURL" value="<?php 
            echo JURI::root();
            ?>
index.php?option=<?php 
            echo _JOOM_OPTION;
            ?>
&task=upload.upload&type=java">
<?php 
        } else {
            ?>
  <param name="postURL" value="<?php 
            echo JURI::root();
            ?>
administrator/index.php?option=<?php 
            echo _JOOM_OPTION;
            ?>
&controller=jupload&task=upload">
<?php 
        }
        ?>
  <param name="lookAndFeel" value="system">
  <param name="showLogWindow" value="false">
  <param name="showStatusBar" value="true">
<?php 
        if ($app->isSite()) {
            ?>
  <param name="formdata" value="JavaUploadForm">
<?php 
        } else {
            ?>
  <param name="formdata" value="adminForm">
<?php 
        }
        ?>
  <param name="debugLevel" value="0">
<?php 
        if ($app->isSite()) {
            ?>
  <param name="afterUploadURL" value="<?php 
            echo JRoute::_('index.php?task=upload.concludejavaupload');
            ?>
">
<?php 
        } else {
            ?>
  <param name="afterUploadURL" value="javascript:alert('<?php 
            echo JText::_('COM_JOOMGALLERY_UPLOAD_OUTPUT_UPLOAD_COMPLETE', true);
            ?>
');">
<?php 
        }
        ?>
  <param name="nbFilesPerRequest" value="1">
  <param name="stringUploadSuccess" value="JOOMGALLERYUPLOADSUCCESS">
  <param name="stringUploadError" value="JOOMGALLERYUPLOADERROR (.*)">
  <param name="uploadPolicy" value="PictureUploadPolicy">
  <param name="allowedFileExtensions" value="jpg/jpeg/jpe/png/gif">
  <param name="pictureTransmitMetadata" value="true">
<?php 
        if (($app->isSite() && $config->get('jg_delete_original_user') == 1 || $app->isAdmin() && $config->get('jg_delete_original') == 1) && $config->get('jg_resizetomaxwidth')) {
            ?>
  <param name="maxPicHeight" value="<?php 
            echo $config->get('jg_maxwidth');
            ?>
">
  <param name="maxPicWidth" value="<?php 
            echo $config->get('jg_maxwidth');
            ?>
">
  <param name="pictureCompressionQuality" value="<?php 
            echo $config->get('jg_picturequality') / 100;
            ?>
">
<?php 
        } else {
            ?>
  <param name="pictureCompressionQuality" value="0.8">
<?php 
        }
        ?>
  <param name="fileChooserImagePreview" value="false">
  <param name="fileChooserIconFromFileContent" value="-1">
<?php 
        if (!$cookieNavigator) {
            ?>
  <param name="readCookieFromNavigator" value="false">
  <param name="specificHeaders" value="Cookie: <?php 
            echo $sessionname . '=' . $sessiontoken;
            ?>
">
<?php 
        }
        ?>
  Java 1.5 or higher plugin required.
</applet>
<?php 
        $html = ob_get_contents();
        ob_end_clean();
        return $html;
    }
Example #23
0
 /**
  * Constructor
  *
  * @return  void
  * @since   1.5.0
  */
 public function __construct()
 {
     $this->_mainframe = JFactory::getApplication();
     $this->_db = JFactory::getDbo();
     $this->_config = JoomConfig::getInstance();
     $this->_ambit = JoomAmbit::getInstance();
     $this->logfilename = 'migration.' . $this->migration . '.php';
     require_once JPATH_COMPONENT . '/helpers/refresher.php';
     $this->refresher = new JoomRefresher(array('task' => 'migrate&migration=' . $this->migration));
     JLog::addLogger(array('text_file' => $this->logfilename, 'text_entry_format' => '{DATETIME}  {PRIORITY}  {MESSAGE}'), JLog::ALL, array('migration' . $this->migration));
     $this->newCatid = $this->_mainframe->getUserState('joom.migration.internal.new_catid', 1);
     $this->copyImages = $this->getStateFromRequest('copy_images', 'copy_images', $this->copyImages, 'boolean');
     $this->checkOwner = $this->getStateFromRequest('check_owner', 'check_owner', $this->checkOwner, 'boolean');
     $this->isCli = $this->getStateFromRequest('is_cli', 'is_cli', $this->isCli, 'boolean');
     // Connect to second database if necessary
     $db = $this->getStateFromRequest('db2', 'db', array(), 'array');
     if (JArrayHelper::getValue($db, 'enabled', false, 'boolean')) {
         $driver = JArrayHelper::getValue($db, 'db_type', 'mysqli', 'string');
         $host = JArrayHelper::getValue($db, 'db_host', 'localhost', 'string');
         $name = JArrayHelper::getValue($db, 'db_name', '', 'string');
         $user = JArrayHelper::getValue($db, 'db_user', '', 'string');
         $password = JArrayHelper::getValue($db, 'db_pass', '', 'string');
         $prefix = $this->getStateFromRequest('prefix', 'prefix', '', 'cmd');
         if (!$prefix) {
             $prefix = JArrayHelper::getValue($db, 'prefix', '', 'cmd');
             $this->setState('prefix', $prefix);
         }
         $options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $name, 'prefix' => $prefix);
         $this->_db2 = JDatabaseDriver::getInstance($options);
         $this->otherDatabase = true;
     } else {
         $this->_db2 = $this->_db;
     }
 }
Example #24
0
 /**
  * HTML view display method
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  * @since   1.5.5
  */
 public function display($tpl = null)
 {
     // Load language files of frontend for Exif and IPTC data
     $language = JFactory::getLanguage();
     $language->load(_JOOM_OPTION . '.exif', JPATH_SITE);
     $language->load(_JOOM_OPTION . '.iptc', JPATH_SITE);
     $display = true;
     if ($this->_config->isExtended()) {
         $config_id = JRequest::getInt('id');
         // Overwrite config object with specified one
         $this->_config = JoomConfig::getInstance($config_id);
         if (JRequest::getInt('group_id') || $config_id && $config_id != 1) {
             $display = false;
         }
     }
     // Check the installation of GD
     $gdver = $this->get('GDVersion');
     // Returns version, 0 if not installed, or -1 if appears
     // to be installed but not verified
     if ($gdver > 0) {
         $gdmsg = JText::sprintf('COM_JOOMGALLERY_CONFIG_GS_IP_GDLIB_INSTALLED', $gdver);
     } else {
         if ($gdver == -1) {
             $gdmsg = JText::_('COM_JOOMGALLERY_CONFIG_GS_IP_GDLIB_NO_VERSION');
         } else {
             $gdmsg = JText::_('COM_JOOMGALLERY_CONFIG_GS_IP_GDLIB_NOT_INSTALLED') . '<a href="http://www.php.net/gd" target="_blank">http://www.php.net/gd</a>' . JText::_('COM_JOOMGALLERY_GD_MORE_INFO');
         }
     }
     // Check the installation of ImageMagick
     // first check if exec() has been diabled in php.ini
     if ($this->get('DisabledExec')) {
         $immsg = JText::_('COM_JOOMGALLERY_CONFIG_GS_IP_IMAGIC_EXEC_DISABLED');
     } else {
         $imver = $this->get('IMVersion');
         // Returns version, 0 if not installed or path not properly configured
         if ($imver) {
             $immsg = JText::_('COM_JOOMGALLERY_CONFIG_GS_IP_IMAGIC_INSTALLED') . $imver;
             // Add the information that IM was detected automatically if path is empty
             if (!$this->_config->get('jg_impath')) {
                 $immsg .= JText::_('COM_JOOMGALLERY_CONFIG_GS_IP_IMAGIC_INSTALLED_AUTO');
             }
         } else {
             $immsg = JText::_('COM_JOOMGALLERY_CONFIG_GS_IP_IMAGIC_NOT_INSTALLED');
         }
     }
     // Check the installation of Exif
     $exifmsg = '';
     if (!extension_loaded('exif')) {
         $exifmsg = '<div style="color:#f00;font-weight:bold; text-align:center;">[' . JText::_('COM_JOOMGALLERY_CONFIG_DV_ED_NOT_INSTALLED') . ' ' . JText::_('COM_JOOMGALLERY_CONFIG_DV_ED_NO_OPTIONS') . ']</div>';
     } else {
         $exifmsg = '<div style="color:#080; text-align:center;">[' . JText::_('COM_JOOMGALLERY_CONFIG_DV_ED_INSTALLED') . ']</div>';
         if (!function_exists('exif_read_data')) {
             $exifmsg = '<div style="color:#f00;font-weight:bold; text-align:center;">[' . JText::_('COM_JOOMGALLERY_CONFIG_DV_ED_INSTALLED_BUT') . ' ' . JText::_('COM_JOOMGALLERY_CONFIG_DV_ED_NO_OPTIONS') . ']</div>';
         }
     }
     // Check pathes and watermark file
     $writeable = '<span style="color:#080;">' . JText::_('COM_JOOMGALLERY_CONFIG_GS_PD_DIRECTORY_WRITEABLE') . '</span>';
     $unwriteable = '<span style="color:#f00;">' . JText::_('COM_JOOMGALLERY_CONFIG_GS_PD_DIRECTORY_UNWRITEABLE') . '</span>';
     if (is_writeable($this->getPath('img'))) {
         $write_pathimages = $writeable;
     } else {
         $write_pathimages = $unwriteable;
     }
     if (is_writeable($this->getPath('orig'))) {
         $write_pathoriginalimages = $writeable;
     } else {
         $write_pathoriginalimages = $unwriteable;
     }
     if (is_writeable($this->getPath('thumb'))) {
         $write_paththumbs = $writeable;
     } else {
         $write_paththumbs = $unwriteable;
     }
     if (is_writeable($this->getPath('ftp'))) {
         $write_pathftpupload = $writeable;
     } else {
         $write_pathftpupload = $unwriteable;
     }
     if (is_writeable($this->getPath('temp'))) {
         $write_pathtemp = $writeable;
     } else {
         $write_pathtemp = $unwriteable;
     }
     if (is_writeable($this->getPath('wtm'))) {
         $write_pathwm = $writeable;
     } else {
         $write_pathwm = $unwriteable;
     }
     if (is_file($this->getPath('wtm') . '/' . $this->_config->get('jg_wmfile'))) {
         $wmfilemsg = '<span style="color:#080;">' . JText::_('COM_JOOMGALLERY_CONFIG_GS_PD_FILE_EXIST') . '</span>';
     } else {
         $wmfilemsg = '<span style="color:#f00;">' . JText::_('COM_JOOMGALLERY_CONFIG_GS_PD_FILE_NOT_EXIST') . '</span>';
     }
     // Check whether CSS file (joom_settings.css) is writeable
     if (is_writeable(JPATH_ROOT . '/media/joomgallery/css/' . $this->_config->getStyleSheetName())) {
         $cssfilemsg = '<div style="color:#080; text-align:center;">[' . JText::_('COM_JOOMGALLERY_CONFIG_GS_PD_CSS_CONFIGURATION_WRITEABLE') . ']</div>';
     } else {
         $cssfilemsg = '<div style="color:#f00;font-weight:bold; text-align:center;">[' . JText::_('COM_JOOMGALLERY_CONFIG_GS_PD_CSS_CONFIGURATION_NOT_WRITEABLE') . ' ' . JText::_('COM_JOOMGALLERY_COMMON_CHECK_PERMISSIONS') . ']</div>';
     }
     // Exif
     require_once JPATH_COMPONENT . '/includes/exifarray.php';
     $ifdotags = explode(',', $this->_config->get('jg_ifdotags'));
     $subifdtags = explode(',', $this->_config->get('jg_subifdtags'));
     $gpstags = explode(',', $this->_config->get('jg_gpstags'));
     $exif_definitions = array(1 => array('TAG' => 'IFD0', 'JG' => $ifdotags, 'NAME' => 'jg_ifdotags[]', 'HEAD' => JText::_('COM_JOOMGALLERY_IFD0TAGS')), 2 => array('TAG' => 'EXIF', 'JG' => $subifdtags, 'NAME' => 'jg_subifdtags[]', 'HEAD' => JText::_('COM_JOOMGALLERY_SUBIFDTAGS')), 3 => array('TAG' => 'GPS', 'JG' => $gpstags, 'NAME' => 'jg_gpstags[]', 'HEAD' => JText::_('COM_JOOMGALLERY_GPSTAGS')));
     // IPTC
     require_once JPATH_COMPONENT . '/includes/iptcarray.php';
     $iptctags = explode(',', $this->_config->get('jg_iptctags'));
     $iptc_definitions = array(1 => array('TAG' => 'IPTC', 'JG' => $iptctags, 'NAME' => 'jg_iptctags[]', 'HEAD' => JText::_('COM_JOOMGALLERY_IPTCTAGS')));
     // Include javascript for form validation, cleaning and submitting
     $this->_doc->addScript($this->_ambit->getScript('config.js'));
     JText::script('COM_JOOMGALLERY_CONFIG_GS_PD_ALERT_THUMBNAIL_PATH_SUPPORT');
     $this->assignRef('display', $display);
     $this->assignRef('cssfilemsg', $cssfilemsg);
     $this->assignRef('exifmsg', $exifmsg);
     $this->assignRef('gdmsg', $gdmsg);
     $this->assignRef('immsg', $immsg);
     $this->assignRef('write_pathimages', $write_pathimages);
     $this->assignRef('write_pathoriginalimages', $write_pathoriginalimages);
     $this->assignRef('write_paththumbs', $write_paththumbs);
     $this->assignRef('write_pathftpupload', $write_pathftpupload);
     $this->assignRef('write_pathtemp', $write_pathtemp);
     $this->assignRef('write_pathwm', $write_pathwm);
     $this->assignRef('wmfilemsg', $wmfilemsg);
     $this->assignRef('exif_definitions', $exif_definitions);
     $this->assignRef('exif_config_array', $exif_config_array);
     $this->assignRef('iptc_definitions', $iptc_definitions);
     $this->assignRef('iptc_config_array', $iptc_config_array);
     $this->addToolbar();
     if (!$this->_mainframe->input->getBool('hidemainmenu')) {
         $this->sidebar = JHtmlSidebar::render();
     }
     parent::display();
 }
Example #25
0
 /**
  * Propagates changes in settings to all config rows
  *
  * @param   array   Array of changed config settings
  * @param   int     ID of the initially changed config row
  * @param   boolean Determines whether all changes shall be propagated (true) or only the global ones (false)
  * @return  boolean True on success, false otherwise
  * @since   2.0
  */
 public function propagateChanges($data, $id = 1, $all = false)
 {
     // Sanitise variables
     $data = (array) $data;
     if (!$id) {
         $id = 1;
     }
     $global_settings = $this->_getGlobalSettings();
     // Unset fields which must not be changed
     foreach ($data as $key => $value) {
         if (strpos($key, 'jg_') !== 0 || !$all && !in_array($key, $global_settings)) {
             unset($data[$key]);
         }
     }
     if (!count($data)) {
         // Nothing to do
         return true;
     }
     // Get the IDs of all config rows except the initially changed one
     $query = $this->_db->getQuery(true)->select('id')->from(_JOOM_TABLE_CONFIG)->where('id != ' . $id);
     $this->_db->setQuery($query);
     try {
         $ids = $this->_db->loadColumn();
     } catch (DatabaseException $e) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if (!count($ids)) {
         // Nothing to do
         return true;
     }
     $config = JoomConfig::getInstance('admin');
     foreach ($ids as $config_id) {
         if (!$config->save($data, $config_id)) {
             $this->setError($config->getError());
             return false;
         }
     }
     return true;
 }
Example #26
0
 /**
  * Resize image with functions from gd/gd2/imagemagick
  *
  * Cropping function adapted from
  * 'Resize Image with Different Aspect Ratio'
  * Author: Nash
  * Website: http://nashruddin.com/Resize_Image_to_Different_Aspect_Ratio_on_the_fly
  *
  * @param   &string $debugoutput            debug information
  * @param   string  $src_file               Path to source file
  * @param   string  $dest_file              Path to destination file
  * @param   int     $useforresizedirection  Thumbnails only:
  *                                          Resize to width/height ratio or free setting
  * @param   int     $new_width              Width to resize
  * @param   int     $thumbheight            Height to resize
  * @param   int     $method                 1=gd1, 2=gd2, 3=im
  * @param   int     $dest_qual              $config->jg_thumbquality/jg_picturequality
  * @param   boolean $max_width              true=resize to maxwidth
  * @param   int     $cropposition           $config->jg_cropposition
  * @return  boolean True on success, false otherwise
  * @since   1.0.0
  */
 public static function resizeImage(&$debugoutput, $src_file, $dest_file, $useforresizedirection, $new_width, $thumbheight, $method, $dest_qual, $max_width = false, $cropposition)
 {
     $config = JoomConfig::getInstance();
     // Ensure that the pathes are valid and clean
     $src_file = JPath::clean($src_file);
     $dest_file = JPath::clean($dest_file);
     // Doing resize instead of thumbnail, copy original and remove it.
     $imginfo = getimagesize($src_file);
     if (!$imginfo) {
         $debugoutput .= JText::_('COM_JOOMGALLERY_UPLOAD_FILE_NOT_FOUND') . '<br />';
         return false;
     }
     // GD can only handle JPG & PNG images
     if ($imginfo[2] != IMAGETYPE_JPEG && $imginfo[2] != IMAGETYPE_PNG && $imginfo[2] != IMAGETYPE_GIF && ($method == 'gd1' || $method == 'gd2')) {
         $debugoutput .= JText::_('COM_JOOMGALLERY_UPLOAD_GD_ONLY_JPG_PNG') . '<br />';
         return false;
     }
     $imagetype = array(1 => 'GIF', 2 => 'JPG', 3 => 'PNG', 4 => 'SWF', 5 => 'PSD', 6 => 'BMP', 7 => 'TIFF', 8 => 'TIFF', 9 => 'JPC', 10 => 'JP2', 11 => 'JPX', 12 => 'JB2', 13 => 'SWC', 14 => 'IFF');
     $imginfo[2] = $imagetype[$imginfo[2]];
     // Height/width
     $srcWidth = $imginfo[0];
     $srcHeight = $imginfo[1];
     if ($max_width && $srcWidth <= $new_width && $srcHeight <= $new_width || !$max_width && $srcWidth <= $new_width && $srcHeight <= $thumbheight) {
         // If source image is already of the same size or smaller than the image
         // which shall be created only copy the source image to destination
         $debugoutput .= JText::_('COM_JOOMGALLERY_UPLOAD_RESIZE_NOT_NECESSARY') . '<br />';
         if (!JFile::copy($src_file, $dest_file)) {
             $debugoutput .= JText::sprintf('COM_JOOMGALLERY_UPLOAD_OUTPUT_PROBLEM_COPYING', $dest_file) . ' ' . JText::_('COM_JOOMGALLERY_COMMON_CHECK_PERMISSIONS') . '<br />';
             return false;
         }
         return true;
     }
     // For free resizing and cropping the center
     $offsetx = null;
     $offsety = null;
     if ($max_width) {
         $debugoutput .= JText::_('COM_JOOMGALLERY_UPLOAD_RESIZE_TO_MAX') . '<br />';
         if ($new_width <= 0) {
             $debugoutput .= JText::_('COM_JOOMGALLERY_UPLOAD_ERROR_NO_VALID_WIDTH_OR_HEIGHT') . '<br />';
             return false;
         }
         $ratio = max($srcHeight, $srcWidth) / $new_width;
     } else {
         // Resizing to thumbnail
         $debugoutput .= JText::_('COM_JOOMGALLERY_UPLOAD_CREATE_THUMBNAIL_FROM') . ' ' . $imginfo[2] . ', ' . $imginfo[0] . ' x ' . $imginfo[1] . '...<br />';
         if ($new_width <= 0 || $thumbheight <= 0) {
             $debugoutput .= JText::_('COM_JOOMGALLERY_UPLOAD_ERROR_NO_VALID_WIDTH_OR_HEIGHT') . '<br />';
             return false;
         }
         switch ($useforresizedirection) {
             // Convert to height ratio
             case 0:
                 $ratio = $srcHeight / $thumbheight;
                 $testwidth = $srcWidth / $ratio;
                 // If new width exceeds setted max. width
                 if ($testwidth > $new_width) {
                     $ratio = $srcWidth / $new_width;
                 }
                 break;
                 // Convert to width ratio
             // Convert to width ratio
             case 1:
                 $ratio = $srcWidth / $new_width;
                 $testheight = $srcHeight / $ratio;
                 // If new height exceeds the setted max. height
                 if ($testheight > $thumbheight) {
                     $ratio = $srcHeight / $thumbheight;
                 }
                 break;
                 // Free resizing and cropping the center
             // Free resizing and cropping the center
             case 2:
                 if ($srcWidth < $new_width) {
                     $new_width = $srcWidth;
                 }
                 if ($srcHeight < $thumbheight) {
                     $thumbheight = $srcHeight;
                 }
                 // Expand the thumbnail's aspect ratio
                 // to fit the width/height of the image
                 $ratiowidth = $srcWidth / $new_width;
                 $ratioheight = $srcHeight / $thumbheight;
                 if ($ratiowidth < $ratioheight) {
                     $ratio = $ratiowidth;
                 } else {
                     $ratio = $ratioheight;
                 }
                 // Calculate the offsets for cropping the source image according
                 // to thumbposition
                 switch ($cropposition) {
                     // Left upper corner
                     case 0:
                         $offsetx = 0;
                         $offsety = 0;
                         break;
                         // Right upper corner
                     // Right upper corner
                     case 1:
                         $offsetx = floor($srcWidth - $new_width * $ratio);
                         $offsety = 0;
                         break;
                         // Left lower corner
                     // Left lower corner
                     case 3:
                         $offsetx = 0;
                         $offsety = floor($srcHeight - $thumbheight * $ratio);
                         break;
                         // Right lower corner
                     // Right lower corner
                     case 4:
                         $offsetx = floor($srcWidth - $new_width * $ratio);
                         $offsety = floor($srcHeight - $thumbheight * $ratio);
                         break;
                         // Default center
                     // Default center
                     default:
                         $offsetx = floor(($srcWidth - $new_width * $ratio) * 0.5);
                         $offsety = floor(($srcHeight - $thumbheight * $ratio) * 0.5);
                         break;
                 }
         }
     }
     if (is_null($offsetx) && is_null($offsety)) {
         $ratio = max($ratio, 1.0);
         $destWidth = (int) ($srcWidth / $ratio);
         $destHeight = (int) ($srcHeight / $ratio);
     } else {
         $destWidth = $new_width;
         $destHeight = $thumbheight;
         $srcWidth = (int) ($destWidth * $ratio);
         $srcHeight = (int) ($destHeight * $ratio);
     }
     // Method for creation of the resized image
     switch ($method) {
         case 'gd1':
             if (!function_exists('imagecreatefromjpeg')) {
                 $debugoutput .= JText::_('COM_JOOMGALLERY_UPLOAD_GD_LIBARY_NOT_INSTALLED');
                 return false;
             }
             if ($imginfo[2] == 'JPG') {
                 $src_img = imagecreatefromjpeg($src_file);
             } else {
                 if ($imginfo[2] == 'PNG') {
                     $src_img = imagecreatefrompng($src_file);
                 } else {
                     $src_img = imagecreatefromgif($src_file);
                 }
             }
             if (!$src_img) {
                 return false;
             }
             $dst_img = imagecreate($destWidth, $destHeight);
             if (!is_null($offsetx) && !is_null($offsety)) {
                 imagecopyresized($dst_img, $src_img, 0, 0, $offsetx, $offsety, $destWidth, (int) $destHeight, $srcWidth, $srcHeight);
             } else {
                 imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int) $destHeight, $srcWidth, $srcHeight);
             }
             if (!@imagejpeg($dst_img, $dest_file, $dest_qual)) {
                 // Workaround for servers with wwwrun problem
                 $dir = dirname($dest_file);
                 JoomFile::chmod($dir, '0777', true);
                 imagejpeg($dst_img, $dest_file, $dest_qual);
                 JoomFile::chmod($dir, '0755', true);
             }
             imagedestroy($src_img);
             imagedestroy($dst_img);
             break;
         case 'gd2':
             if (!function_exists('imagecreatefromjpeg')) {
                 $debugoutput .= JText::_('COM_JOOMGALLERY_UPLOAD_GD_LIBARY_NOT_INSTALLED');
                 return false;
             }
             if (!function_exists('imagecreatetruecolor')) {
                 $debugoutput .= JText::_('COM_JOOMGALLERY_UPLOAD_GD_NO_TRUECOLOR');
                 return false;
             }
             if ($imginfo[2] == 'JPG') {
                 $src_img = imagecreatefromjpeg($src_file);
             } else {
                 if ($imginfo[2] == 'PNG') {
                     $src_img = imagecreatefrompng($src_file);
                 } else {
                     $src_img = imagecreatefromgif($src_file);
                 }
             }
             if (!$src_img) {
                 return false;
             }
             $dst_img = imagecreatetruecolor($destWidth, $destHeight);
             if ($config->jg_fastgd2thumbcreation == 0) {
                 if (!is_null($offsetx) && !is_null($offsety)) {
                     imagecopyresampled($dst_img, $src_img, 0, 0, $offsetx, $offsety, $destWidth, (int) $destHeight, $srcWidth, $srcHeight);
                 } else {
                     imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int) $destHeight, $srcWidth, $srcHeight);
                 }
             } else {
                 if (!is_null($offsetx) && !is_null($offsety)) {
                     JoomFile::fastImageCopyResampled($dst_img, $src_img, 0, 0, $offsetx, $offsety, $destWidth, (int) $destHeight, $srcWidth, $srcHeight);
                 } else {
                     JoomFile::fastImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int) $destHeight, $srcWidth, $srcHeight);
                 }
             }
             if (!@imagejpeg($dst_img, $dest_file, $dest_qual)) {
                 // Workaround for servers with wwwrun problem
                 $dir = dirname($dest_file);
                 JoomFile::chmod($dir, '0777', true);
                 imagejpeg($dst_img, $dest_file, $dest_qual);
                 JoomFile::chmod($dir, '0755', true);
             }
             imagedestroy($src_img);
             imagedestroy($dst_img);
             break;
         case 'im':
             $disabled_functions = explode(',', ini_get('disabled_functions'));
             foreach ($disabled_functions as $disabled_function) {
                 if (trim($disabled_function) == 'exec') {
                     $debugoutput .= JText::_('COM_JOOMGALLERY_UPLOAD_OUTPUT_EXEC_DISABLED') . '<br />';
                     return false;
                 }
             }
             if (!empty($config->jg_impath)) {
                 $convert_path = $config->jg_impath . 'convert';
             } else {
                 $convert_path = 'convert';
             }
             $commands = '';
             // Crop the source image before resiszing if offsets setted before
             // example of crop: convert input -crop destwidthxdestheight+offsetx+offsety +repage output
             // +repage needed to delete the canvas
             if (!is_null($offsetx) && !is_null($offsety)) {
                 $commands .= ' -crop "' . $srcWidth . 'x' . $srcHeight . '+' . $offsetx . '+' . $offsety . '" +repage';
             }
             // Finally the resize
             $commands .= ' -resize "' . $destWidth . 'x' . $destHeight . '" -quality "' . $dest_qual . '" -unsharp "3.5x1.2+1.0+0.10"';
             $convert = $convert_path . ' ' . $commands . ' "' . $src_file . '" "' . $dest_file . '"';
             $return_var = null;
             $dummy = null;
             @exec($convert, $dummy, $return_var);
             if ($return_var != 0) {
                 // Workaround for servers with wwwrun problem
                 $dir = dirname($dest_file);
                 JoomFile::chmod($dir, '0777', true);
                 @exec($convert, $dummy, $return_var);
                 JoomFile::chmod($dir, '0755', true);
                 if ($return_var != 0) {
                     return false;
                 }
             }
             break;
         default:
             JError::raiseError(500, JText::_('COM_JOOMGALLERY_UPLOAD_UNSUPPORTED_RESIZING_METHOD'));
             break;
     }
     // Set mode of uploaded picture
     JPath::setPermissions($dest_file);
     // We check that the image is valid
     $imginfo = getimagesize($dest_file);
     if (!$imginfo) {
         return false;
     }
     return true;
 }
Example #27
0
 /**
  * Returns the rating clause for an SQL - query dependent on the
  * rating calculation method selected.
  *
  * @param   string  $tablealias   Table alias
  * @return  string  Rating clause
  * @since   1.5.6
  */
 public static function getSQLRatingClause($tablealias = '')
 {
     $db = JFactory::getDBO();
     $config = JoomConfig::getInstance();
     static $avgimgvote = 0.0;
     static $avgimgrating = 0.0;
     static $avgdone = false;
     $maxvoting = $config->get('jg_maxvoting');
     $imgvotesum = 'imgvotesum';
     $imgvotes = 'imgvotes';
     if ($tablealias != '') {
         $imgvotesum = $tablealias . '.' . $imgvotesum;
         $imgvotes = $tablealias . '.' . $imgvotes;
     }
     // Standard rating clause
     $clause = 'ROUND(LEAST(IF(imgvotes > 0, ' . $imgvotesum . '/' . $imgvotes . ', 0.0), ' . (double) $maxvoting . '), 2)';
     // Advanced (weigthed) rating clause (Bayes)
     if ($config->get('jg_ratingcalctype') == 1) {
         if (!$avgdone) {
             // Needed values for weighted rating calculation
             $query = $db->getQuery(true)->select('count(*) As imgcount')->select('SUM(imgvotes) As sumimgvotes')->select('SUM(imgvotesum/imgvotes) As sumimgratings')->from(_JOOM_TABLE_IMAGES)->where('imgvotes > 0');
             $db->setQuery($query);
             $row = $db->loadObject();
             if ($row != null) {
                 if ($row->imgcount > 0) {
                     $avgimgvote = round($row->sumimgvotes / $row->imgcount, 2);
                     $avgimgrating = round($row->sumimgratings / $row->imgcount, 2);
                     $avgdone = true;
                 }
             }
         }
         if ($avgdone) {
             $clause = 'ROUND(LEAST(IF(imgvotes > 0, ((' . $avgimgvote . '*' . $avgimgrating . ') + ' . $imgvotesum . ') / (' . $avgimgvote . ' + ' . $imgvotes . '), 0.0), ' . (double) $maxvoting . '), 2)';
         }
     }
     return $clause;
 }
Example #28
0
 /**
  * Constructor
  *
  * Presets all variables
  *
  * @access  protected
  * @return  void
  * @since   1.5.5
  */
 function __construct()
 {
     jimport('joomla.filesystem.folder');
     $config = JoomConfig::getInstance();
     $mainframe = JFactory::getApplication('administrator');
     // Fill all variables
     $this->icon_url = JURI::root() . 'media/joomgallery/images/';
     $this->css_url = JURI::root() . 'media/joomgallery/css/';
     $this->js_url = JURI::root() . 'media/joomgallery/js/';
     $this->_external['thumb'] = false;
     $this->thumb_url = JURI::root() . $config->get('jg_paththumbs');
     $this->thumb_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_paththumbs'));
     if (!JFolder::exists($this->thumb_path)) {
         $this->_external['thumb'] = true;
         $this->thumb_url = '';
         $this->thumb_path = JPath::clean($config->get('jg_paththumbs'));
     }
     $this->_external['img'] = false;
     $this->img_url = JURI::root() . $config->get('jg_pathimages');
     $this->img_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_pathimages'));
     if (!JFolder::exists($this->img_path)) {
         $this->_external['img'] = true;
         $this->img_url = '';
         $this->img_path = JPath::clean($config->get('jg_pathimages'));
     }
     $this->_external['orig'] = false;
     $this->orig_url = JURI::root() . $config->get('jg_pathoriginalimages');
     $this->orig_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_pathoriginalimages'));
     if (!JFolder::exists($this->orig_path)) {
         $this->_external['orig'] = true;
         $this->orig_url = '';
         $this->orig_path = JPath::clean($config->get('jg_pathoriginalimages'));
     }
     $this->temp_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_pathtemp'));
     if (!JFolder::exists($this->temp_path)) {
         $this->temp_path = JPath::clean($config->get('jg_pathtemp'));
     }
     $this->ftp_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_pathftpupload'));
     if (!JFolder::exists($this->ftp_path)) {
         $this->ftp_path = JPath::clean($config->get('jg_pathftpupload'));
     }
     $this->wtm_path = JPath::clean(JPATH_ROOT . '/' . $config->get('jg_wmpath'));
     if (!JFolder::exists($this->wtm_path)) {
         $this->wtm_path = JPath::clean($config->get('jg_wmpath'));
     }
     if (!($this->version = $mainframe->getUserState('joom.version.string'))) {
         $this->version = JoomExtensions::getGalleryVersion();
         $mainframe->setUserState('joom.version.string', $this->version);
     }
 }
Example #29
0
 /**
  * Constructor
  *
  * @return  void
  * @since   1.0.0
  */
 public function __construct()
 {
     $this->_mainframe = JFactory::getApplication();
     $this->_config = JoomConfig::getInstance();
     $this->_ambit = JoomAmbit::getInstance();
     $this->_user = JFactory::getUser();
     $this->_db = JFactory::getDBO();
     $this->debug = $this->_mainframe->getUserStateFromRequest('joom.upload.debug', 'debug', false, 'post', 'bool');
     $this->_debugoutput = $this->_mainframe->getUserStateFromRequest('joom.upload.debugoutput', 'debugoutput', '', 'post', 'string');
     $this->catid = $this->_mainframe->getUserStateFromRequest('joom.upload.catid', 'catid', 0, 'int');
     $this->imgtitle = $this->_mainframe->getUserStateFromRequest('joom.upload.title', 'imgtitle', '', 'string');
     $this->counter = $this->getImageNumber();
     $this->_site = $this->_mainframe->isSite();
     // TODO Parameter in JoomGallery configuration neccessary ?
     // Create folder for image chunks
     $this->chunksFolder = $this->_mainframe->getCfg('tmp_path') . '/joomgallerychunks';
     if (!JFolder::exists($this->chunksFolder)) {
         JFolder::create($this->chunksFolder);
         JoomFile::copyIndexHtml($this->chunksFolder);
     }
 }