Contao\Backend::addFileMetaInformationToRequest PHP Method

addFileMetaInformationToRequest() public static method

Add the file meta information to the request
public static addFileMetaInformationToRequest ( string $strUuid, string $strPtable, integer $intPid )
$strUuid string
$strPtable string
$intPid integer
    public static function addFileMetaInformationToRequest($strUuid, $strPtable, $intPid)
    {
        $objFile = \FilesModel::findByUuid($strUuid);
        if ($objFile === null) {
            return;
        }
        $arrMeta = \StringUtil::deserialize($objFile->meta);
        if (empty($arrMeta)) {
            return;
        }
        $objPage = null;
        if ($strPtable == 'tl_article') {
            $objPage = \PageModel::findOneBy(array('tl_page.id=(SELECT pid FROM tl_article WHERE id=?)'), $intPid);
        } else {
            // HOOK: support custom modules
            if (isset($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest']) && is_array($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest'])) {
                foreach ($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest'] as $callback) {
                    if (($val = \System::importStatic($callback[0])->{$callback[1]}($strPtable, $intPid)) !== false) {
                        $objPage = $val;
                    }
                }
                if ($objPage instanceof Result && $objPage->numRows < 1) {
                    return;
                }
                if (is_object($objPage) && !$objPage instanceof PageModel) {
                    $objPage = \PageModel::findByPk($objPage->id);
                }
            }
        }
        if ($objPage === null) {
            return;
        }
        $objPage->loadDetails();
        // Convert the language to a locale (see #5678)
        $strLanguage = str_replace('-', '_', $objPage->rootLanguage);
        if (isset($arrMeta[$strLanguage])) {
            if (\Input::post('title') == '' && !empty($arrMeta[$strLanguage]['title'])) {
                \Input::setPost('title', $arrMeta[$strLanguage]['title']);
            }
            if (\Input::post('alt') == '' && !empty($arrMeta[$strLanguage]['alt'])) {
                \Input::setPost('alt', $arrMeta[$strLanguage]['alt']);
            }
            if (\Input::post('caption') == '' && !empty($arrMeta[$strLanguage]['caption'])) {
                \Input::setPost('caption', $arrMeta[$strLanguage]['caption']);
            }
        }
    }