[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/administrator/components/com_menus/content_item_link/ -> content_item_link.class.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @subpackage Menus
   5  * @author Mambo Foundation Inc see README.php
   6  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   7  * See COPYRIGHT.php for copyright notices and details.
   8  * @license GNU/GPL Version 2, see LICENSE.php
   9  *
  10  * Redistributions of files must retain the above copyright notice.
  11  *
  12  * Mambo is free software; you can redistribute it and/or
  13  * modify it under the terms of the GNU General Public License
  14  * as published by the Free Software Foundation; version 2 of the License.
  15  */
  16  
  17  /** ensure this file is being included by a parent file */
  18  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  19  
  20  /**
  21  * Content item link class
  22  */
  23  class content_item_link_menu {
  24  
  25  	function edit( &$uid, $menutype, $option ) {
  26          global $database, $my, $mainframe;
  27          global $mosConfig_absolute_path;
  28      
  29          $menu = new mosMenu( $database );
  30          $menu->load( $uid );
  31      
  32          // fail if checked out not by 'me'
  33          if ($menu->checked_out && $menu->checked_out <> $my->id) {
  34              echo "<script>alert('".sprintf(T_('The module % is currently being edited by another administrator'), $menu->title)."'); document.location.href='index2.php?option=$option'</script>\n";
  35              exit(0);
  36          }
  37      
  38          if ( $uid ) {
  39              $menu->checkout( $my->id );
  40          } else {
  41              // load values for new entry
  42              $menu->type = 'content_item_link';
  43              $menu->menutype = $menutype;
  44              $menu->browserNav = 0;
  45              $menu->ordering = 9999;
  46              $menu->parent = intval( mosGetParam( $_POST, 'parent', 0 ) );
  47              $menu->published = 1;
  48          }
  49      
  50          if ( $uid ) {
  51              $link     = 'javascript:submitbutton( \'redirect\' );';
  52              
  53              $temp     = explode( 'id=', $menu->link );
  54              // @RawSQLUse, trivial_implementation, SELECT, CONCEPT
  55               $query = "SELECT a.title, c.name AS category, s.name AS section"
  56              . "\n FROM #__content AS a"
  57              . "\n LEFT JOIN #__categories AS c ON a.catid = c.id"
  58              . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
  59              . "\n WHERE a.id = '". $temp[1] ."'"
  60              ;
  61              $database->setQuery( $query );
  62              $content = $database->loadObjectlist();
  63              // outputs item name, category & section instead of the select list
  64              $lists['content'] = '
  65              <table width="100%">
  66              <tr>
  67                  <td width="10%">
  68                  Item:
  69                  </td>
  70                  <td>
  71                  <a href="'. $link .'" title="'.T_('Edit Content Item').'">
  72                  '. $content[0]->title .'
  73                  </a>
  74                  </td>
  75              </tr>
  76              <tr>
  77                  <td width="10%">
  78                  '.T_('Category:').'
  79                  </td>
  80                  <td>
  81                  '. $content[0]->category .'
  82                  </td>
  83              </tr>
  84              <tr>
  85                  <td width="10%">
  86                  '.T_('Section:').'
  87                  </td>
  88                  <td>
  89                  '. $content[0]->section .'
  90                  </td>
  91              </tr>
  92              </table>';
  93              $contents = '';
  94              $lists['content'] .= '<input type="hidden" name="content_item_link" value="'. $temp[1] .'" />';
  95          } else {
  96              // @RawSQLUse, trivial_implementation, SELECT, CONCEPT
  97              $query = "SELECT a.id AS value, a.title AS text, a.sectionid, a.catid "
  98              . "\n FROM #__content AS a"
  99              . "\n INNER JOIN #__categories AS c ON a.catid = c.id"
 100              . "\n INNER JOIN #__sections AS s ON a.sectionid = s.id"
 101              . "\n WHERE a.state = '1'"
 102              . "\n ORDER BY a.sectionid, a.catid, a.title"
 103              ;
 104              $database->setQuery( $query );
 105              $contents = $database->loadObjectList( );
 106      
 107              foreach ( $contents as $content ) {
 108                  // @RawSQLUse, trivial_implementation, SELECT, CONCEPT
 109                  $database->setQuery( "SELECT s.title"
 110                  . "\n FROM #__sections AS s"
 111                  . "\n WHERE s.scope = 'content'"
 112                  . "\n AND s.id = '". $content->sectionid ."'"
 113                  );
 114                  $section = $database->loadResult();
 115      
 116                  // @RawSQLUse, trivial_implementation, SELECT, CONCEPT
 117                  $database->setQuery( "SELECT c.title"
 118                  . "\n FROM #__categories AS c"
 119                  . "\n WHERE c.id = '". $content->catid ."'"
 120                  );
 121                  $category = $database->loadResult();
 122          
 123                  $value = $content->value;
 124                  $text = $section ." - ". $category ." / ". $content->text ."&nbsp;&nbsp;&nbsp;&nbsp;";
 125                  
 126                  $temp[] = mosHTML::makeOption( $value, $text );
 127                  $contents = $temp;
 128              }
 129      
 130              //    Create a list of links
 131              $lists['content'] = mosHTML::selectList( $contents, 'content_item_link', 'class="inputbox" size="10"', 'value', 'text', '' );
 132          }
 133          
 134          // build html select list for target window
 135          $lists['target']         = mosAdminMenus::Target( $menu );
 136      
 137          // build the html select list for ordering
 138          $lists['ordering']         = mosAdminMenus::Ordering( $menu, $uid );
 139          // build the html select list for the group access
 140          $lists['access']         = mosAdminMenus::Access( $menu );
 141          // build the html select list for paraent item
 142          $lists['parent']         = mosAdminMenus::Parent( $menu );
 143          // build published button option
 144          $lists['published']     = mosAdminMenus::Published( $menu );
 145          // build the url link output
 146          $lists['link']         = mosAdminMenus::Link( $menu, $uid );
 147          
 148          // get params definitions
 149          $params =& new mosAdminParameters( $menu->params, $mainframe->getPath( 'menu_xml', $menu->type ), 'menu' );
 150      
 151          content_item_link_menu_html::edit( $menu, $lists, $params, $option, $contents );
 152      }
 153      
 154  	function redirect( $id ) {
 155          global $database;
 156          
 157          $menu = new mosMenu( $database );
 158          $menu->bind( $_POST );
 159          $menuid = mosGetParam( $_POST, 'menuid', 0 );
 160          if ( $menuid ) {
 161              $menu->id = $menuid;
 162          }
 163          $menu->checkin();
 164      
 165          mosRedirect( 'index2.php?option=com_content&task=edit&id='. $id );    
 166      }
 167  }
 168  ?>