Skip to content

Commit

Permalink
FieldsPlugin - .sectionFields for subpages + .fields for single page
Browse files Browse the repository at this point in the history
BC BREAK SOLUTION: rename all .fields to .sectionFields
  • Loading branch information
zbycz committed May 23, 2013
1 parent f1f0995 commit e1cb03c
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions libs/npress/plugins/FieldsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class FieldsPlugin extends Control{

private $page;
private $fields = array();
private $error = "";

public function __construct(){
parent::__construct();
Expand All @@ -40,13 +41,28 @@ protected function attached($presenter){
$this->template->setTranslator(new TranslationsModel($presenter->lang));

//parse fields
$json = $this->page->getParent()->getMeta('.fields');
$json = $this->page->getParent()->getMeta('.sectionFields');
$sectionFields = array();
try {
if($json)
$fields = Neon::decode($json);
} catch (Exception $e){
$m = htmlspecialchars($e->getMessage());
$this->error .= "<div class='control-group' title=\"$m\">.sectionFields not valid</div>";
}

$fields = array();
$json = $this->page->getMeta('.fields');
try {
if($json)
$fields = Neon::decode($json);
} catch (Exception $e){}
} catch (Exception $e){
$m = htmlspecialchars($e->getMessage()."\"");
$this->error .= "<div class='control-group' title=\"$m\">.fields not valid</div>";
}


$fields = array_merge($fields, $sectionFields);
foreach($fields as $k=>$f){
if(substr($k,-1) == '_') $k .= $this->page->lang;
$this->fields[$k] = $f;
Expand Down Expand Up @@ -75,8 +91,9 @@ function filterPageEditForm_defaults(AppForm $form){

return $form;
}

function filterPageEditForm_render(AppForm $_form){
echo $this->error;
foreach($this->fields as $k=>$v){
?>
<div class="control-group">
Expand Down

0 comments on commit e1cb03c

Please sign in to comment.