0

我在一个名为 iconbasic 的文件中有此代码,该文件应该运行我的个人资料图片上传器,但它不工作。有人知道为什么吗?

我是新手,但是,组件前端的 agentform 文件夹有一个 edit.php 文件,其中包含以下行:

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

然后在模型文件夹中,我们有 agent.xml 文件,它基本上使用以下行将其指向 iconbasic.php:

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

然后在组件的管理员文件中,我在名为 fields 的子文件夹内的模型文件夹中有一个名为 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
}
}
4

1 回答 1

0

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

于 2012-09-24T23:39:20.590 回答