本文整理汇总了PHP中ContentModel::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentModel::getTable方法的具体用法?PHP ContentModel::getTable怎么用?PHP ContentModel::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentModel
的用法示例。
在下文中一共展示了ContentModel::getTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findPreviousElement
/**
* Try to find previous element of same type or specified type.
*
* @param string|null $type Name of the type. If empty current type is used.
*
* @return \Model|null
*/
public function findPreviousElement($type = null)
{
if ($type === null) {
$type = $this->getType();
}
$table = \ContentModel::getTable();
$column = array($table . '.pid=?', $table . '.ptable=?', $table . '.type=?', $table . '.sorting<?');
$values = array($this->model->pid, $this->model->ptable, $this->getTypeName($type), $this->model->sorting);
return \ContentModel::findOneBy($column, $values, array('order' => $table . '.sorting DESC'));
}
示例2: getParents
/**
* Get parents for a specific item.
*
* @param \DataContainer $dataContainer The data container driver.
*
* @return array
*/
public function getParents($dataContainer)
{
if ($dataContainer->id) {
$row = \ContentModel::findByPk($dataContainer->id);
if (!$row) {
return array();
}
$helper = Helper::create($row);
$start = Bootstrap::getConfigVar('wrappers.' . $helper->getGroup() . '.start.name');
if ($start) {
$table = \ContentModel::getTable();
$result = \ContentModel::findBy(array($table . '.pid=?', $table . '.type=?', $table . '.sorting<?'), array($row->pid, $start, $row->sorting), array('order' => $table . '.sorting DESC'));
if ($result) {
$values = array();
foreach ($result as $model) {
$headline = deserialize($model->headline, true);
$values[$model->id] = $headline['value'] ?: $model->type . ' ID: ' . $model->id;
}
return $values;
}
}
return array();
}
}
示例3: run
/**
* Generate the module
*
* @return string
*/
public function run()
{
$objTemplate = new \BackendTemplate('be_rsce_convert');
$objTemplate->isActive = $this->isActive();
$objTemplate->action = ampersand(\Environment::get('request'));
$objTemplate->indexHeadline = $GLOBALS['TL_LANG']['tl_maintenance']['searchIndex'];
// Rebuild the index
if (\Input::get('act') === 'rsce_convert') {
// Check the request token
if (!isset($_GET['rt']) || !\RequestToken::validate(\Input::get('rt'))) {
$this->Session->set('INVALID_TOKEN_URL', \Environment::get('request'));
$this->redirect('contao/confirm.php');
}
$this->import('Database');
$failedElements = array();
$elementsCount = 0;
$contentElements = \ContentModel::findBy(array(\ContentModel::getTable() . '.type LIKE ?'), 'rsce_%');
while ($contentElements && $contentElements->next()) {
$html = $this->getHtmlFromElement($contentElements);
if (!$html) {
$failedElements[] = array('content', $contentElements->id, $contentElements->type);
} else {
$this->createInitialVersion(\ContentModel::getTable(), $contentElements->id);
$this->Database->prepare('UPDATE ' . \ContentModel::getTable() . ' SET tstamp = ?, type = \'html\', html = ? WHERE id = ?')->executeUncached(time(), $html, $contentElements->id);
$elementsCount++;
$this->createNewVersion(\ContentModel::getTable(), $contentElements->id);
$this->log('A new version of record "' . \ContentModel::getTable() . '.id=' . $contentElements->id . '" has been created', __METHOD__, TL_GENERAL);
}
}
$moduleElements = \ModuleModel::findBy(array(\ModuleModel::getTable() . '.type LIKE ?'), 'rsce_%');
while ($moduleElements && $moduleElements->next()) {
$html = $this->getHtmlFromElement($moduleElements);
if (!$html) {
$failedElements[] = array('module', $moduleElements->id, $moduleElements->type);
} else {
$this->createInitialVersion(\ModuleModel::getTable(), $moduleElements->id);
$this->Database->prepare('UPDATE ' . \ModuleModel::getTable() . ' SET tstamp = ?, type = \'html\', html = ? WHERE id = ?')->executeUncached(time(), $html, $moduleElements->id);
$elementsCount++;
$this->createNewVersion(\ModuleModel::getTable(), $moduleElements->id);
$this->log('A new version of record "' . \ModuleModel::getTable() . '.id=' . $moduleElements->id . '" has been created', __METHOD__, TL_GENERAL);
}
}
$formElements = \FormFieldModel::findBy(array(\FormFieldModel::getTable() . '.type LIKE ?'), 'rsce_%');
while ($formElements && $formElements->next()) {
$html = $this->getHtmlFromElement($formElements);
if (!$html) {
$failedElements[] = array('form', $formElements->id, $formElements->type);
} else {
$this->createInitialVersion(\FormFieldModel::getTable(), $formElements->id);
$this->Database->prepare('UPDATE ' . \FormFieldModel::getTable() . ' SET tstamp = ?, type = \'html\', html = ? WHERE id = ?')->executeUncached(time(), $html, $formElements->id);
$elementsCount++;
$this->createNewVersion(\FormFieldModel::getTable(), $formElements->id);
$this->log('A new version of record "' . \FormFieldModel::getTable() . '.id=' . $formElements->id . '" has been created', __METHOD__, TL_GENERAL);
}
}
foreach ($failedElements as $element) {
$this->log('Failed to convert ' . $element[0] . ' element ID ' . $element[1] . ' (' . $element[2] . ') to a standard HTML element', __METHOD__, TL_ERROR);
}
$this->log('Converted ' . $elementsCount . ' RockSolid Custom Elements to standard HTML elements', __METHOD__, TL_GENERAL);
$objTemplate->elementsCount = $elementsCount;
$objTemplate->failedElements = $failedElements;
}
$this->loadLanguageFile('rocksolid_custom_elements');
return $objTemplate->parse();
}
示例4: collectItems
public function collectItems(CollectItemsEvent $event)
{
$item = $event->getParentItem();
if ($item->getType() == 'article') {
$t = \ContentModel::getTable();
$arrColumns = array("{$t}.pid=?", "({$t}.ptable='' OR {$t}.ptable='tl_article')", "{$t}.cssID!=''");
if (!BE_USER_LOGGED_IN) {
$time = time();
$arrColumns[] = "({$t}.start='' OR {$t}.start<{$time}) AND ({$t}.stop='' OR {$t}.stop>{$time}) AND {$t}.invisible=''";
}
$contents = \ContentModel::findBy($arrColumns, array($item->getName()), array('order' => 'sorting'));
if ($contents) {
$factory = $event->getFactory();
$reachedLevel = 7;
foreach ($contents as $content) {
$headline = deserialize($content->headline, true);
$cssID = deserialize($content->cssID, true);
if (!empty($headline['value']) && !empty($headline['unit']) && !empty($cssID[0])) {
$elementLevel = (int) substr($headline['unit'], 1);
if ($elementLevel <= $reachedLevel) {
$factory->createItem('content', $content->id, $item);
$reachedLevel = $elementLevel;
}
}
}
}
} else {
if ($item->getType() == 'content') {
$thisHeadline = deserialize($item->getExtra('headline'), true);
if (!empty($thisHeadline['unit'])) {
$expectedLevel = intval(substr($thisHeadline['unit'], 1)) + 1;
$t = \ContentModel::getTable();
$arrColumns = array("{$t}.pid=?", "({$t}.ptable='' OR {$t}.ptable='tl_article')", "{$t}.cssID!=''", "{$t}.sorting > ?");
if (!BE_USER_LOGGED_IN) {
$time = time();
$arrColumns[] = "({$t}.start='' OR {$t}.start<{$time}) AND ({$t}.stop='' OR {$t}.stop>{$time}) AND {$t}.invisible=''";
}
$contents = \ContentModel::findBy($arrColumns, array($item->getExtra('pid'), $item->getExtra('sorting')), array('order' => 'sorting'));
if ($contents) {
$factory = $event->getFactory();
$reachedLevel = 7;
foreach ($contents as $content) {
$headline = deserialize($content->headline, true);
$cssID = deserialize($content->cssID, true);
if (!empty($headline['value']) && !empty($headline['unit']) && !empty($cssID[0])) {
$elementLevel = (int) substr($headline['unit'], 1);
// level is one down
if ($elementLevel >= $expectedLevel && $elementLevel <= $reachedLevel) {
$factory->createItem('content', $content->id, $item);
$reachedLevel = $elementLevel;
} else {
if ($elementLevel < $expectedLevel) {
break;
}
}
}
}
}
}
}
}
}