[ Index ]

PHP Cross Reference of Mambo 4.6.5

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

title

Body

[close]

/administrator/includes/ -> mosAdminMenus.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @author Mambo Foundation Inc see README.php
   5  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   6  * See COPYRIGHT.php for copyright notices and details.
   7  * @license GNU/GPL Version 2, see LICENSE.php
   8  *
   9  * Redistributions of files must retain the above copyright notice.
  10  *
  11  * Mambo is free software; you can redistribute it and/or
  12  * modify it under the terms of the GNU General Public License
  13  * as published by the Free Software Foundation; version 2 of the License.
  14  */
  15  
  16  /** ensure this file is being included by a parent file */
  17  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  18  
  19  function mosTreeRecurse( $id, $indent, $list, &$children, $maxlevel=9999, $level=0, $type=1,$parent='parent') {
  20      if (@$children[$id] AND $level <= $maxlevel) {
  21          $newindent = $indent.($type ? '.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' : '&nbsp;&nbsp;');
  22          $pre = $type ? '<sup>L</sup>&nbsp;' : '- ';
  23          foreach ($children[$id] as $v) {
  24              $id = $v->id;
  25              $list[$id] = $v;
  26              $list[$id]->treename = $indent.($v->$parent == 0 ? '' : $pre).$v->name;
  27              $list[$id]->children = count( @$children[$id] );
  28              $list[$id]->level = $level;
  29              $list = mosTreeRecurse( $id, $newindent, $list, $children, $maxlevel, $level+1, $type );
  30          }
  31      }
  32      return $list;
  33  }
  34  
  35  /**
  36  * @param string SQL with ordering As value and 'name field' AS text
  37  * @param integer The length of the truncated headline
  38  */
  39  function mosGetOrderingList( $sql, $chop='30' ) {
  40      $database = mamboDatabase::getInstance();
  41      $database->setQuery( $sql );
  42      if (!($orders = $database->loadObjectList())) {
  43          if ($database->getErrorNum()) {
  44              echo $database->stderr();
  45              return false;
  46          } else {
  47              $order[] = mosHTML::makeOption( 1, 'first' );
  48              return $order;
  49          }
  50      }
  51      $order[] = mosHTML::makeOption( 0, '0 first' );
  52      foreach ($orders as $ord) {
  53          $text = strlen($ord->text) > $chop ? substr($ord->text,0,$chop)."..." : $ord->text;
  54          $order[] = mosHTML::makeOption( $ord->value, $ord->value.' ('.$text.')' );
  55      }
  56      $order[] = mosHTML::makeOption( $ord->value+1, ($ord->value+1).' last' );
  57      return $order;
  58  }
  59  
  60  /**
  61  * Common HTML Output Files
  62  * @package Mambo
  63  */
  64  class mosAdminMenus {
  65      /**
  66      * build the select list for Menu Ordering
  67      */
  68  	function Ordering( &$row, $id ) {
  69          global $database;
  70  
  71          if ( $id ) {
  72              $order = mosGetOrderingList( "SELECT ordering AS value, name AS text"
  73              . "\n FROM #__menu"
  74              . "\n WHERE menutype='". $row->menutype ."'"
  75              . "\n AND parent='". $row->parent ."'"
  76              . "\n AND published != '-2'"
  77              . "\n ORDER BY ordering"
  78              );
  79              $ordering = mosHTML::selectList( $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) );
  80          }
  81          else {
  82              $ordering = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />'. T_('New items default to the last place. Ordering can be changed after this item is saved.');
  83          }
  84          return $ordering;
  85      }
  86  
  87      /**
  88      * build the select list for access level
  89      * @param object a module object
  90      * @return mixed a select list
  91      */
  92  	function Access( &$row ) {
  93          global $database;
  94  
  95          // @RawSQLUse, trivial_implementation, SELECT
  96          $query = 'SELECT id AS value, name AS text FROM #__groups ORDER BY id';
  97          $database->setQuery( $query );
  98          $groups = $database->loadObjectList();
  99          $access = mosHTML::selectList( $groups, 'access', 'class="inputbox" size="3"', 'value', 'text', intval( $row->access ) );
 100          return $access;
 101      }
 102  
 103      /**
 104      * build the select list for module group access
 105      */
 106  	function groupAccess( &$row ) {
 107          global $acl;
 108          $gtree = $acl->get_group_children_tree( null, 'USERS', false );
 109          $list = array();
 110          $j = 0;
 111          for($i = 0; $i<count($gtree); $i++) {
 112              $temp = explode('-', $gtree[$i]->text);
 113              $idx = (count($temp) == 1) ? 0 : 1;
 114              if ($gtree[$i]->value != 29 && $gtree[$i]->value != 30) {
 115                  $list[$j]->value = $gtree[$i]->value;
 116                  $list[$j]->text = trim(str_replace('&nbsp;','',$temp[$idx]));
 117                  $j++;
 118              }
 119          }
 120          $groups = explode(',',$row->groups);
 121          for($i=0; $i < count($groups); $i++) {
 122              $group = new stdclass;
 123              $group->value = $groups[$i];
 124              $groups[$i] = $group;
 125          }
 126          $groupSelect = mosHTML::selectList( $list, 'groups[]', 'class="inputbox" multiple="multiple" size="6"', 'value', 'text', $groups );
 127          return $groupSelect;
 128      }
 129  
 130      /**
 131      * build the select list for parent item
 132      */
 133  	function Parent( &$row ) {
 134          global $database;
 135  
 136          // get a list of the menu items
 137          $query = "SELECT m.*"
 138          . "\n FROM #__menu m"
 139          . "\n WHERE menutype='$row->menutype'"
 140          . "\n AND parent!='$row->id'"
 141          . "\n AND published <> -2"
 142          . "\n ORDER BY ordering"
 143          ;
 144          $database->setQuery( $query );
 145          $mitems = $database->loadObjectList();
 146  
 147          // establish the hierarchy of the menu
 148          $children = array();
 149          // first pass - collect children
 150          if (is_array($mitems)) {
 151              foreach ( $mitems as $v ) {
 152                  $pt = $v->parent;
 153                  $list = @$children[$pt] ? $children[$pt] : array();
 154                  array_push( $list, $v );
 155                  $children[$pt] = $list;
 156              }
 157          }
 158          // second pass - get an indent list of the items
 159          $list = mosTreeRecurse( 0, '', array(), $children, 9999, 0, 0 );
 160  
 161          // assemble menu items to the array
 162          $mitems = array();
 163          $mitems[] = mosHTML::makeOption( '0', 'Top' );
 164          $this_treename = '';
 165          foreach ( $list as $item ) {
 166              if ( $this_treename ) {
 167                  if ( $item->id != $row->id && strpos( $item->treename, $this_treename ) === false) {
 168                      $mitems[] = mosHTML::makeOption( $item->id, $item->treename );
 169                  }
 170              } else {
 171                  if ( $item->id != $row->id ) {
 172                      $mitems[] = mosHTML::makeOption( $item->id, $item->treename );
 173                  } else {
 174                      $this_treename = "$item->treename/";
 175                  }
 176              }
 177          }
 178          $parent = mosHTML::selectList( $mitems, 'parent', 'class="inputbox" size="1"', 'value', 'text', $row->parent );
 179          return $parent;
 180      }
 181  
 182      /**
 183      * build a radio button option for published state
 184      */
 185  	function Published( &$row ) {
 186          $published = mosHTML::yesnoRadioList( 'published', 'class="inputbox"', $row->published );
 187          return $published;
 188      }
 189  
 190      /**
 191      * build the link/url of a menu item
 192      */
 193  	function Link( &$row, $id, $link=NULL ) {
 194          if ( $id ) {
 195              if ( $link ) {
 196                  $link = $row->link;
 197              } else {
 198                  $link = $row->link .'&amp;Itemid='. $row->id;
 199              }
 200          } else {
 201              $link = NULL;
 202          }
 203          return $link;
 204      }
 205  
 206      /**
 207      * build the select list for target window
 208      */
 209  	function Target( &$row ) {
 210          $click[] = mosHTML::makeOption( '0',  T_('Parent Window With Browser Navigation'));
 211          $click[] = mosHTML::makeOption( '1',  T_('New Window With Browser Navigation'));
 212          $click[] = mosHTML::makeOption( '2', T_('New Window Without Browser Navigation'));
 213          $target = mosHTML::selectList( $click, 'browserNav', 'class="inputbox" size="4"', 'value', 'text', intval( $row->browserNav ) );
 214          return $target;
 215      }
 216  
 217      /**
 218      * build the multiple select list for Menu Links/Pages
 219      */
 220  	function MenuLinks( &$lookup, $all=NULL, $none=NULL ) {
 221          global $database;
 222  
 223          // get a list of the menu items
 224          $database->setQuery( "SELECT m.*"
 225          . "\n FROM #__menu m"
 226          . "\n WHERE type != 'separator'"
 227          . "\n AND link NOT LIKE '%tp:/%'"
 228          . "\n AND published = '1'"
 229          . "\n ORDER BY menutype, parent, ordering"
 230          );
 231          $mitems = $database->loadObjectList();
 232          $mitems_temp = $mitems;
 233  
 234          // establish the hierarchy of the menu
 235          $children = array();
 236          // first pass - collect children
 237          foreach ( $mitems as $v ) {
 238              $id = $v->id;
 239              $pt = $v->parent;
 240              $list = @$children[$pt] ? $children[$pt] : array();
 241              array_push( $list, $v );
 242              $children[$pt] = $list;
 243          }
 244          // second pass - get an indent list of the items
 245          $list = mosTreeRecurse( intval( $mitems[0]->parent ), '', array(), $children, 9999, 0, 0 );
 246  
 247          // Code that adds menu name to Display of Page(s)
 248          $text_count = "0";
 249          $mitems_spacer = $mitems_temp[0]->menutype;
 250          foreach ($list as $list_a) {
 251              foreach ($mitems_temp as $mitems_a) {
 252                  if ($mitems_a->id == $list_a->id) {
 253                      // Code that inserts the blank line that seperates different menus
 254                      if ($mitems_a->menutype <> $mitems_spacer) {
 255                          $list_temp[] = mosHTML::makeOption( -999, '----' );
 256                          $mitems_spacer = $mitems_a->menutype;
 257                      }
 258                      $text = $mitems_a->menutype." | ".$list_a->treename;
 259                      $list_temp[] = mosHTML::makeOption( $list_a->id, $text );
 260                      if ( strlen($text) > $text_count) {
 261                          $text_count = strlen($text);
 262                      }
 263                  }
 264              }
 265          }
 266          $list = $list_temp;
 267  
 268          $mitems = array();
 269          if ( $all ) {
 270              // prepare an array with 'all' as the first item
 271              $mitems[] = mosHTML::makeOption( 0, T_('All') );
 272              // adds space, in select box which is not saved
 273              $mitems[] = mosHTML::makeOption( -999, '----' );
 274          }
 275          if ( $none ) {
 276              // prepare an array with 'all' as the first item
 277              $mitems[] = mosHTML::makeOption( -998, T_('None') ); 
 278              // adds space, in select box which is not saved
 279              $mitems[] = mosHTML::makeOption( -999, '----' );
 280          }
 281          // append the rest of the menu items to the array
 282          foreach ($list as $item) {
 283              $mitems[] = mosHTML::makeOption( $item->value, $item->text );
 284          }
 285          if ($lookup == NULL) {
 286              $lookup = '-998';
 287          }  
 288          $pages = mosHTML::selectList( $mitems, 'selections[]', 'class="inputbox" size="26" multiple="multiple"', 'value', 'text', $lookup );
 289          return $pages;
 290      }
 291  
 292  
 293      /**
 294      * build the select list to choose a category
 295      */
 296  	function Category( &$menu, $id, $javascript='' ) {
 297          global $database;
 298  
 299          $query = "SELECT c.id AS `value`, c.section AS `id`, CONCAT_WS( ' / ', s.title, c.title) AS `text`"
 300          . "\n FROM #__sections AS s"
 301          . "\n INNER JOIN #__categories AS c ON c.section = s.id"
 302          . "\n WHERE s.scope = 'content'"
 303          . "\n ORDER BY s.name,c.name"
 304          ;
 305          $database->setQuery( $query );
 306          $rows = $database->loadObjectList();
 307          $category = '';
 308          if ( $id ) {
 309              foreach ( $rows as $row ) {
 310                  if ( $row->value == $menu->componentid ) {
 311                      $category = $row->text;
 312                  }
 313              }
 314              $category .= '<input type="hidden" name="componentid" value="'. $menu->componentid .'" />';
 315              $category .= '<input type="hidden" name="link" value="'. $menu->link .'" />';
 316          } else {
 317              $category = mosHTML::selectList( $rows, 'componentid', 'class="inputbox" size="10"'. $javascript, 'value', 'text' );
 318              $category .= '<input type="hidden" name="link" value="" />';
 319          }
 320          return $category;
 321      }
 322  
 323      /**
 324      * build the select list to choose a section
 325      */
 326  	function Section( &$menu, $id, $all=0 ) {
 327          global $database;
 328  
 329          // @RawSQLUse, trivial_implementation, SELECT
 330          $query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`"
 331          . "\n FROM #__sections AS s"
 332          . "\n WHERE s.scope = 'content'"
 333          . "\n ORDER BY s.name"
 334          ;
 335          $database->setQuery( $query );
 336          if ( $all ) {
 337              $rows[] = mosHTML::makeOption( 0, T_('- All Sections -') );
 338              $rows = array_merge( $rows, $database->loadObjectList() );
 339          } else {
 340              $rows = $database->loadObjectList();
 341          }
 342  
 343          if ( $id ) {
 344              foreach ( $rows as $row ) {
 345                  if ( $row->value == $menu->componentid ) {
 346                      $section = $row->text;
 347                  }
 348              }
 349              $section .= '<input type="hidden" name="componentid" value="'. $menu->componentid .'" />';
 350              $section .= '<input type="hidden" name="link" value="'. $menu->link .'" />';
 351          } else {
 352              $section = mosHTML::selectList( $rows, 'componentid', 'class="inputbox" size="10"', 'value', 'text' );
 353              $section .= '<input type="hidden" name="link" value="" />';
 354          }
 355          return $section;
 356      }
 357  
 358      /**
 359      * build the select list to choose a component
 360      */
 361  	function Component( &$menu, $id ) {
 362          global $database;
 363  
 364          // @RawSQLUse, trivial_implementation, SELECT
 365          $query = "SELECT c.id AS value, c.name AS text, c.link"
 366          . "\n FROM #__components AS c"
 367          . "\n WHERE c.link <> ''"
 368          . "\n ORDER BY c.name"
 369          ;
 370          $database->setQuery( $query );
 371          $rows = $database->loadObjectList( );
 372          if ( $id ) {
 373              // existing component, just show name
 374              foreach ( $rows as $row ) {
 375                  if ( $row->value == $menu->componentid ) {
 376                      $component = $row->text;
 377                  }
 378              }
 379              $component .= '<input type="hidden" name="componentid" value="'. $menu->componentid .'" />';
 380          } else {
 381              $component = mosHTML::selectList( $rows, 'componentid', 'class="inputbox" size="10"', 'value', 'text' );
 382          }
 383          return $component;
 384      }
 385  
 386      /**
 387      * build the select list to choose a component
 388      */
 389  	function ComponentName( &$menu, $id ) {
 390          global $database;
 391  
 392          $query = "SELECT c.id AS value, c.name AS text, c.link"
 393          . "\n FROM #__components AS c"
 394          . "\n WHERE c.link <> ''"
 395          . "\n ORDER BY c.name"
 396          ;
 397          $database->setQuery( $query );
 398          $rows = $database->loadObjectList( );
 399  
 400          $component = 'Component';
 401          foreach ( $rows as $row ) {
 402              if ( $row->value == $menu->componentid ) {
 403                  $component = $row->text;
 404              }
 405          }
 406  
 407          return $component;
 408      }
 409  
 410      /**
 411      * build the select list to choose an image
 412      */
 413  	function Images( $name, &$active, $javascript=NULL, $directory=NULL ) {
 414          global $mosConfig_absolute_path;
 415  
 416          if ( !$javascript ) {
 417              $javascript = "onchange=\"javascript:if (document.forms[0].image.options[selectedIndex].value!='') {document.imagelib.src='../images/stories/' + document.forms[0].image.options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\"";
 418          }
 419          if ( !$directory ) {
 420              $directory = '/images/stories';
 421          }
 422  
 423          $imageFiles = mosReadDirectory( $mosConfig_absolute_path . $directory );
 424          $images = array(  mosHTML::makeOption( '', T_('- Select Image -') ) );
 425          foreach ( $imageFiles as $file ) {
 426              if ( eregi( "bmp|gif|jpg|png", $file ) ) {
 427                  $images[] = mosHTML::makeOption( $file );
 428              }
 429          }
 430          $images = mosHTML::selectList( $images, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active );
 431  
 432          return $images;
 433      }
 434  
 435      /**
 436      * build the select list for Ordering of a specified Table
 437      */
 438  	function SpecificOrdering( &$row, $id, $query, $neworder=0 ) {
 439          global $database;
 440  
 441          if ( $neworder ) {
 442              $text = T_('New items default to the first place. Ordering can be changed after this item is saved.');
 443          } else {
 444              $text = T_('New items default to the last place. Ordering can be changed after this item is saved.');
 445          }
 446  
 447          if ( $id ) {
 448              $order = mosGetOrderingList( $query );
 449              $ordering = mosHTML::selectList( $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) );
 450          } else {
 451              $ordering = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />'. $text;
 452          }
 453          return $ordering;
 454      }
 455  
 456      /**
 457      * Select list of active users
 458      */
 459  	function UserSelect( $name, $active, $nouser=0, $javascript=NULL, $order='name' ) {
 460          global $database, $my;
 461  
 462          $query = "SELECT id AS value, CONCAT(name,' (',username,')') AS text"
 463          . "\n FROM #__users"
 464          . "\n WHERE block = '0'"
 465          . "\n ORDER BY ". $order
 466          ;
 467          $database->setQuery( $query );
 468          if ( $nouser ) {
 469              $users[] = mosHTML::makeOption( '0', T_('- No User -') );
 470              $users = array_merge( $users, $database->loadObjectList() );
 471          } else {
 472              $users = $database->loadObjectList();
 473          }
 474  
 475          $users = mosHTML::selectList( $users, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active );
 476  
 477          return $users;
 478      }
 479  
 480      /**
 481      * Select list of positions - generally used for location of images
 482      */
 483  	function Positions( $name, $active=NULL, $javascript=NULL, $none=1, $center=1, $left=1, $right=1 ) {
 484          if ( $none ) {
 485              $pos[] = mosHTML::makeOption( '', T_('None') );
 486          }
 487          if ( $center ) {
 488              $pos[] = mosHTML::makeOption( 'center', T_('Center') );
 489          }
 490          if ( $left ) {
 491              $pos[] = mosHTML::makeOption( 'left', T_('Left') );
 492          }
 493          if ( $right ) {
 494              $pos[] = mosHTML::makeOption( 'right', T_('Right') );
 495          }
 496  
 497          $positions = mosHTML::selectList( $pos, $name, 'class="inputbox" size="1"'. $javascript, 'value', 'text', $active );
 498  
 499          return $positions;
 500      }
 501  
 502      /**
 503      * Select list of active categories for components
 504      */
 505  	function ComponentCategory( $name, $section, $active=NULL, $javascript=NULL, $order='ordering', $size=1, $sel_cat=1 ) {
 506          global $database;
 507  
 508          // @RawSQLUse, trivial_implementation, SELECT
 509          $query = "SELECT id AS value, name AS text"
 510          . "\n FROM #__categories"
 511          . "\n WHERE section = '". $section ."'"
 512          . "\n AND published = '1'"
 513          . "\n ORDER BY ". $order
 514          ;
 515          $database->setQuery( $query );
 516          $categories = $database->loadObjectList();
 517          if (!$categories) $categories = array();
 518          if ( $sel_cat ) array_unshift($categories, mosHTML::makeOption('0', T_('- All Categories -')));
 519          if ( count( $categories ) < 1 ) mosRedirect( 'index2.php?option=com_categories&section='. $section, T_('You must create a category first.') );
 520          $categorylist = mosHTML::selectList( $categories, $name, 'class="inputbox" size="'. $size .'" '. $javascript, 'value', 'text', $active );
 521          return $categorylist;
 522      }
 523  
 524      /**
 525      * Select list of active sections
 526      */
 527  	function SelectSection( $name, $active=NULL, $javascript=NULL, $order='ordering' ) {
 528          global $database;
 529  
 530          $categories[] = mosHTML::makeOption( '0', T_('- All Sections -') );
 531          // @RawSQLUse, trivial_implementation, SELECT
 532          $query = "SELECT id AS value, title AS text"
 533          . "\n FROM #__sections"
 534          . "\n WHERE published = '1'"
 535          . "\n ORDER BY ". $order
 536          ;
 537          $database->setQuery( $query );
 538          if (is_array($database->loadObjectList())) {
 539            $sections = array_merge( $categories, $database->loadObjectList() );
 540          }
 541          $category = mosHTML::selectList( $sections, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active );
 542  
 543          return $category;
 544      }
 545  
 546      /**
 547      * Select list of menu items for a specific menu
 548      */
 549  	function Links2Menu( $type, $_and ) {
 550          global $database;
 551  
 552          // @RawSQLUse, trivial_implementation, SELECT
 553          $query = "SELECT *"
 554          . "\n FROM #__menu"
 555          . "\n WHERE type = '". $type ."'"
 556          . "\n AND published = '1'"
 557          . $_and
 558          ;
 559          $database->setQuery( $query );
 560          $menus = $database->loadObjectList();
 561  
 562          return $menus;
 563      }
 564  
 565      /**
 566      * Select list of menus
 567      */
 568  	function MenuSelect( $name='menuselect', $javascript=NULL ) {
 569          global $database;
 570  
 571          // @RawSQLUse, trivial_implementation, SELECT
 572          $query = "SELECT params"
 573          . "\n FROM #__modules"
 574          . "\n WHERE module = 'mod_mainmenu'"
 575          ;
 576          $database->setQuery( $query );
 577          $menus = $database->loadObjectList();
 578          $total = count( $menus );
 579          for( $i = 0; $i < $total; $i++ ) {
 580              $params = mosParseParams( $menus[$i]->params );
 581              $menuselect[$i]->value     = $params->menutype;
 582              $menuselect[$i]->text     = $params->menutype;
 583          }
 584          // sort array of objects
 585          SortArrayObjects( $menuselect, 'text', 1 );
 586  
 587          $menus = mosHTML::selectList( $menuselect, $name, 'class="inputbox" size="10" '. $javascript, 'value', 'text' );
 588  
 589          return $menus;
 590      }
 591  
 592      /**
 593      * Checks to see if an image exists in the current templates image directory
 594       * if it does it loads this image.  Otherwise the default image is loaded.
 595      * Also can be used in conjunction with the menulist param to create the chosen image
 596      * load the default or use no image
 597      */
 598  	function ImageCheckAdmin( $file, $directory='/administrator/images/', $param=NULL, $param_directory='/administrator/images/', $alt=NULL, $name=NULL, $type=1, $align='middle' ) {
 599          $mosConfig_live_site = mamboCore::get('mosConfig_live_site');
 600          $mainframe = mosMainFrame::getInstance();
 601          $cur_template = $mainframe->getTemplate();
 602          if ($param) $image = $mosConfig_live_site. $param_directory . $param;
 603          else {
 604              if ( file_exists(mamboCore::get('mosConfig_absolute_path').'/administrator/templates/'. $cur_template .'/images/'. $file ) ) {
 605                  $image = $mosConfig_live_site .'/administrator/templates/'. $cur_template .'/images/'. $file;
 606              }
 607              else $image = $mosConfig_live_site. $directory . $file;
 608          }
 609          // outputs actual html <img> tag
 610          if ( $type ) $image = '<img src="'. $image .'" alt="'. $alt .'" align="'. $align .'" name="'. $name .'" border="0" />';
 611          return $image;
 612      }
 613  
 614      /**
 615      * Internal function to recursive scan the media manager directories
 616      * @param string Path to scan
 617      * @param string root path of this folder
 618      * @param array  Value array of all existing folders
 619      * @param array  Value array of all existing images
 620      */
 621  	function ReadImages( $imagePath, $folderPath, &$folders, &$images ) {
 622          $imgDir =& new mosDirectory($imagePath);
 623          $imgFiles =& $imgDir->listFiles ('.', 'both');
 624  
 625          foreach ($imgFiles as $file) {
 626              $ff_ = $folderPath . $file .'/';
 627              $ff = $folderPath . $file;
 628              $i_f = $imagePath .'/'. $file;
 629  
 630              if ( is_dir( $i_f ) AND $file <> 'CVS' ) {
 631                  $folders[] = mosHTML::makeOption( $ff_ );
 632                  mosAdminMenus::ReadImages( $i_f, $ff_, $folders, $images );
 633              } else if ( eregi( "bmp|gif|jpg|png", $file ) AND is_file( $i_f ) ) {
 634                  // leading / we don't need
 635                  $imageFile = substr( $ff, 1 );
 636                  $images[$folderPath][] = mosHTML::makeOption( $imageFile, $file );
 637              }
 638          }
 639      }
 640  
 641  	function GetImageFolders( &$folders, $path ) {
 642          $javascript     = "onchange=\"changeDynaList( 'imagefiles', folderimages, document.adminForm.folders.options[document.adminForm.folders.selectedIndex].value, 0, 0);  previewImage( 'imagefiles', 'view_imagefiles', '$path/' );\"";
 643          $getfolders     = mosHTML::selectList( $folders, 'folders', 'class="inputbox" size="1" '. $javascript, 'value', 'text', '/' );
 644          return $getfolders;
 645      }
 646  
 647  	function GetImages( &$images, $path ) {
 648          if ( !isset($images['/'] ) ) $images['/'][] = mosHTML::makeOption( '' );
 649          //$javascript    = "onchange=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\" onfocus=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\"";
 650          $javascript    = "onchange=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\"";
 651          $getimages    = mosHTML::selectList( $images['/'], 'imagefiles', 'class="inputbox" size="10" multiple="multiple" '. $javascript , 'value', 'text', null );
 652  
 653          return $getimages;
 654      }
 655  
 656  	function GetSavedImages( &$row, $path ) {
 657          $images2 = array();
 658          foreach( $row->images as $file ) {
 659              $temp = explode( '|', $file );
 660              $filename = strrchr($temp[0], '/') ? substr( strrchr($temp[0], '/' ), 1 ) : $temp[0];
 661              $images2[] = mosHTML::makeOption( $file, $filename );
 662          }
 663          //$javascript    = "onchange=\"previewImage( 'imagelist', 'view_imagelist', '$path/' ); showImageProps( '$path/' ); \" onfocus=\"previewImage( 'imagelist', 'view_imagelist', '$path/' )\"";
 664          $javascript    = "onchange=\"previewImage( 'imagelist', 'view_imagelist', '$path/' ); showImageProps( '$path/' ); \"";
 665          $imagelist     = mosHTML::selectList( $images2, 'imagelist', 'class="inputbox" size="10" '. $javascript, 'value', 'text' );
 666  
 667          return $imagelist;
 668      }
 669  
 670  	function menutypes() {
 671          $modulehandler =& mosModuleHandler::getInstance();
 672          $modMenus =& $modulehandler->getByName('mod_mainmenu', false, true);
 673  
 674          $menuhandler =& mosMenuHandler::getInstance();
 675          $mtypes =& $menuhandler->getMenuTypes();
 676          $menuTypes = array();
 677          foreach ($mtypes as $type=>$count) $menuTypes[] = $type;
 678          foreach ($modMenus as $modMenu) {
 679              mosMakeHtmlSafe($modMenu) ;
 680              $modParams     = mosParseParams( $modMenu->params );
 681              $menuType     = @$modParams->menutype ? $modParams->menutype : 'mainmenu';
 682              if (!in_array($menuType, $menuTypes)) $menuTypes[] = $menuType;
 683          }
 684  
 685          // sorts menutypes
 686          asort( $menuTypes );
 687  
 688          return $menuTypes;
 689      }
 690  
 691      /*
 692      * loads files required for menu items
 693      */
 694  	function menuItem( $item ) {
 695          global $mosConfig_absolute_path;
 696  
 697          $path = $mosConfig_absolute_path .'/administrator/components/com_menus/'. $item .'/';
 698          include_once( $path . $item .'.class.php' );
 699          include_once( $path . $item .'.menu.html.php' );
 700      }
 701  }
 702  
 703  ?>