diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-03-10 18:41:23 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-03-18 19:13:48 +0100 |
commit | 1c2fdb98b1c7fbd85aa086641dd47bc9bd03c8eb (patch) | |
tree | 88ff7dc0f0fd12e20324cca5bce53c3d12b3fa2b /index.php | |
parent | 890afc32f744859d11b97eb26ed5c030af9b4145 (diff) | |
download | Shaarli-1c2fdb98b1c7fbd85aa086641dd47bc9bd03c8eb.tar.gz Shaarli-1c2fdb98b1c7fbd85aa086641dd47bc9bd03c8eb.tar.zst Shaarli-1c2fdb98b1c7fbd85aa086641dd47bc9bd03c8eb.zip |
Add method assignAll() to pageBuilder to assign an array of data
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -637,6 +637,29 @@ class pageBuilder | |||
637 | $this->tpl->assign($what,$where); | 637 | $this->tpl->assign($what,$where); |
638 | } | 638 | } |
639 | 639 | ||
640 | /** | ||
641 | * Assign an array of data to the template builder. | ||
642 | * | ||
643 | * @param array $data Data to assign. | ||
644 | * | ||
645 | * @return false if invalid data. | ||
646 | */ | ||
647 | public function assignAll($data) | ||
648 | { | ||
649 | // Lazy initialization | ||
650 | if ($this->tpl === false) { | ||
651 | $this->initialize(); | ||
652 | } | ||
653 | |||
654 | if (empty($data) || !is_array($data)){ | ||
655 | return false; | ||
656 | } | ||
657 | |||
658 | foreach ($data as $key => $value) { | ||
659 | $this->assign($key, $value); | ||
660 | } | ||
661 | } | ||
662 | |||
640 | // Render a specific page (using a template). | 663 | // Render a specific page (using a template). |
641 | // e.g. pb.renderPage('picwall') | 664 | // e.g. pb.renderPage('picwall') |
642 | public function renderPage($page) | 665 | public function renderPage($page) |