/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copyright ©2006 by sTEFANs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This program 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; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* This file provides some basic service routines.
* @copyright Copyright ©2006 by sTEFANs
* @license http://opensource.org/licenses/lgpl-license.php GNU General Public License
/** Common definitions */
require_once('var.inc.php');
* Returns the <b>SwcConfigFactory</b> that should be used.
* The config factory is placed within the file applied as
* <i>config</i> argument to swc URL. If SWC is invoked
* without argument, <b>STD_CONFIG_FILE</b> is used instead.
* The <b>SwcConfigFactory</b>as provided by <b>GetSwcConfigFactory</b>
* of the used file is returned.
* @return <b>SwcConfigFactory</b> Config factory.
* @see GetSwcConfigFactory
require_once($config_file);
// echo "Requires $config_file<br/>";
// echo 'Requires '.STD_CONFIG_FILE.'<br/>';
* Returns the active <b>SwcConfig</b>.
* The active config is either retrieved by
* the current applied <b>SwcConfigFactory</b>.
* If more than one <b>SwcConfig</b> is found,
* the selected config is determined by project name
* given in <i>$_SESSION[IDX_SEL_PROJECT]</i>.
* @return <b>SwcConfig</b> Configuration of the active project
* or NULL if no config was found.
$configs =
$fab->GetSwcConfigs();
if (count($configs) ==
1){
while ($idx <
count($configs) &&
if ($idx <
count($configs)){
* Returns an array of all available <b>SwcConfig</b>s.
* @return array of <b>SwcConfig</b> All available configs
* of the current <b>SwcConfigFactory</b>
* or an empty array if no further configs are given.
// get config for selected project from config factory
$configs =
$fab->GetSwcConfigs();
if ($configs !=
NULL &&
is_array($configs)){
foreach($configs as $config){
$config_array[] =
$config;
* Determines whether the webspace for the selected config
* is already checked aout and available.
* If no config is applied (<b>GetSelectedConfig</b> returns NULL)
* also false is returned.
* @return boolean True if the webspace is availble, false otherwise.
$ws_root =
$config->GetWebspaceRootDir();
$ws_root =
trim($ws_root);
if ($ws_root !=
NULL &&
substr($ws_root, strlen($ws_root)-
1, 1) !=
'/'){
* HTML friendly debug output of an array.
* @param array $array Array to print
* @param string $name Name of the array, also printed.
echo
"<b>$name:</b><br/>";
} else if ($array ==
NULL)
echo
"Array $name is NULL.<br/>\n";
else if (count($array) ==
0)
echo
"Array $name is empty.<br/>\n";
* Creates a string from given parameter that can
* savely be used for paths, repository names, etc.
* The transformed text contains only small letters
* from <i>a</i> to <i>z</i> and digits from
* <i>0</i> to <i>9</i>, other characters
* are changed to underscores.
* @param string $text String to be converted.
* @return string Transformed text
$transformed_text =
preg_replace('/[^a-z0-9]/', ' ', $tmp_text);
$transformed_text =
trim($transformed_text);
$transformed_text =
str_replace(' ', $rep, $transformed_text);
return $transformed_text;