";
}
return implode( "\n", $html );
} else {
return "";
}
}
/**
* @param object A param tag node
* @param string The control name
* @return array Any array of the label, the form element and the tooltip
*/
function renderParam( &$param, $control_name='params' ) {
$result = array();
$name = $param->getAttribute( 'name' );
$label = $param->getAttribute( 'label' ) ;
$value = $this->get( $name, $param->getAttribute( 'default' ) );
$description = $param->getAttribute( 'description' );
$result[0] = $label ? $label : $name;
if ($result[0] == '@spacer') {
$result[0] = ' ';
} else {
$result[0] = mosToolTip( addslashes( $description ), addslashes( $result[0] ), '', '', $result[0], '#', 0 );
}
$type = $param->getAttribute( 'type' );
if (in_array( '_form_' . $type, $this->_methods )) {
$result[1] = call_user_func( array( &$this, '_form_' . $type ), $name, $value, $param, $control_name );
} else {
$result[1] = _HANDLER . ' = ' . $type;
}
if ( $description ) {
$result[2] = mosToolTip( $description, $result[0] );
$result[2] = '';
} else {
$result[2] = '';
}
return $result;
}
/**
* @param string The name of the form element
* @param string The value of the element
* @param object The xml element for the parameter
* @param string The control name
* @return string The html for the element
*/
function _form_text( $name, $value, &$node, $control_name ) {
$size = $node->getAttribute( 'size' );
return '';
}
/**
* @param string The name of the form element
* @param string The value of the element
* @param object The xml element for the parameter
* @param string The control name
* @return string The html for the element
*/
function _form_list( $name, $value, &$node, $control_name ) {
$size = $node->getAttribute( 'size' );
$options = array();
foreach ($node->childNodes as $option) {
$val = $option->getAttribute( 'value' );
$text = $option->gettext();
$options[] = mosHTML::makeOption( $val, $text );
}
return mosHTML::selectList( $options, ''. $control_name .'['. $name .']', 'class="inputbox"', 'value', 'text', $value );
}
/**
* @param string The name of the form element
* @param string The value of the element
* @param object The xml element for the parameter
* @param string The control name
* @return string The html for the element
*/
function _form_radio( $name, $value, &$node, $control_name ) {
global $_LANG;
$options = array();
foreach ($node->childNodes as $option) {
$val = $option->getAttribute( 'value' );
$text = $option->gettext();
if($text=='Hide') $text=$_LANG->_('Hide');
if($text=='Show') $text=$_LANG->_('Show');
if($text=='Yes') $text=$_LANG->_('Yes');
if($text=='No') $text=$_LANG->_('No');
$options[] = mosHTML::makeOption( $val, $text );
}
return mosHTML::radioList( $options, ''. $control_name .'['. $name .']', '', $value );
}
/**
* @param string The name of the form element
* @param string The value of the element
* @param object The xml element for the parameter
* @param string The control name
* @return string The html for the element
*/
function _form_mos_section( $name, $value, &$node, $control_name ) {
global $database;
global $_LANG;
$query = "SELECT id, title"
. "\n FROM #__sections"
. "\n WHERE published = 1"
. "\n AND scope = 'content'"
. "\n ORDER BY title"
;
$database->setQuery( $query );
$options = $database->loadObjectList();
array_unshift( $options, mosHTML::makeOption( '0', '- '.$_LANG->_('Select Section').' -', 'id', 'title' ) );
return mosHTML::selectList( $options, ''. $control_name .'['. $name .']', 'class="inputbox"', 'id', 'title', $value );
}
/**
* @param string The name of the form element
* @param string The value of the element
* @param object The xml element for the parameter
* @param string The control name
* @return string The html for the element
*/
function _form_mos_category( $name, $value, &$node, $control_name ) {
global $database;
global $_LANG;
$scope = $node->getAttribute( 'scope' );
if( !isset($scope) ) {
$scope = 'content';
}
if( $scope== 'content' ) {
// This might get a conflict with the dynamic translation - TODO: search for better solution
$query = "SELECT c.id, CONCAT_WS( '/',s.title, c.title ) AS title"
. "\n FROM #__categories AS c"
. "\n LEFT JOIN #__sections AS s ON s.id=c.section"
. "\n WHERE c.published = 1"
. "\n AND s.scope = '$scope'"
. "\n ORDER BY c.title"
;
} else {
$query = "SELECT c.id, c.title"
. "\n FROM #__categories AS c"
. "\n WHERE c.published = 1"
. "\n AND c.section = '$scope'"
. "\n ORDER BY c.title"
;
}
$database->setQuery( $query );
$options = $database->loadObjectList();
array_unshift( $options, mosHTML::makeOption( '0', '- '.$_LANG->_('Select Category').' -', 'id', 'title' ) );
return mosHTML::selectList( $options, ''. $control_name .'['. $name .']', 'class="inputbox"', 'id', 'title', $value );
}
/**
* @param string The name of the form element
* @param string The value of the element
* @param object The xml element for the parameter
* @param string The control name
* @return string The html for the element
*/
function _form_mos_menu( $name, $value, &$node, $control_name ) {
global $database;
global $_LANG;
$menuTypes = mosAdminMenus::menutypes();
foreach($menuTypes as $menutype ) {
$options[] = mosHTML::makeOption( $menutype, $menutype );
}
array_unshift( $options, mosHTML::makeOption( '', '- '.$_LANG->_('Select Menu').' -' ) );
return mosHTML::selectList( $options, ''. $control_name .'['. $name .']', 'class="inputbox"', 'value', 'text', $value );
}
/**
* @param string The name of the form element
* @param string The value of the element
* @param object The xml element for the parameter
* @param string The control name
* @return string The html for the element
*/
function _form_filelist( $name, $value, &$node, $control_name ) {
global $mosConfig_absolute_path;
global $_LANG;
// path to images directory
$path = $mosConfig_absolute_path . $node->getAttribute( 'directory' );
$filter = $node->getAttribute( 'filter' );
$files = mosReadDirectory( $path, $filter );
$options = array();
foreach ($files as $file) {
$options[] = mosHTML::makeOption( $file, $file );
}
if ( !$node->getAttribute( 'hide_none' ) ) {
array_unshift( $options, mosHTML::makeOption( '-1', '- '. $_LANG->_('Do Not Use') .' -' ) );
}
if ( !$node->getAttribute( 'hide_default' ) ) {
array_unshift( $options, mosHTML::makeOption( '', '- '. $_LANG->_('Use Default') .' -' ) );
}
return mosHTML::selectList( $options, ''. $control_name .'['. $name .']', 'class="inputbox"', 'value', 'text', $value, "param$name" );
}
/**
* @param string The name of the form element
* @param string The value of the element
* @param object The xml element for the parameter
* @param string The control name
* @return string The html for the element
*/
function _form_imagelist( $name, $value, &$node, $control_name ) {
$node->setAttribute( 'filter', '\.png$|\.gif$|\.jpg$|\.bmp$|\.ico$' );
return $this->_form_filelist( $name, $value, $node, $control_name );
}
/**
* @param string The name of the form element
* @param string The value of the element
* @param object The xml element for the parameter
* @param string The control name
* @return string The html for the element
*/
function _form_textarea( $name, $value, &$node, $control_name ) {
$rows = $node->getAttribute( 'rows' );
$cols = $node->getAttribute( 'cols' );
// convert tags so they are not visible when editing
$value = str_replace( ' ', "\n", $value );
return '';
}
/**
* @param string The name of the form element
* @param string The value of the element
* @param object The xml element for the parameter
* @param string The control name
* @return string The html for the element
*/
function _form_spacer( $name, $value, &$node, $control_name ) {
if ( $value ) {
return $value;
} else {
return '';
}
}
/**
* special handling for textarea param
*/
function textareaHandling( &$txt ) {
$total = count( $txt );
for( $i=0; $i < $total; $i++ ) {
if ( strstr( $txt[$i], "\n" ) ) {
$txt[$i] = str_replace( "\n", ' ', $txt[$i] );
}
}
$txt = implode( "\n", $txt );
return $txt;
}
}
/**
* @param string
* @return string
*/
function mosParseParams( $txt ) {
return mosParameters::parse( $txt );
}
class mosEmpty {
function def( $key, $value='' ) {
return 1;
}
function get( $key, $default='' ) {
return 1;
}
}
?>