Source for file mosAdminMenus.php
Documentation is available at mosAdminMenus.php
* @author Mambo Foundation Inc see README.php
* @copyright Mambo Foundation Inc.
* See COPYRIGHT.php for copyright notices and details.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see
* Mambo is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2 of the
/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
function mosTreeRecurse( $id, $indent, $list, &$children, $maxlevel=
9999, $level=
0, $type=
1,$parent=
'parent') {
if (@$children[$id] AND $level <=
$maxlevel) {
$newindent =
$indent.
($type ?
'. ' :
' ');
$pre =
$type ?
'<sup>L</sup> ' :
'- ';
foreach ($children[$id] as $v) {
$list[$id]->treename =
$indent.
($v->$parent ==
0 ?
'' :
$pre).
$v->name;
$list[$id]->children =
count( @$children[$id] );
$list[$id]->level =
$level;
$list =
mosTreeRecurse( $id, $newindent, $list, $children, $maxlevel, $level+
1, $type );
* @param string SQL with ordering As value and 'name field' AS text
* @param integer The length of the truncated headline
$database->setQuery( $sql );
if (!($orders =
$database->loadObjectList())) {
if ($database->getErrorNum()) {
echo
$database->stderr();
foreach ($orders as $ord) {
$text =
strlen($ord->text) >
$chop ?
substr($ord->text,0,$chop).
"..." :
$ord->text;
* Common HTML Output Files
* build the select list for Menu Ordering
.
"\n WHERE menutype='".
$row->menutype .
"'"
.
"\n AND parent='".
$row->parent .
"'"
.
"\n AND published != '-2'"
$ordering =
mosHTML::selectList( $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) );
$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.');
* build the select list for access level
* @param object a module object
* @return mixed a select list
$query =
'SELECT id AS value, name AS text FROM #__groups ORDER BY id';
$database->setQuery( $query );
$groups =
$database->loadObjectList();
$access =
mosHTML::selectList( $groups, 'access', 'class="inputbox" size="3"', 'value', 'text', intval( $row->access ) );
* build the select list for module group access
$gtree =
$acl->get_group_children_tree( null, 'USERS', false );
for($i =
0; $i<
count($gtree); $i++
) {
$temp =
explode('-', $gtree[$i]->text);
$idx =
(count($temp) ==
1) ?
0 :
1;
if ($gtree[$i]->value !=
29 &&
$gtree[$i]->value !=
30) {
$list[$j]->value =
$gtree[$i]->value;
$groups =
explode(',',$row->groups);
for($i=
0; $i <
count($groups); $i++
) {
$group->value =
$groups[$i];
$groupSelect =
mosHTML::selectList( $list, 'groups[]', 'class="inputbox" multiple="multiple" size="6"', 'value', 'text', $groups );
* build the select list for parent item
// get a list of the menu items
.
"\n WHERE menutype='$row->menutype'"
.
"\n AND published <> -2"
$database->setQuery( $query );
$mitems =
$database->loadObjectList();
// establish the hierarchy of the menu
// first pass - collect children
foreach ( $mitems as $v ) {
$list =
@$children[$pt] ?
$children[$pt] :
array();
// second pass - get an indent list of the items
// assemble menu items to the array
foreach ( $list as $item ) {
if ( $item->id !=
$row->id &&
strpos( $item->treename, $this_treename ) ===
false) {
if ( $item->id !=
$row->id ) {
$this_treename =
"$item->treename/";
$parent =
mosHTML::selectList( $mitems, 'parent', 'class="inputbox" size="1"', 'value', 'text', $row->parent );
* build a radio button option for published state
* build the link/url of a menu item
function Link( &$row, $id, $link=
NULL ) {
$link =
$row->link .
'&Itemid='.
$row->id;
* build the select list for target window
$target =
mosHTML::selectList( $click, 'browserNav', 'class="inputbox" size="4"', 'value', 'text', intval( $row->browserNav ) );
* build the multiple select list for Menu Links/Pages
function MenuLinks( &$lookup, $all=
NULL, $none=
NULL ) {
// get a list of the menu items
$database->setQuery( "SELECT m.*"
.
"\n WHERE type != 'separator'"
.
"\n AND link NOT LIKE '%tp:/%'"
.
"\n AND published = '1'"
.
"\n ORDER BY menutype, parent, ordering"
$mitems =
$database->loadObjectList();
// establish the hierarchy of the menu
// first pass - collect children
foreach ( $mitems as $v ) {
$list =
@$children[$pt] ?
$children[$pt] :
array();
// second pass - get an indent list of the items
// Code that adds menu name to Display of Page(s)
$mitems_spacer =
$mitems_temp[0]->menutype;
foreach ($list as $list_a) {
foreach ($mitems_temp as $mitems_a) {
if ($mitems_a->id ==
$list_a->id) {
// Code that inserts the blank line that seperates different menus
if ($mitems_a->menutype <>
$mitems_spacer) {
$mitems_spacer =
$mitems_a->menutype;
$text =
$mitems_a->menutype.
" | ".
$list_a->treename;
if ( strlen($text) >
$text_count) {
// prepare an array with 'all' as the first item
// adds space, in select box which is not saved
// prepare an array with 'all' as the first item
// adds space, in select box which is not saved
// append the rest of the menu items to the array
foreach ($list as $item) {
$pages =
mosHTML::selectList( $mitems, 'selections[]', 'class="inputbox" size="26" multiple="multiple"', 'value', 'text', $lookup );
* build the select list to choose a category
function Category( &$menu, $id, $javascript=
'' ) {
$query =
"SELECT c.id AS `value`, c.section AS `id`, CONCAT_WS( ' / ', s.title, c.title) AS `text`"
.
"\n FROM #__sections AS s"
.
"\n INNER JOIN #__categories AS c ON c.section = s.id"
.
"\n WHERE s.scope = 'content'"
.
"\n ORDER BY s.name,c.name"
$database->setQuery( $query );
$rows =
$database->loadObjectList();
foreach ( $rows as $row ) {
if ( $row->value ==
$menu->componentid ) {
$category .=
'<input type="hidden" name="componentid" value="'.
$menu->componentid .
'" />';
$category .=
'<input type="hidden" name="link" value="'.
$menu->link .
'" />';
$category =
mosHTML::selectList( $rows, 'componentid', 'class="inputbox" size="10"'.
$javascript, 'value', 'text' );
$category .=
'<input type="hidden" name="link" value="" />';
* build the select list to choose a section
function Section( &$menu, $id, $all=
0 ) {
$query =
"SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`"
.
"\n FROM #__sections AS s"
.
"\n WHERE s.scope = 'content'"
$database->setQuery( $query );
$rows =
array_merge( $rows, $database->loadObjectList() );
$rows =
$database->loadObjectList();
foreach ( $rows as $row ) {
if ( $row->value ==
$menu->componentid ) {
$section .=
'<input type="hidden" name="componentid" value="'.
$menu->componentid .
'" />';
$section .=
'<input type="hidden" name="link" value="'.
$menu->link .
'" />';
$section =
mosHTML::selectList( $rows, 'componentid', 'class="inputbox" size="10"', 'value', 'text' );
$section .=
'<input type="hidden" name="link" value="" />';
* build the select list to choose a component
$query =
"SELECT c.id AS value, c.name AS text, c.link"
.
"\n FROM #__components AS c"
.
"\n WHERE c.link <> ''"
$database->setQuery( $query );
$rows =
$database->loadObjectList( );
// existing component, just show name
foreach ( $rows as $row ) {
if ( $row->value ==
$menu->componentid ) {
$component .=
'<input type="hidden" name="componentid" value="'.
$menu->componentid .
'" />';
$component =
mosHTML::selectList( $rows, 'componentid', 'class="inputbox" size="10"', 'value', 'text' );
* build the select list to choose a component
$query =
"SELECT c.id AS value, c.name AS text, c.link"
.
"\n FROM #__components AS c"
.
"\n WHERE c.link <> ''"
$database->setQuery( $query );
$rows =
$database->loadObjectList( );
$component =
'Component';
foreach ( $rows as $row ) {
if ( $row->value ==
$menu->componentid ) {
* build the select list to choose an image
function Images( $name, &$active, $javascript=
NULL, $directory=
NULL ) {
global $mosConfig_absolute_path;
$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'}\"";
$directory =
'/images/stories';
foreach ( $imageFiles as $file ) {
if ( eregi( "bmp|gif|jpg|png", $file ) ) {
$images =
mosHTML::selectList( $images, $name, 'class="inputbox" size="1" '.
$javascript, 'value', 'text', $active );
* build the select list for Ordering of a specified Table
$text =
T_('New items default to the first place. Ordering can be changed after this item is saved.');
$text =
T_('New items default to the last place. Ordering can be changed after this item is saved.');
$ordering =
mosHTML::selectList( $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) );
$ordering =
'<input type="hidden" name="ordering" value="'.
$row->ordering .
'" />'.
$text;
* Select list of active users
function UserSelect( $name, $active, $nouser=
0, $javascript=
NULL, $order=
'name' ) {
$query =
"SELECT id AS value, CONCAT(name,' (',username,')') AS text"
$database->setQuery( $query );
$users =
array_merge( $users, $database->loadObjectList() );
$users =
$database->loadObjectList();
$users =
mosHTML::selectList( $users, $name, 'class="inputbox" size="1" '.
$javascript, 'value', 'text', $active );
* Select list of positions - generally used for location of images
function Positions( $name, $active=
NULL, $javascript=
NULL, $none=
1, $center=
1, $left=
1, $right=
1 ) {
$positions =
mosHTML::selectList( $pos, $name, 'class="inputbox" size="1"'.
$javascript, 'value', 'text', $active );
* Select list of active categories for components
function ComponentCategory( $name, $section, $active=
NULL, $javascript=
NULL, $order=
'ordering', $size=
1, $sel_cat=
1 ) {
$query =
"SELECT id AS value, name AS text"
.
"\n FROM #__categories"
.
"\n WHERE section = '".
$section .
"'"
.
"\n AND published = '1'"
$database->setQuery( $query );
$categories =
$database->loadObjectList();
if (!$categories) $categories =
array();
if ( count( $categories ) <
1 ) mosRedirect( 'index2.php?option=com_categories§ion='.
$section, T_('You must create a category first.') );
$categorylist =
mosHTML::selectList( $categories, $name, 'class="inputbox" size="'.
$size .
'" '.
$javascript, 'value', 'text', $active );
* Select list of active sections
function SelectSection( $name, $active=
NULL, $javascript=
NULL, $order=
'ordering' ) {
$query =
"SELECT id AS value, title AS text"
.
"\n WHERE published = '1'"
$database->setQuery( $query );
if (is_array($database->loadObjectList())) {
$sections =
array_merge( $categories, $database->loadObjectList() );
$category =
mosHTML::selectList( $sections, $name, 'class="inputbox" size="1" '.
$javascript, 'value', 'text', $active );
* Select list of menu items for a specific menu
.
"\n WHERE type = '".
$type .
"'"
.
"\n AND published = '1'"
$database->setQuery( $query );
$menus =
$database->loadObjectList();
function MenuSelect( $name=
'menuselect', $javascript=
NULL ) {
.
"\n WHERE module = 'mod_mainmenu'"
$database->setQuery( $query );
$menus =
$database->loadObjectList();
$total =
count( $menus );
for( $i =
0; $i <
$total; $i++
) {
$menuselect[$i]->value =
$params->menutype;
$menuselect[$i]->text =
$params->menutype;
$menus =
mosHTML::selectList( $menuselect, $name, 'class="inputbox" size="10" '.
$javascript, 'value', 'text' );
* Checks to see if an image exists in the current templates image directory
* if it does it loads this image. Otherwise the default image is loaded.
* Also can be used in conjunction with the menulist param to create the chosen image
* load the default or use no image
function ImageCheckAdmin( $file, $directory=
'/administrator/images/', $param=
NULL, $param_directory=
'/administrator/images/', $alt=
NULL, $name=
NULL, $type=
1, $align=
'middle' ) {
$mosConfig_live_site =
mamboCore::get('mosConfig_live_site');
$cur_template =
$mainframe->getTemplate();
if ($param) $image =
$mosConfig_live_site.
$param_directory .
$param;
if ( file_exists(mamboCore::get('mosConfig_absolute_path').
'/administrator/templates/'.
$cur_template .
'/images/'.
$file ) ) {
$image =
$mosConfig_live_site .
'/administrator/templates/'.
$cur_template .
'/images/'.
$file;
else $image =
$mosConfig_live_site.
$directory .
$file;
// outputs actual html <img> tag
if ( $type ) $image =
'<img src="'.
$image .
'" alt="'.
$alt .
'" align="'.
$align .
'" name="'.
$name .
'" border="0" />';
* Internal function to recursive scan the media manager directories
* @param string Path to scan
* @param string root path of this folder
* @param array Value array of all existing folders
* @param array Value array of all existing images
function ReadImages( $imagePath, $folderPath, &$folders, &$images ) {
$imgFiles =
& $imgDir->listFiles ('.', 'both');
foreach ($imgFiles as $file) {
$ff_ =
$folderPath .
$file .
'/';
$ff =
$folderPath .
$file;
$i_f =
$imagePath .
'/'.
$file;
if ( is_dir( $i_f ) AND $file <>
'CVS' ) {
} else if ( eregi( "bmp|gif|jpg|png", $file ) AND is_file( $i_f ) ) {
// leading / we don't need
$imageFile =
substr( $ff, 1 );
$javascript =
"onchange=\"changeDynaList( 'imagefiles', folderimages, document.adminForm.folders.options[document.adminForm.folders.selectedIndex].value, 0, 0); previewImage( 'imagefiles', 'view_imagefiles', '$path/' );\"";
$getfolders =
mosHTML::selectList( $folders, 'folders', 'class="inputbox" size="1" '.
$javascript, 'value', 'text', '/' );
//$javascript = "onchange=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\" onfocus=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\"";
$javascript =
"onchange=\"previewImage( 'imagefiles', 'view_imagefiles', '$path/' )\"";
$getimages =
mosHTML::selectList( $images['/'], 'imagefiles', 'class="inputbox" size="10" multiple="multiple" '.
$javascript , 'value', 'text', null );
foreach( $row->images as $file ) {
//$javascript = "onchange=\"previewImage( 'imagelist', 'view_imagelist', '$path/' ); showImageProps( '$path/' ); \" onfocus=\"previewImage( 'imagelist', 'view_imagelist', '$path/' )\"";
$javascript =
"onchange=\"previewImage( 'imagelist', 'view_imagelist', '$path/' ); showImageProps( '$path/' ); \"";
$imagelist =
mosHTML::selectList( $images2, 'imagelist', 'class="inputbox" size="10" '.
$javascript, 'value', 'text' );
$modMenus =
& $modulehandler->getByName('mod_mainmenu', false, true);
$mtypes =
& $menuhandler->getMenuTypes();
foreach ($mtypes as $type=>
$count) $menuTypes[] =
$type;
foreach ($modMenus as $modMenu) {
$menuType =
@$modParams->menutype ?
$modParams->menutype :
'منوی اصلی';
if (!in_array($menuType, $menuTypes)) $menuTypes[] =
$menuType;
* loads files required for menu items
global $mosConfig_absolute_path;
$path =
$mosConfig_absolute_path .
'/administrator/components/com_menus/'.
$item .
'/';
include_once( $path .
$item .
'.class.php' );
include_once( $path .
$item .
'.menu.html.php' );
Documentation generated on Mon, 05 May 2008 16:21:27 +0400 by phpDocumentor 1.4.0