private function run(sfEvent $event) { $rtView = rtViewToolkit::getInstance(); if (!$rtView->getSite() || '' == trim($rtView->getSite()->getRedirects())) { return; } try { $conf = sfYaml::load($rtView->getSite()->getRedirects()); foreach ($conf as $redirect) { if (count($redirect) < 2) { continue; } if ($redirect[0] == $rtView->getUri()) { $event->getSubject()->redirect($redirect[1], isset($redirect[2]) ? $redirect[2] : '301'); } } } catch (Exception $e) { } }
/** * Print a single */ function rt_site_page_map_li($page, $selected_page = null, $options = array()) { $options['closing_tag'] = isset($options['closing_tag']) ? $options['closing_tag'] : '</li>'; $options['class_here'] = isset($options['class_here']) ? $options['class_here'] : 'active'; $options['class_in_path'] = isset($options['class_in_path']) ? $options['class_in_path'] : 'in-path'; $is_in_path = false; $is_current = false; if (!is_null($page)) { $is_current = $page['id'] == $selected_page['id']; if ($selected_page['lft'] > $page['lft'] && $selected_page['rgt'] < $page['rgt'] && $page['level'] != 0) { $is_in_path = true; } } $class = ''; if ($is_current) { $class = $options['class_here']; } elseif ($is_in_path) { $class = $options['class_in_path']; } $title = $page['title']; if (!is_null($page['menu_title']) && trim($page['menu_title']) !== '') { $title = $page['menu_title']; } $path = ''; if ($page['level'] == 0) { $path = url_for('homepage'); } else { if (!$page instanceof rtSitePage) { // Clean arrays of extra values $tmp_page = array(); $tmp_page['id'] = $page['id']; $tmp_page['slug'] = $page['slug']; $tmp_page['content'] = $page['content']; $tmp_page['lft'] = $page['lft']; $tmp_page['rgt'] = $page['rgt']; $tmp_page['level'] = $page['level']; $page = $tmp_page; } $path = url_for('rt_site_page_show', array('slug' => $page['slug'])); if ('link:' === substr($page['content'], 0, 5)) { $path = trim(substr($page['content'], 5)); } } // echo '[ "' . $path . '" - "' .rtViewToolkit::getInstance()->getUri() . '" ] <br>'; // $class = ''; if ($page['rgt'] - $page['lft'] > 1 && $page['level'] != 0) { $class .= ' has-dropdown'; } if ($path == rtViewToolkit::getInstance()->getUri()) { $class .= ' ' . 'active'; } if ('' !== trim($class)) { $class = sprintf(' class="%s"', $class); } return sprintf('<li%s><a href="%s">%s</a>', $class, $path, $title); }