/administrator/components/com_menus/content_typed/content_typed.class.php

https://github.com/doctorgrif/Joostina-1.2.1 · PHP · 105 lines · 67 code · 15 blank · 23 comment · 10 complexity · 727a981cba71c1a60b9ffb3907fdbba6 MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joostina
  4. * @copyright Àâòîðñêèå ïðàâà (C) 2008 Joostina team. Âñå ïðàâà çàùèùåíû.
  5. * @license Ëèöåíçèÿ http://www.gnu.org/licenses/gpl-2.0.htm GNU/GPL, èëè help/license.php
  6. * Joostina! - ñâîáîäíîå ïðîãðàììíîå îáåñïå÷åíèå ðàñïðîñòðàíÿåìîå ïî óñëîâèÿì ëèöåíçèè GNU/GPL
  7. * Äëÿ ïîëó÷åíèÿ èíôîðìàöèè î èñïîëüçóåìûõ ðàñøèðåíèÿõ è çàìå÷àíèé îá àâòîðñêîì ïðàâå, ñìîòðèòå ôàéë help/copyright.php.
  8. */
  9. // çàïðåò ïðÿìîãî äîñòóïà
  10. defined('_VALID_MOS') or die();
  11. /**
  12. * @package Joostina
  13. * @subpackage Menus
  14. */
  15. class content_typed_menu {
  16. function edit(&$uid,$menutype,$option) {
  17. global $database,$my,$mainframe;
  18. global $mosConfig_absolute_path;
  19. $menu = new mosMenu($database);
  20. $menu->load((int)$uid);
  21. // fail if checked out not by 'me'
  22. if($menu->checked_out && $menu->checked_out != $my->id) {
  23. mosErrorAlert($menu->title." "._MODULE_IS_EDITING_MY_ADMIN);
  24. }
  25. if($uid) {
  26. $menu->checkout($my->id);
  27. } else {
  28. // load values for new entry
  29. $menu->type = 'content_typed';
  30. $menu->menutype = $menutype;
  31. $menu->browserNav = 0;
  32. $menu->ordering = 9999;
  33. $menu->parent = intval(mosGetParam($_POST,'parent',0));
  34. $menu->published = 1;
  35. }
  36. if($uid) {
  37. $temp = explode('id=',$menu->link);
  38. $query = "SELECT a.title, a.title_alias, a.id"."\n FROM #__content AS a"."\n WHERE a.id = ".(int)
  39. $temp[1];
  40. $database->setQuery($query);
  41. $content = $database->loadObjectlist();
  42. // outputs item name, category & section instead of the select list
  43. if($content[0]->title_alias) {
  44. $alias = ' (<i>'.$content[0]->title_alias.'</i>)';
  45. } else {
  46. $alias = '';
  47. }
  48. $contents = '';
  49. $link = 'javascript:submitbutton( \'redirect\' );';
  50. $lists['content'] = '<input type="hidden" name="content_typed" value="'.$temp[1].'" />';
  51. $lists['content'] .= '<a href="'.$link.'" title="Èçìåíèòü ñòàòè÷íîå ñîäåðæèìîå">'.$content[0]->title.$alias.'</a>';
  52. } else {
  53. $query = "SELECT a.id AS value, CONCAT( a.title, '(', a.title_alias, ')' ) AS text".
  54. "\n FROM #__content AS a"."\n WHERE a.state = 1"."\n AND a.sectionid = 0"."\n AND a.catid = 0".
  55. "\n ORDER BY a.title, a.id";
  56. $database->setQuery($query);
  57. $contents = $database->loadObjectList();
  58. // Create a list of links
  59. $lists['content'] = mosHTML::selectList($contents,'content_typed','ondblclick="jadd(\'name\',this.options[this.selectedIndex].text);" class="inputbox" size="10"','value','text','');
  60. }
  61. // build html select list for target window
  62. $lists['target'] = mosAdminMenus::Target($menu);
  63. // build the html select list for ordering
  64. $lists['ordering'] = mosAdminMenus::Ordering($menu,$uid);
  65. // build the html select list for the group access
  66. $lists['access'] = mosAdminMenus::Access($menu);
  67. // build the html select list for paraent item
  68. $lists['parent'] = mosAdminMenus::Parent($menu);
  69. // build published button option
  70. $lists['published'] = mosAdminMenus::Published($menu);
  71. // build the url link output
  72. $lists['link'] = mosAdminMenus::Link($menu,$uid);
  73. // get params definitions
  74. $params = new mosParameters($menu->params,$mainframe->getPath('menu_xml',$menu->type),
  75. 'menu');
  76. content_menu_html::edit($menu,$lists,$params,$option,$contents);
  77. }
  78. function redirect($id) {
  79. global $database;
  80. $menu = new mosMenu($database);
  81. $menu->bind($_POST);
  82. $menuid = intval(mosGetParam($_POST,'menuid',0));
  83. if($menuid) {
  84. $menu->id = $menuid;
  85. }
  86. $menu->checkin();
  87. mosRedirect('index2.php?option=com_typedcontent&task=edit&id='.$id);
  88. }
  89. }
  90. ?>