export_public_help_db.php now targets app_dir, a=chris

Chris Pollett [2015-01-20 18:Jan:th]
export_public_help_db.php now targets app_dir, a=chris
Filename
configs/createdb.php
configs/export_public_help_db.php
diff --git a/configs/createdb.php b/configs/createdb.php
index 1bc27dfa8..c9aad91b8 100755
--- a/configs/createdb.php
+++ b/configs/createdb.php
@@ -139,7 +139,11 @@ $db->execute("INSERT INTO USER_GROUP VALUES (" . PUBLIC_USER_ID . ", " .
 $group_model = new GroupModel(DB_NAME, false);
 $group_model->db = $db;
 // Insert Default Public Wiki Pages
-require_once BASE_DIR."/configs/public_help_pages.php";
+if(file_exists(APP_DIR . "/configs/public_help_pages.php")) {
+    require_once APP_DIR."/configs/public_help_pages.php";
+} else {
+    require_once BASE_DIR."/configs/public_help_pages.php";
+}
 $default_locale = getLocaleTag();
 foreach($public_pages as $locale_tag => $locale_pages) {
     setLocaleObject($locale_tag);
diff --git a/configs/export_public_help_db.php b/configs/export_public_help_db.php
index bebedbb49..7588389f3 100644
--- a/configs/export_public_help_db.php
+++ b/configs/export_public_help_db.php
@@ -64,7 +64,15 @@ $sql = "SELECT GPH.TITLE AS TITLE, GPH.PAGE AS PAGE, ".
     " GPH.PAGE_ID=GP.PAGE_ID AND ".
     " GPH.PUBDATE < GP.PUBDATE) ORDER BY GPH.LOCALE_TAG, GPH.TITLE";
 $result = $db->execute($sql);
-$out_file = "public_help_pages.php";
+$app_config_dir = APP_DIR . "/configs";
+if(!file_exists($app_config_dir)) {
+    crawlLog("$app_config_dir does not exists, trying to make it...\n");
+    if(!mkdir($app_config_dir)) {
+        crawlLog("Make $app_config_dir failed, quitting");
+        exit();
+    }
+}
+$out_file = "$app_config_dir/public_help_pages.php";
 $out = "<"."?php\n/**\n";
 $out .= " *\n * Default Public Wiki Pages\n *\n";
 $out .= " * This file should be generated using export_public_help_db.php\n";
@@ -98,4 +106,5 @@ if($result) {
 }
 $out .= "\n?".">";
 file_put_contents($out_file, $out);
+crawlLog("Wrote export data to $out_file");
  ?>
ViewGit