_binary From 0673b5223ff69dfaaaa9cf58cf95807f3cdff4ec Mon Sep 17 00:00:00 2001
From: diesal9 <charles.bocage@sjsu.edu>
Date: Mon, 9 May 2016 20:47:34 -0700
Subject: [PATCH] I have added the schema changes to support the CMS activity.

---
 src/configs/Config.php           |   4 +-
 src/configs/Createdb.php         |  49 +++++++++++++++-
 src/library/UpgradeFunctions.php | 121 ++++++++++++++++++++++++++++++++-------
 src/models/ProfileModel.php      |  33 +++++++----
 4 files changed, 170 insertions(+), 37 deletions(-)

diff --git a/src/configs/Config.php b/src/configs/Config.php
index a41b8b4..cf697ee 100755
--- a/src/configs/Config.php
+++ b/src/configs/Config.php
@@ -112,7 +112,7 @@ function nsconddefine($constant, $value)
  * Version number for upgrade function
  * @var int
  */
-nsdefine('YIOOP_VERSION', 38);
+nsdefine('YIOOP_VERSION', 39);
 /**
  * Minimum Version fo Yioop for which keyword ad script
  * still works with this version
@@ -905,4 +905,4 @@ nsconddefine('AD_DATE_FORMAT','Y-m-d');
 /** advertisement logo*/
 nsconddefine('AD_LOGO','resources/adv-logo.png');
 /** sentence compression enabled or not*/
-nsconddefine('SENTENCE_COMPRESSION_ENABLED', false);
+nsconddefine('SENTENCE_COMPRESSION_ENABLED', false);
\ No newline at end of file
diff --git a/src/configs/Createdb.php b/src/configs/Createdb.php
index 59e5364..f495f36 100755
--- a/src/configs/Createdb.php
+++ b/src/configs/Createdb.php
@@ -336,6 +336,10 @@ $activities = [
     "manageAdvertisements" => ['db_activity_manage_advertisements',
         [
             "en-US" => 'Manage Advertisements',
+        ]],
+    "cmsDetectors" => ['db_activity_cms_detectors',
+        [
+            "en-US" => 'CMS Detectors',
         ]]
 ];
 $i = 1;
@@ -406,7 +410,6 @@ $db->execute("INSERT INTO CRAWL_MIXES VALUES (4, 'news', ".ROOT_ID.", -1)");
 $db->execute("INSERT INTO MIX_FRAGMENTS VALUES(4, 0, 1)");
 $db->execute("INSERT INTO MIX_COMPONENTS VALUES(4, 0, 1, 1,
     'media:news')");
-
 $db->execute("INSERT INTO SUBSEARCH VALUES('db_subsearch_images',
     'images','m:2', 50)");
 $db->execute("INSERT INTO TRANSLATION VALUES (1002,'db_subsearch_images')");
@@ -416,6 +419,48 @@ $db->execute("INSERT INTO TRANSLATION VALUES (1003,'db_subsearch_videos')");
 $db->execute("INSERT INTO SUBSEARCH VALUES ('db_subsearch_news',
     'news','m:4',20)");
 $db->execute("INSERT INTO TRANSLATION VALUES (1004,'db_subsearch_news')");
+$db->execute("INSERT INTO TRANSLATION VALUES (1004,'db_subsearch_news')");
+$sql = "INSERT INTO CMS_DETECTORS VALUES (?,?,?,?)";
+$name = "YIOOP!";
+$source_header = "c=resource&amp;a=get&amp;f=css&amp;n=auxiliary\.css";
+$source_importantcontent = "";
+$db->execute($sql, [time(), $name, $source_header, $source_importantcontent]);
+sleep(1);
+$name = "DRUPAL";
+$source_header = "sites\/(?:default|all)\/(?:themes|modules|files)\/";
+$source_importantcontent = "//div[@id=\&quot;content\&quot;]" .
+    "###//div[@id=\&quot;comments\&quot;]" .
+    "###//div[@id=\&quot;respond\&quot;]" .
+    "###//div[@class=\&quot;bottomcontainerBox\&quot;]" .
+    "###//ul[@class=\&quot;post-by\&quot;]" .
+    "###//div[@class=\&quot;entry-meta clear\&quot;]";
+$db->execute($sql, [time(), $name, $source_header, $source_importantcontent]);
+sleep(1);
+$name = "SITECORE";
+$source_header = "\/system\/VisitorIdentification.js";
+$source_importantcontent = "//div[@class=\&quot;container section\&quot;]";
+$db->execute($sql, [time(), $name, $source_header, $source_importantcontent]);
+sleep(1);
+$name = "VBULLETIN";
+$source_header = "vBulletin";
+$source_importantcontent = "//div[@td\s+id=\&quot;content\&quot;]";
+$db->execute($sql, [time(), $name, $source_header, $source_importantcontent]);
+sleep(1);
+$name = "JOOMLA!";
+$source_header = "^\/media";
+$source_importantcontent = "";
+$db->execute($sql, [time(), $name, $source_header, $source_importantcontent]);
+sleep(1);
+$name = "WORDPRESS";
+$source_header = "wp-(?:content|includes)";
+$source_importantcontent = "//div[@id=\&quot;content\&quot;]" .
+    "###//div[@id=\&quot;comments\&quot;]" .
+    "###//div[@id=\&quot;respond\&quot;]" .
+    "###//div[@class=\&quot;bottomcontainerBox\&quot;]" .
+    "###//ul[@class=\&quot;post-by\&quot;]" /
+    "###//div[@class=\&quot;entry-meta clear\&quot;]";
+$db->execute($sql, [time(), $name, $source_header, $source_importantcontent]);
+sleep(1);
 $subsearch_translations = [
     'db_subsearch_images' => [
         'en-US' => 'Images',
@@ -476,4 +521,4 @@ $db->disconnect();
 if (in_array(DBMS, ['sqlite','sqlite3'])){
     chmod(CRAWL_DIR."/data/".DB_NAME.".db", 0666);
 }
-echo "Create DB succeeded\n";
+echo "Create DB succeeded\n";
\ No newline at end of file
diff --git a/src/library/UpgradeFunctions.php b/src/library/UpgradeFunctions.php
index a495746..413b01c 100644
--- a/src/library/UpgradeFunctions.php
+++ b/src/library/UpgradeFunctions.php
@@ -40,7 +40,7 @@ use seekquarry\yioop\models\datasources as D;
 /** For Yioop global defines */
 require_once __DIR__."/../configs/Config.php";
 /**
- * Checks to see if the locale data of Yioop! of a locale in the work dir is 
+ * Checks to see if the locale data of Yioop! of a locale in the work dir is
  * older than the currently running Yioop!
  *
  * @param string $locale_tag locale to check directory of
@@ -71,7 +71,8 @@ function upgradeLocales()
     /*
         if we're upgrading version2 to 3 we want to make sure stemmer becomes
         tokenizer, version3 to 4 pushes out stopwordsRemover used for
-        summarization. version 6 to 7 adds stemmers for french, english, german.
+        summarization. version 6 to 7 adds stemmers for french, english,
+        german.
         version 7 to 8 adds stemmers for russian and spanish
     */
     if (!isset($locale->configure['strings']["view_locale_version14"]) ||
@@ -163,7 +164,7 @@ function upgradeDatabaseWorkDirectory()
     $versions = array_slice($versions, $current_version);
     foreach ($versions as $version) {
         $upgradeDB = C\NS_LIB . "upgradeDatabaseVersion$version";
-        if(function_exists($upgradeDB)) {
+        if (function_exists($upgradeDB)) {
             $upgradeDB($model->db);
         }
     }
@@ -215,9 +216,11 @@ function upgradeDatabaseVersion3(&$db)
     $db->execute("CREATE TABLE MACHINE (
         NAME VARCHAR(16) PRIMARY KEY, URL VARCHAR(".C\MAX_URL_LEN.") UNIQUE,
         HAS_QUEUE_SERVER BOOLEAN, NUM_FETCHERS INTEGER)");
-    $db->execute("DELETE FROM ACTIVITY WHERE ACTIVITY_ID>5 AND ACTIVITY_ID<11");
+    $db->execute("DELETE FROM ACTIVITY WHERE ACTIVITY_ID>5 AND " .
+        "ACTIVITY_ID<11");
     $db->execute(
-        "DELETE FROM TRANSLATION WHERE TRANSLATION_ID>5 AND TRANSLATION_ID<11");
+        "DELETE FROM TRANSLATION WHERE TRANSLATION_ID>5 AND " .
+        "TRANSLATION_ID<11");
     $db->execute("DELETE FROM TRANSLATION_LOCALE ".
         "WHERE TRANSLATION_ID>5 AND TRANSLATION_ID<11");
     $db->execute("INSERT INTO ACTIVITY VALUES (6, 6, 'pageOptions')");
@@ -334,7 +337,8 @@ function upgradeDatabaseVersion8(&$db)
     $db->execute("INSERT INTO LOCALE VALUES (20, 'fa', 'فارسی', 'rl-tb')");
     $db->execute("CREATE TABLE ACTIVE_FETCHER (NAME VARCHAR(".C\NAME_LEN."),".
         " FETCHER_ID INTEGER)");
-    $db->execute("CREATE TABLE CRON_TIME (TIMESTAMP INT(".C\TIMESTAMP_LEN."))");
+    $db->execute("CREATE TABLE CRON_TIME " .
+        "(TIMESTAMP INT(".C\TIMESTAMP_LEN."))");
     $db->execute("INSERT INTO CRON_TIME VALUES ('".time()."')");
     upgradeLocales();
 }
@@ -418,8 +422,8 @@ function upgradeDatabaseVersion11(&$db)
     $db->execute("DROP TABLE CRON_TIME");
     $db->execute("ALTER TABLE ROLE_ACTIVITY ADD CONSTRAINT
         PK_RA PRIMARY KEY(ROLE_ID, ACTIVITY_ID)");
-    $db->execute("CREATE TABLE SUBSEARCH (LOCALE_STRING VARCHAR(16) PRIMARY KEY,
-        FOLDER_NAME VARCHAR(16), INDEX_IDENTIFIER CHAR(13))");
+    $db->execute("CREATE TABLE SUBSEARCH (LOCALE_STRING VARCHAR(16) " .
+        "PRIMARY KEY, FOLDER_NAME VARCHAR(16), INDEX_IDENTIFIER CHAR(13))");
 }
 /**
  * Upgrades a Version 11 version of the Yioop! database to a Version 12 version
@@ -437,13 +441,15 @@ function upgradeDatabaseVersion12(&$db)
         'media:video')");
     $db->execute("INSERT INTO SUBSEARCH VALUES('db_subsearch_images',
         'images','m:2',50)");
-    $db->execute("INSERT INTO TRANSLATION VALUES (1002,'db_subsearch_images')");
+    $db->execute("INSERT INTO TRANSLATION VALUES " .
+        "(1002,'db_subsearch_images')");
     $db->execute("INSERT INTO TRANSLATION_LOCALE VALUES
             (1002, 1, 'Images' )");
 
     $db->execute("INSERT INTO SUBSEARCH VALUES ('db_subsearch_videos',
         'videos','m:3',10)");
-    $db->execute("INSERT INTO TRANSLATION VALUES (1003,'db_subsearch_videos')");
+    $db->execute("INSERT INTO TRANSLATION VALUES " .
+        "(1003,'db_subsearch_videos')");
     $db->execute("INSERT INTO TRANSLATION_LOCALE VALUES
             (1003, 1, 'Videos' )");
 }
@@ -495,10 +501,10 @@ function upgradeDatabaseVersion16(&$db)
 {
     addActivityAtId($db, 'db_activity_manage_classifiers',
         "manageClassifiers", 4);
-    updateTranslationForStringId($db, 'db_activity_manage_classifiers', 'en-US',
-        'Manage Classifiers');
-    updateTranslationForStringId($db, 'db_activity_manage_classifiers', 'fr-FR',
-        'Manage Classifiers');
+    updateTranslationForStringId($db, 'db_activity_manage_classifiers',
+        'en-US', 'Manage Classifiers');
+    updateTranslationForStringId($db, 'db_activity_manage_classifiers',
+        'fr-FR', 'Manage Classifiers');
     updateTranslationForStringId($db, 'db_activity_manage_groups', 'fr-FR',
         'Classificateurs');
 
@@ -619,7 +625,8 @@ function upgradeDatabaseVersion20(&$db)
             $new_profile['WORD_SUGGEST'] = true;
             $profile_model->updateProfile(C\WORK_DIRECTORY, $new_profile,
                 $profile);
-            //get current users (assume can fit in memory and doesn't take long)
+            //get current users
+            //(assume can fit in memory and doesn't take long)
             $users = [];
             $sha1_of_upgrade_code = bchexdec(sha1($v20check));
             $temp = bcpow($sha1_of_upgrade_code . '', '2');
@@ -679,7 +686,8 @@ function upgradeDatabaseVersion20(&$db)
                 foreach ($users as $user) {
                     $user_model->addUser($user["USER_NAME"], $user["PASSWORD"],
                         $user["FIRST_NAME"], $user["LAST_NAME"],
-                        $user["EMAIL"], $user["STATUS"], $user["ZKP_PASSWORD"]);
+                        $user["EMAIL"], $user["STATUS"],
+                        $user["ZKP_PASSWORD"]);
                 }
                 $user = [];
                 $user['USER_ID'] = C\ROOT_ID;
@@ -705,7 +713,7 @@ function upgradeDatabaseVersion20(&$db)
             <meta name="Author" content="Christopher Pollett" />
             <meta charset="utf-8" />
             <?php if (C\MOBILE) {?>
-            <meta name="viewport" content="width=device-width, initial-scale=1">
+            <meta name="viewport" content="width=device-width,initial-scale=1">
             <?php } ?>
             <link rel="stylesheet" type="text/css"
                  href="<?= C\BASE_URL ?>/css/search.css" />
@@ -818,8 +826,9 @@ function upgradeDatabaseVersion24(&$db)
 {
     $profile_model = new M\ProfileModel(C\DB_NAME, false);
     $profile_model->db = $db;
-    $dbinfo = ["DBMS" => C\DBMS, "DB_HOST" => C\DB_HOST, "DB_USER" => C\DB_USER,
-        "DB_PASSWORD" => C\DB_PASSWORD, "DB_NAME" => C\DB_NAME];
+    $dbinfo = ["DBMS" => C\DBMS, "DB_HOST" => C\DB_HOST,
+        "DB_USER" => C\DB_USER, "DB_PASSWORD" => C\DB_PASSWORD,
+        "DB_NAME" => C\DB_NAME];
     $profile_model->initializeSql($db, $dbinfo);
     foreach ($profile_model->create_statements as $object_name => $statement) {
         if (stristr($object_name, "_INDEX")) {
@@ -1104,7 +1113,7 @@ function upgradeDatabaseVersion34(&$db)
 function upgradeDatabaseVersion35(&$db)
 {
     $db->execute("CREATE TABLE CREDIT_LEDGER
-        (USER_ID INTEGER, AMOUNT INTEGER, TYPE VARCHAR(" . 
+        (USER_ID INTEGER, AMOUNT INTEGER, TYPE VARCHAR(" .
         C\NAME_LEN . "), BALANCE INTEGER, TIMESTAMP NUMERIC(" .
         C\TIMESTAMP_LEN . "))");
     addActivityAtId($db, 'db_activity_manage_credits',
@@ -1197,6 +1206,74 @@ function upgradeDatabaseVersion38(&$db)
         NUM_VIEWS FROM ITEM_IMPRESSION_SUMMARY_OLD");
 }
 /**
+ * Upgrades a Version 38 version of the Yioop! database to a Version 39 version
+ * @param object $db datasource to use to upgrade
+ */
+function upgradeDatabaseVersion39(&$db)
+{
+    $role_model = new M\RoleModel(C\DB_NAME, false);
+    $role_model->db = $db;
+    $dbinfo = ["DBMS" => C\DBMS, "DB_HOST" => C\DB_HOST,
+        "DB_NAME" => C\DB_NAME, "DB_PASSWORD" => C\DB_PASSWORD];
+    $db->execute("CREATE TABLE CMS_DETECTORS (TIMESTAMP NUMERIC(" .
+        C\TIMESTAMP_LEN . ") PRIMARY KEY NOT NULL, NAME VARCHAR(" .
+        C\TITLE_LEN . "), HEADER VARCHAR(" . C\TITLE_LEN . ")," .
+        "IMPORTANT_CONTENT VARCHAR(" . C\TITLE_LEN . "))");
+    addActivityAtId($db, 'db_activity_cms_detectors',
+        "cmsDetectors", 20);
+    updateTranslationForStringId($db, 'db_activity_cms_detectors',
+        'en-US', 'CMS Detectors');
+    $role_id = $role_model->getRoleId('Admin');
+    $role_model->addActivityRole($role_id, 20);
+    $sql = "INSERT INTO CMS_DETECTORS VALUES (?,?,?,?)";
+    $name = "YIOOP!";
+    $source_header = "c=resource&amp;a=get&amp;f=css&amp;n=auxiliary\.css";
+    $source_importantcontent = "";
+    $db->execute($sql, [time(), $name, $source_header,
+        $source_importantcontent]);
+    sleep(1);
+    $name = "DRUPAL";
+    $source_header = "sites\/(?:default|all)\/(?:themes|modules|files)\/";
+    $source_importantcontent = "//div[@id=\&quot;content\&quot;]" .
+        "###//div[@id=\&quot;comments\&quot;]" .
+        "###//div[@id=\&quot;respond\&quot;]" .
+        "###//div[@class=\&quot;bottomcontainerBox\&quot;]" .
+        "###//ul[@class=\&quot;post-by\&quot;]" .
+        "###//div[@class=\&quot;entry-meta clear\&quot;]";
+    $db->execute($sql, [time(), $name, $source_header,
+        $source_importantcontent]);
+    sleep(1);
+    $name = "SITECORE";
+    $source_header = "\/system\/VisitorIdentification.js";
+    $source_importantcontent = "//div[@class=\&quot;container section\&quot;]";
+    $db->execute($sql, [time(), $name, $source_header,
+        $source_importantcontent]);
+    sleep(1);
+    $name = "VBULLETIN";
+    $source_header = "vBulletin";
+    $source_importantcontent = "//div[@td\s+id=\&quot;content\&quot;]";
+    $db->execute($sql, [time(), $name, $source_header,
+        $source_importantcontent]);
+    sleep(1);
+    $name = "JOOMLA!";
+    $source_header = "^\/media";
+    $source_importantcontent = "";
+    $db->execute($sql, [time(), $name, $source_header,
+        $source_importantcontent]);
+    sleep(1);
+    $name = "WORDPRESS";
+    $source_header = "wp-(?:content|includes)";
+    $source_importantcontent = "//div[@id=\&quot;content\&quot;]" .
+        "###//div[@id=\&quot;comments\&quot;]" .
+        "###//div[@id=\&quot;respond\&quot;]" .
+        "###//div[@class=\&quot;bottomcontainerBox\&quot;]" .
+        "###//ul[@class=\&quot;post-by\&quot;]" /
+        "###//div[@class=\&quot;entry-meta clear\&quot;]";
+    $db->execute($sql, [time(), $name, $source_header,
+        $source_importantcontent]);
+    sleep(1);
+}
+/**
  * Update the database version number to a new number
  * @param object $db datasource for Yioop database
  * @param int $number the new database number
@@ -1262,7 +1339,7 @@ function addActivityAtId(&$db, $string_id, $method_name, $activity_id)
             [$row['ACTIVITY_ID']]);
     }
     if (!in_array($method_name, ["manageAdvertisements", "manageCredits"])) {
-        $db->execute("UPDATE ROLE_ACTIVITY SET ACTIVITY_ID = ACTIVITY_ID + 1 " .
+        $db->execute("UPDATE ROLE_ACTIVITY SET ACTIVITY_ID = ACTIVITY_ID + 1 ".
             "WHERE ACTIVITY_ID >= ?", [$activity_id]);
         //give root account permissions on the activity.
         $db->execute("INSERT INTO ROLE_ACTIVITY VALUES (1, ?)",
@@ -1311,4 +1388,4 @@ function updateTranslationForStringId(&$db, $string_id, $locale_tag,
     $result = $db->execute($sql, [$translate_id, $locale_id]);
     $sql = "INSERT INTO TRANSLATION_LOCALE VALUES (?, ?, ?)";
     $result = $db->execute($sql, [$translate_id, $locale_id, $translation]);
-}
+}
\ No newline at end of file
diff --git a/src/models/ProfileModel.php b/src/models/ProfileModel.php
index e7a79da..9499e27 100755
--- a/src/models/ProfileModel.php
+++ b/src/models/ProfileModel.php
@@ -57,7 +57,8 @@ class ProfileModel extends Model
         'GROUP_ITEM', 'IN_LINK','IP_LINK', 'LANDING_PAGE', 'LINK_WEIGHT',
         'LOGO', 'M_LOGO', 'MAIL_PASSWORD',  'MAIL_SECURITY',
         'MAIL_SENDER', 'MAIL_SERVER', 'MAIL_SERVERPORT', 'MAIL_USERNAME',
-        'MEMCACHE_SERVERS', 'MIN_RESULTS_TO_GROUP', 'NAME_SERVER', 'MEDIA_MODE',
+        'MEMCACHE_SERVERS', 'MIN_RESULTS_TO_GROUP', 'NAME_SERVER',
+        'MEDIA_MODE',
         'PROXY_SERVERS', 'RECOVERY_MODE', 'REGISTRATION_TYPE', 'RESULT_SCORE',
         'ROBOT_INSTANCE','RSS_ACCESS', 'SEARCHBAR_PATH',
         'SEND_MAIL_MEDIA_UPDATER', 'SERVER_ALPHA', 'SESSION_NAME',
@@ -130,16 +131,22 @@ class ProfileModel extends Model
                 ACTIVITY_TRANSLATION_ID_INDEX ON ACTIVITY (TRANSLATION_ID)",
             "CRAWL_MIXES" => "CREATE TABLE CRAWL_MIXES (TIMESTAMP NUMERIC(".
                 C\TIMESTAMP_LEN.")
-                PRIMARY KEY, NAME VARCHAR(" . C\NAME_LEN . "), OWNER_ID INTEGER,
+                PRIMARY KEY, NAME VARCHAR(" . C\NAME_LEN .
+                "), OWNER_ID INTEGER,
                 PARENT NUMERIC(" . C\TIMESTAMP_LEN . "))",
             "CM_OWNER_ID_INDEX" => "CREATE INDEX CM_OWNER_ID_INDEX ON
                 CRAWL_MIXES (OWNER_ID)",
             "CM_PARENT_INDEX" => "CREATE INDEX CM_PARENT_INDEX ON
                 CRAWL_MIXES (PARENT)",
+            "CMS_DETECTORS" =>
+                "CREATE TABLE CMS_DETECTORS (TIMESTAMP NUMERIC(" .
+                C\TIMESTAMP_LEN . ") PRIMARY KEY NOT NULL, NAME VARCHAR(" .
+                C\TITLE_LEN . "), HEADER VARCHAR(" . C\TITLE_LEN . ")," .
+                "IMPORTANT_CONTENT VARCHAR(" . C\TITLE_LEN . "))",
             "CURRENT_WEB_INDEX" => "CREATE TABLE CURRENT_WEB_INDEX
                 (CRAWL_TIME NUMERIC(" . C\TIMESTAMP_LEN . ") PRIMARY KEY)",
             "CREDIT_LEDGER" => "CREATE TABLE CREDIT_LEDGER
-                (USER_ID INTEGER, AMOUNT INTEGER, TYPE VARCHAR(" . 
+                (USER_ID INTEGER, AMOUNT INTEGER, TYPE VARCHAR(" .
                 C\NAME_LEN . "), BALANCE INTEGER, TIMESTAMP NUMERIC(" .
                 C\TIMESTAMP_LEN . "))",
             "CL_USER_INDEX" => "CREATE INDEX CL_USER_INDEX ON
@@ -220,7 +227,8 @@ class ProfileModel extends Model
                 LOCALE(LOCALE_TAG)",
             "MACHINE" => "CREATE TABLE MACHINE (NAME VARCHAR(" . C\NAME_LEN
                 .") PRIMARY KEY,
-                URL VARCHAR(" . C\MAX_URL_LEN . ") UNIQUE, HAS_QUEUE_SERVER INT,
+                URL VARCHAR(" . C\MAX_URL_LEN .
+                ") UNIQUE, HAS_QUEUE_SERVER INT,
                 NUM_FETCHERS INTEGER, PARENT VARCHAR(" . C\NAME_LEN . ") )",
             "MEDIA_SOURCE" => "CREATE TABLE MEDIA_SOURCE (
                 TIMESTAMP NUMERIC(" . C\TIMESTAMP_LEN . ") PRIMARY KEY,
@@ -231,7 +239,8 @@ class ProfileModel extends Model
             "MS_TYPE_INDEX" => "CREATE INDEX MS_TYPE_INDEX ON
                 MEDIA_SOURCE(TYPE)",
             "MIX_COMPONENTS" => "CREATE TABLE MIX_COMPONENTS (
-                TIMESTAMP NUMERIC(" . C\TIMESTAMP_LEN . "), FRAGMENT_ID INTEGER,
+                TIMESTAMP NUMERIC(" . C\TIMESTAMP_LEN . "),
+                FRAGMENT_ID INTEGER,
                 CRAWL_TIMESTAMP NUMERIC(".C\TIMESTAMP_LEN."), WEIGHT REAL,
                 KEYWORDS VARCHAR(" . C\TITLE_LEN . "),
                 PRIMARY KEY(TIMESTAMP, FRAGMENT_ID, CRAWL_TIMESTAMP) )",
@@ -341,8 +350,8 @@ class ProfileModel extends Model
      * fields of $new_profile_data will be considered).
      * @param array $old_profile_data fields and values that come from
      *     presumably a previously existing profile
-     * @param bool $reset whether the new profile data is coming from a reset to
-     *      factory settings or not
+     * @param bool $reset whether the new profile data is coming from a reset
+     *     to factory settings or not
      */
     public function updateProfile($directory, $new_profile_data,
         $old_profile_data, $reset = false)
@@ -459,7 +468,7 @@ EOT;
             $n[] = "nsdefine('$field', {$profile[$field]});";
         }
         $out = implode("\n", $n);
-        if (file_put_contents($directory.C\PROFILE_FILE_NAME, $out) !== false) {
+        if (file_put_contents($directory.C\PROFILE_FILE_NAME, $out) !== false){
             restore_error_handler();
             @chmod($directory.C\PROFILE_FILE_NAME, 0777);
             if (isset($new_profile_data['AUXILIARY_CSS'])) {
@@ -544,7 +553,8 @@ EOT;
                will be screwed up unless do
              */
             $auto_tables = ["ACTIVITY" =>"ACTIVITY_ID",
-                "GROUP_ITEM" =>"GROUP_ITEM_ID", "GROUP_PAGE" => "GROUP_PAGE_ID",
+                "GROUP_ITEM" =>"GROUP_ITEM_ID",
+                "GROUP_PAGE" => "GROUP_PAGE_ID",
                 "GROUPS" => "GROUP_ID", "LOCALE"=> "LOCALE_ID",
                 "ROLE" => "ROLE_ID", "TRANSLATION" => "TRANSLATION_ID",
                 "USERS" => "USER_ID"];
@@ -662,7 +672,8 @@ EOT;
     public function setWorkDirectoryConfigFile($directory)
     {
         $config = file_get_contents(C\BASE_DIR."/configs/Config.php");
-        $start_machine_section = strpos($config, '/*+++ The next block of code');
+        $start_machine_section = strpos($config,
+            '/*+++ The next block of code');
         if ($start_machine_section === false) {
             return false;
         }
@@ -729,4 +740,4 @@ EOT;
         }
         return $match;
     }
-}
+}
\ No newline at end of file
-- 
1.9.5.github.0

