OREGON STATE UNIVERSITY

Video Archive Page

<p>Note: All videos will open in a new page/tab.</p>
<br />

<?php
$filepath = "sites/default/files/video_list.xml";

if (file_exists($filepath))
{
$xml = new DomDocument('1.0');
$xml->load($filepath);
$videos = $xml->getElementsByTagName('video');

$videoArray = Array();
$id_index = 0;
$html = "";

//Iterates through XML and puts elements into 2D array for formatting purposes if need be
//Static coding is probably not the best way to iterate through element index...
foreach ($videos as $video)
{
$element_index = 0;

$id = $video->getElementsByTagName('id')->item(0)->firstChild->nodeValue;
$title = $video->getElementsByTagName('title')->item(0)->firstChild->nodeValue;
$desc = $video->getElementsByTagName('desc')->item(0)->firstChild->nodeValue;

$videoArray[$id_index][$element_index] = $id;
$videoArray[$id_index][$element_index + 1] = $title;
$videoArray[$id_index][$element_index + 2] = $desc;

$id_index++;

//original scale: 160 x 120

}

//print_r($videoArray);

//loop to populate a table with 2 columns and a dynamic row
$html .= "<table>";
$index = 0;
//loops through and creats however many rows based on array size, assuming we only want two column per row
for ($x = 0; $x < ceil(sizeof($videoArray))/2; $x++)
{
$id1 = $videoArray[$index][0];
$title1 = $videoArray[$index][1];

$id2 = $videoArray[$index+1][0];
$title2 = $videoArray[$index+1][1];

$html .= "
<tr>
<td>
<a href='http://media.oregonstate.edu/index.php/show/?id=$id1' target='_blank'><img src='http://cdnbakmi.kaltura.com/p/391241/sp/39124100/thumbnail/entry_id/$id1/version/100002/width/200/height/150/bgcolor/000000/type/2'></a><br />
$title1
</td>
<td>
<a href='http://media.oregonstate.edu/index.php/show/?id=$id2' target='_blank'><img src='http://cdnbakmi.kaltura.com/p/391241/sp/39124100/thumbnail/entry_id/$id2/version/100002/width/200/height/150/bgcolor/000000/type/2'></a><br />
$title2
</td>
</tr>
";

$index += 2;
}

$html .= "</table>";

echo $html;

//print_r($videoArray);

}
else
{
echo "File does not exist <br />";
}
?>