$current_name) { $available_id .= '\''.$current_id.'\', '; $available_names .= '\''.addslashes($current_name).'\', '; } // Remove the last comma $regex = '/(.+), $/'; $available_id = preg_replace($regex, '$1', $available_id); $available_names = preg_replace($regex, '$1', $available_names); // Locales array $array = array( 'LOCALES_AVAILABLE_ID' => $available_id, 'LOCALES_AVAILABLE_NAMES' => $available_names ); // Apply it! foreach($array as $array_key => $array_value) $string = preg_replace('/(var '.$array_key.'(( )?=( )?)new Array\()(\);)/', '$1'.$array_value.'$5', $string); return $string; } // The function to set the good configuration to a JS file function setConfiguration($string, $locale, $version, $max_upload) { // Special BOSH URL if BOSH proxy enabled if(BOSHProxy()) $bosh_special = staticLocation().'php/bosh.php'; else $bosh_special = HOST_BOSH; // Configuration array $array = array( // xml:lang 'XML_LANG' => $locale, // Jappix parameters 'JAPPIX_STATIC' => staticLocation(), 'JAPPIX_VERSION' => $version, 'JAPPIX_MAX_FILE_SIZE' => $max_upload, 'JAPPIX_MAX_UPLOAD' => formatBytes($max_upload), // Main configuration 'SERVICE_NAME' => SERVICE_NAME, 'SERVICE_DESC' => SERVICE_DESC, 'JAPPIX_RESOURCE' => JAPPIX_RESOURCE, 'LOCK_HOST' => LOCK_HOST, 'ANONYMOUS' => ANONYMOUS, 'REGISTRATION' => REGISTRATION, 'BOSH_PROXY' => BOSH_PROXY, 'MANAGER_LINK' => MANAGER_LINK, 'GROUPCHATS_JOIN' => GROUPCHATS_JOIN, 'ENCRYPTION' => ENCRYPTION, 'HTTPS_STORAGE' => HTTPS_STORAGE, 'HTTPS_FORCE' => HTTPS_FORCE, 'COMPRESSION' => COMPRESSION, 'MULTI_FILES' => MULTI_FILES, 'DEVELOPER' => DEVELOPER, // Hosts configuration 'HOST_MAIN' => HOST_MAIN, 'HOST_MUC' => HOST_MUC, 'HOST_PUBSUB' => HOST_PUBSUB, 'HOST_VJUD' => HOST_VJUD, 'HOST_ANONYMOUS' => HOST_ANONYMOUS, 'HOST_BOSH' => $bosh_special, 'HOST_BOSH_MAIN' => HOST_BOSH_MAIN, 'HOST_BOSH_MINI' => HOST_BOSH_MINI, 'HOST_STATIC' => HOST_STATIC, 'HOST_UPLOAD' => HOST_UPLOAD ); // Apply it! foreach($array as $array_key => $array_value) $string = preg_replace('/var '.$array_key.'(( )?=( )?)null;/', 'var '.$array_key.'$1\''.addslashes($array_value).'\';', $string); return $string; } // The function to set the logos function setLogos($string, $files) { // Jappix Desktop home logo? if(in_array('home.css', $files) && file_exists(JAPPIX_BASE.'/store/logos/desktop_home.png')) { $string .= '#home .left .logo { background-image: url(../store/logos/desktop_home.png) !important; background-position: center center !important; }'; } // Jappix Desktop app logo? if(in_array('tools.css', $files) && file_exists(JAPPIX_BASE.'/store/logos/desktop_app.png')) { $string .= '#top-content .tools-logo { background-image: url(../store/logos/desktop_app.png) !important; background-position: center center !important; }'; } // Jappix Mobile logo? if(in_array('mobile.css', $files) && file_exists(JAPPIX_BASE.'/store/logos/mobile.png')) { $string .= '.header div { background-image: url(../store/logos/mobile.png) !important; background-position: center center !important; }'; } // Jappix Mini logo? if(in_array('mini.css', $files) && file_exists(JAPPIX_BASE.'/store/logos/mini.png')) { $string .= '#jappix_mini div.jm_actions a.jm_logo { background-image: url(../store/logos/mini.png) !important; background-position: center center !important; }'; } return $string; } // The function to set the background function setBackground($string) { // Get the default values $array = defaultBackground(); // Read the background configuration $xml = readXML('conf', 'background'); if($xml) { $read = new SimpleXMLElement($xml); foreach($read->children() as $child) { // Any value? if($child) $array[$child->getName()] = $child; } } $css = ''; // Generate the CSS code switch($array['type']) { // Image case 'image': $css .= "\n".' background-image: url(../store/backgrounds/'.urlencode($array['image_file']).'); background-repeat: '.$array['image_repeat'].'; background-position: '.$array['image_horizontal'].' '.$array['image_vertical'].'; background-color: '.$array['image_color'].';' ; // Add CSS code to adapt the image? if($array['image_adapt'] == 'on') $css .= ' background-attachment: fixed; background-size: cover; -moz-background-size: cover; -webkit-background-size: cover;'; $css .= "\n"; break; // Color case 'color': $css .= "\n".' background-color: '.$array['color_color'].';'."\n"; break; // Default: use the filtering regex default: $css .= '$3'; break; } // Apply the replacement! return preg_replace('/(\.body-images( )?\{)([^\{\}]+)(\})/i', '$1'.$css.'$4', $string); } ?>