public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $table = SLS_String::substrAfterFirstDelimiter(SLS_String::trimSlashesFromString($this->_http->getParam("__table")),"_"); $db = SLS_String::substrBeforeFirstDelimiter(SLS_String::trimSlashesFromString($this->_http->getParam("__table")),"_"); $columns = $this->_http->getParams(); $class = ucfirst($db)."_".SLS_String::tableToClass($table); $desc = SLS_String::trimSlashesFromString($this->_http->getParam("description")); $this->_generic->useModel($table,$db,"user"); $object = new $class(); if (!empty($desc)) $object->setTableComment($desc,$table,$db); // Descriptions foreach($columns as $key => $value) { if (SLS_String::startsWith($key,"col_")) { $column = SLS_String::substrAfterFirstDelimiter($key,"_"); $object->setColumnComment($column,SLS_String::trimSlashesFromString($value),$table); } } $controllers = $this->_generic->getTranslatedController("SLS_Bo","EditModel"); $this->_generic->redirect($controllers["controller"]."/".$controllers["scontroller"]."/name/".$db."_".$table); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $controller = SLS_String::trimSlashesFromString($this->_http->getParam('Controller')); if (is_file($this->_generic->getPathConfig("componentsControllers").$controller.".controller.php")) { unlink($this->_generic->getPathConfig("componentsControllers").$controller.".controller.php"); } $this->_generic->dispatch('SLS_Bo', 'Controllers'); $this->saveXML($xml); }
public function action() { // Objects $user = $this->hasAuthorative(); $name = SLS_String::trimSlashesFromString($this->_http->getParam("name")); $pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/rights.xml"); $xmlRights = new SLS_XMLToolbox($pathsHandle); $result = $xmlRights->getTags("//sls_configs/entry[@login='******']"); if (!empty($result)) { $xmlRights->deleteTags('//sls_configs/entry[@login="******"]'); $xmlRights->saveXML($this->_generic->getPathConfig("configSls")."/rights.xml",$xmlRights->getXML()); } $this->_generic->redirect("Manage/Rights"); }
/** * Action Home * */ public function action() { $this->secureURL(); $this->_generic->registerLink('authentication', 'SLS_Init', 'Authentication'); $reload = $this->_http->getParam('authentication_reload'); $login = SLS_String::trimSlashesFromString($this->_http->getParam('auth_login')); $pass1 = SLS_String::trimSlashesFromString($this->_http->getParam('auth_pass1')); $pass2 = SLS_String::trimSlashesFromString($this->_http->getParam('auth_pass2')); $xml = $this->getXML(); $errors = array(); if ($reload == 'true') { if (strlen($login) < 6) array_push($errors, "The administrator username should have 6 caracters at least"); if (strlen($pass1) < 6) array_push($errors, "The password should have 6 caracters at least"); if ($pass1 != $pass2) array_push($errors, "Both password must be the same"); if (empty($errors)) { if (!is_file($this->_generic->getPathConfig('configSls')."sls.xml") && !touch($this->_generic->getPathConfig('configSls')."sls.xml")) $this->_generic->dispatch('SLS_Init', 'DirRights'); else { $coreXml = $this->_generic->getCoreXml('sls'); $user = new SLS_XMLToolbox(false); $user->startTag("user", array("login"=>sha1($login),"pass"=>sha1($pass1),"level"=>"0")); $user->endTag("user"); $coreXml->appendXMLNode("//sls_configs/auth/users", $user->getXML('noHeader')); file_put_contents($this->_generic->getPathConfig("configSls")."sls.xml", $coreXml->getXML()); $this->setInstallationStep(array(0=>"SLS_Init",1=>"Initialization"), array(0=>"GlobalSettings",1=>"Settings")); return $this->_generic->dispatch("SLS_Init", "GlobalSettings"); } } else { $xml->startTag("errors"); foreach ($errors as $error) $xml->addFullTag("error", $error, true); $xml->endTag("errors"); } } $this->saveXML($xml); }
public function action() { // Params $name = SLS_String::trimSlashesFromString($this->_http->getParam("name")); // Objects $user = $this->hasAuthorative(); $xmlRights = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/rights.xml")); $result = $xmlRights->getTags("//sls_configs/entry[@login='******']"); if (!empty($result)) { $xmlRights->setTagAttributes('//sls_configs/entry[@login="******"]', array("enabled" => ($xmlRights->getTag('//sls_configs/entry[@login="******"]/@enabled')=='false') ? 'true' : 'false')); $xmlRights->saveXML($this->_generic->getPathConfig("configSls")."/rights.xml"); } $this->_generic->forward("SLS_Bo","ManageRights"); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $langs = $this->_generic->getObjectLang()->getSiteLangs(); $listing = true; $errors = array(); $controller = SLS_String::trimSlashesFromString($this->_http->getParam('Controller')); $scontroller = SLS_String::trimSlashesFromString($this->_http->getParam('Action')); $controllersXML = $this->_generic->getControllersXML(); if (($controller != 'Home' && $controller != 'Default') || (($controller == 'Home' && $scontroller != 'Index') || ($controller == 'Default' && ($scontroller != 'UrlError' && $scontroller != 'BadRequestError' && $scontroller != 'TemporaryRedirectError' && $scontroller != 'MaintenanceError' && $scontroller != 'AuthorizationError' && $scontroller != 'ForbiddenError' && $scontroller != 'InternalServerError')))) { $countScontroller = $controllersXML->getTags("//controllers/controller[@side='user' and @name='".$controller."']/scontrollers/scontroller[@name = '".$scontroller."']"); if (count($countScontroller) == 1) { // Delete Action Files if (is_file($this->_generic->getPathConfig("viewsHeaders").$controller."/".$scontroller.".xsl")) unlink($this->_generic->getPathConfig("viewsHeaders").$controller."/".$scontroller.".xsl"); if (is_file($this->_generic->getPathConfig("viewsBody").$controller."/".$scontroller.".xsl")) unlink($this->_generic->getPathConfig("viewsBody").$controller."/".$scontroller.".xsl"); if (is_file($this->_generic->getPathConfig("actionsControllers").$controller."/".$scontroller.".controller.php")) unlink($this->_generic->getPathConfig("actionsControllers").$controller."/".$scontroller.".controller.php"); foreach ($langs as $lang) { if (is_file($this->_generic->getPathConfig("actionLangs").$controller."/".$scontroller.".".$lang.".lang.php")) unlink($this->_generic->getPathConfig("actionLangs").$controller."/".$scontroller.".".$lang.".lang.php"); } // Delete XML Lines $actionID = array_shift($controllersXML->getTags("//controllers/controller[@side='user' and @name='".$controller."']/scontrollers/scontroller[@name='".$scontroller."']/@id")); $controllersXML->deleteTags("//controllers/controller[@side='user' and @name='".$controller."']/scontrollers/scontroller[@name = '".$scontroller."']"); file_put_contents($this->_generic->getPathConfig('configSecure')."controllers.xml", $controllersXML->getXML()); $metasXML = $this->_generic->getCoreXML('metas'); $metasXML->deleteTags("//sls_configs/action[@id='".$actionID."']"); file_put_contents($this->_generic->getPathConfig('configSls')."metas.xml", $metasXML->getXML()); } } $this->_generic->forward('SLS_Bo', 'Controllers'); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $errors = array(); $tpls = $this->getAppTpls(); $siteXML = $this->_generic->getSiteXML(); $ga = $siteXML->getTag("//configs/google/setting[@name='ua']"); if ($this->_http->getParam("reload") == "true") { $tpl = SLS_String::trimSlashesFromString(SLS_String::stringToUrl($this->_http->getParam("tpl_name"),"_")); $doctype = $this->_http->getParam("doctype"); if (empty($tpl)) array_push($errors,"You must choose a name for your template"); else if (in_array($tpl,$tpls)) array_push($errors,"This template name already exists, please choose another one"); if (empty($errors)) { $this->createXslTemplate($tpl,$doctype,$ga); $this->_generic->goDirectTo("SLS_Bo","Templates"); } else { $xml->startTag("errors"); foreach($errors as $error) $xml->addFullTag("error",$error,true); $xml->endTag("errors"); $xml->addFullTag("doctype",(empty($doctype)) ? $this->_generic->getSiteConfig("defaultDoctype") : $doctype,true); } } else { $xml->addFullTag("doctype",$this->_generic->getSiteConfig("defaultDoctype"),true); } $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $tpls = $this->getAppTpls(); $tpl = SLS_String::trimSlashesFromString($this->_http->getParam("name"),"_"); if (in_array($tpl,$tpls)) { try { unlink($this->_generic->getPathConfig("viewsTemplates").$tpl.".xsl"); } catch (Exception $e) { SLS_Tracing::addTrace($e); } } $this->_generic->goDirectTo("SLS_Bo","Templates"); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $errors = array(); $generics = $this->getAppXsl(); if ($this->_http->getParam("reload") == "true") { $generic = ucfirst(SLS_String::trimSlashesFromString(SLS_String::stringToUrl($this->_http->getParam("generic_name"),"_"))); if (empty($generic)) array_push($errors,"You must choose a name for your generic"); else if (in_array(strtolower($generic),$generics)) array_push($errors,"This generic name already exists, please choose another one"); if (empty($errors)) { $str = '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl" xmlns="http://www.w3.org/1999/xhtml">'."\n". t(1).'<xsl:template name="'.$generic.'">'."\n". t(2).''."\n". t(1).'</xsl:template>'."\n". '</xsl:stylesheet>'; file_put_contents($this->_generic->getPathConfig("viewsGenerics").$generic.".xsl",$str); $this->_generic->goDirectTo("SLS_Bo","Templates"); } else { $xml->startTag("errors"); foreach($errors as $error) $xml->addFullTag("error",$error,true); $xml->endTag("errors"); } } $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $langs = $this->_generic->getObjectLang()->getSiteLangs(); $listing = true; $errors = array(); $controllersXML = $this->_generic->getControllersXML(); $controller = SLS_String::trimSlashesFromString($this->_http->getParam('Controller')); if ($controller != 'Home' && $controller != 'Default') { // We want to delete the controller $controllers = $controllersXML->getTags("//controllers/controller[@side='user' and @name='".$controller."']"); if (count($controllers) == 1) { $controllerId = array_shift($controllersXML->getTags("//controllers/controller[@side='user' and @name='".$controller."']/@id")); // Delete all files // Views Header (is_dir($this->_generic->getPathConfig("viewsHeaders").$controller)) ? $this->_generic->rm_recursive($this->_generic->getPathConfig("viewsHeaders").$controller) : SLS_Tracing::addTrace(new Exception("Directory ".$this->_generic->getPathConfig("viewsHeaders").$controller." cannot be removed")); // Views Body (is_dir($this->_generic->getPathConfig("viewsBody").$controller)) ? $this->_generic->rm_recursive($this->_generic->getPathConfig("viewsBody").$controller) : SLS_Tracing::addTrace(new Exception("Directory ".$this->_generic->getPathConfig("viewsBody").$controller." cannot be removed")); // Langs (is_dir($this->_generic->getPathConfig("actionLangs").$controller)) ? $this->_generic->rm_recursive($this->_generic->getPathConfig("actionLangs").$controller) : SLS_Tracing::addTrace(new Exception("Directory ".$this->_generic->getPathConfig("actionLangs").$controller." cannot be removed")); // Delete controller Directory (is_dir($this->_generic->getPathConfig("actionsControllers").$controller)) ? $this->_generic->rm_recursive($this->_generic->getPathConfig("actionsControllers").$controller) : SLS_Tracing::addTrace(new Exception("Directory ".$this->_generic->getPathConfig("actionsControllers").$controller." cannot be removed")); // Delete XML Informations $controllersXML->deleteTags("//controllers/controller[@side='user' and @name='".$controller."']"); file_put_contents($this->_generic->getPathConfig('configSecure')."controllers.xml", $controllersXML->getXML()); $metasXML = $this->_generic->getCoreXML('metas'); $metasXML->deleteTags("//sls_configs/action[@id='".$controllerId."']"); file_put_contents($this->_generic->getPathConfig('configSls')."metas.xml", $metasXML->getXML()); } } $this->_generic->forward('SLS_Bo', 'Controllers'); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $mailXML = $this->_generic->getMailXML(); $templates = $mailXML->getTags("//mails/templates/item/@id"); if ($this->_http->getParam("reload") == "true") { foreach($templates as $template) { $header = SLS_String::trimSlashesFromString($this->_http->getParam("template_".$template."_header")); $footer = SLS_String::trimSlashesFromString($this->_http->getParam("template_".$template."_footer")); $mailXML->setTag("//mails/templates/item[@id='".$template."']/header",$header); $mailXML->setTag("//mails/templates/item[@id='".$template."']/footer",$footer); } $mailXML->saveXML($this->_generic->getPathConfig("configSecure")."mail.xml"); } $xml->startTag("templates"); for($i=0 ; $i<$count=count($templates) ; $i++) { $id = $templates[$i]; $xml->startTag("template"); $xml->addFullTag("id",$id,true); $xml->addFullTag("header",($mailXML->getTag("//mails/templates/item[@id='".$id."']/header")),true); $xml->addFullTag("footer",($mailXML->getTag("//mails/templates/item[@id='".$id."']/footer")),true); $xml->addFullTag("url_preview",$this->_generic->getFullPath("SLS_Bo","MailTemplatesPreview",array(array("key"=>"TplId","value"=>$id))),true); $xml->addFullTag("url_delete",$this->_generic->getFullPath("SLS_Bo","MailTemplatesDelete",array(array("key"=>"TplId","value"=>$id))),true); $xml->endTag("template"); } $xml->endTag("templates"); $xml->addFullTag("url_template_add",$this->_generic->getFullPath("SLS_Bo","MailTemplatesAdd"),true); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $mailXML = $this->_generic->getMailXML(); if ($this->_http->getParam("reload") == "true") { $id = strtolower($this->_http->getParam("tpl_id")); $header = SLS_String::trimSlashesFromString($this->_http->getParam("tpl_header")); $footer = SLS_String::trimSlashesFromString($this->_http->getParam("tpl_footer")); $result = $mailXML->getTag("//mails/templates/item[@id='".$id."']/header"); if (empty($result)) { $str_xml = '<item id="'.$id.'" isSecure="false" js="false"> <header isSecure="false" js="false"><![CDATA['.$header.']]></header> <footer isSecure="false" js="false"><![CDATA['.$footer.']]></footer> </item>'; $mailXML->appendXMLNode("//templates",$str_xml); $mailXML->saveXML($this->_generic->getPathConfig("configSecure")."mail.xml"); $this->_generic->forward("SLS_Bo","MailTemplates"); } else { $xml->addFullTag("error","This name is already use by another template",true); $xml->startTag("template"); $xml->addFullTag("id",$id,true); $xml->addFullTag("header",$header,true); $xml->addFullTag("footer",$footer,true); $xml->endTag("template"); } } $this->saveXML($xml); }
/** * Action Home * */ public function action() { $this->secureURL(); $this->_generic->registerLink('DataBase', 'SLS_Init', 'DataBase'); $step = 0; $xml = $this->getXML(); $errors = array(); $mysqlCharsets = array("armscii8","ascii","big5","binary","cp1250","cp1251","cp1256","cp1257","cp850","cp852","cp866","cp932","dec8","eucjpms","euckr","gb2312","gbk","geostd8","greek","hebrew","hp8","keybcs2","koi8u","koi8r","latin1","latin2","latin5","latin7","macce","macroman","sjis","swe7","tis620","ucs2","ujis","utf8"); if ($this->_http->getParam("database_reload") == "1") { $useSql = $this->_http->getParam("database_useSql"); if (empty($useSql)) array_push($errors, "Will you need MySQL connection?"); else { if ($this->_http->getParam("database_useSql") == "false") { $this->setInstallationStep(array(0=>"SLS_Init",1=>"Initialization"), array(0=>"MailSettings",1=>"MailSettings")); return $this->_generic->dispatch("SLS_Init", "MailSettings"); } else { $step = 1; $nbDbs = $this->_http->getParam("nb_databases"); if (empty($nbDbs) || !is_numeric($nbDbs) || $nbDbs <= 0) $nbDbs = 1; $xml->startTag("nb_databases"); for($i=0 ; $i<$nbDbs ; $i++) $xml->addFullTag("nb_database","",true); $xml->endTag("nb_databases"); } } } elseif ($this->_http->getParam("database_reload") == "2") { $nb_databases = SLS_String::trimSlashesFromString($this->_http->getParam("nb_databases")); if (empty($nb_databases) || !is_numeric($nb_databases) || $nb_databases <= 0) $nb_databases = 1; $xml->startTag("nb_databases"); for($i=0 ; $i<$nb_databases ; $i++) $xml->addFullTag("nb_database","",true); $xml->endTag("nb_databases"); $nicks_used = array(); for($i=1 ; $i<=$nb_databases ; $i++) { $nick_{$i} = strtolower(SLS_String::tableToClass(SLS_String::trimSlashesFromString($this->_http->getParam("database_alias_".$i)))); $charset_{$i} = SLS_String::trimSlashesFromString($this->_http->getParam("database_charset_".$i)); $host_{$i} = SLS_String::trimSlashesFromString($this->_http->getParam("database_host_".$i)); $name_{$i} = SLS_String::trimSlashesFromString($this->_http->getParam("database_name_".$i)); $user_{$i} = SLS_String::trimSlashesFromString($this->_http->getParam("database_user_".$i)); $pass_{$i} = SLS_String::trimSlashesFromString($this->_http->getParam("database_pass_".$i)); $no_p_{$i} = SLS_String::trimSlashesFromString($this->_http->getParam("database_no_pass_".$i)); if (empty($charset_{$i}) || !in_array($charset_{$i},$mysqlCharsets)) array_push($errors, "You have to fill the charset for the database n°".$i); if (empty($nick_{$i})) array_push($errors, "You have to fill the database alias for the database n°".$i); else if (in_array($nick_{$i},$nicks_used)) array_push($errors, "The database alias must be unique"); else array_push($nicks_used,$nick_{$i}); if (empty($host_{$i})) array_push($errors, "You have to fill the database host for the database n°".$i); if (empty($name_{$i})) array_push($errors, "You have to fill the database name for the database n°".$i); if (empty($user_{$i})) array_push($errors, "You have to fill the database username for the database n°".$i); if (empty($no_p_{$i}) && empty($pass_{$i})) array_push($errors, "You have to fill the database password or to check 'No password' for the database n°".$i); } // Ping if ($this->_http->getParam("ping") == "true") { $sql = SLS_Sql::getInstance(); $errorsP = array(); for($i=1 ; $i<=$nb_databases ; $i++) { $verdict = $sql->pingConnection($host_{$i},$name_{$i},$user_{$i},(empty($no_p_{$i}) ? $pass_{$i} : "")); if ($verdict === true) array_push($errorsP,'<li style="color:green;"><u>Database n°'.$i.':</u><br />Connection successfull</li>'); if ($verdict !== true) array_push($errorsP,'<li style="color:red;"><u>Database n°'.$i.':</u><br />Connection failed with message `'.$verdict.'`</li>'); } $xml->addFullTag("ping",(empty($errorsP)) ? "true" : "false",true); $xml->startTag("ping_msgs"); foreach($errorsP as $errorP) $xml->addFullTag("ping_msg",$errorP,true); $xml->endTag("ping_msgs"); } // If it have errors //if (!empty($errors)) //{ $xml->startTag("dbs"); for($i=1 ; $i<=$nb_databases ; $i++) { $xml->startTag("db_".$i); $xml->addFullTag("alias",$nick_{$i},true); $xml->addFullTag("charset",$charset_{$i},true); $xml->addFullTag("host",$host_{$i},true); $xml->addFullTag("name",$name_{$i},true); $xml->addFullTag("user",$user_{$i},true); $xml->addFullTag("pass",$pass_{$i},true); $xml->addFullTag("no_pass",(empty($no_p_{$i}))?"false":"true",true); $xml->endTag("db_".$i); } $xml->endTag("dbs"); //} // Good, we can save it! if (empty($errors) && $this->_http->getParam("ping") != "true") { $dbXml = $this->_generic->getDbXML(); $str_xml = ""; for($i=1 ; $i<=$nb_databases ; $i++) { $default = ($i==1) ? 'true' : 'false'; $host_{$i} = SLS_Security::getInstance()->encrypt($host_{$i},$this->_generic->getSiteConfig("privateKey")); $name_{$i} = SLS_Security::getInstance()->encrypt($name_{$i},$this->_generic->getSiteConfig("privateKey")); $user_{$i} = SLS_Security::getInstance()->encrypt($user_{$i},$this->_generic->getSiteConfig("privateKey")); $pass_{$i} = (empty($no_p_{$i})) ? SLS_Security::getInstance()->encrypt($pass_{$i},$this->_generic->getSiteConfig("privateKey")) : ""; $str_xml .= '<db alias="'.$nick_{$i}.'" isDefault="'.$default.'" isSecure="true" js="false" charset="'.$charset_{$i}.'">'. '<host><![CDATA['.$host_{$i}.']]></host>'. '<base><![CDATA['.$name_{$i}.']]></base>'. '<user><![CDATA['.$user_{$i}.']]></user>'. '<pass><![CDATA['.$pass_{$i}.']]></pass>'. '</db>'; } $dbXml->appendXMLNode("//dbs",$str_xml); $dbXml->saveXML($this->_generic->getPathConfig("configSecure")."db.xml"); $this->setInstallationStep(array(0=>"SLS_Init",1=>"Initialization"), array(0=>"MailSettings",1=>"MailSettings")); // If old sls_graph_* exists $sql = SLS_Sql::getInstance(); $graphTables = array("sls_graph", "sls_graph_query", "sls_graph_query_column", "sls_graph_query_group", "sls_graph_query_join", "sls_graph_query_limit", "sls_graph_query_order", "sls_graph_query_where"); foreach($graphTables as $graphTable) { try { if ($sql->tableExists($graphTable)) $sql->exec("DROP TABLE `".$graphTable."`"); } catch (Exception $e) { continue; } } return $this->_generic->dispatch("SLS_Init", "MailSettings"); } $step = 1; } if (!empty($errors) && $this->_http->getParam("database_reload") == "1" || ( !empty($errors) && $this->_http->getParam("ping") != "true")) { $xml->startTag("errors"); foreach($errors as $error) $xml->addFullTag("error", $error, true); $xml->endTag("errors"); } $xml->addFullTag("step", $step, true); $xml->startTag("charsets"); foreach($mysqlCharsets as $key => $value) $xml->addFullTag("charset",$value,true); $xml->endTag("charsets"); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $langs = $this->_lang->getSiteLangs(); $listing = true; $errors = array(); $controllersXML = $this->_generic->getControllersXML(); $controller = $this->_http->getParam('Controller'); $protocol = $this->_generic->getSiteConfig("protocol"); // Check if bo controller $isBo = ($this->_http->getParam('isBo')=="true") ? true : false; if ($this->_http->getParam('reload') == 'true') { $postControllerName = SLS_String::trimSlashesFromString($this->_http->getParam('controllerName')); $newControllerName = SLS_String::stringToUrl(ucwords($postControllerName), "", false); $postProtocol = SLS_String::trimSlashesFromString($this->_http->getParam('protocol')); $tpl = SLS_String::trimSlashesFromString($this->_http->getParam('template')); $postControllerLangs = array(); if (empty($newControllerName)) array_push($errors, "The generic controller name is required to add a new Controller"); if (empty($postProtocol) || ($postProtocol != 'http' && $postProtocol != 'https')) array_push($errors, "Protocol must be http or https"); else $protocol = $postProtocol; foreach ($langs as $lang) { $langController = SLS_String::stringToUrl(SLS_String::trimSlashesFromString($this->_http->getParam($lang."-controller")), "", false); if (empty($langController)) array_push($errors, "The translation in ".$lang." is required to add a new Controller"); else $postControllerLangs[$lang] = $langController; } if (empty($errors)) { $test = $controllersXML->getTags("//controllers/controller[@name='".$newControllerName."']"); if (count($test) != 0) array_push($errors, ($newControllerName == $postControllerName) ? "The controller Name '".$postControllerName."' already exist" : "The controller Name '".$postControllerName."' (".$newControllerName.") already exist"); } if (empty($errors)) { $translatedController = $controllersXML->getTags("//controllers/controller/controllerLangs/controllerLang", 'id'); foreach ($postControllerLangs as $key=>$value) { if (in_array($value, $translatedController)) array_push($errors, "The translated name '".$value."' for this controller is alredy used"); } if (empty($errors)) { $controllerID = $this->_generic->generateControllerId(); $str = "<controller name=\"".$newControllerName."\" side=\"user\" protocol=\"".$protocol."\" id=\"".$controllerID."\""; if (!$isBo && $tpl != -1) $str .= " tpl=\"".$tpl."\""; if ($isBo) $str .= " isBo=\"true\" tpl=\"bo\""; $str .= "><controllerLangs>"; foreach ($postControllerLangs as $key=>$value) $str .= "<controllerLang lang=\"".$key."\"><![CDATA[".$value."]]></controllerLang>"; $str .= "</controllerLangs><scontrollers></scontrollers></controller>"; $controllersXML->appendXMLNode("//controllers", $str); $strControllerProtected = '<?php'."\n". '/**'."\n". '* Class generic for the controller '.$newControllerName.''."\n". '* Write here all your generic functions you need in your '.$newControllerName.' Actions'."\n". '* @author SillySmart'."\n". '* @copyright SillySmart'."\n". '* @package Mvc.Controllers.'.$newControllerName.''."\n". '* @see Mvc.Controllers.SiteProtected'."\n". '* @see Sls.Controllers.Core.SLS_GenericController'."\n". '* @since 1.0'."\n". '*/'."\n". 'class '.$newControllerName.'ControllerProtected extends SiteProtected'."\n". '{'."\n". t(1).'public function init()'."\n". t(1).'{'."\n". t(2).'parent::init();'."\n". t(1).'}'."\n". '}'."\n". '?>'; // Create the Controller Directory and Protected Function file mkdir($this->_generic->getPathConfig("actionsControllers").$newControllerName); file_put_contents($this->_generic->getPathConfig("actionsControllers").$newControllerName."/__".$newControllerName.".protected.php", $strControllerProtected); // Create Lang Directory mkdir($this->_generic->getPathConfig("actionLangs").$newControllerName); // Create Lang Files foreach ($langs as $lang) { $strLang = '<?php'."\n". '/**'."\n". '* '.strtoupper($lang).' File for all the Controller '.$newControllerName."\n". '* You can create all your sentences variables here. To create it, follow the exemple :'."\n". '* '.t(1).'Access it with JS and XSL variable : $GLOBALS[$GLOBALS[\'PROJECT_NAME\']][\'JS\'][\'KEY_OF_YOUR_VARIABLE\'] = "value of your sentence in '.strtoupper($lang).'";'."\n". '* '.t(1).'Access it with XSL variable only : $GLOBALS[$GLOBALS[\'PROJECT_NAME\']][\'XSL\'][\'KEY_OF_YOUR_VARIABLE\'] = "value of your sentence in '.strtoupper($lang).'";'."\n". '*'."\n". '* '."\t".'You can customise the value \'KEY_OF_YOUR_VARIABLE\' and "value of your sentence in '.strtoupper($lang).'" '."\n". '* @author SillySmart'."\n". '* @copyright SillySmart'."\n". '* @package Langs.Actions.'.$newControllerName."\n". '* @since 1.0'."\n". '*'."\n". '*/'."\n". '?>'; file_put_contents($this->_generic->getPathConfig("actionLangs").$newControllerName."/__".$newControllerName.".".strtolower($lang).".lang.php", $strLang); } // Create Views Directory mkdir($this->_generic->getPathConfig("viewsHeaders").$newControllerName); mkdir($this->_generic->getPathConfig("viewsBody").$newControllerName); // Save the new XML file_put_contents($this->_generic->getPathConfig('configSecure')."controllers.xml", $controllersXML->getXML()); // Insert Into Meta $metasXML = $this->_generic->getCoreXML('metas'); $strMetas = "<action id=\"".$controllerID."\" />"; $metasXML->appendXMLNode("//sls_configs", $strMetas); file_put_contents($this->_generic->getPathConfig('configSls')."metas.xml", $metasXML->getXML()); # isBo if ($isBo) { # Public/Files/__Uploads/images/bo if (!file_exists($this->_generic->getPathConfig("files")."__Uploads") && !is_dir($this->_generic->getPathConfig("files")."__Uploads")) mkdir($this->_generic->getPathConfig("files")."__Uploads"); if (!file_exists($this->_generic->getPathConfig("files")."__Uploads/images") && !is_dir($this->_generic->getPathConfig("files")."__Uploads/images")) mkdir($this->_generic->getPathConfig("files")."__Uploads/images"); if (!file_exists($this->_generic->getPathConfig("files")."__Uploads/images/bo") && !is_dir($this->_generic->getPathConfig("files")."__Uploads/images/bo")) mkdir($this->_generic->getPathConfig("files")."__Uploads/images/bo"); if (file_exists($this->_generic->getPathConfig("installDeployement")."Public/Files/__Uploads/images/bo") && is_dir($this->_generic->getPathConfig("installDeployement")."Public/Files/__Uploads/images/bo")) { $files = scandir($this->_generic->getPathConfig("installDeployement")."Public/Files/__Uploads/images/bo"); foreach($files as $file) { if (!SLS_String::startsWith($file,".")) { @copy($this->_generic->getPathConfig("installDeployement")."Public/Files/__Uploads/images/bo/".$file, $this->_generic->getPathConfig("files")."__Uploads/images/bo/".$file); } } } # /Public/Files/__Uploads/images/bo # Controller langs foreach($langs as $lang) { if (file_exists($this->_generic->getPathConfig("installDeployement")."Langs/Actions/{{USER_BO}}/__{{USER_BO}}.".$lang.".lang.php")) $langContent = str_replace(array("{{USER_BO}}"),array($newControllerName),file_get_contents($this->_generic->getPathConfig("installDeployement")."Langs/Actions/{{USER_BO}}/__{{USER_BO}}.".$lang.".lang.php")); else $langContent = str_replace(array("{{USER_BO}}"),array($newControllerName),file_get_contents($this->_generic->getPathConfig("installDeployement")."Langs/Actions/{{USER_BO}}/__{{USER_BO}}.en.lang.php")); if (!empty($langContent)) file_put_contents($this->_generic->getPathConfig("actionLangs").$newControllerName."/__".$newControllerName.".".$lang.".lang.php",$langContent); } # /Controller langs # XSL Templates $boTemplates = array("bo.xsl","bo_light.xsl","bo_blank.xsl"); foreach($boTemplates as $boTemplate) { if (file_exists($this->_generic->getPathConfig("installDeployement")."Views/Templates/".$boTemplate) && !is_dir($this->_generic->getPathConfig("installDeployement")."Views/Templates/".$boTemplate)) { @copy($this->_generic->getPathConfig("installDeployement")."Views/Templates/".$boTemplate, $this->_generic->getPathConfig("viewsTemplates").$boTemplate); } } # /XSL Templates # XSL Generics $boGenerics = array("Boactionsbar.xsl","Boheaders.xsl","Bomenu.xsl"); foreach($boGenerics as $boGeneric) { if (file_exists($this->_generic->getPathConfig("installDeployement")."Views/Generics/".$boGeneric) && !is_dir($this->_generic->getPathConfig("installDeployement")."Views/Generics/".$boGeneric)) { @copy($this->_generic->getPathConfig("installDeployement")."Views/Generics/".$boGeneric, $this->_generic->getPathConfig("viewsGenerics").$boGeneric); } } # /XSL Generics # Controllers Statics $boStatics = array("BoMenu.controller.php"); foreach($boStatics as $boStatic) { if (file_exists($this->_generic->getPathConfig("installDeployement")."Controllers/Statics/".$boStatic) && !is_dir($this->_generic->getPathConfig("installDeployement")."Controllers/Statics/".$boStatic)) { @copy($this->_generic->getPathConfig("installDeployement")."Controllers/Statics/".$boStatic, $this->_generic->getPathConfig("staticsControllers").$boStatic); } } # /Controllers Statics # __{{USER_BO}}.protected.php if (file_exists($this->_generic->getPathConfig("installDeployement")."Controllers/Actions/{{USER_BO}}/__{{USER_BO}}.protected.php") && !is_dir($this->_generic->getPathConfig("installDeployement")."Controllers/Actions/{{USER_BO}}/__{{USER_BO}}.protected.php")) { @copy($this->_generic->getPathConfig("installDeployement")."Controllers/Actions/{{USER_BO}}/__{{USER_BO}}.protected.php", $this->_generic->getPathConfig("actionsControllers").$newControllerName."/__".$newControllerName.".protected.php"); @file_put_contents($this->_generic->getPathConfig("actionsControllers").$newControllerName."/__".$newControllerName.".protected.php",str_replace(array("{{USER_BO}}"),array($newControllerName),file_get_contents($this->_generic->getPathConfig("actionsControllers").$newControllerName."/__".$newControllerName.".protected.php"))); } # /__{{USER_BO}}.protected.php # Native actions $controllerPath = $this->_generic->getPathConfig("installDeployement")."Controllers/Actions/{{USER_BO}}"; $boActions = scandir($controllerPath); $boLightActions = array("BoLogin","BoRenewPwd","BoForgottenPwd"); $boBlankActions = array("BoMenu"); $tokenSecret = sha1(substr($this->_generic->getSiteConfig("privateKey"), 0, 3).substr($this->_generic->getSiteConfig("privateKey"), strlen($this->_generic->getSiteConfig("privateKey"))-3)); foreach($boActions as $boAction) { if ( SLS_String::startsWith($boAction,"Bo") && // Real boAction file_exists($controllerPath."/".$boAction) && // File exist !is_dir($controllerPath."/".$boAction) && // Not a directory !SLS_String::startsWith($boAction,"BoUser") && // Exclude custom action "BoUser(*)" !SLS_String::startsWith($boAction,"Boi18n") && // Exclude custom action "Boi18n" !SLS_String::startsWith($boAction,"BoFileUpload") && // Exclude custom action "BoFileUpload" !SLS_String::startsWith($boAction,"BoProjectSettings") // Exclude custom action "BoProjectSettings" ) { // Generate Action $action = SLS_String::substrBeforeFirstDelimiter($boAction,"."); $params = array(0 => array("key" => "reload", "value" => "true"), 1 => array("key" => "Controller", "value" => $newControllerName), 2 => array("key" => "actionName", "value" => $action), 3 => array("key" => "token", "value" => $tokenSecret), 4 => array("key" => "template", "value" => (in_array($action,$boLightActions)) ? "bo_light" : ((in_array($action,$boBlankActions)) ? "bo_blank" : "bo")), 5 => array("key" => "dynamic", "value" => "on"), 6 => array("key" => "indexes", "value" => "noindex,nofollow") ); if ($action == "BoLogin") $params[] = array("key" => "default", "value" => "on"); foreach($langs as $lang) { $tmpParam = array("key" => $lang."-action", "value" => $action."_".$lang); $tmpTitle = array("key" => $lang."-title", "value" => $action); array_push($params,$tmpParam); array_push($params,$tmpTitle); } file_get_contents($this->_generic->getFullPath("SLS_Bo", "AddAction", $params, true)); // Erase Action $source = str_replace(array("{{USER_BO}}"),array($newControllerName),file_get_contents($this->_generic->getPathConfig("installDeployement")."Controllers/Actions/{{USER_BO}}/".$action.".controller.php")); file_put_contents($this->_generic->getPathConfig("actionsControllers").$newControllerName."/".$action.".controller.php",$source); // Erase View Head if (file_exists($this->_generic->getPathConfig("installDeployement")."Views/Headers/{{USER_BO}}/".$action.".xsl")) file_put_contents($this->_generic->getPathConfig("viewsHeaders").$newControllerName."/".$action.".xsl",file_get_contents($this->_generic->getPathConfig("installDeployement")."Views/Headers/{{USER_BO}}/".$action.".xsl")); // Erase View Body if (file_exists($this->_generic->getPathConfig("installDeployement")."Views/Body/{{USER_BO}}/".$action.".xsl")) file_put_contents($this->_generic->getPathConfig("viewsBody").$newControllerName."/".$action.".xsl",file_get_contents($this->_generic->getPathConfig("installDeployement")."Views/Body/{{USER_BO}}/".$action.".xsl")); } } # /Native actions } # /isBo $controllersRedirect = $this->_generic->getTranslatedController('SLS_Bo', 'Controllers'); $this->_generic->redirect($controllersRedirect['controller']."/".$controllersRedirect['scontroller']); } } if (!empty($errors)) { $xml->startTag("errors"); foreach ($errors as $error) $xml->addFullTag("error", $error, true); $xml->endTag("errors"); $xml->startTag('form'); $xml->addFullTag("controllerName", $postControllerName); foreach ($postControllerLangs as $key=>$value) $xml->addFullTag($key."-controller", $value, true); $xml->endTag('form'); } } // Build all tpls $tpls = $this->getAppTpls(); $xml->startTag("tpls"); foreach($tpls as $template) $xml->addFullTag("tpl",$template,true); $xml->endTag("tpls"); $xml->startTag('controller'); $xml->addFullTag('isBo',($isBo) ? "true" : "false",true); $xml->startTag('translations'); foreach ($langs as $lang) { $xml->startTag('translation'); $xml->addFullTag("lang", $lang, true); $xml->endTag('translation'); } $xml->endTag('translations'); $xml->endTag('controller'); $listing = false; $xml->addFullTag('request', 'addController', true); $xml->addFullTag('protocol', $protocol, true); $xml->addFullTag('template', $tpl, true); $this->saveXML($xml); }
/** * Action Home * */ public function action() { $this->secureURL(); $this->_generic->registerLink('International', 'SLS_Init', 'International'); $errors = array(); $giveDataStep1 = false; $xml = $this->getXML(); $step = 0; $langs = array(); $handle = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."international.xml")); $xpathLangs = $handle->getTags("//sls_configs/sls_country/sls_country_langs/sls_country_lang[@iso != '']"); foreach ($xpathLangs as $lang) if (!in_array(trim($lang), $langs)) array_push($langs, trim($lang)); array_multisort($langs, SORT_STRING, SORT_ASC); $xml->startTag("langs"); foreach ($langs as $lang) $xml->addFullTag("lang", $lang, true); $xml->endTag("langs"); // If reload if ($this->_http->getParam('reload_international_step1') == "true") { // If one lang at least $listLangs = SLS_String::trimSlashesFromString($this->_http->getParam("international_langs")); if (empty($listLangs)) array_push($errors,"You must choose at least one language"); else { $xmlIsos = ""; foreach($listLangs as $listLang) { $iso = array_shift($handle->getTags("//sls_configs/sls_country/sls_country_langs/sls_country_lang[node()='".$listLang."']/@iso")); $xmlIsos .= '<name isSecure="false" js="false" active="true"><![CDATA['.$iso.']]></name>'; if (is_file($this->_generic->getPathConfig("installDeployement")."Langs/Generics/generic.".$iso.".lang.php")) copy($this->_generic->getPathConfig("installDeployement")."Langs/Generics/generic.".$iso.".lang.php", $this->_generic->getPathConfig("coreGenericLangs")."generic.".$iso.".lang.php"); } } if (empty($errors)) { $step = 1; $coreXml = $this->_generic->getSiteXML(); $coreXml->setTag('langs',$xmlIsos,false); file_put_contents($this->_generic->getPathConfig("configSecure")."site.xml", $coreXml->getXML()); $giveDataStep1 = true; } else { $step = 0; $xml->startTag("errors"); foreach ($errors as $error) $xml->addFullTag("error", $error, true); $xml->endTag("errors"); } } // Set controllers.xml else if ($this->_http->getParam('reload_international_step2') == "true") { $langs = $this->_generic->getSiteXML()->getTags("//configs/langs/name"); $listLangs = explode("-", SLS_String::trimSlashesFromString($this->_http->getParam("international_languages"))); $params = $this->_http->getParams('post'); $userValues = array(); foreach ($langs as $lang) $userValues[$lang] = array(); foreach ($params as $key=>$param) if (array_key_exists(SLS_String::substrBeforeFirstDelimiter($key, '_'), $userValues)) $userValues[SLS_String::substrBeforeFirstDelimiter($key, '_')][SLS_String::substrAfterFirstDelimiter($key, '_')] = SLS_String::trimSlashesFromString($param); // Check errors $errors = array(); $xml->startTag("InternationalMemory"); $xml->addFullTag("default", SLS_String::trimSlashesFromString($this->_http->getParam("default_lang")), true); foreach ($userValues as $key=>$values) { $mods[$key] = array(); $smods[$key]['home'] = array(); $smods[$key]['error'] = array(); foreach ($values as $name=>$value) { $xml->startTag("row"); $xml->addFullTag("name", $key."_".$name, true); $xml->addFullTag("value", SLS_String::trimSlashesFromString($value), true); $xml->endTag("row"); if (substr($name, 0, 11) == "TRANSLATION") { if (empty($value)) array_push($errors, "You must fill the translation for ".ucwords(strtolower(str_replace("_", " ", substr($name, 11))))." in ".strtoupper($key)); } } if (empty($values['home_mod'])) array_push($errors, "You must fill a value for the URL of Main Controller in ".strtoupper($key)); else if (SLS_String::stringToUrl(SLS_String::trimSlashesFromString($values['home_mod']),"")!=strtolower($values['home_mod'])) array_push($errors, "You must fill a value for the URL of Main Controller without spaces, accented characters or specials characters in ".strtoupper($key)); else array_push($mods[$key], $values['home_mod']); if (empty($values['home_desc'])) array_push($errors, "You must fill a page title for your home page in ".strtoupper($key)); if (empty($values['home_index'])) array_push($errors, "You must fill an action value for your home page in ".strtoupper($key)); else if (SLS_String::stringToUrl(SLS_String::trimSlashesFromString($values['home_index']),"")!=strtolower($values['home_index'])) array_push($errors, "You must fill an action value for your home page without spaces, accented characters or specials characters in ".strtoupper($key)); else array_push($smods[$key]['home'], $values['home_index']); if (empty($values['error_mod'])) array_push($errors, "You must fill a value for the URL of Error Controller in ".strtoupper($key)); else if (SLS_String::stringToUrl(SLS_String::trimSlashesFromString($values['error_mod']),"")!=strtolower($values['error_mod'])) array_push($errors, "You must fill a value for the URL of Error Controller without spaces, accented characters or specials characters in ".strtoupper($key)); else array_push($mods[$key], $values['error_mod']); if (empty($values['error_400_desc'])) array_push($errors, "You must fill a page title for your 400 page in ".strtoupper($key)); if (empty($values['error_401_desc'])) array_push($errors, "You must fill a page title for your 401 page in ".strtoupper($key)); if (empty($values['error_403_desc'])) array_push($errors, "You must fill a page title for your 403 page in ".strtoupper($key)); if (empty($values['error_404_desc'])) array_push($errors, "You must fill a page title for your 404 page in ".strtoupper($key)); if (empty($values['error_500_desc'])) array_push($errors, "You must fill a page title for your 500 page in ".strtoupper($key)); if (empty($values['error_307_desc'])) array_push($errors, "You must fill a page title for your 307 page in ".strtoupper($key)); if (empty($values['error_302_desc'])) array_push($errors, "You must fill a page title for your 302 page in ".strtoupper($key)); if (empty($values['error_400_url'])) array_push($errors, "You must fill a value for the URL of your 400 page in ".strtoupper($key)); else if (SLS_String::stringToUrl(SLS_String::trimSlashesFromString($values['error_400_url']),"")!=strtolower($values['error_400_url'])) array_push($errors, "You must fill an action value for the URL of you 400 without spaces, accented characters or specials characters in ".strtoupper($key)); else array_push($smods[$key]['error'], $values['error_400_url']); if (empty($values['error_401_url'])) array_push($errors, "You must fill a value for the URL of your 401 page in ".strtoupper($key)); else if (SLS_String::stringToUrl(SLS_String::trimSlashesFromString($values['error_401_url']),"")!=strtolower($values['error_401_url'])) array_push($errors, "You must fill an action value for the URL of you 401 without spaces, accented characters or specials characters in ".strtoupper($key)); else array_push($smods[$key]['error'], $values['error_401_url']); if (empty($values['error_403_url'])) array_push($errors, "You must fill a value for the URL of your 403 page in ".strtoupper($key)); else if (SLS_String::stringToUrl(SLS_String::trimSlashesFromString($values['error_403_url']),"")!=strtolower($values['error_403_url'])) array_push($errors, "You must fill an action value for the URL of you 403 without spaces, accented characters or specials characters in ".strtoupper($key)); else array_push($smods[$key]['error'], $values['error_403_url']); if (empty($values['error_404_url'])) array_push($errors, "You must fill a value for the URL of your 404 page in ".strtoupper($key)); else if (SLS_String::stringToUrl(SLS_String::trimSlashesFromString($values['error_404_url']),"")!=strtolower($values['error_404_url'])) array_push($errors, "You must fill an action value for the URL of you 404 without spaces, accented characters or specials characters in ".strtoupper($key)); else array_push($smods[$key]['error'], $values['error_404_url']); if (empty($values['error_500_url'])) array_push($errors, "You must fill a value for the URL of your 500 page in ".strtoupper($key)); else if (SLS_String::stringToUrl(SLS_String::trimSlashesFromString($values['error_500_url']),"")!=strtolower($values['error_500_url'])) array_push($errors, "You must fill an action value for the URL of you 500 without spaces, accented characters or specials characters in ".strtoupper($key)); else array_push($smods[$key]['error'], $values['error_500_url']); if (empty($values['error_307_url'])) array_push($errors, "You must fill a value for the URL of your 307 page in ".strtoupper($key)); else if (SLS_String::stringToUrl(SLS_String::trimSlashesFromString($values['error_307_url']),"")!=strtolower($values['error_307_url'])) array_push($errors, "You must fill an action value for the URL of you 307 without spaces, accented characters or specials characters in ".strtoupper($key)); else array_push($smods[$key]['error'], $values['error_307_url']); if (empty($values['error_302_url'])) array_push($errors, "You must fill a value for the URL of your 302 page in ".strtoupper($key)); else if (SLS_String::stringToUrl(SLS_String::trimSlashesFromString($values['error_302_url']),"")!=strtolower($values['error_302_url'])) array_push($errors, "You must fill an action value for the URL of you 302 without spaces, accented characters or specials characters in ".strtoupper($key)); else array_push($smods[$key]['error'], $values['error_302_url']); $unikUrl = array(); foreach ($smods[$key]['error'] as $smod) if (!in_array($smod, $unikUrl)) array_push($unikUrl, $smod); if (count($unikUrl) != count($smods[$key]['error'])) array_push($errors, "You cannot set the same Action name for two differents actions in the same language : ".strtoupper($key)); } $xml->endTag("InternationalMemory"); if (empty($errors)) { $caIds = array(); // Set defaut lang $siteXML = $this->_generic->getSiteXML(); $siteXML->setTag("defaultLang", SLS_String::trimSlashesFromString($this->_http->getParam("default_lang"))); $siteXML->setTagAttributes("//configs/domainName/domain[@default='1']",array("lang" => SLS_String::trimSlashesFromString($this->_http->getParam("default_lang")))); file_put_contents($this->_generic->getPathConfig("configSecure")."site.xml", $siteXML->getXML()); $langs = $this->_generic->getSiteXML()->getTags("//configs/langs/name"); $xmlControllers = $this->_generic->getControllersXML(); // Generate the Home Controller ID and the Default Controller ID $homeID = $this->_generic->generateControllerId(); array_push($caIds, $homeID); $defaultID = $this->_generic->generateControllerId(); while (in_array($defaultID, $caIds)) $defaultID = $this->_generic->generateControllerId(); array_push($caIds, $defaultID); // Generate Actions IDs // Home/Index $indexID = $this->_generic->generateActionId(); array_push($caIds, $indexID); // Default/UrlError $urlErrorID = $this->_generic->generateActionId(); while (in_array($urlErrorID, $caIds)) $urlErrorID = $this->_generic->generateActionId(); array_push($caIds, $urlErrorID); // Default/BadRequestError $badRequestID = $this->_generic->generateActionId(); while (in_array($badRequestID, $caIds)) $badRequestID = $this->_generic->generateActionId(); array_push($caIds, $badRequestID); // Default/AuthorizationError $authorizationID = $this->_generic->generateActionId(); while (in_array($authorizationID, $caIds)) $authorizationID = $this->_generic->generateActionId(); array_push($caIds, $authorizationID); // Default/ForbiddenError $forbiddenID = $this->_generic->generateActionId(); while (in_array($forbiddenID, $caIds)) $forbiddenID = $this->_generic->generateActionId(); array_push($caIds, $forbiddenID); // Default/InternalServerError $serverID = $this->_generic->generateActionId(); while (in_array($serverID, $caIds)) $serverID = $this->_generic->generateActionId(); array_push($caIds, $serverID); // Default/TemporaryRedirectError $redirectID = $this->_generic->generateActionId(); while (in_array($redirectID, $caIds)) $redirectID = $this->_generic->generateActionId(); array_push($caIds, $redirectID); // Default/MaintenanceError $maintenanceID = $this->_generic->generateActionId(); while (in_array($maintenanceID, $caIds)) $maintenanceID = $this->_generic->generateActionId(); array_push($caIds, $maintenanceID); $controllerUser['home']['mod'] = "<controller name=\"Home\" side=\"user\" id=\"".$homeID."\"><controllerLangs>"; $controllerUser['home']['smod'] = "<scontrollers><scontroller name=\"Index\" needParam=\"0\" id=\"".$indexID."\" default=\"1\"><scontrollerLangs>"; $controllerUser['default']['mod'] = "<controller name=\"Default\" side=\"user\" id=\"".$defaultID."\"><controllerLangs>"; $controllerUser['default']['smod']['404'] = "<scontrollers><scontroller name=\"UrlError\" needParam=\"0\" id=\"".$urlErrorID."\"><scontrollerLangs>"; $controllerUser['default']['smod']['400'] = "<scontroller name=\"BadRequestError\" needParam=\"0\" id=\"".$badRequestID."\"><scontrollerLangs>"; $controllerUser['default']['smod']['401'] = "<scontroller name=\"AuthorizationError\" needParam=\"0\" id=\"".$authorizationID."\"><scontrollerLangs>"; $controllerUser['default']['smod']['403'] = "<scontroller name=\"ForbiddenError\" needParam=\"0\" id=\"".$forbiddenID."\"><scontrollerLangs>"; $controllerUser['default']['smod']['500'] = "<scontroller name=\"InternalServerError\" needParam=\"0\" id=\"".$serverID."\"><scontrollerLangs>"; $controllerUser['default']['smod']['307'] = "<scontroller name=\"TemporaryRedirectError\" needParam=\"0\" id=\"".$redirectID."\"><scontrollerLangs>"; $controllerUser['default']['smod']['302'] = "<scontroller name=\"MaintenanceError\" needParam=\"0\" id=\"".$maintenanceID."\"><scontrollerLangs>"; $paramsPost = $this->_http->getParams('post'); $handleLangs = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."international.xml")); $projectName = array_shift($this->_generic->getSiteXML()->getTags("projectName")); /* Create Lang files and Lang Directory mkdir($this->_generic->getPathConfig("actionLangs")."Home"); mkdir($this->_generic->getPathConfig("actionLangs")."Default"); */ $metasXML = $this->_generic->getCoreXML('metas'); // Add Empty Actions in metas foreach ($caIds as $aId) { $str = "<action id=\"".$aId."\"></action>"; $metasXML->appendXMLNode("//sls_configs", $str); } // Foreach langs foreach ($langs as $lang) { // Home controller $controllerUser['home']['mod'] .= "<controllerLang lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_home_mod"))."]]></controllerLang>"; $controllerUser['home']['smod'] .= "<scontrollerLang lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_home_index"))."]]></scontrollerLang>"; $strTitle = "<title lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_home_desc"))."]]></title>"; $strTitle .= "<description lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_home_description"))."]]></description>"; $strTitle .= "<keywords lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_home_keywords"))."]]></keywords>"; $metasXML->appendXMLNode("//sls_configs/action[@id='".$indexID."']", $strTitle); // Default controller $controllerUser['default']['mod'] .= "<controllerLang lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_mod"))."]]></controllerLang>"; $controllerUser['default']['smod']['404'] .= "<scontrollerLang lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_404_url"))."]]></scontrollerLang>"; $strTitle = "<title lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_404_desc"))."]]></title>"; $strTitle .= "<description lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_404_description"))."]]></description>"; $strTitle .= "<keywords lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_404_keywords"))."]]></keywords>"; $metasXML->appendXMLNode("//sls_configs/action[@id='".$urlErrorID."']", $strTitle); $controllerUser['default']['smod']['400'] .= "<scontrollerLang lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_400_url"))."]]></scontrollerLang>"; $strTitle = "<title lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_400_desc"))."]]></title>"; $strTitle .= "<description lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_400_description"))."]]></description>"; $strTitle .= "<keywords lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_400_keywords"))."]]></keywords>"; $metasXML->appendXMLNode("//sls_configs/action[@id='".$badRequestID."']", $strTitle); $controllerUser['default']['smod']['401'] .= "<scontrollerLang lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_401_url"))."]]></scontrollerLang>"; $strTitle = "<title lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_401_desc"))."]]></title>"; $strTitle .= "<description lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_401_description"))."]]></description>"; $strTitle .= "<keywords lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_401_keywords"))."]]></keywords>"; $metasXML->appendXMLNode("//sls_configs/action[@id='".$authorizationID."']", $strTitle); $controllerUser['default']['smod']['403'] .= "<scontrollerLang lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_403_url"))."]]></scontrollerLang>"; $strTitle = "<title lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_403_desc"))."]]></title>"; $strTitle .= "<description lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_403_description"))."]]></description>"; $strTitle .= "<keywords lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_403_keywords"))."]]></keywords>"; $metasXML->appendXMLNode("//sls_configs/action[@id='".$forbiddenID."']", $strTitle); $controllerUser['default']['smod']['500'] .= "<scontrollerLang lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_500_url"))."]]></scontrollerLang>"; $strTitle = "<title lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_500_desc"))."]]></title>"; $strTitle .= "<description lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_500_description"))."]]></description>"; $strTitle .= "<keywords lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_500_keywords"))."]]></keywords>"; $metasXML->appendXMLNode("//sls_configs/action[@id='".$serverID."']", $strTitle); $controllerUser['default']['smod']['307'] .= "<scontrollerLang lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_307_url"))."]]></scontrollerLang>"; $strTitle = "<title lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_307_desc"))."]]></title>"; $strTitle .= "<description lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_307_description"))."]]></description>"; $strTitle .= "<keywords lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_307_keywords"))."]]></keywords>"; $metasXML->appendXMLNode("//sls_configs/action[@id='".$redirectID."']", $strTitle); $controllerUser['default']['smod']['302'] .= "<scontrollerLang lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_302_url"))."]]></scontrollerLang>"; $strTitle = "<title lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_302_desc"))."]]></title>"; $strTitle .= "<description lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_302_description"))."]]></description>"; $strTitle .= "<keywords lang=\"".$lang."\"><![CDATA[".SLS_String::trimSlashesFromString($this->_http->getParam($lang."_error_302_keywords"))."]]></keywords>"; $metasXML->appendXMLNode("//sls_configs/action[@id='".$maintenanceID."']", $strTitle); // Generic langs $genericFile = "<?php\n/**\n * Generic Sls Vars\n */\n"; $length = strlen($lang."_TRANSLATION"); foreach ($paramsPost as $key=>$value) { $value = SLS_String::trimSlashesFromString($value); if (substr($key, 0, $length) == $lang."_TRANSLATION") { $genericFile .= '$GLOBALS[$GLOBALS[\'PROJECT_NAME\']][\'JS\'][\'SLS_'.substr($key, $length+1).'\'] = "'.$value.'";'; $genericFile .= "\n"; } } $genericFile .= "?>"; file_put_contents($this->_generic->getPathConfig("coreGenericLangs")."generic.".$lang.".lang.php", $genericFile); // Generic lang site $language = array_shift($handleLangs->getTags("//sls_configs/sls_country/sls_country_langs/sls_country_lang[@iso = '".$lang."']")); $contentSiteLang = "<?php\n/**\n * ".$projectName." Translations\n * Language : ".ucwords($language)." (".strtoupper($lang).")\n */\n\n?>"; file_put_contents($this->_generic->getPathConfig('genericLangs')."site.".$lang.".lang.php", $contentSiteLang); } // Controllers $controllerUser['home']['mod'] .= "</controllerLangs>"; $controllerUser['home']['smod'] .= "</scontrollerLangs></scontroller></scontrollers></controller>"; $controllerUser['default']['mod'] .= "</controllerLangs>"; $controllerUser['default']['smod']['404'] .= "</scontrollerLangs></scontroller>"; $controllerUser['default']['smod']['400'] .= "</scontrollerLangs></scontroller>"; $controllerUser['default']['smod']['401'] .= "</scontrollerLangs></scontroller>"; $controllerUser['default']['smod']['403'] .= "</scontrollerLangs></scontroller>"; $controllerUser['default']['smod']['307'] .= "</scontrollerLangs></scontroller>"; $controllerUser['default']['smod']['302'] .= "</scontrollerLangs></scontroller>"; $controllerUser['default']['smod']['500'] .= "</scontrollerLangs></scontroller></scontrollers></controller>"; // Formation du Flux Final a append $flux = $controllerUser['home']['mod'].$controllerUser['home']['smod'].$controllerUser['default']['mod'].$controllerUser['default']['smod']['404'].$controllerUser['default']['smod']['400'].$controllerUser['default']['smod']['401'].$controllerUser['default']['smod']['403'].$controllerUser['default']['smod']['307'].$controllerUser['default']['smod']['302'].$controllerUser['default']['smod']['500']; $xmlControllers->appendXMLNode('//controllers', $flux); file_put_contents($this->_generic->getPathConfig("configSecure")."controllers.xml", $xmlControllers->getXML()); // Add meta Tags $metasXML->appendXMLNode("//sls_configs/action[@id='".$indexID."']", "<robots><![CDATA[index, follow]]></robots>"); $metasXML->appendXMLNode("//sls_configs/action[@id='".$urlErrorID."']", "<robots><![CDATA[noindex, follow]]></robots>"); $metasXML->appendXMLNode("//sls_configs/action[@id='".$authorizationID."']", "<robots><![CDATA[noindex, nofollow]]></robots>"); $metasXML->appendXMLNode("//sls_configs/action[@id='".$serverID."']", "<robots><![CDATA[noindex, nofollow]]></robots>"); $metasXML->appendXMLNode("//sls_configs/action[@id='".$forbiddenID."']", "<robots><![CDATA[noindex, nofollow]]></robots>"); $metasXML->appendXMLNode("//sls_configs/action[@id='".$badRequestID."']", "<robots><![CDATA[noindex, nofollow]]></robots>"); $metasXML->appendXMLNode("//sls_configs/action[@id='".$redirectID."']", "<robots><![CDATA[noindex, nofollow]]></robots>"); $metasXML->appendXMLNode("//sls_configs/action[@id='".$maintenanceID."']", "<robots><![CDATA[noindex, nofollow]]></robots>"); file_put_contents($this->_generic->getPathConfig("configSls")."metas.xml", $metasXML->getXML()); // Déplacement des Fichiers de déploiement // Controllers if (!is_dir($this->_generic->getPathConfig("actionsControllers")."Home")) mkdir($this->_generic->getPathConfig("actionsControllers")."Home"); if (!is_dir($this->_generic->getPathConfig("actionsControllers")."Default")) mkdir($this->_generic->getPathConfig("actionsControllers")."Default"); // Langs if (!is_dir($this->_generic->getPathConfig("actionLangs")."Home")) mkdir($this->_generic->getPathConfig("actionLangs")."Home"); if (!is_dir($this->_generic->getPathConfig("actionLangs")."Default")) mkdir($this->_generic->getPathConfig("actionLangs")."Default"); // Generic Site Protected functions copy($this->_generic->getPathConfig("installDeployement")."Controllers/Actions/__site.protected.php", $this->_generic->getPathConfig("actionsControllers")."__site.protected.php"); $homeFiles = scandir($this->_generic->getPathConfig("installDeployement")."Controllers/Actions/Home"); $defaultFiles = scandir($this->_generic->getPathConfig("installDeployement")."Controllers/Actions/Default"); // Copy Home Files foreach ($homeFiles as $file) { if (substr($file, (strlen($file)-3)) == "php") { copy($this->_generic->getPathConfig("installDeployement")."Controllers/Actions/Home/".$file, $this->_generic->getPathConfig("actionsControllers")."Home/".$file); if (SLS_String::startsWith($file, "__")) { foreach ($langs as $lang) { $strLang = '<?php'."\n". '/**'."\n". '* '.strtoupper($lang).' File for all the Controller Home'."\n". '* You can create all your sentences variables here. To create it, follow the exemple :'."\n". '* '.t(1).'Access it with JS and XSL variable : $GLOBALS[$GLOBALS[\'PROJECT_NAME\']][\'JS\'][\'KEY_OF_YOUR_VARIABLE\'] = "value of your sentence in '.strtoupper($lang).'";'."\n". '* '.t(1).'Access it with XSL variable only : $GLOBALS[$GLOBALS[\'PROJECT_NAME\']][\'XSL\'][\'KEY_OF_YOUR_VARIABLE\'] = "value of your sentence in '.strtoupper($lang).'";'."\n". '*'."\n". '* '.t(1).'You can customise the value \'KEY_OF_YOUR_VARIABLE\' and "value of your sentence in '.strtoupper($lang).'" '."\n". '* @author SillySmart'."\n". '* @copyright SillySmart'."\n". '* @package Langs.Actions.'.$controller."\n". '* @since 1.0'."\n". '*'."\n". '*/'."\n". '?>'; file_put_contents($this->_generic->getPathConfig("actionLangs")."Home/__Home.".strtolower($lang).".lang.php", $strLang); } } else { $actionName = trim(SLS_String::substrBeforeFirstDelimiter($file, ".controller")); foreach ($langs as $lang) { $strLang = '<?php'."\n". '/**'."\n". '* '.strtoupper($lang).' File for the action '.$actionName.' into Home Controller'."\n". '* You can create all your sentences variables here. To create it, follow the exemple :'."\n". '* '.t(1).'Access it with JS and XSL variable : $GLOBALS[$GLOBALS[\'PROJECT_NAME\']][\'JS\'][\'KEY_OF_YOUR_VARIABLE\'] = "value of your sentence in '.strtoupper($lang).'";'."\n". '* '.t(1).'Access it with XSL variable only : $GLOBALS[$GLOBALS[\'PROJECT_NAME\']][\'XSL\'][\'KEY_OF_YOUR_VARIABLE\'] = "value of your sentence in '.strtoupper($lang).'";'."\n". '*'."\n". '* '.t(1).'You can customise the value \'KEY_OF_YOUR_VARIABLE\' and "value of your sentence in '.strtoupper($lang).'" '."\n". '* @author SillySmart'."\n". '* @copyright SillySmart'."\n". '* @package Langs.Actions.Home'."\n". '* @since 1.0'."\n". '*'."\n". '*/'."\n". '?>'; file_put_contents($this->_generic->getPathConfig("actionLangs")."Home/".$actionName.".".strtolower($lang).".lang.php", $strLang); } } } } // Copy Default Files foreach ($defaultFiles as $file) { if (substr($file, (strlen($file)-3)) == "php") { copy($this->_generic->getPathConfig("installDeployement")."Controllers/Actions/Default/".$file, $this->_generic->getPathConfig("actionsControllers")."Default/".$file); if (SLS_String::startsWith($file, "__")) { foreach ($langs as $lang) { $strLang = '<?php'."\n". '/**'."\n". '* '.strtoupper($lang).' File for all the Controller Default'."\n". '* You can create all your sentences variables here. To create it, follow the exemple :'."\n". '* '.t(1).'Access it with JS and XSL variable : $GLOBALS[$GLOBALS[\'PROJECT_NAME\']][\'JS\'][\'KEY_OF_YOUR_VARIABLE\'] = "value of your sentence in '.strtoupper($lang).'";'."\n". '* '.t(1).'Access it with XSL variable only : $GLOBALS[$GLOBALS[\'PROJECT_NAME\']][\'XSL\'][\'KEY_OF_YOUR_VARIABLE\'] = "value of your sentence in '.strtoupper($lang).'";'."\n". '*'."\n". '* '.t(1).'You can customise the value \'KEY_OF_YOUR_VARIABLE\' and "value of your sentence in '.strtoupper($lang).'" '."\n". '* @author SillySmart'."\n". '* @copyright SillySmart'."\n". '* @package Langs.Actions.Default'."\n". '* @since 1.0'."\n". '*'."\n". '*/'."\n". '?>'; file_put_contents($this->_generic->getPathConfig("actionLangs")."Default/__Default.".strtolower($lang).".lang.php", $strLang); } } else { $actionName = trim(SLS_String::substrBeforeFirstDelimiter($file, ".controller")); foreach ($langs as $lang) { $strLang = '<?php'."\n". '/**'."\n". '* '.strtoupper($lang).' File for the action '.$actionName.' into Default Controller'."\n". '* You can create all your sentences variables here. To create it, follow the exemple :'."\n". '* '.t(1).'Access it with JS and XSL variable : $GLOBALS[$GLOBALS[\'PROJECT_NAME\']][\'JS\'][\'KEY_OF_YOUR_VARIABLE\'] = "value of your sentence in '.strtoupper($lang).'";'."\n". '* '.t(1).'Access it with XSL variable only : $GLOBALS[$GLOBALS[\'PROJECT_NAME\']][\'XSL\'][\'KEY_OF_YOUR_VARIABLE\'] = "value of your sentence in '.strtoupper($lang).'";'."\n". '*'."\n". '* '.t(1).'You can customise the value \'KEY_OF_YOUR_VARIABLE\' and "value of your sentence in '.strtoupper($lang).'" '."\n". '* @author SillySmart'."\n". '* @copyright SillySmart'."\n". '* @package Langs.Actions.Home'."\n". '* @since 1.0'."\n". '*'."\n". '*/'."\n". '?>'; file_put_contents($this->_generic->getPathConfig("actionLangs")."Default/".$actionName.".".strtolower($lang).".lang.php", $strLang); } } } } // Views if (!is_dir($this->_generic->getPathConfig("viewsBody")."Home")) mkdir($this->_generic->getPathConfig("viewsBody")."Home"); if (!is_dir($this->_generic->getPathConfig("viewsBody")."Default")) mkdir($this->_generic->getPathConfig("viewsBody")."Default"); if (!is_dir($this->_generic->getPathConfig("viewsHeaders")."Home")) mkdir($this->_generic->getPathConfig("viewsHeaders")."Home"); if (!is_dir($this->_generic->getPathConfig("viewsHeaders")."Default")) mkdir($this->_generic->getPathConfig("viewsHeaders")."Default"); $homeBodyFiles = scandir($this->_generic->getPathConfig("installDeployement")."Views/Body/Home"); $defaultBodyFiles = scandir($this->_generic->getPathConfig("installDeployement")."Views/Body/Default"); $homeHeadersFiles = scandir($this->_generic->getPathConfig("installDeployement")."Views/Headers/Home"); $defaultHeadersFiles = scandir($this->_generic->getPathConfig("installDeployement")."Views/Headers/Default"); // Copy Home Body Views foreach ($homeBodyFiles as $file) (substr($file, (strlen($file)-3)) == "xsl") ? copy($this->_generic->getPathConfig("installDeployement")."Views/Body/Home/".$file, $this->_generic->getPathConfig("viewsBody")."Home/".$file) : ""; // Copy Default Body Views foreach ($defaultBodyFiles as $file) (substr($file, (strlen($file)-3)) == "xsl") ? copy($this->_generic->getPathConfig("installDeployement")."Views/Body/Default/".$file, $this->_generic->getPathConfig("viewsBody")."Default/".$file) : ""; // Copy Home Headers Views foreach ($homeHeadersFiles as $file) (substr($file, (strlen($file)-3)) == "xsl") ? copy($this->_generic->getPathConfig("installDeployement")."Views/Headers/Home/".$file, $this->_generic->getPathConfig("viewsHeaders")."Home/".$file) : ""; // Copy Default Headers Views foreach ($defaultHeadersFiles as $file) (substr($file, (strlen($file)-3)) == "xsl") ? copy($this->_generic->getPathConfig("installDeployement")."Views/Headers/Default/".$file, $this->_generic->getPathConfig("viewsHeaders")."Default/".$file) : ""; $this->setInstallationStep(array(0=>"SLS_Init",1=>"Initialization"), array(0=>"DataBase",1=>"DataBase")); return $this->_generic->dispatch("SLS_Init", "DataBase"); } else { $xml->startTag('errors'); foreach ($errors as $error) $xml->addFullTag('error', $error, true); $xml->endTag('errors'); $giveDataStep1 = true; $step = 1; } } // Sinon, default else { $step = 0; } if ($giveDataStep1 == true) { $xml->startTag("choose_langs"); $valueToHidden = ""; $isos = array(); foreach($listLangs as $listLang) { $iso = array_shift($handle->getTags("//sls_configs/sls_country/sls_country_langs/sls_country_lang[node()='".$listLang."']/@iso")); array_push($isos, $iso); $xml->startTag("choose_lang"); $xml->addFullTag("iso",$iso,true); $xml->addFullTag("label",$listLang,true); $xml->endTag("choose_lang"); $valueToHidden .= "-".$listLang; } $xml->endTag("choose_langs"); $xml->addFullTag("hidden_langs", substr($valueToHidden, 1), true); // Récupération des mots à traduire $xml->startTag("translate"); foreach ($isos as $iso) { $xml->startTag($iso); if (is_file($this->_generic->getPathConfig("coreGenericLangs")."generic.".$iso.".lang.php")) $handle = fopen($this->_generic->getPathConfig("coreGenericLangs")."generic.".$iso.".lang.php", 'r'); else $handle = fopen($this->_generic->getPathConfig("coreGenericLangs")."generic.en.lang.php", 'r'); $array = array(); while (!feof($handle)) { $line = fgets($handle, 4096); if (substr($line, 0, 1) == "$") { $tmpArray = array(); $tmpArray['name'] = str_replace("SLS_", "", SLS_String::substrAfterLastDelimiter(SLS_String::substrBeforeLastDelimiter($line, "']"), "['")); $tmpArray['value'] = SLS_String::substrBeforeLastDelimiter(SLS_String::substrAfterFirstDelimiter(trim(SLS_String::substrAfterLastDelimiter($line, " = ")), '"'), '"'); array_push($array, $tmpArray); } } foreach ($array as $row) { $xml->startTag("sentence"); $xml->addFullTag('name', strtolower(str_replace("_", " ", $row['name'])), true); $xml->addFullTag('code', $row['name'], true); $xml->addFullTag('value', $row['value'], true); $xml->endTag("sentence"); } $xml->endTag($iso); } $xml->endTag("translate"); } $xml->addFullTag("step", $step, true); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $langs = $this->_generic->getObjectLang()->getSiteLangs(); $errors = array(); $controllersXML = $this->_generic->getControllersXML(); $controller = $this->_http->getParam('Controller'); $protocol = $this->_generic->getSiteConfig("protocol"); $controllerExist = $controllersXML->getTags("//controllers/controller[@name='".$controller."' and @side='user']"); if (count($controllerExist) == 1) { if ($this->_http->getParam('reload') == 'true') { $postControllerName = SLS_String::trimSlashesFromString($this->_http->getParam('controllerName')); $controller = SLS_String::trimSlashesFromString($this->_http->getParam('oldName')); $postProtocol = SLS_String::trimSlashesFromString($this->_http->getParam('protocol')); $tpl = SLS_String::trimSlashesFromString($this->_http->getParam('template')); if (empty($postProtocol) || ($postProtocol != 'http' && $postProtocol != 'https')) array_push($errors, "Protocol must be http or https"); else $protocol = $postProtocol; $postControllerLangs = array(); foreach ($langs as $lang) $postControllerLangs[$lang] = SLS_String::stringToUrl(SLS_String::trimSlashesFromString($this->_http->getParam($lang."-controller")), "", false); if ($tpl == -1) $controllersXML->deleteTagAttribute("//controllers/controller[@name='".$controller."' and @side='user']", "tpl"); else $controllersXML->setTagAttributes("//controllers/controller[@name='".$controller."' and @side='user']", array('tpl' => $tpl)); @file_put_contents($this->_generic->getPathConfig('configSecure')."controllers.xml", $controllersXML->getXML()); $oldControllerName = $controller; if (empty($postControllerName)) array_push($errors, "Controller name can't be empty."); if (!empty($postControllerName) && $postControllerName != $controller) { $newControllerName = SLS_String::stringToUrl($postControllerName, "", false); $test = $controllersXML->getTags("//controllers/controller[@name='".$newControllerName."']"); if (count($test) != 0) array_push($errors, ($newControllerName == $postControllerName) ? "The controller Name '".$postControllerName."' already exist" : "The controller Name '".$postControllerName."' (".$newControllerName.") already exist"); else { $controllersXML->setTagAttributes("//controllers/controller[@name='".$controller."' and @side='user']", array('name' => $newControllerName)); @file_put_contents($this->_generic->getPathConfig('configSecure')."controllers.xml", $controllersXML->getXML()); $controller = $newControllerName; // Controller Files $files = scandir($this->_generic->getPathConfig('actionsControllers').$oldControllerName); foreach ($files as $file) if (is_file($this->_generic->getPathConfig('actionsControllers').$oldControllerName."/".$file) && substr($file, strlen($file)-3) == "php") @file_put_contents($this->_generic->getPathConfig('actionsControllers').$oldControllerName."/".$file, str_replace(array(0=>" ".$oldControllerName,1=>".".$oldControllerName), array(0=>" ".$newControllerName,1=>".".$newControllerName), file_get_contents($this->_generic->getPathConfig('actionsControllers').$oldControllerName."/".$file))); //Langs $files = scandir($this->_generic->getPathConfig('actionLangs').$oldControllerName); foreach ($files as $file) if (is_file($this->_generic->getPathConfig('actionLangs').$oldControllerName."/".$file) && substr($file, strlen($file)-3) == "php") @file_put_contents($this->_generic->getPathConfig('actionLangs').$oldControllerName."/".$file, str_replace(array(0=>" ".$oldControllerName,1=>".".$oldControllerName), array(0=>" ".$newControllerName,1=>".".$newControllerName), file_get_contents($this->_generic->getPathConfig('actionLangs').$oldControllerName."/".$file))); // Rename Directories @rename($this->_generic->getPathConfig('actionsControllers').$oldControllerName, $this->_generic->getPathConfig('actionsControllers').$controller); foreach ($langs as $lang) @rename($this->_generic->getPathConfig('actionLangs').$oldControllerName."/__".$oldControllerName.".".strtolower($lang).".lang.php", $this->_generic->getPathConfig('actionLangs').$oldControllerName."/__".$controller.".".strtolower($lang).".lang.php"); rename($this->_generic->getPathConfig('actionLangs').$oldControllerName, $this->_generic->getPathConfig('actionLangs').$controller); rename($this->_generic->getPathConfig('viewsBody').$oldControllerName, $this->_generic->getPathConfig('viewsBody').$controller); rename($this->_generic->getPathConfig('viewsHeaders').$oldControllerName, $this->_generic->getPathConfig('viewsHeaders').$controller); } } if (empty($errors)) { $translatedController = $controllersXML->getTags("//controllers/controller[@name != '".$controller."']/controllerLangs/controllerLang", 'id'); foreach ($postControllerLangs as $key=>$value) { if (in_array($value, $translatedController)) array_push($errors, "The translated name '".$value."' for this controller is alredy used"); } if (empty($errors)) { foreach ($postControllerLangs as $key=>$value) { $controllersXML->setTag("//controllers/controller[@name = '".$controller."' and @side='user']/controllerLangs/controllerLang[@lang='".$key."']", $postControllerLangs[$key], true); } $controllersXML->setTagAttributes("//controllers/controller[@name='".$controller."' and @side='user']", array('protocol' => $protocol)); file_put_contents($this->_generic->getPathConfig('configSecure')."controllers.xml", $controllersXML->getXML()); } } if (!empty($errors)) { $xml->startTag("errors"); foreach ($errors as $error) $xml->addFullTag("error", $error, true); $xml->endTag("errors"); } $xml->startTag('form'); $xml->addFullTag("controllerName", $postControllerName); foreach ($postControllerLangs as $key=>$value) $xml->addFullTag($key."-controller", $value, true); $xml->endTag('form'); } $tplResult = array_shift($controllersXML->getTagsAttribute("//controllers/controller[@name='".$controller."' and @side='user']","tpl")); $tpl = $tplResult["attribute"]; $xml->startTag('controller'); $xml->addFullTag("name", $controller, true); $xml->addFullTag("tpl", $tpl, true); $xml->addFullTag("locked", ($controller == 'Home' || $controller == 'Default') ? 1 : 0, true); $xml->startTag('translations'); foreach ($langs as $lang) { $xml->startTag('translation'); $xml->addFullTag("lang", $lang, true); $xml->addFullTag("name", $controllersXML->getTag("//controllers/controller[@name='".$controller."' and @side='user']/controllerLangs/controllerLang[@lang='".$lang."']"), true); $xml->endTag('translation'); } $xml->endTag('translations'); $xml->endTag('controller'); $xml->addFullTag('request', 'modifyController', true); // Build all tpls $tpls = $this->getAppTpls(); $xml->startTag("tpls"); foreach($tpls as $template) $xml->addFullTag("tpl",$template,true); $xml->endTag("tpls"); } else { $this->_generic->dispatch('SLS_Bo', 'Controllers'); } $xml->addFullTag('protocol', $protocol, true); $xml->addFullTag('template', $tpl, true); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $dbXML = $this->_generic->getDbXML(); // Check if db exists $alias = rawurldecode($this->_http->getParam("alias")); $result = $dbXML->getTagsAttribute("//dbs/db","alias"); $dbs = array(); for($i=0 ; $i<$count=count($result) ; $i++) array_push($dbs,$result[$i]["attribute"]); if (in_array($alias,$dbs)) { // Check if it is not the default db $result = array_shift($this->_generic->getDbXML()->getTagsAttribute("//dbs/db[@isDefault='true']","alias")); if ($alias != $result["attribute"]) { $files = array(); $bos = array(); $xml->addFullTag("db_exists","true",true); $controllerXML = $this->_generic->getControllersXML(); $genericBo = array_shift($controllerXML->getTags("//controllers/controller[@isBo='true']/@name")); // List files which will be deleted $models = $this->getAllModels(); $xml->startTag("models"); foreach($models as $model) { if (SLS_String::startsWith($model,$alias)) { $xml->startTag("model"); $xml->addFullTag("label",SLS_String::substrAfterFirstDelimiter($model,"."),true); $xml->addFullTag("file",ucfirst($model),true); array_push($files,$this->_generic->getPathConfig("models").ucfirst($model).".model.php"); array_push($files,$this->_generic->getPathConfig("modelsSql").ucfirst($model).".sql.php"); $actionsBo = $this->getActionsBo(SLS_String::substrAfterFirstDelimiter($model,"."),$alias); $xml->startTag("bos"); foreach($actionsBo as $actionBo) { $tmp = array("model"=>SLS_String::substrAfterFirstDelimiter($model,"."),"action"=>strtolower(SLS_String::substrBeforeFirstDelimiter($actionBo,ucfirst($alias)."_")),"alias"=>$alias); array_push($bos,$tmp); $xml->startTag("bo"); $xml->addFullTag("label",SLS_String::substrBeforeFirstDelimiter($actionBo,ucfirst($alias)."_"),true); $xml->addFullTag("file",$actionBo.".controller.php",true); $xml->endTag("bo"); } $xml->endTag("bos"); $xml->endTag("model"); } } $xml->endTag("models"); if ($this->_http->getParam("reload") == "true") { $password = SLS_String::trimSlashesFromString($this->_http->getParam("password", 'post')); $login = SLS_String::trimSlashesFromString($this->_http->getParam("login", 'post')); $slsXml = $this->_generic->getCoreXML('sls'); $passXML = array_shift($slsXml->getTags("//sls_configs/auth/users/user[@login='******' and @level='0']/@pass")); if (!empty($passXML) && $passXML == sha1($password)) { // Delete files bo foreach($bos as $bo) $this->deleteActionBo($bo["model"],$bo["action"],$bo["alias"]); // Delete files model foreach($files as $file) @unlink($file); // Delete config $dbXML->deleteTags("//dbs/db[@alias='".$alias."']"); $dbXML->saveXML($this->_generic->getPathConfig("configSecure")."db.xml"); $controllers = $this->_generic->getTranslatedController("SLS_Bo","DataBaseSettings"); $this->_generic->redirect($controllers["controller"]."/".$controllers["scontroller"].".sls"); } else $xml->addFullTag("incorrect_account","true",true); } $xml->addFullTag("database",$alias,true); } else { $xml->startTag("errors"); $xml->addFullTag("error","You can't delete the default database",true); $xml->endTag("errors"); } } else { $xml->startTag("errors"); $xml->addFullTag("error","This database can't be found",true); $xml->endTag("errors"); } $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $langs = array(); $appli_langs = array(); $handle = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."international.xml")); $step = 0; $errors = array(); $controllerXML = $this->_generic->getControllersXML(); $metaXML = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."metas.xml")); $appli_langs = $this->_generic->getObjectLang()->getSiteLangs(); $defaultLang = $this->_generic->getObjectLang()->getDefaultLang(); // If lang have been choose if ($this->_http->getParam("step") == "1") { $lang1 = SLS_String::trimSlashesFromString($this->_http->getParam("lang")); $lang = array_shift($handle->getTags("//sls_configs/sls_country/sls_country_langs/sls_country_lang[node()='".$lang1."']/@iso")); if (!in_array($lang,$appli_langs)) { $step = 2; $xml->addFullTag("step","2",true); $xml->addFullTag("lang_to_add",$lang,true); } else { $xml->addFullTag("lang_selected",$lang1,true); $xml->startTag("errors"); $xml->addFullTag("error","This lang already exist in your application",true); $xml->endTag("errors"); } } if ($this->_http->getParam("step") == "2" || $step == 2) { $lang = (empty($lang)) ? $this->_http->getParam("lang_to_add") : $lang; $xml->addFullTag("step","2",true); $xml->addFullTag("lang_to_add",$lang,true); $generics = array( "MONDAY" => "", "TUESDAY" => "", "WEDNESDAY" => "", "THURSDAY" => "", "FRIDAY" => "", "SATURDAY" => "", "SUNDAY" => "", "JANUARY" => "", "FEBRUARY" => "", "MARCH" => "", "APRIL" => "", "MAY" => "", "JUNE" => "", "JULY" => "", "AUGUST" => "", "SEPTEMBER" => "", "OCTOBER" => "", "NOVEMBER" => "", "DECEMBER" => "", "DATE_PATTERN_TIME" => "", "DATE_PATTERN_FULL_TIME" => "", "DATE_PATTERN_DATE" => "", "DATE_PATTERN_MONTH_LITTERAL" => "", "DATE_PATTERN_FULL_LITTERAL" => "", "DATE_PATTERN_FULL_LITTERAL_TIME" => "", "DATE_PATTERN_MONTH_LITTERAL_TIME" => "", "DATE_DIFF_Y" => "", "DATE_DIFF_M" => "", "DATE_DIFF_W" => "", "DATE_DIFF_D" => "", "DATE_DIFF_H" => "", "DATE_DIFF_I" => "", "DATE_DIFF_S" => "", "E_CONTENT" => "", "E_EMPTY" => "", "E_KEY" => "", "E_COMPLEXITY" => "", "E_LENGTH" => "", "E_NULL" => "", "E_UNIQUE" => "", "E_TYPE" => "", "E_SIZE" => "", "E_EXIST" => "", "E_WRITE" => "", "E_LOGGED" => "", "E_AUTHORIZED" => "" ); // Try to recover generic langs from Deployement if (file_exists($this->_generic->getPathConfig("installDeployement")."Langs/Generics/generic.".$lang.".lang.php")) include($this->_generic->getPathConfig("installDeployement")."Langs/Generics/generic.".$lang.".lang.php"); // Set the default value by english or current lang if has been found in Deployement foreach($generics as $key => $value) $generics[$key] = SLS_String::trimSlashesFromString($GLOBALS[$GLOBALS['PROJECT_NAME']]['JS']['SLS_'.$key]); $controllers = array(); // Recover all controllers $controllersA = $controllerXML->getTags("//controllers/controller[@side='user']/@name"); foreach($controllersA as $controller) { $id = array_shift($controllerXML->getTags("//controllers/controller[@name='".$controller."']/@id")); $values = array(); foreach($appli_langs as $appli_lang) $values[$appli_lang] = array_shift($controllerXML->getTags("//controllers/controller[@name='".$controller."']/controllerLangs/controllerLang[@lang='".$appli_lang."']")); $values[$lang] = SLS_String::trimSlashesFromString($this->_http->getParam($id."_".$lang)); $result = array("id" => $id, "key" => $controller, "values" => $values, "actions" => array()); array_push($controllers,$result); } // Foreach controllers, recover all actions for($i=0 ; $i<$count=count($controllers) ; $i++) { $controller = $controllers[$i]["key"]; $actions = $controllerXML->getTags("//controllers/controller[@name='".$controller."']/scontrollers/scontroller/@name"); $actionsA = array(); foreach($actions as $action) { $id = array_shift($controllerXML->getTags("//controllers/controller[@name='".$controller."']/scontrollers/scontroller[@name='".$action."']/@id")); $values = array(); foreach($appli_langs as $appli_lang) $values[$appli_lang] = array_shift($controllerXML->getTags("//controllers/controller[@name='".$controller."']/scontrollers/scontroller[@name='".$action."']/scontrollerLangs/scontrollerLang[@lang='".$appli_lang."']")); $values[$lang] = SLS_String::trimSlashesFromString($this->_http->getParam($id."_".$lang)); $metas = array("title" => array(), "description" => array(), "keywords" => array()); $titles = array(); $descriptions = array(); $keywords = array(); foreach($appli_langs as $appli_lang) { $titles[$appli_lang] = array_shift($metaXML->getTags("//sls_configs/action[@id='".$id."']/title[@lang='".$appli_lang."']")); $descriptions[$appli_lang] = array_shift($metaXML->getTags("//sls_configs/action[@id='".$id."']/description[@lang='".$appli_lang."']")); $keywords[$appli_lang] = array_shift($metaXML->getTags("//sls_configs/action[@id='".$id."']/keywords[@lang='".$appli_lang."']")); } $titles[$lang] = SLS_String::trimSlashesFromString($this->_http->getParam("meta_title-".$id."_".$lang)); $descriptions[$lang] = SLS_String::trimSlashesFromString($this->_http->getParam("meta_description-".$id."_".$lang)); $keywords[$lang] = SLS_String::trimSlashesFromString($this->_http->getParam("meta_keywords-".$id."_".$lang)); $metas["title"] = $titles; $metas["description"] = $descriptions; $metas["keywords"] = $keywords; $result = array("id" => $id,"key" => $action, "values" => $values, "metas" => $metas); array_push($actionsA,$result); } $controllers[$i]["actions"] = $actionsA; } // If informations have been sent, check if it's good if ($this->_http->getParam("reload") == "true") { $mods = array(); $smods = array(); // Get all controllers foreach($this->_http->getParams() as $key => $value) { // Controllers case if (SLS_String::startsWith($key,"c_")) { $id = SLS_String::substrBeforeLastDelimiter($key,"_".$lang); $mod = array_shift($controllerXML->getTags("//controllers/controller[@id='".$id."']/@name")); $mods[$id] = SLS_String::stringToUrl(SLS_String::trimSlashesFromString($value),"",false); if (empty($mods[$id])) array_push($errors,"You have to fill the rewrite of the controller '".$mod."'."); $modsExisted = $controllerXML->getTags("//controllers/controller/controllerLangs/controllerLang"); if (in_array($mods[$id],$modsExisted)) array_push($errors,"The name for rewrite of the controller '".$mod."' is already used, please choose another one."); } // Actions case else if (SLS_String::startsWith($key,"a_")) { $id = SLS_String::substrBeforeLastDelimiter($key,"_".$lang); $smod = array_shift($controllerXML->getTags("//controllers/controller/scontrollers/scontroller[@id='".$id."']/@name")); $mod = array_shift($controllerXML->getTags("//controllers/controller[scontrollers/scontroller[@id='".$id."']]/@name")); $idC = array_shift($controllerXML->getTags("//controllers/controller[scontrollers/scontroller[@id='".$id."']]/@id")); $smods[$id] = SLS_String::stringToUrl(SLS_String::trimSlashesFromString($value),"",false); if (empty($smods[$id])) array_push($errors,"You have to fill the rewrite of the action '".$smod."' (controller '".$mod."')."); $smodsExisted = $controllerXML->getTags("//controllers/controller[@id='".$idC."']/scontrollers/scontroller/scontrollerLangs/scontrollerLang[@lang='".$lang."']"); if (in_array($smods[$id],$smodsExisted)) array_push($errors,"The name for rewrite of the action '".$smod."' (controller '".$mod."') is already used by another action of the same controller, please choose another one."); } // Generics case else if (SLS_String::startsWith($key,"generic_")) { $label = SLS_String::substrAfterFirstDelimiter($key,"generic_"); if (empty($value)) array_push($errors,"You have to fill the content of the variable '".$label."'"); $generics[$label] = strtolower(SLS_String::trimSlashesFromString($value)); } } // If all cool if (empty($errors)) { // controllers.xml foreach($mods as $key => $value) { $str = '<controllerLang lang="'.$lang.'"><![CDATA['.$value.']]></controllerLang>'; $controllerXML->appendXMLNode("//controllers/controller[@id='".$key."']/controllerLangs",$str); } foreach($smods as $key => $value) { $str = '<scontrollerLang lang="'.$lang.'"><![CDATA['.$value.']]></scontrollerLang>'; $controllerXML->appendXMLNode("//controllers/controller/scontrollers/scontroller[@id='".$key."']/scontrollerLangs",$str); // metas.xml $title = SLS_String::trimSlashesFromString($this->_http->getParam("meta_title-".$key."_".$lang)); if (empty($title)) $str = '<title lang="'.$lang.'"/>'; else $str = '<title lang="'.$lang.'"><![CDATA['.$title.']]></title>'; $metaXML->appendXMLNode("//sls_configs/action[@id='".$key."']",$str); $description = SLS_String::trimSlashesFromString($this->_http->getParam("meta_description-".$key."_".$lang)); if (empty($description)) $str = '<description lang="'.$lang.'"/>'; else $str = '<description lang="'.$lang.'"><![CDATA['.$description.']]></description>'; $metaXML->appendXMLNode("//sls_configs/action[@id='".$key."']",$str); $keyword = SLS_String::trimSlashesFromString($this->_http->getParam("meta_keywords-".$key."_".$lang)); if (empty($keyword)) $str = '<keywords lang="'.$lang.'"/>'; else $str = '<keywords lang="'.$lang.'"><![CDATA['.$keyword.']]></keywords>'; $metaXML->appendXMLNode("//sls_configs/action[@id='".$key."']",$str); // /metas.xml } $controllerXML->saveXML($this->_generic->getPathConfig("configSecure")."controllers.xml"); $metaXML->saveXML($this->_generic->getPathConfig("configSls")."metas.xml"); // /controllers.xml // site.xml $siteXML = $this->_generic->getSiteXML(); $str = '<name isSecure="false" js="false" active="false"><![CDATA['.$lang.']]></name>'; $siteXML->appendXMLNode("//configs/langs",$str); $siteXML->saveXML($this->_generic->getPathConfig("configSecure")."site.xml"); // /site.xml // generic.iso.lang.php $fileContent = '<?php'."\n". '/**'."\n". ' * Generic Sls Vars'."\n". ' */'."\n"; foreach($generics as $key => $value) $fileContent .= '$GLOBALS[$GLOBALS[\'PROJECT_NAME\']][\'JS\'][\'SLS_'.$key.'\'] = "'.str_replace('"','\"',$value).'";'."\n"; $fileContent .= '?>'; file_put_contents($this->_generic->getPathConfig("coreGenericLangs")."generic.".$lang.".lang.php",$fileContent); // /generic.iso.lang.php // site.iso.lang.php $fileContent = '<?php'."\n". '/**'."\n". ' * SillySmart Translations'."\n". ' * Language : '.array_shift($handle->getTags("//sls_configs/sls_country/sls_country_langs/sls_country_lang[node()='".$lang."']/@iso")).' ('.strtoupper($lang).')'."\n". ' */'."\n\n". '?>'; file_put_contents($this->_generic->getPathConfig("genericLangs")."site.".$lang.".lang.php",str_replace(array("Translations in '".strtoupper($defaultLang)."'","site.".$defaultLang.".lang.php","sentence in ".strtoupper($defaultLang)),array("Translations in '".strtoupper($lang)."'","site.".$lang.".lang.php","sentence in ".strtoupper($lang)),file_get_contents($this->_generic->getPathConfig("genericLangs")."site.".$defaultLang.".lang.php"))); // /site.iso.lang.php // Actions langs files $directories = array(); foreach($mods as $key => $value) array_push($directories,array_shift($controllerXML->getTags("//controllers/controller[@id='".$key."']/@name"))); $this->copyActionsLang($directories,$lang); // /Actions langs files // User_Bo langs $controllerBo = $controllerXML->getTag("//controllers/controller[@side='user' and @isBo='true']/@name"); if (!empty($controllerBo)) { if (file_exists($this->_generic->getPathConfig("installDeployement")."Langs/Actions/{{USER_BO}}/__{{USER_BO}}.".$lang.".lang.php")) $langContent = str_replace(array("{{USER_BO}}"),array($controllerBo),file_get_contents($this->_generic->getPathConfig("installDeployement")."Langs/Actions/{{USER_BO}}/__{{USER_BO}}.".$lang.".lang.php")); else $langContent = str_replace(array("{{USER_BO}}"),array($controllerBo),file_get_contents($this->_generic->getPathConfig("installDeployement")."Langs/Actions/{{USER_BO}}/__{{USER_BO}}.en.lang.php")); if (!empty($langContent)) file_put_contents($this->_generic->getPathConfig("actionLangs").$controllerBo."/__".$controllerBo.".".$lang.".lang.php",$langContent); } // MySQL multilanguage tables $handle = opendir($this->_generic->getPathConfig("models")); // Disable explain SLS_Sql::getInstance()->_explain = false; // Foreach models while (false !== ($file = readdir($handle))) { if (!is_dir($this->_generic->getPathConfig("models")."/".$file) && substr($file, 0, 1) != ".") { $fileExploded = explode(".",$file); if (is_array($fileExploded) && count($fileExploded) == 4) { $db = $fileExploded[0]; $class = $fileExploded[1]; $className = $db."_".$class; $this->_generic->useModel($class,$db,"user"); $object = new $className(); if ($object->isMultilanguage()) { $results = $object->searchModels($object->getTable(),array(),array(0=>array("column"=>"pk_lang","value"=>$defaultLang,"mode"=>"equal"))); for($i=0 ; $i<$count=count($results) ; $i++) { $object = new $className(); $object->setModelLanguage($lang); foreach($results[$i] as $column => $col_value) { if ($column != "pk_lang" && $column != $object->getPrimaryKey()) { $object->__set($column,$col_value); } } try { $object->create($results[$i]->{$object->getPrimaryKey()}); } catch (Exception $e){} } } } } } // /MySQL multilanguage tables // Redirect $controllers = $this->_generic->getTranslatedController("SLS_Bo","Langs"); $this->_generic->redirect($controllers["controller"]."/".$controllers["scontroller"].".sls"); } // Else, form errors else { $xml->startTag("errors"); foreach($errors as $error) $xml->addFullTag("error",$error,true); $xml->endTag("errors"); } } $xml->startTag("generic_langs"); foreach($generics as $key => $value) { $xml->startTag("generic_lang"); $xml->addFullTag("key",$key,true); $xml->addFullTag("value",$value,true); $xml->endTag("generic_lang"); } $xml->endTag("generic_langs"); $xml->startTag("controllers"); for($i=0 ; $i<$count=count($controllers) ; $i++) { $xml->startTag("controller"); $xml->addFullTag("id",$controllers[$i]["id"],true); $xml->addFullTag("key",$controllers[$i]["key"],true); $xml->startTag("values"); foreach($controllers[$i]["values"] as $key2 => $value2) { $xml->startTag("value"); $xml->addFullTag("key",$key2,true); $xml->addFullTag("value",$value2,true); $xml->endTag("value"); } $xml->endTag("values"); $xml->startTag("actions"); for($j=0 ; $j<$count2=count($controllers[$i]["actions"]) ; $j++) { $action = $controllers[$i]["actions"]; $xml->startTag("action"); $xml->addFullTag("id",$action[$j]["id"],true); $xml->addFullTag("key",$action[$j]["key"],true); $xml->startTag("values"); foreach($action[$j]["values"] as $key3 => $value3) { $xml->startTag("value"); $xml->addFullTag("key",$key3,true); $xml->addFullTag("value",$value3,true); $xml->endTag("value"); } $xml->endTag("values"); $xml->startTag("metas"); foreach($action[$j]["metas"] as $key4 => $value4) { $xml->startTag("meta"); $xml->addFullTag("key",$key4,true); $xml->startTag("values"); foreach($value4 as $key5 => $value5) { $xml->startTag("value"); $xml->addFullTag("key",$key5,true); $xml->addFullTag("value",$value5,true); $xml->endTag("value"); } $xml->endTag("values"); $xml->endTag("meta"); } $xml->endTag("metas"); $xml->endTag("action"); } $xml->endTag("actions"); $xml->endTag("controller"); } $xml->endTag("controllers"); } $xpathLangs = $handle->getTags("//sls_configs/sls_country/sls_country_langs/sls_country_lang[@iso != '']"); foreach ($xpathLangs as $lang) if (!in_array(trim($lang), $langs)) array_push($langs, trim($lang)); array_multisort($langs, SORT_STRING, SORT_ASC); $xml->startTag("langs"); foreach ($langs as $lang) $xml->addFullTag("lang", $lang, true); $xml->endTag("langs"); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $confirmation = $this->_http->getParam("confirm", 'post'); $password = SLS_String::trimSlashesFromString($this->_http->getParam("password", 'post')); $login = SLS_String::trimSlashesFromString($this->_http->getParam("login", 'post')); $stepPassword = false; if ($confirmation == 'update') { $stepPassword = true; if (!empty($password) && !empty($login)) { $slsXml = $this->_generic->getCoreXML('sls'); $passXML = array_shift($slsXml->getTags("//sls_configs/auth/users/user[@login='******' and @level='0']/@pass")); if (!empty($passXML) && $passXML == sha1($password)) { $syncServer = array_shift($slsXml->getTags("slsnetwork")); $slsVersion = array_shift($slsXml->getTags("version")); $serversJSON = @file_get_contents($syncServer); if ($serversJSON !== false && !empty($serversJSON)) { $servers = json_decode($serversJSON); $updateServer = array_shift($servers->servers->update); if ($updateServer === false || empty($updateServer)) { $xml->addFullTag("error_server","Update server can't be found, please retry later"); } else { $serverContent = @file_get_contents($updateServer->url); $jsonContent = json_decode($serverContent); if ($jsonContent === false || empty($jsonContent)) { $xml->addFullTag("error_server","Update server not available, please retry later"); } else { $allSls = $jsonContent->releases; $currentSls = $slsVersion; // Foreach releases, check if we need to update it for($i=0 ; $i<$count=count($allSls) ; $i++) { $version = $allSls[$i]->version; // If it's we have to update to this version if ($version > $currentSls) { // If we can't download install files, abort update if (SLS_Remote::remoteFileExists($updateServer->domain.$allSls[$i]->archive) != 0 || SLS_Remote::remoteFileExists($updateServer->domain.$allSls[$i]->script) != 0) { $xml->addFullTag("error_server","Update process failed"); break; } // Else, it's cool, update this version else { // If 'Releases' directory doesn't exists, create it if (!is_dir($this->_generic->getPathConfig("coreTmpDownload")."Releases")) mkdir($this->_generic->getPathConfig("coreTmpDownload")."Releases"); // If 'Releases/[Release Version]' directory doesn't exists, create it if (!is_dir($this->_generic->getPathConfig("coreTmpDownload")."Releases/".$allSls[$i]->version)) mkdir($this->_generic->getPathConfig("coreTmpDownload")."Releases/".$allSls[$i]->version); // Archive & script names $archive = $this->_generic->getPathConfig("coreTmpDownload")."Releases/".$allSls[$i]->version."/archive.tar"; $script = $this->_generic->getPathConfig("coreTmpDownload")."Releases/".$allSls[$i]->version."/update.php"; // Copy archive & script $resultTar = @copy($updateServer->domain.$allSls[$i]->archive, $archive); $resultScript = @copy($updateServer->domain.$allSls[$i]->script, $script); // If a copy has failed if ($resultTar === false || $resultScript === false) { $xml->addFullTag("error_server","Update process failed"); break; } // Execute script eval(file_get_contents($script)); // Delete unstall files @unlink($this->_generic->getPathConfig("coreTmpDownload")."Releases/".$allSls[$i]->version."/archive.tar"); @unlink($this->_generic->getPathConfig("coreTmpDownload")."Releases/".$allSls[$i]->version."/update.php"); @rmdir($this->_generic->getPathConfig("coreTmpDownload")."Releases/".$allSls[$i]->version); } } } $this->_generic->goDirectTo("SLS_Bo","Updates"); } } } else { $xml->addFullTag("error_server","Synchronisation server not available, please retry later"); } } } } $xml->addFullTag('stepPassword', ($stepPassword) ? 'yes' : 'no', true); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $env = $this->_http->getParam("Env"); if (empty($env)) $env = "prod"; if ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/mail_".$env.".xml")) $mailXML = new SLS_XMLToolbox(file_get_contents($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/mail_".$env.".xml")); else $mailXML = $this->_generic->getMailXML(); $errors = array(); // Prod Deployment $finalFile = ($this->_http->getParam("ProdDeployment") == "true") ? "mail_".$env.".xml" : "mail.xml"; $isInBatch = ($this->_http->getParam("CompleteBatch") == "true") ? true : false; $xml->addFullTag("is_batch",($isInBatch) ? "true" : "false",true); $xml->addFullTag("is_prod",($this->_http->getParam("ProdDeployment") == "true") ? "true" : "false",true); // Get default values $defaultHost = $this->_generic->getMailConfig("host"); $defaultPort = $this->_generic->getMailConfig("port"); $defaultUser = $this->_generic->getMailConfig("username"); $defaultPass = $this->_generic->getMailConfig("passsword"); $defaultDomain = $this->_generic->getMailConfig("defaultDomain"); $defaultReturn = $this->_generic->getMailConfig("defaultReturn"); $defaultNameReturn = $this->_generic->getMailConfig("defaultNameReturn"); $defaultReply = $this->_generic->getMailConfig("defaultReply"); $defaultNameReply = $this->_generic->getMailConfig("defaultNameReply"); $defaultSender = $this->_generic->getMailConfig("defaultSender"); $defaultNameSender = $this->_generic->getMailConfig("defaultNameSender"); $TemplatesHeader = $mailXML->getTags("//mails/templates/item[@id='default']/header"); $TemplatesFooter = $mailXML->getTags("//mails/templates/item[@id='default']/footer"); $reload = $this->_http->getParam("reload"); if ($reload == "true") { // Get New Parameters $exportConfig = $this->_http->getParam('export'); $postHost = SLS_String::trimSlashesFromString($this->_http->getParam("host", "post")); $postPort = SLS_String::trimSlashesFromString($this->_http->getParam("port", "post")); $postUser = SLS_String::trimSlashesFromString($this->_http->getParam("user", "post")); $postPass = SLS_String::trimSlashesFromString($this->_http->getParam("pass", "post")); $postDomain = SLS_String::trimSlashesFromString($this->_http->getParam("domain", "post")); $postReturn = SLS_String::trimSlashesFromString($this->_http->getParam("return", "post")); $postNameReturn = SLS_String::trimSlashesFromString($this->_http->getParam("nameReturn", "post"));; $postReply = SLS_String::trimSlashesFromString($this->_http->getParam("reply", "post")); $postNameReply = SLS_String::trimSlashesFromString($this->_http->getParam("nameReply", "post")); $postSender = SLS_String::trimSlashesFromString($this->_http->getParam("sender", "post")); $postNameSender = SLS_String::trimSlashesFromString($this->_http->getParam("nameSender", "post")); $postPassNeed = SLS_String::trimSlashesFromString($this->_http->getParam("needpass", "post")); $postUserNeed = SLS_String::trimSlashesFromString($this->_http->getParam("needuser", "post")); $varsPost = $this->_http->getParams("post"); if ($postUserNeed != "on" && empty($postUser)) array_push($errors, "You need to fill the username"); if ($postPassNeed != "on" && empty($postPass)) array_push($errors, "You need to fill the password"); if (empty($errors) && $this->_http->getParam("ping") != "true") { if ($defaultHost != $postHost) $mailXML->setTag("//mails/host", SLS_Security::getInstance()->encrypt($postHost, $this->_generic->getSiteConfig("privateKey")), true); if ($defaultPort != $postPort) $mailXML->setTag("//mails/port", SLS_Security::getInstance()->encrypt($postPort, $this->_generic->getSiteConfig("privateKey")), true); if ($defaultReturn != $postReturn) $mailXML->setTag("//mails/defaultReturn", $postReturn, true); if ($defaultDomain != $postDomain) $mailXML->setTag("//mails/defaultDomain", $postDomain, true); if ($defaultNameReturn != $postNameReturn) $mailXML->setTag("//mails/defaultNameReturn", $postNameReturn, true); if ($defaultReply != $postReply) $mailXML->setTag("//mails/defaultReply", $postReply, true); if ($defaultNameReply != $postNameReply) $mailXML->setTag("//mails/defaultNameReply", $postNameReply, true); if ($defaultSender != $postSender) $mailXML->setTag("//mails/defaultSender", $postSender, true); if ($defaultNameSender != $postNameSender) $mailXML->setTag("//mails/defaultNameSender", $postNameSender, true); if ($postUserNeed == "on") $mailXML->setTag("//mails/username", "", true); else $mailXML->setTag("//mails/username", SLS_Security::getInstance()->encrypt($postUser, $this->_generic->getSiteConfig("privateKey")), true); if ($postPassNeed == "on") $mailXML->setTag("//mails/password", "", true); else $mailXML->setTag("//mails/password", SLS_Security::getInstance()->encrypt($postPass, $this->_generic->getSiteConfig("privateKey")), true); if ($exportConfig == "on") { $date = gmdate('D, d M Y H:i:s'); header("Content-Type: text/xml"); header('Content-Disposition: attachment; filename='.$finalFile); header('Last-Modified: '.$date. ' GMT'); header('Expires: ' .$date); // For This F**k'in Browser if(preg_match('/msie|(microsoft internet explorer)/i', $_SERVER['HTTP_USER_AGENT'])) { header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else header('Pragma: no-cache'); print($mailXML->getXML()); exit; } else { $mailXML->refresh(); @file_put_contents($this->_generic->getPathConfig("configSecure").$finalFile, $mailXML->getXML()); if ($isInBatch) $this->_generic->forward("SLS_Bo","ProjectSettings",array(array("key"=>"ProdDeployment","value"=>"true"),array("key"=>"CompleteBatch","value"=>"true"),array("key"=>"Env","value"=>$env))); else if ($this->_http->getParam("ProdDeployment") == "true") $this->_generic->forward("SLS_Bo","ProductionDeployment"); } } if (!empty($errors) && $this->_http->getParam("ping") != "true") { $xml->startTag('errors'); foreach ($errors as $error) { $xml->addFullTag('error', $error); } $xml->endTag('errors'); } if ($this->_http->getParam("ping") == "true") { $smtp = new SLS_Email(""); $verdict = $smtp->pingConnection($postHost,$postPort,$postUser,$postPass); $xml->addFullTag("ping",($verdict===true) ? "true" : $verdict,true); } } $this->_generic->eraseCache('Mail'); $xml->startTag("current_values"); $xml->addFullTag("host", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/mail_".$env.".xml")) ? SLS_Security::getInstance()->decrypt(array_shift($mailXML->getTags("//mails/host")), $this->_generic->getSiteConfig("privateKey")) : SLS_Security::getInstance()->decrypt($this->_generic->getMailConfig("host"), $this->_generic->getSiteConfig("privateKey")), true); $xml->addFullTag("port", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/mail_".$env.".xml")) ? SLS_Security::getInstance()->decrypt(array_shift($mailXML->getTags("//mails/port")), $this->_generic->getSiteConfig("privateKey")) : SLS_Security::getInstance()->decrypt($this->_generic->getMailConfig("port"), $this->_generic->getSiteConfig("privateKey")), true); $xml->addFullTag("user", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/mail_".$env.".xml")) ? SLS_Security::getInstance()->decrypt(array_shift($mailXML->getTags("//mails/username")), $this->_generic->getSiteConfig("privateKey")) : SLS_Security::getInstance()->decrypt($this->_generic->getMailConfig("username"), $this->_generic->getSiteConfig("privateKey")), true); $xml->addFullTag("pass", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/mail_".$env.".xml")) ? array_shift($mailXML->getTags("//mails/password")) : $this->_generic->getMailConfig("password"), true); $xml->addFullTag("domain", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/mail_".$env.".xml")) ? array_shift($mailXML->getTags("//mails/defaultDomain")) : $this->_generic->getMailConfig("defaultDomain"), true); $xml->addFullTag("return", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/mail_".$env.".xml")) ? array_shift($mailXML->getTags("//mails/defaultReturn")) : $this->_generic->getMailConfig("defaultReturn"), true); $xml->addFullTag("nameReturn", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/mail_".$env.".xml")) ? array_shift($mailXML->getTags("//mails/defaultNameReturn")) : $this->_generic->getMailConfig("defaultNameReturn"), true); $xml->addFullTag("reply", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/mail_".$env.".xml")) ? array_shift($mailXML->getTags("//mails/defaultReply")) : $this->_generic->getMailConfig("defaultReply"), true); $xml->addFullTag("nameReply", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/mail_".$env.".xml")) ? array_shift($mailXML->getTags("//mails/defaultNameReply")) : $this->_generic->getMailConfig("defaultNameReply"), true); $xml->addFullTag("sender", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/mail_".$env.".xml")) ? array_shift($mailXML->getTags("//mails/defaultSender")) : $this->_generic->getMailConfig("defaultSender"), true); $xml->addFullTag("nameSender", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/mail_".$env.".xml")) ? array_shift($mailXML->getTags("//mails/defaultNameSender")) : $this->_generic->getMailConfig("defaultNameSender"), true); $xml->endTag("current_values"); $xml->addFullTag("url_mail_templates",$this->_generic->getFullPath("SLS_Bo","MailTemplates"),true); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $siteXML = $this->_generic->getSiteXML(); $langs = $this->_lang->getSiteLangs(); $errors = array(); if ($this->_http->getParam("reload") == "true") { $alias = SLS_String::trimSlashesFromString($this->_http->getParam("alias")); $domain = SLS_String::trimSlashesFromString($this->_http->getParam("domain")); $lang = SLS_String::trimSlashesFromString($this->_http->getParam("lang")); $cdn = $this->_http->getParam("cdn"); if ($cdn != 'true') $cdn = 'false'; if (SLS_String::endsWith(trim($domain),"/")) $domain = SLS_String::substrBeforeLastDelimiter(trim($domain),"/"); $result = $siteXML->getTag("//configs/domainName/domain[@alias='".$alias."']"); if (empty($alias)) array_push($errors,"You must choose an alias for your domain name."); else if (!empty($result)) array_push($errors,"This alias is already used by another domain, please choose another."); if (empty($domain)) array_push($errors,"You must fill your domain name."); else if (!SLS_String::isValidUrl("http://".$domain)) array_push($errors,"This domain is not a valid url."); if (empty($errors)) { $str_xml = '<domain alias="'.$alias.'" js="true" isSecure="false" cdn="'.$cdn.'" lang="'.$lang.'">'. '<![CDATA['.$domain.']]>'. '</domain>'; $siteXML->appendXMLNode("//configs/domainName",$str_xml); $siteXML->saveXML($this->_generic->getPathConfig("configSecure")."site.xml"); $this->_generic->forward("SLS_Bo","GlobalSettings"); } else { $xml->startTag("domain"); $xml->addFullTag("alias",$alias,true); $xml->addFullTag("domain",$domain,true); $xml->addFullTag("cdn",$cdn,true); $xml->addFullTag("lang",$lang,true); $xml->endTag("domain"); } } $langsBinded = $siteXML->getTags("//configs/domainName/domain/@lang"); foreach($langs as $lang) if (in_array($lang,$langsBinded)) unset($langs[array_shift(array_keys($langs,$lang))]); $xml->startTag("langs"); foreach($langs as $lang) $xml->addFullTag("lang",$lang,true); $xml->endTag("langs"); $xml->startTag("errors"); foreach($errors as $error) $xml->addFullTag("error",$error,true); $xml->endTag("errors"); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $errors = array(); $plugin = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configPlugins")."/plugins.xml")); $pluginMobile = $plugin->getTag("//plugins/plugin[@code='mobile']"); $pluginMobile = (!empty($pluginMobile)) ? true : false; if ($this->_http->getParam('reload') == 'true') { $controller = SLS_String::trimSlashesFromString($this->_http->getParam('controllerName')); $cache_visibility = SLS_String::trimSlashesFromString($this->_http->getParam('cache_visibility')); $cache_expiration = SLS_String::trimSlashesFromString($this->_http->getParam('cache_expiration')); $cache_responsive = SLS_String::trimSlashesFromString($this->_http->getParam('cache_responsive')); // If responsive wanted if ($cache_responsive == "true" && !$pluginMobile) { // Force Mobile plugin download file_get_contents($this->_generic->getFullPath("SLS_Bo", "SearchPlugin", array("Action" => "Download", "Server" => "4", "Plugin" => "20", "token" => sha1(substr($this->_generic->getSiteConfig("privateKey"), 0, 3).substr($this->_generic->getSiteConfig("privateKey"), strlen($this->_generic->getSiteConfig("privateKey"))-3))), true)); } if (empty($controller)) array_push($errors, "You must fill the component controller name"); if (in_array($cache_visibility,array("public","private")) && (!is_numeric($cache_expiration) || $cache_expiration < 0)) array_push($errors, "Your expiration cache must be a positive time or 0"); $controller = str_replace(" ", "", ucwords(trim(SLS_String::getAlphaString($controller)))); $components = $this->_generic->recursiveReadDir($this->_generic->getPathConfig("componentsControllers"), array(), array(0=>"php")); foreach ($components as $component) { if (SLS_String::substrBeforeLastDelimiter(SLS_String::substrAfterLastDelimiter($component, "/"), ".controller.php") == $controller) { array_push($errors, "The name '".$controller."' is already in use for a component controller"); break; } } if (empty($errors)) { $strNewComponent = '<?php'."\n". '/**'."\n". '* Controller Component '.$controller.'Controller'."\n". '*'."\n". '* @author SillySmart'."\n". '* @copyright SillySmart'."\n". '* @package Mvc.Controllers.Components.'.$controller.'Controller'."\n". '* @see Sls.Controllers.Core.SLS_FrontComponent'."\n". '* @since 1.0'."\n". '*/'."\n". 'class '.$controller.'Controller extends SLS_FrontComponent implements SLS_IComponent '."\n". '{'."\n". ''."\n". t(1).'public function __construct()'."\n". t(1).'{'."\n". t(2).'parent::__construct(true);'."\n". t(1).'}'."\n". ''."\n". t(1).'public function constructXML()'."\n". t(1).'{'."\n". t(2).'// Write here all your instructions to make your Component configuration with xml by $this->_xmlToolBox'."\n". t(1).'}'."\n". ''."\n". '}'."\n". '?>'; file_put_contents($this->_generic->getPathConfig("componentsControllers").$controller.".controller.php", $strNewComponent); // Cache if (in_array($cache_visibility,array("public","private"))) { $this->_cache->addObject(strtolower($controller),"components",$cache_visibility,($cache_responsive=="true") ? "responsive" : "no_responsive",$cache_expiration); $this->_cache->saveObject(); } $this->_generic->forward('SLS_Bo', 'Controllers'); } if (!empty($errors)) { $xml->startTag("errors"); foreach ($errors as $error) $xml->addFullTag("error", $error, true); $xml->endTag("errors"); $xml->startTag('form'); $xml->addFullTag("controllerName", $controller); $xml->addFullTag("cache_visibility", $cache_visibility,true); $xml->addFullTag("cache_expiration", $cache_expiration,true); $xml->addFullTag("cache_responsive", $cache_responsive,true); $xml->endTag('form'); } } else { $xml->startTag('form'); $xml->addFullTag("controllerName", $controller,true); $xml->addFullTag("cache_visibility", "",true); $xml->addFullTag("cache_expiration", "0",true); $xml->addFullTag("cache_responsive", "",true); $xml->endTag('form'); } $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $sql = SLS_Sql::getInstance(); $dbs = $sql->getDbs(); $results = array(); $error = ""; $success = ""; $xml->startTag("dbs"); foreach($dbs as $db) $xml->addFullTag("db",$db,true); $xml->endTag("dbs"); if ($this->_http->getParam("reload") == "true") { $db = $this->_http->getParam("db"); $query = trim(SLS_String::trimSlashesFromString($this->_http->getParam("query"))); $sql->changeDb($db); switch($query) { case (SLS_String::startsWith(strtolower($query),"select") || SLS_String::startsWith(strtolower($query),"show") || SLS_String::startsWith(strtolower($query),"explain") || SLS_String::startsWith(strtolower($query),"describe")): $results = $sql->select($query); if ($results !== false) $success = count($results)." row(s) selected"; break; case (SLS_String::startsWith(strtolower($query),"insert")): $results = $sql->exec($query); if ($results !== false) $success = $results." row(s) inserted"; break; case (SLS_String::startsWith(strtolower($query),"update")): $results = $sql->update($query); if ($results !== false) $success = $results." row(s) updated"; break; case (SLS_String::startsWith(strtolower($query),"delete")): $results = $sql->delete($query); if ($results !== false) $success = $results." row(s) deleted"; break; default: $results = $sql->query($query); if ($results !== false) $success = $results; break; } if (!empty($success)) $xml->addFullTag("success",$success,true); if ($results === false) $xml->addFullTag("error","SQL syntax error",true); else if (!empty($results) && is_array($results)) { $xml->startTag("legends"); foreach($results[0] as $key => $value) $xml->addFullTag("legend",strtolower($key),true); $xml->endTag("legends"); $xml->startTag("results"); for($i=0 ; $i<$count=count($results) ; $i++) { $xml->startTag("result"); foreach($results[$i] as $key => $value) $xml->addFullTag(strtolower($key),$value,true); $xml->endTag("result"); } $xml->endTag("results"); } $xml->addFullTag("query",$query,true); } $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $langs = $this->_generic->getObjectLang()->getSiteLangs(); $listing = true; $errors = array(); $protocol = $this->_generic->getProtocol(); $siteXML = $this->_generic->getSiteXML(); $aliasesSelected = array(); $componentsSelected = array(); $plugin = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configPlugins")."/plugins.xml")); $pluginMobile = $plugin->getTag("//plugins/plugin[@code='mobile']"); $pluginMobile = (!empty($pluginMobile)) ? true : false; $controllersXML = $this->_generic->getControllersXML(); $controller = SLS_String::trimSlashesFromString($this->_http->getParam("Controller")); $controllers = $controllersXML->getTags("//controllers/controller[@side='user' and @name='".$controller."']"); if (count($controllers) == 1) { $controllerID = array_shift($controllersXML->getTags("//controllers/controller[@side='user' and @name='".$controller."']/@id")); $protocol = $this->_generic->getControllerProtocol($controllerID); $listing = false; $xml->addFullTag('request', 'AddAction', true); if ($this->_http->getParam('reload') == 'true') { // Get the form informations $newAction = SLS_String::stringToUrl(ucwords(SLS_String::trimSlashesFromString($this->_http->getParam("actionName"))), "", false); $needDynamic = SLS_String::trimSlashesFromString($this->_http->getParam("dynamic")); $needOffline = SLS_String::trimSlashesFromString($this->_http->getParam("offline")); $needDefault = SLS_String::trimSlashesFromString($this->_http->getParam("default")); $searchEngine = SLS_String::trimSlashesFromString($this->_http->getParam("indexes")); $postProtocol = SLS_String::trimSlashesFromString($this->_http->getParam("protocol")); $tpl = SLS_String::trimSlashesFromString($this->_http->getParam('template')); $aliases = SLS_String::trimSlashesFromString($this->_http->getParam('domains')); $components = SLS_String::trimSlashesFromString($this->_http->getParam('components')); $cache_visibility = SLS_String::trimSlashesFromString($this->_http->getParam('cache_visibility')); $cache_scope = SLS_String::trimSlashesFromString($this->_http->getParam('cache_scope')); $cache_expiration = SLS_String::trimSlashesFromString($this->_http->getParam('cache_expiration')); $cache_responsive = SLS_String::trimSlashesFromString($this->_http->getParam('cache_responsive')); if (empty($postProtocol)) $postProtocol = "http"; $postActionsLang = array(); $postTitlesLang = array(); $postDescriptionsLang = array(); $postKeywordsLang = array(); $toCache = (in_array($cache_visibility,array("public","private"))) ? true : false; // If responsive wanted if ($cache_responsive == "true" && !$pluginMobile) { // Force Mobile plugin download file_get_contents($this->_generic->getFullPath("SLS_Bo", "SearchPlugin", array("Action" => "Download", "Server" => "4", "Plugin" => "20", "token" => sha1(substr($this->_generic->getSiteConfig("privateKey"), 0, 3).substr($this->_generic->getSiteConfig("privateKey"), strlen($this->_generic->getSiteConfig("privateKey"))-3))), true)); } if (empty($newAction)) array_push($errors, "Action name can't be empty"); $actionExist = $controllersXML->getTags("//controllers/controller[@side='user' and @name='".$controller."']/scontrollers/scontroller[@name='".$newAction."']"); if (count($actionExist) == 0) { if (empty($postProtocol) || ($postProtocol != 'http' && $postProtocol != 'https')) array_push($errors, "Protocol must be http or https"); else $protocol = $postProtocol; if (!empty($aliases) && is_array($aliases)) foreach($aliases as $alias) array_push($aliasesSelected,$alias); if (!empty($components) && is_array($components)) foreach($components as $component) array_push($componentsSelected,$component); $siteLangs = $this->_generic->getObjectLang()->getSiteLangs(); foreach ($siteLangs as $lang) { // Check Url $postLang = trim(SLS_String::stringToUrl(SLS_String::trimSlashesFromString($this->_http->getParam(strtolower($lang)."-action")), "", false)); $translationExist = $controllersXML->getTags("//controllers/controller[@side='user' and @name='".$controller."']/scontrollers/scontroller/scontrollerLangs[scontrollerLang = '".$postLang."']"); if (empty($postLang)) array_push($errors, "You need to fill the ".$lang." url translations"); elseif(count($translationExist) != 0) array_push($errors, "You URL translation in ".$lang." is already in use on another action in the same controller"); else $postActionsLang[$lang] = $postLang; // Get Titles $postTitlesLang[$lang] = SLS_String::trimSlashesFromString($this->_http->getParam(strtolower($lang)."-title")); // Get Description $postDescriptionsLang[$lang] = SLS_String::trimSlashesFromString($this->_http->getParam(strtolower($lang)."-description")); // Get Keywords $postKeywordsLang[$lang] = SLS_String::trimSlashesFromString($this->_http->getParam(strtolower($lang)."-keywords")); } if ($toCache && (!is_numeric($cache_expiration) || $cache_expiration < 0)) array_push($errors, "Your expiration cache must be a positive time or 0"); if ($toCache && (!in_array($cache_scope,array("full","partial")))) array_push($errors, "Your must describe your cache scope"); if (count($errors) == 0) { // If an error existing and the controller directory wasn't created if (!is_dir($this->_generic->getPathConfig("actionsControllers").$controller)) mkdir($this->_generic->getPathConfig("actionsControllers").$controller); if (!is_file($this->_generic->getPathConfig("actionsControllers").$controller."/__".$controller.".protected.php")) { $strControllerProtected = '<?php'."\n". '/**'."\n". '* Class generic for the controller '.$newControllerName.''."\n". '* Write here all your generic functions you need in your '.$newControllerName.' Actions'."\n". '* @author SillySmart'."\n". '* @copyright SillySmart'."\n". '* @package Mvc.Controllers.'.$newControllerName.''."\n". '* @see Mvc.Controllers.SiteProtected'."\n". '* @see Sls.Controllers.Core.SLS_GenericController'."\n". '* @since 1.0'."\n". '*/'."\n". 'class '.$newControllerName.'ControllerProtected extends SiteProtected'."\n". '{'."\n". t(1).'public function init()'."\n". t(1).'{'."\n". t(2).'parent::init();'."\n". t(1).'}'."\n". '}'."\n". '?>'; file_put_contents($this->_generic->getPathConfig("actionsControllers").$controller."/__".$controller.".protected.php", $strControllerProtected); } // Create Controller File $strControllerAction = '<?php'."\n". '/**'."\n". '* Class '.$newAction.' into '.$controller.' Controller'."\n". '* @author SillySmart'."\n". '* @copyright SillySmart'."\n". '* @package Mvc.Controllers.'.$controller."\n". '* @see Mvc.Controllers.'.$controller.'.ControllerProtected'."\n". '* @see Mvc.Controllers.SiteProtected'."\n". '* @see Sls.Controllers.Core.SLS_GenericController'."\n". '* @since 1.0'."\n". '*'."\n". '*/'."\n". 'class '.$controller.$newAction.' extends '.$controller.'ControllerProtected'."\n". '{'."\n". t(1).'public function init()'."\n". t(1).'{'."\n". t(2).'parent::init();'."\n". t(1).'}'."\n\n". t(1).'public function action()'."\n". t(1).'{'."\n". t(2)."\n". t(1).'}'."\n". "}\n". '?>'; file_put_contents($this->_generic->getPathConfig("actionsControllers").$controller."/".$newAction.".controller.php", $strControllerAction); // Create Lang Files if (!is_dir($this->_generic->getPathConfig("langs")."Actions/".$controller)) mkdir($this->_generic->getPathConfig("langs")."Actions/".$controller); $langsFiles = array(); foreach ($siteLangs as $lang) { $strLang = '<?php'."\n". '/**'."\n". '* '.strtoupper($lang).' File for the action '.$newAction.' into '.$controller.' Controller'."\n". '* You can create all your sentences variables here. To create it, follow the exemple :'."\n". '* '."\t".'Access it with JS and XSL variable : $GLOBALS[$GLOBALS[\'PROJECT_NAME\']][\'JS\'][\'KEY_OF_YOUR_VARIABLE\'] = "value of your sentence in '.strtoupper($lang).'";'."\n". '* '."\t".'Access it with XSL variable only : $GLOBALS[$GLOBALS[\'PROJECT_NAME\']][\'XSL\'][\'KEY_OF_YOUR_VARIABLE\'] = "value of your sentence in '.strtoupper($lang).'";'."\n". '*'."\n". '* '."\t".'You can customise the value \'KEY_OF_YOUR_VARIABLE\' and "value of your sentence in '.strtoupper($lang).'" '."\n". '* @author SillySmart'."\n". '* @copyright SillySmart'."\n". '* @package Langs.Actions.'.$controller."\n". '* @since 1.0'."\n". '*'."\n". '*/'."\n". '?>'; file_put_contents($this->_generic->getPathConfig("langs")."Actions/".$controller."/".$newAction.".".strtolower($lang).".lang.php", $strLang); } // Create Views File if (!is_dir($this->_generic->getPathConfig("viewsBody").$controller)) mkdir($this->_generic->getPathConfig("viewsBody").$controller); if (!is_dir($this->_generic->getPathConfig("viewsHeaders").$controller)) mkdir($this->_generic->getPathConfig("viewsHeaders").$controller); $strBody = '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl" xmlns="http://www.w3.org/1999/xhtml">'."\n". t(1).'<xsl:template name="'.$newAction.'">'."\n". t(2).'<h1>Customize the body of this page in <i>'.$this->_generic->getPathConfig('viewsBody').$controller.'/'.$newAction.'.xsl</i></h1>'."\n". t(2).'<h2>And your headers in <i>'.$this->_generic->getPathConfig('viewsHeaders').$controller.'/'.$newAction.'.xsl</i></h2>'."\n". t(1).'</xsl:template>'."\n". '</xsl:stylesheet>'; $strHeader = '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl" xmlns="http://www.w3.org/1999/xhtml">'."\n". t(1).'<xsl:template name="Header'.$newAction.'">'."\n". t(1).'</xsl:template>'."\n". '</xsl:stylesheet>'; file_put_contents($this->_generic->getPathConfig("viewsBody").$controller.'/'.$newAction.'.xsl', $strBody); file_put_contents($this->_generic->getPathConfig("viewsHeaders").$controller.'/'.$newAction.'.xsl', $strHeader); // End of files creation // XML Modifications $metasXML = $this->_generic->getCoreXML('metas'); // Get the titles // If default, reset other in current controller if (!empty($needDefault)) { $actions = $controllersXML->getTags("//controllers/controller[@side='user' and @name='".$controller."']/scontrollers/scontroller/@id"); foreach($actions as $curActionId) $controllersXML->setTagAttributes("//controllers/controller[@side='user' and @name='".$controller."']/scontrollers/scontroller[@id='".$curActionId."']", array('default' => '0')); } $actionId = $this->_generic->generateActionId(); $xmlAction = "<scontroller name=\"".$newAction."\" needParam=\""; $xmlAction .= ($this->_http->getParam("dynamic") == "on") ? "1" : "0"; $xmlAction .= "\" id=\"".$actionId."\" protocol=\"".$protocol."\""; if ($tpl != -1) $xmlAction .= " tpl=\"".$tpl."\""; if (!empty($aliases)) $xmlAction .= " domains=\"".implode(",",$aliases)."\""; if (!empty($components)) $xmlAction .= " components=\"".implode(",",$components)."\""; if (!empty($needOffline)) $xmlAction .= " disable=\"1\""; if (!empty($needDefault)) $xmlAction .= " default=\"1\""; if ($toCache) $xmlAction .= " cache=\"".$cache_visibility."|".$cache_scope."|".(($cache_responsive == "true") ? "responsive" : "no_responsive")."|".$cache_expiration."\""; $xmlAction .= "><scontrollerLangs>"; $strMetas = "<action id=\"".$actionId."\" />"; $metasXML->appendXMLNode("//sls_configs", $strMetas); foreach ($siteLangs as $lang) { $xmlAction .= "<scontrollerLang lang=\"".$lang."\"><![CDATA[".$postActionsLang[$lang]."]]></scontrollerLang>"; // Metas $metas = "<title lang=\"".$lang."\"><![CDATA[".$postTitlesLang[$lang]."]]></title>"; $metas .= "<description lang=\"".$lang."\"><![CDATA[".$postDescriptionsLang[$lang]."]]></description>"; $metas .= "<keywords lang=\"".$lang."\"><![CDATA[".$postKeywordsLang[$lang]."]]></keywords>"; $metasXML->appendXMLNode("//sls_configs/action[@id=\"".$actionId."\"]", $metas); } $xmlAction .= "</scontrollerLangs></scontroller>"; if (!SLS_String::contains($searchEngine,", ")) $searchEngine = str_replace(",",", ",$searchEngine); if ($searchEngine != "index, follow" && $searchEngine != "noindex, follow" && $searchEngine != "noindex, nofollow" && $searchEngine != "index, nofollow") $searchEngine = "index, follow"; $metasXML->appendXMLNode("//sls_configs/action[@id='".$actionId."']", "<robots><![CDATA[".$searchEngine."]]></robots>"); $controllersXML->appendXMLNode("//controllers/controller[@side='user' and @name='".$controller."']/scontrollers", $xmlAction); file_put_contents($this->_generic->getPathConfig("configSecure")."controllers.xml", $controllersXML->getXML()); file_put_contents($this->_generic->getPathConfig("configSls")."metas.xml", $metasXML->getXML()); $controllers = $this->_generic->getTranslatedController("SLS_Bo", "Controllers"); $this->_generic->redirect($controllers['controller']."/".$controllers['scontroller'].".sls"); } } else array_push($errors, "This generic name is already in use for this controller"); if (!empty($errors)) { $xml->startTag("errors"); foreach ($errors as $error) $xml->addFullTag("error", $error, true); $xml->endTag("errors"); $xml->startTag('form'); $xml->addFullTag("controllerName", $postControllerName); foreach ($postActionsLang as $key=>$value) $xml->addFullTag($key."-action", $value, true); $xml->endTag('form'); $xml->addFullTag("default",(empty($needDefault)) ? "false" : "true",true); $xml->addFullTag("dynamic",(empty($needDynamic)) ? "false" : "true",true); $xml->addFullTag("offline",(empty($needOffline)) ? "false" : "true",true); $xml->startTag("cache"); $xml->addFullTag("cache_visibility", $cache_visibility,true); $xml->addFullTag("cache_scope", $cache_scope,true); $xml->addFullTag("cache_responsive", $cache_responsive,true); $xml->addFullTag("cache_expiration", $cache_expiration,true); $xml->endTag("cache"); } } else { $defaultExists = $controllersXML->getTag("//controllers/controller[@name='".$controller."']/scontrollers/scontroller[@default='1']/@name"); $xml->addFullTag("default",(empty($defaultExists)) ? "true" : "false",true); $xml->startTag("cache"); $xml->addFullTag("cache_visibility", "",true); $xml->addFullTag("cache_scope", "",true); $xml->addFullTag("cache_responsive","",true); $xml->addFullTag("cache_expiration", 0,true); $xml->endTag("cache"); } // Build all tpls $tpls = $this->getAppTpls(); $xml->startTag("tpls"); foreach($tpls as $template) $xml->addFullTag("tpl",$template,true); $xml->endTag("tpls"); $xml->startTag('controller'); $xml->addFullTag("name", $controller, true); $xml->startTag('translations'); foreach ($langs as $lang) { $xml->startTag('translation'); $xml->addFullTag("lang", $lang, true); $xml->addFullTag("name", $controllersXML->getTag("//controllers/controller[@name='".$controller."' and @side='user']/controllerLangs/controllerLang[@lang='".$lang."']"), true); $xml->endTag('translation'); } $xml->endTag('translations'); $xml->endTag('controller'); $xml->addFullTag('request', 'addAction', true); } else { $this->_generic->dispatch('SLS_Bo', 'Controllers'); } if (empty($tpl)) $tpl = $controllersXML->getTag("//controllers/controller[@name='".$controller."' and @side='user']/@tpl"); $xml->addFullTag('protocol', $protocol, true); $xml->addFullTag('template', $tpl, true); $aliases = $siteXML->getTagsAttributes("//configs/domainName/domain",array("alias")); $xml->startTag("aliases"); for($i=0 ; $i<$count=count($aliases) ; $i++) { $xml->startTag("alias"); $xml->addFullTag("name",$aliases[$i]["attributes"][0]["value"],true); $xml->addFullTag("selected",(in_array($aliases[$i]["attributes"][0]["value"],$aliasesSelected)) ? "true" : "false",true); $xml->endTag("alias"); } $xml->endTag("aliases"); $components = $this->_generic->recursiveReadDir($this->_generic->getPathConfig("componentsControllers"), array(), array(0=>"php")); $xml->startTag("components"); foreach ($components as $component) { $xml->startTag("component"); $xml->addFullTag("name", SLS_String::substrBeforeFirstDelimiter(SLS_String::substrAfterLastDelimiter($component, "/"), ".controller.php"),true); $xml->addFullTag("selected",(in_array(SLS_String::substrBeforeFirstDelimiter(SLS_String::substrAfterLastDelimiter($component, "/"), ".controller.php"),$componentsSelected)) ? "true" : "false",true); $xml->endTag("component"); } $xml->endTag("components"); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $siteXML = $this->_generic->getSiteXML(); $errors = array(); $aliases = array(); $domains = array(); // Prod Deployment $env = $this->_http->getParam("Env"); if (empty($env)) $env = "prod"; $finalFile = ($this->_http->getParam("ProdDeployment") == "true") ? "site_".$env.".xml" : "site.xml"; $isInBatch = ($this->_http->getParam("CompleteBatch") == "true") ? true : false; $xml->addFullTag("is_batch",($isInBatch) ? "true" : "false",true); $xml->addFullTag("is_prod",($this->_http->getParam("ProdDeployment") == "true") ? "true" : "false",true); $xml->addFullTag("env",$env,true); // Get default values if ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/site_".$env.".xml")) { $xmlSite = new SLS_XMLToolbox(file_get_contents($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/site_".$env.".xml")); $defaultDomain = $xmlSite->getTag("//configs/domainName/domain"); $defaultProject = $xmlSite->getTag("//configs/projectName"); $defaultVersion = $xmlSite->getTag("//configs/versionName"); $defaultExtension = $xmlSite->getTag("//configs/defaultExtension"); $defaultCharset = $xmlSite->getTag("//configs/defaultCharset"); $defaultDoctype = $xmlSite->getTag("//configs/defaultDoctype"); $timezone_area = SLS_String::substrBeforeFirstDelimiter($xmlSite->getTag("//configs/defaultTimezone"),"/"); $timezone_city = SLS_String::substrAfterFirstDelimiter($xmlSite->getTag("//configs/defaultTimezone"),"/"); $defaultLang = $xmlSite->getTag("//configs/defaultLang"); $defaultdomainSessionShare = $xmlSite->getTag("//configs/domainSession"); } else { $defaultDomain = $this->_generic->getSiteConfig("domainName"); $defaultProject = $this->_generic->getSiteConfig("projectName"); $defaultVersion = $this->_generic->getSiteConfig("versionName"); $defaultExtension = $this->_generic->getSiteConfig("defaultExtension"); $defaultCharset = $this->_generic->getSiteConfig("defaultCharset"); $defaultDoctype = $this->_generic->getSiteConfig("defaultDcotype"); $timezone_area = SLS_String::substrBeforeFirstDelimiter($this->_generic->getSiteConfig("defaultTimezone"),"/"); $timezone_city = SLS_String::substrAfterFirstDelimiter($this->_generic->getSiteConfig("defaultTimezone"),"/"); $defaultLang = $this->_generic->getSiteConfig("defaultLang"); $defaultdomainSessionShare = $this->_generic->getSiteConfig("domainSession"); } $reload = $this->_http->getParam("reload"); $charsetsXML = new SLS_XMLToolBox(file_get_contents($this->_generic->getPathConfig('configSls')."charset.xml")); $charsets = array_map('strtoupper', $charsetsXML->getTags('//sls_configs/charset/code')); $handle2 = file_get_contents($this->_generic->getPathConfig("configSls").'timezone.xml'); $xml->addFullTag("timezones", SLS_String::substrBeforeLastDelimiter(SLS_String::substrAfterFirstDelimiter($handle2, "<sls_configs>"), "</sls_configs>"), false); $langs = $this->_generic->getSiteXML()->getTags('//configs/langs/name'); if ($reload == "true") { $domains = $siteXML->getTagsAttributes("//configs/domainName/domain",array("alias")); for($i=0 ; $i<$count=count($domains) ; $i++) array_push($aliases,$domains[$i]["attributes"][0]["value"]); // Get New Parameters $exportConfig = $this->_http->getParam('export'); $domains = array(); foreach($aliases as $alias) { $domain = SLS_String::trimSlashesFromString($this->_http->getParam("domain_".$alias, "post")); if (SLS_String::endsWith(trim($domain),"/")) $domain = SLS_String::substrBeforeLastDelimiter(trim($domain),"/"); $domains[$alias]= $domain; } $postProject = SLS_String::trimSlashesFromString($this->_http->getParam("project", "post")); $postVersion = SLS_String::trimSlashesFromString($this->_http->getParam("version", "post")); $postExtension = SLS_String::trimSlashesFromString($this->_http->getParam("extension", "post")); $postCharset = SLS_String::trimSlashesFromString($this->_http->getParam("charset", "post")); $postDoctype = SLS_String::trimSlashesFromString($this->_http->getParam("doctype", "post")); $timezone_area = SLS_String::trimSlashesFromString($this->_http->getParam('settings_timezone_area')); $timezone_city = SLS_String::trimSlashesFromString($this->_http->getParam('settings_timezone_area_'.$timezone_area)); $postLang = SLS_String::trimSlashesFromString($this->_http->getParam("lang", "post")); $domainSessionShare = SLS_String::trimSlashesFromString($this->_http->getParam("domainSession", "post")); if ($this->_http->getParam("domainSessionActive") == "") $domainSessionShare = ""; foreach($domains as $alias => $domain) if (empty($domain)) array_push($errors, "The Domain name is required for the domain alias ".$alias); if (empty($postProject)) array_push($errors, "The project Name is required"); if (empty($postVersion)) array_push($errors, "The version Name is required"); if (empty($postExtension)) array_push($errors, "The extension is required"); if (!in_array($postCharset, $charsets)) array_push($errors, "The Charset selected is incorrect"); if (empty($postDoctype)) array_push($errors, "The doctype is required"); if (empty($timezone_area) || empty($timezone_city)) array_push($errors,"You must choose your default timezone"); if (!in_array($postLang, $langs)) array_push($errors, "The Default lang selected is incorrect"); if ($this->_http->getParam("domainSessionActive") != "" && empty($domainSessionShare)) array_push($errors,"You need to fill the domain pattern from which you want to share session"); if (empty($errors)) { foreach($domains as $alias => $domain) $siteXML->setTag("//configs/domainName/domain[@alias='".$alias."']", $domain, true); if ($defaultProject != $postProject) $siteXML->setTag("//configs/projectName", $postProject, true); if ($defaultVersion != $postVersion) $siteXML->setTag("//configs/versionName", $postVersion, true); if ($defaultExtension != $postExtension) $siteXML->setTag("//configs/defaultExtension", $postExtension, true); if ($defaultCharset != $postCharset) $siteXML->setTag("//configs/defaultCharset", $postCharset, true); if ($defaultDoctype != $postDoctype) $siteXML->setTag("//configs/defaultDoctype", $postDoctype, true); if ($defaultTimezone != $timezone_area."/".$timezone_city) $siteXML->setTag("//configs/defaultTimezone", $timezone_area."/".$timezone_city, true); if ($defaultLang != $postLang) $siteXML->setTag("//configs/defaultLang", $postLang, true); if ($defaultdomainSessionShare != $domainSessionShare) $siteXML->setTag("//configs/domainSession", $domainSessionShare, true); if ($exportConfig == "on") { $date = gmdate('D, d M Y H:i:s'); header("Content-Type: text/xml"); header('Content-Disposition: attachment; filename='.$finalFile); header('Last-Modified: '.$date. ' GMT'); header('Expires: ' .$date); // For This F**k'in Browser if(preg_match('/msie|(microsoft internet explorer)/i', $_SERVER['HTTP_USER_AGENT'])) { header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else header('Pragma: no-cache'); print($siteXML->getXML()); exit; } else { $siteXML->refresh(); @file_put_contents($this->_generic->getPathConfig("configSecure").$finalFile, $siteXML->getXML()); if ($isInBatch) $this->_generic->forward("SLS_Bo","DataBaseSettings",array(array("key"=>"ProdDeployment","value"=>"true"),array("key"=>"CompleteBatch","value"=>"true"),array("key"=>"Env","value"=>$env))); else if ($this->_http->getParam("ProdDeployment") == "true") $this->_generic->forward("SLS_Bo","ProductionDeployment"); } } else { $xml->startTag('errors'); foreach ($errors as $error) $xml->addFullTag('error', $error); $xml->endTag('errors'); } } $this->_generic->eraseCache('Site'); $xml->startTag("charsets"); foreach ($charsets as $charset) $xml->addFullTag('charset', $charset, true); $xml->endTag("charsets"); $xml->startTag("langs"); foreach ($langs as $lang) $xml->addFullTag('lang', $lang, true); $xml->endTag("langs"); $xmlSite = (file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/site_".$env.".xml")) ? new SLS_XMLToolbox(file_get_contents($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/site_".$env.".xml")) : null; $xml->startTag("current_values"); if ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/site_".$env.".xml")) $domains = $xmlSite->getTagsAttributes("//configs/domainName/domain",array("alias","default","lang")); else $domains = $siteXML->getTagsAttributes("//configs/domainName/domain",array("alias","default","lang")); $xml->startTag("domains"); for($i=0 ; $i<$count=count($domains) ; $i++) { $alias = $domains[$i]["attributes"][0]["value"]; $default = ($domains[$i]["attributes"][1]["value"] == 1) ? true : false; $domain_lang = $domains[$i]["attributes"][2]["value"]; $xml->startTag("domain"); $xml->addFullTag("alias",$alias,true); $xml->addFullTag("default",($default) ? "true" : "false",true); $xml->addFullTag("domain",$domains[$i]["value"],true); $xml->addFullTag("lang",$domain_lang,true); $xml->addFullTag("delete_url",$this->_generic->getFullPath("SLS_Bo","DeleteDomain",array(array("key"=>"alias","value"=>$alias))),true); $xml->endTag("domain"); } $xml->endTag("domains"); $xml->addFullTag("project", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/site_".$env.".xml")) ? $xmlSite->getTag("//configs/projectName") : $this->_generic->getSiteConfig("projectName"), true); $xml->addFullTag("version", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/site_".$env.".xml")) ? $xmlSite->getTag("//configs/versionName") : $this->_generic->getSiteConfig("versionName"), true); $xml->addFullTag("extension", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/site_".$env.".xml")) ? $xmlSite->getTag("//configs/defaultExtension") :$this->_generic->getSiteConfig("defaultExtension"), true); $xml->addFullTag("charset", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/site_".$env.".xml")) ? $xmlSite->getTag("//configs/defaultCharset") :$this->_generic->getSiteConfig("defaultCharset"), true); $xml->addFullTag("doctype", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/site_".$env.".xml")) ? $xmlSite->getTag("//configs/defaultDoctype") :$this->_generic->getSiteConfig("defaultDoctype"), true); $xml->addFullTag("lang", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/site_".$env.".xml")) ? $xmlSite->getTag("//configs/defaultLang") :$this->_generic->getSiteConfig("defaultLang"), true); $xml->addFullTag("domain_session", ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/site_".$env.".xml")) ? $xmlSite->getTag("//configs/domainSession") : ((is_null($this->_generic->getSiteConfig("domainSession"))) ? "" : $this->_generic->getSiteConfig("domainSession")), true); $xml->startTag("timezone"); $xml->addFullTag("area",$timezone_area,true); $xml->addFullTag("city",$timezone_city,true); $xml->endTag("timezone"); $xml->endTag("current_values"); $xml->addFullTag("add_domain_url",$this->_generic->getFullPath("SLS_Bo","AddDomain"),true); $environments = $this->getEnvironments(); $xml->startTag("environments"); foreach($environments as $environment) $xml->addFullTag("environment",$environment,true); $xml->endTag("environments"); $this->saveXML($xml); }
/** * Action Home * */ public function action() { $this->secureURL(); $this->_generic->registerLink('GlobalSettings', 'SLS_Init', 'GlobalSettings'); $handle = file_get_contents($this->_generic->getPathConfig("configSls").'charset.xml'); $handle2 = file_get_contents($this->_generic->getPathConfig("configSls").'timezone.xml'); $xml = $this->getXML(); $xml->addFullTag("charsets", SLS_String::substrBeforeLastDelimiter(SLS_String::substrAfterFirstDelimiter($handle, "<sls_configs>"), "</sls_configs>"), false); $xml->addFullTag("timezones", SLS_String::substrBeforeLastDelimiter(SLS_String::substrAfterFirstDelimiter($handle2, "<sls_configs>"), "</sls_configs>"), false); $errors = array(); $domain = SLS_String::trimSlashesFromString($this->_http->getParam('settings_domain')); $protocol = SLS_String::trimSlashesFromString($this->_http->getParam('settings_protocol')); $project = SLS_String::trimSlashesFromString($this->_http->getParam('settings_project')); $description = SLS_String::trimSlashesFromString($this->_http->getParam('settings_description')); $keywords = SLS_String::trimSlashesFromString($this->_http->getParam('settings_keywords')); $author = SLS_String::trimSlashesFromString($this->_http->getParam('settings_author')); $copyright = SLS_String::trimSlashesFromString($this->_http->getParam('settings_copyright')); $extension = ($this->_http->getParam('settings_extension') == "") ? "sls" : SLS_String::trimSlashesFromString($this->_http->getParam('settings_extension')); $charset = SLS_String::trimSlashesFromString($this->_http->getParam('settings_charset')); $doctype = SLS_String::trimSlashesFromString($this->_http->getParam('settings_doctype')); $bo = SLS_String::trimSlashesFromString($this->_http->getParam('settings_bo')); $timezone_area = SLS_String::trimSlashesFromString($this->_http->getParam('settings_timezone_area')); $timezone_city = SLS_String::trimSlashesFromString($this->_http->getParam('settings_timezone_area_'.$timezone_area)); $xmlTmp = new SLS_XMLToolbox($handle); $allowedCharsets = $xmlTmp->getTags("//sls_configs/charset/code"); if ($this->_http->getParam('globalSettings_reload') == "true") { if (empty($domain)) array_push($errors,"You must fill your main domain name"); if ($protocol != 'http' && $protocol != 'https') array_push($errors,"You must choose a correct Protocol"); if (empty($project)) array_push($errors,"You must fill your project name"); if (empty($description)) array_push($errors,"You must fill your project description"); if (empty($author)) $author = $project; if (empty($copyright)) $copyright = $domain; if (empty($extension)) array_push($errors,"You must fill your default extension"); if (empty($bo)) array_push($errors,"You must fill your access to your SillySmart's Back-Office"); if (!in_array($charset,$allowedCharsets)) array_push($errors,"You must choose a valid charset"); if (empty($doctype)) array_push($errors,"You must choose your default doctype"); if (empty($timezone_area) || empty($timezone_city)) array_push($errors,"You must choose your default timezone"); if (empty($errors)) { $key = substr(md5($domain).sha1($project).uniqid(microtime()),mt_rand(5,10),mt_rand(20,32)); $coreXml = $this->_generic->getSiteXML(); $coreXml->setTag('//configs/domainName', "<domain alias='__default' default='1' js='true' isSecure='false' lang=''><![CDATA[".$domain."]]></domain>", false); $coreXml->setTag('//configs/protocol',$protocol); $coreXml->setTag('//configs/defaultExtension',$extension); $coreXml->setTag('//configs/projectName',$project); $coreXml->setTag('//configs/versionName',date("Ymd")."-dev"); $coreXml->setTag('//configs/metaDescription',$description); $coreXml->setTag('//configs/metaKeywords',$keywords); $coreXml->setTag('//configs/metaAuthor',$author); $coreXml->setTag('//configs/metaCopyright',$copyright); $coreXml->setTag('//configs/privateKey',$key); $coreXml->setTag('//configs/defaultCharset',strtoupper($charset)); $coreXml->setTag('//configs/defaultDoctype',$doctype); $coreXml->setTag('//configs/defaultTimezone',$timezone_area."/".$timezone_city); file_put_contents($this->_generic->getPathConfig("configSecure")."site.xml", $coreXml->getXML()); $controllersXml = $this->_generic->getControllersXML(); $controllersXml->setTag("//controllers/controller[@name='SLS_Bo']/controllerLangs/controllerLang",$bo); $uniqs = array(); $metas = array(); // Generate Controllers IDS $slsControllers = $controllersXml->getTags("//controllers/controller[@side='sls']/@name"); $slsLangs = $controllersXml->getTags("//controllers/controller[@side='sls'][1]/scontrollers/scontroller[1]/scontrollerLangs/scontrollerLang/@lang"); foreach ($slsControllers as $slsController) { // Take a random id and set it $uniq = uniqid("c_"); while(in_array($uniq, $uniqs)) $uniq = uniqid("c_"); array_push($uniqs, $uniq); $controllersXml->setTagAttributes("//controllers/controller[@name='".$slsController."' and @side='sls']", array("id"=>$uniq)); // Generate Actions IDS $slsActions = $controllersXml->getTags("//controllers/controller[@side='sls' and @name='".$slsController."']/scontrollers/scontroller/@name"); foreach ($slsActions as $slsAction) { // Take a random id and set it $uniq = uniqid("a_"); while(in_array($uniq, $uniqs)) $uniq = uniqid("a_"); array_push($uniqs, $uniq); $controllersXml->setTagAttributes("//controllers/controller[@name='".$slsController."' and @side='sls']/scontrollers/scontroller[@name='".$slsAction."']", array("id"=>$uniq)); // Get title attribute, save it into array and delete this attribute $tmpArray = array(); foreach ($slsLangs as $lang) { $tmpArray[$lang] = array_shift($controllersXml->getTags("//controllers/controller[@name='".$slsController."' and @side='sls']/scontrollers/scontroller[@name='".$slsAction."']/scontrollerLangs/scontrollerLang[@lang='".$lang."']/@title")); $controllersXml->deleteTagAttribute("//controllers/controller[@name='".$slsController."' and @side='sls']/scontrollers/scontroller[@name='".$slsAction."']/scontrollerLangs/scontrollerLang[@lang='".$lang."']","title"); } $metas[$uniq] = $tmpArray; } } // Update metas.xml $metaXml = ''; foreach($metas as $key => $value) { $metaXml .= '<action id="'.$key.'">'; foreach ($value as $lang => $title) $metaXml .= '<title lang="'.$lang.'"><![CDATA['.$title.']]></title>'; $metaXml .= '<robots><![CDATA[noindex, nofollow]]></robots>'; $metaXml .= '</action>'; } $metaO = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."metas.xml")); $metaO->appendXML("//sls_configs",$metaXml); $metaO->saveXML($this->_generic->getPathConfig("configSls")."metas.xml"); // Overwrite template __default $this->createXslTemplate("__default",$doctype); file_put_contents($this->_generic->getPathConfig("configSecure")."controllers.xml", $controllersXml->getXML()); $this->setInstallationStep(array(0=>"SLS_Init",1=>"Initialization"), array(0=>"International",1=>"International")); return $this->_generic->dispatch("SLS_Init", "International"); } else { $xml->startTag("errors"); foreach ($errors as $error) $xml->addFullTag("error", $error, true); $xml->endTag("errors"); $xml->addFullTag("domain",$domain,true); $xml->addFullTag("protocol",$protocol,true); $xml->addFullTag("project",$project,true); $xml->addFullTag("description",$description,true); $xml->addFullTag("keywords",$keywords,true); $xml->addFullTag("author",$author,true); $xml->addFullTag("copyright",$copyright,true); $xml->addFullTag("extension",$extension,true); $xml->addFullTag("charset",$charset,true); $xml->addFullTag("doctype",$doctype,true); $xml->addFullTag("bo",$bo,true); $xml->startTag("timezone"); $xml->addFullTag("area",$timezone_area,true); $xml->addFullTag("city",$timezone_city,true); $xml->endTag("timezone"); } } else { $timezone = date_default_timezone_get(); $xml->addFullTag("domain",$_SERVER['HTTP_HOST'].(($_SERVER['SCRIPT_NAME'] != "/index.php") ? SLS_String::substrBeforeFirstDelimiter($_SERVER['SCRIPT_NAME'],"/index.php") : ""),true); $xml->addFullTag("protocol",(SLS_String::startsWith($_SERVER['SERVER_PROTOCOL'],'HTTPS')) ? 'https' : 'http',true); $xml->addFullTag("author","SillySmart",true); $xml->addFullTag("extension","sls",true); $xml->startTag("timezone"); $xml->addFullTag("area",(empty($timezone) || !SLS_String::contains($timezone,'/')) ? 'Europe' : SLS_String::substrBeforeFirstDelimiter($timezone,'/'),true); $xml->addFullTag("city",(empty($timezone) || !SLS_String::contains($timezone,'/')) ? 'Paris' : SLS_String::substrAfterFirstDelimiter($timezone,'/'),true); $xml->endTag("timezone"); $xml->addFullTag("bo","Manage",true); } $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $sql = SLS_Sql::getInstance(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $errors = array(); // Get the table name $table = SLS_String::substrAfterFirstDelimiter($this->_http->getParam("name"),"_"); $db = SLS_String::substrBeforeFirstDelimiter($this->_http->getParam("name"),"_"); $column= $this->_http->getParam("column"); $class = ucfirst($db)."_".SLS_String::tableToClass($table); $file = ucfirst($db).".".SLS_String::tableToClass($table); // If current db is not this one if ($sql->getCurrentDb() != $db) $sql->changeDb($db); if ($sql->tableExists($table)) { if ($this->_http->getParam("reload") == "true") { $replacements = array('&','>','<','=','"',"'"); $masks = array('&','>','<','=','','',''); $columnWanted = $this->_http->getParam("column"); $tableWanted = $this->_http->getParam("table"); $labelWanted = $this->_http->getParam($tableWanted.'_fkLabel'); $labelSpecified = SLS_String::trimSlashesFromString($this->_http->getParam("fkLabel_specified")); $multilang = $this->_http->getParam("multilanguage"); $onDelete = $this->_http->getParam("ondelete"); $pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml"); $xmlFk = new SLS_XMLToolbox($pathsHandle); $pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/types.xml"); $xmlType = new SLS_XMLToolbox($pathsHandle); $pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/filters.xml"); $xmlFilter = new SLS_XMLToolbox($pathsHandle); if (!empty($labelSpecified)) $labelSpecified = str_replace(array('='),array('='),htmlentities(strtolower($labelSpecified),ENT_QUOTES,"UTF-8")); $result = $xmlFk->getTags("//sls_configs/entry[@tableFk='".$db."_".$table."' and @columnFk='".$columnWanted."' and @tablePk='".$tableWanted."']"); // If an entry already exists in the XML, delete this record if (!empty($result)) { $xmlTmp = $xmlFk->deleteTags("//sls_configs/entry[@tableFk='".$db."_".$table."' and @columnFk='".$columnWanted."' and @tablePk='".$tableWanted."']"); $xmlFk->saveXML($this->_generic->getPathConfig("configSls")."/fks.xml",$xmlTmp); $pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml"); $xmlFk = new SLS_XMLToolbox($pathsHandle); } // Save it into the XML $xmlNode = '<entry tableFk="'.$db."_".$table.'" columnFk="'.$columnWanted.'" multilanguage="'.$multilang.'" ondelete="'.$onDelete.'" labelPk="'.(empty($labelSpecified) ? $labelWanted : $labelSpecified).'" tablePk="'.$tableWanted.'" />'; $xmlFk->appendXMLNode("//sls_configs",$xmlNode); $xmlFk->saveXML($this->_generic->getPathConfig("configSls")."/fks.xml",$xmlFk->getXML()); // Update model $this->_generic->goDirectTo("SLS_Bo","UpdateModel",array(array("key"=>"name","value"=>$this->_http->getParam("name")))); } // Get generic object $this->_generic->useModel(SLS_String::tableToClass($table),$db,"user"); $object = new $class(); // Get object's infos $pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml"); $xmlFk = new SLS_XMLToolbox($pathsHandle); $columnsP = $object->getParams(); $pk = $object->getPrimaryKey(); $multilanguage = $object->isMultilanguage(); $xml->startTag("model"); $xml->addFullTag("table",$table,true); $xml->addFullTag("db",$db,true); $xml->addFullTag("class",$class,true); $xml->addFullTag("pk",$pk,true); $xml->addFullTag("multilanguage",($multilanguage) ? "true" : "false",true); $xml->startTag("columns"); foreach($columnsP as $key => $value) { if ($object->getPrimaryKey() != $key && $key != "pk_lang") $xml->addFullTag("column",$key,true); } $xml->endTag("columns"); $attributes = array_shift($xmlFk->getTagsAttributes("//sls_configs/entry[@tableFk='".strtolower($db."_".$table)."' and @ columnFk='".$column."']",array("multilanguage","labelPk","tablePk","ondelete"))); $this->_generic->useModel(SLS_String::substrAfterFirstDelimiter($attributes["attributes"][2]["value"],"_"),ucfirst(SLS_String::substrBeforeFirstDelimiter($attributes["attributes"][2]["value"],"_")),"user"); $className = ucfirst($attributes["attributes"][2]["value"]); $objectN = new $className(); $columns = $objectN->getColumns(); $specificPattern = true; foreach($columns as $key) if ($key == $attributes["attributes"][1]["value"]) $specificPattern = false; $xml->startTag("current_values"); $xml->addFullTag("tableFk",$db."_".SLS_String::tableToClass($table),true); $xml->addFullTag("columnFk",$column,true); $xml->addFullTag("multilanguage",$attributes["attributes"][0]["value"],true); $xml->addFullTag("labelPk",$attributes["attributes"][1]["value"],true); $xml->addFullTag("tablePk",$attributes["attributes"][2]["value"],true); $xml->addFullTag("ondelete",$attributes["attributes"][3]["value"],true); $xml->addFullTag("specific_pattern",($specificPattern) ? "true" : "false",true); $xml->endTag("current_values"); $tables = $this->getAllModels(); sort($tables,SORT_REGULAR); $xml->startTag("tables"); for($i=0 ; $i<$count=count($tables) ; $i++) { if (SLS_String::startsWith($tables[$i],$db)) { $xml->startTag("table"); $xml->addFullTag("name",SLS_String::substrAfterFirstDelimiter($tables[$i],".")); $xml->addFullTag("db",SLS_String::substrBeforeFirstDelimiter($tables[$i],".")); $tableN = SLS_String::substrAfterFirstDelimiter($tables[$i],"."); $dbN = SLS_String::substrBeforeFirstDelimiter($tables[$i],"."); $classN = ucfirst($dbN)."_".SLS_String::tableToClass($tableN); $this->_generic->useModel($tableN,$dbN,"user"); $obj = new $classN(); $properties = $obj->getParams(); $xml->startTag("columns"); foreach($properties as $key => $value) if ($key != "pk_lang") $xml->addFullTag("column",$key,true); $xml->endTag("columns"); $xml->endTag("table"); } } $xml->endTag("tables"); $xml->endTag("model"); } else { $xml->addFullTag("error","Sorry this table doesn't exist anymore",true); } $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $langs = $this->_generic->getObjectLang()->getSiteLangs(); $errors = array(); $siteXML = $this->_generic->getSiteXML(); $aliasesSelected = array(); $componentsSelected = array(); $plugin = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configPlugins")."/plugins.xml")); $pluginMobile = $plugin->getTag("//plugins/plugin[@code='mobile']"); $pluginMobile = (!empty($pluginMobile)) ? true : false; $controllersXML = $this->_generic->getControllersXML(); $metasXML = $this->_generic->getCoreXML('metas'); $controller = $this->_http->getParam('Controller'); $action = $this->_http->getParam('Action'); $actionExist = $controllersXML->getTags("//controllers/controller[@name='".$controller."' and @side='user']/scontrollers/scontroller[@name='".$action."']"); $actionId = array_shift($controllersXML->getTags("//controllers/controller[@name='".$controller."' and @side='user']/scontrollers/scontroller[@name='".$action."']/@id")); $protocol = $this->_generic->getActionProtocol($actionId); if (count($actionExist) == 1) { $aliasesChecked = array_shift($controllersXML->getTagsAttributes("//controllers/controller/scontrollers/scontroller[@id='".$actionId."']",array("domains"))); if (!empty($aliasesChecked)) { $alias = explode(",",$aliasesChecked["attributes"][0]["value"]); foreach($alias as $cur_alias) array_push($aliasesSelected,$cur_alias); } $componentsChecked = array_shift($controllersXML->getTagsAttributes("//controllers/controller/scontrollers/scontroller[@id='".$actionId."']",array("components"))); if (!empty($componentsChecked)) { $component = explode(",",$componentsChecked["attributes"][0]["value"]); foreach($component as $cur_component) array_push($componentsSelected,$cur_component); } $reload = $this->_http->getParam("reload"); if ($reload == 'true') { $oldAction = SLS_String::trimSlashesFromString($this->_http->getParam("genericName")); $newAction = SLS_String::stringToUrl(ucwords(SLS_String::trimSlashesFromString($this->_http->getParam("actionName"))), "", false); $needDynamic = SLS_String::trimSlashesFromString($this->_http->getParam("dynamic")); $needOffline = SLS_String::trimSlashesFromString($this->_http->getParam("offline")); $needDefault = SLS_String::trimSlashesFromString($this->_http->getParam("default")); $searchEngine = SLS_String::trimSlashesFromString($this->_http->getParam("indexes")); $postProtocol = SLS_String::trimSlashesFromString($this->_http->getParam("protocol")); $tpl = SLS_String::trimSlashesFromString($this->_http->getParam('template')); $aliases = SLS_String::trimSlashesFromString($this->_http->getParam('domains')); $components = SLS_String::trimSlashesFromString($this->_http->getParam('components')); $cache_visibility = SLS_String::trimSlashesFromString($this->_http->getParam('cache_visibility')); $cache_scope = SLS_String::trimSlashesFromString($this->_http->getParam('cache_scope')); $cache_expiration = SLS_String::trimSlashesFromString($this->_http->getParam('cache_expiration')); $cache_responsive = SLS_String::trimSlashesFromString($this->_http->getParam('cache_responsive')); $toCache = (in_array($cache_visibility,array("public","private"))) ? true : false; if ($controller == "Home" && $action == "Index") { $needDefault = "true"; $newAction = $oldAction; } // If responsive wanted if ($cache_responsive == "true" && !$pluginMobile) { // Force Mobile plugin download file_get_contents($this->_generic->getFullPath("SLS_Bo", "SearchPlugin", array("Action" => "Download", "Server" => "4", "Plugin" => "20", "token" => sha1(substr($this->_generic->getSiteConfig("privateKey"), 0, 3).substr($this->_generic->getSiteConfig("privateKey"), strlen($this->_generic->getSiteConfig("privateKey"))-3))), true)); } $postActionsLang = array(); $postTitlesLang = array(); $postDescriptionsLang = array(); $postKeywordsLang = array(); // Save Form informations $xml->startTag("form"); $xml->addFullTag("actionName", $newAction, true); foreach ($langs as $lang) { $postLang = trim(SLS_String::stringToUrl(SLS_String::trimSlashesFromString($this->_http->getParam(strtolower($lang)."-action")), "", false)); $postOldLang = SLS_String::trimSlashesFromString($this->_http->getParam(strtolower($lang)."-oldAction")); if ($postLang != $oldAction) { $translationExist = $controllersXML->getTags("//controllers/controller[@side='user' and @name='".$controller."']/scontrollers/scontroller[@name != '".$oldAction."']/scontrollerLangs[scontrollerLang = '".$postLang."']"); if (empty($postLang)) array_push($errors, "You need to fill the ".$lang." url translations"); elseif(count($translationExist) != 0) array_push($errors, "You URL translation in ".$lang." is already in use on another action in the same controller"); else $postActionsLang[$lang] = $postLang; } // Get Titles $postTitlesLang[$lang] = SLS_String::trimSlashesFromString($this->_http->getParam(strtolower($lang)."-title")); $postDescriptionsLang[$lang] = SLS_String::trimSlashesFromString($this->_http->getParam(strtolower($lang)."-description")); $postKeywordsLang[$lang] = SLS_String::trimSlashesFromString($this->_http->getParam(strtolower($lang)."-keywords")); $xml->addFullTag($lang."-action", $postLang, true); $xml->addFullTag($lang."-title", $postTitlesLang[$lang], true); $xml->addFullTag($lang."-description", $postDescriptionsLang[$lang], true); $xml->addFullTag($lang."-keywords", $postKeywordsLang[$lang], true); } $xml->endTag("form"); if (empty($postProtocol) || ($postProtocol != 'http' && $postProtocol != 'https')) array_push($errors, "Protocol must be http or https"); else $protocol = $postProtocol; if (!empty($aliases) && is_array($aliases)) { $aliasesSelected = array(); foreach($aliases as $alias) array_push($aliasesSelected,$alias); } else { $aliasesSelected = array(); $controllersXML->setTagAttributes("//controllers/controller[@name='".$controller."']/scontrollers/scontroller[@name='".$action."' and @id='".$actionId."']", array('domains' => '')); } if ($toCache && (!is_numeric($cache_expiration) || $cache_expiration < 0)) array_push($errors, "Your expiration cache must be a positive time or 0"); if ($toCache && (!in_array($cache_scope,array("full","partial")))) array_push($errors, "Your must describe your cache scope"); if ($toCache && is_numeric($cache_expiration) && $cache_expiration >= 0 && in_array($cache_scope,array("full","partial"))) $controllersXML->setTagAttributes("//controllers/controller[@name='".$controller."']/scontrollers/scontroller[@name='".$action."' and @id='".$actionId."']", array('cache' => $cache_visibility.'|'.$cache_scope.'|'.(($cache_responsive == 'true') ? 'responsive' : 'no_responsive').'|'.$cache_expiration)); if (!$toCache) $controllersXML->deleteTagAttribute("//controllers/controller[@name='".$controller."']/scontrollers/scontroller[@name='".$action."' and @id='".$actionId."']","cache"); if (!empty($components) && is_array($components)) { $componentsSelected = array(); foreach($components as $component) array_push($componentsSelected,$component); } else { $componentsSelected = array(); $controllersXML->setTagAttributes("//controllers/controller[@name='".$controller."']/scontrollers/scontroller[@name='".$action."' and @id='".$actionId."']", array('components' => '')); } if ((($controller != 'Home' && $controller != 'Default') || (($controller == 'Home' && $action != 'Index') || ($controller == 'Default' && ($action != 'UrlError' && $action != 'BadRequestError' && $action != 'AuthorizationError' && $action != 'ForbiddenError' && $action != 'InternalServerError' && $action != 'TemporaryRedirectError' && $action != 'MaintenanceError')))) && ($oldAction != $newAction)) { $newNameExist = $controllersXML->getTags("//controllers/controller[@name='".$controller."' and @side='user']/scontrollers/scontroller[@name='".$newAction."']"); if (count($newNameExist) != 0) array_push($errors, "The generic action name is already in use in this controller"); } else $newAction = $oldAction; if (empty($newAction)) array_push($errors, "Action name can't be empty."); if (!empty($aliases)) $controllersXML->setTagAttributes("//controllers/controller[@name='".$controller."']/scontrollers/scontroller[@name='".$action."' and @id='".$actionId."']", array('domains' => implode(",",$aliasesSelected))); if (!empty($components)) $controllersXML->setTagAttributes("//controllers/controller[@name='".$controller."']/scontrollers/scontroller[@name='".$action."' and @id='".$actionId."']", array('components' => implode(",",$componentsSelected))); $controllersXML->setTagAttributes("//controllers/controller[@name='".$controller."']/scontrollers/scontroller[@name='".$action."' and @id='".$actionId."']", array('disable' => (empty($needOffline)) ? '0' : '1')); if ($tpl == -1) $controllersXML->deleteTagAttribute("//controllers/controller[@name='".$controller."' and @side='user']/scontrollers/scontroller[@name='".$action."']", "tpl"); else $controllersXML->setTagAttributes("//controllers/controller[@name='".$controller."' and @side='user']/scontrollers/scontroller[@name='".$action."']", array('tpl' => $tpl)); file_put_contents($this->_generic->getPathConfig('configSecure')."controllers.xml", $controllersXML->getXML()); $dynamic = (($controller != 'Home' && $controller != 'Default') || (($controller == 'Home' && $action != 'Index') || ($controller == 'Default' && ($action != 'UrlError' && $action != 'BadRequestError' && $action != 'AuthorizationError' && $action != 'ForbiddenError' && $action != 'InternalServerError' && $action != 'TemporaryRedirectError' && $action != 'MaintenanceError')))) ? ($needDynamic == 'on') ? "1" : "0" : array_shift($controllersXML->getTags("//controllers/controller[@name='".$controller."' and side='user']/scontrollers/scontroller[@name='".$oldAction."']/@needParam")); // If no errors if (empty($errors)) { // If default, reset other in current controller if (!empty($needDefault)) { $actions = $controllersXML->getTags("//controllers/controller[@side='user' and @name='".$controller."']/scontrollers/scontroller/@id"); foreach($actions as $curActionId) $controllersXML->setTagAttributes("//controllers/controller[@side='user' and @name='".$controller."']/scontrollers/scontroller[@id='".$curActionId."']", array('default' => '0')); } $controllersXML->setTagAttributes("//controllers/controller/scontrollers/scontroller[@id='".$actionId."']", array("name"=>$newAction,"needParam"=>$dynamic,'protocol'=>$protocol,"default"=>(empty($needDefault) ? '0' : '1'))); foreach ($langs as $lang) { if (array_key_exists($lang, $postActionsLang)) $controllersXML->setTag("//controllers/controller/scontrollers/scontroller[@id='".$actionId."']/scontrollerLangs/scontrollerLang[@lang='".$lang."']", $postActionsLang[$lang], true); else $controllersXML->setTag("//controllers/controller/scontrollers/scontroller[@id='".$actionId."']/scontrollerLangs/scontrollerLang[@lang='".$lang."']", SLS_String::trimSlashesFromString($this->_http->getParam(strtolower($lang)."-oldAction")), true); } // If generic name is not the same, we modify all files if ($oldAction != $newAction) { // Controller $contentController = file_get_contents($this->_generic->getPathConfig('actionsControllers').$controller."/".$oldAction.".controller.php"); $contentController = str_replace(array(0=>" ".$controller.$oldAction." ", 1=>" ".$oldAction." "), array(0=>" ".$controller.$newAction." ", 1=>" ".$newAction." "), $contentController); file_put_contents($this->_generic->getPathConfig('actionsControllers').$controller."/".$newAction.".controller.php", $contentController); unlink($this->_generic->getPathConfig('actionsControllers').$controller."/".$oldAction.".controller.php"); //Langs foreach ($langs as $lang) { $contentLang = file_get_contents($this->_generic->getPathConfig('actionLangs').$controller."/".$oldAction.".".$lang.".lang.php"); $contentLang = str_replace(array(0=>" ".$controller.$oldAction." ", 1=>" ".$oldAction." "), array(0=>" ".$controller.$newAction." ", 1=>" ".$newAction." "), $contentLang); file_put_contents($this->_generic->getPathConfig('actionLangs').$controller."/".$newAction.".".$lang.".lang.php", $contentLang); unlink($this->_generic->getPathConfig('actionLangs').$controller."/".$oldAction.".".$lang.".lang.php"); } // Views // Body $contentBody = file_get_contents($this->_generic->getPathConfig('viewsBody').$controller."/".$oldAction.".xsl"); $contentBody = str_replace(array(0=>"name=\"".$oldAction."\">", 1=>$oldAction.".xsl"), array(0=>"name=\"".$newAction."\">", 1=>$newAction.".xsl"), $contentBody); file_put_contents($this->_generic->getPathConfig('viewsBody').$controller."/".$newAction.".xsl", $contentBody); unlink($this->_generic->getPathConfig('viewsBody').$controller."/".$oldAction.".xsl"); // Headers $contentHeader = file_get_contents($this->_generic->getPathConfig('viewsHeaders').$controller."/".$oldAction.".xsl"); $contentHeader = str_replace(array(0=>"name=\"Header".$oldAction."\">"), array(0=>"name=\"Header".$newAction."\">"), $contentHeader); file_put_contents($this->_generic->getPathConfig('viewsHeaders').$controller."/".$newAction.".xsl", $contentHeader); unlink($this->_generic->getPathConfig('viewsHeaders').$controller."/".$oldAction.".xsl"); } // We now update the XML foreach ($langs as $lang) { // Metas $metasXML->setTag("//sls_configs/action[@id='".$actionId."']/title[@lang='".$lang."']", $postTitlesLang[$lang], true); $metasXML->setTag("//sls_configs/action[@id='".$actionId."']/description[@lang='".$lang."']", $postDescriptionsLang[$lang], true); $metasXML->setTag("//sls_configs/action[@id='".$actionId."']/keywords[@lang='".$lang."']", $postKeywordsLang[$lang], true); } if (!SLS_String::contains($searchEngine,", ")) $searchEngine = str_replace(",",", ",$searchEngine); if ($searchEngine != "index, follow" && $searchEngine != "noindex, follow" && $searchEngine != "noindex, nofollow" && $searchEngine != "index, nofollow") $searchEngine = "index, follow"; $metasXML->setTag("//sls_configs/action[@id='".$actionId."']/robots", $searchEngine, true); file_put_contents($this->_generic->getPathConfig("configSecure")."controllers.xml", $controllersXML->getXML()); file_put_contents($this->_generic->getPathConfig("configSls")."metas.xml", $metasXML->getXML()); } if (count($errors) != 0) { $xml->startTag("errors"); foreach ($errors as $error) $xml->addFullTag("error", $error, true); $xml->endTag("errors"); } $xml->startTag("cache"); $xml->addFullTag("cache_visibility", $cache_visibility,true); $xml->addFullTag("cache_scope", $cache_scope,true); $xml->addFullTag("cache_expiration", $cache_expiration,true); $xml->addFullTag("cache_responsive", $cache_responsive,true); $xml->endTag("cache"); } else { $actionCache = $this->_cache->getAction($actionId); $xml->startTag("cache"); $xml->addFullTag("cache_visibility", (is_array($actionCache)) ? $actionCache[0] : "",true); $xml->addFullTag("cache_scope", (is_array($actionCache)) ? $actionCache[1] : "",true); $xml->addFullTag("cache_expiration", (is_array($actionCache)) ? $actionCache[3] : "",true); $xml->addFullTag("cache_responsive", (is_array($actionCache)) ? (($actionCache[2]=="responsive") ? "true" : "") : "",true); $xml->endTag("cache"); } $tpl = $controllersXML->getTag("//controllers/controller[@name='".$controller."' and @side='user']/scontrollers/scontroller[@name='".$action."']/@tpl"); if (empty($tpl)) $tpl = $controllersXML->getTag("//controllers/controller[@name='".$controller."' and @side='user']/@tpl"); $controllersXML = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSecure")."controllers.xml")); $xml->startTag("action"); $xml->addFullTag("name", $action, true); $xml->addFullTag("dynamic", (array_shift($controllersXML->getTags("//controllers/controller[@name='".$controller."' and @side='user']/scontrollers/scontroller[@name='".$action."']/@needParam")) == '1') ? 'true' : 'false', true); $xml->addFullTag("offline", (array_shift($controllersXML->getTags("//controllers/controller[@name='".$controller."' and @side='user']/scontrollers/scontroller[@name='".$action."']/@disable")) == '1') ? 'true' : 'false', true); $xml->addFullTag("default", (array_shift($controllersXML->getTags("//controllers/controller[@name='".$controller."' and @side='user']/scontrollers/scontroller[@name='".$action."']/@default")) == '1') ? 'true' : 'false', true); $xml->addFullTag("indexes", array_shift($metasXML->getTags("//sls_configs/action[@id='".$actionId."']/robots")), true); $xml->addFullTag("canBeModified", (($controller != 'Home' && $controller != 'Default') || (($controller == 'Home' && $action != 'Index') || ($controller == 'Default' && ($action != 'UrlError' && $action != 'BadRequestError' && $action != 'AuthorizationError' && $action != 'ForbiddenError' && $action != 'InternalServerError' && $action != 'TemporaryRedirectError' && $action != 'MaintenanceError')))) ? 'true' : 'false', true); $xml->startTag("translations"); foreach ($langs as $lang) { $xml->startTag("translation"); $xml->addFullTag("lang", $lang, true); $xml->addFullTag("name", array_shift($controllersXML->getTags("//controllers/controller[@name='".$controller."' and @side='user']/scontrollers/scontroller[@name='".$action."']/scontrollerLangs/scontrollerLang[@lang='".$lang."']")) ,true); $xml->addFullTag("title", array_shift($metasXML->getTags("//sls_configs/action[@id='".$actionId."']/title[@lang='".$lang."']")),true); $xml->addFullTag("description", array_shift($metasXML->getTags("//sls_configs/action[@id='".$actionId."']/description[@lang='".$lang."']")),true); $xml->addFullTag("keywords", array_shift($metasXML->getTags("//sls_configs/action[@id='".$actionId."']/keywords[@lang='".$lang."']")),true); $xml->endTag("translation"); } $xml->endTag("translations"); $xml->endTag("action"); $xml->startTag('controller'); $xml->addFullTag("name", $controller, true); $xml->startTag('translations'); foreach ($langs as $lang) { $xml->startTag('translation'); $xml->addFullTag("lang", $lang, true); $xml->addFullTag("name", $controllersXML->getTag("//controllers/controller[@name='".$controller."' and @side='user']/controllerLangs/controllerLang[@lang='".$lang."']"), true); $xml->endTag('translation'); } $xml->endTag('translations'); $xml->endTag('controller'); // Build all tpls $tpls = $this->getAppTpls(); $xml->startTag("tpls"); foreach($tpls as $template) $xml->addFullTag("tpl",$template,true); $xml->endTag("tpls"); $xml->addFullTag('request', 'modifyAction', true); $aliases = $siteXML->getTagsAttributes("//configs/domainName/domain",array("alias")); $xml->startTag("aliases"); for($i=0 ; $i<$count=count($aliases) ; $i++) { $xml->startTag("alias"); $xml->addFullTag("name",$aliases[$i]["attributes"][0]["value"],true); $xml->addFullTag("selected",(in_array($aliases[$i]["attributes"][0]["value"],$aliasesSelected)) ? "true" : "false",true); $xml->endTag("alias"); } $xml->endTag("aliases"); $components = $this->_generic->recursiveReadDir($this->_generic->getPathConfig("componentsControllers"), array(), array(0=>"php")); $xml->startTag("components"); foreach ($components as $component) { $xml->startTag("component"); $xml->addFullTag("name", SLS_String::substrBeforeFirstDelimiter(SLS_String::substrAfterLastDelimiter($component, "/"), ".controller.php"),true); $xml->addFullTag("selected",(in_array(SLS_String::substrBeforeFirstDelimiter(SLS_String::substrAfterLastDelimiter($component, "/"), ".controller.php"),$componentsSelected)) ? "true" : "false",true); $xml->endTag("component"); } $xml->endTag("components"); } else { $this->_generic->dispatch('SLS_Bo', 'Controllers'); } $xml->addFullTag('protocol', $protocol, true); $xml->addFullTag('template', $tpl, true); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $this->_generic->loadProjectSettings(); $env = $this->_http->getParam("Env"); if (empty($env)) $env = "prod"; if ($this->_http->getParam("ProdDeployment") == "true" && file_exists($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/project_".$env.".xml")) $projectXML = new SLS_XMLToolbox(file_get_contents($this->_generic->getRoot().$this->_generic->getPathConfig("configSecure")."/project_".$env.".xml")); else $projectXML = $this->_generic->getProjectXML(); $errors = array(); // Prod Deployment $finalFile = ($this->_http->getParam("ProdDeployment") == "true") ? "project_".$env.".xml" : "project.xml"; $isInBatch = ($this->_http->getParam("CompleteBatch") == "true") ? true : false; $xml->addFullTag("is_batch",($isInBatch) ? "true" : "false",true); $xml->addFullTag("is_prod",($this->_http->getParam("ProdDeployment") == "true") ? "true" : "false",true); $reload = $this->_http->getParam("reload"); if ($reload == "true") { $postProject = SLS_String::trimSlashesFromString($this->_http->getParam("project", "post")); $newXML = (SLS_String::startsWith(trim($postProject),"<?xml")) ? new SLS_XMLToolbox($postProject) : new SLS_XMLToolbox("<?xml version=\"1.0\" encoding=\"utf-8\"?>".$postProject); if (!$this->_generic->isValidXML($newXML->getXML())) array_push($errors, "The XML is incorrect"); if (empty($errors)) { if (count($newXML->getTags("//project")) != 1) array_push($errors, "The Root node should be called 'project'"); $newXML = $this->checkNode("//project", $newXML); if (empty($errors)) { $xmlStr = trim($newXML->getXML()); if (substr($xmlStr, 0, 2)!= "<?") $xmlStr = "<?xml version=\"1.0\" encoding=\"utf-8\"?>".$xmlStr; $projectXML->refresh(); @file_put_contents($this->_generic->getPathConfig("configSecure").$finalFile, $xmlStr); if ($isInBatch) $this->_generic->forward("SLS_Bo","ProductionDeployment"); else if ($this->_http->getParam("ProdDeployment") == "true") $this->_generic->forward("SLS_Bo","ProductionDeployment"); $projectXML = new SLS_XMLToolbox($xmlStr); } } if (!empty($errors)) { $xml->startTag('errors'); foreach ($errors as $error) { $xml->addFullTag('error', $error, true); } $xml->endTag('errors'); } } $this->_generic->eraseCache('Project'); $value = (count($projectXML->getTags('//project/*')) == 0) ? "<project>\n</project>" : $projectXML->getXML('noHeader'); $xml->startTag("current_values"); $xml->addFullTag("project", str_replace(array('<![CDATA[', ']]>'), array('‹![CDATA[',']]›'), $value), true); $xml->endTag("current_values"); $this->saveXML($xml); }
/** * Action Home * */ public function action() { $this->secureURL(); $this->_generic->registerLink('MailSettings', 'SLS_Init', 'MailSettings'); $step = 0; $xml = $this->getXML(); $errors = array(); if ($this->_http->getParam("mails_reload") == "1") { $useSmtp = $this->_http->getParam("mails_useSmtp"); if (empty($useSmtp)) array_push($errors, "Will you need SMTP connection?"); else { if ($this->_http->getParam("mails_useSmtp") == "false") { $this->setInstallationStep(array(0=>"SLS_Init",1=>"Initialization"), array(0=>"Final",1=>"Congratulations")); return $this->_generic->dispatch("SLS_Init", "Final"); } else { $step = 1; $domainName = $this->_generic->getSiteConfig("domainName"); $port = 25; $xmlToolBox = $this->getXML(); $xmlToolBox->addFullTag("defaultDomain",$domainName,true); $xmlToolBox->addFullTag("port",$port,true); $xmlToolBox->addFullTag("header",'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="FFFFFF" color="000000">',true); $xmlToolBox->addFullTag("footer",'</body></html>',true); $this->saveXML($xmlToolBox); } } } elseif ($this->_http->getParam("mails_reload") == "2") { $host = SLS_String::trimSlashesFromString($this->_http->getParam("host")); $port = ($this->_http->getParam("port")=="") ? 25 : SLS_String::trimSlashesFromString($this->_http->getParam("port")); $username = SLS_String::trimSlashesFromString($this->_http->getParam("username")); $password = SLS_String::trimSlashesFromString($this->_http->getParam("password")); $password2 = SLS_String::trimSlashesFromString($this->_http->getParam("password2")); $defaultDomain = ($this->_http->getParam("defaultDomain") == "") ? $this->_generic->getSiteConfig("domainName") : SLS_String::trimSlashesFromString($this->_http->getParam("defaultDomain")); $defaultNameSender = SLS_String::trimSlashesFromString($this->_http->getParam("defaultNameSender")); $defaultSender = SLS_String::trimSlashesFromString($this->_http->getParam("defaultSender")); $defaultNameReply = SLS_String::trimSlashesFromString($this->_http->getParam("defaultNameReply")); $defaultReply = SLS_String::trimSlashesFromString($this->_http->getParam("defaultReply")); $defaultNameReturn = SLS_String::trimSlashesFromString($this->_http->getParam("defaultNameReturn")); $defaultReturn = SLS_String::trimSlashesFromString($this->_http->getParam("defaultReturn")); $header = SLS_String::trimSlashesFromString($this->_http->getParam("header")); $footer = SLS_String::trimSlashesFromString($this->_http->getParam("footer")); if (empty($host)) array_push($errors, "You have to fill the SMTP Host"); if (empty($port)) array_push($errors, "You have to fill the SMTP Port"); if (empty($username)) array_push($errors, "You have to fill the SMTP Username"); if (empty($password)) array_push($errors, "You have to fill the SMTP Password"); else if ($password != $password2) array_push($errors, "Both passwords don't match"); if (empty($defaultDomain)) array_push($errors, "You have to fill the SMTP Domain"); if (empty($defaultNameSender)) array_push($errors, "You have to fill the `From`' name"); if (empty($defaultSender)) array_push($errors, "You have to fill the `From`' alias"); if (empty($defaultNameReply)) array_push($errors, "You have to fill the `Reply To`' name"); if (empty($defaultReply)) array_push($errors, "You have to fill the `Reply To`' alias"); if (empty($defaultNameReturn)) array_push($errors, "You have to fill the `Return-Path`' name"); if (empty($defaultReturn)) array_push($errors, "You have to fill the `Return-Path`' alias"); if (empty($errors) && $this->_http->getParam("ping") != "true") { $dbXml = $this->_generic->getMailXML(); $dbXml->setTag("host", SLS_Security::getInstance()->encrypt($this->_http->getParam("host"), $this->_generic->getSiteConfig("privateKey"))); $dbXml->setTag("port", SLS_Security::getInstance()->encrypt($this->_http->getParam("port"), $this->_generic->getSiteConfig("privateKey"))); $dbXml->setTag("username", SLS_Security::getInstance()->encrypt($this->_http->getParam("username"), $this->_generic->getSiteConfig("privateKey"))); $dbXml->setTag("password", SLS_Security::getInstance()->encrypt($this->_http->getParam("password"), $this->_generic->getSiteConfig("privateKey"))); $dbXml->setTag("defaultDomain",$defaultDomain); $dbXml->setTag("defaultSender",$defaultSender); $dbXml->setTag("defaultNameSender",$defaultNameSender); $dbXml->setTag("defaultReply",$defaultReply); $dbXml->setTag("defaultNameReply",$defaultNameReply); $dbXml->setTag("defaultReturn",$defaultReturn); $dbXml->setTag("defaultNameReturn",$defaultNameReturn); // Default Template $mailTpl = '<item id="default" isSecure="false" js="false" default="true">'; $mailTpl .= '<header isSecure="false" js="false"><![CDATA['.$header.']]></header>'; $mailTpl .= '<footer isSecure="false" js="false"><![CDATA['.$footer.']]></footer>'; $mailTpl .= '</item>'; $dbXml->appendXMLNode("//mails/templates",$mailTpl); file_put_contents($this->_generic->getPathConfig("configSecure")."mail.xml", $dbXml->getXML()); $this->setInstallationStep(array(0=>"SLS_Init",1=>"Initialization"), array(0=>"Final",1=>"Congratulations")); return $this->_generic->dispatch("SLS_Init", "Final"); } else { $xmlToolBox = $this->getXML(); $xmlToolBox->addFullTag("host",$host,true); $xmlToolBox->addFullTag("port",$port,true); $xmlToolBox->addFullTag("username",$username,true); $xmlToolBox->addFullTag("password",$password,true); $xmlToolBox->addFullTag("defaultDomain",$defaultDomain,true); $xmlToolBox->addFullTag("defaultSender",$defaultSender,true); $xmlToolBox->addFullTag("defaultNameSender",$defaultNameSender,true); $xmlToolBox->addFullTag("defaultReply",$defaultReply,true); $xmlToolBox->addFullTag("defaultNameReply",$defaultNameReply,true); $xmlToolBox->addFullTag("defaultReturn",$defaultReturn,true); $xmlToolBox->addFullTag("defaultNameReturn",$defaultNameReturn,true); $xmlToolBox->addFullTag("header",$header,true); $xmlToolBox->addFullTag("footer",$footer,true); $this->saveXML($xmlToolBox); } $step = 1; } if (!empty($errors) && $this->_http->getParam("ping") != "true") { $xml->startTag("errors"); foreach($errors as $error) $xml->addFullTag("error", $error, true); $xml->endTag("errors"); } if ($this->_http->getParam("ping") == "true") { $smtp = new SLS_Email(""); $verdict = $smtp->pingConnection($host,$port,$username,$password); $xml->addFullTag("ping",($verdict===true) ? "true" : $verdict,true); } $xml->addFullTag("step", $step, true); $this->saveXML($xml); }