Exemplo n.º 1
0
/**
 *transforms a string operation from a patch page into a logoot operation
 * insertion or deletion
 * returns false if there is a problem with the type of the operation
 *
 * @param <String> $operation
 * @return <Object> logootOp
 */
function operationToLogootOp($operation)
{
    wfDebugLog('p2p', '@@@@@@@@@@@@@@@@@@@@@@@@@@@ - function operationToLogootOp : ' . $operation);
    $arr = array();
    $res = explode(';', $operation);
    foreach ($res as $key => $attr) {
        $res[$key] = trim($attr, " ");
    }
    //echo $operation." <--\n";
    //var_dump($res);
    $position = $res[2];
    $position = str_ireplace('(', '', $position);
    $position = str_ireplace(')', '', $position);
    $res1 = explode(' ', $position);
    foreach ($res1 as $id) {
        $id1 = explode(':', $id);
        $idArrray = new LogootId($id1[0], $id1[1], $id1[2]);
        $arr[] = $idArrray;
    }
    $logootPos = new LogootPosition($arr);
    /*$id1 = str_ireplace('(', '', $res[2]);
        $id2 = $res[3];
        $id3 = str_ireplace(')', '', $res[4]);
        $idArrray = new LogootId($id1, $id2, $id3);
        
    	echo $logootPos->toString();*/
    //    if(strpos($res[3], '-5B-5B')!==false || strpos($res[3], '-5D-5D')!==false) {
    //        $res[3] = utils::decodeRequest($res[3]);
    //    }
    $res[3] = utils::contentDecoding($res[3]);
    //    if($res[3]=="") $res[3]="\r\n";
    if ($res[1] == "Insert") {
        $logootOp = manager::getNewLogootIns($logootPos, $res[3]);
        //new LogootIns($logootPos, $res[3]);
    } elseif ($res[1] == "Delete") {
        $logootOp = manager::getNewLogootDel($logootPos, $res[3]);
        //new LogootDel($logootPos, $res[3]);
    } else {
        $logootOp = false;
    }
    //echo $logootOp;
    return $logootOp;
}