setCondition(array()); //$dalData->setLimit(10); $arrayObj = StUserDataDAL::GetResult($dalData); //Utils::ArrayDisplay($arrayObj); $arrayObjDescrypted = array(); /* * dekodowanie ze starej wersji * * */ foreach ($arrayObj as $obj) { $obj->SetAddress(StUserData::Decrypt($obj->getAddress())); $obj->SetaddressMore(StUserData::Decrypt($obj->getaddressMore())); $obj->Setcode(StUserData::Decrypt($obj->getcode())); $obj->Setcompany(StUserData::Decrypt($obj->getcompany())); $obj->Setflat(StUserData::Decrypt($obj->getflat())); $obj->Sethouse(StUserData::Decrypt($obj->gethouse())); $obj->Setpesel(StUserData::Decrypt($obj->getpesel())); $obj->Setphone(StUserData::Decrypt($obj->getphone())); $obj->Setregion(StUserData::Decrypt($obj->getregion())); $obj->Setstreet(StUserData::Decrypt($obj->getstreet())); $obj->Settown(StUserData::Decrypt($obj->gettown())); $arrayObjDescrypted[] = $obj; } /* * Kodowaie do nowej wersji * * */ $arrayObjEncrypted = array(); foreach ($arrayObjDescrypted as $obj) { // $obj->SetAddress(StUserData::Encrypt($obj->getAddress())); // $obj->SetaddressMore(StUserData::Encrypt($obj->getaddressMore())); // $obj->Setcode(StUserData::Encrypt($obj->getcode())); // $obj->Setcompany(StUserData::Encrypt($obj->getcompany())); // $obj->Setflat(StUserData::Encrypt($obj->getflat())); // $obj->Sethouse(StUserData::Encrypt($obj->gethouse())); // $obj->Setpesel(StUserData::Encrypt($obj->getpesel())); // $obj->Setphone(StUserData::Encrypt($obj->getphone())); // $obj->Setregion(StUserData::Encrypt($obj->getregion())); // $obj->Setstreet(StUserData::Encrypt($obj->getstreet())); // $obj->Settown(StUserData::Encrypt($obj->gettown())); // $obj->setUpdatedAt(Utils::GetNowDate()); StUserDataDAL::Save($obj); $arrayObjEncrypted[] = $obj; } Utils::ArrayDisplay($arrayObjDescrypted); } public function GenerateModAction($param) { MFLog::Info(__FUNCTION__); //require_once('../core/lib/Smarty/Smarty.class.php'); //$smarty = new Smarty(); // $smarty->template_dir = Config::Get('PATH_SMARTY_TEMPLATE'); // $smarty->compile_dir = Config::Get('PATH_SMARTY_COMPILE'); $db = Registry::Get('db'); $sql = " select table_name from information_schema.tables where table_schema <> 'information_schema' "; $stmt = $db->prepare($sql) ->execute($sql); $tables = $stmt->FetchAllRow(); foreach ($tables as $table) { $tableName = $table[0]; $className = ucfirst(Utils::SQLName2PHPName($tableName)); $this->smarty->assign('tableName', $tableName); $this->smarty->assign('className', $className); // zależne obiekty/tabele działa dopiero od mySQL 5.1.16 // $sql = " select table_name from referential_constraints where constraint_schema <> 'information_schema' and referenced_table_name = '$tableName' "; // $stmt = $db->prepare($sql) // ->execute($sql); // // $refTableNames = array(); // // $refTables = $stmt->FetchAllRow(); // foreach ($refTables as $refTable) { // $tmp_name = Utils::SQLName2PHPName($refTable[0]); // $refTables[$refTable[0]] = $tmp_name; // } // // $smarty->assign('refTables', $refTables); // kolumny tabeli dla obiektu $sql = " select column_name from information_schema.columns where table_name='$tableName'; "; $stmt = $db->prepare($sql) ->execute($sql); $columnNames = array(); $columns = $stmt->FetchAllRow(); foreach ($columns as $column) { if ($column[0] === 'id_' . $tableName) { $tmp_name = 'id'; } else { $tmp_name = Utils::SQLName2PHPName($column[0]); } $columnNames[$column[0]] = $tmp_name; } $this->smarty->assign('columnNames', $columnNames); $output = 'smarty->fetch('templateModel.tpl') . '?>'; $file = fopen(PATH_MODEL_TMP . $className . '.class.php', "w"); fwrite($file, $output); fclose($file); $outputDAL = 'smarty->fetch('templateModelDAL.tpl') . '?>'; $file = fopen(PATH_MODEL_TMP . $className . 'DAL.class.php', "w"); fwrite($file, $outputDAL); fclose($file); } } public function GenOneModelAction($param) { // kolumny tabeli dla obiektu $tableName = 'st_user_data'; $db = Registry::Get('db'); $sql = " select column_name from information_schema.columns where table_name='$tableName'; "; $stmt = $db->prepare($sql) ->execute($sql); $className = ucfirst(Utils::SQLName2PHPName($tableName)); $this->smarty->assign('tableName', $tableName); $this->smarty->assign('className', $className); $columnNames = array(); $columns = $stmt->fetchAllAssoc(); //Utils::ArrayDisplay($columns); //$columns = $stmt->FetchAllRow(); foreach ($columns as $column) { //Utils::ArrayDisplay($column); if ($column['COLUMN_NAME'] === 'id_mf_participant') { $tmp_name = 'id'; } else { $tmp_name = Utils::SQLName2PHPName($column['COLUMN_NAME']); } $columnNames[$column['COLUMN_NAME']] = $tmp_name; } //Utils::ArrayDisplay($this->smarty); $this->smarty->assign('columnNames', $columnNames); $output = 'smarty->fetch('partial/Utils/templateModel.tpl') . '?>'; //Utils::ArrayDisplay($this->smarty); $file = fopen(PATH_MODEL_TMP . $className . '.class.php', "w"); fwrite($file, $output); fclose($file); $outputDAL = 'smarty->fetch('partial/Utils/templateModelDAL.tpl') . '?>'; //Utils::ArrayDisplay($outputDAL); $file = fopen(PATH_MODEL_TMP . $className . 'DAL.class.php', "w"); fwrite($file, $outputDAL); fclose($file); } public function UpdateFieldAction($param) { $arrayTableField = array( 'mf_article_description' => array('description', 'shortnote'), 'mf_dictionary' => array('replacement'), 'mf_article_box' => array('description', 'shortnote'), 'st_webpage' => array('opt_other_link', 'opt_content'), 'st_webpage_i18n' => array('other_link', 'content') ); $stringToReplace = 'https://aem.hean.pl'; $stringReplace = 'https://hean.pl'; foreach ($arrayTableField as $table => $arrayField) { //$table = ''; foreach ($arrayField as $field) { $sql = "UPDATE $table SET $field = REPLACE($field, '$stringToReplace', '$stringReplace') WHERE $field LIKE '%$stringToReplace%'"; Utils::ArrayDisplay($sql); // $db = Registry::Get('db'); // $stmt = $db->prepare($sql)->execute($sql); } } } /** * preDispatch * @param array $param * @return null */ public function preDispatch($param){ $this->Run($param); $this->AddScript('dropDown.js'); $this->AddScript('structure.js'); $this->AddScript('Dosia.js'); $this->AddScript('Link.js'); $this->AddScript('drag-drop-folder-tree.js'); // //$this->AddScript('Validator.js'); $this->AddScript('calendar.js'); $this->RunShared('Auth', array()); $this->RunShared('Structure', $param); $this->smarty->assign('idStucture', SessionProxy::GetValue('idStructure')); $this->smarty->assign('lang', 'pl'); $this->smarty->assign('titleAdmin', 'Pliki'); $this->smarty->assign('activeTab', 'index'); } /** * postDispatch * @param array $param * @return null */ public function postDispatch($param){ } }