Subversion Repositories php-qbpwcf

Rev

Rev 172 | Rev 226 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 172 Rev 218
Line 4261... Line 4261...
4261
			#回傳結果
4261
			#回傳結果
4262
			return $result;
4262
			return $result;
4263
		
4263
		
4264
			}#if end
4264
			}#if end
4265
		
4265
		
-
 
4266
		#初始化儲存解析好的變數資訊陣列
-
 
4267
		$result["parsedVar"]=array();
-
 
4268
		
4266
		#另存一份input
4269
		#另存一份input
4267
		$modifiedInput=$conf["input"];
4270
		$modifiedInput=$conf["input"];
4268
			
4271
			
4269
		#預設分段的關鍵字為空
4272
		#預設分段的關鍵字為空
4270
		$keyWordPart=array();
4273
		$keyWordPart=array();
Line 4545... Line 4548...
4545
 
4548
 
4546
					#設置順序資訊
4549
					#設置順序資訊
4547
					$OderOfPartInLine[]=$tmp;
4550
					$OderOfPartInLine[]=$tmp;
4548
				
4551
				
4549
					}#if end
4552
					}#if end
4550
			
4553
				
4551
				#結束格式字串的解析
4554
				#結束格式字串的解析
4552
				break;
4555
				break;
4553
			
4556
			
4554
				}#else end
4557
				}#else end
4555
		
4558
		
4556
			}#while end
4559
			}#while end
4557
		
4560
		
-
 
4561
		#如果沒有解析出格式字串,代表關鍵字為空字串.
-
 
4562
		if($OderOfPartInLine===array()){
-
 
4563
		
-
 
4564
			#儲存剩下的內容為關鍵字之一
-
 
4565
			$keyWordPart[]=$conf["format"];
-
 
4566
		
-
 
4567
			#暫存的關鍵字資訊
-
 
4568
			$tmp=array("name"=>"keyWordPart","index"=>0,"value"=>$conf["format"]);
-
 
4569
 
-
 
4570
			#設置順序資訊
-
 
4571
			$OderOfPartInLine[]=$tmp;
-
 
4572
		
-
 
4573
			}#if end
-
 
4574
		
4558
		#debug
4575
		#debug
4559
		#var_dump(__LINE__,$OderOfPartInLine);
4576
		#var_dump(__LINE__,$OderOfPartInLine);
4560
		
4577
		
4561
		#如果有關鍵字片段與變數的順序存在
4578
		#如果有關鍵字片段與變數的順序存在
4562
		if( count($OderOfPartInLine)>0 ){
4579
		if( count($OderOfPartInLine)>0 ){
Line 4577... Line 4594...
4577
				switch($condition["name"]){
4594
				switch($condition["name"]){
4578
				
4595
				
4579
					#如果是 "keyWordPart"
4596
					#如果是 "keyWordPart"
4580
					case "keyWordPart":
4597
					case "keyWordPart":
4581
					
4598
					
4582
						#確認是否開頭有符合
4599
						#確認是否開頭有符號
4583
						
4600
						
4584
						#函式說明:
4601
						#函式說明:
4585
						#取得關鍵字在字串的哪個位置(字首,字尾,中間)
4602
						#取得關鍵字在字串的哪個位置(字首,字尾,中間)
4586
						#回傳結果:
4603
						#回傳結果:
4587
						#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
4604
						#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
Line 4606... Line 4623...
4606
						#備註:
4623
						#備註:
4607
						#無.
4624
						#無.
4608
						$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
4625
						$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
4609
						unset($conf["search::findKeyWordPosition"]);
4626
						unset($conf["search::findKeyWordPosition"]);
4610
					
4627
					
-
 
4628
						/*
4611
						#debug
4629
						#debug
-
 
4630
						if($condition["value"]===""){
-
 
4631
						
-
 
4632
							#debug
4612
						#var_dump(__LINE__,$findKeyWordPosition);
4633
							var_dump(__LINE__,$findKeyWordPosition);
-
 
4634
						
-
 
4635
							}#if end
-
 
4636
						*/
4613
					
4637
						
4614
						#如果執行失敗
4638
						#如果執行失敗
4615
						if($findKeyWordPosition["status"]==="false"){
4639
						if($findKeyWordPosition["status"]==="false"){
4616
						
4640
						
4617
							#設置錯誤識別
4641
							#設置錯誤識別
4618
							$result["status"]="false";
4642
							$result["status"]="false";
Line 4626... Line 4650...
4626
							}#if end
4650
							}#if end
4627
							
4651
							
4628
						#如果沒有符合
4652
						#如果沒有符合
4629
						if($findKeyWordPosition["found"]==="false"){
4653
						if($findKeyWordPosition["found"]==="false"){
4630
						
4654
						
4631
							#設置錯誤識別
4655
							#設置執行正常
4632
							$result["status"]="true";
4656
							$result["status"]="true";
4633
							
4657
							
4634
							#設置沒有符合格式
4658
							#設置沒有符合格式
4635
							$result["found"]="false";
4659
							$result["found"]="false";
4636
							
4660
							
Line 4640... Line 4664...
4640
							}#if end
4664
							}#if end
4641
							
4665
							
4642
						#如果關鍵字不在開頭
4666
						#如果關鍵字不在開頭
4643
						if($findKeyWordPosition["head"]==="false"){
4667
						if($findKeyWordPosition["head"]==="false"){
4644
						
4668
						
4645
							#設置錯誤識別
4669
							#設置執行正常
4646
							$result["status"]="true";
4670
							$result["status"]="true";
4647
							
4671
							
4648
							#設置沒有符合格式
4672
							#設置沒有符合格式
4649
							$result["found"]="false";
4673
							$result["found"]="false";
4650
							
4674
							
Line 4680... Line 4704...
4680
						#備註:
4704
						#備註:
4681
						#無.
4705
						#無.
4682
						$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
4706
						$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
4683
						unset($conf["stringProcess::delStrBeforeKeyWord"]);
4707
						unset($conf["stringProcess::delStrBeforeKeyWord"]);
4684
						
4708
						
-
 
4709
						/*
4685
						#debug
4710
						#debug
-
 
4711
						if($condition["value"]===" "){
-
 
4712
						
-
 
4713
							#debug
4686
						#var_dump(__LINE__,$delStrBeforeKeyWord);
4714
							var_dump(__LINE__,$delStrBeforeKeyWord);
-
 
4715
							
-
 
4716
							}#if end
-
 
4717
						*/
4687
						
4718
						
4688
						#如果執行失敗
4719
						#如果執行失敗
4689
						if($delStrBeforeKeyWord["status"]==="false"){
4720
						if($delStrBeforeKeyWord["status"]==="false"){
4690
						
4721
						
4691
							#設置錯誤識別
4722
							#設置錯誤識別
Line 4864... Line 4895...
4864
							#參考資料:
4895
							#參考資料:
4865
							#無.
4896
							#無.
4866
							#備註:
4897
							#備註:
4867
							#無.
4898
							#無.
4868
							$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
4899
							$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
4869
							unset($conf["stringProcess::delStrAfterKeyWord"]);						
4900
							unset($conf["stringProcess::delStrAfterKeyWord"]);
4870
							
4901
							
4871
							#如果執行失敗
4902
							#如果執行失敗
4872
							if($delStrAfterKeyWord["status"]==="false"){
4903
							if($delStrAfterKeyWord["status"]==="false"){
4873
							
4904
							
4874
								#設置錯誤識別
4905
								#設置錯誤識別
Line 5461... Line 5492...
5461
			}#else end
5492
			}#else end
5462
	
5493
	
5463
		}#function findSpecifyStr end
5494
		}#function findSpecifyStr end
5464
	
5495
	
5465
	/*
5496
	/*
-
 
5497
	#尋找連續的多行字串是否依順含有符合格式的內容,且回傳解析好的變數數值.
-
 
5498
	#回傳結果:
-
 
5499
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
5500
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
5501
	#$result["function"],當前執行的函式名稱.
-
 
5502
	#$result["argu"],所使用的參數.
-
 
5503
	#$result["found"],是否有找到符合格式的連續字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
5504
	#$result["content"],陣列,每段符合格式的段落資訊.
-
 
5505
	#$result["content"][$i]["lineS"],字串,為第 $i+1 個符合格式的段落起始行數.
-
 
5506
	#$result["content"][$i]["ori"],字串,為第 $i+1 個符合格式的段落每行原始內容資訊.
-
 
5507
	#$result["content"][$i]["deletedHead"],字串,為第 $i+1 個符合格式的段落每行原始內容被剔除的開頭資訊.
-
 
5508
	#$result["content"][$i]["new"],字串,為第 $i+1 個符合格式的段落每行關鍵字內容.
-
 
5509
	#$result["content"][$i]["vars"],陣列,為第 $i+1 個符合格式的段落每行變數解析的結果.
-
 
5510
	#必填參數:
-
 
5511
	#$conf["input"],字串陣列,要檢查的每行字串.
-
 
5512
	$conf["input"]=array("");
-
 
5513
	#$conf["format"],格式字串陣列,要尋找的每行格式字串集合.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
5514
	$conf["formats"]=array("");
-
 
5515
	#可省略參數:
-
 
5516
	#無.
-
 
5517
	#參考資料:
-
 
5518
	#無.
-
 
5519
	#備註:
-
 
5520
	#回傳結果 $result["content"][$i]["ori"][$j]=array("index"=>$oriLineIndex,"value"=>$oriLineContent) 代表第 $i+1 個符合格式的段落中第 $j+1 個原始內容對應的行數($oriLineIndex+1),其原始內容為 $oriLineContent.
-
 
5521
	*/
-
 
5522
	public static function findConMatchStrs(&$conf){
-
 
5523
	
-
 
5524
		#初始化要回傳的結果
-
 
5525
		$result=array();
-
 
5526
 
-
 
5527
		#取得當前執行的函數名稱
-
 
5528
		$result["function"]=__FUNCTION__;
-
 
5529
 
-
 
5530
		#如果沒有參數
-
 
5531
		if(func_num_args()==0){
-
 
5532
 
-
 
5533
			#設置執行失敗
-
 
5534
			$result["status"]="false";
-
 
5535
 
-
 
5536
			#設置執行錯誤訊息
-
 
5537
			$result["error"]="函數".$result["function"]."需要參數";
-
 
5538
 
-
 
5539
			#回傳結果
-
 
5540
			return $result;
-
 
5541
 
-
 
5542
			}#if end
-
 
5543
 
-
 
5544
		#取得參數
-
 
5545
		$result["argu"]=$conf;
-
 
5546
 
-
 
5547
		#如果 $conf 不為陣列
-
 
5548
		if(gettype($conf)!=="array"){
-
 
5549
 
-
 
5550
			#設置執行失敗
-
 
5551
			$result["status"]="false";
-
 
5552
 
-
 
5553
			#設置執行錯誤訊息
-
 
5554
			$result["error"][]="\$conf變數須為陣列形態";
-
 
5555
 
-
 
5556
			#如果傳入的參數為 null
-
 
5557
			if(is_null($conf)){
-
 
5558
 
-
 
5559
				#設置執行錯誤訊息
-
 
5560
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
-
 
5561
 
-
 
5562
				}#if end
-
 
5563
 
-
 
5564
			#回傳結果
-
 
5565
			return $result;
-
 
5566
 
-
 
5567
			}#if end
-
 
5568
			
-
 
5569
		#函式說明:
-
 
5570
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
-
 
5571
		#回傳結果:
-
 
5572
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
5573
		#$result["error"],執行不正常結束的錯訊息陣列.
-
 
5574
		#$result["simpleError"],簡單表示的錯誤訊息.
-
 
5575
		#$result["function"],當前執行的函式名稱.
-
 
5576
		#$result["argu"],設置給予的參數.
-
 
5577
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
-
 
5578
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
-
 
5579
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
-
 
5580
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
-
 
5581
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
-
 
5582
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
-
 
5583
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
-
 
5584
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
-
 
5585
		#必填參數:
-
 
5586
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
-
 
5587
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
-
 
5588
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
-
 
5589
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
-
 
5590
		#可省略參數:
-
 
5591
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
-
 
5592
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("input","formats");
-
 
5593
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null、any代表不指定變數形態.其中 resource也包含"resource (closed)".
-
 
5594
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","array");
-
 
5595
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
-
 
5596
		#$conf["canBeEmptyString"]="false";
-
 
5597
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
-
 
5598
		#$conf["canNotBeEmpty"]=array();
-
 
5599
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
-
 
5600
		#$conf["canBeEmpty"]=array();
-
 
5601
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
-
 
5602
		#$conf["skipableVariableCanNotBeEmpty"]=array();
-
 
5603
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
-
 
5604
		#$conf["skipableVariableName"]=array();
-
 
5605
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
-
 
5606
		#$conf["skipableVariableType"]=array();
-
 
5607
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
-
 
5608
		#$conf["skipableVarDefaultValue"]=array("");
-
 
5609
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
-
 
5610
		#$conf["disallowAllSkipableVarIsEmpty"]="";
-
 
5611
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
-
 
5612
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
-
 
5613
		#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
-
 
5614
		#$conf["disallowAllSkipableVarNotExist"]="";
-
 
5615
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
-
 
5616
		#$conf["arrayCountEqualCheck"][]=array();
-
 
5617
		#參考資料:
-
 
5618
		#array_keys=>http://php.net/manual/en/function.array-keys.php
-
 
5619
		#備註:
-
 
5620
		#無.
-
 
5621
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
-
 
5622
		unset($conf["variableCheck::checkArguments"]);
-
 
5623
	
-
 
5624
		#如果執行失敗
-
 
5625
		if($checkArguments["status"]==="false"){
-
 
5626
		
-
 
5627
			#設置錯誤訊息
-
 
5628
			$result["error"]=$checkArguments;
-
 
5629
		
-
 
5630
			#設置執行錯誤
-
 
5631
			$result["status"]="false";
-
 
5632
		
-
 
5633
			#回傳結果
-
 
5634
			return $result;
-
 
5635
		
-
 
5636
			}#if end
-
 
5637
	
-
 
5638
		#如果檢查不通過
-
 
5639
		if($checkArguments["passed"]==="false"){
-
 
5640
		
-
 
5641
			#設置錯誤訊息
-
 
5642
			$result["error"]=$checkArguments;
-
 
5643
		
-
 
5644
			#設置執行錯誤
-
 
5645
			$result["status"]="false";
-
 
5646
		
-
 
5647
			#回傳結果
-
 
5648
			return $result;
-
 
5649
		
-
 
5650
			}#if end
-
 
5651
			
-
 
5652
		#關鍵字行搜尋的索引預設數值為0
-
 
5653
		$keyWordLineIndex=0;
-
 
5654
	
-
 
5655
		#針對每行原始內容
-
 
5656
		for($oriLineContentIndex=0;$oriLineContentIndex<count($conf["input"]);$oriLineContentIndex++){
-
 
5657
		
-
 
5658
			#取得原始內容行
-
 
5659
			$oriLineContent=$conf["input"][$oriLineContentIndex];
-
 
5660
			
-
 
5661
			#預設調整後的原始內容跟原本一樣
-
 
5662
			$modifiedOriLineContent=$oriLineContent;
-
 
5663
		
-
 
5664
			#debug
-
 
5665
			#var_dump(__LINE__,$modifiedOriLineContent);
-
 
5666
			
-
 
5667
			#初始化儲存移除的開頭內容
-
 
5668
			$deletedOriHead="";
-
 
5669
		
-
 
5670
			#無窮迴圈
-
 
5671
			while(true){
-
 
5672
			
-
 
5673
				#嘗試移除開頭的 空格 跟 \t
-
 
5674
				
-
 
5675
				#函式說明:
-
 
5676
				#取得符合多個特定字首與字尾的字串
-
 
5677
				#回傳結果:
-
 
5678
				#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
-
 
5679
				#$result["function"],當前執行的函數名稱.
-
 
5680
				#$result["error"],錯誤訊息陣列.
-
 
5681
				#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
-
 
5682
				#$result["content"],符合條件的字串,去掉字首字尾後的結果.
-
 
5683
				#$result["returnString"],爲符合字首字、尾條件的字串內容.
-
 
5684
				#$result["meetConditions"],為符合的條件,會是$conf["keyWord"]中的其中一個元素.
-
 
5685
				#$result["argu"],使用的參數.
-
 
5686
				#必填參數:
-
 
5687
				#$conf["checkString"],字串,要檢查的字串.
-
 
5688
				$conf["search::getMeetMultiConditionsString"]["checkString"]=$modifiedOriLineContent;
-
 
5689
				#$conf["keyWord"],字串陣列,用來檢查字首、字尾應該要有哪些字串之一,每個元素代表一個可能的條件,key為front者代表開頭的關鍵字,key為tail為代表結尾的官關鍵字.
-
 
5690
				$conf["search::getMeetMultiConditionsString"]["keyWord"]=array(array("front"=>" "),array("front"=>"\t"));
-
 
5691
				#可省略參數:
-
 
5692
				#無.
-
 
5693
				#參考資料:
-
 
5694
				#無.
-
 
5695
				#備註:
-
 
5696
				#無.
-
 
5697
				$getMeetMultiConditionsString=search::getMeetMultiConditionsString($conf["search::getMeetMultiConditionsString"]);
-
 
5698
				unset($conf["search::getMeetMultiConditionsString"]);
-
 
5699
				
-
 
5700
				#debug
-
 
5701
				#var_dump(__LINE__,$getMeetMultiConditionsString);
-
 
5702
				
-
 
5703
				#如果執行失敗
-
 
5704
				if($getMeetMultiConditionsString["status"]==="false"){
-
 
5705
				
-
 
5706
					#設置錯誤識別
-
 
5707
					$result["status"]="false";
-
 
5708
					
-
 
5709
					#設置錯誤訊息
-
 
5710
					$result["error"]=$getMeetMultiConditionsString;
-
 
5711
					
-
 
5712
					#回傳結果
-
 
5713
					return $result;
-
 
5714
				
-
 
5715
					}#if end
-
 
5716
					
-
 
5717
				#如果有關鍵字存在
-
 
5718
				if($getMeetMultiConditionsString["founded"]==="true"){
-
 
5719
				
-
 
5720
					#取得已經移開頭空格跟\t後的內容
-
 
5721
					$modifiedOriLineContent=$getMeetMultiConditionsString["content"];
-
 
5722
				
-
 
5723
					#另存符合且剔除的內容
-
 
5724
					$meetConditions=$getMeetMultiConditionsString["meetConditions"]["front"];
-
 
5725
				
-
 
5726
					#串接開頭剔除的內容
-
 
5727
					$deletedOriHead=$deletedOriHead.$meetConditions;
-
 
5728
				
-
 
5729
					#繼續檢查
-
 
5730
					continue;
-
 
5731
				
-
 
5732
					}#if end
-
 
5733
				
-
 
5734
				#到這表代表已經移除開頭的 空格 跟 \t
-
 
5735
				
-
 
5736
				#結束 while
-
 
5737
				break;
-
 
5738
			
-
 
5739
				}#while end
-
 
5740
				
-
 
5741
			#debug
-
 
5742
			#var_dump(__LINE__,$modifiedOriLineContent);
-
 
5743
				
-
 
5744
			#取得關鍵字行的內容
-
 
5745
			$keyWordLine=$conf["formats"][$keyWordLineIndex];
-
 
5746
			
-
 
5747
			#調整過的關鍵字內容行預設跟原始關鍵行內容一樣
-
 
5748
			$modifiedKeyWordLine=$keyWordLine;
-
 
5749
			
-
 
5750
			#初始化關鍵字前面的內容(可能有為多個空格或tab)
-
 
5751
			$keyWordContentOfHead="";
-
 
5752
			
-
 
5753
			#無窮迴圈
-
 
5754
			while(true){
-
 
5755
			
-
 
5756
				#嘗試剔除開頭的 空格 跟 "\t"
-
 
5757
			
-
 
5758
				#函式說明:
-
 
5759
				#取得符合多個特定字首與字尾的字串
-
 
5760
				#回傳結果:
-
 
5761
				#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
-
 
5762
				#$result["function"],當前執行的函數名稱.
-
 
5763
				#$result["error"],錯誤訊息陣列.
-
 
5764
				#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
-
 
5765
				#$result["content"],符合條件的字串,去掉字首字尾後的結果.
-
 
5766
				#$result["returnString"],爲符合字首字、尾條件的字串內容.
-
 
5767
				#$result["meetConditions"],為符合的條件,會是$conf["keyWord"]中的其中一個元素.
-
 
5768
				#$result["argu"],使用的參數.
-
 
5769
				#必填參數:
-
 
5770
				#$conf["checkString"],字串,要檢查的字串.
-
 
5771
				$conf["search::getMeetMultiConditionsString"]["checkString"]=$modifiedKeyWordLine;
-
 
5772
				#$conf["keyWord"],字串陣列,用來檢查字首、字尾應該要有哪些字串之一,每個元素代表一個可能的條件,key為front者代表開頭的關鍵字,key為tail為代表結尾的官關鍵字.
-
 
5773
				$conf["search::getMeetMultiConditionsString"]["keyWord"]=array(array("front"=>" "),array("front"=>"\t"));
-
 
5774
				#可省略參數:
-
 
5775
				#無.
-
 
5776
				#參考資料:
-
 
5777
				#無.
-
 
5778
				#備註:
-
 
5779
				#無.
-
 
5780
				$getMeetMultiConditionsString=search::getMeetMultiConditionsString($conf["search::getMeetMultiConditionsString"]);
-
 
5781
				unset($conf["search::getMeetMultiConditionsString"]);
-
 
5782
				
-
 
5783
				#debug
-
 
5784
				#var_dump(__LINE__,$getMeetMultiConditionsString);
-
 
5785
				
-
 
5786
				#如果執行失敗
-
 
5787
				if($getMeetMultiConditionsString["status"]==="false"){
-
 
5788
				
-
 
5789
					#設置錯誤識別
-
 
5790
					$result["status"]="false";
-
 
5791
					
-
 
5792
					#設置錯誤訊息
-
 
5793
					$result["error"]=$getMeetMultiConditionsString;
-
 
5794
					
-
 
5795
					#回傳結果
-
 
5796
					return $result;
-
 
5797
				
-
 
5798
					}#if end
-
 
5799
					
-
 
5800
				#如果有關鍵字存在
-
 
5801
				if($getMeetMultiConditionsString["founded"]==="true"){
-
 
5802
				
-
 
5803
					#取得移除開頭 空格 跟 \t 後的內容
-
 
5804
					$modifiedKeyWordLine=$getMeetMultiConditionsString["content"];
-
 
5805
					
-
 
5806
					#取得關鍵字前面的內容
-
 
5807
					$keyWordContentOfHead=substr($keyWordLine,0,strlen($keyWordLine)-strlen($modifiedKeyWordLine));
-
 
5808
					
-
 
5809
					#繼續檢查
-
 
5810
					continue;
-
 
5811
					
-
 
5812
					}#if end
-
 
5813
				
-
 
5814
				#到這表代表已經移除開頭的 空格 跟 \t
-
 
5815
			
-
 
5816
				#解析關鍵字字串
-
 
5817
				#函式說明:
-
 
5818
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
5819
				#回傳結果:
-
 
5820
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
5821
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
5822
				#$result["function"],當前執行的函式名稱.
-
 
5823
				#$result["argu"],所使用的參數.
-
 
5824
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
5825
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
5826
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
5827
				#必填參數:
-
 
5828
				#$conf["input"],字串,要檢查的字串.
-
 
5829
				$conf["search::findSpecifyStrFormat"]["input"]=$modifiedOriLineContent;
-
 
5830
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
5831
				$conf["search::findSpecifyStrFormat"]["format"]=$modifiedKeyWordLine;
-
 
5832
				#可省略參數:
-
 
5833
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
5834
				#$conf["varEqual"]=array(null,"found");
-
 
5835
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
5836
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
5837
				#參考資料:
-
 
5838
				#無.
-
 
5839
				#備註:
-
 
5840
				#無.
-
 
5841
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
5842
				unset($conf["search::findSpecifyStrFormat"]);
-
 
5843
			
-
 
5844
				#debug
-
 
5845
				#var_dump(__LINE__,$findSpecifyStrFormat);
-
 
5846
			
-
 
5847
				#如果執行異常
-
 
5848
				if($findSpecifyStrFormat["status"]==="false"){
-
 
5849
				
-
 
5850
					#設置錯誤識別
-
 
5851
					$result["status"]="false";
-
 
5852
					
-
 
5853
					#設置錯誤訊息
-
 
5854
					$result["error"]=$findSpecifyStrFormat;
-
 
5855
					
-
 
5856
					#回傳結果
-
 
5857
					return $result;
-
 
5858
					
-
 
5859
					}#if end
-
 
5860
					
-
 
5861
				#如果沒有找到符合的格式
-
 
5862
				if($findSpecifyStrFormat["found"]==="false"){
-
 
5863
				
-
 
5864
					#重新尋找第一個關鍵字串
-
 
5865
					$keyWordLineIndex=0;
-
 
5866
					
-
 
5867
					}#if end
-
 
5868
				
-
 
5869
				#反之有找到符合的格式
-
 
5870
				else if($findSpecifyStrFormat["found"]==="true"){
-
 
5871
					
-
 
5872
					#$result["content"][$i]["lineS"],字串,為第 $i+1 個符合格式的段落起始行數.
-
 
5873
					#$result["content"][$i]["ori"],陣列,為第 $i+1 個符合格式的段落每行原始內容資訊.
-
 
5874
					#$result["content"][$i]["ori"][$j]=array("index"=>$oriLineIndex,"value"=>$oriLineContent),代表第 $i+1 個符合格式的段落中第 $j+1 個原始內容對應的行數($oriLineIndex+1),其原始內容為 $oriLineContent.
-
 
5875
					#$result["content"][$i]["new"],陣列,為第 $i+1 個符合格式的段落每行關鍵字內容.
-
 
5876
					#$result["content"][$i]["vars"],陣列,為第 $i+1 個符合格式的段落每行變數解析的結果.
-
 
5877
					
-
 
5878
					#如果第一個關鍵字串有符合
-
 
5879
					if($keyWordLineIndex===0){
-
 
5880
					
-
 
5881
						#初始化暫存符合的行數資訊
-
 
5882
						$matchInfo=array();
-
 
5883
						
-
 
5884
						#記錄符合的行數
-
 
5885
						$matchInfo["lineS"]=$oriLineContentIndex;
-
 
5886
					
-
 
5887
						}#if end
-
 
5888
					
-
 
5889
					#記錄符合的原始字串行
-
 
5890
					$matchInfo["ori"][]=array("index"=>$oriLineContentIndex,"value"=>$modifiedOriLineContent,"deletedHead"=>$deletedOriHead);
-
 
5891
					
-
 
5892
					#記錄符合的關鍵字字串行
-
 
5893
					$matchInfo["new"][]=$modifiedKeyWordLine;
-
 
5894
					
-
 
5895
					#記錄解析出來的變數結果
-
 
5896
					$matchInfo["vars"][]=$findSpecifyStrFormat["parsedVar"];
-
 
5897
					
-
 
5898
					#如果後面還有關鍵字串
-
 
5899
					if(isset($conf["formats"][$keyWordLineIndex+1])){
-
 
5900
					
-
 
5901
						#看下一個要判斷的關鍵字串
-
 
5902
						$keyWordLineIndex++;
-
 
5903
					
-
 
5904
						}#if end
-
 
5905
					
-
 
5906
					#反之
-
 
5907
					else{
-
 
5908
					
-
 
5909
						#記錄符合的結果資訊
-
 
5910
						$result["content"][]=$matchInfo;
-
 
5911
					
-
 
5912
						#下次要再從第一個關鍵字字串看起
-
 
5913
						$keyWordLineIndex=0;
-
 
5914
					
-
 
5915
						}#else end
-
 
5916
				
-
 
5917
					}#else end
-
 
5918
					
-
 
5919
				#不應該執行到這邊
-
 
5920
				else{
-
 
5921
				
-
 
5922
					#設置錯誤識別
-
 
5923
					$result["status"]="false";
-
 
5924
					
-
 
5925
					#設置錯誤訊息
-
 
5926
					$result["error"][]="unexpected error";
-
 
5927
					
-
 
5928
					#設置錯誤訊息
-
 
5929
					$result["error"][]=$findSpecifyStrFormat;
-
 
5930
					
-
 
5931
					#回傳結果
-
 
5932
					return $result;
-
 
5933
				
-
 
5934
					}#else end
-
 
5935
				
-
 
5936
				#結束 while
-
 
5937
				break;
-
 
5938
				
-
 
5939
				}#while end
-
 
5940
		
-
 
5941
			}#for end
-
 
5942
		
-
 
5943
		#預設沒有找到符合的字串區段
-
 
5944
		$result["found"]="false";
-
 
5945
	
-
 
5946
		#如果有比對到的結果
-
 
5947
		if(!empty($result["content"])){
-
 
5948
		
-
 
5949
			#設置有找到符合的字串區段
-
 
5950
			$result["found"]="true";
-
 
5951
		
-
 
5952
			}#if end
-
 
5953
 
-
 
5954
		#設置執行正常
-
 
5955
		$result["status"]="true";
-
 
5956
 
-
 
5957
		#回傳結果
-
 
5958
		return $result;
-
 
5959
 
-
 
5960
		}#function findConMatchStrs end
-
 
5961
	
-
 
5962
	/*
5466
	#函式說明:
5963
	#函式說明:
5467
	#尋找字串中是否含有符合多個格式之一的內容,且回傳解析好的變數數值.
5964
	#尋找字串中是否含有符合多個格式之一的內容,且回傳解析好的變數數值.
5468
	#回傳結果:
5965
	#回傳結果:
5469
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5966
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5470
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
5967
	#$reuslt["error"],執行不正常結束的錯訊息陣列.