本文整理汇总了PHP中Frontend::addImageToTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP Frontend::addImageToTemplate方法的具体用法?PHP Frontend::addImageToTemplate怎么用?PHP Frontend::addImageToTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frontend
的用法示例。
在下文中一共展示了Frontend::addImageToTemplate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addTeaserImage
/**
* Add teaser image to template
* @param array
* @param array
* @param integer
* @param integer
* @return array
* called from getAllEvents HOOK
*/
public function addTeaserImage($arrEvents, $arrCalendars, $intStart, $intEnd, $objModule)
{
$arrReturn = array();
foreach ($arrEvents as $date => $startDate) {
foreach ($startDate as $time => $events) {
foreach ($events as $i => $event) {
if ($event['teaser_addImage']) {
// overwrite image size if set in module
$size = deserialize($event['teaser_size']);
if ($objModule->size != '') {
$size = deserialize($objModule->imgSize);
}
// fetch teaser image
$objFile = \FilesModel::findByPk($event['teaser_singleSRC']);
if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) {
return;
}
$event['teaser_singleSRC'] = $objFile->path;
// create psydo template object to call addImageToTemplate Function
$objTemplate = new \FrontendTemplate($objModule->cal_template);
$arrTeaserImage = array('singleSRC' => $event['teaser_singleSRC'], 'size' => $event['teaser_size'], 'alt' => $event['teaser_alt'], 'imageUrl' => $event['teaser_imageUrl'], 'fullsize' => $event['teaser_fullsize'], 'floating' => $event['teaser_floating'], 'imagemargin' => $event['teaser_imagemargin'], 'linkedimage' => $event['teaser_linkedimage']);
parent::addImageToTemplate($objTemplate, $arrTeaserImage);
// set vars
$event['teaser_singleSRC'] = $objTemplate->singleSRC;
$event['teaser_src'] = $objTemplate->src;
$event['teaser_href'] = $objTemplate->href;
$event['teaser_alt'] = $objTemplate->alt;
$event['teaser_title'] = $objTemplate->title;
$event['teaser_imageUrl'] = $objTemplate->imageUrl;
$event['teaser_fullsize'] = $objTemplate->fullsize;
$event['teaser_float'] = $objTemplate->float;
$event['teaser_floatClass'] = $objTemplate->floatClass;
$event['teaser_margin'] = $objTemplate->margin;
$event['teaser_imgSize'] = $objTemplate->imgSize;
$event['teaser_attributes'] = $objTemplate->attributes;
$event['teaser_addBefore'] = $objTemplate->addBefore;
// Link to post, overwrite all other link settings
if ($event['teaser_linkedimage'] && TL_MODE == "FE") {
$event['teaser_href'] = $event['href'];
$event['teaser_attributes'] = $objTemplate->fullsize ? LINK_NEW_WINDOW : '';
}
// remove temp. template
unset($objTemplate);
}
// set
$arrReturn[$date][$time][$i] = $event;
}
}
}
$arrEvents = $arrReturn;
return $arrEvents;
}
示例2: __construct
/**
* Add image to template
* @param object
* @param boolean
*/
public function __construct($objTemplate, $isCE = false)
{
$articleHref = $objTemplate->href;
$arrImage = array();
// handle include articles
if ($isCE) {
$objDatabase = \Database::getInstance();
$objArticle = $objDatabase->prepare("SELECT * FROM tl_article WHERE id=?")->limit(1)->execute($objTemplate->article);
if (!$objArticle->addImage) {
return;
}
$arrImage = $objArticle->row();
// fetch teaser image
$objFile = \FilesModel::findByPk($arrImage['singleSRC']);
if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) {
return;
}
$arrImage['singleSRC'] = $objFile->path;
}
// regular article
if (!$isCE && $objTemplate->addImage) {
// fetch teaser image
$objFile = \FilesModel::findByPk($objTemplate->singleSRC);
if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) {
return;
}
$objTemplate->singleSRC = $objFile->path;
$arrImage = array('addImage' => $objTemplate->addImage, 'singleSRC' => $objTemplate->singleSRC, 'alt' => $objTemplate->alt, 'size' => $objTemplate->size, 'imagemargin' => $objTemplate->imagemargin, 'floating' => $objTemplate->floating, 'fullsize' => $objTemplate->fullsize, 'caption' => $objTemplate->caption, 'linkedimage' => $objTemplate->linkedimage, 'imageUrl' => $objTemplate->imageUrl);
}
if (count($arrImage) < 1) {
return;
}
// add image to template
parent::addImageToTemplate($objTemplate, $arrImage);
$objTemplate->imageHref = $arrImage['imageUrl'];
$objTemplate->href = $articleHref;
// prepare for lightbox
if ($arrImage['fullsize'] && !$arrImage['linkedimage'] && !$arrImage['imageUrl']) {
$objTemplate->imageHref = $arrImage['singleSRC'];
}
// link to article
if ($arrImage['linkedimage'] && TL_MODE == 'FE') {
$objTemplate->imageHref = $articleHref;
$objTemplate->attributes = $objTemplate->fullsize ? LINK_NEW_WINDOW : '';
}
}
示例3: addTeaserImage
/**
* Insert a teaser image to the template
* @param object
* @param array
* @return void
* called from parseArticles HOOK
*/
public function addTeaserImage($objTemplate, $row)
{
if (!$objTemplate->teaser_addImage) {
return;
}
// original image setting
$addNewsImage = $objTemplate->addImage;
$addTeaserImage = $objTemplate->teaser_addImage;
// overwrite image sizes if set in module
if ($row['size'] != '') {
$objTemplate->size = $row['size'];
$objTemplate->teaser_size = $row['size'];
}
// teaser image
if ($addTeaserImage) {
// fetch teaser image
$objFile = \FilesModel::findByPk($objTemplate->teaser_singleSRC);
if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) {
return;
}
$objTemplate->teaser_singleSRC = $objFile->path;
$arrTeaserImage = array('singleSRC' => $objTemplate->teaser_singleSRC, 'size' => $objTemplate->teaser_size, 'alt' => $objTemplate->teaser_alt, 'imageUrl' => $objTemplate->teaser_imageUrl, 'fullsize' => $objTemplate->teaser_fullsize, 'floating' => $objTemplate->teaser_floating, 'imagemargin' => $objTemplate->teaser_imagemargin, 'linkedimage' => $objTemplate->teaser_linkedimage);
}
// news image
if ($addNewsImage) {
// store news image data
$arrNewsImage = array('singleSRC' => $objTemplate->singleSRC, 'size' => $objTemplate->size, 'alt' => $objTemplate->alt, 'imageUrl' => $objTemplate->imageUrl, 'fullsize' => $objTemplate->fullsize, 'floating' => $objTemplate->floating, 'imagemargin' => $objTemplate->imagemaring);
}
// Add teaser image.
if ($addTeaserImage) {
//Use contao internal function. (overwrites news image values)
parent::addImageToTemplate($objTemplate, $arrTeaserImage);
// set template vars
$objTemplate->teaser_imgSize = $objTemplate->imgSize;
$objTemplate->teaser_src = $objTemplate->src;
$objTemplate->teaser_attributes = $objTemplate->attributes;
$objTemplate->teaser_addBefore = $objTemplate->addBefore;
$objTemplate->teaser_margin = $objTemplate->margin;
$objTemplate->teaser_title = $objTemplate->title;
$objTemplate->teaser_alt = $objTemplate->alt;
$objTemplate->teaser_href = $objTemplate->href;
$objTemplate->teaser_float = $objTemplate->float;
$objTemplate->teaser_floatClass = $objTemplate->floatClass;
// link to post
if ($objTemplate->teaser_linkedimage && TL_MODE == 'FE') {
$objTemplate->teaser_href = $objTemplate->link;
$objTemplate->teaser_attributes = $objTemplate->teaser_fullsize ? LINK_NEW_WINDOW : '';
}
}
// Add news image.
if ($addNewsImage) {
// restore news image in template
parent::addImageToTemplate($objTemplate, $arrNewsImage);
}
$objTemplate->addImage = $addNewsImage;
$objTemplate->teaser_addImage = $addTeaserImage;
}