OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / include / mos / render / mainmenuHelper.php
1 <?php
2 /**
3 * @version              $Id: mainmenuHelper.php 5528 2013-01-08 12:00:41Z fishbone $
4 * @package              Joomla
5 * @copyright    Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
6 * @license              GNU/GPL, see LICENSE.php
7 * Joomla! is free software. This version may have been modified pursuant
8 * to the GNU General Public License, and as distributed it includes or
9 * is derivative of works licensed under the GNU General Public License or
10 * other free or open source software licenses.
11 * See COPYRIGHT.php for copyright notices and details.
12 */
13
14 // no direct access
15 defined('_JEXEC') or die('Restricted access');
16
17 /**
18  * mod_mainmenu Helper class
19  *
20  * @static
21  * @package             Joomla
22  * @subpackage  Menus
23  * @since               1.5
24  */
25 class modMainMenuHelper
26 {
27         function &getXML($type, &$params, $decorator)
28         {
29                 global $gEnvManager;
30                 static $xmls;
31
32                 // Joomla用のメニューコンテンツを取得
33                 $xmls[$type] = $gEnvManager->getJoomlaMenuContent();
34
35                 // Get document
36                 $xml = JFactory::getXMLParser('Simple');
37                 $xml->loadString($xmls[$type]);
38                 $doc = &$xml->document;
39
40                 //$menu = &JSite::getMenu();
41         //      $menu   = new JMenuTree($params);
42         //      $active = $menu->getActive();
43                 $start  = $params->get('startLevel');
44                 $end    = $params->get('endLevel');
45                 $sChild = $params->get('showAllChildren');
46 //              $path   = array();
47
48                 if ($doc && is_callable($decorator)) {
49                         $doc->map($decorator, array('end'=>$end, 'children'=>$sChild));
50                 }
51                 return $doc;
52         }
53
54         function render(&$params, $callback)
55         {
56                 // Include the new menu class
57                 $xml = modMainMenuHelper::getXML($params->get('menutype'), $params, $callback);
58                 if ($xml) {
59                         $class = $params->get('class_sfx');
60                         $xml->addAttribute('class', 'menu'.$class);
61                         if ($tagId = $params->get('tag_id')) {
62                                 $xml->addAttribute('id', $tagId);
63                         }
64
65                         $result = JFilterOutput::ampReplace($xml->toString((bool)$params->get('show_whitespace')));
66                         $result = str_replace(array('<ul/>', '<ul />'), '', $result);
67                         echo $result;
68                 }
69         }
70 }