new WCF.Date.Time();
new WCF.Effect.SmoothScroll();
new WCF.Effect.BalloonTooltip();
+ new WCF.Sitemap();
WCF.Dropdown.init();
{event name='javascriptInit'}
<ul class="navigationIcons">
<li id="toBottomLink"><a href="{$__wcf->getAnchor('bottom')}" title="{lang}wcf.global.scrollDown{/lang}" class="jsTooltip"><img src="{icon size='S'}circleArrowDownColored{/icon}" alt="" class="icon16" /> <span class="invisible">{lang}wcf.global.scrollDown{/lang}</span></a></li>
+ <li id="sitemap"><a title="{lang}wcf.sitemap.title{/lang}" class="jsTooltip"><img src="{icon size='S'}switchColored{/icon}" alt="" class="icon16" /> <span class="invisible">{lang}wcf.sitemap.title{/lang}</span></a></li>
{if $headerNavigation|isset}{@$headerNavigation}{/if}
{event name='headerNavigation'}
</ul>
--- /dev/null
+<div class="sitemap">
+ {hascontent}
+ <div class="tabMenuContainer" data-active="sitemap-{@$defaultSitemapName}">
+ <nav class="tabMenu">
+ <ul>
+ {content}
+ {foreach from=$tree item=sitemapName}
+ <li><a href="#sitemap-{$sitemapName}" class="sitemapNavigation" data-sitemap-name="{$sitemapName}">{lang}wcf.sitemap.{$sitemapName}{/lang}</a></li>
+ {/foreach}
+ {/content}
+ </ul>
+ </nav>
+
+ {foreach from=$tree item=sitemapName}
+ <div id="sitemap-{$sitemapName}" class="container containerPadding tabMenuContent hidden">
+ {if $sitemapName == $defaultSitemapName}{@$sitemap}{/if}
+ </div>
+ {/foreach}
+ </div>
+
+ <script type="text/javascript">
+ //<![CDATA[
+ $(function() {
+ WCF.TabMenu.init();
+ });
+ //]]>
+ </script>
+ {hascontentelse}
+ {@$sitemap}
+ {/hascontent}
+</div>
\ No newline at end of file
}
});
+/**
+ * Provides a generic sitemap.
+ */
+WCF.Sitemap = Class.extend({
+ /**
+ * sitemap name cache
+ */
+ _cache: [ ],
+
+ /**
+ * dialog overlay
+ * @var jQuery
+ */
+ _dialog: null,
+
+ /**
+ * initialization state
+ * @var boolean
+ */
+ _didInit: false,
+
+ /**
+ * action proxy
+ * @var WCF.Action.Proxy
+ */
+ _proxy: null,
+
+ /**
+ * Initializes the generic sitemap.
+ */
+ init: function() {
+ $('#sitemap').click($.proxy(this._click, this));
+
+ this._cache = [ ];
+ this._dialog = null;
+ this._didInit = false;
+ this._proxy = new WCF.Action.Proxy({
+ success: $.proxy(this._success, this)
+ });
+ },
+
+ /**
+ * Handles clicks on the sitemap icon.
+ */
+ _click: function() {
+ if (this._dialog === null) {
+ this._dialog = $('<div id="sitemapDialog" />').appendTo(document.body);
+
+ this._proxy.setOption('data', {
+ actionName: 'getSitemap',
+ className: 'wcf\\data\\sitemap\\SitemapAction'
+ });
+ this._proxy.sendRequest();
+ }
+ else {
+ this._dialog.wcfDialog('open');
+ }
+ },
+
+ /**
+ * Handles successful AJAX responses.
+ *
+ * @param object data
+ * @param string textStatus
+ * @param jQuery jqXHR
+ */
+ _success: function(data, textStatus, jqXHR) {
+ if (this._didInit) {
+ this._cache.push(data.returnValues.sitemapName);
+
+ this._dialog.find('#sitemap-' + data.returnValues.sitemapName).html(data.returnValues.template);
+
+ // redraw dialog
+ this._dialog.wcfDialog('render');
+ }
+ else {
+ // mark sitemap name as loaded
+ this._cache.push(data.returnValues.sitemapName);
+
+ // insert sitemap template
+ this._dialog.html(data.returnValues.template);
+
+ // bind event listener
+ this._dialog.find('.sitemapNavigation').click($.proxy(this._navigate, this));
+
+ // show dialog
+ this._dialog.wcfDialog({
+ title: WCF.Language.get('wcf.sitemap.title')
+ });
+
+ this._didInit = true;
+ }
+ },
+
+ /**
+ * Navigates between different sitemaps.
+ *
+ * @param object event
+ */
+ _navigate: function(event) {
+ var $sitemapName = $(event.currentTarget).data('sitemapName');
+ if (WCF.inArray($sitemapName, this._cache)) {
+ this._dialog.find('.tabMenuContainer').wcfTabs('select', 'sitemap-' + $sitemapName);
+
+ // redraw dialog
+ this._dialog.wcfDialog('render');
+ }
+ else {
+ this._proxy.setOption('data', {
+ actionName: 'getSitemap',
+ className: 'wcf\\data\\sitemap\\SitemapAction',
+ parameters: {
+ sitemapName: $sitemapName
+ }
+ });
+ this._proxy.sendRequest();
+ }
+ }
+});
+
/**
* Provides a toggleable sidebar with persistent visibility.
*/
* @see wcf\data\IStorableObject::getDatabaseTableAlias()
*/
public static function getDatabaseTableAlias() {
+ if (empty(static::$databaseTableName)) {
+ $className = get_called_class();
+ $className = substr($className, (strrpos($className, '\\') + 1));
+
+ preg_match_all('~((?:^|[A-Z])[a-z]+)~', $className, $matches);
+ foreach ($matches[1] as $part) {
+ if (!empty(static::$databaseTableName)) {
+ static::$databaseTableName .= '_';
+ }
+
+ static::$databaseTableName .= strtolower($part);
+ }
+ }
+
return static::$databaseTableName;
}
if (!count($this->objectIDs)) {
return;
}
-
$sql = "SELECT ".(!empty($this->sqlSelects) ? $this->sqlSelects.($this->useQualifiedShorthand ? ',' : '') : '')."
".($this->useQualifiedShorthand ? $this->getDatabaseTableAlias().'.*' : '')."
FROM ".$this->getDatabaseTableName()." ".$this->getDatabaseTableAlias()."
$this->objects = $statement->fetchObjects(($this->objectClassName ?: $this->className));
}
else {
+ //if (!empty($this->sqlSelects)) die("x".$this->sqlSelects);
$sql = "SELECT ".(!empty($this->sqlSelects) ? $this->sqlSelects.($this->useQualifiedShorthand ? ',' : '') : '')."
".($this->useQualifiedShorthand ? $this->getDatabaseTableAlias().'.*' : '')."
FROM ".$this->getDatabaseTableName()." ".$this->getDatabaseTableAlias()."
public function getSitemap() {
if (isset($this->parameters['sitemapName'])) {
return array(
+ 'sitemapName' => $this->parameters['sitemapName'],
'template' => SitemapHandler::getInstance()->getSitemap($this->parameters['sitemapName'])
);
}
else {
+ $sitemapName = SitemapHandler::getInstance()->getDefaultSitemapName();
+
WCF::getTPL()->assign(array(
- 'tree' => SitemapHandler::getInstance()->getTree(),
- 'sitemap' => SitemapHandler::getInstance()->getSitemap()
+ 'defaultSitemapName' => $sitemapName,
+ 'sitemap' => SitemapHandler::getInstance()->getSitemap($sitemapName),
+ 'tree' => SitemapHandler::getInstance()->getTree()
));
return array(
+ 'sitemapName' => $sitemapName,
'template' => WCF::getTPL()->fetch('sitemap')
);
}
*/
public function getData(array $cacheResource) {
$sitemapList = new SitemapList();
- $sitemapList->getConditionBuilder()->add("sitemap.packageID IN (?)", array(PackageDependencyHandler::getInstance()->getPackageIDs()));
+ $sitemapList->getConditionBuilder()->add("sitemap.packageID IN (?)", array(PackageDependencyHandler::getInstance()->getDependencies()));
$sitemapList->sqlLimit = 0;
$sitemapList->readObjects();
}
/**
- * Returns sitemap for given sitemap name or falls back to active package id.
+ * Returns default sitemap name.
*
- * @param string $sitemapName
- * @return wcf\data\sitemap\Sitemap
+ * @return string
*/
- public function getSitemap($sitemapName = '') {
- if (empty($sitemapName)) {
- foreach ($this->cache as $sitemap) {
- if ($sitemap->packageID == PACKAGE_ID) {
- $sitemapName = $sitemap->sitemapName;
- }
- }
-
- if (empty($sitemapName)) {
- $sitemap = reset($this->cache);
+ public function getDefaultSitemapName() {
+ foreach ($this->cache as $sitemap) {
+ if ($sitemap->packageID == PACKAGE_ID) {
$sitemapName = $sitemap->sitemapName;
}
}
+ if (empty($sitemapName)) {
+ $sitemap = reset($this->cache);
+ $sitemapName = $sitemap->sitemapName;
+ }
+
+ return $sitemapName;
+ }
+
+ /**
+ * Returns sitemap for given sitemap name.
+ *
+ * @param string $sitemapName
+ * @return wcf\data\sitemap\Sitemap
+ */
+ public function getSitemap($sitemapName) {
foreach ($this->cache as $sitemap) {
if ($sitemap->sitemapName == $sitemapName) {
return $sitemap->getTemplate();