Permalink
Browse files

Allow content to be passed directly into Page

  • Loading branch information...
1 parent 373b316 commit 3bd5e02704180311ad0d686fcc486211d949d2cb @kolber committed May 29, 2012
Showing with 13 additions and 12 deletions.
  1. +2 −3 app/asset-types/page.inc.php
  2. +11 −9 app/page-data.inc.php
@@ -10,17 +10,16 @@
var $data;
var $all_pages;
- function __construct($url) {
+ function __construct($url, $content = false) {
# store url and converted file path
$this->file_path = Helpers::url_to_file_path($url);
$this->url_path = $url;
$this->template_name = self::template_name($this->file_path);
$this->template_file = self::template_file($this->template_name);
$this->template_type = self::template_type($this->template_file);
-
# create/set all content variables
- PageData::create($this);
+ PageData::create($this, $content);
}
function clean_json($data) {
View
@@ -193,17 +193,19 @@ static function get_shared_data() {
$shared_file_path = file_exists(Config::$content_folder.'/_shared.yml') ? Config::$content_folder.'/_shared.yml' : Config::$content_folder.'/_shared.txt';
if (file_exists($shared_file_path)) {
return self::$shared = sfYaml::load($shared_file_path);
- } else {
- return array();
}
}
- static function create_textfile_vars($page) {
+ static function create_textfile_vars($page, $content = false) {
# store contents of content file (if it exists, otherwise, pass back an empty string)
- $content_file = sprintf('%s/%s', $page->file_path, $page->template_name);
- $content_file_path = file_exists($content_file.'.yml') ? $content_file.'.yml' : $content_file.'.txt' ;
- if (!file_exists($content_file_path)) return;
- $vars = sfYaml::load($content_file_path);
+ if ($content) {
+ $vars = sfYaml::load($content);
+ } else {
+ $content_file = sprintf('%s/%s', $page->file_path, $page->template_name);
+ $content_file_path = file_exists($content_file.'.yml') ? $content_file.'.yml' : $content_file.'.txt' ;
+ if (!file_exists($content_file_path)) return;
+ $vars = sfYaml::load($content_file_path);
+ }
# include shared variables for each page
$vars = array_merge(self::get_shared_data(), $vars ? $vars : array());
@@ -248,9 +250,9 @@ static function clean_json($value) {
return addslashes($value);
}
- static function create($page) {
+ static function create($page, $content = false) {
# set vars created within the text file
- self::create_textfile_vars($page);
+ self::create_textfile_vars($page, $content);
# create each of the page-specfic helper variables
self::create_collections($page);
self::create_vars($page);

0 comments on commit 3bd5e02

Please sign in to comment.