コード例 #1
0
 function compile_activity($pId, $activityId)
 {
     $act_info = $this->get_activity($pId, $activityId);
     $actname = $act_info['normalized_name'];
     $pm = new ProcessManager($this->db);
     $proc_info = $pm->get_process($pId);
     $compiled_file = GALAXIA_PROCESSES . '/' . $proc_info['normalized_name'] . '/compiled/' . $act_info['normalized_name'] . '.php';
     $template_file = GALAXIA_PROCESSES . '/' . $proc_info['normalized_name'] . '/code/templates/' . $actname . '.tpl';
     $user_file = GALAXIA_PROCESSES . '/' . $proc_info['normalized_name'] . '/code/activities/' . $actname . '.php';
     $pre_file = GALAXIA_LIBRARY . '/compiler/' . $act_info['type'] . '_pre.php';
     $pos_file = GALAXIA_LIBRARY . '/compiler/' . $act_info['type'] . '_pos.php';
     $fw = fopen($compiled_file, "wb");
     // First of all add an include to to the shared code
     $shared_file = GALAXIA_PROCESSES . '/' . $proc_info['normalized_name'] . '/code/shared.php';
     fwrite($fw, '<' . "?php include_once('{$shared_file}'); ?" . '>' . "\n");
     // Before pre shared
     $fp = fopen(GALAXIA_LIBRARY . '/compiler/_shared_pre.php', "rb");
     while (!feof($fp)) {
         $data = fread($fp, 4096);
         fwrite($fw, $data);
     }
     fclose($fp);
     // Now get pre and pos files for the activity
     $fp = fopen($pre_file, "rb");
     while (!feof($fp)) {
         $data = fread($fp, 4096);
         fwrite($fw, $data);
     }
     fclose($fp);
     // Get the user data for the activity
     $fp = fopen($user_file, "rb");
     while (!feof($fp)) {
         $data = fread($fp, 4096);
         fwrite($fw, $data);
     }
     fclose($fp);
     // Get pos and write
     $fp = fopen($pos_file, "rb");
     while (!feof($fp)) {
         $data = fread($fp, 4096);
         fwrite($fw, $data);
     }
     fclose($fp);
     // Shared pos
     $fp = fopen(GALAXIA_LIBRARY . '/compiler/_shared_pos.php', "rb");
     while (!feof($fp)) {
         $data = fread($fp, 4096);
         fwrite($fw, $data);
     }
     fclose($fp);
     fclose($fw);
     //Copy the templates
     if ($act_info['isInteractive'] == 'y' && !file_exists($template_file)) {
         $fw = fopen($template_file, 'w');
         if (defined('GALAXIA_TEMPLATE_HEADER') && GALAXIA_TEMPLATE_HEADER) {
             fwrite($fw, GALAXIA_TEMPLATE_HEADER . "\n");
         }
         fclose($fw);
     }
     if ($act_info['isInteractive'] != 'y' && file_exists($template_file)) {
         @unlink($template_file);
         if (GALAXIA_TEMPLATES && file_exists(GALAXIA_TEMPLATES . '/' . $proc_info['normalized_name'] . "/{$actname}.tpl")) {
             @unlink(GALAXIA_TEMPLATES . '/' . $proc_info['normalized_name'] . "/{$actname}.tpl");
         }
     }
     if (GALAXIA_TEMPLATES && file_exists($template_file)) {
         @copy($template_file, GALAXIA_TEMPLATES . '/' . $proc_info['normalized_name'] . "/{$actname}.tpl");
     }
 }