function getInput() { $default = $this->value; $arrPathes = explode('/', $default); $filename = array_pop($arrPathes); $targetfolder = array_pop($arrPathes); $output = ImageSelectJL::getSelector($this->name, $this->name . '_preview', $targetfolder, $this->value, $default, $this->name, $this->id); $output .= '<img class="imagepreview" src="' . JUri::root(true) . '/media/com_joomleague/jl_images/spinner.gif" '; $output .= ' name="' . $this->name . '_preview" id="' . $this->name . '_preview" border="3" alt="Preview" title="Preview" />'; $output .= '<input type="hidden" id="' . $this->id . '" name="' . $this->name . '" value="' . $this->value . '" />'; return $output; }
function getSelector($fieldname, $fieldpreview_name, $type, $value, $default = '', $control_name = '', $fieldid) { $document = JFactory::getDocument(); $this->_foldertype = $type; JHTML::_('behavior.modal'); $baseFolder = JURI::root(); //.'images/com_joomleague/database/'.ImageSelectJL::getfolder($type); $funcname = preg_replace("/^[.]*/", '', $fieldid); //Build the image select functionality $js = "\n\t\tfunction selectImage_" . $type . "(image, imagename, field, fieldid)\n\t\t{\n\t\t\t\$('a_' + field).value = 'images/com_joomleague/database/" . ImageSelectJL::getfolder($type) . "/'+image;\n\t\t\t\$('a_' + field + '_name').value ='images/com_joomleague/database/" . ImageSelectJL::getfolder($type) . "/'+imagename;\n\t\t\t\$('a_' + field + '_name').fireEvent('change');\n \t\tif(\$(fieldid)) {\n \t\t\$(fieldid).value = 'images/com_joomleague/database/" . ImageSelectJL::getfolder($type) . "/'+imagename;\n \t\t}\n\t\t\t\$('a_' + field + '_name').fireEvent('change');\n\t\t\twindow.top.setTimeout('window.parent.SqueezeBox.close()', 100);\n\t\t}\n\t\tfunction reset_" . $funcname . "()\n\t\t{\n\t\t\t\$('a_" . $fieldname . "').setProperty('value', '" . $default . "');\n\t\t\t\$('a_" . $fieldname . "_name').setProperty('value', '" . $default . "').fireEvent('change');\n\t\t}\n\n\t\tfunction clear_" . $funcname . "()\n\t\t{\n\t\t\t\$('a_" . $fieldname . "').setProperty('value', '');\n\t\t\t\$('a_" . $fieldname . "_name').setProperty('value', '').fireEvent('change');\n\t\t}\n\n\t\twindow.addEvent('domready', function()\n\t\t{\n\t\t\t\$('a_" . $fieldname . "_name').addEvent('change', function()\n\t\t\t{\n\t\t\t\tif (\$('a_" . $fieldname . "_name').value!='') {\n\t\t\t\t\t\$('" . $fieldpreview_name . "').src='" . $baseFolder . "' + \$('a_" . $fieldname . "_name').value;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t\$('" . $fieldpreview_name . "').src='../images/blank.png';\n\t\t\t\t}\n\t\t\t\tif(\$('" . $fieldid . "')) {\n\t\t\t\t\t\$('" . $fieldid . "').value = \$('a_" . $fieldname . "_name').value;\n\t\t\t\t}\n\t\t\t});\n\t\t\t\$('a_" . $fieldname . "_name').fireEvent('change');\n\t\t});\n\t\t"; $link = 'index.php?option=com_joomleague&view=imagehandler&layout=upload&type=' . $type . '&field=' . $fieldname . '&fieldid=' . $fieldid . '&tmpl=component'; $link2 = 'index.php?option=com_joomleague&view=imagehandler&type=' . $type . '&field=' . $fieldname . '&fieldid=' . $fieldid . '&tmpl=component'; $document->addScriptDeclaration($js); JHTML::_('behavior.modal', 'a.modal'); $imageselect = "\n <input style=\"background: #ffffff;\" type=\"text\" id=\"a_" . $fieldname . "_name\" value=\"" . $value . "\" disabled=\"disabled\" size=\"60\" />"; $imageselect .= "<div class=\"button2-left\"><div class=\"blank\"><a class=\"modal\" title=\"" . JText::_('COM_JOOMLEAGUE_GLOBAL_UPLOAD') . "\" href=\"{$link}\" rel=\"{handler: 'iframe', size: {x: 800, y: 500}}\">" . JText::_('COM_JOOMLEAGUE_GLOBAL_UPLOAD') . "</a></div></div>\n"; $imageselect .= "<div class=\"button2-left\"><div class=\"blank\"><a class=\"modal\" title=\"" . JText::_('COM_JOOMLEAGUE_GLOBAL_SELECT_IMG') . "\" href=\"{$link2}\" rel=\"{handler: 'iframe', size: {x: 800, y: 500}}\">" . JText::_('COM_JOOMLEAGUE_GLOBAL_SELECT_IMG') . "</a></div></div>\n"; $imageselect .= "<div class=\"button2-left\"><div class=\"blank\"><a title=\"" . JText::_('COM_JOOMLEAGUE_GLOBAL_SELECT_IMG') . "\" href=\"#\" onclick=\"reset_" . $fieldid . "();\">" . JText::_('COM_JOOMLEAGUE_GLOBAL_RESET') . "</a></div></div>\n"; $imageselect .= "<div class=\"button2-left\"><div class=\"blank\"><a title=\"" . JText::_('COM_JOOMLEAGUE_GLOBAL_CLEAR') . "\" href=\"#\" onclick=\"clear_" . $fieldid . "();\">" . JText::_('COM_JOOMLEAGUE_GLOBAL_CLEAR') . "</a></div></div>\n"; $imageselect .= "\n<input type=\"hidden\" id=\"a_" . $fieldname . "\" name=\"" . $fieldname . "\" value=\"" . $value . "\" />"; return $imageselect; }
/** * Prepares the upload image screen * * @param $tpl * * @since 0.9 */ function _displayupload($tpl = null) { $option = JRequest::getCmd('option'); $mainframe = JFactory::getApplication(); //initialise variables $document = JFactory::getDocument(); $uri = JFactory::getURI(); $params =& JComponentHelper::getParams('com_joomleague'); $type = JRequest::getVar('type'); $folder = ImageSelectJL::getfolder($type); $field = JRequest::getVar('field'); $fieldid = JRequest::getVar('fieldid'); $menu = JRequest::setVar('hidemainmenu', 1); //get vars $task = JRequest::getVar('task'); jimport('joomla.client.helper'); $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); //assign data to template $this->assignRef('params', $params); $this->assignRef('request_url', $uri->toString()); $this->assignRef('ftp', $ftp); $this->assignRef('folder', $folder); $this->assignRef('field', $field); $this->assignRef('fieldid', $fieldid); $this->assignRef('menu', $menu); parent::display($tpl); }
/** * logic to mass delete images * * @access public * @return void * @since 0.9 */ function delete() { $mainframe = JFactory::getApplication(); // Set FTP credentials, if given jimport('joomla.client.helper'); JClientHelper::setCredentialsFromRequest('ftp'); // Get some data from the request $images = JRequest::getVar('rm', array(), '', 'array'); $type = JRequest::getVar('type'); $folder = ImageSelectJL::getfolder($type); if (count($images)) { foreach ($images as $image) { if ($image !== JFilterInput::clean($image, 'path')) { JError::raiseWarning(100, JText::_('COM_JOOMLEAGUE_ADMIN_IMAGEHANDLER_CTRL_UNABLE_TO_DELETE') . ' ' . htmlspecialchars($image, ENT_COMPAT, 'UTF-8')); continue; } // $fullPath = JPath::clean( JPATH_SITE . DS . 'media' . DS . 'com_joomleague' . DS . $folder . DS . $image ); // $fullPaththumb = JPath::clean( JPATH_SITE . DS . 'media' . DS . 'com_joomleague' . DS . $folder . DS . 'small' . DS . $image ); $fullPath = JPath::clean(JPATH_SITE . DS . 'images' . DS . 'com_joomleague' . DS . 'database' . DS . $folder . DS . $image); $fullPaththumb = JPath::clean(JPATH_SITE . DS . 'images' . DS . 'com_joomleague' . DS . 'database' . DS . $folder . DS . 'small' . DS . $image); if (is_file($fullPath)) { JFile::delete($fullPath); if (JFile::exists($fullPaththumb)) { JFile::delete($fullPaththumb); } } } } $mainframe->redirect('index.php?option=com_joomleague&view=imagehandler&type=' . $type . '&tmpl=component'); }