本文整理汇总了PHP中ContentModel类的典型用法代码示例。如果您正苦于以下问题:PHP ContentModel类的具体用法?PHP ContentModel怎么用?PHP ContentModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContentModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: home
public static function home()
{
require_once 'Goals.model.php';
require_once 'Content.model.php';
$contentMdl = new ContentModel();
$data = array('templates' => array('header.html', 'menu.html', 'searchForm.html', 'content.html', 'footer.html'), 'content' => $contentMdl->viewContent(), 'userID' => $_SESSION['userID'], 'user' => $_SESSION['username'], 'userLevel' => $_SESSION['userLevel'], 'viewRating' => $contentMdl->viewRating());
return $data;
}
示例2: search
public static function search()
{
// sends info to search method in content.model on what to search for
require_once 'Content.model.php';
$contentMdl = new ContentModel();
$data = array('templates' => array('header.html', 'menu.html', 'searchForm.html', 'content.html', 'footer.html'), 'content' => $contentMdl->searchContent($_POST['search'], $_POST['searchSubject'], $_POST['searchYear']), 'userLevel' => $_SESSION['userLevel'], 'user' => $_SESSION['username'], 'userID' => $_SESSION['userID']);
return $data;
}
示例3: __construct
/**
* Initialize the object
*
* @param ContentModel|ModuleModel|FormModel $objElement
* @param string $strColumn
*/
public function __construct($objElement, $strColumn = 'main')
{
parent::__construct();
// Store the parent element (see #4556)
if ($objElement instanceof Model) {
$this->objParent = $objElement;
} elseif ($objElement instanceof Model\Collection) {
$this->objParent = $objElement->current();
}
if ($this->strKey == '' || $this->strTable == '') {
return;
}
/** @var Model $strModelClass */
$strModelClass = \Model::getClassFromTable($this->strTable);
// Load the model
if (class_exists($strModelClass)) {
$objHybrid = $strModelClass::findByPk($objElement->{$this->strKey});
if ($objHybrid === null) {
return;
}
$this->objModel = $objHybrid;
} else {
$objHybrid = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE id=?")->limit(1)->execute($objElement->{$this->strKey});
if ($objHybrid->numRows < 1) {
return;
}
}
$cssID = array();
$this->arrData = $objHybrid->row();
// Get the CSS ID from the parent element (!)
$this->cssID = deserialize($objElement->cssID, true);
if (isset($objHybrid->attributes)) {
$cssID = deserialize($objHybrid->attributes, true);
}
// Override the CSS ID (see #305)
if (!empty($this->cssID[0])) {
$cssID[0] = $this->cssID[0];
}
// Merge the CSS classes (see #6011)
if (!empty($this->cssID[1])) {
$cssID[1] = trim($cssID[1] . ' ' . $this->cssID[1]);
}
$this->cssID = $cssID;
$this->typePrefix = $objElement->typePrefix;
$arrHeadline = deserialize($objElement->headline);
$this->headline = is_array($arrHeadline) ? $arrHeadline['value'] : $arrHeadline;
$this->hl = is_array($arrHeadline) ? $arrHeadline['unit'] : 'h1';
$this->strColumn = $strColumn;
}
示例4: del
public function del()
{
if (IS_POST) {
$uid = Q('uid', 0, 'intval');
//删除文章
if (Q('post.delcontent')) {
$ModelCache = cache('model');
foreach ($ModelCache as $model) {
$contentModel = ContentModel::getInstance($model['mid']);
$contentModel->where(array('uid' => $uid))->del();
}
}
//删除评论
if (Q('post.delcomment')) {
M('comment')->where(array('uid' => $uid))->del();
}
//删除附件
if (Q('post.delupload')) {
M('upload')->where(array('uid' => $uid))->del();
}
//删除用户
M('user')->del($uid);
$this->success('删除成功...');
} else {
$uid = Q("uid", 0, "intval");
$field = M('user')->find($uid);
$this->assign('field', $field);
$this->display();
}
}
示例5: createContentElements
protected function createContentElements(&$objItem)
{
if ($objItem->tl_content) {
// need to wrap <p> around text for contao
$tidyConfig = array('enclose-text' => true, 'drop-font-tags' => true, 'drop-proprietary-attributes' => true, 'quote-ampersand' => true, 'clean' => false);
$bodyText = '<!DOCTYPE html><head><title></title></head><body>' . $objItem->tl_content . '</body></html>';
// $bodyText = $this->convert_external_link_tags($bodyText);
// $bodyText = $this->convert_internal_link_tags($bodyText);
$bodyText = $this->nl2p($bodyText);
$tidy = new \tidy();
$tidy->parseString($bodyText, $tidyConfig, $GLOBALS['TL_CONFIG']['dbCharset']);
$body = $tidy->body();
$objContent = new \ContentModel();
$objContent->text = trim(str_replace(array('<body>', '</body>'), '', $body));
$objContent->text = preg_replace("/<img[^>]+\\>/i", "", $objContent->text);
// strip images
// create links from text
$objContent->text = preg_replace('!(\\s|^)((https?://|www\\.)+[a-z0-9_./?=&-]+)!i', ' <a href="http://$2" target="_blank">$2</a>', $objContent->text);
// replace <b> by <strong>
$objContent->text = preg_replace('!<b(.*?)>(.*?)</b>!i', '<strong>$2</strong>', $objContent->text);
// replace emails with inserttags
$objContent->text = preg_replace('/([A-Z0-9._%+-]+)@([A-Z0-9.-]+)\\.([A-Z]{2,4})(\\((.+?)\\))?/i', "{{email::\$1@\$2.\$3}}", $objContent->text);
// strip not allowed tags
$objContent->text = strip_tags($objContent->text, \Config::get('allowedTags'));
$objContent->text = $this->stripAttributes($objContent->text, array('style', 'class', 'id'));
$objContent->ptable = static::$strTable;
$objContent->pid = $objItem->id;
$objContent->sorting = 16;
$objContent->tstamp = time();
$objContent->type = 'text';
$objContent->save();
}
}
示例6: listNewsletterArticles
/**
* Add the type of input field
* @param array
* @return string
*/
public function listNewsletterArticles($arrRow)
{
$strStats = '';
$strContents = '';
$objContents = \ContentModel::findPublishedByPidAndTable($arrRow['id'], 'tl_newsletter');
if (!is_null($objContents)) {
foreach ($objContents as $objContent) {
$strContents .= $this->getContentElement($objContent->id) . '<hr>';
}
}
$intTotal = $arrRow['recipients'] + $arrRow['rejected'];
// $intTracked = NewsletterContent\Models\NewsletterTrackingModel::countTrackedByPid($arrRow['id']);
$objTracked = NewsletterContent\Models\NewsletterTrackingModel::findTrackedInteractionsByPid($arrRow['id']);
$intTracked = !is_null($objTracked) ? $objTracked->count() : 0;
$intPercent = @round($intTracked / $intTotal * 100);
$strStats = sprintf($GLOBALS['TL_LANG']['tl_newsletter']['sentTo'], $arrRow['recipients'], strval($intTotal), strval($intTracked), strval($intPercent));
return '
<div class="cte_type ' . ($arrRow['sent'] && $arrRow['date'] ? 'published' : 'unpublished') . '"><strong>' . $arrRow['subject'] . '</strong> - ' . ($arrRow['sent'] && $arrRow['date'] ? sprintf($GLOBALS['TL_LANG']['tl_newsletter']['sentOn'], Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $arrRow['date'])) . '<br>' . $strStats : $GLOBALS['TL_LANG']['tl_newsletter']['notSent']) . '</div>
<div class="limit_height' . (!$GLOBALS['TL_CONFIG']['doNotCollapse'] ? ' h128' : '') . '">
' . (!$arrRow['sendText'] && strlen($strContents) ? '
' . $strContents : '') . '
' . nl2br_html5($arrRow['text']) . '
</div>' . "\n";
return '<div class="tl_content_left">' . $arrRow['subject'] . ' <span style="color:#b3b3b3;padding-left:3px">[' . $arrRow['senderName'] . ' <' . $arrRow['sender'] . '>]</span></div>';
}
示例7: compile
/**
* compile wrapper element
*/
protected function compile()
{
// get included elements
if ($this->objWrapper->getType() == ContentWrapper\Model::TYPE_START) {
$this->Template->count = ContentWrapper\Repository::countRelatedElements($this->objWrapper);
$cssID = $this->cssID;
if ($cssID[0] == '') {
$cssID[0] = sprintf($this->strIdentifier, $this->id);
$this->cssID = $cssID;
}
} else {
$start = \ContentModel::findByPk($this->bootstrap_parentId);
if ($start !== null) {
$start = new Attributes($start);
$start->registerNamespaceAttributes($this->arrBootstrapAttributes);
$start->cssID = deserialize($start->cssID, true);
$this->Template->start = $start;
if ($start->cssID[0] == '') {
$cssID = $start->cssID;
$cssID[0] = sprintf($this->strIdentifier, $start->id);
$this->cssID = $cssID;
} else {
$this->cssID = $start->cssID;
}
}
}
$this->Template->identifier = $this->cssID[0];
}
示例8: generate
/**
* Parse the template
*
* @return string
*/
public function generate()
{
$objElement = \ContentModel::findByPk($this->cteAlias);
if ($objElement === null) {
return '';
}
$strClass = static::findClass($objElement->type);
if (!class_exists($strClass)) {
return '';
}
$objElement->origId = $objElement->id;
$objElement->id = $this->id;
$objElement->typePrefix = 'ce_';
/** @var ContentElement $objElement */
$objElement = new $strClass($objElement);
$cssID = deserialize($objElement->cssID, true);
// Override the CSS ID (see #305)
if (!empty($this->cssID[0])) {
$cssID[0] = $this->cssID[0];
}
// Merge the CSS classes (see #6011)
if (!empty($this->cssID[1])) {
$cssID[1] = trim($cssID[1] . ' ' . $this->cssID[1]);
}
$objElement->cssID = $cssID;
return $objElement->generate();
}
示例9: generate
/**
* Parse the template
*
* @return string
*/
public function generate()
{
$objElement = \ContentModel::findByPk($this->cteAlias);
if ($objElement === null) {
return '';
}
$strClass = static::findClass($objElement->type);
if (!class_exists($strClass)) {
return '';
}
$objElement->origId = $objElement->id;
$objElement->id = $this->id;
$objElement->typePrefix = 'ce_';
/** @var \ContentElement $objElement */
$objElement = new $strClass($objElement);
// create new cssID array
$cssID = array();
// set the ID
$cssID[0] = $this->cssID[0] ?: $objElement->cssID[0];
// merge the classes
$arrElementClasses = explode(' ', $this->cssID[1]);
$arrIncludeClasses = explode(' ', $objElement->cssID[1]);
$cssID[1] = implode(' ', array_unique(array_merge($arrIncludeClasses, $arrElementClasses)));
// Overwrite spacing and CSS ID
$objElement->origSpace = $objElement->space;
$objElement->space = $this->space;
$objElement->origCssID = $objElement->cssID;
$objElement->cssID = $cssID;
return $objElement->generate();
}
示例10: compile
/**
* compile wrapper element
*/
protected function compile()
{
if ($this->wrapper->isTypeOf(Wrapper\Helper::TYPE_START)) {
$cssID = $this->cssID;
if ($cssID[0] == '') {
$cssID[0] = sprintf($this->identifier, $this->id);
$this->cssID = $cssID;
}
$attributes = new Attributes();
$attributes->addClass('carousel')->addClass('slide')->setAttribute('id', $cssID[0]);
if ($this->bootstrap_autostart) {
$attributes->setAttribute('data-ride', 'carousel');
}
if ($this->bootstrap_interval > 0) {
$attributes->setAttribute('data-interval', $this->bootstrap_interval);
}
$this->Template->attributes = $attributes;
$this->Template->count = $this->wrapper->countRelatedElements();
} else {
$start = \ContentModel::findByPk($this->bootstrap_parentId);
if ($start !== null) {
$start->cssID = deserialize($start->cssID, true);
$this->Template->start = $start;
if ($start->cssID[0] == '') {
$cssID = $start->cssID;
$cssID[0] = sprintf($this->identifier, $start->id);
$this->cssID = $cssID;
} else {
$this->cssID = $start->cssID;
}
}
}
$this->Template->identifier = $this->cssID[0];
$this->Template->wrapper = $this->wrapper;
}
示例11: compile
protected function compile()
{
global $objPage;
$arrElements = array();
$objCte = \ContentModel::findPublishedByPidAndTable($objPage->id, 'tl_page');
if ($objCte !== null) {
$intCount = 0;
$intLast = $objCte->count() - 1;
while ($objCte->next()) {
$arrCss = array();
/** @var \ContentModel $objRow */
$objRow = $objCte->current();
// Add the "first" and "last" classes (see #2583)
if ($intCount == 0 || $intCount == $intLast) {
if ($intCount == 0) {
$arrCss[] = 'first';
}
if ($intCount == $intLast) {
$arrCss[] = 'last';
}
}
$objRow->classes = $arrCss;
$arrElements[] = $this->getContentElement($objRow, $this->strColumn);
++$intCount;
}
}
$this->Template->elements = $arrElements;
// HOOK: add custom logic
if (isset($GLOBALS['TL_HOOKS']['compileArticle']) && is_array($GLOBALS['TL_HOOKS']['compileArticle'])) {
foreach ($GLOBALS['TL_HOOKS']['compileArticle'] as $callback) {
$this->import($callback[0]);
$this->{$callback}[0]->{$callback}[1]($this->Template, $this->arrData, $this);
}
}
}
示例12: getPlaceholder
public static function getPlaceholder($placeholder)
{
$object = new self();
$strContent = "";
$addStmt = "";
$db = \Database::getInstance();
$placeholderId = is_numeric($placeholder) ? $placeholder : 0;
$placeholderAlias = is_string($placeholder) ? $placeholder : 0;
if (!BE_USER_LOGGED_IN) {
$time = time();
$addStmt = " AND (start='' OR start<{$time}) AND (stop='' OR stop>{$time}) AND published=1";
}
// TODO: make a Placeholder Model!!
$objPlaceholder = $db->prepare("SELECT * FROM tl_dps_placeholder WHERE (id=? OR alias=?)" . $addStmt)->limit(1)->execute($placeholderId, $placeholderAlias);
if ($objPlaceholder->numRows > 0) {
$objPlaceholder = $objPlaceholder->first();
$id = $objPlaceholder->id;
$objContent = \ContentModel::findPublishedByPidAndTable($id, "tl_dps_placeholder");
if ($objContent && $objContent->count() > 0) {
while ($objContent->next()) {
$strContent .= $object->replaceInsertTags($object->getContentElement($objContent->id));
}
}
}
return $strContent;
}
示例13: compile
/**
* Generate module
*/
protected function compile()
{
// Get ID
$strAlias = \Input::get('auto_item') ? \Input::get('auto_item') : \Input::get('store');
// Find published store from ID
if (($objStore = AnyStoresModel::findPublishedByIdOrAlias($strAlias)) !== null) {
// load all details
$objStore->loadDetails();
// generate description
$objDescription = \ContentModel::findPublishedByPidAndTable($objStore->id, $objStore->getTable());
if ($objDescription !== null) {
while ($objDescription->next()) {
$objStore->description .= \Controller::getContentElement($objDescription->current());
}
}
// Get referer for back button
$objStore->referer = $this->getReferer();
// generate google map if template and geodata is set
if ($this->anystores_mapTpl != '' && is_numeric($objStore->latitude) && is_numeric($objStore->longitude)) {
$objMapTemplate = new \FrontendTemplate($this->anystores_mapTpl);
$objMapTemplate->setData($objStore->row());
$objStore->gMap = $objMapTemplate->parse();
}
// Template
$objDetailTemplate = new \FrontendTemplate($this->anystores_detailTpl);
$objDetailTemplate->setData($objStore->row());
$this->Template->store = $objDetailTemplate->parse();
} else {
$this->_redirect404();
}
}
示例14: compile
/**
* Generate the module
*/
protected function compile()
{
global $objPage;
$this->Template->content = '';
$this->Template->referer = 'javascript:history.go(-1)';
$this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
if (TL_MODE == 'FE' && BE_USER_LOGGED_IN) {
$objNewsletter = \NewsletterModel::findByIdOrAlias(\Input::get('items'));
} else {
$objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels);
}
if ($objNewsletter === null) {
// Do not index or cache the page
$objPage->noSearch = 1;
$objPage->cache = 0;
// Send a 404 header
header('HTTP/1.1 404 Not Found');
$this->Template->content = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>';
return;
}
// Overwrite the page title (see #2853 and #4955)
if ($objNewsletter->subject != '') {
$objPage->pageTitle = strip_tags(strip_insert_tags($objNewsletter->subject));
}
// Add enclosure
if ($objNewsletter->addFile) {
$this->addEnclosuresToTemplate($this->Template, $objNewsletter->row(), 'files');
}
if (!$objNewsletter->sendText) {
$nl2br = $objPage->outputFormat == 'xhtml' ? 'nl2br_xhtml' : 'nl2br_html5';
$strContent = '';
$objContentElements = \ContentModel::findPublishedByPidAndTable($objNewsletter->id, 'tl_newsletter');
if ($objContentElements !== null) {
if (!defined('NEWSLETTER_CONTENT_PREVIEW')) {
define('NEWSLETTER_CONTENT_PREVIEW', true);
}
foreach ($objContentElements as $objContentElement) {
$strContent .= $this->getContentElement($objContentElement->id);
}
}
// Parse simple tokens and insert tags
$strContent = $this->replaceInsertTags($strContent);
$strContent = \String::parseSimpleTokens($strContent, array());
// Encode e-mail addresses
$strContent = \String::encodeEmail($strContent);
$this->Template->content = $strContent;
} else {
$strContent = str_ireplace(' align="center"', '', $objNewsletter->content);
}
// Convert relative URLs
$strContent = $this->convertRelativeUrls($strContent);
// Parse simple tokens and insert tags
$strContent = $this->replaceInsertTags($strContent);
$strContent = \String::parseSimpleTokens($strContent, array());
// Encode e-mail addresses
$strContent = \String::encodeEmail($strContent);
$this->Template->content = $strContent;
$this->Template->subject = $objNewsletter->subject;
}
示例15: compile
/**
* Generate the module
*/
protected function compile()
{
$this->Template->content = '';
if (($objElement = \ContentModel::findPublishedByPidAndTable($this->User->id, 'tl_member')) !== null) {
while ($objElement->next()) {
$this->Template->content .= $this->getContentElement($objElement->id);
}
}
}