简体   繁体   English

6.0.3中的Typo3 $ this-> contentObj中缺少图像

[英]Missing image in Typo3 $this->contentObj in 6.0.3

in TYPO3 6.0.2 I got an Extbase/Fluid-Extension. 在TYPO3 6.0.2中,我得到了一个Extbase / Fluid-Extension。 The function in the Controller looks like this: Controller中的函数如下所示:

$this->contentObj = $this->configurationManager->getContentObject();
$data = $this->contentObj->data;
print_r($data);

This will return a tt_content - object including image => /path/to/image . 这将返回一个tt_content对象,其中包括image => /path/to/image Everything fine. 一切都很好。

[bodytext] => Lorem ipsum dolor 
[image] => ../../fileadmin/user_upload/images/businessman.jpg

Today changing source to TYPO3 6.0.3 everything the same but the image is just a "1" . 今天,将源更改为TYPO3 6.0.3的一切都一样,但是映像只是一个"1"

[bodytext] => Lorem ipsum dolor
[image] => 1

What can I do? 我能做什么? Thanks! 谢谢!

i found this to get files without sql query 我发现这是在没有SQL查询的情况下获取文件

    public function myAction(){        

    // get data of the content object
    $data = $this->contentObj = $this->configurationManager->getContentObject()->data;

    // Neu ab Typo3 6.0.3 -> Bild in tt_content-Object wird nicht mehr mit zurueckgeliefert, daher:     
    $fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
    $fileObjects = $fileRepository->findByRelation('tt_content', 'image', $data['uid']);
    $files = array();
    foreach ($fileObjects as $key => $value) {
      $files[$key]['reference'] = $value->getReferenceProperties();
      $files[$key]['original'] = $value->getOriginalFile()->getProperties();
    } 

    #t3lib_utility_Debug::debug($files);
    #die('Ende');        

    // Files in Fluid ausgeben
    $this->view->assign('files', $files);        

    // Daten in Fluid ausgeben
    $this->view->assign('data', $data);
} 

fluid 流体

                    <f:for each="{files}" as="file">                        
                    <li>
                        <a href="{file.reference.link}"><img src="fileadmin{file.original.identifier}" alt="" /></a>
                        <p class="flex-caption"><f:format.nl2br>{file.reference.description}</f:format.nl2br></p>
                    </li>                        
                </f:for> 

the bug appears to be a result of the security update where the typical jumpURL system has changed (SQL Injection). 该错误似乎是由于安全更新导致的,其中典型的jumpURL系统已更改(SQL注入)。 I filed a bug here: http://forge.typo3.org/issues/46090 我在这里提交了一个错误: http : //forge.typo3.org/issues/46090

Since TYPO3 6 the method " function getContentObject($name) " was located in *typo3\\sysext\\cms\\tslib\\class.tslib_content.php*. 从TYPO3 6开始,方法“ function getContentObject($name) ”位于* typo3 \\ sysext \\ cms \\ tslib \\ class.tslib_content.php *中。

Content of this file: 该文件的内容:

/*
 * @deprecated since 6.0, the classname tslib_cObj and this file is obsolete
 * and will be removed with 6.2. The class was renamed and is now located at:
 * typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
 */
require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('frontend') . 'Classes/ContentObject/ContentObjectRenderer.php';

But I don't see any differences between the old an the new file containing my problem. 但是我看不到旧文件和包含我的问题的新文件之间的任何区别。

I didn't find out how to get the file reference for the tt_content-entry "native", so I wrote a SQL-query: 我没有找到如何获取tt_content-entry“ native”的文件引用,所以写了一个SQL查询:

 public function bla() {
    // get data of the content object
    $this->contentObj = $this->configurationManager->getContentObject();
    $data = $this->contentObj->data;
    // Neu ab Typo3 6.0.3 -> Bild in tt_content-Object wird nicht mehr mit zurueckgeliefert, daher: 
    // https://forge.typo3.org/issues/46090
    // http://stackoverflow.com/questions/15250351/missing-image-in-typo3-this-contentobj-in-6-0-3
    $res = $GLOBALS['TYPO3_DB']->sql_query(
        'select sys_file.identifier from sys_file_reference left join sys_file on sys_file_reference.uid_local = sys_file.uid where sys_file_reference.uid_foreign='.$data['uid'].' and sys_file_reference.deleted=0'
    );
    while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
        $data['image'] = $row['identifier'];
    }
    #print_r($data);
    // assign the data to the fluid template
    $this->view->assign('data', $data);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM