2012-09-23 52 views
0

我有一个名为iconbasic的文件中的代码应该运行我的个人资料图片上传器,但它不工作。任何人有任何想法为什么?文件扩展JFormField

我新的这一点,但是,在组件弗朗端的agentform文件夹中有哪些具有此行成为一个edit.php文件:

<?php echo $this->form->getInput('icon'); ?> 

然后在模型文件夹中,我们有代理.xml文件,它使用此行主要指这在iconbasic.php:

<field name="icon" type="iconbasic" label="COM_IPROPERTY_IMAGE" readonly="true" folder="agents" /> 

然后在组件的档案管理员,我有一个在里面的子文件夹名为领域模型文件夹名为iconbasic.php文件。 在前端,该网站允许我上传文件,然后我发现它们存储在正确的目录中,但它们不显示在网站上。我试图找出为什么,并会真正感谢一些帮助的原因。没有编码经验,使用记事本自己今天++刚刚或多或少想通了这一点:)

这是iconbasic.php文件:

<?php 
/** 
* @version 2.0 2012-01-20 
* @package Joomla 
* @subpackage Intellectual Property 
* @copyright (C) 2012 the Thinkery 
* @license GNU/GPL see LICENSE.php 
*/ 

defined('JPATH_BASE') or die; 

jimport('joomla.html.html'); 
jimport('joomla.form.formfield'); 

class JFormFieldIconBasic extends JFormField 
{ 
protected $type = 'Iconbasic'; 

protected function getInput() 
{ 
    $user  = JFactory::getUser(); 
    $document = JFactory::getDocument(); 
    $folder  = $this->element['folder']; // agents or companies 
    $id   = JRequest::getInt('id'); 
    $settings = ipropertyAdmin::config(); 
    $database = JFactory::getDBO(); 

    switch ($folder){ 
     case 'agents': 
      $width = $settings->agent_photo_width; 
      $table = '#__iproperty_agents'; 
     break; 
     case 'companies': 
      $width = $settings->company_photo_width; 
      $table = '#__iproperty_companies'; 
     break; 
     default: 
      $width = $settings->agent_photo_width; 
      $table = '#__iproperty_agents'; 
     break; 
    } 

    $sql = "SELECT icon FROM ".$table." WHERE id = ".$id; 
    $database->setQuery($sql); 
    $icon = $database->loadResult(); 

    if (!$icon) $icon = 'nopic.png'; 


    $document->addScript("http://bp.yahooapis.com/2.4.21/browserplus-min.js"); 
    $document->addScript("https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"); 
    $document->addScript(JURI::root()."components/com_iproperty/assets/js/plupload/js/plupload.full.js"); 

    $script = 
"jQuery.noConflict(); 
jQuery(document).ready(function($) { 
var uploader = new plupload.Uploader({ 
    runtimes : 'html5,flash,silverlight,browserplus', 
    browse_button : 'pickfiles', 
    container : 'container', 
    max_file_size : '2mb', 
    unique_names : true, 
    multipart: true, 
    urlstream_upload: true, 
    url : '".JURI::root()."index.php?option=com_iproperty&task=ajax.ajaxIconUpload&format=raw&".JUtility::getToken()."=1&target=".$folder."&id=".$id."', 
    flash_swf_url : '".JURI::root()."components/com_iproperty/assets/js/plupload/js/plupload.flash.swf', 
    silverlight_xap_url : '".JURI::root()."components/com_iproperty/assets/js/plupload/js/plupload.silverlight.xap', 
    filters : [ 
     {title : 'Image files', extensions : 'jpg,gif,png'} 
     //{title : '".JText::_('COM_IPROPERTY_IMAGE_TYPES')."', extensions : '".JText::_('COM_IPROPERTY_IMAGE_EXTENSIONS')."'} 
    ], 
    resize : {width : ".$width.", height : ".$width.", quality : 90} // we use the same value for width/height so it scales proportionally 
}); 

$('#uploadfiles').click(function(e) { 
    uploader.start(); 
    e.preventDefault(); 
}); 

uploader.init(); 

uploader.bind('FilesAdded', function(up, files) { 
    $.each(files, function(i, file) { 
     $('#filelist').append(
      '<div id=\"' + file.id + '\">' + 
      file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' + 
     '</div>'); 
    }); 

    uploader.start(); // auto start when file added 

    up.refresh(); // Reposition Flash/Silverlight 
}); 

uploader.bind('UploadProgress', function(up, file) { 
    $('#' + file.id + \" b\").html(file.percent + \"%\"); 
}); 

uploader.bind('Error', function(up, err) { 
console.log(err); 
    $('#filelist').append(\"<div>Error: \" + err.code + 
     \", Message: \" + err.message + 
     (err.file ? \", File: \" + err.file.name : \"\") + 
     \"</div>\" 
    ); 
    up.refresh(); // Reposition Flash/Silverlight 
}); 

uploader.bind('FileUploaded', function(up, file, info) { 
    var finfo = jQuery.parseJSON(info.response); 
    if (finfo[0].status){ // successful image upload 
     var path = '".JURI::root()."media/com_iproperty/".$folder."/'+finfo[0].result; 
     $('#ip_photo_holder').attr('src', path); 
    } 
}); 
});"."\n"; 

    $document->addScriptDeclaration($script); 
    // Build image select js and load the view 
    $img_path = JURI::root(true).'/media/com_iproperty/'.$folder.'/';  
    ?> 
    <div style="padding: 4px;" id="container"> 
     <div id="filelist"></div><br /> 
     <a id="pickfiles" href="javascript:void(0);">[Select files]</a> 
     <a id="uploadfiles" href="javascript:void(0);">[Upload files]</a> 
    </div> 
    <div><img id="ip_photo_holder" src="<?php echo JURI::root(); ?>/media/com_iproperty/<?php echo $folder.'/'.$icon; ?>"></div> 
    <?php 
} 
} 

回答

0

这是在manage.php文件中的行错误的SQL位

+0

[user1925127](http://stackoverflow.com/users/1925127/user1925127)有同样的问题,并询问您如何修复它。 – wimh