improved installer

This commit is contained in:
Taras Machyshyn
2014-04-14 16:15:54 +03:00
parent 37462dc30c
commit df0a65b7c1
3 changed files with 20 additions and 33 deletions
+5 -26
View File
@@ -221,8 +221,8 @@ class Manager
{
$fileContent = $this->getContents($path);
$savedDataArray= $this->getArrayData($fileContent);
$newDataArray= $this->getArrayData($content);
$savedDataArray = Utils\Json::getArrayData($fileContent);
$newDataArray = Utils\Json::getArrayData($content);
$data= Utils\Util::merge($savedDataArray, $newDataArray);
if ($isJSON) {
@@ -245,8 +245,8 @@ class Manager
{
$fileContent = $this->getContents($path);
$savedDataArray= $this->getArrayData($fileContent);
$newDataArray= $this->getArrayData($content);
$savedDataArray = Utils\Json::getArrayData($fileContent);
$newDataArray = Utils\Json::getArrayData($content);
if ($onlyFirstLevel) {
foreach($newDataArray as $key => $val) {
@@ -288,7 +288,7 @@ class Manager
return false;
}
$currentDataArray = $this->getArrayData($currentData);
$currentDataArray = Utils\Json::getArrayData($currentData);
$unsettedData = Utils\Util::unsetInArray($currentDataArray, $unsets);
@@ -505,27 +505,6 @@ class Manager
return $result;
}
/** //TODO remove
* Get an array data (if JSON convert to array)
*
* @param mixed $data - can be JSON, array
*
* @return array
*/
protected function getArrayData($data)
{
if (is_array($data)) {
return $data;
}
else if (Utils\Json::isJSON($data)) {
return Utils\Json::decode($data, true);
}
return array();
}
/**
* Get a filename without the file extension
*
+14 -6
View File
@@ -35,21 +35,29 @@ class SystemHelper
protected $modRewriteUrl = '/api/v1/Metadata';
protected $writableDir = 'data';
protected $systemConfig = 'data/config.php';
public function initWritable()
{
if (is_writable($this->writableDir)) {
return true;
$pathInfo = pathinfo($this->systemConfig);
if (!is_writable($pathInfo['dirname'])) {
return false;
}
return false;
if (!@touch($this->systemConfig)) {
return false;
}
return true;
}
public function getWritableDir()
public function getSystemDir()
{
return $this->writableDir;
$pathInfo = pathinfo($this->systemConfig);
return $pathInfo['dirname'];
}
+1 -1
View File
@@ -39,7 +39,7 @@ require_once 'core/SystemHelper.php';
$systemHelper = new SystemHelper();
if (!$systemHelper->initWritable()) {
$dir = $systemHelper->getWritableDir();
$dir = $systemHelper->getSystemDir();
$message = $langs['Bad init Permission'];
$message = str_replace('{*}', $dir, $message);