public function upload()
 {
     // todo: secure upload from injections
     $user = JFactory::getUser();
     if (!$user->authorise('core.manage', 'com_djmediatools')) {
         echo JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN');
         exit(0);
     }
     DJUploadHelper::upload();
     return true;
 }
Exemplo n.º 2
0
 function display($tpl = null)
 {
     $par = JComponentHelper::getParams('com_djclassifieds');
     $dispatcher = JDispatcher::getInstance();
     //$model =& $this->getModel();
     $this->item = $this->get('Item');
     $this->images = $this->get('ItemImages');
     $this->regions = $this->get('Regions');
     $this->payment = $this->get('Payment');
     $this->promotions = $this->get('Promotions');
     $this->durations = $this->get('Dutarions');
     $this->custom_contact = $this->get('CustomContact');
     $this->view_levels = $this->get('viewLevels');
     $this->bids = $this->get('Bids');
     $this->buynow = $this->get('BuyNow');
     $this->units = $this->get('Units');
     $dispatcher->trigger('onAdminPrepareItemEdit', array(&$this->item, &$this->images, &$this->payment, &$this->custom_contact, &$this->bids, &$this->buynow));
     $country = '';
     $city = '';
     $reg_path = '';
     if ($this->item->region_id != 0) {
         $id = array();
         $name = array();
         $rid = $this->item->region_id;
         if ($rid != 0) {
             while ($rid != 0) {
                 $parent_f = 0;
                 foreach ($this->regions as $li) {
                     if ($li->id == $rid) {
                         $rid = $li->parent_id;
                         $id[] = $li->id;
                         $name[] = $li->name;
                         $reg_path = 'new_reg(' . $li->parent_id . ',' . $li->id . ');' . $reg_path;
                         if ($li->country) {
                             $country = $li->name;
                         }
                         if ($li->city) {
                             $city = $li->name;
                         }
                         $parent_f = 1;
                         break;
                     }
                 }
                 if ($rid == $this->item->region_id) {
                     break;
                 }
                 if (!$parent_f) {
                     break;
                 }
             }
         }
     }
     $this->country = $country;
     $this->city = $city;
     $this->reg_path = $reg_path;
     /*
     		$this->cats = $this->get('Categories');
     		
     		$cat_path='';		
     		if($this->item->cat_id!=0){								
     			$id = Array();
     			$name = Array();
     			$cid = $this->item->cat_id;
     			if($cid!=0){
     				while($cid!=0){	
     					foreach($this->cats as $li){
     						if($li->id==$cid){
     							$cid=$li->parent_id;
     							$id[]=$li->id;
     							$name[]=$li->name;
     							$cat_path = 'new_cat('.$li->parent_id.','.$li->id.');'.$cat_path;
     							break;
     						}
     					}
     				}
     			}
     		}
     		
     		$this->cat_path = $cat_path;*/
     $this->document->addScript(JURI::root() . '/components/com_djclassifieds/assets/djuploader.js');
     $settings = array();
     $settings['max_file_size'] = $par->get('upload_max_size', '10240') . 'kb';
     $settings['chunk_size'] = $par->get('upload_chunk_size', '1024') . 'kb';
     $settings['resize'] = true;
     $settings['width'] = $par->get('upload_width', '1600');
     $settings['height'] = $par->get('upload_height', '1200');
     $settings['quality'] = $par->get('upload_quality', '90');
     $settings['filter'] = 'jpg,png,gif';
     $settings['onUploadedEvent'] = 'injectUploaded';
     $settings['onAddedEvent'] = 'startUpload';
     $settings['label_generate'] = $par->get('image_label_from_name', '1');
     //$settings['debug'] = true;
     $this->uploader = DJUploadHelper::getUploader('uploader', $settings);
     $this->selusers = $this->get('selUsers');
     $this->abuse = $this->get('AbuseRaports');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->addToolbar();
     $version = new JVersion();
     if (version_compare($version->getShortVersion(), '3.0.0', '<')) {
         $tpl = 'legacy';
     }
     parent::display($tpl);
 }
Exemplo n.º 3
0
$id = JRequest::getVar('id', 0, '', 'int');
$document = JFactory::getDocument();
$document->addScript(JURI::root() . '/components/com_djclassifieds/assets/djuploader.js');
$settings = array();
$settings['max_file_size'] = $up_img_maxsize . 'kb';
$settings['chunk_size'] = '1024kb';
$settings['resize'] = true;
$settings['width'] = $par->get('upload_width', '1600');
$settings['height'] = $par->get('upload_height', '1200');
$settings['quality'] = $par->get('upload_quality', '90');
$settings['filter'] = 'jpg,png,gif';
$settings['onUploadedEvent'] = 'injectFrontUploaded';
$settings['onAddedEvent'] = 'startUploadLimit';
$settings['label_generate'] = $par->get('image_label_from_name', '1');
//$settings['debug'] = true;
$this->uploader = DJUploadHelper::getUploader('uploader', $settings);
?>

	<div class="images_box additem_djform">
		<div class="title_top"><?php 
echo JText::_('COM_DJCLASSIFIEDS_IMAGES');
?>
</div>
		<div class="additem_djform_in">
			<div class="img_info">
			<?php 
if ($img_maxsize > 0) {
    echo '<div class="img_info_row">' . JText::_('COM_DJCLASSIFIEDS_MAX_IMAGE_SIZE') . ': <span>' . $img_maxsize . ' MB </span></div>';
}
echo '<div class="img_info_row">' . JText::_('COM_DJCLASSIFIEDS_IMAGES_LIMIT') . ': <span>' . $imglimit . '</span></div>';
if ($imgfreelimit > -1) {
Exemplo n.º 4
0
 public function upload()
 {
     $user = JFactory::getUser();
     DJUploadHelper::upload();
     return true;
 }
Exemplo n.º 5
0
    public function display($tpl = null)
    {
        // Initialiase variables.
        $this->form = $this->get('Form');
        $this->item = $this->get('Item');
        $this->state = $this->get('State');
        $this->plgParams = $this->get('plgParams');
        // Check for errors.
        if (count($errors = $this->get('Errors'))) {
            JError::raiseError(500, implode("\n", $errors));
            return false;
        }
        $version = new JVersion();
        if (version_compare($version->getShortVersion(), '3.0.0', '<')) {
            $tpl = 'legacy';
            $btnclass = 'button';
            $btn2class = 'button-link';
        } else {
            $btnclass = 'btn btn-primary btn-large';
            $btn2class = 'btn btn-link btn-large';
        }
        if ($this->item->id && $this->item->source == 'component') {
            $this->items = $this->get('Items');
            foreach ($this->items as $item) {
                if (!($item->thumb = DJImageResizer::createThumbnail($item->image, 'media/djmediatools/cache', 200, 150, 'toHeight', 80))) {
                    $item->thumb = $item->image;
                }
                if (strcasecmp(substr($item->image, 0, 4), 'http') != 0 && !empty($item->image)) {
                    $item->image = JURI::root(true) . '/' . $item->image;
                }
                if (strcasecmp(substr($item->thumb, 0, 4), 'http') != 0 && !empty($item->thumb)) {
                    $item->thumb = JURI::root(true) . '/' . $item->thumb;
                }
            }
        }
        // include uploader events and simple managing of album items
        $this->document->addScript(JURI::base(true) . '/components/com_djmediatools/assets/album.js');
        $params = JComponentHelper::getParams('com_djmediatools');
        $settings = array();
        $settings['max_file_size'] = $params->get('upload_max_size', '10240') . 'kb';
        $settings['chunk_size'] = $params->get('upload_chunk_size', '1024') . 'kb';
        $settings['resize'] = true;
        $settings['width'] = $params->get('upload_width', '1600');
        $settings['height'] = $params->get('upload_height', '1200');
        $settings['quality'] = $params->get('upload_quality', '90');
        $settings['filter'] = 'jpg,png,gif';
        $settings['onUploadedEvent'] = 'injectUploaded';
        $settings['onAddedEvent'] = 'startUpload';
        //$settings['debug'] = true;
        $this->uploader = DJUploadHelper::getUploader('uploader', $settings);
        if (JRequest::getVar('tmpl') != 'component') {
            $this->addToolbar();
        } else {
            $function = JRequest::getVar('f_name');
            //die('dupa przed');
            $this->button = "\r\n\t\t\t\t\r\n\t\t\t\t<script type='text/javascript'>\r\n\t\t\t\t\tfunction save2insert(cover) {\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif (document.formvalidator.isValid(document.id('item-form'))) {\r\n\t\t\t\t\t\t\t" . $this->form->getField('description')->save() . "\r\n\t\t\t\t\t\t\tdocument.getElementById('item-form').task.value='category.save';\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tvar loader = new Element('div', {\r\n\t\t\t\t\t\t\t\tstyles: {\r\n\t\t\t\t\t\t\t\t\tbackground: '#fff url(components/com_djmediatools/assets/bigloader.gif) center center no-repeat',\r\n\t\t\t\t\t\t\t\t\tposition: 'fixed', top: 0, left: 0, width: '100%', height: '100%', 'z-index': 9999\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\tloader.fade('hide');\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tdocument.id('item-form').set('send',{\r\n\t\t\t\t\t\t\t\tonRequest: function(){\r\n\t\t\t\t\t\t\t\t\tloader.inject(document.id(document.body));\r\n\t\t\t\t\t\t\t\t\tloader.fade(0.8);\r\n\t\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\tonSuccess: function(responseText){\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\tvar rsp = responseText.trim();\r\n\t\t\t\t\t\t\t\t\tif(rsp){\r\n\t\t\t\t\t\t\t\t\t\tvar json = rsp;\r\n\t\t\t\t\t\t\t\t\t\tif(rsp.charAt(0) != '[' && rsp.charAt(0) != '{'){\r\n\t\t\t\t\t\t\t\t\t\t\tjson = rsp.match(/{.*?}/);\r\n\t\t\t\t\t\t\t\t\t\t\tif(json && json[0]){\r\n\t\t\t\t\t\t\t\t\t\t\t\tjson = json[0];\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\tif(json && typeof json == 'string'){\r\n\t\t\t\t\t\t\t\t\t\t\tjson = JSON.decode(json);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\tif (window.parent) window.parent." . $function . "(json.id,json.image,json.title, cover);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\tonFailure: function(){\r\n\t\t\t\t\t\t\t\t\tloader.destroy();\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tdocument.id('item-form').send();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse {\r\n\t\t\t\t\t\t\talert('" . $this->escape(JText::_('COM_DJMEDIATOOLS_VALIDATION_FORM_FAILED')) . "');\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t</script>\r\n\t\t\t\t\n\t\t\t";
            //if (window.parent) window.parent.".$function."('".$item->id."','".$item->image ? $item->image : $item->thumb."','".$this->escape($item->title)."');
            //die('dupa po');
            //die($this->button);
            $this->button .= '
				<div class="modalAlbum">
					<input type="hidden" name="tmpl" value="component" />
					<input type="hidden" name="f_name" value="' . $function . '" />
					<input type="button" class="' . $btnclass . '" value="' . JText::_('COM_DJMEDIATOOLS_MODAL_SAVE_INSERT') . '" onclick="return save2insert();" />
					<input type="button" class="' . $btnclass . ' hasTip" title="::' . JText::_('COM_DJMEDIATOOLS_INSERT_LINKED_COVER_DESC') . '" value="' . JText::_('COM_DJMEDIATOOLS_MODAL_SAVE_INSERT_COVER') . '" onclick="return save2insert(true);" />
					<a class="' . $btn2class . '" href="index.php?option=com_djmediatools&amp;view=categories&amp;layout=modal&amp;tmpl=component&amp;f_name=' . $function . '">' . JText::_('JCANCEL') . '</a>
				</div>';
        }
        parent::display($tpl);
    }