Skip to content

Instantly share code, notes, and snippets.

@danieljpeter
Created May 3, 2012 23:50
Show Gist options
  • Save danieljpeter/2590508 to your computer and use it in GitHub Desktop.
Save danieljpeter/2590508 to your computer and use it in GitHub Desktop.
parse Ant listMetadata
$arrCustomField = filerToStandardObjects(parseLog("/home/dpeter/sf/lists/CustomField.log"));
$arrBusinessProcess = parseLog("/home/dpeter/sf/lists/BusinessProcess.log");
$arrRecordType = parseLog("/home/dpeter/sf/lists/RecordType.log");
$arrWebLink = parseLog("/home/dpeter/sf/lists/WebLink.log");
$arrValidationRule = parseLog("/home/dpeter/sf/lists/ValidationRule.log");
$arrNamedFilter = parseLog("/home/dpeter/sf/lists/NamedFilter.log");
$arrSharingReason = parseLog("/home/dpeter/sf/lists/SharingReason.log");
$arrListView = parseLog("/home/dpeter/sf/lists/ListView.log");
$arrFieldSet = parseLog("/home/dpeter/sf/lists/FieldSet.log");
//======================================
function parseLog($fileName) {
$arrFields = array();
$myFile = $fileName;
if (file_exists($myFile)) {
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
//read the file into an array of lines
$arrLines = explode("\n", $theData);
//loop through the lines and get the ones that start with "FullName/Id:"
//lines look like this: FullName/Id: Case.Queue_Feedback/00B000000095c8IEAQ
foreach ($arrLines as $arrLine) {
if (strpos($arrLine, "FullName/Id:") !== false) {
//parse out just the objectName.ListView, FieldName, etc from the string
$arrTemp = explode("FullName/Id:", $arrLine, 2);
if (count($arrTemp) == 2) {
$arrTemp = explode("/", $arrTemp[1], 2);
if (count($arrTemp) == 2) {
array_push($arrFields, trim($arrTemp[0]));
}
}
}
}
}
sort($arrFields);
return $arrFields;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment