Browse Source

Change the way how get the config data - refs #7279

Angel Fernando Quiroz Campos 10 years ago
parent
commit
36836206e8
2 changed files with 17 additions and 5 deletions
  1. 2 5
      plugin/tour/index.php
  2. 15 0
      plugin/tour/src/tour_plugin.class.php

+ 2 - 5
plugin/tour/index.php

@@ -9,20 +9,17 @@
  */
 require_once dirname(__FILE__) . '/config.php';
 
-$pluginPath = api_get_path(PLUGIN_PATH) . 'tour/';
 $pluginWebPath = api_get_path(WEB_PLUGIN_PATH) . 'tour/';
 
 $userId = api_get_user_id();
 
 $tourPlugin = Tour::create();
 
-$jsonContent = file_get_contents($pluginPath . 'config/tour.json');
-
-$json = json_decode($jsonContent, true);
+$config = $tourPlugin->getTourCofig();
 
 $pages = array();
 
-foreach ($json as $pageContent) {
+foreach ($config as $pageContent) {
     $pages[] = array(
         'pageClass' => $pageContent['pageClass'],
         'show' => $tourPlugin->checkTourForUser($pageContent['pageClass'], $userId)

+ 15 - 0
plugin/tour/src/tour_plugin.class.php

@@ -126,4 +126,19 @@ class Tour extends Plugin
         ));
     }
 
+    /**
+     * Get the configuration to show the tour in pages
+     * @return array The config data
+     */
+    public function getTourCofig()
+    {
+        $pluginPath = api_get_path(PLUGIN_PATH) . 'tour/';
+
+        $jsonContent = file_get_contents($pluginPath . 'config/tour.json');
+
+        $jsonData = json_decode($jsonContent, true);
+
+        return $jsonData;
+    }
+
 }