set up layout information

This commit is contained in:
John Bintz 2009-07-23 17:13:53 -04:00
parent 7f4188929c
commit fbec175cb8
2 changed files with 22 additions and 7 deletions

View File

@ -24,6 +24,7 @@ class ComicPress {
var $category_tree = array();
var $partial_paths = array();
var $layouts = null;
/**
* Load ComicPress options.
@ -360,14 +361,24 @@ class ComicPress {
function _file_get_contents($file) { return file_get_contents($file); }
function get_layout_choices() {
$layouts = array();
foreach ($this->_glob(get_template_directory() . '/layouts/*') as $file) {
$content = $this->_file_get_contents($file);
if (preg_match('#/\*.*Layout Name: ([^\n]+).*\*/#s', $content, $matches) > 0) {
$layouts[pathinfo($file, PATHINFO_BASENAME)] = $matches[1];
if (!is_array($this->layouts)) {
$this->layouts = array();
foreach ($this->_glob(get_template_directory() . '/layouts/*') as $file) {
$content = $this->_file_get_contents($file);
$basename = pathinfo($file, PATHINFO_BASENAME);
foreach (array(
"Layout Name", "Sidebars"
) as $field) {
if (preg_match('#/\*.*' . $field . ': ([^\n]+).*\*/#s', $content, $matches) > 0) {
if (!is_array($this->layouts[$basename])) {
$this->layouts[$basename] = array();
}
$this->layouts[$basename][$field] = $matches[1];
}
}
}
}
return $layouts;
return $this->layouts;
}
}

View File

@ -192,10 +192,14 @@ FILE
'layout.php' => <<<FILE
/*
Layout Name: Test
Sidebars: left,right
*/
FILE
),
array('layout.php' => 'Test')
array('layout.php' => array(
'Layout Name' => 'Test',
'Sidebars' => 'left,right',
))
),
);
}