case time

case “data_date”:
/*不确定年月的处理,’去年(-1),前6个月(-6)’ 用文章时间与提出时间的名字相加得出真正时间*/
//for($i=0;$i<20;$i++)echo $myData[$i]->name;
if ($myData[$order-1]->other == “data_link”)
$myData[$order-1]->attribute = $myData[$order-1]->other;

if (($type == 1) && (strpos($name,”year”) == true)) {//如果是今年类型的,需要向前找。
$name =substr($name,0,2);
$name = substr($ctime,0,4) + $name;
$name .= “年”;
$query = “select id,name,type from $c where key_word=’$name'”;
$result = mysql_query($query);
$id = @mysql_result($result,0,”id”);
$name = @mysql_result($result,0,”name”);
$type = @mysql_result($result,0,”type”);

if(strpos($key,”未来”)!==false || strpos($key,”内”)!==false){//增加对时间段的判断。
$name_b = substr($ctime,0,4).”年”;
$query = “select id,name,type from $c where key_word=’$name_b'”;
$result = @mysql_query($query);
$id = @mysql_result($result,0,”id”).”-“.$id;
$name = @mysql_result($result,0,”name”).”至”.$name;
}
}elseif (($type == 3) && (strpos($name,”month”) == true)) {//如果是本月类型,是当前年,
$name=substr($name,0,2);
$name = substr($ctime,5,2) + $name;
$name .= “月”;
$query = “select id,name,type from $c where key_word=’$name'”;
$result = mysql_query($query);
$id = @mysql_result($result,0,”id”);
$name = @mysql_result($result,0,”name”);
$type = @mysql_result($result,0,”type”);
$myData[$order]->id = “#”.$id;
$myData[$order]->name = $name;
$myData[$order]->keyw = “#”.$key;
$myData[$order]->attribute = ‘data_date’;
$order++;
return;
}elseif (($type == 3) && (strpos($name,”quarter”) == true)) {//如果是本季度类型,是当前年
$name=substr($name,0,2);
$name = ceil(substr($ctime,5,2)/3 + $name);
$name .= “季度”;
$query = “select id,name,type from $c where key_word=’$name'”;
$result = mysql_query($query);
$id = @mysql_result($result,0,”id”);
$name = @mysql_result($result,0,”name”);
$type = @mysql_result($result,0,”type”);
$myData[$order]->id = “#”.$id;
$myData[$order]->name = $name;
$myData[$order]->keyw = “#”.$key;
$myData[$order]->attribute = ‘data_date’;
$order++;
return;
}elseif(($type == 3) && (strpos($name,”blur”) == true)){//对模糊年月的查找,
///模糊日期
///-0-blur 同期 向前找到“月”包括连续和不连续的,年份向下
///+1-blur 本期 向前找到“月”包括连续和不连续的,年份ctime(break;)
///-1-blur 这个月 向前找到“月”要不连续的,年份向下
///-2-blur 这个季度 向前找到“月”要连续的,年份向下
//$jinghao_i=0;
if(substr($name,0,2)==1){//本期不用找年,ctime
for($i=count($myData)-1; $i>=0; $i–){
if($myData[$i]->attribute==’data_date’ && strpos($myData[$i]->name,”月”) !== false){//如果是时间并且包含月
if(strpos($myData[$i]->name,”年”)!==false){
$date_start=strpos($myData[$i]->name,”年”);
$date_end=strpos($myData[$i]->name,”月”);
$name=substr($myData[$i]->name,$date_start+2,$date_end);
$s_id = explode(“#”,$myData[$i]->id);
$myData[$order]->id = “#”.$s_id[1];
$myData[$order]->name = $name;
$s_keyw=explode(“#”,$myData[$i]->keyw);
$myData[$order]->keyw = “#”.$s_keyw[1];
$myData[$order]->attribute = ‘data_date’;
$order++;
return;
}
else{//不包含年的。
//echo $myData[$i]->$name;
if(strpos($myData[$i]->id,”#”) !== false){
$myData[$order]->id = $myData[$i]->id;
}else{
$myData[$order]->id = “#”.$myData[$i]->id;
}
$myData[$order]->name = $myData[$i]->name;
if(strpos($myData[$i]->keyw,”#”) !== false){
$myData[$order]->keyw = $myData[$i]->keyw;
}else{
$myData[$order]->keyw = “#”.$myData[$i]->keyw;
}

$myData[$order]->attribute = ‘data_date’;
$order++;
return;
}
}
}//如果还没有找到年并且还没有退出,向下执行,计算当前时间。
$name = substr($ctime,5,2) ;
$name .= “月”;
$query = “select id,name,type from $c where key_word=’$name'”;
$result = mysql_query($query);
$id = @mysql_result($result,0,”id”);
$name = @mysql_result($result,0,”name”);
$type = @mysql_result($result,0,”type”);
$myData[$order]->id = “#”.$id;
$myData[$order]->name = $name;
$myData[$order]->keyw = “#”.$key;
$myData[$order]->attribute = ‘data_date’;
$order++;
return;
}//本期的结束
else{
if(substr($name,0,2)==0){//-0-blur 同期 向前找到“月”包括连续和不连续的,年份向下

$seek_i=0;
$seek_y=0;
for($i=count($myData)-1; $i>=0; $i–){//向前找时间
if($seek_y==0 && $myData[$i]->attribute==’data_date’ && strpos($myData[$i]->name,”月”) !== false){//时间包含月
if(strpos($myData[$i]->name,”年”)!==false){
$date_start=strpos($myData[$i]->name,”年”);
$date_end=strpos($myData[$i]->name,”月”);
$name=substr($myData[$i]->name,$date_start+2,$date_end);
$s_id = explode(“#”,$myData[$i]->id);
$id=$s_id[1];
$name = $name;
$type= 3;
$seek_i=1;
$seek_y=1;
}//含有年的
else{
if(strpos($myData[$i]->id,”#”) !== false){
$s_id = explode(“#”,$myData[$i]->id);
$id = $s_id[1];
}else{
$id = $myData[$i]->id;
}
$name = $myData[$i]->name;
$type = 3;
$seek_i = 1;
$seek_y=1;
}//不包含年的
}
}//不含有时间的有问题
if($seek_i==0){//不含有时间的用当前时间
$name = substr($ctime,5,2) ;
$name .= “月”;
$query = “select id,name,type from $c where key_word=’$name'”;
$result = mysql_query($query);
$id = @mysql_result($result,0,”id”);
$name = @mysql_result($result,0,”name”);
$type = @mysql_result($result,0,”type”);
if($myData[$order-1]->attribute == “data_date” && strpos($myData[$order-1]->name,”年”)){
$myData[$order-1]->attribute = “data_date”;
$myData[$order-1]->keyw =$myData[$order-1]->keyw.”#”.$key;
$myData[$order-1]->id =$myData[$order-1]->id.”#”.$id;
$myData[$order-1]->name =$myData[$order-1]->name.$name;
return;
}
else{
$myData[$order]->id = “#”.$id;
$myData[$order]->name = $name;
$myData[$order]->keyw = “#”.$key;
$myData[$order]->attribute = ‘data_date’;
$order++;
return;
}
}
}
if(substr($name,0,2)==-1){//-1-blur 这个月 向前找到“月”要不连续的,年份向下
}
if(substr($name,0,2)==-2){//-2-blur 这个季度 向前找到“月”要连续的,年份向下
}
}
}

//对日处理,学要向前找月,
if($myData[$order-1]->attribute == “data_date” && $type==4){ //如果前一个是日期后一个是日则放在一起,作为一个元素
$myData[$order-1]->id .= “#”.$id;
$myData[$order-1]->name .= $name;
$myData[$order-1]->keyw .= “#”.$key;
return;
}
elseif($myData[$order-1]->attribute != “data_date” && $type==4){ //seek month & link
for($i=count($myData)-1; $i>=0; $i–){
if($myData[$i]->attribute==’data_date’){
if($myData[$i]->attribute==’data_date’ && strpos($myData[$i]->name,”日”) !== false && strpos($myData[$i]->name,”月”) !== false && strpos($myData[$i]->name,”年”) !== false){//20004年8月2日
$s_id = explode(“#”,$myData[$i]->id);
$myData[$order]->id = $s_id[0].”#”.$s_id[1].”#”.$id;
$date_end=strpos($myData[$i]->name,”月”);
$myData[$order]->name = substr($myData[$i]->name,0,$date_end+2).$name;
$s_keyw = explode(“#”,$myData[$i]->keyw);
$myData[$order]->keyw = $s_key[0].”#”.$s_key[1].”#”.$key;
$myData[$order]->attribute = ‘data_date’;
$myData[$order]->type =1;
$order++;
return;
}
elseif($myData[$i]->attribute==’data_date’ && strpos($myData[$i]->name,”年” )!==false && strpos($myData[$i]->name,”月”) !== false){//如果2004年8月
$myData[$order]->id = $myData[$i]->id.”#”.$id;
$myData[$order]->name = $myData[$i]->name.$name;
$myData[$order]->keyw = $myData[$i]->keyw.”#”.$key;
$myData[$order]->attribute = ‘data_date’;
$myData[$order]->type =2;
$order++;
return;
}
elseif($myData[$i]->attribute==’data_date’ && strpos($myData[$i]->name,”月” )!==false ){//如果是8月
$id = $myData[$i]->id.”#”.$id;
$name = $myData[$i]->name.$name;
$keyw = $myData[$i]->keyw.”#”.$key;
$type =2;
}
}
}//如果找不到做入库准备
$myData[$order]->id = “#”.$id;
$myData[$order]->name = $name;
$myData[$order]->keyw = “#”.$key;
$myData[$order]->attribute = ‘data_date’;
$order++;
return;
}
elseif($myData[$order-1]->attribute == “data_date” && $type==4){ //重月
$id = $myData[$order-1]->id;
$keyw = $myData[$order-1]->keyw;
}
//对月处理,学要向前找年,
if($myData[$order-1]->attribute == “data_date” && $type==3){ //如果前一个是日期后一个是月则放在一起,作为一个元素
$myData[$order-1]->id = $myData[$order-1]->id.”#”.$id;
$myData[$order-1]->name .= $name;
$myData[$order-1]->keyw .= “#”.$key;
return;
}
elseif($myData[$order-1]->attribute != “data_date” && $type==3){ //seek year & link
for($i=count($myData)-1; $i>=0; $i–){
if($myData[$i]->attribute==’data_date’){
if($myData[$i]->attribute==’data_date’ && strpos($myData[$i]->name,”月”) !== false && strpos($myData[$i]->name,”年”) !== false){
$s_id = explode(“#”,$myData[$i]->id);
$myData[$order]->id = $s_id[0].”#”.$id;
$myData[$order]->name = substr($myData[$i]->name,0,6).$name;
$s_keyw=explode(“#”,$myData[$i]->keyw);
$myData[$order]->keyw = $s_keyw[0].”#”.$key;
$myData[$order]->attribute = ‘data_date’;
$myData[$order]->type =1;
$order++;
return;
}
elseif($myData[$i]->attribute==’data_date’ && strpos($myData[$i]->name,”年”)!==false){//如果是日期而且不含有月
//echo “*”;
$myData[$order]->id = $myData[$i]->id.”#”.$id;
$myData[$order]->name = $myData[$i]->name.$name;
$myData[$order]->keyw = $myData[$i]->keyw.”#”.$key;
$myData[$order]->attribute = ‘data_date’;
$myData[$order]->type =1;
$order++;
return;
}
}
}//如果找不到做入库准备
$myData[$order]->id = “#”.$id;
$myData[$order]->name = $name;
$myData[$order]->keyw = “#”.$key;
$myData[$order]->attribute = ‘data_date’;
$myData[$order]->id;
$order++;
return;
}
elseif($myData[$order-1]->attribute == “data_date” && $type==1){ //重年
$id = $myData[$order-1]->id;
$keyw = $myData[$order-1]->keyw;
}
elseif($type == 3){ //只有月,把年置空
$id = “#”.$id;
$keyw = “#”.$key;
}
break;

Leave a comment

Your email address will not be published. Required fields are marked *