本文整理汇总了PHP中ModuleModel::findByPk方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleModel::findByPk方法的具体用法?PHP ModuleModel::findByPk怎么用?PHP ModuleModel::findByPk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleModel
的用法示例。
在下文中一共展示了ModuleModel::findByPk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFrontendModuleAjax
/**
* Generate a front end module and return it as string
*
* @param mixed $intId A module ID or a Model object
* @param string $strColumn The name of the column
*
* @return string The module HTML markup
*/
protected static function getFrontendModuleAjax($intId, $strColumn = 'main')
{
if (!is_object($intId) && !strlen($intId)) {
return '';
}
if (is_object($intId)) {
$objRow = $intId;
} else {
$objRow = \ModuleModel::findByPk($intId);
if ($objRow === null) {
return '';
}
}
// Check the visibility (see #6311)
if (!\Controller::isVisibleElement($objRow)) {
return '';
}
$strClass = \Module::findClass($objRow->type);
// Return if the class does not exist
if (!class_exists($strClass)) {
\System::log('Module class "' . $strClass . '" (module "' . $objRow->type . '") does not exist', __METHOD__, TL_ERROR);
return '';
}
$objRow->typePrefix = 'mod_';
$objModule = new $strClass($objRow, $strColumn);
$strBuffer = AjaxInput::get('g') == '1' ? $objModule->generate() : $objModule->generateAjax();
// HOOK: add custom logic
if (isset($GLOBALS['TL_HOOKS']['getFrontendModule']) && is_array($GLOBALS['TL_HOOKS']['getFrontendModule'])) {
foreach ($GLOBALS['TL_HOOKS']['getFrontendModule'] as $callback) {
$strBuffer = \System::importStatic($callback[0])->{$callback}[1]($objRow, $strBuffer, $objModule);
}
}
return $strBuffer;
}
示例2: generate
/**
* Parse the template
*
* @return string
*/
public function generate()
{
if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && ($this->invisible || $this->start > 0 && $this->start > time() || $this->stop > 0 && $this->stop < time())) {
return '';
}
$objModule = \ModuleModel::findByPk($this->news_module);
if ($objModule === null) {
return '';
}
$strClass = \Module::findClass($objModule->type);
if (!class_exists($strClass)) {
return '';
}
$objModule->typePrefix = 'ce_';
$objModule = new $strClass($objModule, $this->strColumn);
// Overwrite spacing and CSS ID
$objModule->origSpace = $objModule->space;
$objModule->space = $this->space;
$objModule->origCssID = $objModule->cssID;
$objModule->cssID = $this->cssID;
// Override news filter settings
$objModule->news_filterCategories = $this->news_filterCategories;
$objModule->news_filterDefault = $this->news_filterDefault;
$objModule->news_filterPreserve = $this->news_filterPreserve;
return $objModule->generate();
}
示例3: generate
/**
* Parse the template
*
* @return string
*/
public function generate()
{
if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && ($this->invisible || $this->start != '' && $this->start > time() || $this->stop != '' && $this->stop < time())) {
return '';
}
$objModule = \ModuleModel::findByPk($this->module);
if ($objModule === null) {
return '';
}
$strClass = \Module::findClass($objModule->type);
if (!class_exists($strClass)) {
return '';
}
$objModule->typePrefix = 'ce_';
/** @var Module $objModule */
$objModule = new $strClass($objModule, $this->strColumn);
$cssID = deserialize($objModule->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]);
}
$objModule->cssID = $cssID;
return $objModule->generate();
}
示例4: generate
/**
* Parse the template
* @return string
*/
public function generate()
{
if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && ($this->invisible || $this->start > 0 && $this->start > time() || $this->stop > 0 && $this->stop < time())) {
return '';
}
$objModule = \ModuleModel::findByPk($this->module);
if ($objModule === null) {
return '';
}
$strClass = \Module::findClass($objModule->type);
if (!class_exists($strClass)) {
return '';
}
$objModule->typePrefix = 'ce_';
$objModule = new $strClass($objModule, $this->strColumn);
// create new cssID array
$cssID = array();
// set the ID
$cssID[0] = $this->cssID[0] ?: $objModule->cssID[0];
// merge the classes
$arrElementClasses = explode(' ', $this->cssID[1]);
$arrModuleClasses = explode(' ', $objModule->cssID[1]);
$cssID[1] = implode(' ', array_unique(array_merge($arrModuleClasses, $arrElementClasses)));
// Overwrite spacing and CSS ID
$objModule->space = $this->space;
$objModule->cssID = $cssID;
return $objModule->generate();
}
示例5: compile
protected function compile()
{
$objContentStart = \Database::getInstance()->prepare("SELECT * FROM tl_content WHERE pid=? AND type=? ORDER BY sorting")->limit(1)->execute($this->pid, 'formhybridStart');
if ($objContentStart->numRows === 0) {
return;
}
$objModule = \ModuleModel::findByPk($objContentStart->formhybridModule);
if ($objModule === null) {
return;
}
$objModule->refresh();
$strClass = \Module::findClass($objModule->type);
// Return if the class does not exist
if (!class_exists($strClass)) {
static::log('Module class "' . $strClass . '" (module "' . $objModule->type . '") does not exist', __METHOD__, TL_ERROR);
return '';
}
$objArticle = \ArticleModel::findByPk($this->pid);
if ($objArticle === null) {
return;
}
global $objPage;
$objModule = new $strClass($objModule, $objArticle->inColumn);
$objModule->renderStop = true;
$objModule->startModule = $_SESSION[FormSession::FORMHYBRID_FORMSESSION_START_KEY][$objPage->id . '_' . $objModule->formHybridDataContainer];
$this->Template->content = $objModule->generate();
}
示例6: addSubscriptions
public static function addSubscriptions(Order $objOrder, $arrTokens)
{
$strEmail = $objOrder->getBillingAddress()->email;
$objAddress = $objOrder->getShippingAddress() ?: $objOrder->getBillingAddress();
$arrItems = $objOrder->getItems();
$objSession = \Session::getInstance();
if (!($intModule = $objSession->get('isotopeCheckoutModuleIdSubscriptions'))) {
return true;
}
$objSession->remove('isotopeCheckoutModuleIdSubscriptions');
$objModule = \ModuleModel::findByPk($intModule);
foreach ($arrItems as $item) {
switch ($objModule->iso_direct_checkout_product_mode) {
case 'product_type':
$objFieldpalette = FieldPaletteModel::findBy('iso_direct_checkout_product_type', Standard::findAvailableByIdOrAlias($item->product_id)->type);
break;
default:
$objFieldpalette = FieldPaletteModel::findBy('iso_direct_checkout_product', $item->product_id);
break;
}
if ($objFieldpalette !== null && $objFieldpalette->iso_addSubscription) {
if ($objFieldpalette->iso_subscriptionArchive && (!$objFieldpalette->iso_addSubscriptionCheckbox || \Input::post('subscribeToProduct_' . $item->product_id))) {
$objSubscription = Subscription::findOneBy(array('email=?', 'pid=?', 'activation!=?', 'disable=?'), array($strEmail, $objFieldpalette->iso_subscriptionArchive, '', 1));
if (!$objSubscription) {
$objSubscription = new Subscription();
}
if ($objFieldpalette->iso_addActivation) {
$strToken = md5(uniqid(mt_rand(), true));
$objSubscription->disable = true;
$objSubscription->activation = $strToken;
if (($objNotification = Notification::findByPk($objFieldpalette->iso_activationNotification)) !== null) {
if ($objFieldpalette->iso_activationJumpTo && ($objPageRedirect = \PageModel::findByPk($objFieldpalette->iso_activationJumpTo)) !== null) {
$arrTokens['link'] = \Environment::get('url') . '/' . \Controller::generateFrontendUrl($objPageRedirect->row()) . '?token=' . $strToken;
}
$objNotification->send($arrTokens, $GLOBALS['TL_LANGUAGE']);
}
}
$arrAddressFields = \Config::get('iso_addressFields');
if ($arrAddressFields === null) {
$arrAddressFields = serialize(array_keys(static::getIsotopeAddressFields()));
}
foreach (deserialize($arrAddressFields, true) as $strName) {
$objSubscription->{$strName} = $objAddress->{$strName};
}
$objSubscription->email = $strEmail;
$objSubscription->pid = $objFieldpalette->iso_subscriptionArchive;
$objSubscription->tstamp = $objSubscription->dateAdded = time();
$objSubscription->quantity = \Input::post('quantity');
$objSubscription->order_id = $objOrder->id;
$objSubscription->save();
}
}
}
return true;
}
示例7: generate
/**
* Display a wildcard in the back end
* @return string
*/
public function generate()
{
if (TL_MODE == 'BE') {
$objTemplate = new \BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['newslist_plus'][0]) . ' ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
return $objTemplate->parse();
}
// set news categories from filter
if (\Input::get('newscategories')) {
$this->news_archives = explode(',', \Input::get('newscategories'));
$this->filterActive = true;
}
$this->news_archives = $this->sortOutProtected(deserialize($this->news_archives));
// Return if there are no archives
if (!is_array($this->news_archives) || empty($this->news_archives)) {
return '';
}
$GLOBALS['NEWS_FILTER_CATEGORIES'] = $this->news_filterCategories ? true : false;
$GLOBALS['NEWS_FILTER_DEFAULT'] = deserialize($this->news_filterDefault, true);
$GLOBALS['NEWS_FILTER_PRESERVE'] = $this->news_filterPreserve;
if ($this->news_filterModule) {
$this->objFilter = \ModuleModel::findByPk($this->news_filterModule);
}
$this->news_categories = array();
// set news categories from filter
if (\Input::get('categories')) {
$this->news_categories = explode(',', \Input::get('categories'));
$this->filterActive = true;
}
// Show the event reader if an item has been selected
if (!$this->news_showInModal && $this->news_readerModule > 0 && (isset($_GET['news']) || \Config::get('useAutoItem') && isset($_GET['auto_item']))) {
return $this->getFrontendModule($this->news_readerModule, $this->strColumn);
}
// filter
if (\Input::get('startDate')) {
$this->startDate = strtotime(\Input::get('startDate') . ' 00:00:00');
$this->filterActive = true;
}
if (\Input::get('endDate')) {
$this->endDate = strtotime(\Input::get('endDate') . ' 23:59:59');
$this->filterActive = true;
}
if (\Input::get('searchKeywords')) {
$this->strKeywords = trim(\Input::get('searchKeywords'));
$this->filterActive = true;
$this->filterSearch = true;
}
return parent::generate();
}
示例8: adjustPalettesForLists
public static function adjustPalettesForLists(\DataContainer $objDc)
{
\Controller::loadDataContainer('tl_module');
\System::loadLanguageFile('tl_module');
if (($objModule = \ModuleModel::findByPk($objDc->id)) !== null) {
$arrDca =& $GLOBALS['TL_DCA']['tl_module'];
if (\HeimrichHannot\Haste\Util\Module::isSubModuleOf($objModule->type, 'HeimrichHannot\\FrontendEdit\\ModuleList')) {
$arrDca['palettes'][MODULE_FRONTENDEDIT_MEMBER_LIST] = str_replace('filterArchives', 'filterGroups', $arrDca['palettes'][MODULE_FRONTENDEDIT_MEMBER_LIST]);
// override labels for suiting a list module
$arrDca['fields']['formHybridAddDefaultValues']['label'] =& $GLOBALS['TL_LANG']['tl_module']['formHybridAddDefaultFilterValues'];
$arrDca['fields']['formHybridDefaultValues']['label'] =& $GLOBALS['TL_LANG']['tl_module']['formHybridDefaultFilterValues'];
}
}
}
示例9: modifyPalette
public function modifyPalette()
{
$objModule = \ModuleModel::findByPk(\Input::get('id'));
$arrDc =& $GLOBALS['TL_DCA']['tl_module'];
// submission -> already done in formhybrid
// confirmation
$arrFieldsToHide = array('formHybridConfirmationMailSender', 'formHybridConfirmationMailSubject', 'formHybridConfirmationMailText', 'formHybridConfirmationMailTemplate', 'formHybridConfirmationMailAttachment');
if (in_array('avisota-core', \ModuleLoader::getActive()) && $objModule->reg_activate_plus && $objModule->formHybridConfirmationAvisotaMessage) {
$arrDc['subpalettes']['reg_activate_plus'] = str_replace($arrFieldsToHide, array_map(function () {
return '';
}, $arrFieldsToHide), $arrDc['subpalettes']['reg_activate_plus']);
$arrDc['subpalettes']['reg_activate_plus'] = str_replace('formHybridConfirmationAvisotaMessage', 'formHybridConfirmationAvisotaMessage,formHybridConfirmationAvisotaSalutationGroup', $arrDc['subpalettes']['reg_activate_plus']);
}
}
示例10: onload
public function onload(DataContainer $dc)
{
if (\Input::get('table') == 'tl_module' && \Input::get('act') == 'edit') {
$module = \ModuleModel::findByPk($dc->id);
if ($module && $module->type == 'Merger2') {
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/merger2/html/merger2.js';
if (\Input::post('FORM_SUBMIT') == 'tl_module') {
$blnDisabled = !\Input::post('merger_container');
} else {
$blnDisabled = !$module->merger_container;
}
$GLOBALS['TL_DCA']['tl_module']['fields']['cssID']['eval']['disabled'] = $blnDisabled;
$GLOBALS['TL_DCA']['tl_module']['fields']['space']['eval']['disabled'] = $blnDisabled;
}
}
}
示例11: generate
/**
* Parse the template
* @return string
*/
public function generate()
{
$objModule = \ModuleModel::findByPk($this->module);
if ($objModule === null) {
return '';
}
$strClass = $this->findFrontendModule($objModule->type);
if (!class_exists($strClass)) {
return '';
}
$objModule->typePrefix = 'ce_';
$objModule = new $strClass($objModule);
// Overwrite spacing and CSS ID
$objModule->space = $this->space;
$objModule->cssID = $this->cssID;
return $objModule->generate();
}
示例12: joinModule
protected function joinModule($column, $moduleId, &$sections)
{
$module = \ModuleModel::findByPk($moduleId);
if (!$module || $module->type != 'Merger2') {
return;
}
$data = deserialize($module->merger_data, true);
foreach ($data as $row) {
if (!$row['disabled']) {
if (in_array($row['content'], array('article', 'inherit_articles', 'inherit_all_articles', 'inherit_articles_fallback', 'inherit_all_articles_fallback'))) {
$sections[] = $column;
} elseif ($row['content']) {
$this->joinModule($column, $row['content'], $sections);
}
}
}
}
示例13: modifyPalette
public function modifyPalette()
{
$objModule = \ModuleModel::findByPk(\Input::get('id'));
$arrDca =& $GLOBALS['TL_DCA']['tl_module'];
if (\HeimrichHannot\Haste\Util\Module::isSubModuleOf($objModule->type, 'HeimrichHannot\\PinBoard\\ModulePinBoard')) {
$objModule->formHybridDataContainer = 'tl_news';
$objModule->formHybridPalette = 'pinboard';
$objModule->showInitialResults = true;
$objModule->addDetailsCol = true;
$objModule->sortingMode = OPTION_FORMHYBRID_SORTINGMODE_FIELD;
if (!$objModule->itemSorting) {
$objModule->itemSorting = 'date_desc';
}
if (!$objModule->updateDeleteConditions) {
$objModule->updateDeleteConditions = deserialize(array(array('field' => 'memberAuthor', 'value' => '{{user::id}}')));
}
if (!$objModule->additionalWhereSql) {
$objModule->additionalWhereSql = '(tl_news.published=1 OR tl_news.memberAuthor="{{user::id}}")';
}
$objModule->save();
$arrDca['fields']['jumpToCreate']['eval']['tl_class'] = 'w50 clr';
$arrDca['fields']['createMemberGroups']['eval']['tl_class'] = 'w50 clr';
$arrDca['fields']['jumpToEdit']['eval']['tl_class'] = 'w50';
}
if (\HeimrichHannot\Haste\Util\Module::isSubModuleOf($objModule->type, 'HeimrichHannot\\PinBoard\\ModulePinBoardEditor')) {
$objModule->formHybridDataContainer = 'tl_news';
$objModule->formHybridPalette = 'pinboard';
if (!$objModule->updateDeleteConditions) {
$objModule->updateDeleteConditions = serialize(array(array('field' => 'memberAuthor', 'value' => '{{user::id}}')));
}
if (!$objModule->formHybridDefaultValues) {
$objModule->formHybridDefaultValues = serialize(array(array('field' => 'date', 'value' => '{{date::U}}', 'label' => ''), array('field' => 'time', 'value' => '{{date::U}}', 'label' => ''), array('field' => 'source', 'value' => 'default', 'label' => ''), array('field' => 'type', 'value' => 'pinboard', 'label' => ''), array('field' => 'memberAuthor', 'value' => '{{user::id}}', 'label' => ''), array('field' => 'useMemberAuthor', 'value' => true, 'label' => '')));
}
$objModule->save();
$arrDca['fields']['setPageTitle']['eval']['tl_class'] = 'w50 clr';
}
if (\HeimrichHannot\Haste\Util\Module::isSubModuleOf($objModule->type, 'HeimrichHannot\\PinBoard\\ModulePinBoardReader')) {
$objModule->formHybridDataContainer = 'tl_news';
$objModule->formHybridPalette = 'pinboard';
if (!$objModule->itemTemplate) {
$objModule->itemTemplate = 'formhybrid_reader_pinboard';
}
$objModule->save();
}
}
示例14: appendColumnsetIdToPalette
/**
* Add column set field to the colsetStart content element.
*
* We need to do it dynamically because subcolumns creates its palette dynamically.
*
* @param \DataContainer $dataContainer The data container driver.
*
* @return void
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
public function appendColumnsetIdToPalette($dataContainer)
{
if ($GLOBALS['TL_CONFIG']['subcolumns'] != 'bootstrap_customizable') {
return;
}
if ($dataContainer->table == 'tl_content') {
$model = \ContentModel::findByPK($dataContainer->id);
if ($model->sc_type > 0) {
\MetaPalettes::appendFields($dataContainer->table, 'colsetStart', 'colset', array('columnset_id'));
}
} else {
$model = \ModuleModel::findByPk($dataContainer->id);
if ($model->sc_type > 0) {
if ($model->sc_type > 0) {
$GLOBALS['TL_DCA']['tl_module']['palettes']['subcolumns'] = str_replace('sc_type,', 'sc_type,columnset_id,', $GLOBALS['TL_DCA']['tl_module']['palettes']['subcolumns']);
}
}
}
}
示例15: generate
/**
* Parse the template
* @return string
*/
public function generate()
{
if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && ($this->invisible || $this->start != '' && $this->start > time() || $this->stop != '' && $this->stop < time())) {
return '';
}
$objModule = \ModuleModel::findByPk($this->module);
if ($objModule === null) {
return '';
}
$strClass = \Module::findClass($objModule->type);
if (!class_exists($strClass)) {
return '';
}
$objModule->typePrefix = 'ce_';
$objModule = new $strClass($objModule, $this->strColumn);
// Overwrite spacing and CSS ID
$objModule->space = $this->space;
$objModule->cssID = $this->cssID;
return $objModule->generate();
}