getBuildTemplate(); if ( $template == 'widgets/widget_detail' ) { // This is default template for this prefix, so don't add it to resulting url. $this->setBuildParam('pass_template', false); } $build_params = $this->extractBuildParams(); if ( $build_params === false ) { return ''; } $ret = array('', ''); $filename = $this->getBuildParam('@filename'); $this->setBuildParam('@filename'); if ( $build_params[$this->buildPrefix . '_id'] > 0 ) { // Add id. if ( !$filename ) { $sql = 'SELECT Title FROM ' . TABLE_PREFIX . 'Widgets WHERE WidgetId = ' . $build_params[$this->buildPrefix . '_id']; $filename = $this->Conn->GetOne($sql); } $ret[0] .= 'widgets/' . $filename . '/'; } elseif ( $build_params[$this->buildPrefix . '_Page'] > 1 ) { // Add page, only when ID is missing. $ret[1] .= $build_params[$this->buildPrefix . '_Page'] . '/'; } $ret[0] = rtrim($ret[0], '/'); $ret[1] = rtrim($ret[1], '/'); return array_map('mb_strtolower', $ret); } /** * Parses url part. * * @param array $url_parts Url parts to parse. * @param array $params Parameters, that are used for url building or created during url parsing. * * @return boolean Return true to continue to next router; return false to stop processing at this router. */ public function parse(array &$url_parts, array &$params) { $widget_id = 0; $widget_filename = ''; $widget_index = array_search('widgets', $url_parts); if ( $widget_index !== false && isset($url_parts[$widget_index + 1]) ) { $widget_filename = $url_parts[$widget_index + 1]; } if ( $widget_filename ) { $sql = 'SELECT WidgetId FROM ' . TABLE_PREFIX . 'Widgets WHERE Title = ' . $this->Conn->qstr($widget_filename); $widget_id = $this->Conn->GetOne($sql); if ( $widget_id ) { $params[$this->buildPrefix . '_id'] = $widget_id; $params[$this->buildPrefix . '_filename'] = $widget_filename; $params['pass'][] = $this->buildPrefix; $this->partParsed('widgets'); $this->partParsed($widget_filename); } } if ( $widget_id && !$this->moreToParse() ) { // Widget was last url part - use default template. $params['t'] = 'widgets/widget_detail'; } return true; } }