private function getMenuNodes()
 {
     $navigationModel = new NavigationModel();
     $localNavigation = $navigationModel->getLocalNavigationTree(NavigationModel::WIKI_LOCAL_MESSAGE);
     $onTheWikiNavigation = $navigationModel->getOnTheWikiNavigationTree(NavigationModel::WIKIA_GLOBAL_VARIABLE);
     return array_merge($localNavigation, $onTheWikiNavigation);
 }
 /**
  * Clear local wikinav cache when local version of global menu
  * is modified using WikiFactory
  *
  * @param string $cv_name WF variable name
  * @param int $city_id wiki ID
  * @param mixed $value new variable value
  * @return bool return true
  */
 public static function onWikiFactoryChanged($cv_name, $city_id, $value)
 {
     if ($cv_name == NavigationModel::WIKIA_GLOBAL_VARIABLE) {
         $model = new NavigationModel();
         $model->clearMemc(NavigationModel::WIKIA_GLOBAL_VARIABLE, $city_id);
         wfDebug(__METHOD__ . ": purging the cache for wiki #{$city_id}\n");
     }
     return true;
 }
 /**
  * Clear the local navigation cache every time the MediaWiki message is edited
  *
  * @param string $title name of the page changed.
  * @param string $text new contents of the page
  * @return bool return true
  */
 public static function onMessageCacheReplace($title, $text)
 {
     if (NavigationModel::isWikiNavMessage(Title::newFromText($title, NS_MEDIAWIKI))) {
         $model = new NavigationModel();
         // clear the cache of the "old" local nav logic
         // it's still used when NavigationModel::parse() is called
         $model->clearMemc($title);
         // clear the cache of the new local nav logic
         $model->clearNavigationTreeCache();
     }
     return true;
 }
 /**
  * Fetches wiki navigation
  *
  * @responseParam array $navigation Wiki Navigation
  *
  * @example
  */
 public function getData()
 {
     $model = new NavigationModel();
     $nav = $model->getWiki();
     $ret = array();
     foreach ($nav as $type => $list) {
         $ret[$type] = $this->getChildren($list);
     }
     $this->setResponseData(['navigation' => $ret], ['urlFields' => 'href'], NavigationModel::CACHE_TTL);
     $errors = $model->getErrors();
     if (!empty($errors)) {
         throw new InvalidDataApiException(implode(', ', array_keys($errors)));
     }
 }
 public function delete()
 {
     $view = $this->getView();
     $req = $this->getPageRequest();
     $mid = $req->getParameter(0);
     $m = new NavigationModel($mid);
     if (!$req->isPost()) {
         return View::ERROR_BADREQUEST;
     }
     if (!$m->exists()) {
         return View::ERROR_NOTFOUND;
     }
     $m->delete();
     \core\redirect('/navigation');
 }
 public function addNavProcess()
 {
     $nav = new NavigationModel();
     if ($vo = $nav->create()) {
         //dump($vo);exit;
         $list = $nav->add();
         if ($list !== false) {
             $this->success('数据保存成功!');
         } else {
             $this->error('数据写入错误!');
         }
     } else {
         $this->error($nav->getError());
     }
 }
 /**
  * Check if we should show mobile and desktop preview icon
  * Excluded pages:
  * - Main page
  * - Code page (CSS, JS and Lua)
  * - MediaWiki:Wiki-navigation
  *
  * @param Title $title
  * @return bool
  */
 public function showMobilePreview(Title $title)
 {
     $blacklistedPage = self::isCodePage($title) || $title->isMainPage() || NavigationModel::isWikiNavMessage($title);
     return !$blacklistedPage;
 }
 /**
  * Adds necessary tables if Wall or Forum has just been enabled in Special:WikiFeatures
  *
  * @param String $name
  * @param String $val
  *
  * @return bool
  */
 public static function onAfterToggleFeature($name, $val)
 {
     global $IP;
     if ($name == 'wgEnableWallExt' || $name == 'wgEnableForumExt') {
         $db = wfGetDB(DB_MASTER);
         if (!$db->tableExists('wall_history')) {
             $db->sourceFile($IP . "/extensions/wikia/Wall/sql/wall_history_local.sql");
         }
         if (!$db->tableExists('wall_related_pages')) {
             $db->sourceFile($IP . "/extensions/wikia/Wall/sql/wall_related_pages.sql");
         }
         $nm = new NavigationModel();
         $nm->clearMemc(NavigationModel::WIKIA_GLOBAL_VARIABLE);
     }
     return true;
 }
 /**
  * @group Slow
  * @slowExecutionTime 0.03666 ms
  * @group UsingDB
  */
 function testParseErrors()
 {
     $model = new NavigationModel();
     $this->assertEmpty($model->getErrors());
     // magic words are not allowed on level #1
     $nodes = $model->parseText("*#category1");
     $this->assertTrue($model->getErrors()[NavigationModel::ERR_MAGIC_WORD_IN_LEVEL_1]);
     // magic words are  allowed on level #2
     $nodes = $model->parseText("*foo\n**#category1");
     $this->assertEmpty($model->getErrors());
 }
 public function view()
 {
     $view = $this->getView();
     $m = NavigationModel::Construct($this->getParameter(0));
     $current = PageRequest::GetSystemRequest();
     $currenturl = $current->getBaseURL();
     // Used to indicate the "active" link.
     if (!$m->exists()) {
         return View::ERROR_NOTFOUND;
     }
     // Get the entries for this model as well.
     $entries = $m->getLink('NavigationEntry', 'weight ASC');
     // View won't quite just have a flat list of entries, as they need to be checked and sorted
     // into a nested array.
     $sortedentries = [];
     // First level children
     foreach ($entries as $k => $e) {
         if (!$e->get('parentid')) {
             $classes = [];
             $classes[] = Core\str_to_url($e->get('title')) . '-link';
             if ($e->get('baseurl') == $currenturl) {
                 $classes[] = 'active';
             }
             if (\Core\user()->checkAccess($e->getAccessString())) {
                 // There's a weird bug where sometimes the access cache is empty.
                 // In that case, just allow the user to view the page.
                 $sortedentries[] = ['obj' => $e, 'children' => [], 'classes' => $classes];
             }
             unset($entries[$k]);
         }
     }
     // One level deep
     if (sizeof($entries)) {
         foreach ($sortedentries as $sk => $se) {
             foreach ($entries as $k => $e) {
                 if ($e->get('parentid') == $se['obj']->get('id')) {
                     if (\Core\user()->checkAccess($e->getAccessString())) {
                         // There's a weird bug where sometimes the access cache is empty.
                         // In that case, just allow the user to view the page.
                         $classes = [];
                         $classes[] = Core\str_to_url($e->get('title')) . '-link';
                         if ($e->get('baseurl') == $currenturl) {
                             $classes[] = 'active';
                             // also set active class on the parent so frontenders don't rage :)
                             $sortedentries[$sk]['classes'][] = 'active';
                         }
                         // Add the "more" class to the parent.
                         $sortedentries[$sk]['classes'][] = 'more';
                         $sortedentries[$sk]['children'][] = ['obj' => $e, 'children' => [], 'classes' => $classes];
                     }
                     unset($entries[$k]);
                 }
             }
         }
     }
     // Two levels deep
     // this would be so much simpler if the menu was in DOM format... :/
     if (sizeof($entries)) {
         foreach ($sortedentries as $sk => $se) {
             foreach ($se['children'] as $subsk => $subse) {
                 foreach ($entries as $k => $e) {
                     if ($e->get('parentid') == $subse['obj']->get('id')) {
                         if (\Core\user()->checkAccess($e->getAccessString())) {
                             $classes = [];
                             $classes[] = Core\str_to_url($e->get('title')) . '-link';
                             if ($e->get('baseurl') == $currenturl) {
                                 $classes[] = 'active';
                                 // also set active class on the top-most nav parent so frontenders don't rage :)
                                 $sortedentries[$sk]['children'][$subsk]['class'][] = 'active';
                             }
                             // Add the "more" class to the parent.
                             $sortedentries[$sk]['children'][$subsk]['class'][] = 'more';
                             $sortedentries[$sk]['children'][$subsk]['children'][] = ['obj' => $e, 'children' => [], 'classes' => $classes];
                         }
                         unset($entries[$k]);
                     }
                 }
             }
         }
     }
     foreach ($sortedentries as $k => $el) {
         $this->_transposeClass($sortedentries[$k]);
     }
     $view->title = $m->get('title');
     $view->access = $m->get('access');
     $view->templatename = '/widgets/navigation/view.tpl';
     $view->assignVariable('model', $m);
     $view->assignVariable('entries', $sortedentries);
     /*
     $view->addControl('New Navigation Menu', '/Navigation/Create', 'add');
     $view->addControl('Edit Page', '/Content/Edit/' . $m->get('id'), 'edit');
     $view->addControl('Delete Page', '/Content/Delete/' . $m->get('id'), 'delete');
     $view->addControl('All Content Pages', '/Content', 'directory');
     */
 }
Example #11
0
<?php

/*
 * Define your routes and which views to display
 * depending of the query.
 *
 * Based on WordPress conditional tags from the WordPress Codex
 * http://codex.wordpress.org/Conditional_Tags
 *
 */
/*Layouts Data - Header */
View::share(array('logoUrl' => themosis_assets() . '/images/slhb-logo.png', 'logoMinUrl' => themosis_assets() . '/images/white_logo.png', 'logoFb' => themosis_assets() . '/images/logo-fb.png', 'logoGMap' => themosis_assets() . '/images/logo-gmap.png', 'footerImage' => themosis_assets() . '/images/image-footer-2015.png', 'defaultAvatar' => themosis_assets() . '/images/slhb-default-avatar.png', 'currentUser' => User::current(), 'headerMenu' => NavigationModel::getMenuItems("header-nav"), 'home_banner' => themosis_assets() . "/images/banner.jpg"));
/*Page d'accueil */
Route::any('front', 'HomeController@index');
/* Page Toutes les équipes */
Route::get('postTypeArchive', ['slhb_team', 'uses' => 'TeamController@index']);
/* Page de détails d'une équipes */
Route::get('singular', ['slhb_team', 'uses' => 'TeamController@getSingle']);
/*Page de détails d'une actualité */
Route::get('singular', array('post', function () {
    return View::make('actualites.single');
}));
/* Page Calendrier */
Route::get('template', array('calendar-template', 'uses' => 'AgendaController@index'));
/* Page Infos pratiques */
Route::get('template', array('infos-pratiques-template', 'uses' => 'InfosPratiquesController@index'));
/* Page Médiathèque */
/* Page Contacts */
/* Page Boutique */
/* Page Profil  */
/*Page par défaut*/