1

在 TYPO3 6.0.2 中,我得到了一个 Extbase/Fluid-Extension。Controller 中的函数如下所示:

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

这将返回一个tt_content- 对象,包括image => /path/to/image. 一切都很好。

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

今天将源更改为 TYPO3 6.0.3 一切都一样,但图像只是"1".

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

我能做些什么?谢谢!

4

3 回答 3

2

我发现这是在没有 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);
} 

体液

                    <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> 
于 2013-10-15T07:31:22.867 回答
0

Since TYPO3 6 the method "function getContentObject($name)" was located in *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:

 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);
}
于 2013-03-08T10:45:07.683 回答
0

该错误似乎是典型 jumpURL 系统已更改(SQL 注入)的安全更新的结果。我在这里提交了一个错误:http: //forge.typo3.org/issues/46090

于 2013-03-07T12:12:32.050 回答