mView = 'Search'; } /** * parse * @param $mixed * @return $obj A MetaDataBean instance **/ function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) { $contents = file_get_contents($filePath); $contents = $this->trimHTML($contents); // Get the second table in the page and onward $tables = $this->getElementsByType("table", $contents); //basic search table $basicSection = $this->processSection("basic", $tables[0], $filePath, $vardefs); $advancedSection = $this->processSection("advanced", $tables[1], $filePath, $vardefs); if(file_exists($masterCopy)) { require($masterCopy); $layouts = $searchdefs[$moduleDir]['layout']; if(isset($layouts['basic_search'])) { $basicSection = $this->mergeSection($basicSection, $layouts['basic_search']); $basicSection = $this->applyRules($moduleDir, $basicSection); } if(isset($layouts['advanced_search'])) { $advancedSection = $this->mergeSection($advancedSection, $layouts['advanced_search']); $advancedSection = $this->applyRules($moduleDir, $advancedSection); } } //if $header = " array('maxColumns' => '3', 'widths' => array('label' => '10', 'field' => '30')), 'layout' => array( \n\t'basic_search' =>"; $header .= "\t" . var_export($basicSection, true); $header .= "\n\t,'advanced_search' =>"; $header .= "\t" . var_export($advancedSection, true); $header .= " ),\n ); ?>"; $header = preg_replace('/(\d+)[\s]=>[\s]?/',"",$header); return $header; } function mergeSection($section, $masterSection) { // Get all the names in the panel $existingElements = array(); $existingLocation = array(); foreach($section as $rowKey=>$row) { if(is_array($row) && !empty($row['name'])) { $existingElements[$row['name']] = $row['name']; $existingLocation[$row['name']] = array("row"=>$rowKey); } else if(!is_array($row) && !empty($row)) { $existingElements[$row] = $row; $existingLocation[$row] = array("row"=>$rowKey); } } //foreach // Now check against the $masterCopy foreach($masterSection as $row) { $addEntry = ''; $id = is_array($row) ? $row['name'] : $row; /* if(!isset($existingElements[$id])) { //$addEntry = $row; } */ if(isset($existingElements[$id])) { //Use master copy instead $section[$existingLocation[$id]['row']] = $row; } // Add it to the $panels /* if(!empty($addEntry)) { $section[] = $addEntry; } */ } //foreach return $section; } function processSection($section, $table, $filePath, $vardefs=array()) { $toptr = $this->getElementsByType("tr", $table); if(!is_array($toptr) || empty($toptr)) { $GLOBALS['log']->error("Could not process top row (