* @license PHP License * @package WB * @subpackage datasource */ WBClass::load('WBDatasource_TreeMenu_Child' ); /** * Datasource TreeMenu Children: Any * * Add recent blog articles to TreeMenu * * @todo read config * @todo add config parameters for output and article list * @version 1.0.0 * @package WB * @subpackage datasource */ class WBDatasource_TreeMenu_Child_Any extends WBDatasource_TreeMenu_Child { /** * Check URL dictionary record * * Return menu record * * @param string $urlid * @param string $url * @return array */ public function getNode($urlid, $url) { $url = WBString::replaceSuperPlaceholders($url); $listPath = WBString::replaceSuperPlaceholders('[[SERVICE_HTML]]' . $this->params['pathprefix']); if (strncmp($url, $listPath, strlen($listPath)) != 0) { return array(); } $node = $this->nodePrototype; $node['id'] = $this->params['pathprefix'] . '-' . $urlid; $node['url'] = $url; $node['urlid'] = $urlid; return $node; $path = explode('/', trim(substr($url, strlen($listPath)), '/')); if (empty($path[0])) { $node = $this->nodePrototype; $node['id'] = $this->params['pathprefix'] . '-' . $urlid; $node['url'] = $url; $node['urlid'] = $urlid; return $node; } return array(); } /** * Get parent nodes until normal tree menu * * List parent nodes until normal (tree manu) parent nodes are reached. * The tree menu class will merge parents together * * @param array $child * @return array */ public function getParents($child) { $parents = array(); $listPath = WBString::replaceSuperPlaceholders('[[SERVICE_HTML]]' . $this->params['pathprefix']); $this->url->addWord($listPath); $node = $this->nodePrototype; $node['url'] = $this->url->getWord(); $node['urlid'] = $this->url->getId(); $parents[] = $node; if (strlen($child['url']) <= strlen($listPath)) { return $parents; } $parents[] = $child; return $parents; } }