Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions core/components/com_courses/models/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,26 +237,32 @@ public function eachPage($fun, $version=null)
}
}

// Sort
// Sort (reindexed, since natsort keeps the scandir keys)
natsort($versions);
$versions = array_values($versions);

// If there's a dir for the given version, just use that
if (in_array($version, $versions))
{
$base = $this->base . $this->id . DS . $version;
$version_dir = $version;
}
else // Otherwise, see if there's a version dir for a previous version
{
for ($i=0; $i < count($versions); $i++)
foreach ($versions as $v)
{
if ($versions[$i] < $version)
if ($v < $version)
{
$version_dir = $versions[$i];
$version_dir = $v;
}
}
}

// Count the page images in the same dir the image URLs point at
if (isset($version_dir))
{
$base = $this->base . $this->id . DS . $version_dir;
}

$dir = opendir($base);
$images = array();

Expand Down
Loading