Code:
if (!defined('TL_ROOT')) die('You cannot access this file directly!'); /** * Boxes4ward * Contao extension to manage articles and contentelement in content boxes * * @copyright 4ward.media 2012 * @author Christoph Wiechert * @licence LGPL * @filesource * @package Boxes4ward * @see https://github.com/psi-4ward/boxes4ward */ // GlobalContentelements switch if($this->Input->get('do') == 'boxes4ward') { $GLOBALS['TL_DCA']['tl_content']['config']['ptable'] = 'tl_boxes4ward_article'; // set news4wards checkPermissions function $GLOBALS['TL_DCA']['tl_content']['config']['onload_callback'][] = array('tl_content_boxes4ward', 'checkPermission'); // set headerFields $GLOBALS['TL_DCA']['tl_content']['list']['sorting']['headerFields'] = array('name'); $GLOBALS['TL_DCA']['tl_content']['list']['sorting']['header_callback'] = array('tl_content_boxes4ward','generateHeader'); $GLOBALS['TL_DCA']['tl_content']['list']['operations']['toggle']['button_callback'] = array('tl_content_boxes4ward', 'toggleIcon'); } class tl_content_boxes4ward extends tl_content { /** * Import the back end user object */ public function __construct() { parent::__construct(); $this->import('BackendUser', 'User'); } /** * Add Modulname to headerFields * @param string $add * @param DataContainer $dc * @return array */ public function generateHeader($add, $dc) { $objModule = $this->Database->prepare('SELECT tl_module.name FROM tl_module LEFT JOIN tl_boxes4ward_article ON (tl_module.id = tl_boxes4ward_article.module_id) WHERE tl_boxes4ward_article.id=?')->execute(CURRENT_ID); $add[$GLOBALS['TL_LANG']['tl_boxes4ward_article']['module_id'][0]] = $objModule->name; return $add; } /** * Check permissions to edit table tl_content */ public function checkPermission() { if ($this->User->isAdmin) { return; } if($this->Input->get('act')) $articleID = $this->Database->prepare('SELECT pid FROM tl_content WHERE id=?')->execute($this->Input->get('id'))->pid; else $articleID = $this->Input->get('id'); // get archive id $objArchive = $this->Database->prepare('SELECT pid FROM tl_boxes4ward_article WHERE id=?')->execute($articleID); if($objArchive->numRows < 1 || !is_array($this->User->boxes4ward) || !in_array($objArchive->pid,$this->User->boxes4ward)) { $this->log('Not enough permissions to '.$this->Input->get('act').' boxes4ward contentelement ID "'.$this->Input->get('id').'"', 'tl_content_boxes4ward checkPermission', TL_ERROR); $this->redirect('contao/main.php?act=error'); } } } /** * Contao Open Source CMS * * Copyright (C) 2005-2012 Leo Feyer * * @package Comments * @link http://www.contao.org * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL */ /** * Add palette to tl_content */ $GLOBALS['TL_DCA']['tl_content']['palettes']['comments'] = '{type_legend},type,headline;{comment_legend},com_order,com_perPage,com_moderate,com_bbcode,com_requireLogin,com_disableCaptcha;{template_legend:hide},com_template;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop'; /** * Add fields to tl_content */ $GLOBALS['TL_DCA']['tl_content']['fields']['com_order'] = array ( 'label' => &$GLOBALS['TL_LANG']['tl_content']['com_order'], 'default' => 'ascending', 'exclude' => true, 'inputType' => 'select', 'options' => array('ascending', 'descending'), 'reference' => &$GLOBALS['TL_LANG']['MSC'], 'eval' => array('tl_class'=>'w50'), 'sql' => "varchar(32) NOT NULL default ''" ); $GLOBALS['TL_DCA']['tl_content']['fields']['com_perPage'] = array ( 'label' => &$GLOBALS['TL_LANG']['tl_content']['com_perPage'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp'=>'digit', 'tl_class'=>'w50'), 'sql' => "smallint(5) unsigned NOT NULL default '0'" ); $GLOBALS['TL_DCA']['tl_content']['fields']['com_moderate'] = array ( 'label' => &$GLOBALS['TL_LANG']['tl_content']['com_moderate'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class'=>'w50'), 'sql' => "char(1) NOT NULL default ''" ); $GLOBALS['TL_DCA']['tl_content']['fields']['com_bbcode'] = array ( 'label' => &$GLOBALS['TL_LANG']['tl_content']['com_bbcode'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class'=>'w50'), 'sql' => "char(1) NOT NULL default ''" ); $GLOBALS['TL_DCA']['tl_content']['fields']['com_disableCaptcha'] = array ( 'label' => &$GLOBALS['TL_LANG']['tl_content']['com_disableCaptcha'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class'=>'w50'), 'sql' => "char(1) NOT NULL default ''" ); $GLOBALS['TL_DCA']['tl_content']['fields']['com_requireLogin'] = array ( 'label' => &$GLOBALS['TL_LANG']['tl_content']['com_requireLogin'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class'=>'w50'), 'sql' => "char(1) NOT NULL default ''" ); $GLOBALS['TL_DCA']['tl_content']['fields']['com_template'] = array ( 'label' => &$GLOBALS['TL_LANG']['tl_content']['com_template'], 'default' => 'com_default', 'exclude' => true, 'inputType' => 'select', 'options_callback' => array('tl_content_comments', 'getCommentsTemplates'), 'sql' => "varchar(32) NOT NULL default ''" ); /** * Class tl_content_comments * * Provide miscellaneous methods that are used by the data configuration array. * @copyright Leo Feyer 2005-2012 * @author Leo Feyer * @package Comments */ class tl_content_comments extends Backend { /** * Return all comments templates as array * @param \DataContainer * @return array */ public function getCommentsTemplates(DataContainer $dc) { $intPid = $dc->activeRecord->pid; if (Input::get('act') == 'overrideAll') { $intPid = Input::get('id'); } // Get the page ID $objArticle = $this->Database->prepare("SELECT pid FROM tl_article WHERE id=?") ->limit(1) ->execute($intPid); // Inherit the page settings $objPage = $this->getPageDetails($objArticle->pid); // Get the theme ID $objLayout = LayoutModel::findByPk($objPage->layout); if ($objLayout === null) { return array(); } // Return all gallery templates return $this->getTemplateGroup('com_', $objLayout->pid); } }
Funktion an sich ok, nur wird halt zusätzlich Quellcode gezeigt...
Lesezeichen