本文整理汇总了PHP中ModuleModel::findBy方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleModel::findBy方法的具体用法?PHP ModuleModel::findBy怎么用?PHP ModuleModel::findBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleModel
的用法示例。
在下文中一共展示了ModuleModel::findBy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Compile the current element
*/
protected function compile()
{
$config = deserialize($this->bootstrap_navbarModules, true);
$modules = array();
$ids = array();
// get ids
foreach ($config as $index => $module) {
$ids[$index] = intval($module['module']);
}
// prefetch modules, so only 1 query is required
$ids = implode(',', $ids);
$collection = \ModuleModel::findBy(array('tl_module.id IN(' . $ids . ')'), array());
$models = array();
if ($collection) {
while ($collection->next()) {
$model = $collection->current();
$model->bootstrap_inNavbar = true;
$models[$model->id] = $model;
}
}
foreach ($config as $module) {
$id = $module['module'];
if ($id != '' && array_key_exists($id, $models)) {
$modules[] = $this->generateModule($module, $models[$id]);
}
}
if ($this->cssID[1] == '') {
$cssID = $this->cssID;
$cssID[1] = 'navbar-default';
$this->cssID = $cssID;
}
$this->Template->modules = $modules;
}
示例2: getModules
public function getModules($mcw)
{
// Get all modules from DB
$modules = array($GLOBALS['TL_LANG']['merger2']['legend_article'] => array('article' => $GLOBALS['TL_LANG']['merger2']['article'], 'inherit_articles' => $GLOBALS['TL_LANG']['merger2']['inherit_articles'], 'inherit_all_articles' => $GLOBALS['TL_LANG']['merger2']['inherit_all_articles'], 'inherit_articles_fallback' => $GLOBALS['TL_LANG']['merger2']['inherit_articles_fallback'], 'inherit_all_articles_fallback' => $GLOBALS['TL_LANG']['merger2']['inherit_all_articles_fallback']));
$themeCollection = \ThemeModel::findAll(array('order' => 'name'));
while ($themeCollection->next()) {
$modules[$themeCollection->name] = array();
$moduleCollection = \ModuleModel::findBy('pid', $themeCollection->id, array('order' => 'name'));
if ($moduleCollection) {
while ($moduleCollection->next()) {
$modules[$themeCollection->name][$moduleCollection->id] = $moduleCollection->name;
}
}
}
return $modules;
}
示例3: prefetchModules
/**
* Prefetch modules.
*
* @param array $config Navbar config.
*
* @return array
*/
protected function prefetchModules($config)
{
$ids = $this->extractModuleIds($config);
$models = array();
if ($ids) {
// prefetch modules, so only 1 query is required
$ids = implode(',', $ids);
$collection = \ModuleModel::findBy(array('tl_module.id IN(' . $ids . ')'), array());
if ($collection) {
while ($collection->next()) {
$model = $collection->current();
$model->bootstrap_inNavbar = true;
$models[$model->id] = $model;
}
}
}
return $models;
}
示例4: templates
public function templates($obj)
{
$template = $obj->getName();
switch ($template) {
case 'fe_page':
case 'fe_page_multitoggle':
//custom
$obj->setName($template . '_gc');
//gc = grid controll only
$obj->__get("layout")->__set("gridCSS", (array) $this->getGridArr($obj->layout));
break;
case 'form':
$obj->setName($template . '_' . \Config::get('co_grid_prefix'));
break;
default:
}
// `-,-´ ContentElements
if ($obj->__get('typePrefix') == 'ce_' && strpos($template, 'ce_row_start') === FALSE) {
$strClass = $this->findContentElement($obj->__get('type'));
if ($strClass !== NULL && $strClass != '') {
$objModel = \ContentModel::findBy('id', $obj->__get('id'));
if ($objModel !== NULL) {
$objEl = new $strClass($objModel);
$objEl = $this->design_elements($objEl);
$obj->__set('ftc_classes', $objEl->ftc_classes);
$obj->__set('ftcID', $objEl->ftcID);
$obj->__set('data_attr', $this->splitArr($objEl->data_attr));
$obj->__set('class', $objEl->ftc_classes);
$obj->__set('cssID', $objEl->ftcID);
}
}
}
if (strpos($template, 'ce_row_start') !== FALSE) {
$obj->__set('row_data_attr_ftc', $this->splitArr($obj->row_data_attr_ftc));
}
// `-,-´ Article
if (strpos($template, 'mod_article') !== FALSE) {
$objModel = \ArticleModel::findBy('id', $obj->__get('id'));
if ($objModel !== NULL) {
$objEl = new \ModuleArticle($objModel);
$objEl = $this->design_articles($objEl);
$obj->__set('class', '' . $objEl->ftc_classes);
$obj->__set('cssID', $objEl->ftcID . ' ');
//.$objEl->data_attr.' '
}
}
// `-,-´ Module
if ($obj->__get('typePrefix') == 'mod_') {
$strClass = \Module::findClass($obj->__get('type'));
if ($strClass !== NULL && $strClass != '') {
$objModel = \ModuleModel::findBy('id', $obj->__get('id'));
if ($objModel !== NULL) {
$objEl = new $strClass($objModel);
$co_grid = $this->design_modules($objEl);
$obj->__set('class', $co_grid['class'] . ' ' . $co_grid['co_grid_classes']);
// $obj->__set('cssID',$co_grid['ftcID'].' '.$co_grid['data_attr'].' ');
$obj->__set('ftc_classes', $co_grid['class'] . ' ' . $co_grid['co_grid_classes']);
$obj->__set('ftcID', $co_grid['ftcID'] . ' ');
$obj->__set('ftc_data_attr', $co_grid['data_attr']);
}
}
}
}
示例5: 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();
}
示例6: extractThemeFilesHook
/**
* Convert IDs for theme import
*
* @param \DOMDocument $xml theme.xml
* @param \ZipWriter $zipArchive CTO file
* @param int $themeId
* @param array $idMappingData ID mapping for imported database rows
* @return void
*/
public function extractThemeFilesHook($xml, $zipArchive, $themeId, $idMappingData)
{
$modules = \ModuleModel::findBy(array('tl_module.pid = ? AND tl_module.type LIKE \'rsce_%\''), $themeId);
if (!$modules || !count($modules)) {
return;
}
foreach ($modules as $module) {
if (substr($module->type, 0, 5) !== 'rsce_') {
continue;
}
$rsceDataConverted = $this->convertDataForImportExport(true, $module->type, $module->rsce_data, $idMappingData);
if (!$rsceDataConverted || strtolower($rsceDataConverted) === 'null' || $rsceDataConverted === '{}' || $rsceDataConverted === '[]' || $rsceDataConverted === $module->rsce_data) {
continue;
}
$module->rsce_data = $rsceDataConverted;
$module->save();
}
}