PageRenderTime 65ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/system/modules/backend/dca/tl_content.php

https://github.com/alaittin/testing_tv
PHP | 1131 lines | 871 code | 103 blank | 157 comment | 46 complexity | 4bc03a1667c0459b31916ac714f9a350 MD5 | raw file
  1. <?php if (!defined('TL_ROOT')) die('You can not access this file directly!');
  2. /**
  3. * TYPOlight Open Source CMS
  4. * Copyright (C) 2005-2010 Leo Feyer
  5. *
  6. * This program is free software: you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation, either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this program. If not, please visit the Free
  18. * Software Foundation website at <http://www.gnu.org/licenses/>.
  19. *
  20. * PHP version 5
  21. * @copyright Leo Feyer 2005-2010
  22. * @author Leo Feyer <http://www.typolight.org>
  23. * @package Backend
  24. * @license LGPL
  25. * @filesource
  26. */
  27. /**
  28. * Table tl_content
  29. */
  30. $GLOBALS['TL_DCA']['tl_content'] = array
  31. (
  32. // Config
  33. 'config' => array
  34. (
  35. 'dataContainer' => 'Table',
  36. 'ptable' => 'tl_article',
  37. 'enableVersioning' => true,
  38. 'onload_callback' => array
  39. (
  40. array('tl_content', 'checkPermission')
  41. )
  42. ),
  43. // List
  44. 'list' => array
  45. (
  46. 'sorting' => array
  47. (
  48. 'mode' => 4,
  49. 'fields' => array('sorting'),
  50. 'panelLayout' => 'filter;search,limit',
  51. 'headerFields' => array('title', 'author', 'inColumn', 'tstamp', 'showTeaser', 'printable', 'published', 'start', 'stop'),
  52. 'child_record_callback' => array('tl_content', 'addCteType')
  53. ),
  54. 'global_operations' => array
  55. (
  56. 'all' => array
  57. (
  58. 'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
  59. 'href' => 'act=select',
  60. 'class' => 'header_edit_all',
  61. 'attributes' => 'onclick="Backend.getScrollOffset();"'
  62. )
  63. ),
  64. 'operations' => array
  65. (
  66. 'edit' => array
  67. (
  68. 'label' => &$GLOBALS['TL_LANG']['tl_content']['edit'],
  69. 'href' => 'act=edit',
  70. 'icon' => 'edit.gif'
  71. ),
  72. 'copy' => array
  73. (
  74. 'label' => &$GLOBALS['TL_LANG']['tl_content']['copy'],
  75. 'href' => 'act=paste&amp;mode=copy',
  76. 'icon' => 'copy.gif',
  77. 'attributes' => 'onclick="Backend.getScrollOffset();"'
  78. ),
  79. 'cut' => array
  80. (
  81. 'label' => &$GLOBALS['TL_LANG']['tl_content']['cut'],
  82. 'href' => 'act=paste&amp;mode=cut',
  83. 'icon' => 'cut.gif',
  84. 'attributes' => 'onclick="Backend.getScrollOffset();"'
  85. ),
  86. 'delete' => array
  87. (
  88. 'label' => &$GLOBALS['TL_LANG']['tl_content']['delete'],
  89. 'href' => 'act=delete',
  90. 'icon' => 'delete.gif',
  91. 'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"',
  92. 'button_callback' => array('tl_content', 'deleteElement')
  93. ),
  94. 'toggle' => array
  95. (
  96. 'label' => &$GLOBALS['TL_LANG']['tl_content']['toggle'],
  97. 'icon' => 'visible.gif',
  98. 'attributes' => 'onclick="Backend.getScrollOffset(); return AjaxRequest.toggleVisibility(this, %s);"',
  99. 'button_callback' => array('tl_content', 'toggleIcon')
  100. ),
  101. 'show' => array
  102. (
  103. 'label' => &$GLOBALS['TL_LANG']['tl_content']['show'],
  104. 'href' => 'act=show',
  105. 'icon' => 'show.gif'
  106. )
  107. ),
  108. ),
  109. // Palettes
  110. 'palettes' => array
  111. (
  112. '__selector__' => array('type', 'mooType', 'addImage', 'useImage', 'sortable', 'protected'),
  113. 'default' => '{type_legend},type',
  114. 'headline' => '{type_legend},type,headline;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
  115. 'text' => '{type_legend},type,headline;{text_legend},text;{image_legend},addImage;{protected_legend:hide},protected;{expert_legend},{expert_legend:hide},guests,cssID,space',
  116. 'html' => '{type_legend},type;{text_legend},html;{protected_legend:hide},protected;{expert_legend},{expert_legend:hide},guests',
  117. 'list' => '{type_legend},type,headline;{list_legend},listtype,listitems;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
  118. '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',
  119. 'accordion' => '{type_legend},type,mooType',
  120. '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',
  121. 'accordionstart' => '{type_legend},type,mooType;{moo_legend},mooHeadline,mooStyle,mooClasses;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
  122. 'accordionstop' => '{type_legend},type,mooType;{moo_legend},mooClasses;{protected_legend:hide},protected;{expert_legend:hide},guests',
  123. 'code' => '{type_legend},type,headline;{text_legend},highlight,shClass,code;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
  124. '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',
  125. 'toplink' => '{type_legend},type,linkTitle;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
  126. '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',
  127. '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',
  128. 'download' => '{type_legend},type,headline;{source_legend},singleSRC;{dwnconfig_legend},linkTitle;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
  129. 'downloads' => '{type_legend},type,headline;{source_legend},multiSRC,useHomeDir;{dwnconfig_legend},sortBy;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
  130. 'alias' => '{type_legend},type;{include_legend},cteAlias;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
  131. 'article' => '{type_legend},type;{include_legend},articleAlias;{protected_legend:hide},protected',
  132. 'teaser' => '{type_legend},type;{include_legend},article;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
  133. 'form' => '{type_legend},type,headline;{include_legend},form;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space',
  134. 'module' => '{type_legend},type;{include_legend},module;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space'
  135. ),
  136. // Subpalettes
  137. 'subpalettes' => array
  138. (
  139. 'protected' => 'groups',
  140. 'addImage' => 'singleSRC,alt,size,imagemargin,imageUrl,fullsize,caption,floating',
  141. 'sortable' => 'sortIndex,sortOrder',
  142. 'useImage' => 'singleSRC,alt,size,caption'
  143. ),
  144. // Fields
  145. 'fields' => array
  146. (
  147. 'invisible' => array
  148. (
  149. 'label' => &$GLOBALS['TL_LANG']['tl_content']['invisible']
  150. ),
  151. 'type' => array
  152. (
  153. 'label' => &$GLOBALS['TL_LANG']['tl_content']['type'],
  154. 'default' => 'text',
  155. 'exclude' => true,
  156. 'filter' => true,
  157. 'inputType' => 'select',
  158. 'options_callback' => array('tl_content', 'getContentElements'),
  159. 'reference' => &$GLOBALS['TL_LANG']['CTE'],
  160. 'eval' => array('helpwizard'=>true, 'submitOnChange'=>true)
  161. ),
  162. 'headline' => array
  163. (
  164. 'label' => &$GLOBALS['TL_LANG']['tl_content']['headline'],
  165. 'exclude' => true,
  166. 'search' => true,
  167. 'inputType' => 'inputUnit',
  168. 'options' => array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'),
  169. 'eval' => array('maxlength'=>255)
  170. ),
  171. 'text' => array
  172. (
  173. 'label' => &$GLOBALS['TL_LANG']['tl_content']['text'],
  174. 'exclude' => true,
  175. 'search' => true,
  176. 'inputType' => 'textarea',
  177. 'eval' => array('mandatory'=>true, 'rte'=>'tinyMCE', 'helpwizard'=>true),
  178. 'explanation' => 'insertTags'
  179. ),
  180. 'addImage' => array
  181. (
  182. 'label' => &$GLOBALS['TL_LANG']['tl_content']['addImage'],
  183. 'exclude' => true,
  184. 'inputType' => 'checkbox',
  185. 'eval' => array('submitOnChange'=>true)
  186. ),
  187. 'singleSRC' => array
  188. (
  189. 'label' => &$GLOBALS['TL_LANG']['tl_content']['singleSRC'],
  190. 'exclude' => true,
  191. 'inputType' => 'fileTree',
  192. 'eval' => array('fieldType'=>'radio', 'files'=>true, 'mandatory'=>true, 'tl_class'=>'clr')
  193. ),
  194. 'alt' => array
  195. (
  196. 'label' => &$GLOBALS['TL_LANG']['tl_content']['alt'],
  197. 'exclude' => true,
  198. 'search' => true,
  199. 'inputType' => 'text',
  200. 'eval' => array('mandatory'=>true, 'maxlength'=>255, 'tl_class'=>'long')
  201. ),
  202. 'size' => array
  203. (
  204. 'label' => &$GLOBALS['TL_LANG']['tl_content']['size'],
  205. 'exclude' => true,
  206. 'inputType' => 'imageSize',
  207. 'options' => array('crop', 'proportional', 'box'),
  208. 'reference' => &$GLOBALS['TL_LANG']['MSC'],
  209. 'eval' => array('rgxp'=>'digit', 'nospace'=>true, 'tl_class'=>'w50')
  210. ),
  211. 'imagemargin' => array
  212. (
  213. 'label' => &$GLOBALS['TL_LANG']['tl_content']['imagemargin'],
  214. 'exclude' => true,
  215. 'inputType' => 'trbl',
  216. 'options' => array('px', '%', 'em', 'pt', 'pc', 'in', 'cm', 'mm'),
  217. 'eval' => array('includeBlankOption'=>true, 'tl_class'=>'w50')
  218. ),
  219. 'imageUrl' => array
  220. (
  221. 'label' => &$GLOBALS['TL_LANG']['tl_content']['imageUrl'],
  222. 'exclude' => true,
  223. 'search' => true,
  224. 'inputType' => 'text',
  225. 'eval' => array('rgxp'=>'url', 'decodeEntities'=>true, 'maxlength'=>255, 'tl_class'=>'w50 wizard'),
  226. 'wizard' => array
  227. (
  228. array('tl_content', 'pagePicker')
  229. )
  230. ),
  231. 'fullsize' => array
  232. (
  233. 'label' => &$GLOBALS['TL_LANG']['tl_content']['fullsize'],
  234. 'exclude' => true,
  235. 'inputType' => 'checkbox',
  236. 'eval' => array('tl_class'=>'w50 m12')
  237. ),
  238. 'caption' => array
  239. (
  240. 'label' => &$GLOBALS['TL_LANG']['tl_content']['caption'],
  241. 'exclude' => true,
  242. 'search' => true,
  243. 'inputType' => 'text',
  244. 'eval' => array('maxlength'=>255, 'tl_class'=>'w50')
  245. ),
  246. 'floating' => array
  247. (
  248. 'label' => &$GLOBALS['TL_LANG']['tl_content']['floating'],
  249. 'exclude' => true,
  250. 'inputType' => 'radioTable',
  251. 'options' => array('above', 'left', 'right', 'below'),
  252. 'eval' => array('cols'=>4),
  253. 'reference' => &$GLOBALS['TL_LANG']['MSC'],
  254. 'eval' => array('tl_class'=>'w50')
  255. ),
  256. 'html' => array
  257. (
  258. 'label' => &$GLOBALS['TL_LANG']['tl_content']['html'],
  259. 'exclude' => true,
  260. 'search' => true,
  261. 'inputType' => 'textarea',
  262. 'eval' => array('mandatory'=>true, 'allowHtml'=>true, 'class'=>'monospace')
  263. ),
  264. 'listtype' => array
  265. (
  266. 'label' => &$GLOBALS['TL_LANG']['tl_content']['listtype'],
  267. 'exclude' => true,
  268. 'inputType' => 'select',
  269. 'options' => array('ordered', 'unordered'),
  270. 'reference' => &$GLOBALS['TL_LANG']['tl_content']
  271. ),
  272. 'listitems' => array
  273. (
  274. 'label' => &$GLOBALS['TL_LANG']['tl_content']['listitems'],
  275. 'exclude' => true,
  276. 'inputType' => 'listWizard',
  277. 'eval' => array('allowHtml'=>true)
  278. ),
  279. 'tableitems' => array
  280. (
  281. 'label' => &$GLOBALS['TL_LANG']['tl_content']['tableitems'],
  282. 'exclude' => true,
  283. 'inputType' => 'tableWizard',
  284. 'eval' => array('allowHtml'=>true, 'doNotSaveEmpty'=>true, 'style'=>'width:142px; height:66px;')
  285. ),
  286. 'summary' => array
  287. (
  288. 'label' => &$GLOBALS['TL_LANG']['tl_content']['summary'],
  289. 'exclude' => true,
  290. 'search' => true,
  291. 'inputType' => 'text',
  292. 'eval' => array('mandatory'=>true, 'maxlength'=>255)
  293. ),
  294. 'thead' => array
  295. (
  296. 'label' => &$GLOBALS['TL_LANG']['tl_content']['thead'],
  297. 'exclude' => true,
  298. 'inputType' => 'checkbox',
  299. 'eval' => array('tl_class'=>'w50')
  300. ),
  301. 'tfoot' => array
  302. (
  303. 'label' => &$GLOBALS['TL_LANG']['tl_content']['tfoot'],
  304. 'exclude' => true,
  305. 'inputType' => 'checkbox',
  306. 'eval' => array('tl_class'=>'w50')
  307. ),
  308. 'sortable' => array
  309. (
  310. 'label' => &$GLOBALS['TL_LANG']['tl_content']['sortable'],
  311. 'exclude' => true,
  312. 'inputType' => 'checkbox',
  313. 'eval' => array('submitOnChange'=>true)
  314. ),
  315. 'sortIndex' => array
  316. (
  317. 'label' => &$GLOBALS['TL_LANG']['tl_content']['sortIndex'],
  318. 'exclude' => true,
  319. 'inputType' => 'text',
  320. 'eval' => array('rgxp'=>'digit', 'tl_class'=>'w50')
  321. ),
  322. 'sortOrder' => array
  323. (
  324. 'label' => &$GLOBALS['TL_LANG']['tl_content']['sortOrder'],
  325. 'default' => 'ascending',
  326. 'exclude' => true,
  327. 'inputType' => 'select',
  328. 'options' => array('ascending', 'descending'),
  329. 'reference' => &$GLOBALS['TL_LANG']['MSC'],
  330. 'eval' => array('tl_class'=>'w50')
  331. ),
  332. 'mooType' => array
  333. (
  334. 'label' => &$GLOBALS['TL_LANG']['tl_content']['mooType'],
  335. 'default' => 'start',
  336. 'exclude' => true,
  337. 'inputType' => 'radio',
  338. 'options' => array('start', 'stop', 'single'),
  339. 'reference' => &$GLOBALS['TL_LANG']['tl_content'],
  340. 'eval' => array('helpwizard'=>true, 'submitOnChange'=>true)
  341. ),
  342. 'mooHeadline' => array
  343. (
  344. 'label' => &$GLOBALS['TL_LANG']['tl_content']['mooHeadline'],
  345. 'exclude' => true,
  346. 'inputType' => 'text',
  347. 'eval' => array('maxlength'=>255, 'allowHtml'=>true)
  348. ),
  349. 'mooStyle' => array
  350. (
  351. 'label' => &$GLOBALS['TL_LANG']['tl_content']['mooStyle'],
  352. 'exclude' => true,
  353. 'inputType' => 'text',
  354. 'eval' => array('maxlength'=>255, 'decodeEntities'=>true, 'tl_class'=>'w50')
  355. ),
  356. 'mooClasses' => array
  357. (
  358. 'label' => &$GLOBALS['TL_LANG']['tl_content']['mooClasses'],
  359. 'exclude' => true,
  360. 'search' => true,
  361. 'inputType' => 'text',
  362. 'eval' => array('multiple'=>true, 'size'=>2, 'rgxp'=>'alnum', 'tl_class'=>'w50')
  363. ),
  364. 'highlight' => array
  365. (
  366. 'label' => &$GLOBALS['TL_LANG']['tl_content']['highlight'],
  367. 'exclude' => true,
  368. 'inputType' => 'select',
  369. 'options' => array('AS3', 'Bash', 'C', 'CSharp', 'CSS', 'Delphi', 'Diff', 'Groovy', 'Java', 'JavaFx', 'JavaScript', 'Perl', 'PHP', 'PowerShell', 'Python', 'Ruby', 'Scala', 'SQL', 'Text', 'VB', 'XHTML', 'XML'),
  370. 'eval' => array('includeBlankOption'=>true, 'tl_class'=>'w50')
  371. ),
  372. 'shClass' => array
  373. (
  374. 'label' => &$GLOBALS['TL_LANG']['tl_content']['shClass'],
  375. 'exclude' => true,
  376. 'inputType' => 'text',
  377. 'eval' => array('tl_class'=>'w50', 'helpwizard'=>true),
  378. 'explanation' => 'highlighter'
  379. ),
  380. 'code' => array
  381. (
  382. 'label' => &$GLOBALS['TL_LANG']['tl_content']['code'],
  383. 'exclude' => true,
  384. 'search' => true,
  385. 'inputType' => 'textarea',
  386. 'eval' => array('mandatory'=>true, 'preserveTags'=>true, 'decodeEntities'=>true, 'class'=>'monospace', 'tl_class'=>'clr')
  387. ),
  388. 'url' => array
  389. (
  390. 'label' => &$GLOBALS['TL_LANG']['MSC']['url'],
  391. 'exclude' => true,
  392. 'search' => true,
  393. 'inputType' => 'text',
  394. 'eval' => array('mandatory'=>true, 'rgxp'=>'url', 'decodeEntities'=>true, 'maxlength'=>255, 'tl_class'=>'w50 wizard'),
  395. 'wizard' => array
  396. (
  397. array('tl_content', 'pagePicker')
  398. )
  399. ),
  400. 'target' => array
  401. (
  402. 'label' => &$GLOBALS['TL_LANG']['MSC']['target'],
  403. 'exclude' => true,
  404. 'inputType' => 'checkbox',
  405. 'eval' => array('tl_class'=>'w50 m12')
  406. ),
  407. 'linkTitle' => array
  408. (
  409. 'label' => &$GLOBALS['TL_LANG']['tl_content']['linkTitle'],
  410. 'exclude' => true,
  411. 'search' => true,
  412. 'inputType' => 'text',
  413. 'eval' => array('maxlength'=>255, 'tl_class'=>'w50')
  414. ),
  415. 'embed' => array
  416. (
  417. 'label' => &$GLOBALS['TL_LANG']['tl_content']['embed'],
  418. 'exclude' => true,
  419. 'inputType' => 'text',
  420. 'eval' => array('maxlength'=>255, 'tl_class'=>'long clr')
  421. ),
  422. 'rel' => array
  423. (
  424. 'label' => &$GLOBALS['TL_LANG']['tl_content']['rel'],
  425. 'exclude' => true,
  426. 'search' => true,
  427. 'inputType' => 'text',
  428. 'eval' => array('maxlength'=>64, 'tl_class'=>'w50')
  429. ),
  430. 'useImage' => array
  431. (
  432. 'label' => &$GLOBALS['TL_LANG']['tl_content']['useImage'],
  433. 'exclude' => true,
  434. 'inputType' => 'checkbox',
  435. 'eval' => array('submitOnChange'=>true)
  436. ),
  437. 'multiSRC' => array
  438. (
  439. 'label' => &$GLOBALS['TL_LANG']['tl_content']['multiSRC'],
  440. 'exclude' => true,
  441. 'inputType' => 'fileTree',
  442. 'eval' => array('fieldType'=>'checkbox', 'files'=>true, 'mandatory'=>true)
  443. ),
  444. 'useHomeDir' => array
  445. (
  446. 'label' => &$GLOBALS['TL_LANG']['tl_content']['useHomeDir'],
  447. 'exclude' => true,
  448. 'inputType' => 'checkbox'
  449. ),
  450. 'perRow' => array
  451. (
  452. 'label' => &$GLOBALS['TL_LANG']['tl_content']['perRow'],
  453. 'default' => 4,
  454. 'exclude' => true,
  455. 'inputType' => 'select',
  456. 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),
  457. 'eval' => array('tl_class'=>'w50')
  458. ),
  459. 'perPage' => array
  460. (
  461. 'label' => &$GLOBALS['TL_LANG']['tl_content']['perPage'],
  462. 'exclude' => true,
  463. 'inputType' => 'text',
  464. 'eval' => array('rgxp'=>'digit', 'tl_class'=>'w50')
  465. ),
  466. 'sortBy' => array
  467. (
  468. 'label' => &$GLOBALS['TL_LANG']['tl_content']['sortBy'],
  469. 'exclude' => true,
  470. 'inputType' => 'select',
  471. 'options' => array('name_asc', 'name_desc', 'date_asc', 'date_desc', 'meta', 'random'),
  472. 'reference' => &$GLOBALS['TL_LANG']['tl_content'],
  473. 'eval' => array('tl_class'=>'w50')
  474. ),
  475. 'galleryTpl' => array
  476. (
  477. 'label' => &$GLOBALS['TL_LANG']['tl_content']['galleryTpl'],
  478. 'exclude' => true,
  479. 'inputType' => 'select',
  480. 'options' => $this->getTemplateGroup('gallery_')
  481. ),
  482. 'cteAlias' => array
  483. (
  484. 'label' => &$GLOBALS['TL_LANG']['tl_content']['cteAlias'],
  485. 'exclude' => true,
  486. 'inputType' => 'select',
  487. 'options_callback' => array('tl_content', 'getAlias'),
  488. 'eval' => array('mandatory'=>true, 'submitOnChange'=>true),
  489. 'wizard' => array
  490. (
  491. array('tl_content', 'editAlias')
  492. )
  493. ),
  494. 'articleAlias' => array
  495. (
  496. 'label' => &$GLOBALS['TL_LANG']['tl_content']['articleAlias'],
  497. 'exclude' => true,
  498. 'inputType' => 'select',
  499. 'options_callback' => array('tl_content', 'getArticleAlias'),
  500. 'eval' => array('mandatory'=>true, 'submitOnChange'=>true),
  501. 'wizard' => array
  502. (
  503. array('tl_content', 'editArticleAlias')
  504. )
  505. ),
  506. 'article' => array
  507. (
  508. 'label' => &$GLOBALS['TL_LANG']['tl_content']['article'],
  509. 'exclude' => true,
  510. 'inputType' => 'select',
  511. 'options_callback' => array('tl_content', 'getArticles'),
  512. 'eval' => array('mandatory'=>true, 'submitOnChange'=>true),
  513. 'wizard' => array
  514. (
  515. array('tl_content', 'editArticle')
  516. )
  517. ),
  518. 'form' => array
  519. (
  520. 'label' => &$GLOBALS['TL_LANG']['tl_content']['form'],
  521. 'exclude' => true,
  522. 'inputType' => 'select',
  523. 'options_callback' => array('tl_content', 'getForms'),
  524. 'eval' => array('mandatory'=>true, 'submitOnChange'=>true),
  525. 'wizard' => array
  526. (
  527. array('tl_content', 'editForm')
  528. )
  529. ),
  530. 'module' => array
  531. (
  532. 'label' => &$GLOBALS['TL_LANG']['tl_content']['module'],
  533. 'exclude' => true,
  534. 'inputType' => 'select',
  535. 'options_callback' => array('tl_content', 'getModules'),
  536. 'eval' => array('mandatory'=>true, 'submitOnChange'=>true),
  537. 'wizard' => array
  538. (
  539. array('tl_content', 'editModule')
  540. )
  541. ),
  542. 'protected' => array
  543. (
  544. 'label' => &$GLOBALS['TL_LANG']['tl_content']['protected'],
  545. 'exclude' => true,
  546. 'filter' => true,
  547. 'inputType' => 'checkbox',
  548. 'eval' => array('submitOnChange'=>true)
  549. ),
  550. 'groups' => array
  551. (
  552. 'label' => &$GLOBALS['TL_LANG']['tl_content']['groups'],
  553. 'exclude' => true,
  554. 'inputType' => 'checkbox',
  555. 'foreignKey' => 'tl_member_group.name',
  556. 'eval' => array('mandatory'=>true, 'multiple'=>true)
  557. ),
  558. 'guests' => array
  559. (
  560. 'label' => &$GLOBALS['TL_LANG']['tl_content']['guests'],
  561. 'exclude' => true,
  562. 'filter' => true,
  563. 'inputType' => 'checkbox'
  564. ),
  565. 'cssID' => array
  566. (
  567. 'label' => &$GLOBALS['TL_LANG']['tl_content']['cssID'],
  568. 'exclude' => true,
  569. 'inputType' => 'text',
  570. 'eval' => array('multiple'=>true, 'size'=>2, 'tl_class'=>'w50')
  571. ),
  572. 'space' => array
  573. (
  574. 'label' => &$GLOBALS['TL_LANG']['tl_content']['space'],
  575. 'exclude' => true,
  576. 'inputType' => 'text',
  577. 'eval' => array('multiple'=>true, 'size'=>2, 'rgxp'=>'digit', 'nospace'=>true)
  578. ),
  579. 'source' => array
  580. (
  581. 'label' => &$GLOBALS['TL_LANG']['tl_content']['source'],
  582. 'eval' => array('fieldType'=>'checkbox', 'files'=>true, 'filesOnly'=>true, 'extensions'=>'csv')
  583. )
  584. )
  585. );
  586. /**
  587. * Class tl_content
  588. *
  589. * Provide miscellaneous methods that are used by the data configuration array.
  590. * @copyright Leo Feyer 2005-2010
  591. * @author Leo Feyer <http://www.typolight.org>
  592. * @package Controller
  593. */
  594. class tl_content extends Backend
  595. {
  596. /**
  597. * Import the back end user object
  598. */
  599. public function __construct()
  600. {
  601. parent::__construct();
  602. $this->import('BackendUser', 'User');
  603. }
  604. /**
  605. * Check permissions to edit table tl_content
  606. */
  607. public function checkPermission()
  608. {
  609. if ($this->User->isAdmin)
  610. {
  611. return;
  612. }
  613. $groups = $this->User->groups;
  614. // Set default user and group
  615. $GLOBALS['TL_DCA']['tl_page']['fields']['cuser']['default'] = ($GLOBALS['TL_CONFIG']['defaultUser'] != '') ? $GLOBALS['TL_CONFIG']['defaultUser'] : $this->User->id;
  616. $GLOBALS['TL_DCA']['tl_page']['fields']['cgroup']['default'] = ($GLOBALS['TL_CONFIG']['defaultGroup'] != '') ? $GLOBALS['TL_CONFIG']['defaultGroup'] : $groups[0];
  617. // Get pagemounts
  618. $pagemounts = array();
  619. foreach ($this->User->pagemounts as $root)
  620. {
  621. $pagemounts[] = $root;
  622. $pagemounts = array_merge($pagemounts, $this->getChildRecords($root, 'tl_page', true));
  623. }
  624. $pagemounts = array_unique($pagemounts);
  625. // Check the current action
  626. switch ($this->Input->get('act'))
  627. {
  628. case 'paste':
  629. // Allow
  630. break;
  631. case '': // empty
  632. case 'create':
  633. case 'select':
  634. // Check access to the article
  635. if (!$this->checkAccessToElement(CURRENT_ID, $pagemounts, true))
  636. {
  637. $this->redirect('typolight/main.php?act=error');
  638. }
  639. break;
  640. case 'editAll':
  641. case 'deleteAll':
  642. case 'overrideAll':
  643. case 'cutAll':
  644. case 'copyAll':
  645. // Check access to the parent element if a content element is moved
  646. if (($this->Input->get('act') == 'cutAll' || $this->Input->get('act') == 'copyAll') && !$this->checkAccessToElement($this->Input->get('pid'), $pagemounts, ($this->Input->get('mode') == 2)))
  647. {
  648. $this->redirect('typolight/main.php?act=error');
  649. }
  650. $objCes = $this->Database->prepare("SELECT id FROM tl_content WHERE pid=?")
  651. ->execute(CURRENT_ID);
  652. $session = $this->Session->getData();
  653. $session['CURRENT']['IDS'] = array_intersect($session['CURRENT']['IDS'], $objCes->fetchEach('id'));
  654. $this->Session->setData($session);
  655. break;
  656. case 'cut':
  657. case 'copy':
  658. // Check access to the parent element if a content element is moved
  659. if (!$this->checkAccessToElement($this->Input->get('pid'), $pagemounts, ($this->Input->get('mode') == 2)))
  660. {
  661. $this->redirect('typolight/main.php?act=error');
  662. }
  663. // NO BREAK STATEMENT HERE
  664. default:
  665. // Check access to the content element
  666. if (!$this->checkAccessToElement($this->Input->get('id'), $pagemounts))
  667. {
  668. $this->redirect('typolight/main.php?act=error');
  669. }
  670. break;
  671. }
  672. }
  673. /**
  674. * Check access to a particular content element
  675. * @param integer
  676. * @param array
  677. * @param boolean
  678. * @return boolean
  679. */
  680. protected function checkAccessToElement($id, $pagemounts, $blnIsPid=false)
  681. {
  682. if ($blnIsPid)
  683. {
  684. $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")
  685. ->limit(1)
  686. ->execute($id);
  687. }
  688. else
  689. {
  690. $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")
  691. ->limit(1)
  692. ->execute($id);
  693. }
  694. // Invalid ID
  695. if ($objPage->numRows < 1)
  696. {
  697. $this->log('Invalid content element ID ' . $id, 'tl_content checkAccessToElement()', TL_ERROR);
  698. return false;
  699. }
  700. // The page is not mounted
  701. if (!in_array($objPage->id, $pagemounts))
  702. {
  703. $this->log('Not enough permissions to modify article ID ' . $objPage->aid . ' on page ID ' . $objPage->id, 'tl_content checkAccessToElement()', TL_ERROR);
  704. return false;
  705. }
  706. // Not enough permissions to modify the article
  707. if (!$this->User->isAllowed(4, $objPage->row()))
  708. {
  709. $this->log('Not enough permissions to modify article ID ' . $objPage->aid, 'tl_content checkAccessToElement()', TL_ERROR);
  710. return false;
  711. }
  712. return true;
  713. }
  714. /**
  715. * Return all content elements as array
  716. * @return array
  717. */
  718. public function getContentElements()
  719. {
  720. $groups = array();
  721. foreach ($GLOBALS['TL_CTE'] as $k=>$v)
  722. {
  723. foreach (array_keys($v) as $kk)
  724. {
  725. $groups[$k][] = $kk;
  726. }
  727. }
  728. return $groups;
  729. }
  730. /**
  731. * Add the type of content element
  732. * @param array
  733. * @return string
  734. */
  735. public function addCteType($arrRow)
  736. {
  737. $key = $arrRow['invisible'] ? 'unpublished' : 'published';
  738. return '
  739. <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>
  740. <div class="limit_height' . (!$GLOBALS['TL_CONFIG']['doNotCollapse'] ? ' h64' : '') . ' block">
  741. ' . $this->getContentElement($arrRow['id']) . '
  742. </div>' . "\n";
  743. }
  744. /**
  745. * Return the edit article alias wizard
  746. * @param object
  747. * @return string
  748. */
  749. public function editArticleAlias(DataContainer $dc)
  750. {
  751. return ($dc->value < 1) ? '' : ' <a href="typolight/main.php?do=article&amp;table=tl_article&amp;act=edit&amp;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>';
  752. }
  753. /**
  754. * Get all articles and return them as array (article alias)
  755. * @param object
  756. * @return array
  757. */
  758. public function getArticleAlias(DataContainer $dc)
  759. {
  760. $arrPids = array();
  761. $arrAlias = array();
  762. if (!$this->User->isAdmin)
  763. {
  764. foreach ($this->User->pagemounts as $id)
  765. {
  766. $arrPids[] = $id;
  767. $arrPids = array_merge($arrPids, $this->getChildRecords($id, 'tl_page', true));
  768. }
  769. if (empty($arrPids))
  770. {
  771. return $arrAlias;
  772. }
  773. $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")
  774. ->execute($dc->id);
  775. }
  776. else
  777. {
  778. $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")
  779. ->execute($dc->id);
  780. }
  781. if ($objAlias->numRows)
  782. {
  783. $this->loadLanguageFile('tl_article');
  784. while ($objAlias->next())
  785. {
  786. $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 . ')';
  787. }
  788. }
  789. return $arrAlias;
  790. }
  791. /**
  792. * Return the edit alias wizard
  793. * @param object
  794. * @return string
  795. */
  796. public function editAlias(DataContainer $dc)
  797. {
  798. 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>';
  799. }
  800. /**
  801. * Get all content elements and return them as array (content element alias)
  802. * @return array
  803. */
  804. public function getAlias()
  805. {
  806. $this->import('String');
  807. $arrPids = array();
  808. $arrAlias = array();
  809. if (!$this->User->isAdmin)
  810. {
  811. foreach ($this->User->pagemounts as $id)
  812. {
  813. $arrPids[] = $id;
  814. $arrPids = array_merge($arrPids, $this->getChildRecords($id, 'tl_page', true));
  815. }
  816. if (empty($arrPids))
  817. {
  818. return $arrAlias;
  819. }
  820. $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")
  821. ->execute($this->Input->get('id'));
  822. }
  823. else
  824. {
  825. $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")
  826. ->execute($this->Input->get('id'));
  827. }
  828. while ($objAlias->next())
  829. {
  830. $arrHeadline = deserialize($objAlias->headline, true);
  831. $headline = $this->String->substr(preg_replace('/[\n\r\t]+/', ' ', $arrHeadline[0]), 32, true) . (($arrHeadline[0] != '') ? ', ' : '');
  832. $text = $this->String->substr(strip_tags(preg_replace('/[\n\r\t]+/', ' ', $objAlias->text)), 32, true) . (($objAlias->text != '') ? ', ' : '');
  833. $arrAlias[$objAlias->title][$objAlias->id] = $GLOBALS['TL_LANG']['CTE'][$objAlias->type][0] . ' (' . (strlen($headline) ? $headline : $text) . 'ID ' . $objAlias->id . ')';
  834. }
  835. return $arrAlias;
  836. }
  837. /**
  838. * Return the edit form wizard
  839. * @param object
  840. * @return string
  841. */
  842. public function editForm(DataContainer $dc)
  843. {
  844. return ($dc->value < 1) ? '' : ' <a href="typolight/main.php?do=form&amp;act=edit&amp;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>';
  845. }
  846. /**
  847. * Get all forms and return them as array
  848. * @return array
  849. */
  850. public function getForms()
  851. {
  852. if (!$this->User->isAdmin && !is_array($this->User->forms))
  853. {
  854. return array();
  855. }
  856. $arrForms = array();
  857. $objForms = $this->Database->execute("SELECT id, title FROM tl_form ORDER BY title");
  858. while ($objForms->next())
  859. {
  860. if ($this->User->isAdmin || $this->User->hasAccess($objForms->id, 'forms'))
  861. {
  862. $arrForms[$objForms->id] = $objForms->title . ' (ID ' . $objForms->id . ')';
  863. }
  864. }
  865. return $arrForms;
  866. }
  867. /**
  868. * Return the edit module wizard
  869. * @param object
  870. * @return string
  871. */
  872. public function editModule(DataContainer $dc)
  873. {
  874. return ($dc->value < 1) ? '' : ' <a href="typolight/main.php?do=modules&amp;act=edit&amp;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>';
  875. }
  876. /**
  877. * Get all modules and return them as array
  878. * @return array
  879. */
  880. public function getModules()
  881. {
  882. $arrModules = array();
  883. $objModules = $this->Database->execute("SELECT id, name FROM tl_module ORDER BY name");
  884. while ($objModules->next())
  885. {
  886. $arrModules[$objModules->id] = $objModules->name . ' (ID ' . $objModules->id . ')';
  887. }
  888. return $arrModules;
  889. }
  890. /**
  891. * Return the edit article teaser wizard
  892. * @param object
  893. * @return string
  894. */
  895. public function editArticle(DataContainer $dc)
  896. {
  897. return ($dc->value < 1) ? '' : ' <a href="typolight/main.php?do=article&amp;table=tl_content&amp;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>';
  898. }
  899. /**
  900. * Get all articles and return them as array (article teaser)
  901. * @param object
  902. * @return array
  903. */
  904. public function getArticles(DataContainer $dc)
  905. {
  906. $arrPids = array();
  907. $arrArticle = array();
  908. $arrRoot = array();
  909. // Limit pages to the website root
  910. $objPage = $this->Database->prepare("SELECT pid FROM tl_article WHERE id=?")
  911. ->limit(1)
  912. ->execute($dc->activeRecord->pid);
  913. if ($objPage->numRows)
  914. {
  915. $objPage = $this->getPageDetails($objPage->pid);
  916. $arrRoot = $this->getChildRecords($objPage->rootId, 'tl_page', true);
  917. }
  918. // Limit pages to the user's pagemounts
  919. if (!$this->User->isAdmin)
  920. {
  921. foreach ($this->User->pagemounts as $id)
  922. {
  923. if (!in_array($id, $arrRoot))
  924. {
  925. continue;
  926. }
  927. $arrPids[] = $id;
  928. $arrPids = array_merge($arrPids, $this->getChildRecords($id, 'tl_page', true));
  929. }
  930. if (empty($arrPids))
  931. {
  932. return $arrArticle;
  933. }
  934. $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");
  935. }
  936. else
  937. {
  938. $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");
  939. }
  940. if ($objArticle->numRows)
  941. {
  942. $this->loadLanguageFile('tl_article');
  943. while ($objArticle->next())
  944. {
  945. $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 . ')';
  946. }
  947. }
  948. return $arrArticle;
  949. }
  950. /**
  951. * Return the link picker wizard
  952. * @param object
  953. * @return string
  954. */
  955. public function pagePicker(DataContainer $dc)
  956. {
  957. $strField = 'ctrl_' . $dc->field . (($this->Input->get('act') == 'editAll') ? '_' . $dc->id : '');
  958. return ' ' . $this->generateImage('pickpage.gif', $GLOBALS['TL_LANG']['MSC']['pagepicker'], 'style="vertical-align:top; cursor:pointer;" onclick="Backend.pickPage(\'' . $strField . '\')"');
  959. }
  960. /**
  961. * Return the delete content element button
  962. * @param array
  963. * @param string
  964. * @param string
  965. * @param string
  966. * @param string
  967. * @param string
  968. * @return string
  969. */
  970. public function deleteElement($row, $href, $label, $title, $icon, $attributes)
  971. {
  972. $objElement = $this->Database->prepare("SELECT id FROM tl_content WHERE cteAlias=? AND type=?")
  973. ->limit(1)
  974. ->execute($row['id'], 'alias');
  975. return $objElement->numRows ? $this->generateImage(preg_replace('/\.gif$/i', '_.gif', $icon)) . ' ' : '<a href="'.$this->addToUrl($href.'&amp;id='.$row['id']).'" title="'.specialchars($title).'"'.$attributes.'>'.$this->generateImage($icon, $label).'</a> ';
  976. }
  977. /**
  978. * Return the "toggle visibility" button
  979. * @param array
  980. * @param string
  981. * @param string
  982. * @param string
  983. * @param string
  984. * @param string
  985. * @return string
  986. */
  987. public function toggleIcon($row, $href, $label, $title, $icon, $attributes)
  988. {
  989. if (strlen($this->Input->get('tid')))
  990. {
  991. $this->toggleVisibility($this->Input->get('tid'), ($this->Input->get('state') == 1));
  992. $this->redirect($this->getReferer());
  993. }
  994. $href .= '&amp;id='.$this->Input->get('id').'&amp;tid='.$row['id'].'&amp;state='.$row['invisible'];
  995. if ($row['invisible'])
  996. {
  997. $icon = 'invisible.gif';
  998. }
  999. return '<a href="'.$this->addToUrl($href).'" title="'.specialchars($title).'"'.$attributes.'>'.$this->generateImage($icon, $label).'</a> ';
  1000. }
  1001. /**
  1002. * Toggle the visibility of an element
  1003. * @param integer
  1004. * @param boolean
  1005. */
  1006. public function toggleVisibility($intId, $blnVisible)
  1007. {
  1008. // Check permissions to edit
  1009. $this->Input->setGet('id', $intId);
  1010. $this->Input->setGet('act', 'toggle');
  1011. $this->checkPermission();
  1012. $this->createInitialVersion('tl_content', $intId);
  1013. // Trigger the save_callback
  1014. if (is_array($GLOBALS['TL_DCA']['tl_content']['fields']['invisible']['save_callback']))
  1015. {
  1016. foreach ($GLOBALS['TL_DCA']['tl_content']['fields']['invisible']['save_callback'] as $callback)
  1017. {
  1018. $this->import($callback[0]);
  1019. $blnVisible = $this->$callback[0]->$callback[1]($blnVisible, $this);
  1020. }
  1021. }
  1022. // Update the database
  1023. $this->Database->prepare("UPDATE tl_content SET invisible='" . ($blnVisible ? '' : 1) . "' WHERE id=?")
  1024. ->execute($intId);
  1025. $this->createNewVersion('tl_content', $intId);
  1026. }
  1027. }
  1028. ?>