From 51138d1c41d9be15d64d42bd25a46758d360ae4e Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Fri, 11 Feb 2011 00:55:42 +0000 Subject: improved actions history --- h-source/Application/Include/myFunctions.php | 69 +++++++++++++++------------- 1 file changed, 36 insertions(+), 33 deletions(-) (limited to 'h-source/Application/Include/myFunctions.php') diff --git a/h-source/Application/Include/myFunctions.php b/h-source/Application/Include/myFunctions.php index 483a85f..daefb59 100644 --- a/h-source/Application/Include/myFunctions.php +++ b/h-source/Application/Include/myFunctions.php @@ -95,40 +95,40 @@ function getOrderByClause($string) function diff($old, $new){ - $maxlen = 0; - foreach($old as $oindex => $ovalue){ + $maxlen = 0; + foreach($old as $oindex => $ovalue){ // $nkeys = getNewKeys($new,$ovalue); - $nkeys = array_keys($new, $ovalue); - foreach($nkeys as $nindex){ - $matrix[$oindex][$nindex] = isset($matrix[$oindex - 1][$nindex - 1]) ? - $matrix[$oindex - 1][$nindex - 1] + 1 : 1; - if($matrix[$oindex][$nindex] > $maxlen){ - $maxlen = $matrix[$oindex][$nindex]; - $omax = $oindex + 1 - $maxlen; - $nmax = $nindex + 1 - $maxlen; - } - } - } - if($maxlen == 0) return array(array('d'=>$old, 'i'=>$new)); - return array_merge( - diff(array_slice($old, 0, $omax), array_slice($new, 0, $nmax)), - array_slice($new, $nmax, $maxlen), - diff(array_slice($old, $omax + $maxlen), array_slice($new, $nmax + $maxlen))); + $nkeys = array_keys($new, $ovalue); + foreach($nkeys as $nindex){ + $matrix[$oindex][$nindex] = isset($matrix[$oindex - 1][$nindex - 1]) ? + $matrix[$oindex - 1][$nindex - 1] + 1 : 1; + if($matrix[$oindex][$nindex] > $maxlen){ + $maxlen = $matrix[$oindex][$nindex]; + $omax = $oindex + 1 - $maxlen; + $nmax = $nindex + 1 - $maxlen; + } + } + } + if($maxlen == 0) return array(array('d'=>$old, 'i'=>$new)); + return array_merge( + diff(array_slice($old, 0, $omax), array_slice($new, 0, $nmax)), + array_slice($new, $nmax, $maxlen), + diff(array_slice($old, $omax + $maxlen), array_slice($new, $nmax + $maxlen))); } function htmlDiff($old, $new){ - $old = str_replace("\r\n"," \r\n ",$old); - $new = str_replace("\r\n"," \r\n ",$new); - - $ret = null; - $diff = diff(explode(' ', $old), explode(' ', $new)); - foreach($diff as $k){ - if(is_array($k)) - $ret .= (!empty($k['d'])?"".implode(' ',$k['d'])." ":''). - (!empty($k['i'])?"".implode(' ',$k['i'])." ":''); - else $ret .= $k . ' '; - } - return $ret; + $old = str_replace("\r\n"," \r\n ",$old); + $new = str_replace("\r\n"," \r\n ",$new); + + $ret = null; + $diff = diff(explode(' ', $old), explode(' ', $new)); + foreach($diff as $k){ + if(is_array($k)) + $ret .= (!empty($k['d'])?"".implode(' ',$k['d'])." ":''). + (!empty($k['i'])?"".implode(' ',$k['i'])." ":''); + else $ret .= $k . ' '; + } + return $ret; } @@ -457,16 +457,19 @@ function getUrlsFromIdHard($id_hard) $urlView = "http://".DOMAIN_NAME; $urlTalk = "http://".DOMAIN_NAME; + $deviceName = null; $hard = new HardwareModel(); $res = $hard->select('type,model')->where(array('id_hard'=>$clean['id_hard']))->send(); if (count($res) > 0) { - $urlView = "http://".DOMAIN_NAME."/".MyStrings::$reverse[$res[0]['hardware']['type']]."/view/".Lang::$current."/".$clean['id_hard']."/".encodeUrl($res[0]['hardware']['model']); + $urlView = "http://".DOMAIN_NAME."/".Hardware::$typeToController[$res[0]['hardware']['type']]."/view/".Lang::$current."/".$clean['id_hard']."/".encodeUrl($res[0]['hardware']['model']); - $urlTalk = "http://".DOMAIN_NAME."/".MyStrings::$reverse[$res[0]['hardware']['type']]."/talk/".Lang::$current."/".$clean['id_hard']; + $urlTalk = "http://".DOMAIN_NAME."/".Hardware::$typeToController[$res[0]['hardware']['type']]."/talk/".Lang::$current."/".$clean['id_hard']; + + $deviceName = $res[0]['hardware']['model']; } - return array('urlView'=>$urlView,'urlTalk'=>$urlTalk); + return array('urlView'=>$urlView,'urlTalk'=>$urlTalk,'modelName'=>$deviceName); } \ No newline at end of file -- cgit v1.2.3