Login   Register  
PHP Classes
elePHPant
Icontem

File: exampleSearchCustomFunctions.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Cinu Chacko  >  Class Grep Search  >  exampleSearchCustomFunctions.php  >  Download  
File: exampleSearchCustomFunctions.php
Role: Auxiliary script
Content type: text/plain
Description: Customizable Functions used with the Search.
Class: Class Grep Search
Search files in directories like grep
Author: By
Last change:
Date: 2008-08-19 05:27
Size: 1,248 bytes
 

Contents

Class file image Download
<?php
require_once('ClassGrepSearch.inc.php');

/**
 *
 * function to retrieve text lines from file
 *  highlighting the search string
 *
 * @param $filePath string
 * @param $classGrepSearch class Instance
 *
 */  

function createLinesFromFile($filePath,$classGrepSearch)
{

    
$linesArray file($filePath); 
    
$htmlLines="";
    
$classGrepSearch->setGlobalCount(0);
    
$newLine "";
    for(
$i=0;$i<count($linesArray);$i++) 
    {
        
$newLine $classGrepSearch->allStrReplaceTag($linesArray[$i],"<b><font color='green'>","</font></b>" )."<br>";
        if(
$classGrepSearch->getGlobalResult())
        {
            
$htmlLines=$htmlLines."line no:".$i.":".$newLine
        } 
    } 
    
$globalSearchCount $classGrepSearch->getGlobalCount(); 
    return     
$htmlLines
}




/**
*
* function to return the Chapter Names
*  from start and end index
*
* @param $startSpan string
* @param $endSpan string
*
*    return array
*/  
function getBookNames($startSpan,$endSpan)
{
    
$Book = array();
    
$Book[1]="Chapter_1_3";
    
$Book[2]="Chapter_4_6";
    
$Book[3]="Chapter_7_9";
    
$Book[4]="Chapter_10_12"
    
$resultArray=array();
    for(
$i=$startSpan;$i<=$endSpan;$i++)
    {
        
array_push($resultArray,$Book[$i]);
    }

    return 
$resultArray;

}



?>