Skip to content

Commit

Permalink
Created a consistent use of a $replacements array within all the part…
Browse files Browse the repository at this point in the history
…ials
  • Loading branch information
kolber committed Nov 8, 2009
1 parent 8160ac7 commit fd919c8
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions app/stacey.inc.php
Expand Up @@ -599,15 +599,15 @@ static function parse_loop($page, $dir, $loop_html) {
$html = '';
foreach($files as $key => $file) {
// for each page within this category...
$vars = array(
$replacements = array(
'/@url/' => $path.'/'.preg_replace('/^\d+?\./', '', $file).'/',
'/@thumb/' => $page->link_path.'content/'.self::check_thumb($dir, $file)
);
// create a MockPageInCategory to give us access to all the variables inside this PageInCategory
$c = new ContentParser;
$category_page = new MockPageInCategory(preg_replace('/\.\.\/content\//', '', $dir), $file);
$vars = array_merge($vars, $c->parse($category_page));
$html .= preg_replace(array_keys($vars), array_values($vars), $loop_html);
$vars = array_merge($replacements, $c->parse($category_page));
$html .= preg_replace(array_keys($replacements), array_values($replacements), $loop_html);
}

return $html;
Expand Down Expand Up @@ -699,17 +699,15 @@ static function parse_loop($page, $dir, $loop_html) {
// pull dimensions from file name (if they exist)
if(preg_match('/(\d+?)x(\d+?)\./', $file, $matches)) $dimensions = array('width' => $matches[1], 'height' => $matches[2]);
else $dimensions = array('width' => '', 'height' => '');
$html .= preg_replace(array(
'/@url/',
'/@width/',
'/@height/'
), array(
$dir.'/'.$file,
$dimensions['width'],
$dimensions['height']
), $loop_html);
}

$replacements = array(
'/@url/' => $dir.'/'.$file,
'/@width/' => $dimensions['width'],
'/@height/' => $dimensions['height']
);

$html .= preg_replace(array_keys($replacements), array_values($replacements), $loop_html);
}
return $html;
}

Expand All @@ -727,15 +725,13 @@ static function parse_loop($page, $dir, $loop_html) {
// pull dimensions from file name (if they exist)
if(preg_match('/(\d+?)x(\d+?)\./', $file, $matches)) $dimensions = array('width' => $matches[1], 'height' => $matches[2]);
else $dimensions = array('width' => '', 'height' => '');
$html .= preg_replace(array(
'/@url/',
'/@width/',
'/@height/'
), array(
$dir.'/'.$file,
$dimensions['width'],
$dimensions['height']
), $loop_html);
$replacements = array(
'/@url/' => $dir.'/'.$file,
'/@width/' => $dimensions['width'],
'/@height/' => $dimensions['height']
);

$html .= preg_replace(array_keys($replacements), array_values($replacements), $loop_html);
}
return $html;
}
Expand Down

0 comments on commit fd919c8

Please sign in to comment.