-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from F3Community/2016
2016 update!
- Loading branch information
Showing
25 changed files
with
1,156 additions
and
1,905 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ F3com | |
fatfreeframework.com Wiki | ||
|
||
##Installation | ||
The project consists of two different repositories. One with the code, another | ||
The project consists of two different repositories. One with the code, another | ||
with the data. To clone both use the following command | ||
|
||
`git clone --recursive [email protected]:F3Community/F3com.git` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
<?php | ||
/* | ||
This file is part of F3::WIKI | ||
namespace Layout; | ||
|
||
class Model extends \DB\Jig\Mapper { | ||
The contents of this file are subject to the terms of the GNU General | ||
Public License Version 3.0. You may not use this file except in | ||
compliance with the license. Any of the license terms and conditions | ||
can be waived if you get permission from the copyright holder. | ||
*/ | ||
|
||
/** @var \Base */ | ||
protected $f3; | ||
namespace Layout; | ||
|
||
public function __construct() | ||
{ | ||
$this->f3 = \Base::instance(); | ||
parent::__construct($this->f3->get('DB'), 'layout.json'); | ||
} | ||
class Model extends \DB\Jig\Mapper | ||
{ | ||
/** @var \Base */ | ||
protected $f3; | ||
|
||
} | ||
public function __construct() | ||
{ | ||
$this->f3 = \Base::instance(); | ||
parent::__construct($this->f3->get('DB'), 'layout.json'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,48 @@ | ||
<?php | ||
/** | ||
Navigation Model | ||
**/ | ||
/* | ||
This file is part of F3::WIKI | ||
namespace Navigation; | ||
The contents of this file are subject to the terms of the GNU General | ||
Public License Version 3.0. You may not use this file except in | ||
compliance with the license. Any of the license terms and conditions | ||
can be waived if you get permission from the copyright holder. | ||
*/ | ||
|
||
class Model extends \DB\Jig\Mapper { | ||
namespace Navigation; | ||
|
||
/** @var \Base */ | ||
protected $f3; | ||
class Model extends \DB\Jig\Mapper | ||
{ | ||
/** @var \Base */ | ||
protected $f3; | ||
|
||
public function __construct() { | ||
$this->f3 = \Base::instance(); | ||
parent::__construct($this->f3->get('DB'),'navigation.json'); | ||
} | ||
public function __construct() | ||
{ | ||
$this->f3 = \Base::instance(); | ||
parent::__construct($this->f3->get('DB'),'navigation.json'); | ||
} | ||
|
||
/** | ||
* return a set of pages that belongs to a given menu | ||
* @param $menu | ||
* @return array | ||
*/ | ||
public function getPages($menu) { | ||
$this->load(array('@name = ?', $menu)); | ||
if(!$this->dry()) { | ||
$page = new \Page\Model(); | ||
$pages = array(); | ||
foreach ($this->pages as $item) { | ||
// $page->load(array('@_id = ? AND ( isset(@deleted) && @deleted = 0)', $item)); | ||
$page->load(array('@_id = ?', $item)); | ||
if (!$page->dry()) | ||
$pages[] = array('title' => $page->title, 'slug' => $page->slug); | ||
$page->reset(); | ||
} | ||
} else { | ||
trigger_error('menu not found'); | ||
} | ||
$this->reset(); | ||
return $pages; | ||
} | ||
/** | ||
* return a set of pages that belongs to a given menu | ||
* @param $menu | ||
* @return array | ||
*/ | ||
public function getPages($menu) | ||
{ | ||
$this->load(array('@name = ?', $menu)); | ||
if(!$this->dry()) { | ||
$page = new \Page\Model(); | ||
$pages = array(); | ||
foreach ($this->pages as $item) { | ||
// $page->load(array('@_id = ? AND ( isset(@deleted) && @deleted = 0)', $item)); | ||
$page->load(array('@_id = ?', $item)); | ||
if (!$page->dry()) | ||
$pages[] = array('title' => $page->title, 'slug' => $page->slug); | ||
$page->reset(); | ||
} | ||
} else { | ||
trigger_error('menu not found'); | ||
} | ||
$this->reset(); | ||
return $pages; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,77 @@ | ||
<?php | ||
/** | ||
Navigation Menu Builder | ||
**/ | ||
/* | ||
This file is part of F3::WIKI | ||
The contents of this file are subject to the terms of the GNU General | ||
Public License Version 3.0. You may not use this file except in | ||
compliance with the license. Any of the license terms and conditions | ||
can be waived if you get permission from the copyright holder. | ||
*/ | ||
|
||
namespace Navigation; | ||
|
||
class View { | ||
class View | ||
{ | ||
|
||
static public function render($menu,$tmpl = 'navigation_main.html') | ||
{ | ||
$f3 = \Base::instance(); | ||
$nav = new Model(); | ||
$current_page = $f3->get('PARAMS.page'); | ||
$pages = $nav->getPages($menu); | ||
$activePageFound = false; | ||
|
||
foreach($pages as &$page) | ||
if($current_page == $page['slug']) { | ||
$page['active'] = true; | ||
$activePageFound = true; | ||
} else { | ||
$page['active'] = false; | ||
} | ||
|
||
static public function render($menu,$tmpl = 'navigation_main.html') { | ||
$f3 = \Base::instance(); | ||
$nav = new Model(); | ||
$current_page = $f3->get('PARAMS.page'); | ||
$pages = $nav->getPages($menu); | ||
$activePageFound = false; | ||
foreach($pages as &$page) | ||
if($current_page == $page['slug']) { | ||
$page['active'] = true; | ||
$activePageFound = true; | ||
} else | ||
$page['active'] = false; | ||
if(!$activePageFound) | ||
$pages = self::resolveParentActivePage($current_page,$pages); | ||
$f3->set('menu', $pages); | ||
$content = \Template::instance()->render($f3->get('TMPL').$tmpl); | ||
$f3->clear('menu'); | ||
return $content; | ||
} | ||
if(!$activePageFound) | ||
$pages = self::resolveParentActivePage($current_page,$pages); | ||
|
||
static private function resolveParentActivePage($current_page,$pages) | ||
{ | ||
// get parent page id | ||
$pageModel = new \Page\Model(); | ||
$pageModel->load(array('@slug = ?', $current_page)); | ||
if (!$pageModel->dry() && !empty($pageModel->pid)) { | ||
// load parent page | ||
$pageModel->load(array('@_id = ? ', $pageModel->pid)); | ||
if (!$pageModel->dry()) { | ||
$parent_page = $pageModel->cast(); | ||
// see, if parent page is in the set of menu pages | ||
foreach ($pages as &$page) | ||
if ($page['slug'] == $parent_page['slug']) { | ||
$page['active'] = true; | ||
return $pages; | ||
} | ||
return self::resolveParentActivePage($parent_page['slug'],$pages); | ||
} | ||
} | ||
return $pages; | ||
} | ||
$f3->set('menu', $pages); | ||
$content = \Template::instance()->render($f3->get('TMPL').$tmpl); | ||
$f3->clear('menu'); | ||
|
||
static public function renderTag($args) | ||
{ | ||
$attr = $args['@attrib']; | ||
$tmp = \Template::instance(); | ||
foreach ($attr as &$att) | ||
$att = $tmp->token($att); | ||
if (array_key_exists('menu', $attr)) { | ||
$nav_code = '\Navigation\View::render(\''.$attr['menu'].'\');'; | ||
if (array_key_exists('tmpl', $attr)) | ||
$nav_code = "\Navigation\View::render('".$attr['menu']."','".$attr['tmpl']."');"; | ||
return '<?php echo '.$nav_code.' ?>'; | ||
} | ||
} | ||
return $content; | ||
} | ||
|
||
static private function resolveParentActivePage($current_page,$pages) | ||
{ | ||
// get parent page id | ||
$pageModel = new \Page\Model(); | ||
$pageModel->load(array('@slug = ?', $current_page)); | ||
if (!$pageModel->dry() && !empty($pageModel->pid)) { | ||
// load parent page | ||
$pageModel->load(array('@_id = ? ', $pageModel->pid)); | ||
if (!$pageModel->dry()) { | ||
$parent_page = $pageModel->cast(); | ||
// see, if parent page is in the set of menu pages | ||
foreach ($pages as &$page) | ||
if ($page['slug'] == $parent_page['slug']) { | ||
$page['active'] = true; | ||
return $pages; | ||
} | ||
return self::resolveParentActivePage($parent_page['slug'],$pages); | ||
} | ||
} | ||
return $pages; | ||
} | ||
|
||
static public function renderTag($args) | ||
{ | ||
$attr = $args['@attrib']; | ||
$tmp = \Template::instance(); | ||
foreach ($attr as &$att) | ||
$att = $tmp->token($att); | ||
if (array_key_exists('menu', $attr)) { | ||
$nav_code = '\Navigation\View::render(\''.$attr['menu'].'\');'; | ||
if (array_key_exists('tmpl', $attr)) | ||
$nav_code = "\Navigation\View::render('".$attr['menu']."','".$attr['tmpl']."');"; | ||
return '<?php echo '.$nav_code.' ?>'; | ||
} | ||
} | ||
} |
Oops, something went wrong.