protected function actionEdit()
    {
        $mm = new MessageModel($_GET['id'], $this->dao);
        $row = $this->dao->messageById($_GET['id']);
        $tm = new TemplateModel($this->dao->templateBody($row['template']));
        $ref = Reference::decode(stripslashes($_GET['field']));
        $area = ContentAreaBase::createContentArea($tm->namedNode($ref->name));
        $result = $area->display($ref, $mm->messageAreas());
        $html = <<<END
<html>
<body>{$result}</body>
</html>
END;
        ob_end_clean();
        echo $html;
        exit;
    }
Ejemplo n.º 2
0
 /**
  * Merge all the content areas at a specific level.
  *
  * @param DOMNodeList $nodes          content area nodes
  * @param array       $areas          the content area values for the current level
  * @param bool        $edit           whether the merge should include edit buttons
  * @param string|null $repeatName     name of repeatable or hideable area
  * @param int|null    $repeatInstance the repeat or hideable instance
  */
 private function mergeNodesAtLevel(DOMNodeList $nodes, array $areas, $edit, $repeatName = null, $repeatInstance = null)
 {
     ++$this->depth;
     foreach ($nodes as $node) {
         $area = ContentAreaBase::createContentArea($node);
         $area->edit = $edit;
         if ($repeatName) {
             $area->reference = new Reference($repeatName, $repeatInstance, $area->name);
         }
         if (isset($areas[$area->name])) {
             $area->merge($areas[$area->name], $this);
         } else {
             $area->merge(null, $this);
         }
     }
     --$this->depth;
 }
    /**
     * @test
     */
    public function createsRepeatContentArea()
    {
        $html = <<<'END'
<html>
    <body>
        <div data-repeatable="repeat1">
            <div data-edit="article" data-type="textarea"></div>
        </div>
    </body>
</html>
END;
        $tm = new TemplateModel();
        $tm->loadHtml($html);
        $node = $tm->namedNode('repeat1');
        $area = ContentAreaBase::createContentArea($node);
        $this->assertInstanceOf('phpList\\plugin\\ContentAreas\\ContentAreaRepeat', $area);
        $this->assertEquals('repeat1', $area->name);
        $this->assertEquals('repeat1', $area->reference);
    }