Skip to content

Commit

Permalink
Converted the _readTemplate() to a public function to fix multiple ga…
Browse files Browse the repository at this point in the history
…llery implimentations
  • Loading branch information
PHLAK committed Jan 5, 2013
1 parent 306eb9c commit a5ded88
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions resources/UberGallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class UberGallery {

// Define application version
const VERSION = '2.4.2';
const VERSION = '2.4.3';

// Reserve some variables
protected $_config = array();
Expand Down Expand Up @@ -159,7 +159,7 @@ public function createGallery($directory, $relText = 'colorbox') {
$galleryArray['relText'] = $relText;

// Echo the template contents
echo $this->_readTemplate($templatePath, $galleryArray);
echo $this->readTemplate($templatePath, $galleryArray);

return $this;

Expand Down Expand Up @@ -219,6 +219,34 @@ public function readImageDirectory($directory) {
}


/**
* Returns a template string with custom data injected into it
*
* @param string $templatePath Path to template file
* @param array $data Array of data to be injected into the template
* @return string Processed template string
* @access private
*/
public function readTemplate($templatePath, $data) {

// Extract array to variables
extract($data);

// Start the output buffer
ob_start();

// Include the template
include $templatePath;

// Set buffer output to a variable
$output = ob_get_clean();

// Return the output
return $output;

}


/**
* Returns the theme name
*
Expand Down Expand Up @@ -301,7 +329,7 @@ public function getColorboxScripts() {
$colorboxPath = $this->_getRelativePath(getcwd(), $this->_appDir) . '/colorbox/jquery.colorbox.js';

// Get the template contents
$template = $this->_readTemplate($templatePath, array('path' => $colorboxPath));
$template = $this->readTemplate($templatePath, array('path' => $colorboxPath));

// Return the include text
return $template;
Expand Down Expand Up @@ -561,34 +589,6 @@ private function _readDirectory($directory, $paginate = true) {
return $dirArray;
}


/**
* Returns a template string with custom data injected into it
*
* @param string $templatePath Path to template file
* @param array $data Array of data to be injected into the template
* @return string Processed template string
* @access private
*/
private function _readTemplate($templatePath, $data) {

// Extract array to variables
extract($data);

// Start the output buffer
ob_start();

// Include the template
include $templatePath;

// Set buffer output to a variable
$output = ob_get_clean();

// Return the output
return $output;

}


/**
* Creates a cropped, square thumbnail of given dimensions from a source image
Expand Down

0 comments on commit a5ded88

Please sign in to comment.