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); $xmlBo = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/bo.xml")); $param = $this->_http->getParam("name"); $model = SLS_String::substrAfterFirstDelimiter($param,"_"); $alias = SLS_String::substrBeforeFirstDelimiter($param,"_"); if ($this->_http->getParam("type") == "") $actionsTypes = array("list","add","modify","delete","clone"); else $actionsTypes = array($this->_http->getParam("type")); foreach($actionsTypes as $actionType) $this->deleteActionBo($model,$actionType,$alias); # Node into bo.xml $boPath = "//sls_configs/entry[@type='table' and @name='".strtolower($alias."_".$model)."']"; $boExists = $xmlBo->getTag($boPath."/@type"); if (empty($boExists)) $boPath = "//sls_configs/entry/entry[@type='table' and @name='".strtolower($alias."_".$model)."']"; $boExists = $xmlBo->getTag($boPath); if (!empty($boExists)) { $xmlBo->deleteTags($boPath, count($xmlBo->getTags($boPath))); $xmlBo->saveXML($this->_generic->getPathConfig("configSls")."/bo.xml",$xmlBo->getXML()); $xmlBo->refresh(); } # /Node into bo.xml $controllers = $this->_generic->getTranslatedController("SLS_Bo","Bo"); $this->_generic->redirect($controllers["controller"]."/".$controllers["scontroller"]); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $actions = array("list","add","modify","delete","clone","email"); // Get the table & class name $table = SLS_String::substrAfterFirstDelimiter($this->_http->getParam("name"),"_"); $db = SLS_String::substrBeforeFirstDelimiter($this->_http->getParam("name"),"_"); $class = ucfirst($db)."_".SLS_String::tableToClass($table); $file = ucfirst($db).".".SLS_String::tableToClass($table); $sql = SLS_Sql::getInstance(); // If current db is not this one if ($sql->getCurrentDb() != $db) $sql->changeDb($db); // If the table exists, delete the bo & model if ($sql->tableExists($table)) { foreach($actions as $action) if($this->boActionExist($table,$db,$action)) $this->deleteActionBo($table,$action,$db); @unlink($this->_generic->getPathConfig("models").$file.".model.php"); @unlink($this->_generic->getPathConfig("modelsSql").$file.".sql.php"); } $controllers = $this->_generic->getTranslatedController("SLS_Bo","Models"); $this->_generic->redirect($controllers['controller']."/".$controllers['scontroller']); }
/** * Constructor * * @access public * @since 1.0 */ public function __construct() { // Merge all params $this->_params = array_merge_recursive($_POST,$_GET,$this->fixFilesArray($_FILES)); // Strip extension if exists if (SLS_String::endsWith($this->_params['smode'], SLS_Generic::getInstance()->getSiteConfig('defaultExtension'))) $this->_params['smode'] = SLS_String::substrBeforeLastDelimiter($this->_params['smode'], '.'.SLS_Generic::getInstance()->getSiteConfig('defaultExtension')); // Command line if (PHP_SAPI === 'cli') { global $argv; if (is_array($argv)) { $args = array_slice($argv, 1); $controllerPosition = 0; for($i=0 ; $i<count($args) ; $i++) { $argKey = SLS_String::substrBeforeFirstDelimiter($args[$i],"="); if (!empty($argKey) && strtolower($argKey) == "mode") { $this->_params['mode'] = SLS_String::substrAfterFirstDelimiter($args[$i],"="); $controllerPosition = $i; } if (!empty($argKey) && strtolower($argKey) == "smode") { $args[$i] = SLS_String::substrAfterFirstDelimiter($args[$i],"="); } } unset($args[$controllerPosition]); $this->_params['smode'] = str_replace("=","/",implode("/",$args)); } } // Get smode $explode = explode("/", $this->_params['smode']); $this->_params['smode'] = array_shift($explode); // Transform url in classic queryString '?param1=value1¶m2=value2...' $queryString = ""; $params = array_chunk($explode, 2); for($i=0 ; $i<$count=count($params) ; $i++) if (count($params[$i]) == 2) $queryString .= (($i == 0) ? '' : '&').$params[$i][0].'='.(($params[$i][1] != "|sls_empty|") ? $params[$i][1] : ""); // Get all params/values parse_str($queryString,$params); if (!empty($params)) { foreach($params as $key => $value) $this->_params[$key] = $value; } }
public function action() { $user = $this->hasAuthorative(); // Objects $xmlFk = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml")); $xmlBearer = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/bearers.xml")); // Get the table & class name $table = SLS_String::substrAfterFirstDelimiter($this->_http->getParam("name"),"_"); $db = SLS_String::substrBeforeFirstDelimiter($this->_http->getParam("name"),"_"); $class = ucfirst($db)."_".SLS_String::tableToClass($table); $result = array_shift($xmlBearer->getTagsAttributes("//sls_configs/entry[@tableBearer='".$class."']",array("table1"))); if (!empty($result)) $xmlBearer->saveXML($this->_generic->getPathConfig("configSls")."/bearers.xml",$xmlBearer->deleteTags("//sls_configs/entry[@tableBearer='".$class."']")); $this->_generic->forward("SLS_Bo","EditModel",array(array("key"=>"name","value"=>$this->_http->getParam("name")))); }
public function action() { $user = $this->hasAuthorative(); $redirect = true; $param = $this->_http->getParam("name"); $model = SLS_String::substrAfterFirstDelimiter($param,"_"); $alias = SLS_String::substrBeforeFirstDelimiter($param,"_"); $checkbox = $this->_http->getParam("redirect"); if (empty($checkbox)) $redirect = false; $controllersXML = $this->_generic->getControllersXML(); $controller = array_shift($controllersXML->getTags("//controllers/controller[@isBo='true']/@name")); $this->createActionBoAdd($controller,$model,$alias,$redirect); $controllers = $this->_generic->getTranslatedController("SLS_Bo","EditBo"); $this->_generic->redirect($controllers["controller"]."/".$controllers["scontroller"]."/name/".$param.".sls"); }
public function action() { $user = $this->hasAuthorative(); $controllersXML = $this->_generic->getControllersXML(); $controller = array_shift($controllersXML->getTags("//controllers/controller[@isBo='true']/@name")); if (!empty($controller)) { $param = $this->_http->getParam("name"); $model = SLS_String::substrAfterFirstDelimiter($param,"_"); $alias = SLS_String::substrBeforeFirstDelimiter($param,"_"); $type = ucfirst($this->_http->getParam("type")); $actionTypes = array("List","Add","Modify","Delete","Clone","Email"); if (in_array($type,$actionTypes)) $this->{createActionBo.$type}($controller,$model,$alias); } $controllers = $this->_generic->getTranslatedController("SLS_Bo","Bo"); $this->_generic->redirect($controllers["controller"]."/".$controllers["scontroller"]); }
public function getEnvironments() { $environments = array(); $filesToCheck = array("site","db","project","mail"); if ($handle = opendir($this->_generic->getPathConfig("configSecure"))) { while (false !== ($entry = readdir($handle))) { foreach($filesToCheck as $file) { if (SLS_String::startsWith($entry,$file."_") && SLS_String::endsWith($entry,".xml")) { $environment = SLS_String::substrBeforeFirstDelimiter(SLS_String::substrAfterFirstDelimiter($entry,$file."_"),".xml"); if (!in_array($environment,$environments)) $environments[] = $environment; } } } } return $environments; }
/** * Protect a sql column * * @param string $col the column to protect * @return string column protected * @since 1.0.7 * @example * protectColumn("news_id") * // will produce "`news_id`" * protectColumn("news.news_id") * // will produce "`news`.`news_id`" */ public function protectColumn($col) { return ((SLS_String::contains($col,'.')) ? self::ESC.SLS_String::substrBeforeFirstDelimiter($col,'.').self::ESC.'.'.self::ESC.SLS_String::substrAfterFirstDelimiter($col,'.').self::ESC : self::ESC.$col.self::ESC); }
/** * Send the email to all the recipients * * @access public * @since 1.0 */ public function send() { if (!$this->compiled) $this->compileMail(); $headers = $this->headers; $message = $this->message; // Using remote smtp if (!empty($this->hostname)) { // If it has 1 recipient min if(!empty($headers['To'])) { // Open the smtp connection $this->openConnection(); // Merge all the recipients ('To','Cc','Bcc') into one array $headersTmp = array_merge($headers['To'],empty($this->headers['Cc']) ? array() : $this->headers['Cc'],empty($this->headers['Bcc']) ? array() : $this->headers['Bcc']); // For all the recipients foreach($headersTmp as $key => $value) { // Count number of lines of log file if (count(file($this->logurl)) >= 200) $this->deleteLogLine(); // Add email subject into log fwrite($this->fp, date("Y-m-d H:i:s").' - SUBJECT: '.SLS_String::substrAfterFirstDelimiter($this->headers['Subject'],'Subject: ')."\n", 1024); // Send to the smtp the sender fputs($this->server,"MAIL FROM: <".(substr($headers['From'],strrpos($headers['From'],"<")+1,strlen($headers['From'])-strrpos($headers['From'],"<")-2)).">\r\n"); // Log smtp response $response = $this->readAndLogServerResponse('MAIL From: <'.(substr($headers['From'],strrpos($headers['From'],"<")+1,strlen($headers['From'])-strrpos($headers['From'],"<")-2)).">",$key); // If smtp answer 250 if ($this->checkSmtpAnswer($response,"250")) { // Send to the smtp the recipient fputs($this->server,"RCPT TO: <".$value.">\r\n"); // Log smtp response $response = $this->readAndLogServerResponse('RCPT To: '.$value,$key); // If smtp answer 250 if ($this->checkSmtpAnswer($response,"250")) { // If it have no recipients, exit if(empty($headers['To'])) { // Smtp reset fputs($this->server,"RSET\r\n"); // Log smtp response $response = $this->readAndLogServerResponse('RSET:',$key); $this->error[$key]=$response; } // Else, it's good, write the recipient else { if(!empty($headers['To'])) $headers['To'] = "To: ".$value; // We prepare Smtp putting mail content fputs($this->server,"DATA\r\n"); // Log smtp response $response = $this->readAndLogServerResponse('DATA:',$key); // If smtp answer 354 if ($this->checkSmtpAnswer($response,"354")) { // Parse mail content and implode headers $message = str_replace("\r\n.\r\n","\r\n..\r\n",$message); $headersI = implode("\r\n",$headers); // Send to smtp the mail fputs($this->server,$headersI."\r\n".$message."\r\n.\r\n"); // Log smtp response $response = $this->readAndLogServerResponse('SENDING MAIL:',$key); $this->checkSmtpAnswer($response,"250"); } } } } } } return $this->error; } // Using mail() function else { // Merge all the recipients ('To','Cc','Bcc') into one array $headersTmp = array_merge($headers['To'],empty($this->headers['Cc']) ? array() : $this->headers['Cc'],empty($this->headers['Bcc']) ? array() : $this->headers['Bcc']); // For all the recipients foreach($headersTmp as $key => $value) { if(!empty($headers['To'])) { $headers['To'] = "To: ".$value; // Parse mail content and implode headers $message = str_replace("\r\n.\r\n","\r\n..\r\n",$message); $headersI = implode("\r\n",$headers); mail("",SLS_String::substrAfterFirstDelimiter($this->headers['Subject'],'Subject: '),$message,$headersI); } } } }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $siteXML = $this->_generic->getSiteXML(); $googleSettings = array(); if ($this->_http->getParam("reload") == "true") { $googleSettings = $this->_http->getParam("ga"); $siteXML->setTag("//configs/google/setting[@name='ua']",trim($googleSettings["ua"])); $siteXML->setTag("//configs/google/setting[@name='apiKey']",trim($googleSettings["apiKey"])); $siteXML->setTag("//configs/google/setting[@name='clientId']",trim($googleSettings["clientId"])); $siteXML->setTag("//configs/google/setting[@name='accountId']",trim($googleSettings["accountId"])); $siteXML->saveXML($this->_generic->getPathConfig("configSecure")."site.xml"); $siteXML->refresh(); if (!empty($googleSettings["ua"])) { $googleSettings["ua"] = (SLS_String::startsWith(trim(strtolower($googleSettings["ua"])),"ua-")) ? $googleSettings["ua"] : "UA-".$googleSettings["ua"]; $templates = scandir($this->_generic->getPathConfig("viewsTemplates")); foreach($templates as $template) { if (!SLS_String::startsWith($template,".")) { $templateContent = file_get_contents($this->_generic->getPathConfig("viewsTemplates").$template); if (SLS_String::contains($templateContent,"<!-- GA loading -->") && SLS_String::contains($templateContent,"_gaq.push(['_setAccount'")) { $oldUa = trim(str_replace("'","",SLS_String::substrBeforeFirstDelimiter(SLS_String::substrAfterFirstDelimiter($templateContent,"_gaq.push(['_setAccount',"),"]"))); if ($oldUa != $googleSettings["ua"]) { $templateContent = str_replace("_gaq.push(['_setAccount', '".$oldUa."']);","_gaq.push(['_setAccount', '".$googleSettings["ua"]."']);",$templateContent); file_put_contents($this->_generic->getPathConfig("viewsTemplates").$template,$templateContent); } } else { $newContent = ""; $templateLines = explode("\n",$templateContent); for($i=0 ; $i<$count=count($templateLines) ; $i++) { $line = $templateLines[$i]; if (SLS_String::contains($line,"</body>")) { $newContent .= t(4)."<!-- GA loading -->"."\n". t(4)."<xsl:if test=\"//Statics/Sls/Configs/site/isProd = '1'\">"."\n". t(5)."<script type=\"text/javascript\">"."\n". t(6)."var _gaq = _gaq || [];"."\n". t(6)."_gaq.push(['_setAccount', '".$googleSettings["ua"]."']);"."\n". t(6)."_gaq.push(['_trackPageview']);"."\n". t(6)."(function() {"."\n". t(7)."var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;"."\n". t(7)."ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';"."\n". t(7)."var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);"."\n". t(6)."})();"."\n". t(5)."</script>"."\n". t(4)."</xsl:if>"."\n". t(4)."<!-- /GA loading -->"."\n\n"; } $newContent .= $line."\n"; } file_put_contents($this->_generic->getPathConfig("viewsTemplates").$template,$newContent); } } } } $xml->addFullTag("success","Your settings have been saved.",true); } else { $googleSettings["ua"] = $siteXML->getTag("//configs/google/setting[@name='ua']"); $googleSettings["apiKey"] = $siteXML->getTag("//configs/google/setting[@name='apiKey']"); $googleSettings["clientId"] = $siteXML->getTag("//configs/google/setting[@name='clientId']"); $googleSettings["accountId"] = $siteXML->getTag("//configs/google/setting[@name='accountId']"); } $xml->startTag("google"); foreach($googleSettings as $key => $value) $xml->addFullTag($key,$value,true); $xml->endTag("google"); $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() { $xml = $this->getXML(); $xml = $this->makeMenu($xml); $user = $this->hasAuthorative(); // Objects $sql = SLS_Sql::getInstance(); $properties = array(); $pathsHandleFk = file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml"); $pathsHandleType = file_get_contents($this->_generic->getPathConfig("configSls")."/types.xml"); $pathsHandleFilter = file_get_contents($this->_generic->getPathConfig("configSls")."/filters.xml"); $xmlFk = new SLS_XMLToolbox($pathsHandleFk); $xmlType = new SLS_XMLToolbox($pathsHandleType); $xmlFilter = new SLS_XMLToolbox($pathsHandleFilter); // Foreach existing models $models = scandir($this->_generic->getPathConfig("models")); foreach($models as $file) { if (!is_dir($this->_generic->getPathConfig("models")."/".$file) && substr($file, 0, 1) != ".") { $fileExploded = explode(".",$file); if (is_array($fileExploded) && count($fileExploded) == 4) { $db = strtolower($fileExploded[0]); $class = $fileExploded[1]; $className = $db."_".$class; $this->_generic->useModel($class,$db,"user"); $object = new $className(); $table = $object->getTable(); $properties[$db][$table] = array("types" => array(), "filters" => array(), "fks" => array()); $types = $xmlType->getTagsAttributes("//sls_configs/entry[@table='".$db."_".$table."']",array("column","type","rules")); for($i=0 ; $i<$count=count($types) ; $i++) { $column = $types[$i]["attributes"][0]["value"]; $type = $types[$i]["attributes"][1]["value"]; $rules = $types[$i]["attributes"][2]["value"]; if ($type == "complexity" && !empty($rules)) $type .= " (".$rules.")"; $properties[$db][$table]["types"][$column][] = $type; } $filters = $xmlFilter->getTagsAttributes("//sls_configs/entry[@table='".$db."_".$table."']",array("column","filter","hash")); for($i=0 ; $i<$count=count($filters) ; $i++) { $column = $filters[$i]["attributes"][0]["value"]; $filter = $filters[$i]["attributes"][1]["value"]; $hash = $filters[$i]["attributes"][2]["value"]; if ($filter == "hash" && !empty($hash)) $filter .= " (".$hash.")"; $properties[$db][$table]["filters"][$column][] = $filter; } $fks = $xmlFk->getTagsAttributes("//sls_configs/entry[@tableFk='".$db."_".$table."']",array("columnFk","tablePk","labelPk")); for($i=0 ; $i<$count=count($fks) ; $i++) { $column = $fks[$i]["attributes"][0]["value"]; $classPk = ucfirst($fks[$i]["attributes"][1]["value"]); $labelPk = $fks[$i]["attributes"][2]["value"]; $tablePk = SLS_String::substrAfterFirstDelimiter($classPk,"_"); $this->_generic->useModel($tablePk,$db,"user"); $objectPk = new $classPk(); $properties[$db][$table]["fks"][$column][] = $objectPk->getTable(); } } } } asort($properties,SORT_REGULAR); uksort($properties,array($this, 'unshiftDefaultDb')); $xml->startTag("dbs"); foreach($properties as $db => $tables) { $xml->startTag("db"); $xml->addFullTag("name",$db,true); $xml->startTag("tables"); foreach($tables as $table => $infos) { $columns = array(); $xml->startTag("table"); $xml->addFullTag("name",$table,true); $xml->startTag("types"); foreach($infos["types"] as $column => $type) { $xml->addFullTag("type",implode(", ",$type),true,array("column"=>$column)); $columns[] = $column; } $xml->endTag("types"); $xml->startTag("filters"); foreach($infos["filters"] as $column => $filter) { $xml->addFullTag("filter",implode(", ",$filter),true,array("column"=>$column)); $columns[] = $column; } $xml->endTag("filters"); $xml->startTag("fks"); foreach($infos["fks"] as $column => $fk) { $xml->addFullTag("fk",implode(", ",$fk),true,array("column"=>$column)); $columns[] = $column; } $xml->endTag("fks"); $xml->startTag("columns"); foreach($columns as $column) $xml->addFullTag("column",$column,true); $xml->endTag("columns"); $xml->endTag("table"); } $xml->endTag("tables"); $xml->endTag("db"); } $xml->endTag("dbs"); $xml->addFullTag("url_type",$this->_generic->getFullPath("SLS_Bo","EditType",array(),false),true); $xml->addFullTag("url_model",$this->_generic->getFullPath("SLS_Bo","EditModel",array(),false),true); $xml->addFullTag("url_fk",$this->_generic->getFullPath("SLS_Bo","EditForeignKey",array(),false),true); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $param = $this->_http->getParam("class"); $model = SLS_String::substrAfterFirstDelimiter($param,"_"); $alias = SLS_String::substrBeforeFirstDelimiter($param,"_"); $filters = $this->_http->getParam("filters"); $columns = $this->_http->getParam("columns"); $column = $this->_http->getParam("column"); $group = $this->_http->getParam("group"); $order = $this->_http->getParam("order"); $start = $this->_http->getParam("start"); $length = $this->_http->getParam("length"); $action_add = $this->_http->getParam("action_add"); $action_modify = $this->_http->getParam("action_modify"); $action_delete = $this->_http->getParam("action_delete"); $action_clone = $this->_http->getParam("action_clone"); $action_email = $this->_http->getParam("action_email"); $join = $this->_http->getParam("join"); if (!empty($order) && !empty($column)) { $orderA = array("column" => $column, "order" => $order); } else $orderA = array(); if (is_numeric($start) && is_numeric($length) && $start >= 0 && $length > 0) { $limitA = array("start" => $start, "length" => $length); } else $limitA = array(); if (is_array($join)) { $newJoin = array(); foreach($join as $cur_join) { $this->_generic->useModel(SLS_String::tableToClass($cur_join),$alias,"user"); $class = ucfirst($alias)."_".SLS_String::tableToClass($cur_join); $object = new $class(); $newJoin[] = array("table" => $cur_join, "column" => $object->getPrimaryKey(), "mode" => "left"); } $join = $newJoin; } $join = (empty($join)) ? "" : (is_array($join) ? $join : ""); $actions = array("add" => ($action_add == "true") ? true : false, "modify" => ($action_modify == "true") ? true : false, "delete" => ($action_delete == "true") ? true : false, "clone" => ($action_clone == "true") ? true : false, "email" => ($action_email == "true") ? true : false); $controllersXML = $this->_generic->getControllersXML(); $controller = array_shift($controllersXML->getTags("//controllers/controller[@isBo='true']/@name")); $this->createActionBoList($controller,$model,$alias,$columns,$filters,$group,$orderA,$limitA,$join,$actions); $controllers = $this->_generic->getTranslatedController("SLS_Bo","EditBo"); $this->_generic->redirect($controllers["controller"]."/".$controllers["scontroller"]."/name/".$param.".sls"); }
public function action() { $user = $this->hasAuthorative(); $json = array(); $xml = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig('configSls').'fks.xml')); $tableName = $this->_http->getParam('table_name'); $tmp = explode('.', $tableName); if(count($tmp) != 2) die; $slsGraphQueryDbAlias = $tmp[0]; $slsGraphQueryTable = $tmp[1]; $this->sql->changeDb($slsGraphQueryDbAlias); if($this->sql->tableExists($slsGraphQueryTable)) { $json['status'] = 'OK'; $json['fields'] = array(); $fields = $this->sql->showColumns($slsGraphQueryTable); // Get Attributes $getAttributes = $xml->getTagsAttributes('//sls_configs/entry[@tableFk="'.$slsGraphQueryDbAlias."_".$slsGraphQueryTable.'"]', array('columnFk', 'labelPk', 'tablePk')); // Format Attributes $columnFk = array(); $labelPk = array(); $tablePk = array(); for($i = 0; $i < $count = count($getAttributes); $i++) { array_push($columnFk, $getAttributes[$i]['attributes'][0]['value']); array_push($labelPk, $getAttributes[$i]['attributes'][1]['value']); array_push($tablePk, $getAttributes[$i]['attributes'][2]['value']); } foreach($fields as $field) { if(in_array($field->Field, $columnFk)) { $isFk = true; $index = array_search($field->Field, $columnFk); $labelPkValue = $labelPk[$index]; $tablePkValue = $tablePk[$index]; } else { $isFk = false; } array_push($json['fields'], array( 'field_name' => $field->Field, 'field_table' => $slsGraphQueryTable, 'field_label' => $field->Field, 'field_isFk' => $isFk, 'field_labelPk' => $labelPkValue, 'field_tablePk' => empty($tablePkValue) ? '' : $slsGraphQueryDbAlias.'.'.SLS_String::substrAfterFirstDelimiter(strtolower($tablePkValue), '_')) ); } } else{ $json['status'] = 'ERROR'; $json['error'] = "Table doesn't exist"; } echo json_encode($json); die; }
/** * Function saved SLS_XMLToolbox object of your running controller * * @access protected * @param SLS_XMLToolbox $xmlObject a SLS_XMLToolbox object * @since 1.0 */ protected function saveXML($xmlObject) { $bufferXml = new SLS_XMLToolbox($this->_generic->getBufferXML()); $xmlAction = $xmlObject->getXML(); // Sls cached enabled and Action cache enabled ? $cacheOptions = $this->_cache->getAction(); if ($this->_generic->isCache() && $this->_generic->getSide() == "user" && $this->_generic->getGenericControllerName() != "Default" && is_array($cacheOptions) && count($cacheOptions) == 4) { $actionCacheVisibility = $cacheOptions[0]; $actionCacheScope = $cacheOptions[1]; $actionCacheResponsive = $cacheOptions[2]; $actionCacheExpiration = $cacheOptions[3]; // Save partial xml action cache if ($actionCacheScope == "partial") { $this->_cache->saveCachePartial($xmlAction,"action","action_".SLS_String::substrAfterFirstDelimiter($this->_generic->getActionId(),"a_"),$actionCacheVisibility,$actionCacheResponsive); $this->_cacheSaved = true; } } $bufferXml->appendXMLNode("//root/View", $xmlAction); $this->_xml = $bufferXml->getXML(); $this->_generic->setBufferXml($this->_xml, false); }
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(); // Objects $sql = SLS_Sql::getInstance(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); // Actions $xml->addFullTag("delete",$this->_generic->getFullPath("SLS_Bo","DeleteModel",array(),false)); $xml->addFullTag("delete_bearer",$this->_generic->getFullPath("SLS_Bo","DeleteBearerTable",array(),false)); $xml->addFullTag("delete_type",$this->_generic->getFullPath("SLS_Bo","DeleteType",array(),false)); $xml->addFullTag("edit_type",$this->_generic->getFullPath("SLS_Bo","EditType",array(),false)); $xml->addFullTag("delete_fk",$this->_generic->getFullPath("SLS_Bo","DeleteForeignKey",array(),false)); $xml->addFullTag("edit_fk",$this->_generic->getFullPath("SLS_Bo","EditForeignKey",array(),false)); $xml->addFullTag("update",$this->_generic->getFullPath("SLS_Bo","UpdateModel",array(),false)); $xml->addFullTag("descriptions",$this->_generic->getFullPath("SLS_Bo","UpdateDescription",array(),false)); // Get the table & class name $table = SLS_String::substrAfterFirstDelimiter($this->_http->getParam("name"),"_"); $db = SLS_String::substrBeforeFirstDelimiter($this->_http->getParam("name"),"_"); $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); // Get generic object $this->_generic->useModel(SLS_String::tableToClass($table),$db,"user"); $object = new $class(); // Get description's table $description = $object->getTableComment($table); $columnsInfos = $sql->showColumns($table); // Get object's infos $columns = array(); $columnsP = $object->getParams(); $pk = $object->getPrimaryKey(); $multilanguage = $object->isMultilanguage(); $xml->startTag("model"); $xml->addFullTag("table",$table,true); $xml->addFullTag("description",(SLS_String::contains($description,"InnoDB free")) ? SLS_String::substrBeforeFirstDelimiter($description,"; InnoDB free") : $description,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"); $cursor = 0; foreach($columnsP as $column => $value) { $xml->startTag("column"); $xml->addFullTag("name",$column,true); array_push($columns,$column); $fk = ""; $sType = ""; $pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml"); $xmlFk = new SLS_XMLToolbox($pathsHandle); $res = $xmlFk->getTagsByAttributes("//sls_configs/entry",array("tableFk","columnFk"),array($db."_".$table,$column)); if (!empty($res)) { $tableTmp = substr($res,(strpos($res,'tablePk="')+9),(strpos($res,'"/>')-(strpos($res,'tablePk="')+9))); $fk = SLS_String::substrAfterFirstDelimiter($tableTmp,"_"); } $pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/types.xml"); $xmlType = new SLS_XMLToolbox($pathsHandle); $res = $xmlType->getTagsByAttributes("//sls_configs/entry",array("table","column"),array($db."_".$table,$column)); if (!empty($res)) { $sType = SLS_String::substrBeforeFirstDelimiter(SLS_String::substrAfterFirstDelimiter($res,'type="'),'"/>'); // If specific type numeric and native type too if (SLS_String::startsWith($sType,"num_") && $this->containsRecursive($columnsInfos[$cursor]->Type,array("int","float","double","decimal","real"))) $xml->addFullTag("allow_to_delete_type","false",true); } $pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/filters.xml"); $xmlFilter = new SLS_XMLToolbox($pathsHandle); $results = $xmlFilter->getTagsAttributes("//sls_configs/entry[@table='".$db."_".$table."' and @column='".$column."']",array("filter","hash")); $xml->startTag("filters"); for($i=0 ; $i<$count=count($results) ; $i++) { $filter = $results[$i]["attributes"][0]["value"]; $result = $results[$i]["attributes"][1]["value"]; $xml->startTag("filter"); $xml->addFullTag("name",$filter.((!empty($result)) ? ' ['.$result.']' : ''),true); $xml->addFullTag("url_delete",$this->_generic->getFullPath("SLS_Bo","DeleteFilter",array(array("key"=>"table","value"=>$this->_http->getParam("name")),array("key"=>"column","value"=>$column),array("key"=>"filter","value"=>$filter))),true); $xml->endTag("filter"); } $xml->endTag("filters"); $xml->addFullTag("fk",$fk,true); $xml->addFullTag("type",ucfirst($sType),true); $xml->addFullTag("comment",$object->getColumnComment($column),true); $xml->endTag("column"); $cursor++; } $xml->endTag("columns"); $xml->addFullTag("url_add_type",$this->_generic->getFullPath("SLS_Bo","AddType",array(0=>array("key"=>"name","value"=>$db."_".$table))),true); $xml->addFullTag("url_add_filter",$this->_generic->getFullPath("SLS_Bo","AddFilter",array(0=>array("key"=>"name","value"=>$db."_".$table))),true); $xml->addFullTag("url_add_fk",$this->_generic->getFullPath("SLS_Bo","AddForeignKey",array(0=>array("key"=>"name","value"=>$db."_".$table))),true); // Get the source of the current model $xml->addFullTag("current_source",str_replace("\t"," ",file_get_contents($this->_generic->getPathConfig("models").$file.".model.php")),true); // Get the source of the current table if (!$sql->tableExists($table)) $xml->addFullTag("current_table",-1,true); else { $columns = $sql->showColumns($table); $tableName = $table; $currentTable = array("table"=>$db.".".$tableName,"errors"=>array()); $className = ucfirst($db)."_".SLS_String::tableToClass($tableName); $fileName = ucfirst($db).".".SLS_String::tableToClass($table).".model.php"; $primaryKey = ""; $multiLanguage = 'false'; $pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/types.xml"); $xmlType = new SLS_XMLToolbox($pathsHandle); $pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml"); $xmlFk = new SLS_XMLToolbox($pathsHandle); $pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/filters.xml"); $xmlFilter = new SLS_XMLToolbox($pathsHandle); // Get source $contentM = $this->getModelSource($tableName,$db); // Is data bearer $xmlBearer = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/bearers.xml")); $result = array_shift($xmlBearer->getTagsAttributes("//sls_configs/entry[@tableBearer='".$class."']",array("table1"))); $xml->addFullTag("is_data_bearer",(!empty($result)) ? $result["attributes"][0]["value"] : "false",true); // Save the new source $xml->addFullTag("current_table",str_replace("\t"," ",$contentM),true); $xml->addFullTag("url_data_bearer",$this->_generic->getFullPath("SLS_Bo","AddBearerTable",array(array("key"=>"name","value"=>$this->_http->getParam("name")))),true); } $xml->endTag("model"); $this->saveXML($xml); }
public function action() { $xml = $this->getXML(); $xml = $this->makeMenu($xml); $user = $this->hasAuthorative(); // Objects $sql = SLS_Sql::getInstance(); $xmlBo = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/bo.xml")); $xmlFk = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml")); $xmlType = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/types.xml")); // Get the table & class name $tableName = SLS_String::substrAfterFirstDelimiter($this->_http->getParam("name"),"_"); $db = SLS_String::substrBeforeFirstDelimiter($this->_http->getParam("name"),"_"); $className = ucfirst($db)."_".SLS_String::tableToClass($tableName); $file = ucfirst($db).".".SLS_String::tableToClass($tableName); $fileName = ucfirst($db).".".SLS_String::tableToClass($tableName).".model.php"; // If current db is not this one if ($sql->getCurrentDb() != $db) $sql->changeDb($db); // Remind old properties $this->_generic->useModel(SLS_String::tableToClass($tableName),ucfirst(strtolower($db)), "user"); $object = new $className(); $oldColumns = $object->getColumns(); // Update Model $contentM = $this->getModelSource($tableName,$db); file_put_contents($this->_generic->getPathConfig("models").$fileName,$contentM); // Check Bo $controllerBo = $this->_generic->getBo(); if (!empty($controllerBo)) { $boPath = "//sls_configs/entry[@type='table' and @name='".strtolower($className)."']"; $boExists = $xmlBo->getTag($boPath."/@type"); if (empty($boExists)) { $boPath = "//sls_configs/entry/entry[@type='table' and @name='".strtolower($className)."']"; $boExists = $xmlBo->getTag($boPath); } if (!empty($boExists)) { $columns = $sql->showColumns($tableName); $newColumns = array(); for($i=0 ; $i<$count=count($columns) ; $i++) $newColumns[] = $columns[$i]->Field; $xmlNodes = ''; foreach($newColumns as $column) { $columnExists = $xmlBo->getTag($boPath."/columns/column[@table='".strtolower($className)."' and @name='".$column."']/@name"); if (empty($columnExists)) { // Avoid pk $isPk = ($column == $object->getPrimaryKey() || $column == 'pk_lang') ? true : false; // Avoid fk $fkExist = $xmlFk->getTag("//sls_configs/entry[@tableFk='".strtolower($db."_".$tableName)."' and @columnFk='".$column."']/@tablePk"); $isFk = (!empty($fkExist)) ? true : false; // Avoid quick edit on type file $fileExist = $xmlType->getTag("//sls_configs/entry[@table='".strtolower($db."_".$tableName)."' and @column='".$column."' and (@type='file_all' or @type='file_img')]/@column"); $isFile = (!empty($fileExist)) ? true : false; $xmlNodes .= ' <column table="'.strtolower($db."_".$tableName).'" name="'.$column.'" multilanguage="'.(($object->isMultilanguage() && !$isPk) ? "true" : "false").'" displayFilter="true" displayList="'.(($isFk) ? "false" : "true").'" allowEdit="'.(($isPk || $isFk || $isFile) ? "false" : "true").'" allowHtml="false" />'."\n"; } } if (!empty($xmlNodes)) { $xmlBo->appendXMLNode($boPath."/columns",$xmlNodes); } $deprecatedColumns = array_diff($oldColumns,$newColumns); foreach($deprecatedColumns as $column) { $xmlBo->deleteTags($boPath."/columns/column[@table='".strtolower($className)."' and @name='".$column."']",1); } $xmlBo->saveXML($this->_generic->getPathConfig("configSls")."/bo.xml",$xmlBo->getXML()); $xmlBo->refresh(); } } $action_id = $this->_http->getParam("Redirect"); if ($this->_generic->actionIdExists($action_id)) { $infos = $this->_generic->translateActionId($action_id); $this->_generic->redirect($infos['controller']."/".$infos['scontroller']); } else { $controllers = $this->_generic->getTranslatedController("SLS_Bo","EditModel"); $this->_generic->redirect($controllers['controller']."/".$controllers['scontroller']."/name/".$db."_".$tableName); } }
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('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() { // Objects $xml = $this->getXML(); $user = $this->hasAuthorative(); $xml = $this->makeMenu($xml); $this->_generic->registerLink('Generate', 'SLS_Bo', 'GenerateBo'); $this->_generic->registerLink('Translation', 'SLS_Bo', 'GenerateBoAction', array("Actions" => "Boi18n")); $this->_generic->registerLink('FileUpload', 'SLS_Bo', 'GenerateBoAction', array("Actions" => "BoFileUpload")); $this->_generic->registerLink('ManageAdmin', 'SLS_Bo', 'GenerateBoAction', array("Actions" => "BoUserList|BoUserAdd|BoUserDelete|BoUserModify|BoUserStatus")); $this->_generic->registerLink('ProjectSettings', 'SLS_Bo', 'GenerateBoAction', array("Actions" => "BoProjectSettings")); $this->_generic->registerLink('Manage_Rights', 'SLS_Bo', 'ManageRights'); $this->_generic->registerLink('Manage_BoMenu', 'SLS_Bo', 'BoMenu'); $xml->addFullTag("delete",$this->_generic->getFullPath("SLS_Bo","DeleteBo",array(),false)); $xml->addFullTag("edit",$this->_generic->getFullPath("SLS_Bo","EditBo",array(),false)); $this->_xmlBo = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/bo.xml")); $bos = array(); // Search for user back-office $controllersXML = $this->_generic->getControllersXML(); $controller = array_shift($controllersXML->getTags("//controllers/controller[@isBo='true']/@name")); if (!empty($controller)) { $models = $this->getAllModels(); for($i=0 ; $i<$count=count($models) ; $i++) { $model = SLS_String::substrAfterFirstDelimiter($models[$i],"."); $db = SLS_String::substrBeforeFirstDelimiter($models[$i],"."); if ($this->boActionExist($model,$db)) { $this->_generic->useModel($model,$db,"user"); $class = ucfirst($db)."_".SLS_String::tableToClass($model); $object = new $class(); $bos[$class] = array("db" => $db, "className" => $class, "tableName" => $object->getTable(), "nb_actions" => count($this->getActionsBo($model,$db))); } } } asort($bos,SORT_REGULAR); $xml->startTag("bos"); foreach($bos as $bo) { $categoryExists = $this->_xmlBo->getTag("//sls_configs/entry[@type='category' and entry[@type='table' and @name='".strtolower($bo["db"]."_".$bo["tableName"])."']]/@name"); $xml->startTag("bo"); $xml->addFullTag("db",strtolower($bo["db"]),true); $xml->addFullTag("class",$bo["className"],true); $xml->addFullTag("table",$bo["tableName"],true); $xml->addFullTag("category",(empty($categoryExists)) ? "X" : $categoryExists,true); $xml->addFullTag("nb_actions",$bo["nb_actions"],true); $xml->endTag("bo"); } $xml->endTag("bos"); $pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/rights.xml"); $xmlRights = new SLS_XMLToolbox($pathsHandle); $result = $xmlRights->getTags("//sls_configs/entry"); $xml->addFullTag("admins_exist",(!empty($result)) ? "true" : "false",true); $xml->startTag("actions"); $action = array_shift($controllersXML->getTags("//controllers/controller[@isBo='true']/scontrollers/scontroller[@name='Boi18n']")); $action2 = array_shift($controllersXML->getTags("//controllers/controller[@isBo='true']/scontrollers/scontroller[@name='BoFileUpload']")); $action3 = array_shift($controllersXML->getTags("//controllers/controller[@isBo='true']/scontrollers/scontroller[@name='BoUserList']")); $action4 = array_shift($controllersXML->getTags("//controllers/controller[@isBo='true']/scontrollers/scontroller[@name='BoProjectSettings']")); $xml->startTag("action"); $xml->addFullTag("name","Translation",true); $xml->addFullTag("icon","boi18n16.png",true); $xml->addFullTag("existed",(!empty($action)) ? "true" : "false",true); $xml->endTag("action"); $xml->startTag("action"); $xml->addFullTag("name","FileUpload",true); $xml->addFullTag("icon","boupload16.png",true); $xml->addFullTag("existed",(!empty($action2)) ? "true" : "false",true); $xml->endTag("action"); $xml->startTag("action"); $xml->addFullTag("name","ManageAdmin",true); $xml->addFullTag("icon","boadmin16.png",true); $xml->addFullTag("existed",(!empty($action3)) ? "true" : "false",true); $xml->endTag("action"); $xml->startTag("action"); $xml->addFullTag("name","ProjectSettings",true); $xml->addFullTag("icon","bosettings16.png",true); $xml->addFullTag("existed",(!empty($action4)) ? "true" : "false",true); $xml->endTag("action"); $xml->endTag("actions"); if (SLS_Sql::getInstance()->tableExists("sls_graph")) { $this->_generic->useModel("Sls_graph",$this->defaultDb,"sls"); $className = ucfirst($this->defaultDb)."_Sls_graph"; $slsGraph = new $className; $nbGraph = $slsGraph->countModels("sls_graph"); } else $nbGraph = 0; $xml->addFullTag("nb_reporting",$nbGraph,true); $xml->addFullTag("url_reporting",$this->_generic->getFullPath("SLS_Bo","ReportingBo"),true); $this->saveXML($xml); }
public function action() { $user = $this->hasAuthorative(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); $sql = SLS_Sql::getInstance(); $slsGraphId = $this->_http->getParam('id'); $this->useModel('Sls_graph_query',$this->defaultDb,"sls"); $this->useModel('Sls_graph',$this->defaultDb,"sls"); $this->useModel('Sls_graph_query_column',$this->defaultDb,"sls"); $this->useModel('Sls_graph_query_join',$this->defaultDb,"sls"); $this->useModel('Sls_graph_query_group',$this->defaultDb,"sls"); $this->useModel('Sls_graph_query_where',$this->defaultDb,"sls"); $className = ucfirst($this->defaultDb)."_Sls_graph_query"; $slsGraphQuery = new $className(); $className = ucfirst($this->defaultDb)."_Sls_graph"; $slsGraph = new $className(); if($slsGraph->getModel($slsGraphId) === false || $slsGraphQuery->getModel($slsGraph->sls_graph_query_id) === false) $this->forward('SLS_Default', 'UrlError'); $slsGraphQueryCurrent = $slsGraphQuery; $errors = array(); $slsGraphTypes = array('pie', 'bar', 'pivot', 'list'); $slsGraphAggregationTypes = array('sum', 'avg', 'count'); $slsGraphAggregationTypesNeedField = array('sum', 'avg'); $slsGraphQueryOperators = array('like','notlike','startwith','endwith','equal','notequal','in','notin','lt','lte','gt','gte','null','notnull'); $this->queryOperatorsNeedField = array('like','notlike','startwith','endwith','equal','notequal','in','notin','lt','lte','gt','gte'); $tableFieldsValues = array(); $slsGraphQueryData = array( 'sls_graph_query_where' => array( 'sls_graph_query_where_type' => 'group', 'sls_graph_query_where_condition' => '', 'sls_graph_query_where_column' => '', 'sls_graph_query_where_operator' => '', 'sls_graph_query_where_value' => '', 'sls_graph_query_where_children' => array(), 'sls_graph_query_where_root' => 'true', ) ); $slsGraphData = array(); $slsGraphQueryWheres = array(); # reload if($this->_http->getParam('reload') == 'true') { $xmlFk = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml")); $slsGraphQueryData = $this->_http->getParam('sls_graph_query'); $slsGraphData = $this->_http->getParam('sls_graph'); if(!$slsGraph->setSlsGraphTitle($slsGraphData['sls_graph_title'])) $errors['sls_graph_title'] = 'Titre invalide'; $tmp = explode('.', $slsGraphQueryData['sls_graph_query_table']); if(count($tmp) == 2) { $slsGraphQueryDbAlias = $tmp[0]; $slsGraphQueryTable = $tmp[1]; $slsGraphQueryTableAlias = $this->getTableAlias($slsGraphQueryTable); $sql->changeDb($slsGraphQueryDbAlias); } else { $slsGraphQueryTableAlias = $slsGraphQueryDbAlias = $slsGraphQueryTable = ''; } if(!$slsGraphQuery->setSlsGraphQueryDbAlias($slsGraphQueryDbAlias) || !$slsGraphQuery->setSlsGraphQueryTable($slsGraphQueryTable) || !$slsGraphQuery->setSlsGraphQueryTableAlias($slsGraphQueryTableAlias) || !$sql->tableExists($slsGraphQueryTable)) $errors['sls_graph_query_table'] = 'Table invalide'; else { $tableFields = $sql->showColumns($slsGraphQueryTable); $tableFieldsValues = array_map(array($this,'filterFields'), $tableFields); } if(!$slsGraph->setSlsGraphType($slsGraphData['sls_graph_type'])) { $errors['sls_graph_type'] = 'Type invalide'; } else if($slsGraphData['sls_graph_type'] == 'pie') { # query columns $tmp = explode('.', $slsGraphData['sls_graph_pie_group_by']); $column = $tmp[1]; $columnConcat = $column; $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; $slsGraphQueryColumn1 = new $className(); $slsGraphQueryColumn1->setSlsGraphQueryColumnName($column); $slsGraphQueryColumn1->setSlsGraphQueryColumnAlias('legend_id'); $slsGraphQueryColumn1->setSlsGraphQueryColumnTable($slsGraphQueryTable); $slsGraphQueryColumn1->setSlsGraphQueryColumnTableAlias($slsGraphQueryTableAlias); $columnFk = array_shift($xmlFk->getTagsAttributes("//sls_configs/entry[@tableFk='".strtolower($slsGraphQueryDbAlias.'_'.$slsGraphQueryTable)."' and @columnFk = '".$column."']",array("tablePk","labelPk"))); if(!empty($columnFk)) { $tablePk = $columnFk['attributes'][0]['value']; $labelPk = $columnFk['attributes'][1]['value']; $dbPk = SLS_String::substrBeforeFirstDelimiter($tablePk, '_'); $tablePk = SLS_String::substrAfterFirstDelimiter($tablePk, '_'); $this->_generic->useModel($tablePk, $dbPk, "user"); $classFk = ucfirst($dbPk)."_".SLS_String::tableToClass($tablePk); $objectFk = new $classFk(); $columns = array(); $columnsLabel = array(); $clause = array(); $render = array(); $columnTable = $objectFk->getTable(); # add join $i = 1; # target $className = ucfirst($this->defaultDb)."_Sls_graph_query_join"; ${slsGraphQueryJoin.$i} = new $className(); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableTarget($slsGraphQueryTable); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableAliasTarget($slsGraphQueryTableAlias); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinColumnTarget($column); # /target # source ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableSource($columnTable); $slsGraphQueryJoin = $this->getTableAlias($columnTable); /*$slsGraphQueryJoin = $columnTable.$aliasIndex; $aliasIndex++;*/ ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableAliasSource($slsGraphQueryJoin); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinColumnSource($objectFk->getPrimaryKey()); # /source ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinMode('left'); $i++; # /add join foreach($objectFk->getParams() as $key => $value) { array_push($columns,"`".$key."`"); if (SLS_String::contains($labelPk,$key)) $columnsLabel[$key] = strpos($labelPk,$key); } array_multisort($columnsLabel); foreach($columnsLabel as $columnLabel => $offset) array_push($clause,$columnLabel); $pattern = str_replace("'","''",$labelPk); foreach($clause as $columnC) $pattern = str_replace($columnC,"',"."CAST(".$slsGraphQueryJoin.".`".$columnC."` AS CHAR),'",$pattern); $columnConcat = "CONCAT('".$pattern."')"; } $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; $slsGraphQueryColumn2 = new $className(); $slsGraphQueryColumn2->setSlsGraphQueryColumnName($columnConcat); $slsGraphQueryColumn2->setSlsGraphQueryColumnAlias('legend'); $slsGraphQueryColumn2->setSlsGraphQueryColumnTable($slsGraphQueryTable); $slsGraphQueryColumn2->setSlsGraphQueryColumnTableAlias($slsGraphQueryTableAlias); $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; $slsGraphQueryColumn3 = new $className(); $slsGraphQueryColumn3->setSlsGraphQueryColumnAggregation('count'); $slsGraphQueryColumn3->setSlsGraphQueryColumnAlias('count'); $slsGraphQueryColumn3->setSlsGraphQueryColumnTable($slsGraphQueryTable); $slsGraphQueryColumn3->setSlsGraphQueryColumnTableAlias($slsGraphQueryTableAlias); # /query columns # query groups $className = ucfirst($this->defaultDb)."_Sls_graph_query_group"; $slsGraphQueryGroup1 = new $className(); if(!$slsGraphQueryGroup1->setSlsGraphQueryGroupColumn($column)/* || !in_array($slsGraphData['sls_graph_pie_group_by'], $tableFieldsValues)*/) $errors['sls_graph_pie_group_by'] = 'Champ groupé invalide'; # /query groups $sql->changeDb($slsGraphQueryDbAlias); $joins = $this->getQueryJoin($slsGraphQueryTable, $slsGraphQueryTableAlias, array($slsGraphData['sls_graph_pie_group_by'])); } else if($slsGraphData['sls_graph_type'] == 'bar') { $i = 1; $j = 1; # query columns $tmp = explode('.', $slsGraphData['sls_graph_bar_aggregation_field']); if(count($tmp) == 2) $columnAggregationField = $tmp[1]; else $columnAggregationField = ''; $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; ${slsGraphQueryColumn.$j} = new $className(); if(empty($slsGraphData['sls_graph_bar_aggregation']) || !${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnAggregation($slsGraphData['sls_graph_bar_aggregation']) || !${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTable($slsGraphQueryTable) || !${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTableAlias($slsGraphQueryTableAlias) || !${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnAlias('value')) $errors['sls_graph_bar_aggregation'] = 'Aggrégation invalide'; if(in_array($slsGraphData['sls_graph_bar_aggregation'], $slsGraphAggregationTypesNeedField) && (empty($columnAggregationField) || !${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnName($columnAggregationField))) $errors['sls_graph_bar_aggregation_field'] = 'Champ aggrégation invalide'; $j++; # query column group $tmp = explode('.', $slsGraphData['sls_graph_bar_group_by']); $column = $tmp[1]; $columnConcat = $column; $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; ${slsGraphQueryColumn.$j} = new $className(); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnName($column); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnAlias('legend_group_id'); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTable($slsGraphQueryTable); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTableAlias($slsGraphQueryTableAlias); $j++; $columnFk = array_shift($xmlFk->getTagsAttributes("//sls_configs/entry[@tableFk='".strtolower($slsGraphQueryDbAlias.'_'.$slsGraphQueryTable)."' and @columnFk = '".$column."']",array("tablePk","labelPk"))); if(!empty($columnFk)) { $tablePk = $columnFk['attributes'][0]['value']; $labelPk = $columnFk['attributes'][1]['value']; $dbPk = SLS_String::substrBeforeFirstDelimiter($tablePk, '_'); $tablePk = SLS_String::substrAfterFirstDelimiter($tablePk, '_'); $this->_generic->useModel($tablePk, $dbPk, "user"); $classFk = ucfirst($dbPk)."_".SLS_String::tableToClass($tablePk); $objectFk = new $classFk(); $columns = array(); $columnsLabel = array(); $clause = array(); $render = array(); $columnTable = $objectFk->getTable(); # add join # target $className = ucfirst($this->defaultDb)."_Sls_graph_query_join"; ${slsGraphQueryJoin.$i} = new $className(); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableTarget($slsGraphQueryTable); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableAliasTarget($slsGraphQueryTableAlias); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinColumnTarget($column); # /target # source ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableSource($columnTable); $slsGraphQueryJoin = $this->getTableAlias($columnTable); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableAliasSource($slsGraphQueryJoin); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinColumnSource($objectFk->getPrimaryKey()); # /source ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinMode('left'); $i++; # /add join foreach($objectFk->getParams() as $key => $value) { array_push($columns,"`".$key."`"); if (SLS_String::contains($labelPk,$key)) $columnsLabel[$key] = strpos($labelPk,$key); } array_multisort($columnsLabel); foreach($columnsLabel as $columnLabel => $offset) array_push($clause,$columnLabel); $pattern = str_replace("'","''",$labelPk); foreach($clause as $columnC) $pattern = str_replace($columnC,"',"."CAST(".$slsGraphQueryJoin.".`".$columnC."` AS CHAR),'",$pattern); $columnConcat = "CONCAT('".$pattern."')"; } $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; ${slsGraphQueryColumn.$j} = new $className(); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnName($columnConcat); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnAlias('legend_group'); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTable($slsGraphQueryTable); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTableAlias($slsGraphQueryTableAlias); $j++; # query column group # query column stacked if(!empty($slsGraphData['sls_graph_bar_stacked_field'])) { $tmp = explode('.', $slsGraphData['sls_graph_bar_stacked_field']); $column = $tmp[1]; $columnConcat = $column; $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; ${slsGraphQueryColumn.$j} = new $className(); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnName($column); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnAlias('legend_stacked_id'); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTable($slsGraphQueryTable); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTableAlias($slsGraphQueryTableAlias); $j++; $columnFk = array_shift($xmlFk->getTagsAttributes("//sls_configs/entry[@tableFk='".strtolower($slsGraphQueryDbAlias.'_'.$slsGraphQueryTable)."' and @columnFk = '".$column."']",array("tablePk","labelPk"))); if(!empty($columnFk)) { $tablePk = $columnFk['attributes'][0]['value']; $labelPk = $columnFk['attributes'][1]['value']; $dbPk = SLS_String::substrBeforeFirstDelimiter($tablePk, '_'); $tablePk = SLS_String::substrAfterFirstDelimiter($tablePk, '_'); $this->_generic->useModel($tablePk, $dbPk, "user"); $classFk = ucfirst($dbPk)."_".SLS_String::tableToClass($tablePk); $objectFk = new $classFk(); $columns = array(); $columnsLabel = array(); $clause = array(); $render = array(); $columnTable = $objectFk->getTable(); # add join # target $className = ucfirst($this->defaultDb)."_Sls_graph_query_join"; ${slsGraphQueryJoin.$i} = new $className(); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableTarget($slsGraphQueryTable); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableAliasTarget($slsGraphQueryTableAlias); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinColumnTarget($column); # /target # source ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableSource($columnTable); $slsGraphQueryJoin = $this->getTableAlias($columnTable); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableAliasSource($slsGraphQueryJoin); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinColumnSource($objectFk->getPrimaryKey()); # /source ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinMode('left'); $i++; # /add join foreach($objectFk->getParams() as $key => $value) { array_push($columns,"`".$key."`"); if (SLS_String::contains($labelPk,$key)) $columnsLabel[$key] = strpos($labelPk,$key); } array_multisort($columnsLabel); foreach($columnsLabel as $columnLabel => $offset) array_push($clause,$columnLabel); $pattern = str_replace("'","''",$labelPk); foreach($clause as $columnC) $pattern = str_replace($columnC,"',"."CAST(".$slsGraphQueryJoin.".`".$columnC."` AS CHAR),'",$pattern); $columnConcat = "CONCAT('".$pattern."')"; } $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; ${slsGraphQueryColumn.$j} = new $className(); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnName($columnConcat); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnAlias('legend_stacked'); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTable($slsGraphQueryTable); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTableAlias($slsGraphQueryTableAlias); } # query column stacked # /query columns # query groups $tmp = explode('.', $slsGraphData['sls_graph_bar_group_by']); $columnGroupByField = $tmp[1]; $className = ucfirst($this->defaultDb)."_Sls_graph_query_group"; $slsGraphQueryGroup1 = new $className(); if(!$slsGraphQueryGroup1->setSlsGraphQueryGroupColumn($columnGroupByField)) $errors['sls_graph_bar_group_by'] = 'Champ groupé invalide'; if(!empty($slsGraphData['sls_graph_bar_stacked_field'])) { $tmp = explode('.', $slsGraphData['sls_graph_bar_stacked_field']); $columnStackedField = $tmp[1]; $className = ucfirst($this->defaultDb)."_Sls_graph_query_group"; $slsGraphQueryGroup2 = new $className(); if(!$slsGraphQueryGroup2->setSlsGraphQueryGroupColumn($columnStackedField)) $errors['sls_graph_bar_stacked_field'] = 'Champ réservé invalide'; } # /query groups $joins = $this->getQueryJoin($slsGraphQueryTable, $slsGraphQueryTableAlias, array($slsGraphData['sls_graph_bar_group_by'])); } else if($slsGraphData['sls_graph_type'] == 'pivot') { $i = 1; $j = 1; # query columns $tmp = explode('.', $slsGraphData['sls_graph_pivot_aggregation_field']); if(count($tmp) == 2) $columnAggregationField = $tmp[1]; else $columnAggregationField = ''; $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; ${slsGraphQueryColumn.$j} = new $className(); if(empty($slsGraphData['sls_graph_pivot_aggregation']) || !${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnAggregation($slsGraphData['sls_graph_pivot_aggregation']) || !${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTable($slsGraphQueryTable) || !${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTableAlias($slsGraphQueryTableAlias) || !${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnAlias('value')) $errors['sls_graph_pivot_aggregation'] = 'Aggrégation invalide'; if(in_array($slsGraphData['sls_graph_pivot_aggregation'], $slsGraphAggregationTypesNeedField) && (empty($columnAggregationField) || !${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnName($columnAggregationField))) $errors['sls_graph_pivot_aggregation_field'] = 'Champ aggrégation invalide'; $j++; # query column line $tmp = explode('.', $slsGraphData['sls_graph_pivot_line']); $column = $tmp[1]; $columnConcat = $tmp[1]; $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; ${slsGraphQueryColumn.$j} = new $className(); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnName($column); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnAlias('legend_line_id'); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTable($slsGraphQueryTable); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTableAlias($slsGraphQueryTableAlias); $j++; $columnFk = array_shift($xmlFk->getTagsAttributes("//sls_configs/entry[@tableFk='".strtolower($slsGraphQueryDbAlias.'_'.$slsGraphQueryTable)."' and @columnFk = '".$column."']",array("tablePk","labelPk"))); if(!empty($columnFk)) { $tablePk = $columnFk['attributes'][0]['value']; $labelPk = $columnFk['attributes'][1]['value']; $dbPk = SLS_String::substrBeforeFirstDelimiter($tablePk, '_'); $tablePk = SLS_String::substrAfterFirstDelimiter($tablePk, '_'); $this->_generic->useModel($tablePk, $dbPk, "user"); $classFk = ucfirst($dbPk)."_".SLS_String::tableToClass($tablePk); $objectFk = new $classFk(); $columns = array(); $columnsLabel = array(); $clause = array(); $render = array(); $columnTable = $objectFk->getTable(); # add join # target $className = ucfirst($this->defaultDb)."_Sls_graph_query_join"; ${slsGraphQueryJoin.$i} = new $className(); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableTarget($slsGraphQueryTable); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableAliasTarget($slsGraphQueryTableAlias); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinColumnTarget($column); # /target # source ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableSource($columnTable); $slsGraphQueryJoin = $this->getTableAlias($columnTable); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableAliasSource($slsGraphQueryJoin); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinColumnSource($objectFk->getPrimaryKey()); # /source ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinMode('left'); $i++; # /add join foreach($objectFk->getParams() as $key => $value) { array_push($columns,"`".$key."`"); if (SLS_String::contains($labelPk,$key)) $columnsLabel[$key] = strpos($labelPk,$key); } array_multisort($columnsLabel); foreach($columnsLabel as $columnLabel => $offset) array_push($clause,$columnLabel); $pattern = str_replace("'","''",$labelPk); foreach($clause as $columnC) $pattern = str_replace($columnC,"',"."CAST(".$slsGraphQueryJoin.".`".$columnC."` AS CHAR),'",$pattern); $columnConcat = "CONCAT('".$pattern."')"; } $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; ${slsGraphQueryColumn.$j} = new $className(); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnName($columnConcat); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnAlias('legend_line'); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTable($slsGraphQueryTable); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTableAlias($slsGraphQueryTableAlias); $j++; # query column line # query column column $tmp = explode('.', $slsGraphData['sls_graph_pivot_column']); $column = $tmp[1]; $columnConcat = $column; $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; ${slsGraphQueryColumn.$j} = new $className(); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnName($column); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnAlias('legend_column_id'); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTable($slsGraphQueryTable); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTableAlias($slsGraphQueryTableAlias); $j++; $columnFk = array_shift($xmlFk->getTagsAttributes("//sls_configs/entry[@tableFk='".strtolower($slsGraphQueryDbAlias.'_'.$slsGraphQueryTable)."' and @columnFk = '".$column."']",array("tablePk","labelPk"))); if(!empty($columnFk)) { $tablePk = $columnFk['attributes'][0]['value']; $labelPk = $columnFk['attributes'][1]['value']; $dbPk = SLS_String::substrBeforeFirstDelimiter($tablePk, '_'); $tablePk = SLS_String::substrAfterFirstDelimiter($tablePk, '_'); $this->_generic->useModel($tablePk, $dbPk, "user"); $classFk = ucfirst($dbPk)."_".SLS_String::tableToClass($tablePk); $objectFk = new $classFk(); $columns = array(); $columnsLabel = array(); $clause = array(); $render = array(); $columnTable = $objectFk->getTable(); # add join # target $className = ucfirst($this->defaultDb)."_Sls_graph_query_join"; ${slsGraphQueryJoin.$i} = new $className(); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableTarget($slsGraphQueryTable); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableAliasTarget($slsGraphQueryTableAlias); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinColumnTarget($column); # /target # source ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableSource($columnTable); $slsGraphQueryJoin = $this->getTableAlias($columnTable); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinTableAliasSource($slsGraphQueryJoin); ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinColumnSource($objectFk->getPrimaryKey()); # /source ${slsGraphQueryJoin.$i}->setSlsGraphQueryJoinMode('left'); $i++; # /add join foreach($objectFk->getParams() as $key => $value) { array_push($columns,"`".$key."`"); if (SLS_String::contains($labelPk,$key)) $columnsLabel[$key] = strpos($labelPk,$key); } array_multisort($columnsLabel); foreach($columnsLabel as $columnLabel => $offset) array_push($clause,$columnLabel); $pattern = str_replace("'","''",$labelPk); foreach($clause as $columnC) $pattern = str_replace($columnC,"',"."CAST(".$slsGraphQueryJoin.".`".$columnC."` AS CHAR),'",$pattern); $columnConcat = "CONCAT('".$pattern."')"; } $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; ${slsGraphQueryColumn.$j} = new $className(); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnName($columnConcat); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnAlias('legend_column'); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTable($slsGraphQueryTable); ${slsGraphQueryColumn.$j}->setSlsGraphQueryColumnTableAlias($slsGraphQueryTableAlias); # query column column # /query columns # query groups $tmp = explode('.', $slsGraphData['sls_graph_pivot_line']); $columnLine = $tmp[1]; $className = ucfirst($this->defaultDb)."_Sls_graph_query_group"; $slsGraphQueryGroup1 = new $className(); if(!$slsGraphQueryGroup1->setSlsGraphQueryGroupColumn($columnLine)) $errors['sls_graph_pivot_line'] = 'Champ Ligne invalide'; $tmp = explode('.', $slsGraphData['sls_graph_pivot_column']); $columnColumn = $tmp[1]; $className = ucfirst($this->defaultDb)."_Sls_graph_query_group"; $slsGraphQueryGroup2 = new $className(); if(!$slsGraphQueryGroup2->setSlsGraphQueryGroupColumn($columnColumn)) $errors['sls_graph_pivot_column'] = 'Champ colonne invalide'; # /query groups $joins = $this->getQueryJoin($slsGraphQueryTable, $slsGraphQueryTableAlias, array($slsGraphData['sls_graph_pivot_column'])); } else if($slsGraphData['sls_graph_type'] == 'list') { # columns $i = 1; $j = 1; $joins = array(); foreach($slsGraphQueryData['sls_graph_query_column'] as $col) { $column = $col['sls_graph_query_column_value']; $path = explode('|', $column); $nbJoins = count($path); $data = explode('.', $path[$nbJoins-1]); $table = $data[0]; $column = $data[1]; $joinBefore = null; # joins for($k = 0; $k<$nbJoins ; $k++) { if($k == 0) { $columns = $sql->showColumns($slsGraphQueryTable); $columnSource = array_shift(array_filter($columns, array($this,'filterPK'))); $columnSourcePK = $columnSource->Field; $join = array( 'sls_graph_query_join_table_source' => $slsGraphQueryTable, 'sls_graph_query_join_column_source' => $columnSourcePK ); } else { $dataSource = explode('.', $path[$k]); $dataTarget = explode('.', $path[$k-1]); $tableSource = $dataSource[0]; $tableTarget = $dataTarget[0]; $columnSource = $dataSource[1]; $columnTarget = $dataTarget[1]; $columns = $sql->showColumns($tableSource); $columnSourcePK = array_shift(array_filter($columns, array($this,'filterPK')))->Field; $columns = $sql->showColumns($tableTarget); $this->columnTarget = $columnTarget; $columnTargetComment = array_shift(array_filter($columns, array($this,'filterFieldTarget')))->Comment; $join = array( 'sls_graph_query_join_table_target' => $tableTarget, 'sls_graph_query_join_column_target' =>$columnTarget, 'sls_graph_query_join_table_comment_target' => empty($columnTargetComment) ? $columnTarget : $columnTargetComment, 'sls_graph_query_join_table_source' => $tableSource, 'sls_graph_query_join_column_source' => $columnSourcePK ); } $joinSearch = $this->array_search_multi($join, $joins); if(empty($joinSearch)) { $join['sls_graph_query_join_table_alias_source'] = ($k == 0) ? $slsGraphQueryTableAlias : $this->getTableAlias($join['sls_graph_query_join_table_source']); /*$join['sls_graph_query_join_table_source'].$aliasIndex++*/; if($k > 0) { $className = ucfirst($this->defaultDb)."_Sls_graph_query_join"; ${slsGraphQueryJoin.$j} = new $className(); ${slsGraphQueryJoin.$j}->setSlsGraphQueryJoinTableSource($join['sls_graph_query_join_table_source']); ${slsGraphQueryJoin.$j}->setSlsGraphQueryJoinTableAliasSource($join['sls_graph_query_join_table_alias_source']); ${slsGraphQueryJoin.$j}->setSlsGraphQueryJoinColumnSource($join['sls_graph_query_join_column_source']); ${slsGraphQueryJoin.$j}->setSlsGraphQueryJoinTableTarget($join['sls_graph_query_join_table_target']); ${slsGraphQueryJoin.$j}->setSlsGraphQueryJoinTableAliasTarget($joinBefore['sls_graph_query_join_table_alias_source']); ${slsGraphQueryJoin.$j}->setSlsGraphQueryJoinColumnTarget($join['sls_graph_query_join_column_target']); ${slsGraphQueryJoin.$j}->setSlsGraphQueryJoinMode('left'); $j++; } array_push($joins, $join); } else $join = $joinSearch; $joinBefore = $join; } # /joins $columns = $sql->showColumns($table); $this->column = $column; $columnComment = array_shift(array_filter($columns, array($this,'filterColumnField')))->Comment; $tableComment = $join['sls_graph_query_join_table_comment_target']; if(empty($tableComment)) { $tables = $sql->showTables(); $this->table = $table; $tableComment = array_shift(array_filter($tables, array($this,'filterTable4')))->Comment; } $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; ${slsGraphQueryColumn.$i} = new $className(); ${slsGraphQueryColumn.$i}->setSlsGraphQueryColumnTable($join['sls_graph_query_join_table_source']); ${slsGraphQueryColumn.$i}->setSlsGraphQueryColumnTableAlias($join['sls_graph_query_join_table_alias_source']); ${slsGraphQueryColumn.$i}->setSlsGraphQueryColumnName($column); ${slsGraphQueryColumn.$i}->setSlsGraphQueryColumnAlias($tableComment.' - '.$columnComment); $i++; } # /columns } # query where if(!empty($slsGraphQueryData['sls_graph_query_where'])) { $i = 0; $j = 0; $this->iterateSetSlsGraphQueryWhere($slsGraphQueryData['sls_graph_query_where'], $i, $j, $slsGraphQueryWheres, $errors, $joins); } # /query where if (empty($errors)) { $sql->changeDb($this->defaultDb); # query $this->deleteQuery($slsGraphQueryCurrent->sls_graph_query_id); $slsGraphQuery->create(); # /query # graph $slsGraph->setSlsGraphQueryId($slsGraphQuery->sls_graph_query_id); $slsGraph->save(); # /graph # query joins $i = 1; //$slsGraphQueryJoin1 while(${slsGraphQueryJoin.$i}) { ${slsGraphQueryJoin.$i}->setSlsGraphQueryId($slsGraphQuery->sls_graph_query_id); ${slsGraphQueryJoin.$i}->create(); $i++; } # /query joins # query columns $i = 1; while(${slsGraphQueryColumn.$i}) { ${slsGraphQueryColumn.$i}->setSlsGraphQueryId($slsGraphQuery->sls_graph_query_id); ${slsGraphQueryColumn.$i}->create(); $i++; } # /query columns # query groups $i = 1; while(${slsGraphQueryGroup.$i}) { ${slsGraphQueryGroup.$i}->setSlsGraphQueryGroupTable($slsGraphQueryTable); ${slsGraphQueryGroup.$i}->setSlsGraphQueryGroupTableAlias($slsGraphQueryTableAlias); ${slsGraphQueryGroup.$i}->setSlsGraphQueryId($slsGraphQuery->sls_graph_query_id); ${slsGraphQueryGroup.$i}->create(); $i++; } # /query groups # query where if(!empty($slsGraphQueryData['sls_graph_query_where'])) { $i = 0; $this->iterateCreateQueryWhere($slsGraphQueryData['sls_graph_query_where'], 0, $i, $slsGraphQueryWheres, $slsGraphQuery->sls_graph_query_id); } # /query where $this->forward('SLS_Bo', 'ReportingBo'); } else { $xml->startTag("errors"); foreach($errors as $key => $error) { if($key == 'sls_graph_query_where') { foreach($error as $slsGraphQueryWhereIndex => $slsGraphQueryWhereErrors) { foreach($slsGraphQueryWhereErrors as $slsGraphQueryWhereKey => $slsGraphQueryWhereError) { $xml->addFullTag("error", $slsGraphQueryWhereError, true, array("num" => $slsGraphQueryWhereIndex, "column" => $slsGraphQueryWhereKey)); } } } else $xml->addFullTag("error", $error, true, array("column" => $key)); } $xml->endTag("errors"); } $slsGraphQueryData = $this->_http->getParam('sls_graph_query'); } # /reload # load else { $this->useModel('Sls_graph_query',$this->defaultDb,"sls"); $this->useModel('Sls_graph',$this->defaultDb,"sls"); $this->useModel('Sls_graph_query_column',$this->defaultDb,"sls"); $this->useModel('Sls_graph_query_join',$this->defaultDb,"sls"); $this->useModel('Sls_graph_query_group',$this->defaultDb,"sls"); $this->useModel('Sls_graph_query_where',$this->defaultDb,"sls"); $className = ucfirst($this->defaultDb)."_Sls_graph_query_column"; $slsGraphQueryColumn = new $className(); $className = ucfirst($this->defaultDb)."_Sls_graph_query_join"; $slsGraphQueryJoin = new $className(); $className = ucfirst($this->defaultDb)."_Sls_graph_query_where"; $slsGraphQueryWhere = new $className(); $className = ucfirst($this->defaultDb)."_Sls_graph_query_group"; $slsGraphQueryGroup = new $className(); $slsGraphQueryId = $slsGraphQueryCurrent->sls_graph_query_id; $tables = array($slsGraphQueryCurrent->sls_graph_query_table => !empty($slsGraphQueryCurrent->sls_graph_query_alias) ? $slsGraphQuery->sls_graph_query_alias : $slsGraphQueryCurrent->sls_graph_query_table); $columns = $slsGraphQueryColumn->searchModels("sls_graph_query_column",array(),array(0=>array("column"=>"sls_graph_query_id","value"=>$slsGraphQueryId,"mode"=>"equal")),array(),array(array("column"=>"sls_graph_query_column_id","order"=>"asc"))); $joins = $slsGraphQueryJoin->searchModels("sls_graph_query_join",array(),array(0=>array("column"=>"sls_graph_query_id","value"=>$slsGraphQueryId,"mode"=>"equal")),array(),array(array("column"=>"sls_graph_query_join_id","order"=>"asc"))); $wheres = $slsGraphQueryWhere->searchModels("sls_graph_query_where",array(),array(0=>array("column"=>"sls_graph_query_id","value"=>$slsGraphQueryId,"mode"=>"equal")),array(),array(array("column"=>"sls_graph_query_where_id","order"=>"asc"))); $groups = $slsGraphQueryGroup->searchModels("sls_graph_query_group",array(),array(0=>array("column"=>"sls_graph_query_id","value"=>$slsGraphQueryId,"mode"=>"equal")),array(),array(array("column"=>"sls_graph_query_group_id","order"=>"asc"))); if($slsGraph->sls_graph_type == 'pie') { $slsGraphData['sls_graph_pie_group_by'] = !empty($groups) ? $slsGraphQueryCurrent->sls_graph_query_table_alias.'.'.$groups[0]->sls_graph_query_group_column : ''; } else if($slsGraph->sls_graph_type == 'bar') { $slsGraphData['sls_graph_bar_aggregation'] = !empty($columns) ? $columns[0]->sls_graph_query_column_aggregation : ''; $slsGraphData['sls_graph_bar_aggregation_field'] = !empty($columns) && !empty($columns[0]->sls_graph_query_column_name) ? $slsGraphQueryCurrent->sls_graph_query_table_alias.'.'.$columns[0]->sls_graph_query_column_name : ''; $slsGraphData['sls_graph_bar_group_by'] = !empty($groups) && !empty($groups[0]->sls_graph_query_group_column) ? $slsGraphQueryCurrent->sls_graph_query_table_alias.'.'.$groups[0]->sls_graph_query_group_column : ''; $slsGraphData['sls_graph_bar_stacked_field'] = !empty($groups) && !empty($groups[1]->sls_graph_query_group_column) ? $slsGraphQueryCurrent->sls_graph_query_table_alias.'.'.$groups[1]->sls_graph_query_group_column : ''; } else if($slsGraph->sls_graph_type == 'pivot') { $slsGraphData['sls_graph_pivot_aggregation'] = !empty($columns) ? $columns[0]->sls_graph_query_column_aggregation : ''; $slsGraphData['sls_graph_pivot_aggregation_field'] = !empty($columns) && !empty($columns[0]->sls_graph_query_column_name) ? $slsGraphQueryCurrent->sls_graph_query_table_alias.'.'.$columns[0]->sls_graph_query_column_name : ''; $slsGraphData['sls_graph_pivot_line'] = !empty($groups) && !empty($groups[0]->sls_graph_query_group_column) ? $slsGraphQueryCurrent->sls_graph_query_table_alias.'.'.$groups[0]->sls_graph_query_group_column : ''; $slsGraphData['sls_graph_pivot_column'] = !empty($groups) && !empty($groups[1]->sls_graph_query_group_column) ? $slsGraphQueryCurrent->sls_graph_query_table_alias.'.'.$groups[1]->sls_graph_query_group_column : ''; } foreach($slsGraph->getParams() as $key => $value) $slsGraphData[$key] = $value; if ($slsGraphQueryCurrent->sls_graph_query_db_alias != $sql->getCurrentDb()) $sql->changeDb($slsGraphQueryCurrent->sls_graph_query_db_alias); $tableFields = $sql->showColumns($slsGraphQueryCurrent->sls_graph_query_table); foreach($slsGraphQueryCurrent->getParams() as $key => $value) { if($key == 'sls_graph_query_table') $value = $slsGraphQueryCurrent->sls_graph_query_db_alias.'.'.$value; $slsGraphQueryData[$key] = $value; } $slsGraphQueryData['sls_graph_query_column'] = $this->iterateFormatQueryColumnToArray($columns, $joins); $slsGraphQueryData['sls_graph_query_where'] = $this->iterateFormatQueryWhereToArray($wheres, 0); } # /load # graph $xml->startTag('sls_graph'); foreach($slsGraphData as $key => $value) $xml->addFullTag($key, $value, true); $xml->addFullTag('graph_table_fields_class', empty($tableFields) ? 'hide' : '', true); $xml->startTag('sls_graph_query'); foreach($slsGraphQueryData as $key => $value) { if($key == 'sls_graph_query_where') { $i = 0; $j = 0; $this->iterateAddXmlQueryWhere($value, $i, $j, $xml); } else if($key == 'sls_graph_query_column') { $xml->startTag('sls_graph_query_columns'); foreach($value as $column) { $xml->startTag('sls_graph_query_column'); $xml->addFullTag('sls_graph_query_column_value', $column['sls_graph_query_column_value'], true); $xml->addFullTag('sls_graph_query_column_label', $column['sls_graph_query_column_label'], true); $xml->endTag('sls_graph_query_column'); } $xml->endTag('sls_graph_query_columns'); } else $xml->addFullTag($key, $value, true); } $xml->endTag('sls_graph_query'); $xml->endTag('sls_graph'); # /graph $labels = array( 'SLS_GRAPH_TYPE_PIE' => "Pie Chart", 'SLS_GRAPH_TYPE_BAR' => "Bar Chart", 'SLS_GRAPH_TYPE_PIVOT' => "Pivot Table", 'SLS_GRAPH_TYPE_LIST' => "List", 'SLS_AGGREGATION_TYPE_SUM' => "SUM", 'SLS_AGGREGATION_TYPE_AVG' => "AVG", 'SLS_AGGREGATION_TYPE_COUNT' => "COUNT", 'SLS_AGGREGATION_TYPE_SUM_LABEL' => "Sum", 'SLS_AGGREGATION_TYPE_AVG_LABEL' => "Average", 'SLS_AGGREGATION_TYPE_COUNT_LABEL' => "Total", 'SLS_QUERY_OPERATOR_LIKE' => "LIKE", 'SLS_QUERY_OPERATOR_NOTLIKE' => "NOT LIKE", 'SLS_QUERY_OPERATOR_STARTWITH' => "START WITH", 'SLS_QUERY_OPERATOR_ENDWITH' => "END WITH", 'SLS_QUERY_OPERATOR_EQUAL' => "EQUAL", 'SLS_QUERY_OPERATOR_NOTEQUAL' => "NOT EQUAL", 'SLS_QUERY_OPERATOR_IN' => "IN", 'SLS_QUERY_OPERATOR_NOTIN' => "NOT IN", 'SLS_QUERY_OPERATOR_LT' => "LESS THAN", 'SLS_QUERY_OPERATOR_LTE' => "LESS THAN EQUAL", 'SLS_QUERY_OPERATOR_GT' => "GREATER THAN", 'SLS_QUERY_OPERATOR_GTE' => "GREATER THAN EQUAL", 'SLS_QUERY_OPERATOR_NULL' => "IS NULL", 'SLS_QUERY_OPERATOR_NOTNULL' => "IS NOT NULL" ); # graph types $xml->startTag('sls_graph_types'); foreach($slsGraphTypes as $slsGraphType){ $xml->startTag('sls_graph_type'); $xml->addFullTag('sls_graph_type_value', $slsGraphType, true); $xml->addFullTag('sls_graph_type_label', $labels['SLS_GRAPH_TYPE_'.mb_strtoupper($slsGraphType, 'UTF-8')], true); $xml->endTag('sls_graph_type'); } $xml->endTag('sls_graph_types'); # /graph types # aggregation types $xml->startTag('sls_graph_aggregation_types'); foreach($slsGraphAggregationTypes as $slsGraphAggregationType){ $xml->startTag('sls_graph_aggregation_type'); $xml->addFullTag('sls_graph_aggregation_type_value', $slsGraphAggregationType, true); $xml->addFullTag('sls_graph_aggregation_type_label', $labels['SLS_AGGREGATION_TYPE_'.mb_strtoupper($slsGraphAggregationType, 'UTF-8')], true); $xml->endTag('sls_graph_aggregation_type'); } $xml->endTag('sls_graph_aggregation_types'); # /aggregation types # query operators $xml->startTag('sls_graph_query_operators'); foreach($slsGraphQueryOperators as $slsGraphQueryOperator){ $xml->startTag('sls_graph_query_operator'); $xml->addFullTag('sls_graph_query_operator_value', $slsGraphQueryOperator, true); $xml->addFullTag('sls_graph_query_operator_label', $labels['SLS_QUERY_OPERATOR_'.mb_strtoupper($slsGraphQueryOperator, 'UTF-8')], true); $xml->endTag('sls_graph_query_operator'); } $xml->endTag('sls_graph_query_operators'); # /query operators # tables $xml->startTag('tables'); $dbs = $sql->getDbs(); foreach($dbs as $db) { $sql->changeDb($db); $tables = $sql->showTables(); usort($tables, array($this,'cmpTables')); foreach($tables as $table) { $xml->startTag('table'); $xml->addFullTag('table_name', $db.'.'.$table->Name, true); $xml->addFullTag('table_label', $db.' - '.$table->Name, true); $xml->endTag('table'); } } $xml->endTag('tables'); # /tables $xml->addFullTag("url_reporting_getfields",$this->_generic->getFullPath("SLS_Bo","ReportingBoGetFields"),true); $xml->addFullTag("url_reporting_getfieldsfrommutipletables",$this->_generic->getFullPath("SLS_Bo","ReportingBoGetFieldsFromMultipleTables"),true); $xml->addFullTag("url_report",$this->_generic->getFullPath("SLS_Bo","ReportingBo"),true); $xml->addFullTag("url_delete",$this->_generic->getFullPath("SLS_Bo","ReportingBoDelete",array("id" => $slsGraphId)),true); $xml->addFullTag("url_status",$this->_generic->getFullPath("SLS_Bo","ReportingBoStatus",array("id" => $slsGraphId)),true); $this->saveXML($xml); }
/** * Constructor * * @access public * @since 1.0 */ public function __construct($xml,$db,$table,$forward=true) { parent::__construct(); $this->_xml = $xml; $this->_db_alias = $db; $this->_table = $table; $this->_forward = $forward; # Objects $className = ucfirst(strtolower($this->_db_alias))."_".SLS_String::tableToClass($this->_table); $this->_generic->useModel(SLS_String::tableToClass($this->_table),ucfirst(strtolower($this->_db_alias)),"user"); $this->_object = new $className(); $this->_table = $this->_object->getTable(); $this->_clone = new $className(); $this->_columns = array(); $this->_filters = array(); $this->_types = array(); # /Objects # Params $ids = $this->_http->getParam("id"); $ids = (SLS_String::contains($ids,"|")) ? explode("|",$ids) : array($ids); # /Params # Types $types = $this->_db->showColumns($this->_table); for($i=0 ; $i<$count=count($types) ; $i++) { $nativeType = "text"; switch($types[$i]->Type) { case (false !== $typeMatch = $this->containsRecursive($types[$i]->Type,array("int","float","double","decimal","real"))): $nativeType = "number"; break; case (false !== $typeMatch = $this->containsRecursive($types[$i]->Type,array("year","datetime","timestamp","time","date"))): $nativeType = "date_".$typeMatch; break; } $this->_types[$types[$i]->Field] = $nativeType; } # /Types # Blocking specificities $specificities = $this->_xmlType->getTagsAttributes("//sls_configs/entry[@table='".$this->_db_alias."_".$this->_table."' and (@type='position' or @type='uniqid' or @type='email')]",array("column","type")); for($i=0 ; $i<$count=count($specificities) ; $i++) { $column = $specificities[$i]["attributes"][0]["value"]; $type = $specificities[$i]["attributes"][1]["value"]; if (!array_key_exists($column,$this->_columns)) $this->_columns[$column] = $type; } $filters = $this->_xmlFilter->getTags("//sls_configs/entry[@table='".$this->_db_alias."_".$this->_table."' and @filter='hash']/@column"); # Blocking specificities # Perform clone if ($this->_object->isMultilanguage()) { $siteLangs = $this->_lang->getSiteLangs(); unset($siteLangs[array_search($this->_defaultLang,$siteLangs)]); array_unshift($siteLangs,$this->_defaultLang); $langs = $siteLangs; } else $langs = array($this->_defaultLang); // Recordsets to clone $nbClone = 0; foreach($ids as $id) { // Next id $cloneId = $this->_object->giveNextId(); // Each lang foreach($langs as $lang) { if ($this->_object->isMultilanguage()) $this->_clone->setModelLanguage($lang); // Get recordset if ($this->_object->getModel($id) === true) { // Foreach column foreach($this->_object->getParams() as $key => $value) { if ($key == $this->_object->getPrimaryKey() || $key == "pk_lang") continue; // Setter $functionName = "set".SLS_String::fullTrim(ucwords(SLS_String::stringToUrl(str_replace("_"," ",$key)," ",false)),""); // Specific type ? if (array_key_exists($key,$this->_columns) && $this->_columns[$key] != "email") { // Default lang if ($lang == $this->_defaultLang && in_array($this->_columns[$key],array("uniqid","position"))) { // Regenerate uniqid if ($this->_columns[$key] == "uniqid") $value = substr(md5(time().substr(sha1(microtime()),0,rand(12,25))),mt_rand(1,20),40); // Get next position else if ($this->_columns[$key] == "position") { $record = array_shift($this->_db->select("SELECT MAX(`".$key."`) AS max_position FROM `".$this->_table."` ")); $value = (!empty($record->max_position) && is_numeric($record->max_position) && $record->max_position > 0) ? ($record->max_position+1) : 1; } } // Take the default lang value else $value = $this->_clone->__get($key); } // Set if (in_array($key,$filters)) $this->_clone->__set($key,$value); else $this->_clone->$functionName($value); // Unique error ? if ($this->_clone->getError($key) == "E_UNIQUE") { if (array_key_exists($key,$this->_columns) && $this->_columns[$key] == "email") $value = "clone_".time()."@".((substr_count($this->_generic->getSiteConfig("domainName"),".") > 1) ? SLS_String::substrAfterLastDelimiter(SLS_String::substrBeforeLastDelimiter($this->_generic->getSiteConfig("domainName"),"."),".").".".SLS_String::substrAfterLastDelimiter($this->_generic->getSiteConfig("domainName"),".") : $this->_generic->getSiteConfig("domainName")); else { switch($this->_types[$key]) { case "number": $record = array_shift($this->_db->select("SELECT MAX(`".$key."`) AS max_nb FROM `".$this->_table."` ")); $value = (!empty($record->max_nb) && is_numeric($record->max_nb)) ? ($record->max_nb+1) : 1; break; case (SLS_String::startsWith($this->_types[$key],"date_")): $record = array_shift($this->_db->select("SELECT MAX(`".$key."`) AS max_date FROM `".$this->_table."` ")); $value = (!empty($record->max_date)) ? ($record->max_date) : ""; $dateType = SLS_String::substrAfterFirstDelimiter($this->_types[$key],"date_"); switch($dateType) { case (in_array($dateType,array("year","timestamp"))): $value = $value + 1; break; case "date": $value = SLS_Date::timestampToDate(strtotime("+ 1 second",SLS_Date::dateToTimestamp($value))); break; case "datetime": $value = SLS_Date::timestampToDateTime(strtotime("+ 1 second",SLS_Date::dateTimeToTimestamp($value))); break; case "time": $value = sls_string::substrAfterFirstDelimiter(SLS_Date::timestampToDateTime(strtotime("+ 1 second",SLS_Date::dateTimeToTimestamp(date("Y-m-d")." ".$value)))," "); break; } break; default: $value = substr(md5(time().substr(sha1(microtime()),0,rand(12,5))),mt_rand(1,5),10); break; } } $this->_clone->$functionName($value); } } $errors = $this->_clone->getErrors(); if (empty($errors)) { $this->_clone->create($cloneId); $nbClone += 1; } } } $this->_clone->clear(); } if ($this->_object->isMultilanguage() && is_numeric($nbClone) && $nbClone > 0) $nbClone = floor($nbClone / count($langs)); # Perform clone # Notif if (!empty($nbClone) && $nbClone !== false && is_numeric($nbClone)) $this->pushNotif("success",($nbClone==1) ? $GLOBALS[$GLOBALS['PROJECT_NAME']]['JS']['SLS_BO_GENERIC_SUBMIT_SUCCESS_CLONE'] : sprintf($GLOBALS[$GLOBALS['PROJECT_NAME']]['JS']['SLS_BO_GENERIC_SUBMIT_SUCCESS_CLONES'],$nbClone)); else $this->pushNotif("error",$GLOBALS[$GLOBALS['PROJECT_NAME']]['JS']['SLS_BO_GENERIC_SUBMIT_ERROR_CLONE']); # /Notif if ($this->_async) { if ($nbClone !== false && is_numeric($nbClone) && $nbClone > 0) { $this->_render["status"] = "OK"; $this->_render["result"]["message"] = ($nbClone==1) ? $GLOBALS[$GLOBALS['PROJECT_NAME']]['JS']['SLS_BO_GENERIC_SUBMIT_SUCCESS_CLONE'] : sprintf($GLOBALS[$GLOBALS['PROJECT_NAME']]['JS']['SLS_BO_GENERIC_SUBMIT_SUCCESS_CLONES'],$nbClone); $rememberList = (is_array($this->_session->getParam("SLS_BO_LIST"))) ? $this->_session->getParam("SLS_BO_LIST") : array(); if (array_key_exists($this->_db_alias."_".$this->_table,$rememberList) && !empty($rememberList[$this->_db_alias."_".$this->_table])) $this->_render["forward"] = $this->_generic->getSiteConfig("protocol")."://".$this->_generic->getSiteConfig("domainName")."/".$rememberList[$this->_db_alias."_".$this->_table]; else $this->_render["forward"] = $this->_generic->getFullPath($this->_boController,"List".ucfirst(strtolower($this->_db_alias))."_".SLS_String::tableToClass($this->_table)); } else $this->_render["result"]["message"] = $GLOBALS[$GLOBALS['PROJECT_NAME']]['JS']['SLS_BO_ASYNC_ERROR']; echo json_encode($this->_render); die(); } else { # Forward if ($this->_forward) { $rememberList = (is_array($this->_session->getParam("SLS_BO_LIST"))) ? $this->_session->getParam("SLS_BO_LIST") : array(); if (array_key_exists($this->_db_alias."_".$this->_table,$rememberList) && !empty($rememberList[$this->_db_alias."_".$this->_table])) $this->_generic->redirect($rememberList[$this->_db_alias."_".$this->_table]); else $this->_generic->forward($this->_boController,"List".ucfirst(strtolower($this->_db_alias))."_".SLS_String::tableToClass($this->_table)); } # /Forward } }
/** * Check all the on delete constraints on all foreign keys of the current model * * @access public * @since 1.0.9 */ public function onDeleteConstraints() { // Check fks $db = SLS_Sql::getInstance(); $xmlFk = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml")); $fks = $xmlFk->getTagsAttributes("//sls_configs/entry[@tablePk='".strtolower($this->getDatabase())."_".SLS_String::tableToClass($this->getTable())."' and @ondelete != 'no_action']",array("tableFk","columnFk","ondelete")); for($i=0 ; $i<$count=count($fks) ; $i++) { if (empty($fks) || (!empty($fks) && count($fks[0]["attributes"]) != 3)) continue; $className = ucfirst(SLS_String::substrBeforeFirstDelimiter($fks[$i]["attributes"][0]["value"],"_"))."_".SLS_String::tableToClass(SLS_String::substrAfterFirstDelimiter($fks[$i]["attributes"][0]["value"],"_")); $fk = $fks[$i]["attributes"][1]["value"]; $onDelete = $fks[$i]["attributes"][2]["value"]; $this->_generic->useModel(SLS_String::substrAfterFirstDelimiter($className,"_"),SLS_String::substrBeforeFirstDelimiter($className,"_"),"user"); $object = new $className(); if ($object->getDatabase() != $db->getCurrentDb()) $db->changeDb($object->getDatabase()); switch ($onDelete) { case "set_null": $db->update("UPDATE `".$object->getTable()."` SET `".$fk."` = NULL WHERE `".$fk."` = ".$db->quote($this->{__.$this->getPrimaryKey()})." "); break; case "cascade": $objects = $db->select("SELECT * FROM `".$object->getTable()."` WHERE `".$fk."` = ".$db->quote($this->{__.$this->getPrimaryKey()})." "); for($j=0 ; $j<$countJ=count($objects) ; $j++) if ($object->getModel($objects[$j]->{$object->getPrimaryKey()}) === true) $object->delete($object->isMultilanguage()); break; } } }
public function action() { set_time_limit(0); $user = $this->hasAuthorative(); $errors = array(); $sql = SLS_Sql::getInstance(); $xml = $this->getXML(); $xml = $this->makeMenu($xml); // Get all models $models = array(); $handle = opendir($this->_generic->getPathConfig("models")); while (false !== ($file = readdir($handle))) { if (!is_dir($this->_generic->getPathConfig("models")."/".$file) && substr($file, 0, 1) != ".") { $modelExploded = explode(".",$file); array_push($models,strtolower($modelExploded[0]).".".$modelExploded[1]); } } // If reload if ($this->_http->getParam("reload")=="true") { // Get the tables dude wants to generate $tablesG = ($this->_http->getParam("tables")=="") ? array() : $this->_http->getParam("tables"); // Foreach tables, generate model foreach($tablesG as $tableG) { $db = Sls_String::substrBeforeFirstDelimiter($tableG,"."); $table = Sls_String::substrAfterFirstDelimiter($tableG,"."); // Change db if it's required if ($sql->getCurrentDb() != $db) $sql->changeDb($db); // If table exists if ($sql->tableExists($table)) { $columns = $sql->showColumns($table); $tableName = $table; $currentTable = array("table"=>$db.".".$tableName,"errors"=>array()); $fieldsOk = true; $className = ucfirst($db)."_".SLS_String::tableToClass($tableName); $fileName = ucfirst($db).".".SLS_String::tableToClass($table).".model.php"; for($i=0 ; $i<$count=count($columns) ; $i++) { // Check forbidden chars if (SLS_String::removePhpChars($columns[$i]->Field) != $columns[$i]->Field) { $error = array("column"=>$columns[$i]->Field,"column_clean"=>SLS_String::removePhpChars($columns[$i]->Field)); array_push($currentTable["errors"],$error); $fieldsOk = false; } } // If all ok with special chars for the current model if ($fieldsOk) { // Check real fks $create = array_shift($sql->select("SHOW CREATE TABLE `".$table."`")); $queries = array_map("trim",explode("\n",$create->{Create." ".Table})); foreach($queries as $query) { if (SLS_String::startsWith($query,"CONSTRAINT")) { $tableFk = strtolower($db."_".$tableName); $columnFk = SLS_String::substrBeforeFirstDelimiter(SLS_String::substrAfterFirstDelimiter($query,"FOREIGN KEY (`"),"`)"); $tablePk = $db."_".SLS_String::tableToClass(SLS_String::substrBeforeFirstDelimiter(SLS_String::substrAfterFirstDelimiter($query,"REFERENCES `"),"`")); $onDelete = strtolower(SLS_String::stringToUrl(trim(SLS_String::substrBeforeFirstDelimiter(SLS_String::substrAfterFirstDelimiter($query,"ON DELETE"),"ON UPDATE")),"_")); $labelPk = ""; $columns = $sql->showColumns(SLS_String::substrBeforeFirstDelimiter(SLS_String::substrAfterFirstDelimiter($query,"REFERENCES `"),"`")); for($i=0 ; $i<$count=count($columns) ; $i++) { if ($columns[$i]->Key != "PRI" && $columns[$i]->Field != "pk_lang" && SLS_String::contains($columns[$i]->Type,"char")) { $labelPk = $columns[$i]->Field; break; } } if (empty($labelPk)) $labelPk = SLS_String::substrBeforeFirstDelimiter(SLS_String::substrAfterFirstDelimiter($query,"REFERENCES `".SLS_String::substrBeforeFirstDelimiter(SLS_String::substrAfterFirstDelimiter($query,"REFERENCES `"),"`")."` (`"),"`)"); $xmlNode = '<entry tableFk="'.$tableFk.'" columnFk="'.$columnFk.'" multilanguage="false" ondelete="'.$onDelete.'" labelPk="'.$labelPk.'" tablePk="'.$tablePk.'" />'; $xmlFk = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml")); $result = $xmlFk->getTags("//sls_configs/entry[@tableFk='".$tableFk."' and @columnFk='".$columnFk."' and @tablePk='".$tablePk."']"); if (!empty($result)) { $xmlTmp = $xmlFk->deleteTags("//sls_configs/entry[@tableFk='".$tableFk."' and @columnFk='".$columnFk."' and @tablePk='".$tablePk."']"); $xmlFk->saveXML($this->_generic->getPathConfig("configSls")."/fks.xml",$xmlTmp); $xmlFk = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml")); } $xmlFk->appendXMLNode("//sls_configs",$xmlNode); $xmlFk->saveXML($this->_generic->getPathConfig("configSls")."/fks.xml",$xmlFk->getXML()); } } // Generate Model $contentM = $this->getModelSource($tableName,$db); $status = touch($this->_generic->getPathConfig("models")."/".$fileName); if ($status) file_put_contents($this->_generic->getPathConfig("models").$fileName,$contentM); // Create SQL $fileNameS = ucfirst($db).".".SLS_String::tableToClass($table).".sql.php"; $contentS = '<?php'."\n". '/**'."\n". '* Object '.$className.'Sql'."\n". '* @author SillySmart'."\n". '* @copyright SillySmart'."\n". '* @package Mvc.Models.Objects'."\n". '* @see Sls.Models.Core.SLS_FrontModel'."\n". '* @since 1.0'."\n". '*/'."\n". 'class '.$className.'Sql extends SLS_FrontModelSql'."\n". '{'."\n". ''."\n". '}'."\n". '?>'; if ($status) $status2 = touch($this->_generic->getPathConfig("modelsSql")."/".$fileNameS); if ($status2) file_put_contents($this->_generic->getPathConfig("modelsSql")."/".$fileNameS,$contentS); } else array_push($errors,$currentTable); } } // If no errors if (empty($errors)) { $controllers = $this->_generic->getTranslatedController("SLS_Bo","Models"); $this->_generic->redirect($controllers['controller']."/".$controllers['scontroller']); } else { // Get all models $models = array(); $handle = opendir($this->_generic->getPathConfig("models")); while (false !== ($file = readdir($handle))) if (!is_dir($this->_generic->getPathConfig("models")."/".$file) && substr($file, 0, 1) != ".") { $modelExploded = explode(".",$file); array_push($models,strtolower($modelExploded[0]).".".$modelExploded[1]); } // Form errors $xml->startTag("errors"); for($i=0 ; $i<$count=count($errors) ; $i++) { $xml->startTag("error"); $xml->addFullTag("table",SLS_String::substrAfterFirstDelimiter($errors[$i]["table"],"."),true); $xml->addFullTag("db",SLS_String::substrBeforeFirstDelimiter($errors[$i]["table"],"."),true); $xml->startTag("columns"); for($j=0 ; $j<$count2=count($errors[$i]["errors"]) ; $j++) { $xml->startTag("column"); $xml->addFullTag("old",$errors[$i]["errors"][$j]["column"],true); $xml->addFullTag("new",$errors[$i]["errors"][$j]["column_clean"],true); $xml->endTag("column"); } $xml->endTag("columns"); $xml->endTag("error"); } $xml->endTag("errors"); } } // Foreach db $dbs = $sql->getDbs(); $allDbs = array(); foreach($dbs as $db) { $allDbs[$db] = array(); // Change db $sql->changeDb($db); // Get all tables $tables = $sql->showTables(); for($i=0 ; $i<$count=count($tables) ; $i++) { $allDbs[$db][$tables[$i]->Name] = array("name" => $tables[$i]->Name, "existed" => (in_array($db.".".SLS_String::tableToClass($tables[$i]->Name),$models)) ? 'true' : 'false'); } } asort($allDbs,SORT_REGULAR); uksort($allDbs,array($this, 'unshiftDefaultDb')); $xml->startTag("dbs"); foreach($allDbs as $key => $db) { asort($db,SORT_REGULAR); $xml->startTag("db"); $xml->addFullTag("name",$key,true); $xml->startTag("tables"); foreach($db as $tableCur) { if (!SLS_String::startsWith(strtolower($tableCur["name"]),"sls_graph")) { $xml->startTag("table"); $xml->addFullTag("name",$tableCur["name"]); $xml->addFullTag("existed",$tableCur["existed"]); $xml->endTag("table"); } } $xml->endTag("tables"); $xml->endTag("db"); } $xml->endTag("dbs"); $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); }
/** * Flush cache * * @access private * @param string $query the sql query you have to analyze * @param string $delimiter the delimiter after table name * @since 1.0.9 */ private function flushCache($query,$delimiter="update") { $query = strtolower($query); $table = str_replace('`','',SLS_String::substrBeforeFirstDelimiter(trim(SLS_String::substrAfterFirstDelimiter($query,$delimiter))," ")); if ($this->tableExists($table)) $this->_cache->flushFromTable($table); }
public function action() { // Objects $xml = $this->getXML(); $user = $this->hasAuthorative(); $xml = $this->makeMenu($xml); $date = $this->_http->getParam("date"); $dateE = explode("-",$date); $dateL = new SLS_Date($date); if (is_array($dateE) && count($dateE) == 3 && is_dir($this->_generic->getPathConfig("logs")."monitoring/".$dateE[0]."-".$dateE[1])) { $content = ""; $i = 0; while(file_exists($this->_generic->getPathConfig("logs")."monitoring/".$dateE[0]."-".$dateE[1]."/".$dateE[0]."-".$dateE[1]."-".$dateE[2]."_".$i.".log")) { $content .= file_get_contents($this->_generic->getPathConfig("logs")."monitoring/".$dateE[0]."-".$dateE[1]."/".$dateE[0]."-".$dateE[1]."-".$dateE[2]."_".$i.".log"); $i++; } $batchs = explode("#|end|#",$content); $xml->startTag("batchs"); $xml->addFullTag("date",$dateL->getDate("FULL_LITTERAL")); foreach($batchs as $batch) { if (!empty($batch)) { $lines = explode("\n",$batch); $times = array ("Render" => 0, "XML/XSL Parsing" => 0, "MySQL Query" => 0, "Controller Action" => 0, "Controller Front" => 0, "Controller Static" => 0); $msg = ""; $totalTime = 0; $endTime = 0; $xml->startTag("batch"); $xml->startTag("lines"); foreach($lines as $line) { $infos = explode("||",$line); $infos = array_map('trim',$infos); if (count($infos) > 4) { $times[$infos[0]] += $infos[2]; if ($infos[0] == "Render") { $totalTime = $infos[2]; $endTime = SLS_String::substrAfterFirstDelimiter($infos[1]," "); } if ($infos[0] == "Controller Front") $msg = SLS_String::substrAfterFirstDelimiter(SLS_String::substrBeforeLastDelimiter($infos[3],")"),"("); $xml->startTag("line"); $xml->addFullTag("msg",$infos[3],true); $xml->addFullTag("type",$infos[0],true); $xml->addFullTag("more",str_replace(array("|n|","|t|"," "),array("<br />","  ","    "),$infos[4]),true); $xml->addFullTag("time",SLS_String::substrAfterFirstDelimiter($infos[1]," "),true); $xml->addFullTag("duration",$infos[2],true); $xml->endTag("line"); } } $xml->endTag("lines"); $xml->startTag("infos"); $xml->addFullTag("name",$endTime." - ".$msg,true); $xml->startTag("times"); $xml->addFullTag("total",$totalTime,true); foreach($times as $key => $value) $xml->addFullTag(SLS_String::stringToUrl(trim($key),"_"),$value,true); $xml->endTag("times"); $xml->endTag("infos"); $sum = 0; $xml->startTag("ratios"); foreach($times as $key => $value) { if ($key == "Render") continue; else $sum += $value; $xml->startTag("ratio"); $xml->addFullTag("label",str_replace(" ","+",trim($key)),true); $xml->addFullTag("duration",$times[$key],true); $xml->addFullTag("degree",($totalTime > 0) ? 360 * $value / $totalTime : "360",true); $xml->endTag("ratio"); } if ($totalTime - $sum > 0) { $xml->startTag("ratio"); $xml->addFullTag("label","Others",true); $xml->addFullTag("duration",$sum,true); $xml->addFullTag("degree",($totalTime > 0) ? 360 * $sum / $totalTime : "360",true); $xml->endTag("ratio"); } $xml->endTag("ratios"); $xml->endTag("batch"); } } $xml->endTag("batchs"); } $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); }