本文整理汇总了PHP中FilesModel::findByUuid方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesModel::findByUuid方法的具体用法?PHP FilesModel::findByUuid怎么用?PHP FilesModel::findByUuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilesModel
的用法示例。
在下文中一共展示了FilesModel::findByUuid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Generate the content element
*/
protected function compile()
{
/** @var \PageModel $objPage */
global $objPage;
if (substr($this->url, 0, 7) == 'mailto:') {
$this->url = \StringUtil::encodeEmail($this->url);
} else {
$this->url = ampersand($this->url);
}
$embed = explode('%s', $this->embed);
if ($this->linkTitle == '') {
$this->linkTitle = $this->url;
}
// Use an image instead of the title
if ($this->useImage && $this->singleSRC != '') {
$objModel = \FilesModel::findByUuid($this->singleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($this->singleSRC)) {
$this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
/** @var \FrontendTemplate|object $objTemplate */
$objTemplate = new \FrontendTemplate('ce_hyperlink_image');
$this->Template = $objTemplate;
$this->Template->setData($this->arrData);
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
$this->Template->linkTitle = specialchars($this->linkTitle);
}
}
if (strncmp($this->rel, 'lightbox', 8) !== 0 || $objPage->outputFormat == 'xhtml') {
$this->Template->attribute = ' rel="' . $this->rel . '"';
} else {
$this->Template->attribute = ' data-lightbox="' . substr($this->rel, 9, -1) . '"';
}
$this->Template->rel = $this->rel;
// Backwards compatibility
$this->Template->href = $this->url;
$this->Template->embed_pre = $embed[0];
$this->Template->embed_post = $embed[1];
$this->Template->link = $this->linkTitle;
$this->Template->linkTitle = specialchars($this->titleText ?: $this->linkTitle);
$this->Template->target = '';
// Override the link target
if ($this->target) {
$this->Template->target = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
}
// Unset the title attributes in the back end (see #6258)
if (TL_MODE == 'BE') {
$this->Template->title = '';
$this->Template->linkTitle = '';
}
}
示例2: storeFileMetaInformation
public function storeFileMetaInformation($varValue, DataContainer $dc)
{
if ($dc->activeRecord->singleSRC == $varValue) {
return $varValue;
}
$objFile = FilesModel::findByUuid($varValue);
if ($objFile !== null) {
$arrMeta = deserialize($objFile->meta);
if (!empty($arrMeta)) {
$objPage = $this->Database->prepare("SELECT * FROM tl_page WHERE id=(SELECT pid FROM " . ($dc->activeRecord->ptable ?: 'tl_article') . " WHERE id=?)")->execute($dc->activeRecord->pid);
if ($objPage->numRows) {
$objModel = new PageModel();
$objModel->setRow($objPage->row());
$objModel->loadDetails();
// Convert the language to a locale (see #5678)
$strLanguage = str_replace('-', '_', $objModel->rootLanguage);
if (isset($arrMeta[$strLanguage])) {
Input::setPost('alt', $arrMeta[$strLanguage]['title']);
Input::setPost('caption', $arrMeta[$strLanguage]['caption']);
}
}
}
}
return $varValue;
}
示例3: generate
/**
* Return if there are no files
* @return string
*/
public function generate()
{
// Use the home directory of the current user as file source
if ($this->useHomeDir && FE_USER_LOGGED_IN) {
$this->import('FrontendUser', 'User');
if ($this->User->assignDir && $this->User->homeDir) {
$this->folderSRC = $this->User->homeDir;
}
}
// Return if there is no folder defined
if (empty($this->folderSRC)) {
return '';
}
// Get the folders from the database
$this->objFolder = \FilesModel::findByUuid($this->folderSRC);
if ($this->objFolder === null) {
if (!\Validator::isUuid($this->folderSRC[0])) {
return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
return '';
}
$file = \Input::get('file', true);
// Send the file to the browser and do not send a 404 header (see #4632)
if ($file != '' && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', basename($file))) {
if (strpos(dirname($file), $this->objFolder->path) !== FALSE) {
\Controller::sendFileToBrowser($file);
}
}
return parent::generate();
}
示例4: generateStatic
public function generateStatic(array $arrOptions = array())
{
$this->arrOptions = array_merge($this->arrOptions, $arrOptions);
$arrData = $this->getData($this->arrOptions);
$strMarker = '';
switch ($arrData['type']) {
case 'MARKER':
if ($arrData['markerType'] == 'ICON') {
$arrData['iconSRC'] = \FilesModel::findByUuid($arrData['iconSRC'])->path;
return array('icon:' . rawurlencode(\Environment::get('base') . $arrData['iconSRC']) . '|shadow:false|' => $arrData['singleCoords']);
} else {
$strMarker = '&markers=' . $arrData['singleCoords'];
}
break;
case 'POLYLINE':
if (is_array($arrData['multiCoords']) && count($arrData['multiCoords']) > 0) {
$strMarker .= '&path=weight:' . $arrData['strokeWeight']['value'] . '|color:0x' . $arrData['strokeColor'] . dechex($arrData['strokeOpacity'] * 255);
foreach ($arrData['multiCoords'] as $coords) {
$strMarker .= '|' . str_replace(' ', '', $coords);
}
}
break;
case 'POLYGON':
if (is_array($arrData['multiCoords']) && count($arrData['multiCoords']) > 0) {
$strMarker .= '&path=weight:' . $arrData['strokeWeight']['value'] . '|color:0x' . $arrData['strokeColor'] . dechex($arrData['strokeOpacity'] * 255) . '|fillcolor:0x' . $arrData['fillColor'] . dechex($arrData['fillOpacity'] * 255);
foreach ($arrData['multiCoords'] as $coords) {
$strMarker .= '|' . str_replace(' ', '', $coords);
}
$strMarker .= '|' . str_replace(' ', '', $arrData['multiCoords'][0]);
}
break;
}
return $strMarker;
}
示例5: compile
/**
* Generate the content element
*/
protected function compile()
{
/** @var \PageModel $objPage */
global $objPage;
// Clean RTE output
if ($objPage->outputFormat == 'xhtml') {
$this->text = \StringUtil::toXhtml($this->text);
} else {
$this->text = \StringUtil::toHtml5($this->text);
}
$this->Template->text = \StringUtil::encodeEmail($this->text);
$this->Template->addImage = false;
// Add an image
if ($this->addImage && $this->singleSRC != '') {
$objModel = \FilesModel::findByUuid($this->singleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($this->singleSRC)) {
$this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
}
}
$classes = deserialize($this->mooClasses);
$this->Template->toggler = $classes[0] ?: 'toggler';
$this->Template->accordion = $classes[1] ?: 'accordion';
$this->Template->headlineStyle = $this->mooStyle;
$this->Template->headline = $this->mooHeadline;
}
示例6: compile
/**
* Generate the content element
*/
protected function compile()
{
/** @var \PageModel $objPage */
global $objPage;
// Clean the RTE output
if ($objPage->outputFormat == 'xhtml') {
$this->text = \String::toXhtml($this->text);
} else {
$this->text = \String::toHtml5($this->text);
}
// Add the static files URL to images
if (TL_FILES_URL != '') {
$path = \Config::get('uploadPath') . '/';
$this->text = str_replace(' src="' . $path, ' src="' . TL_FILES_URL . $path, $this->text);
}
$this->Template->text = \String::encodeEmail($this->text);
$this->Template->addImage = false;
// Add an image
if ($this->addImage && $this->singleSRC != '') {
$objModel = \FilesModel::findByUuid($this->singleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($this->singleSRC)) {
$this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
}
}
}
示例7: buildFileDir
protected function buildFileDir($objEntity = null)
{
if ($this->fileDir && ($objFolder = \FilesModel::findByUuid($this->fileDir))) {
$objMember = \FrontendUser::getInstance();
$strDir = $objFolder->path;
if ($this->useHomeDir && FE_USER_LOGGED_IN && $objMember->assignDir && $objMember->homeDir) {
$strDir = Files::getPathFromUuid($objMember->homeDir);
}
if (in_array('protected_homedirs', \ModuleLoader::getActive())) {
if ($this->useProtectedHomeDir && $objMember->assignProtectedDir && $objMember->protectedHomeDir) {
$strDir = Files::getPathFromUuid($objMember->protectedHomeDir);
}
}
if ($this->fileSubDirName) {
$strDir .= '/' . $this->fileSubDirName;
}
if (isset($GLOBALS['TL_HOOKS']['exporter_modifyFileDir']) && is_array($GLOBALS['TL_HOOKS']['exporter_modifyFileDir'])) {
foreach ($GLOBALS['TL_HOOKS']['exporter_modifyFileDir'] as $callback) {
$objCallback = \System::importStatic($callback[0]);
$strFixedDir = $objCallback->{$callback}[1]($strDir, $this);
$strDir = $strFixedDir ?: $strDir;
}
}
return $strDir;
}
throw new \Exception('No exporter fileDir defined!');
}
示例8: generateAddActions
public function generateAddActions($arrData, $id, Watchlist $objWatchlist)
{
global $objPage;
if ($objPage === null) {
return;
}
if (\Validator::isUuid($id)) {
$objFile = \FilesModel::findByUuid($id);
} else {
$objFile = \FilesModel::findBy('path', $id);
}
$objItem = new WatchlistItemModel();
$objItem->pid = Watchlist::getInstance()->getId();
$objItem->uuid = $objFile->uuid;
$objItem->pageID = $objPage->id;
$objItem->cid = $arrData['id'];
$objItem->type = $arrData['type'];
$objT = new \FrontendTemplate('watchlist_add_actions');
$objT->addHref = ampersand(\Controller::generateFrontendUrl($objPage->row()) . '?act=' . WATCHLIST_ACT_ADD . '&cid=' . $objItem->cid . '&type=' . $objItem->type . '&id=' . $strUuid . '&title=' . urlencode($objItem->getTitle()));
$objT->addTitle = $GLOBALS['TL_LANG']['WATCHLIST']['addTitle'];
$objT->addLink = $GLOBALS['TL_LANG']['WATCHLIST']['addLink'];
$objT->active = $objWatchlist->isInList($strUuid);
$objT->id = $strUuid;
return $objT->parse();
}
示例9: loadStoreDetails
/**
* @deprecated
*/
public static function loadStoreDetails(array $arrStore, $jumpTo = null)
{
//load country names
//@todo load only once. not every time.
$arrCountryNames = \System::getCountries();
//full localized country name
//@todo rename country to countrycode in database
$arrStore['countrycode'] = $arrStore['country'];
$arrStore['country'] = $arrCountryNames[$arrStore['countrycode']];
// generate jump to
if ($jumpTo) {
if (($objLocation = \PageModel::findByPk($jumpTo)) !== null) {
//@todo language parameter
$strStoreKey = !$GLOBALS['TL_CONFIG']['useAutoItem'] ? '/store/' : '/';
$strStoreValue = $arrStore['alias'];
$arrStore['href'] = \Controller::generateFrontendUrl($objLocation->row(), $strStoreKey . $strStoreValue);
}
}
// opening times
$arrStore['opening_times'] = deserialize($arrStore['opening_times']);
// store logo
//@todo change size and properties in module
if ($arrStore['logo']) {
if (($objLogo = \FilesModel::findByUuid($arrStore['logo'])) !== null) {
$arrLogo = $objLogo->row();
$arrMeta = deserialize($arrLogo['meta']);
$arrLogo['meta'] = $arrMeta[$GLOBALS['TL_LANGUAGE']];
$arrStore['logo'] = $arrLogo;
} else {
$arrStore['logo'] = null;
}
}
return $arrStore;
}
示例10: collectPageImages
/**
* Collect the images from page
* @param object
* @param object
*/
public function collectPageImages($objPage, $objLayout)
{
if (!$objLayout->socialImages) {
return;
}
// Initialize the array
if (!is_array($GLOBALS['SOCIAL_IMAGES'])) {
$GLOBALS['SOCIAL_IMAGES'] = array();
}
// Add the current page image
if ($objPage->socialImage && ($objImage = \FilesModel::findByUuid($objPage->socialImage)) !== null && is_file(TL_ROOT . '/' . $objImage->path)) {
array_unshift($GLOBALS['SOCIAL_IMAGES'], $objImage->path);
} else {
$objTrail = \PageModel::findParentsById($objPage->id);
if ($objTrail !== null) {
while ($objTrail->next()) {
// Add the image
if ($objTrail->socialImage && ($objImage = \FilesModel::findByUuid($objTrail->socialImage)) !== null && is_file(TL_ROOT . '/' . $objImage->path)) {
array_unshift($GLOBALS['SOCIAL_IMAGES'], $objImage->path);
break;
}
}
}
}
}
示例11: generate
/**
* Return if the file does not exist
*
* @return string
*/
public function generate()
{
// Return if there is no file
if ($this->singleSRC == '') {
return '';
}
$objFile = \FilesModel::findByUuid($this->singleSRC);
if ($objFile === null) {
if (!\Validator::isUuid($this->singleSRC)) {
return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
return '';
}
$allowedDownload = trimsplit(',', strtolower(\Config::get('allowedDownload')));
// Return if the file type is not allowed
if (!in_array($objFile->extension, $allowedDownload)) {
return '';
}
$file = \Input::get('file', true);
// Send the file to the browser and do not send a 404 header (see #4632)
if ($file != '' && $file == $objFile->path) {
\Controller::sendFileToBrowser($file);
}
$this->singleSRC = $objFile->path;
return parent::generate();
}
示例12: compile
/**
* Generate the module
*/
protected function compile()
{
$this->Template->size = '';
// Set the size
if ($this->playerSize != '') {
$size = deserialize($this->playerSize);
if (is_array($size)) {
$this->Template->size = ' width="' . $size[0] . '" height="' . $size[1] . '"';
}
}
$this->Template->poster = false;
// Optional poster
if ($this->posterSRC != '') {
if (($objFile = \FilesModel::findByUuid($this->posterSRC)) !== null) {
$this->Template->poster = $objFile->path;
}
}
// Check for SSL (see #6900)
$protocol = \Environment::get('ssl') ? 'https://' : 'http://';
$objFile = new \stdClass();
$objFile->mime = 'video/x-youtube';
$objFile->path = $protocol . 'www.youtube.com/watch?v=' . $this->youtube;
$this->Template->isVideo = true;
$this->Template->files = array($objFile);
$this->Template->autoplay = $this->autoplay;
}
示例13: parseIcon
/**
* Parse the icon and prepare it for the Template
* @param array
* @return array
*/
protected function parseIcon($icon)
{
$arrIcon = array();
//Check for image
if ($icon['iconfile'] != '') {
$objFile = \FilesModel::findByUuid($icon['iconfile']);
if ($objFile != null) {
if (is_file(TL_ROOT . '/' . $objFile->path)) {
$arrIcon['hasImage'] = true;
$arrIcon['img'] = $objFile->path;
}
}
}
//Add Foundation icon class
if (!$arrIcon['hasImage'] && $icon['iconclass'] != '') {
$arrIcon['iconclass'] = 'fi-' . $icon['iconclass'];
}
if ($icon['iconclass_custom'] != '') {
$arrIcon['class'] .= ' ' . $icon['iconclass_custom'];
}
if ($icon['icon_label'] != '') {
$arrIcon['label'] .= $icon['icon_label'];
}
$arrIcon['href'] = $icon['icon_href'];
return $arrIcon;
}
示例14: cb_parseTemplate
public function cb_parseTemplate(\Template &$objTemplate)
{
global $objPage;
if (strpos($objTemplate->getName(), 'news_') === 0) {
if ($objTemplate->source == 'singlefile') {
$modelFile = \FilesModel::findByUuid($objTemplate->singlefileSRC);
try {
if ($modelFile === null) {
throw new \Exception("no file");
}
$allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload']));
if (!in_array($modelFile->extension, $allowedDownload)) {
throw new Exception("download not allowed by extension");
}
$objFile = new \File($modelFile->path, true);
$strHref = \System::urlEncode($objFile->value);
} catch (\Exception $e) {
$strHref = "";
}
$target = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
$objTemplate->more = sprintf('<a %s href="%s" title="%s">%s</a>', $target, $strHref, specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['open'], $objFile->basename)), $GLOBALS['TL_LANG']['MSC']['more']);
$objTemplate->linkHeadline = sprintf('<a %s href="%s" title="%s">%s</a>', $target, $strHref, specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['open'], $objFile->basename)), $objTemplate->headline);
}
}
}
示例15: getPictureFromDB
public function getPictureFromDB($strTable, $strColumn, $strWhereParam, $strObjID)
{
$query = "SELECT " . $strColumn . " FROM " . $strTable . "WHERE " . $strWhereParam . "=?";
$objPicture = $this->Database->prepare($query)->execute($strObjID);
$objFile = \FilesModel::findByUuid($objPicture->{$strColumn});
return $objFile->path;
}