<?php require_once('includes/requirecompere.inc.php'); $op=TGET('op'); $replaces=array(); if ($op=='revise' && $_SESSION['reserv.inputcache.domain']=='textreplace') { $entrycount=$_SESSION['reserv.inputcache.data']['entrycount']; $ordinals=$_SESSION['reserv.inputcache.data']['ordinal']; asort($ordinals); $from_arr=$_SESSION['reserv.inputcache.data']['from']; $to_arr=$_SESSION['reserv.inputcache.data']['to']; $idx=10; foreach ($ordinals as $key=>$ordinal) { if ($from_arr[$key] || $to_arr[$key]) { array_push($replaces, array( 'idx'=>$idx, 'from'=>$from_arr[$key], 'to'=>$to_arr[$key] ) ); $idx+=10; } } } else { $src_file=compute_user_path(current_mb_id(),$Config->Paths['user.base'].'/','/trt.xml'); $replacexml=@simplexml_load_file($src_file); if ($replacexml) { $idx=10; foreach ($replacexml->rule as $rule) { array_push($replaces, array( 'idx'=>$idx, 'from'=>$rule->from, 'to'=>$rule->to ) ); $idx+=10; } } $entrycount=max(sizeof($replaces),5); } $dataset['entrycount']=$entrycount; while (sizeof($replaces)<$entrycount) { $idx=sizeof($replaces)*10+10; array_push($replaces, array( 'idx'=>$idx, 'from'=>'', 'to'=>'' ) ); } $dataset['REPLACE']=$replaces; $dataset['SAVED-OK']=$op=='saved.ok'?array(0):array(); ?>