/system/modules/backend/dca/tl_content.php
PHP | 1131 lines | 871 code | 103 blank | 157 comment | 46 complexity | 4bc03a1667c0459b31916ac714f9a350 MD5 | raw file
- <?php if (!defined('TL_ROOT')) die('You can not access this file directly!');
- /**
- * TYPOlight Open Source CMS
- * Copyright (C) 2005-2010 Leo Feyer
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation, either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program. If not, please visit the Free
- * Software Foundation website at <http://www.gnu.org/licenses/>.
- *
- * PHP version 5
- * @copyright Leo Feyer 2005-2010
- * @author Leo Feyer <http://www.typolight.org>
- * @package Backend
- * @license LGPL
- * @filesource
- */
- /**
- * Table tl_content
- */
- $GLOBALS['TL_DCA']['tl_content'] = array
- (
- // Config
- 'config' => array
- (
- 'dataContainer' => 'Table',
- 'ptable' => 'tl_article',
- 'enableVersioning' => true,
- 'onload_callback' => array
- (
- array('tl_content', 'checkPermission')
- )
- ),
- // List
- 'list' => array
- (
- 'sorting' => array
- (
- 'mode' => 4,
- 'fields' => array('sorting'),
- 'panelLayout' => 'filter;search,limit',
- 'headerFields' => array('title', 'author', 'inColumn', 'tstamp', 'showTeaser', 'printable', 'published', 'start', 'stop'),
- 'child_record_callback' => array('tl_content', 'addCteType')
- ),
- 'global_operations' => array
- (
- 'all' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
- 'href' => 'act=select',
- 'class' => 'header_edit_all',
- 'attributes' => 'onclick="Backend.getScrollOffset();"'
- )
- ),
- 'operations' => array
- (
- 'edit' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['edit'],
- 'href' => 'act=edit',
- 'icon' => 'edit.gif'
- ),
- 'copy' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['copy'],
- 'href' => 'act=paste&mode=copy',
- 'icon' => 'copy.gif',
- 'attributes' => 'onclick="Backend.getScrollOffset();"'
- ),
- 'cut' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['cut'],
- 'href' => 'act=paste&mode=cut',
- 'icon' => 'cut.gif',
- 'attributes' => 'onclick="Backend.getScrollOffset();"'
- ),
- 'delete' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['delete'],
- 'href' => 'act=delete',
- 'icon' => 'delete.gif',
- 'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"',
- 'button_callback' => array('tl_content', 'deleteElement')
- ),
- 'toggle' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['toggle'],
- 'icon' => 'visible.gif',
- 'attributes' => 'onclick="Backend.getScrollOffset(); return AjaxRequest.toggleVisibility(this, %s);"',
- 'button_callback' => array('tl_content', 'toggleIcon')
- ),
- 'show' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['show'],
- 'href' => 'act=show',
- 'icon' => 'show.gif'
- )
- ),
- ),
- // Palettes
- 'palettes' => array
- (
- '__selector__' => array('type', 'mooType', 'addImage', 'useImage', 'sortable', 'protected'),
- 'default' => '{type_legend},type',
- 'headline' => '{type_legend},type,headline;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'text' => '{type_legend},type,headline;{text_legend},text;{image_legend},addImage;{protected_legend:hide},protected;{expert_legend},{expert_legend:hide},guests,cssID,space',
- 'html' => '{type_legend},type;{text_legend},html;{protected_legend:hide},protected;{expert_legend},{expert_legend:hide},guests',
- 'list' => '{type_legend},type,headline;{list_legend},listtype,listitems;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'table' => '{type_legend},type,headline;{table_legend},tableitems;{tconfig_legend},summary,thead,tfoot;{sortable_legend:hide},sortable;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'accordion' => '{type_legend},type,mooType',
- 'accordionsingle' => '{type_legend},type,mooType;{moo_legend},mooHeadline,mooStyle,mooClasses;{text_legend},text;{image_legend},addImage;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'accordionstart' => '{type_legend},type,mooType;{moo_legend},mooHeadline,mooStyle,mooClasses;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'accordionstop' => '{type_legend},type,mooType;{moo_legend},mooClasses;{protected_legend:hide},protected;{expert_legend:hide},guests',
- 'code' => '{type_legend},type,headline;{text_legend},highlight,shClass,code;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'hyperlink' => '{type_legend},type,headline;{link_legend},url,target,linkTitle,rel,embed;{imglink_legend:hide},useImage;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'toplink' => '{type_legend},type,linkTitle;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'image' => '{type_legend},type,headline;{source_legend},singleSRC;{image_legend},alt,size,imagemargin,imageUrl,fullsize,caption;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'gallery' => '{type_legend},type,headline;{source_legend},multiSRC,useHomeDir;{image_legend},size,imagemargin,perRow,perPage,sortBy,fullsize;{template_legend:hide},galleryTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'download' => '{type_legend},type,headline;{source_legend},singleSRC;{dwnconfig_legend},linkTitle;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'downloads' => '{type_legend},type,headline;{source_legend},multiSRC,useHomeDir;{dwnconfig_legend},sortBy;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'alias' => '{type_legend},type;{include_legend},cteAlias;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'article' => '{type_legend},type;{include_legend},articleAlias;{protected_legend:hide},protected',
- 'teaser' => '{type_legend},type;{include_legend},article;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'form' => '{type_legend},type,headline;{include_legend},form;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
- 'module' => '{type_legend},type;{include_legend},module;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space'
- ),
- // Subpalettes
- 'subpalettes' => array
- (
- 'protected' => 'groups',
- 'addImage' => 'singleSRC,alt,size,imagemargin,imageUrl,fullsize,caption,floating',
- 'sortable' => 'sortIndex,sortOrder',
- 'useImage' => 'singleSRC,alt,size,caption'
- ),
- // Fields
- 'fields' => array
- (
- 'invisible' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['invisible']
- ),
- 'type' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['type'],
- 'default' => 'text',
- 'exclude' => true,
- 'filter' => true,
- 'inputType' => 'select',
- 'options_callback' => array('tl_content', 'getContentElements'),
- 'reference' => &$GLOBALS['TL_LANG']['CTE'],
- 'eval' => array('helpwizard'=>true, 'submitOnChange'=>true)
- ),
- 'headline' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['headline'],
- 'exclude' => true,
- 'search' => true,
- 'inputType' => 'inputUnit',
- 'options' => array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'),
- 'eval' => array('maxlength'=>255)
- ),
- 'text' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['text'],
- 'exclude' => true,
- 'search' => true,
- 'inputType' => 'textarea',
- 'eval' => array('mandatory'=>true, 'rte'=>'tinyMCE', 'helpwizard'=>true),
- 'explanation' => 'insertTags'
- ),
- 'addImage' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['addImage'],
- 'exclude' => true,
- 'inputType' => 'checkbox',
- 'eval' => array('submitOnChange'=>true)
- ),
- 'singleSRC' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['singleSRC'],
- 'exclude' => true,
- 'inputType' => 'fileTree',
- 'eval' => array('fieldType'=>'radio', 'files'=>true, 'mandatory'=>true, 'tl_class'=>'clr')
- ),
- 'alt' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['alt'],
- 'exclude' => true,
- 'search' => true,
- 'inputType' => 'text',
- 'eval' => array('mandatory'=>true, 'maxlength'=>255, 'tl_class'=>'long')
- ),
- 'size' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['size'],
- 'exclude' => true,
- 'inputType' => 'imageSize',
- 'options' => array('crop', 'proportional', 'box'),
- 'reference' => &$GLOBALS['TL_LANG']['MSC'],
- 'eval' => array('rgxp'=>'digit', 'nospace'=>true, 'tl_class'=>'w50')
- ),
- 'imagemargin' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['imagemargin'],
- 'exclude' => true,
- 'inputType' => 'trbl',
- 'options' => array('px', '%', 'em', 'pt', 'pc', 'in', 'cm', 'mm'),
- 'eval' => array('includeBlankOption'=>true, 'tl_class'=>'w50')
- ),
- 'imageUrl' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['imageUrl'],
- 'exclude' => true,
- 'search' => true,
- 'inputType' => 'text',
- 'eval' => array('rgxp'=>'url', 'decodeEntities'=>true, 'maxlength'=>255, 'tl_class'=>'w50 wizard'),
- 'wizard' => array
- (
- array('tl_content', 'pagePicker')
- )
- ),
- 'fullsize' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['fullsize'],
- 'exclude' => true,
- 'inputType' => 'checkbox',
- 'eval' => array('tl_class'=>'w50 m12')
- ),
- 'caption' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['caption'],
- 'exclude' => true,
- 'search' => true,
- 'inputType' => 'text',
- 'eval' => array('maxlength'=>255, 'tl_class'=>'w50')
- ),
- 'floating' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['floating'],
- 'exclude' => true,
- 'inputType' => 'radioTable',
- 'options' => array('above', 'left', 'right', 'below'),
- 'eval' => array('cols'=>4),
- 'reference' => &$GLOBALS['TL_LANG']['MSC'],
- 'eval' => array('tl_class'=>'w50')
- ),
- 'html' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['html'],
- 'exclude' => true,
- 'search' => true,
- 'inputType' => 'textarea',
- 'eval' => array('mandatory'=>true, 'allowHtml'=>true, 'class'=>'monospace')
- ),
- 'listtype' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['listtype'],
- 'exclude' => true,
- 'inputType' => 'select',
- 'options' => array('ordered', 'unordered'),
- 'reference' => &$GLOBALS['TL_LANG']['tl_content']
- ),
- 'listitems' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['listitems'],
- 'exclude' => true,
- 'inputType' => 'listWizard',
- 'eval' => array('allowHtml'=>true)
- ),
- 'tableitems' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['tableitems'],
- 'exclude' => true,
- 'inputType' => 'tableWizard',
- 'eval' => array('allowHtml'=>true, 'doNotSaveEmpty'=>true, 'style'=>'width:142px; height:66px;')
- ),
- 'summary' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['summary'],
- 'exclude' => true,
- 'search' => true,
- 'inputType' => 'text',
- 'eval' => array('mandatory'=>true, 'maxlength'=>255)
- ),
- 'thead' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['thead'],
- 'exclude' => true,
- 'inputType' => 'checkbox',
- 'eval' => array('tl_class'=>'w50')
- ),
- 'tfoot' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['tfoot'],
- 'exclude' => true,
- 'inputType' => 'checkbox',
- 'eval' => array('tl_class'=>'w50')
- ),
- 'sortable' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['sortable'],
- 'exclude' => true,
- 'inputType' => 'checkbox',
- 'eval' => array('submitOnChange'=>true)
- ),
- 'sortIndex' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['sortIndex'],
- 'exclude' => true,
- 'inputType' => 'text',
- 'eval' => array('rgxp'=>'digit', 'tl_class'=>'w50')
- ),
- 'sortOrder' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['sortOrder'],
- 'default' => 'ascending',
- 'exclude' => true,
- 'inputType' => 'select',
- 'options' => array('ascending', 'descending'),
- 'reference' => &$GLOBALS['TL_LANG']['MSC'],
- 'eval' => array('tl_class'=>'w50')
- ),
- 'mooType' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['mooType'],
- 'default' => 'start',
- 'exclude' => true,
- 'inputType' => 'radio',
- 'options' => array('start', 'stop', 'single'),
- 'reference' => &$GLOBALS['TL_LANG']['tl_content'],
- 'eval' => array('helpwizard'=>true, 'submitOnChange'=>true)
- ),
- 'mooHeadline' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['mooHeadline'],
- 'exclude' => true,
- 'inputType' => 'text',
- 'eval' => array('maxlength'=>255, 'allowHtml'=>true)
- ),
- 'mooStyle' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['mooStyle'],
- 'exclude' => true,
- 'inputType' => 'text',
- 'eval' => array('maxlength'=>255, 'decodeEntities'=>true, 'tl_class'=>'w50')
- ),
- 'mooClasses' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['mooClasses'],
- 'exclude' => true,
- 'search' => true,
- 'inputType' => 'text',
- 'eval' => array('multiple'=>true, 'size'=>2, 'rgxp'=>'alnum', 'tl_class'=>'w50')
- ),
- 'highlight' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['highlight'],
- 'exclude' => true,
- 'inputType' => 'select',
- 'options' => array('AS3', 'Bash', 'C', 'CSharp', 'CSS', 'Delphi', 'Diff', 'Groovy', 'Java', 'JavaFx', 'JavaScript', 'Perl', 'PHP', 'PowerShell', 'Python', 'Ruby', 'Scala', 'SQL', 'Text', 'VB', 'XHTML', 'XML'),
- 'eval' => array('includeBlankOption'=>true, 'tl_class'=>'w50')
- ),
- 'shClass' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['shClass'],
- 'exclude' => true,
- 'inputType' => 'text',
- 'eval' => array('tl_class'=>'w50', 'helpwizard'=>true),
- 'explanation' => 'highlighter'
- ),
- 'code' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['code'],
- 'exclude' => true,
- 'search' => true,
- 'inputType' => 'textarea',
- 'eval' => array('mandatory'=>true, 'preserveTags'=>true, 'decodeEntities'=>true, 'class'=>'monospace', 'tl_class'=>'clr')
- ),
- 'url' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['MSC']['url'],
- 'exclude' => true,
- 'search' => true,
- 'inputType' => 'text',
- 'eval' => array('mandatory'=>true, 'rgxp'=>'url', 'decodeEntities'=>true, 'maxlength'=>255, 'tl_class'=>'w50 wizard'),
- 'wizard' => array
- (
- array('tl_content', 'pagePicker')
- )
- ),
- 'target' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['MSC']['target'],
- 'exclude' => true,
- 'inputType' => 'checkbox',
- 'eval' => array('tl_class'=>'w50 m12')
- ),
- 'linkTitle' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['linkTitle'],
- 'exclude' => true,
- 'search' => true,
- 'inputType' => 'text',
- 'eval' => array('maxlength'=>255, 'tl_class'=>'w50')
- ),
- 'embed' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['embed'],
- 'exclude' => true,
- 'inputType' => 'text',
- 'eval' => array('maxlength'=>255, 'tl_class'=>'long clr')
- ),
- 'rel' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['rel'],
- 'exclude' => true,
- 'search' => true,
- 'inputType' => 'text',
- 'eval' => array('maxlength'=>64, 'tl_class'=>'w50')
- ),
- 'useImage' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['useImage'],
- 'exclude' => true,
- 'inputType' => 'checkbox',
- 'eval' => array('submitOnChange'=>true)
- ),
- 'multiSRC' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['multiSRC'],
- 'exclude' => true,
- 'inputType' => 'fileTree',
- 'eval' => array('fieldType'=>'checkbox', 'files'=>true, 'mandatory'=>true)
- ),
- 'useHomeDir' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['useHomeDir'],
- 'exclude' => true,
- 'inputType' => 'checkbox'
- ),
- 'perRow' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['perRow'],
- 'default' => 4,
- 'exclude' => true,
- 'inputType' => 'select',
- 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),
- 'eval' => array('tl_class'=>'w50')
- ),
- 'perPage' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['perPage'],
- 'exclude' => true,
- 'inputType' => 'text',
- 'eval' => array('rgxp'=>'digit', 'tl_class'=>'w50')
- ),
- 'sortBy' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['sortBy'],
- 'exclude' => true,
- 'inputType' => 'select',
- 'options' => array('name_asc', 'name_desc', 'date_asc', 'date_desc', 'meta', 'random'),
- 'reference' => &$GLOBALS['TL_LANG']['tl_content'],
- 'eval' => array('tl_class'=>'w50')
- ),
- 'galleryTpl' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['galleryTpl'],
- 'exclude' => true,
- 'inputType' => 'select',
- 'options' => $this->getTemplateGroup('gallery_')
- ),
- 'cteAlias' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['cteAlias'],
- 'exclude' => true,
- 'inputType' => 'select',
- 'options_callback' => array('tl_content', 'getAlias'),
- 'eval' => array('mandatory'=>true, 'submitOnChange'=>true),
- 'wizard' => array
- (
- array('tl_content', 'editAlias')
- )
- ),
- 'articleAlias' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['articleAlias'],
- 'exclude' => true,
- 'inputType' => 'select',
- 'options_callback' => array('tl_content', 'getArticleAlias'),
- 'eval' => array('mandatory'=>true, 'submitOnChange'=>true),
- 'wizard' => array
- (
- array('tl_content', 'editArticleAlias')
- )
- ),
- 'article' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['article'],
- 'exclude' => true,
- 'inputType' => 'select',
- 'options_callback' => array('tl_content', 'getArticles'),
- 'eval' => array('mandatory'=>true, 'submitOnChange'=>true),
- 'wizard' => array
- (
- array('tl_content', 'editArticle')
- )
- ),
- 'form' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['form'],
- 'exclude' => true,
- 'inputType' => 'select',
- 'options_callback' => array('tl_content', 'getForms'),
- 'eval' => array('mandatory'=>true, 'submitOnChange'=>true),
- 'wizard' => array
- (
- array('tl_content', 'editForm')
- )
- ),
- 'module' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['module'],
- 'exclude' => true,
- 'inputType' => 'select',
- 'options_callback' => array('tl_content', 'getModules'),
- 'eval' => array('mandatory'=>true, 'submitOnChange'=>true),
- 'wizard' => array
- (
- array('tl_content', 'editModule')
- )
- ),
- 'protected' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['protected'],
- 'exclude' => true,
- 'filter' => true,
- 'inputType' => 'checkbox',
- 'eval' => array('submitOnChange'=>true)
- ),
- 'groups' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['groups'],
- 'exclude' => true,
- 'inputType' => 'checkbox',
- 'foreignKey' => 'tl_member_group.name',
- 'eval' => array('mandatory'=>true, 'multiple'=>true)
- ),
- 'guests' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['guests'],
- 'exclude' => true,
- 'filter' => true,
- 'inputType' => 'checkbox'
- ),
- 'cssID' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['cssID'],
- 'exclude' => true,
- 'inputType' => 'text',
- 'eval' => array('multiple'=>true, 'size'=>2, 'tl_class'=>'w50')
- ),
- 'space' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['space'],
- 'exclude' => true,
- 'inputType' => 'text',
- 'eval' => array('multiple'=>true, 'size'=>2, 'rgxp'=>'digit', 'nospace'=>true)
- ),
- 'source' => array
- (
- 'label' => &$GLOBALS['TL_LANG']['tl_content']['source'],
- 'eval' => array('fieldType'=>'checkbox', 'files'=>true, 'filesOnly'=>true, 'extensions'=>'csv')
- )
- )
- );
- /**
- * Class tl_content
- *
- * Provide miscellaneous methods that are used by the data configuration array.
- * @copyright Leo Feyer 2005-2010
- * @author Leo Feyer <http://www.typolight.org>
- * @package Controller
- */
- class tl_content extends Backend
- {
- /**
- * Import the back end user object
- */
- public function __construct()
- {
- parent::__construct();
- $this->import('BackendUser', 'User');
- }
- /**
- * Check permissions to edit table tl_content
- */
- public function checkPermission()
- {
- if ($this->User->isAdmin)
- {
- return;
- }
- $groups = $this->User->groups;
- // Set default user and group
- $GLOBALS['TL_DCA']['tl_page']['fields']['cuser']['default'] = ($GLOBALS['TL_CONFIG']['defaultUser'] != '') ? $GLOBALS['TL_CONFIG']['defaultUser'] : $this->User->id;
- $GLOBALS['TL_DCA']['tl_page']['fields']['cgroup']['default'] = ($GLOBALS['TL_CONFIG']['defaultGroup'] != '') ? $GLOBALS['TL_CONFIG']['defaultGroup'] : $groups[0];
- // Get pagemounts
- $pagemounts = array();
- foreach ($this->User->pagemounts as $root)
- {
- $pagemounts[] = $root;
- $pagemounts = array_merge($pagemounts, $this->getChildRecords($root, 'tl_page', true));
- }
- $pagemounts = array_unique($pagemounts);
- // Check the current action
- switch ($this->Input->get('act'))
- {
- case 'paste':
- // Allow
- break;
- case '': // empty
- case 'create':
- case 'select':
- // Check access to the article
- if (!$this->checkAccessToElement(CURRENT_ID, $pagemounts, true))
- {
- $this->redirect('typolight/main.php?act=error');
- }
- break;
- case 'editAll':
- case 'deleteAll':
- case 'overrideAll':
- case 'cutAll':
- case 'copyAll':
- // Check access to the parent element if a content element is moved
- if (($this->Input->get('act') == 'cutAll' || $this->Input->get('act') == 'copyAll') && !$this->checkAccessToElement($this->Input->get('pid'), $pagemounts, ($this->Input->get('mode') == 2)))
- {
- $this->redirect('typolight/main.php?act=error');
- }
- $objCes = $this->Database->prepare("SELECT id FROM tl_content WHERE pid=?")
- ->execute(CURRENT_ID);
- $session = $this->Session->getData();
- $session['CURRENT']['IDS'] = array_intersect($session['CURRENT']['IDS'], $objCes->fetchEach('id'));
- $this->Session->setData($session);
- break;
- case 'cut':
- case 'copy':
- // Check access to the parent element if a content element is moved
- if (!$this->checkAccessToElement($this->Input->get('pid'), $pagemounts, ($this->Input->get('mode') == 2)))
- {
- $this->redirect('typolight/main.php?act=error');
- }
- // NO BREAK STATEMENT HERE
- default:
- // Check access to the content element
- if (!$this->checkAccessToElement($this->Input->get('id'), $pagemounts))
- {
- $this->redirect('typolight/main.php?act=error');
- }
- break;
- }
- }
- /**
- * Check access to a particular content element
- * @param integer
- * @param array
- * @param boolean
- * @return boolean
- */
- protected function checkAccessToElement($id, $pagemounts, $blnIsPid=false)
- {
- if ($blnIsPid)
- {
- $objPage = $this->Database->prepare("SELECT p.id, p.pid, p.includeChmod, p.chmod, p.cuser, p.cgroup, a.id AS aid FROM tl_article a, tl_page p WHERE a.id=? AND a.pid=p.id")
- ->limit(1)
- ->execute($id);
- }
- else
- {
- $objPage = $this->Database->prepare("SELECT p.id, p.pid, p.includeChmod, p.chmod, p.cuser, p.cgroup, a.id AS aid FROM tl_content c, tl_article a, tl_page p WHERE c.id=? AND c.pid=a.id AND a.pid=p.id")
- ->limit(1)
- ->execute($id);
- }
- // Invalid ID
- if ($objPage->numRows < 1)
- {
- $this->log('Invalid content element ID ' . $id, 'tl_content checkAccessToElement()', TL_ERROR);
- return false;
- }
- // The page is not mounted
- if (!in_array($objPage->id, $pagemounts))
- {
- $this->log('Not enough permissions to modify article ID ' . $objPage->aid . ' on page ID ' . $objPage->id, 'tl_content checkAccessToElement()', TL_ERROR);
- return false;
- }
- // Not enough permissions to modify the article
- if (!$this->User->isAllowed(4, $objPage->row()))
- {
- $this->log('Not enough permissions to modify article ID ' . $objPage->aid, 'tl_content checkAccessToElement()', TL_ERROR);
- return false;
- }
- return true;
- }
- /**
- * Return all content elements as array
- * @return array
- */
- public function getContentElements()
- {
- $groups = array();
- foreach ($GLOBALS['TL_CTE'] as $k=>$v)
- {
- foreach (array_keys($v) as $kk)
- {
- $groups[$k][] = $kk;
- }
- }
- return $groups;
- }
- /**
- * Add the type of content element
- * @param array
- * @return string
- */
- public function addCteType($arrRow)
- {
- $key = $arrRow['invisible'] ? 'unpublished' : 'published';
- return '
- <div class="cte_type ' . $key . '">' . $GLOBALS['TL_LANG']['CTE'][$arrRow['type']][0] . (($arrRow['type'] == 'alias') ? ' ID ' . $arrRow['cteAlias'] : '') . ($arrRow['protected'] ? ' (' . $GLOBALS['TL_LANG']['MSC']['protected'] . ')' : '') . '</div>
- <div class="limit_height' . (!$GLOBALS['TL_CONFIG']['doNotCollapse'] ? ' h64' : '') . ' block">
- ' . $this->getContentElement($arrRow['id']) . '
- </div>' . "\n";
- }
- /**
- * Return the edit article alias wizard
- * @param object
- * @return string
- */
- public function editArticleAlias(DataContainer $dc)
- {
- return ($dc->value < 1) ? '' : ' <a href="typolight/main.php?do=article&table=tl_article&act=edit&id=' . $dc->value . '" title="'.sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editalias'][1]), $dc->value).'" style="padding-left:3px;">' . $this->generateImage('alias.gif', $GLOBALS['TL_LANG']['tl_content']['editalias'][0], 'style="vertical-align:top;"') . '</a>';
- }
- /**
- * Get all articles and return them as array (article alias)
- * @param object
- * @return array
- */
- public function getArticleAlias(DataContainer $dc)
- {
- $arrPids = array();
- $arrAlias = array();
- if (!$this->User->isAdmin)
- {
- foreach ($this->User->pagemounts as $id)
- {
- $arrPids[] = $id;
- $arrPids = array_merge($arrPids, $this->getChildRecords($id, 'tl_page', true));
- }
- if (empty($arrPids))
- {
- return $arrAlias;
- }
- $objAlias = $this->Database->prepare("SELECT a.id, a.title, a.inColumn, p.title AS parent FROM tl_article a LEFT JOIN tl_page p ON p.id=a.pid WHERE a.pid IN(". implode(',', array_map('intval', array_unique($arrPids))) .") AND a.id!=(SELECT pid FROM tl_content WHERE id=?) ORDER BY parent, a.sorting")
- ->execute($dc->id);
- }
- else
- {
- $objAlias = $this->Database->prepare("SELECT a.id, a.title, a.inColumn, p.title AS parent FROM tl_article a LEFT JOIN tl_page p ON p.id=a.pid WHERE a.id!=(SELECT pid FROM tl_content WHERE id=?) ORDER BY parent, a.sorting")
- ->execute($dc->id);
- }
- if ($objAlias->numRows)
- {
- $this->loadLanguageFile('tl_article');
- while ($objAlias->next())
- {
- $arrAlias[$objAlias->parent][$objAlias->id] = $objAlias->title . ' (' . (strlen($GLOBALS['TL_LANG']['tl_article'][$objAlias->inColumn]) ? $GLOBALS['TL_LANG']['tl_article'][$objAlias->inColumn] : $objAlias->inColumn) . ', ID ' . $objAlias->id . ')';
- }
- }
- return $arrAlias;
- }
- /**
- * Return the edit alias wizard
- * @param object
- * @return string
- */
- public function editAlias(DataContainer $dc)
- {
- return ($dc->value < 1) ? '' : ' <a href="'.preg_replace('/id=[0-9]+/', 'id=' . $dc->value, ampersand($this->Environment->request)).'" title="'.sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editalias'][1]), $dc->value).'" style="padding-left:3px;">' . $this->generateImage('alias.gif', $GLOBALS['TL_LANG']['tl_content']['editalias'][0], 'style="vertical-align:top;"') . '</a>';
- }
- /**
- * Get all content elements and return them as array (content element alias)
- * @return array
- */
- public function getAlias()
- {
- $this->import('String');
- $arrPids = array();
- $arrAlias = array();
- if (!$this->User->isAdmin)
- {
- foreach ($this->User->pagemounts as $id)
- {
- $arrPids[] = $id;
- $arrPids = array_merge($arrPids, $this->getChildRecords($id, 'tl_page', true));
- }
- if (empty($arrPids))
- {
- return $arrAlias;
- }
- $objAlias = $this->Database->prepare("SELECT c.id, c.type, (CASE c.type WHEN 'module' THEN m.name WHEN 'form' THEN f.title WHEN 'table' THEN c.summary ELSE c.headline END) AS headline, c.text, a.title FROM tl_content c LEFT JOIN tl_article a ON a.id=c.pid LEFT JOIN tl_module m ON m.id=c.module LEFT JOIN tl_form f on f.id=c.form WHERE a.pid IN(". implode(',', array_map('intval', array_unique($arrPids))) .") AND c.id!=? ORDER BY a.title, c.sorting")
- ->execute($this->Input->get('id'));
- }
- else
- {
- $objAlias = $this->Database->prepare("SELECT c.id, c.type, (CASE c.type WHEN 'module' THEN m.name WHEN 'form' THEN f.title WHEN 'table' THEN c.summary ELSE c.headline END) AS headline, c.text, a.title FROM tl_content c LEFT JOIN tl_article a ON a.id=c.pid LEFT JOIN tl_module m ON m.id=c.module LEFT JOIN tl_form f on f.id=c.form WHERE c.id!=? ORDER BY a.title, c.sorting")
- ->execute($this->Input->get('id'));
- }
- while ($objAlias->next())
- {
- $arrHeadline = deserialize($objAlias->headline, true);
- $headline = $this->String->substr(preg_replace('/[\n\r\t]+/', ' ', $arrHeadline[0]), 32, true) . (($arrHeadline[0] != '') ? ', ' : '');
- $text = $this->String->substr(strip_tags(preg_replace('/[\n\r\t]+/', ' ', $objAlias->text)), 32, true) . (($objAlias->text != '') ? ', ' : '');
- $arrAlias[$objAlias->title][$objAlias->id] = $GLOBALS['TL_LANG']['CTE'][$objAlias->type][0] . ' (' . (strlen($headline) ? $headline : $text) . 'ID ' . $objAlias->id . ')';
- }
- return $arrAlias;
- }
- /**
- * Return the edit form wizard
- * @param object
- * @return string
- */
- public function editForm(DataContainer $dc)
- {
- return ($dc->value < 1) ? '' : ' <a href="typolight/main.php?do=form&act=edit&id=' . $dc->value . '" title="'.sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editalias'][1]), $dc->value).'" style="padding-left:3px;">' . $this->generateImage('alias.gif', $GLOBALS['TL_LANG']['tl_content']['editalias'][0], 'style="vertical-align:top;"') . '</a>';
- }
- /**
- * Get all forms and return them as array
- * @return array
- */
- public function getForms()
- {
- if (!$this->User->isAdmin && !is_array($this->User->forms))
- {
- return array();
- }
- $arrForms = array();
- $objForms = $this->Database->execute("SELECT id, title FROM tl_form ORDER BY title");
- while ($objForms->next())
- {
- if ($this->User->isAdmin || $this->User->hasAccess($objForms->id, 'forms'))
- {
- $arrForms[$objForms->id] = $objForms->title . ' (ID ' . $objForms->id . ')';
- }
- }
- return $arrForms;
- }
- /**
- * Return the edit module wizard
- * @param object
- * @return string
- */
- public function editModule(DataContainer $dc)
- {
- return ($dc->value < 1) ? '' : ' <a href="typolight/main.php?do=modules&act=edit&id=' . $dc->value . '" title="'.sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editalias'][1]), $dc->value).'" style="padding-left:3px;">' . $this->generateImage('alias.gif', $GLOBALS['TL_LANG']['tl_content']['editalias'][0], 'style="vertical-align:top;"') . '</a>';
- }
- /**
- * Get all modules and return them as array
- * @return array
- */
- public function getModules()
- {
- $arrModules = array();
- $objModules = $this->Database->execute("SELECT id, name FROM tl_module ORDER BY name");
- while ($objModules->next())
- {
- $arrModules[$objModules->id] = $objModules->name . ' (ID ' . $objModules->id . ')';
- }
- return $arrModules;
- }
- /**
- * Return the edit article teaser wizard
- * @param object
- * @return string
- */
- public function editArticle(DataContainer $dc)
- {
- return ($dc->value < 1) ? '' : ' <a href="typolight/main.php?do=article&table=tl_content&id=' . $dc->value . '" title="'.sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editarticle'][1]), $dc->value).'">' . $this->generateImage('alias.gif', $GLOBALS['TL_LANG']['tl_content']['editarticle'][0], 'style="vertical-align:top;"') . '</a>';
- }
- /**
- * Get all articles and return them as array (article teaser)
- * @param object
- * @return array
- */
- public function getArticles(DataContainer $dc)
- {
- $arrPids = array();
- $arrArticle = array();
- $arrRoot = array();
- // Limit pages to the website root
- $objPage = $this->Database->prepare("SELECT pid FROM tl_article WHERE id=?")
- ->limit(1)
- ->execute($dc->activeRecord->pid);
- if ($objPage->numRows)
- {
- $objPage = $this->getPageDetails($objPage->pid);
- $arrRoot = $this->getChildRecords($objPage->rootId, 'tl_page', true);
- }
- // Limit pages to the user's pagemounts
- if (!$this->User->isAdmin)
- {
- foreach ($this->User->pagemounts as $id)
- {
- if (!in_array($id, $arrRoot))
- {
- continue;
- }
- $arrPids[] = $id;
- $arrPids = array_merge($arrPids, $this->getChildRecords($id, 'tl_page', true));
- }
- if (empty($arrPids))
- {
- return $arrArticle;
- }
- $objArticle = $this->Database->execute("SELECT a.id, a.title, a.inColumn, p.title AS parent FROM tl_article a LEFT JOIN tl_page p ON p.id=a.pid WHERE a.pid IN(". implode(',', array_map('intval', array_unique($arrPids))) .") ORDER BY parent, a.sorting");
- }
- else
- {
- $objArticle = $this->Database->execute("SELECT a.id, a.title, a.inColumn, p.title AS parent FROM tl_article a LEFT JOIN tl_page p ON p.id=a.pid WHERE a.pid IN(". implode(',', array_map('intval', array_unique($arrRoot))) .") ORDER BY parent, a.sorting");
- }
- if ($objArticle->numRows)
- {
- $this->loadLanguageFile('tl_article');
- while ($objArticle->next())
- {
- $arrArticle[$objArticle->parent][$objArticle->id] = $objArticle->title . ' (' . (strlen($GLOBALS['TL_LANG']['tl_article'][$objArticle->inColumn]) ? $GLOBALS['TL_LANG']['tl_article'][$objArticle->inColumn] : $objArticle->inColumn) . ', ID ' . $objArticle->id . ')';
- }
- }
- return $arrArticle;
- }
- /**
- * Return the link picker wizard
- * @param object
- * @return string
- */
- public function pagePicker(DataContainer $dc)
- {
- $strField = 'ctrl_' . $dc->field . (($this->Input->get('act') == 'editAll') ? '_' . $dc->id : '');
- return ' ' . $this->generateImage('pickpage.gif', $GLOBALS['TL_LANG']['MSC']['pagepicker'], 'style="vertical-align:top; cursor:pointer;" onclick="Backend.pickPage(\'' . $strField . '\')"');
- }
- /**
- * Return the delete content element button
- * @param array
- * @param string
- * @param string
- * @param string
- * @param string
- * @param string
- * @return string
- */
- public function deleteElement($row, $href, $label, $title, $icon, $attributes)
- {
- $objElement = $this->Database->prepare("SELECT id FROM tl_content WHERE cteAlias=? AND type=?")
- ->limit(1)
- ->execute($row['id'], 'alias');
- return $objElement->numRows ? $this->generateImage(preg_replace('/\.gif$/i', '_.gif', $icon)) . ' ' : '<a href="'.$this->addToUrl($href.'&id='.$row['id']).'" title="'.specialchars($title).'"'.$attributes.'>'.$this->generateImage($icon, $label).'</a> ';
- }
- /**
- * Return the "toggle visibility" button
- * @param array
- * @param string
- * @param string
- * @param string
- * @param string
- * @param string
- * @return string
- */
- public function toggleIcon($row, $href, $label, $title, $icon, $attributes)
- {
- if (strlen($this->Input->get('tid')))
- {
- $this->toggleVisibility($this->Input->get('tid'), ($this->Input->get('state') == 1));
- $this->redirect($this->getReferer());
- }
- $href .= '&id='.$this->Input->get('id').'&tid='.$row['id'].'&state='.$row['invisible'];
- if ($row['invisible'])
- {
- $icon = 'invisible.gif';
- }
- return '<a href="'.$this->addToUrl($href).'" title="'.specialchars($title).'"'.$attributes.'>'.$this->generateImage($icon, $label).'</a> ';
- }
- /**
- * Toggle the visibility of an element
- * @param integer
- * @param boolean
- */
- public function toggleVisibility($intId, $blnVisible)
- {
- // Check permissions to edit
- $this->Input->setGet('id', $intId);
- $this->Input->setGet('act', 'toggle');
- $this->checkPermission();
-
- $this->createInitialVersion('tl_content', $intId);
- // Trigger the save_callback
- if (is_array($GLOBALS['TL_DCA']['tl_content']['fields']['invisible']['save_callback']))
- {
- foreach ($GLOBALS['TL_DCA']['tl_content']['fields']['invisible']['save_callback'] as $callback)
- {
- $this->import($callback[0]);
- $blnVisible = $this->$callback[0]->$callback[1]($blnVisible, $this);
- }
- }
- // Update the database
- $this->Database->prepare("UPDATE tl_content SET invisible='" . ($blnVisible ? '' : 1) . "' WHERE id=?")
- ->execute($intId);
- $this->createNewVersion('tl_content', $intId);
- }
- }
- ?>