- Timestamp:
- 08/07/09 16:06:07 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/workflow/2.0/inc/class.workflow_processmanager.inc.php
r795 r1293 26 26 'database_user', 27 27 'database_password' 28 ); 28 ); 29 29 /** 30 30 * Constructor … … 34 34 function workflow_processmanager() 35 35 { 36 parent::ProcessManager( $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);36 parent::ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 37 37 $this->workflow_acl = CreateObject('workflow.workflow_acl'); 38 38 39 39 /* allow regular users to see the process graph */ 40 40 if ($_GET['menuaction'] == "workflow.ui_adminactivities.show_graph") … … 67 67 { 68 68 $proc_name = $this->_normalize_name($data['name'],$data['version']); 69 foreach($data['templates'] as $tpl) 69 foreach($data['templates'] as $tpl) 70 70 { 71 71 $full_fname = GALAXIA_PROCESSES.SEP.$proc_name.SEP.'code'.SEP.'templates'.SEP.$tpl['name']; 72 72 if (file_exists($full_fname)) unlink($full_fname); 73 73 74 74 $fp = fopen($full_fname,"w"); 75 75 fwrite($fp, $tpl['code']); … … 77 77 } 78 78 79 foreach($data['includes'] as $inc) 79 foreach($data['includes'] as $inc) 80 80 { 81 81 $full_fname = GALAXIA_PROCESSES.SEP.$proc_name.SEP.'code'.SEP.$inc['name']; 82 82 if (file_exists($full_fname)) unlink($full_fname); 83 83 84 84 $fp = fopen($full_fname,"w"); 85 85 fwrite($fp, $inc['code']); … … 111 111 } 112 112 113 /** 113 /** 114 114 * Creates an XML representation of a process. 115 115 * Original from ProcessManager Class … … 124 124 if (!isset($this->jobManager)) 125 125 $this->jobManager = new JobManager($this->db); 126 126 127 127 //if (!(isset($this->activity_manager))) $this->activity_manager = new ActivityManager($this->db); 128 128 // <process> … … 151 151 //Loop on config values 152 152 $out.=' <configs>'."\n"; 153 foreach($proc_info['config'] as $res) { 153 foreach($proc_info['config'] as $res) { 154 154 $name = $res['wf_config_name']; 155 155 $value_int = $res['wf_config_value_int']; 156 156 $value = $res['wf_config_value']; 157 if (array_search($name,$this->not_export_attributes) === false) 157 if (array_search($name,$this->not_export_attributes) === false) 158 158 { 159 159 $out.=' <config>'."\n"; … … 167 167 168 168 // Now loop over activities 169 169 170 170 $act_list = $this->activity_manager->list_activities($pId, 0, -1, 'wf_name__asc', '','',false); 171 171 $out.=' <activities>'."\n"; 172 foreach($act_list['data'] as $res) { 172 foreach($act_list['data'] as $res) { 173 173 $name = $res['wf_normalized_name']; 174 174 $out.=' <activity>'."\n"; … … 193 193 $out.=' <role>'.htmlspecialchars($role['wf_name']).'</role>'."\n"; 194 194 } 195 } 195 } 196 196 $out.=' </roles>'."\n"; 197 197 $out.=' <agents>'."\n"; … … 216 216 $out.=' </agent_datas>'."\n"; 217 217 $out.=' </agent>'."\n"; 218 } 218 } 219 219 $out.=' </agents>'."\n"; 220 220 … … 238 238 $out.=' ]]></template>'; 239 239 } 240 $out.=' </activity>'."\n"; 240 $out.=' </activity>'."\n"; 241 241 } 242 242 $out.=' </activities>'."\n"; 243 243 244 244 //export all templates 245 $base_path = GALAXIA_PROCESSES.SEP.$wf_procname.SEP.'code'.SEP.'templates'; 246 $handle = opendir($base_path); 245 $base_path = GALAXIA_PROCESSES.SEP.$wf_procname.SEP.'code'.SEP.'templates'; 246 $handle = opendir($base_path); 247 247 $out.=' <templates>'."\n"; 248 248 while (false !== ($name = readdir($handle))) … … 263 263 fclose($fp); 264 264 $out.=' ]]></code>'; 265 $out.=' </template>'."\n"; 265 $out.=' </template>'."\n"; 266 266 } 267 267 $out.=' </templates>'."\n"; 268 268 269 //export all includes 270 $base_path = GALAXIA_PROCESSES.SEP.$wf_procname.SEP.'code'; 271 $handle = opendir($base_path); 269 //export all includes 270 $base_path = GALAXIA_PROCESSES.SEP.$wf_procname.SEP.'code'; 271 $handle = opendir($base_path); 272 272 $out.=' <includes>'."\n"; 273 273 while (false !== ($name = readdir($handle))) … … 291 291 fclose($fp); 292 292 $out.=' ]]></code>'; 293 $out.=' </include>'."\n"; 293 $out.=' </include>'."\n"; 294 294 } 295 295 $out.=' </includes>'."\n"; … … 314 314 $out .= " </jobs>\n"; 315 315 316 //export all resources 316 //export all resources 317 317 $base_path = GALAXIA_PROCESSES . SEP . $wf_procname . SEP . 'resources'; 318 $handle = opendir($base_path); 318 $handle = opendir($base_path); 319 319 $out.=' <resources>'."\n"; 320 320 while (false !== ($name = readdir($handle))) 321 { 321 { 322 322 if (is_dir($base_path.SEP.$name)) 323 323 continue; … … 348 348 $out.=' <to>'.htmlspecialchars($tran['wf_act_to_name']).'</to>'."\n"; 349 349 $out.=' </transition>'."\n"; 350 } 350 } 351 351 $out.=' </transitions>'."\n"; 352 352 $out.= '</process>'."\n"; 353 353 354 354 //$fp = fopen(GALAXIA_PROCESSES."/$wf_procname/$wf_procname.xml","w"); 355 355 //fwrite($fp,$out); … … 360 360 /** 361 361 * Creates a process PHP data structure from its XML representation 362 * 363 * Unserialize process data 362 * 363 * Unserialize process data 364 364 * @access public 365 365 * @return void 366 366 */ 367 function unserialize_process(&$xml) 367 function unserialize_process(&$xml) 368 368 { 369 369 // Create SAX parser assign this object as base for handlers 370 370 // handlers are private methods defined below. 371 371 // keep contexts and parse 372 $this->parser = xml_parser_create("ISO-8859-1"); 372 $this->parser = xml_parser_create("ISO-8859-1"); 373 373 xml_parser_set_option($this->parser,XML_OPTION_CASE_FOLDING,0); 374 374 //xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE, 1); … … 376 376 xml_set_element_handler($this->parser, '_start_element_handler', '_end_element_handler'); 377 377 xml_set_character_data_handler($this->parser, '_data_handler'); 378 378 379 379 $aux=Array( 380 380 'name'=>'root', 381 381 'children'=>Array(), 382 382 'parent' => 0, 383 'data'=>'', 383 'data'=>'', 384 384 'attribs' => Array(), 385 385 ); 386 386 387 387 $this->tree[0]=$aux; 388 388 $this->current=0; 389 389 390 390 if (!xml_parse($this->parser, $xml, true)) { 391 391 $error = sprintf("XML error: %s at line %d", … … 395 395 $this->error[] = $error; 396 396 } 397 xml_parser_free($this->parser); 397 xml_parser_free($this->parser); 398 398 // Now that we have the tree we can do interesting things 399 399 400 400 $process=Array(); 401 401 $activities=Array(); … … 406 406 $z=$this->tree[1]['children'][$i]; 407 407 $name = trim($this->tree[$z]['name']); 408 408 409 409 //config values 410 410 if ($name=='configs') { … … 422 422 $configs[]=$aux; 423 423 } 424 } 424 } 425 425 } 426 426 //activities … … 453 453 ); 454 454 } 455 } 456 elseif ($name=='agents') 455 } 456 elseif ($name=='agents') 457 457 { 458 458 $agents=Array(); 459 for($l=0;$l<count($this->tree[$z3]['children']);$l++) 459 for($l=0;$l<count($this->tree[$z3]['children']);$l++) 460 460 { 461 461 $z4 = $this->tree[$z3]['children'][$l]; … … 472 472 // data will be the agent_type or an array for agent_datas 473 473 $data = trim($this->tree[$z5]['data']); 474 if ($name=='agent_type') 474 if ($name=='agent_type') 475 475 { 476 476 $agent['wf_agent_type']=$data; 477 } 478 elseif ($name=='agent_datas') 477 } 478 elseif ($name=='agent_datas') 479 479 { 480 480 for($n=0;$n<count($this->tree[$z5]['children']);$n++) … … 618 618 return $process; 619 619 } 620 620 621 621 /** 622 622 * Creates a new process PHP data structure from its XML representation 623 * unserial 623 * unserial 624 624 * @access public 625 625 * @return void … … 641 641 /** 642 642 * Remove process 643 * @param int $pId process id 644 * @access public 645 * @return string 643 * @param int $pId process id 644 * @access public 645 * @return string 646 646 */ 647 647 function remove_process($pId) … … 653 653 /** 654 654 * Replace_process 655 * 656 * @param int $pid process id 657 * @param array $vars 655 * 656 * @param int $pid process id 657 * @param array $vars 658 658 * @param boolean $create 659 * 659 * 660 660 * @access public 661 661 * @return int new id … … 671 671 672 672 return $id; 673 } 673 } 674 674 } 675 675 ?>
Note: See TracChangeset
for help on using the changeset viewer.