本文整理汇总了PHP中ContentModel::countPublishedByPidAndTable方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentModel::countPublishedByPidAndTable方法的具体用法?PHP ContentModel::countPublishedByPidAndTable怎么用?PHP ContentModel::countPublishedByPidAndTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentModel
的用法示例。
在下文中一共展示了ContentModel::countPublishedByPidAndTable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseArticle
/**
* Parse an item and return it as string
*
* @param \NewsModel $objArticle
* @param boolean $blnAddArchive
* @param string $strClass
* @param integer $intCount
*
* @return string
*/
protected function parseArticle($objArticle, $blnAddArchive = false, $strClass = '', $intCount = 0)
{
/** @var \PageModel $objPage */
global $objPage;
/** @var \FrontendTemplate|object $objTemplate */
$objTemplate = new \FrontendTemplate($this->news_template);
$objTemplate->setData($objArticle->row());
$objTemplate->class = ($objArticle->cssClass != '' ? ' ' . $objArticle->cssClass : '') . $strClass;
$objTemplate->newsHeadline = $objArticle->headline;
$objTemplate->subHeadline = $objArticle->subheadline;
$objTemplate->hasSubHeadline = $objArticle->subheadline ? true : false;
$objTemplate->linkHeadline = $this->generateLink($objArticle->headline, $objArticle, $blnAddArchive);
$objTemplate->more = $this->generateLink($GLOBALS['TL_LANG']['MSC']['more'], $objArticle, $blnAddArchive, true);
$objTemplate->link = $this->generateNewsUrl($objArticle, $blnAddArchive);
$objTemplate->archive = $objArticle->getRelated('pid');
$objTemplate->count = $intCount;
// see #5708
$objTemplate->text = '';
$objTemplate->hasText = false;
$objTemplate->hasTeaser = false;
// Clean the RTE output
if ($objArticle->teaser != '') {
$objTemplate->hasTeaser = true;
if ($objPage->outputFormat == 'xhtml') {
$objTemplate->teaser = \StringUtil::toXhtml($objArticle->teaser);
} else {
$objTemplate->teaser = \StringUtil::toHtml5($objArticle->teaser);
}
$objTemplate->teaser = \StringUtil::encodeEmail($objTemplate->teaser);
}
// Display the "read more" button for external/article links
if ($objArticle->source != 'default') {
$objTemplate->text = true;
$objTemplate->hasText = true;
} else {
$id = $objArticle->id;
$objTemplate->text = function () use($id) {
$strText = '';
$objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_news');
if ($objElement !== null) {
while ($objElement->next()) {
$strText .= $this->getContentElement($objElement->current());
}
}
return $strText;
};
$objTemplate->hasText = \ContentModel::countPublishedByPidAndTable($objArticle->id, 'tl_news') > 0;
}
$arrMeta = $this->getMetaFields($objArticle);
// Add the meta information
$objTemplate->date = $arrMeta['date'];
$objTemplate->hasMetaFields = !empty($arrMeta);
$objTemplate->numberOfComments = $arrMeta['ccount'];
$objTemplate->commentCount = $arrMeta['comments'];
$objTemplate->timestamp = $objArticle->date;
$objTemplate->author = $arrMeta['author'];
$objTemplate->datetime = date('Y-m-d\\TH:i:sP', $objArticle->date);
$objTemplate->addImage = false;
// Add an image
if ($objArticle->addImage && $objArticle->singleSRC != '') {
$objModel = \FilesModel::findByUuid($objArticle->singleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($objArticle->singleSRC)) {
$objTemplate->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
// Do not override the field now that we have a model registry (see #6303)
$arrArticle = $objArticle->row();
// Override the default image size
if ($this->imgSize != '') {
$size = deserialize($this->imgSize);
if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
$arrArticle['size'] = $this->imgSize;
}
}
$arrArticle['singleSRC'] = $objModel->path;
$this->addImageToTemplate($objTemplate, $arrArticle);
}
}
$objTemplate->enclosure = array();
// Add enclosures
if ($objArticle->addEnclosure) {
$this->addEnclosuresToTemplate($objTemplate, $objArticle->row());
}
// HOOK: add custom logic
if (isset($GLOBALS['TL_HOOKS']['parseArticles']) && is_array($GLOBALS['TL_HOOKS']['parseArticles'])) {
foreach ($GLOBALS['TL_HOOKS']['parseArticles'] as $callback) {
$this->import($callback[0]);
$this->{$callback[0]}->{$callback[1]}($objTemplate, $objArticle->row(), $this);
}
//.........这里部分代码省略.........
示例2: compile
//.........这里部分代码省略.........
$objTemplate->class = $objEvent->cssClass != '' ? ' ' . $objEvent->cssClass : '';
$objTemplate->recurring = $recurring;
$objTemplate->until = $until;
$objTemplate->locationLabel = $GLOBALS['TL_LANG']['MSC']['location'];
$objTemplate->details = '';
$objTemplate->hasDetails = false;
$objTemplate->hasTeaser = false;
// Clean the RTE output
if ($objEvent->teaser != '') {
$objTemplate->hasTeaser = true;
if ($objPage->outputFormat == 'xhtml') {
$objTemplate->teaser = \StringUtil::toXhtml($objEvent->teaser);
} else {
$objTemplate->teaser = \StringUtil::toHtml5($objEvent->teaser);
}
$objTemplate->teaser = \StringUtil::encodeEmail($objTemplate->teaser);
}
// Display the "read more" button for external/article links
if ($objEvent->source != 'default') {
$objTemplate->details = true;
$objTemplate->hasDetails = true;
} else {
$id = $objEvent->id;
$objTemplate->details = function () use($id) {
$strDetails = '';
$objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_calendar_events');
if ($objElement !== null) {
while ($objElement->next()) {
$strDetails .= $this->getContentElement($objElement->current());
}
}
return $strDetails;
};
$objTemplate->hasDetails = \ContentModel::countPublishedByPidAndTable($id, 'tl_calendar_events') > 0;
}
$objTemplate->addImage = false;
// Add an image
if ($objEvent->addImage && $objEvent->singleSRC != '') {
$objModel = \FilesModel::findByUuid($objEvent->singleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($objEvent->singleSRC)) {
$objTemplate->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
// Do not override the field now that we have a model registry (see #6303)
$arrEvent = $objEvent->row();
// Override the default image size
if ($this->imgSize != '') {
$size = deserialize($this->imgSize);
if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
$arrEvent['size'] = $this->imgSize;
}
}
$arrEvent['singleSRC'] = $objModel->path;
$this->addImageToTemplate($objTemplate, $arrEvent);
}
}
$objTemplate->enclosure = array();
// Add enclosures
if ($objEvent->addEnclosure) {
$this->addEnclosuresToTemplate($objTemplate, $objEvent->row());
}
$this->Template->event = $objTemplate->parse();
// HOOK: comments extension required
if ($objEvent->noComments || !in_array('comments', \ModuleLoader::getActive())) {
$this->Template->allowComments = false;
示例3: compile
protected function compile()
{
if ($this->objConfig->header) {
$this->Template->showHeader = true;
}
$id = $this->id;
$this->Template->body = function () use($id) {
$strText = '';
$objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_modal');
if ($objElement !== null) {
while ($objElement->next()) {
$strContent = $this->getContentElement($objElement->current());
// HOOK: add custom logic
if (isset($GLOBALS['TL_HOOKS']['getModalContentElement']) && is_array($GLOBALS['TL_HOOKS']['getModalContentElement'])) {
foreach ($GLOBALS['TL_HOOKS']['getModalContentElement'] as $callback) {
$strContent = static::importStatic($callback[0])->{$callback[1]}($objElement->current(), $strContent, $this->Template, $this->objModel, $this->objConfig, $this);
}
}
$strText .= $strContent;
}
}
return $strText;
};
$this->Template->hasBody = \ContentModel::countPublishedByPidAndTable($this->id, 'tl_modal') > 0;
if ($this->objConfig->footer && $this->addFooter) {
$this->Template->showFooter = true;
}
}
示例4: addEvent
//.........这里部分代码省略.........
$strDay = '';
}
$strTime = '';
if ($objEvents->addTime) {
if ($span > 0) {
$strDate = \Date::parse($objPage->datimFormat, $intStart) . ' – ' . \Date::parse($objPage->datimFormat, $intEnd);
} elseif ($intStart == $intEnd) {
$strTime = \Date::parse($objPage->timeFormat, $intStart);
} else {
$strTime = \Date::parse($objPage->timeFormat, $intStart) . ' – ' . \Date::parse($objPage->timeFormat, $intEnd);
}
}
$until = '';
$recurring = '';
// Recurring event
if ($objEvents->recurring) {
$arrRange = deserialize($objEvents->repeatEach);
$strKey = 'cal_' . $arrRange['unit'];
$recurring = sprintf($GLOBALS['TL_LANG']['MSC'][$strKey], $arrRange['value']);
if ($objEvents->recurrences > 0) {
$until = sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], \Date::parse($objPage->dateFormat, $objEvents->repeatEnd));
}
}
// Store raw data
$arrEvent = $objEvents->row();
// Overwrite some settings
$arrEvent['date'] = $strDate;
$arrEvent['time'] = $strTime;
$arrEvent['datetime'] = $objEvents->addTime ? date('Y-m-d\\TH:i:sP', $intStart) : date('Y-m-d', $intStart);
$arrEvent['day'] = $strDay;
$arrEvent['month'] = $strMonth;
$arrEvent['parent'] = $intCalendar;
$arrEvent['calendar'] = $objEvents->getRelated('pid');
$arrEvent['link'] = $objEvents->title;
$arrEvent['target'] = '';
$arrEvent['title'] = specialchars($objEvents->title, true);
$arrEvent['href'] = $this->generateEventUrl($objEvents);
$arrEvent['class'] = $objEvents->cssClass != '' ? ' ' . $objEvents->cssClass : '';
$arrEvent['recurring'] = $recurring;
$arrEvent['until'] = $until;
$arrEvent['begin'] = $intStart;
$arrEvent['end'] = $intEnd;
$arrEvent['details'] = '';
$arrEvent['hasDetails'] = false;
$arrEvent['hasTeaser'] = false;
// Override the link target
if ($objEvents->source == 'external' && $objEvents->target) {
$arrEvent['target'] = ' target="_blank"';
}
// Clean the RTE output
if ($arrEvent['teaser'] != '') {
$arrEvent['hasTeaser'] = true;
$arrEvent['teaser'] = \StringUtil::toHtml5($arrEvent['teaser']);
$arrEvent['teaser'] = \StringUtil::encodeEmail($arrEvent['teaser']);
}
// Display the "read more" button for external/article links
if ($objEvents->source != 'default') {
$arrEvent['details'] = true;
$arrEvent['hasDetails'] = true;
} else {
$id = $objEvents->id;
$arrEvent['details'] = function () use($id) {
$strDetails = '';
$objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_calendar_events');
if ($objElement !== null) {
while ($objElement->next()) {
$strDetails .= $this->getContentElement($objElement->current());
}
}
return $strDetails;
};
$arrEvent['hasDetails'] = \ContentModel::countPublishedByPidAndTable($id, 'tl_calendar_events') > 0;
}
// Get todays start and end timestamp
if ($this->intTodayBegin === null) {
$this->intTodayBegin = strtotime('00:00:00');
}
if ($this->intTodayEnd === null) {
$this->intTodayEnd = strtotime('23:59:59');
}
// Mark past and upcoming events (see #3692)
if ($intEnd < $this->intTodayBegin) {
$arrEvent['class'] .= ' bygone';
} elseif ($intStart > $this->intTodayEnd) {
$arrEvent['class'] .= ' upcoming';
} else {
$arrEvent['class'] .= ' current';
}
$this->arrEvents[$intKey][$intStart][] = $arrEvent;
// Multi-day event
for ($i = 1; $i <= $span && $intDate <= $intLimit; $i++) {
// Only show first occurrence
if ($this->cal_noSpan && $intDate >= $intBegin) {
break;
}
$intDate = strtotime('+ 1 day', $intDate);
$intNextKey = date('Ymd', $intDate);
$this->arrEvents[$intNextKey][$intDate][] = $arrEvent;
}
}
示例5: addEvent
//.........这里部分代码省略.........
} elseif ($intStart == $intEnd) {
$strTime = \Date::parse($objPage->timeFormat, $intStart);
} else {
$strTime = \Date::parse($objPage->timeFormat, $intStart) . ' – ' . \Date::parse($objPage->timeFormat, $intEnd);
}
}
$until = '';
$recurring = '';
// Recurring event
if ($objEvents->recurring) {
$arrRange = deserialize($objEvents->repeatEach);
if (is_array($arrRange) && isset($arrRange['unit']) && isset($arrRange['value'])) {
$strKey = 'cal_' . $arrRange['unit'];
$recurring = sprintf($GLOBALS['TL_LANG']['MSC'][$strKey], $arrRange['value']);
if ($objEvents->recurrences > 0) {
$until = sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], \Date::parse($objPage->dateFormat, $objEvents->repeatEnd));
}
}
}
// Store raw data
$arrEvent = $objEvents->row();
// Overwrite some settings
$arrEvent['date'] = $strDate;
$arrEvent['time'] = $strTime;
$arrEvent['datetime'] = $objEvents->addTime ? date('Y-m-d\\TH:i:sP', $intStart) : date('Y-m-d', $intStart);
$arrEvent['day'] = $strDay;
$arrEvent['month'] = $strMonth;
$arrEvent['parent'] = $intCalendar;
$arrEvent['calendar'] = $objEvents->getRelated('pid');
$arrEvent['link'] = $objEvents->title;
$arrEvent['target'] = '';
$arrEvent['title'] = specialchars($objEvents->title, true);
$arrEvent['href'] = $this->generateEventUrl($objEvents, $strUrl);
$arrEvent['class'] = $objEvents->cssClass != '' ? ' ' . $objEvents->cssClass : '';
$arrEvent['recurring'] = $recurring;
$arrEvent['until'] = $until;
$arrEvent['begin'] = $intStart;
$arrEvent['end'] = $intEnd;
$arrEvent['details'] = '';
$arrEvent['hasDetails'] = false;
$arrEvent['hasTeaser'] = false;
// Override the link target
if ($objEvents->source == 'external' && $objEvents->target) {
$arrEvent['target'] = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
}
// Clean the RTE output
if ($arrEvent['teaser'] != '') {
$arrEvent['hasTeaser'] = true;
if ($objPage->outputFormat == 'xhtml') {
$arrEvent['teaser'] = \StringUtil::toXhtml($arrEvent['teaser']);
} else {
$arrEvent['teaser'] = \StringUtil::toHtml5($arrEvent['teaser']);
}
$arrEvent['teaser'] = \StringUtil::encodeEmail($arrEvent['teaser']);
}
// Display the "read more" button for external/article links
if ($objEvents->source != 'default') {
$arrEvent['details'] = true;
$arrEvent['hasDetails'] = true;
} else {
$id = $objEvents->id;
$arrEvent['details'] = function () use($id) {
$strDetails = '';
$objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_calendar_events');
if ($objElement !== null) {
while ($objElement->next()) {
$strDetails .= $this->getContentElement($objElement->current());
}
}
return $strDetails;
};
$arrEvent['hasDetails'] = \ContentModel::countPublishedByPidAndTable($id, 'tl_calendar_events') > 0;
}
// Get todays start and end timestamp
if ($this->intTodayBegin === null) {
$this->intTodayBegin = strtotime('00:00:00');
}
if ($this->intTodayEnd === null) {
$this->intTodayEnd = strtotime('23:59:59');
}
// Mark past and upcoming events (see #3692)
if ($intEnd < $this->intTodayBegin) {
$arrEvent['class'] .= ' bygone';
} elseif ($intStart > $this->intTodayEnd) {
$arrEvent['class'] .= ' upcoming';
} else {
$arrEvent['class'] .= ' current';
}
$this->arrEvents[$intKey][$intStart][] = $arrEvent;
// Multi-day event
for ($i = 1; $i <= $span && $intDate <= $intLimit; $i++) {
// Only show first occurrence
if ($this->cal_noSpan) {
break;
}
$intDate = strtotime('+ 1 day', $intDate);
$intNextKey = date('Ymd', $intDate);
$this->arrEvents[$intNextKey][$intDate][] = $arrEvent;
}
}