| 162 |
else $this->set('mosConfig_lang', 'english'); |
else $this->set('mosConfig_lang', 'english'); |
| 163 |
$language_file = "$this->mosConfig_absolute_path/language/$this->mosConfig_lang.php"; |
$language_file = "$this->mosConfig_absolute_path/language/$this->mosConfig_lang.php"; |
| 164 |
if (file_exists($language_file)) require_once ($language_file); |
if (file_exists($language_file)) require_once ($language_file); |
| 165 |
|
|
| 166 |
|
DEFINE('_ISO','charset=iso-8859-1'); |
| 167 |
|
DEFINE('_DATE_FORMAT_LC',"%A, %d %B %Y"); //Uses PHP's strftime Command Format |
| 168 |
|
DEFINE('_DATE_FORMAT_LC2',"%A, %d %B %Y %H:%M"); |
| 169 |
|
// include phpgettext library |
| 170 |
|
require_once( 'includes/phpgettext/phpgettext.class.php' ); |
| 171 |
|
require_once( 'includes/phpgettext/phpgettext.includes.php' ); |
| 172 |
|
|
| 173 |
|
set_error_handler('error_handler'); |
| 174 |
|
|
| 175 |
|
$domain = 'frontend'; |
| 176 |
|
$textdomain = $this->mosConfig_absolute_path.'language'; |
| 177 |
|
$charset = 'utf-8'; |
| 178 |
|
$phpgettext =& phpgettext(); |
| 179 |
|
$phpgettext->setlocale($this->mosConfig_locale); |
| 180 |
|
$phpgettext->bindtextdomain($domain, $textdomain); |
| 181 |
|
$phpgettext->bind_textdomain_codeset($domain, $charset); |
| 182 |
|
$phpgettext->textdomain($domain); |
| 183 |
|
|
| 184 |
|
|
| 185 |
} |
} |
| 186 |
|
|
| 187 |
function secure () { |
function secure () { |
| 1089 |
* Constructor |
* Constructor |
| 1090 |
*/ |
*/ |
| 1091 |
function mosMambotHandler() { |
function mosMambotHandler() { |
| 1092 |
if (mamboCore::is_set('currentUser')) $gid = mamboCore::get('currentUser')->gid; |
if (mamboCore::is_set('currentUser')) { |
| 1093 |
|
$cu = mamboCore::get('currentUser'); |
| 1094 |
|
$gid = $cu->gid; |
| 1095 |
|
} |
| 1096 |
else $gid = 0; |
else $gid = 0; |
| 1097 |
$this->_events = array(); |
$this->_events = array(); |
| 1098 |
$database = mamboDatabase::getInstance(); |
$database = mamboDatabase::getInstance(); |
| 1385 |
*/ |
*/ |
| 1386 |
function &getInstance () { |
function &getInstance () { |
| 1387 |
static $mainframe; |
static $mainframe; |
| 1388 |
if (func_num_args()) { |
if (!isset($mainframe) && func_num_args()) { |
| 1389 |
$args =& func_get_args(); |
$mainframe = func_get_arg(0); |
|
$mainframe = $args[0]; |
|
| 1390 |
} |
} |
| 1391 |
if (isset($mainframe)) $result =& $mainframe; |
return $mainframe; |
|
else $result = null; |
|
|
return $result; |
|
| 1392 |
} |
} |
| 1393 |
/** |
/** |
| 1394 |
* @param string |
* @param string |
| 1909 |
var $_params = null; |
var $_params = null; |
| 1910 |
/** @var string The raw params string */ |
/** @var string The raw params string */ |
| 1911 |
var $_raw = null; |
var $_raw = null; |
|
/** @var string Path to the xml setup file */ |
|
|
var $_path = null; |
|
|
/** @var string The type of setup file */ |
|
|
var $_type = null; |
|
|
/** @var object The xml params element */ |
|
|
var $_xmlElem = null; |
|
| 1912 |
/** |
/** |
| 1913 |
* Constructor |
* Constructor |
| 1914 |
* @param string The raw parms text |
* @param string The raw parms text |
| 1915 |
* @param string Path to the xml setup file |
* @param string Path to the xml setup file |
| 1916 |
* @var string The type of setup file |
* @var string The type of setup file |
| 1917 |
*/ |
*/ |
| 1918 |
function mosParameters( $text, $path='', $type='component' ) { |
function mosParameters( $text, $process_sections = false) { |
| 1919 |
$this->_params = $this->parse( $text ); |
$this->_params = $this->parse( $text, $process_sections ); |
| 1920 |
$this->_raw = $text; |
$this->_raw = $text; |
| 1921 |
$this->_path = $path; |
} |
| 1922 |
$this->_type = $type; |
/** |
| 1923 |
|
* Get the result of parsing the string provided on creation |
| 1924 |
|
* @return string parsed result |
| 1925 |
|
*/ |
| 1926 |
|
function getParams () { |
| 1927 |
|
return $this->_params; |
| 1928 |
} |
} |
| 1929 |
/** |
/** |
| 1930 |
* @param string The name of the param |
* @param string The name of the param |
| 1950 |
* @return string |
* @return string |
| 1951 |
*/ |
*/ |
| 1952 |
function get( $key, $default='' ) { |
function get( $key, $default='' ) { |
| 1953 |
if (isset( $this->_params->$key )) { |
if (isset( $this->_params->$key )) return $this->_params->$key === '' ? $default : $this->_params->$key; |
| 1954 |
return $this->_params->$key === '' ? $default : $this->_params->$key; |
else return $default; |
|
} else { |
|
|
return $default; |
|
| 1955 |
} |
} |
| 1956 |
|
/** |
| 1957 |
|
* Look to see if string is bracketed by opener and closer |
| 1958 |
|
* If so, extract and trim the bracketed string |
| 1959 |
|
* Otherwise, return a null string |
| 1960 |
|
**/ |
| 1961 |
|
function getBracketed ($text, $opener, $closer) { |
| 1962 |
|
if (strlen($text) > 1 AND ($text[0] != $opener OR substr($text,-1) != $closer)) return ''; |
| 1963 |
|
else return trim(substr($text,1,-1)); |
| 1964 |
} |
} |
| 1965 |
/** |
/** |
| 1966 |
* Parse an .ini string, based on phpDocumentor phpDocumentor_parse_ini_file function |
* Parse an .ini string, based on phpDocumentor phpDocumentor_parse_ini_file function |
| 1969 |
* @return object |
* @return object |
| 1970 |
*/ |
*/ |
| 1971 |
function parse( $txt, $process_sections = false ) { |
function parse( $txt, $process_sections = false ) { |
| 1972 |
if (is_string( $txt )) { |
$result = new stdClass(); |
| 1973 |
$lines = explode( "\n", $txt ); |
if (is_string($txt)) $lines = explode( "\n", $txt ); |
| 1974 |
} else if (is_array( $txt )) { |
elseif (is_array($txt)) $lines = $txt; |
| 1975 |
$lines = $txt; |
else return $result; |
|
} else { |
|
|
$lines = array(); |
|
|
} |
|
|
$obj = new stdClass(); |
|
| 1976 |
|
|
| 1977 |
$sec_name = ''; |
$sec_name = ''; |
| 1978 |
$unparsed = 0; |
$unparsed = 0; |
| 1979 |
if (!$lines) { |
|
|
return $obj; |
|
|
} |
|
| 1980 |
foreach ($lines as $line) { |
foreach ($lines as $line) { |
| 1981 |
// ignore comments |
// ignore comments and null lines |
|
if ($line && $line[0] == ';') { |
|
|
continue; |
|
|
} |
|
| 1982 |
$line = trim( $line ); |
$line = trim( $line ); |
| 1983 |
|
if (strlen($line) == 0 OR $line[0] == ';') continue; |
| 1984 |
|
|
| 1985 |
if ($line == '') { |
if ($sec_name = $this->getBracketed($line, '[', ']')) { |
| 1986 |
|
if ($process_sections) $result->$sec_name = new stdClass(); |
| 1987 |
continue; |
continue; |
| 1988 |
} |
} |
|
if ($line && $line[0] == '[' && $line[strlen($line) - 1] == ']') { |
|
|
$sec_name = substr( $line, 1, strlen($line) - 2 ); |
|
|
if ($process_sections) { |
|
|
$obj->$sec_name = new stdClass(); |
|
|
} |
|
|
} else { |
|
|
if ($pos = strpos( $line, '=' )) { |
|
|
$property = trim( substr( $line, 0, $pos ) ); |
|
|
|
|
|
if (substr($property, 0, 1) == '"' && substr($property, -1) == '"') { |
|
|
$property = stripcslashes(substr($property,1,count($property) - 2)); |
|
|
} |
|
|
$value = trim( substr( $line, $pos + 1 ) ); |
|
|
if ($value == 'false') { |
|
|
$value = false; |
|
|
} |
|
|
if ($value == 'true') { |
|
|
$value = true; |
|
|
} |
|
|
if (substr( $value, 0, 1 ) == '"' && substr( $value, -1 ) == '"') { |
|
|
$value = stripcslashes( substr( $value, 1, count( $value ) - 2 ) ); |
|
|
} |
|
| 1989 |
|
|
| 1990 |
if ($process_sections) { |
if (count($propsetter = explode ('=', $line, 2)) == 2) { |
| 1991 |
if ($sec_name != '') { |
$property = trim($propsetter[0]); |
| 1992 |
$obj->$sec_name->$property = $value; |
if ($pquoted = $this->getBracketed($property, '"', '"')) $property = stripcslashes($pquoted); |
| 1993 |
} else { |
$value = trim($propsetter[1]); |
| 1994 |
$obj->$property = $value; |
if ($value == 'false') $value = false; |
| 1995 |
|
elseif ($value == 'true') $value = true; |
| 1996 |
|
else if ($vquoted = $this->getBracketed($value, '"', '"')) $value = stripcslashes($vquoted); |
| 1997 |
|
if ($process_sections AND $sec_name) $result->$sec_name->$property = $value; |
| 1998 |
|
else $result->$property = $value; |
| 1999 |
} |
} |
| 2000 |
} else { |
else { |
|
$obj->$property = $value; |
|
|
} |
|
|
} else { |
|
|
if ($line && trim($line[0]) == ';') { |
|
|
continue; |
|
|
} |
|
|
if ($process_sections) { |
|
| 2001 |
$property = '__invalid' . $unparsed++ . '__'; |
$property = '__invalid' . $unparsed++ . '__'; |
| 2002 |
if ($process_sections) { |
if ($process_sections AND $sec_name) $result->$sec_name->$property = $line; |
| 2003 |
if ($sec_name != '') { |
else $result->$property = $line; |
|
$obj->$sec_name->$property = trim($line); |
|
|
} else { |
|
|
$obj->$property = trim($line); |
|
|
} |
|
|
} else { |
|
|
$obj->$property = trim($line); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return $obj; |
|
|
} |
|
|
/** |
|
|
* @param string The name of the control, or the default text area if a setup file is not found |
|
|
* @return string HTML |
|
|
*/ |
|
|
function render( $name='params' ) { |
|
|
global $mosConfig_absolute_path; |
|
|
|
|
|
if ($this->_path) { |
|
|
if (!is_object( $this->_xmlElem )) { |
|
|
require_once( $mosConfig_absolute_path . '/includes/domit/xml_domit_lite_include.php' ); |
|
|
|
|
|
$xmlDoc =& new DOMIT_Lite_Document(); |
|
|
$xmlDoc->resolveErrors( true ); |
|
|
if ($xmlDoc->loadXML( $this->_path, false, true )) { |
|
|
$element =& $xmlDoc->documentElement; |
|
|
|
|
|
if ($element->getTagName() == 'mosinstall' && $element->getAttribute( "type" ) == $this->_type) { |
|
|
if ($element = &$xmlDoc->getElementsByPath( 'params', 1 )) { |
|
|
$this->_xmlElem =& $element; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (is_object( $this->_xmlElem )) { |
|
|
$html = array(); |
|
|
$html[] = '<table class="paramlist">'; |
|
|
|
|
|
$element =& $this->_xmlElem; |
|
|
|
|
|
if ($description = $element->getAttribute( 'description' )) { |
|
|
// add the params description to the display |
|
|
$html[] = '<tr><td colspan="3">' . $description . '</td></tr>'; |
|
|
} |
|
|
|
|
|
//$params = mosParseParams( $row->params ); |
|
|
$this->_methods = get_class_methods( get_class( $this ) ); |
|
|
|
|
|
foreach ($element->childNodes as $param) { |
|
|
$result = $this->renderParam( $param, $name ); |
|
|
$html[] = '<tr>'; |
|
|
|
|
|
$html[] = '<td width="35%" align="right" valign="top">' . $result[0] . '</td>'; |
|
|
$html[] = '<td>' . $result[1] . '</td>'; |
|
|
$html[] = '<td width="10%" align="left" valign="top">' . $result[2] . "</td>"; |
|
|
|
|
|
$html[] = '</tr>'; |
|
|
} |
|
|
$html[] = '</table>'; |
|
|
|
|
|
if (count( $element->childNodes ) < 1) { |
|
|
$html[] = "<tr><td colspan=\"2\"><i>" . _NO_PARAMS . "</i></td></tr>"; |
|
|
} |
|
|
return implode( "\n", $html ); |
|
|
} else { |
|
|
return "<textarea name=\"$name\" cols=\"40\" rows=\"10\" class=\"text_area\">$this->_raw</textarea>"; |
|
|
} |
|
|
} |
|
|
/** |
|
|
* @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] = '<hr/>'; |
|
|
} else if ( $result[0] ) { |
|
|
$result[0] .= ':'; |
|
| 2004 |
} |
} |
|
|
|
|
$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; |
|
| 2005 |
} |
} |
|
|
|
|
if ( $description ) { |
|
|
$result[2] = mosToolTip( $description, $name ); |
|
|
} else { |
|
|
$result[2] = ''; |
|
|
} |
|
|
|
|
| 2006 |
return $result; |
return $result; |
| 2007 |
} |
} |
| 2008 |
/** |
/** |
|
* @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 '<input type="text" name="'. $control_name .'['. $name .']" value="'. $value .'" class="text_area" size="'. $size .'"/>'; |
|
|
} |
|
|
/** |
|
|
* @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 ) { |
|
|
$options = array(); |
|
|
foreach ($node->childNodes as $option) { |
|
|
$val = $option->getAttribute( 'value' ); |
|
|
$text = $option->gettext(); |
|
|
$options[] = mosHTML::makeOption( $val, $text, true ); |
|
|
} |
|
|
|
|
|
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; |
|
|
|
|
|
$query = "SELECT id AS value, title AS text" |
|
|
. "\n FROM #__sections" |
|
|
. "\n WHERE published='1' AND scope='content'" |
|
|
. "\n ORDER BY title" |
|
|
; |
|
|
$database->setQuery( $query ); |
|
|
$options = $database->loadObjectList(); |
|
|
array_unshift( $options, mosHTML::makeOption( '0', '- Select Content Section -' ) ); |
|
|
|
|
|
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_mos_category( $name, $value, &$node, $control_name ) { |
|
|
global $database; |
|
|
|
|
|
$query = "SELECT c.id AS value, CONCAT_WS( '/',s.title, c.title ) AS text" |
|
|
. "\n FROM #__categories AS c" |
|
|
. "\n LEFT JOIN #__sections AS s ON s.id=c.section" |
|
|
. "\n WHERE c.published='1' AND s.scope='content'" |
|
|
. "\n ORDER BY c.title" |
|
|
; |
|
|
$database->setQuery( $query ); |
|
|
$options = $database->loadObjectList(); |
|
|
array_unshift( $options, mosHTML::makeOption( '0', '- Select Content Category -' ) ); |
|
|
|
|
|
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_mos_menu( $name, $value, &$node, $control_name ) { |
|
|
// global $database; |
|
|
// |
|
|
// $menuTypes = $mainframe->menutypes(); |
|
|
// |
|
|
// foreach($menuTypes as $menutype ) { |
|
|
// $options[] = mosHTML::makeOption( $menutype, $menutype ); |
|
|
// } |
|
|
// array_unshift( $options, mosHTML::makeOption( '', '- 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_imagelist( $name, $value, &$node, $control_name ) { |
|
|
global $mosConfig_absolute_path; |
|
|
|
|
|
// path to images directory |
|
|
$path = $mosConfig_absolute_path . $node->getAttribute( 'directory' ); |
|
|
$files = mosReadDirectory( $path, '\.png$|\.gif$|\.jpg$|\.bmp$|\.ico$' ); |
|
|
|
|
|
$options = array(); |
|
|
foreach ($files as $file) { |
|
|
$options[] = mosHTML::makeOption( $file, $file ); |
|
|
} |
|
|
if ( !$node->getAttribute( 'hide_none' ) ) { |
|
|
array_unshift( $options, mosHTML::makeOption( '-1', '- Do not use an image -' ) ); |
|
|
} |
|
|
if ( !$node->getAttribute( 'hide_default' ) ) { |
|
|
array_unshift( $options, mosHTML::makeOption( '', '- Use Default image -' ) ); |
|
|
} |
|
|
|
|
|
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_textarea( $name, $value, &$node, $control_name ) { |
|
|
$rows = $node->getAttribute( 'rows' ); |
|
|
$cols = $node->getAttribute( 'cols' ); |
|
|
// convert <br /> tags so they are not visible when editing |
|
|
$value = str_replace( '<br />', "\n", $value ); |
|
|
|
|
|
return '<textarea name="params['. $name .']" cols="'. $cols .'" rows="'. $rows .'" class="text_area">'. $value .'</textarea>'; |
|
|
} |
|
|
|
|
|
/** |
|
|
* @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 '<hr />'; |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
| 2009 |
* special handling for textarea param |
* special handling for textarea param |
| 2010 |
*/ |
*/ |
| 2011 |
function textareaHandling( &$txt ) { |
function textareaHandling( &$txt ) { |
| 2012 |
$total = count( $txt ); |
foreach ($txt as $key=>$value) $txt[$key] = str_replace("\n", '<br />', $value); |
| 2013 |
for( $i=0; $i < $total; $i++ ) { |
return implode( "\n", $txt ); |
|
if ( strstr( $txt[$i], "\n" ) ) { |
|
|
$txt[$i] = str_replace( "\n", '<br />', $txt[$i] ); |
|
|
} |
|
|
} |
|
|
$txt = implode( "\n", $txt ); |
|
|
|
|
|
return $txt; |
|
| 2014 |
} |
} |
| 2015 |
} |
} |
| 2016 |
|
|