protected function InitItem($resize_mode = 'html') { $image = sfAdminDash::getProperty('default_image'); if (array_key_exists('image', $this->item)) { $image = $this->item['image']; } $this->item['image'] = sfAdminDash::getProperty('image_dir'); if ($resize_mode == 'thumbnail') { $this->item['image'] .= 'small/'; } //if image isn't specified - use default if (!array_key_exists('image', $this->item)) { $this->item['image'] .= $image; } else { $this->item['image'] .= $image; } //if name isn't specified - use key if (!array_key_exists('name', $this->item)) { $this->item['name'] = $this->key; } //if url isn't specified - use key if (!array_key_exists('url', $this->item)) { $this->item['url'] = $this->key; } }
/** * The main navigation component for the sfAdminDash plugin */ public function executeHeader() { $this->items = sfAdminDash::getItems(); $this->categories = sfAdminDash::getCategories(); $this->called_from_component = true; // BC check if (sfConfig::get('sf_error_404_module') == $this->getContext()->getModuleName() && sfConfig::get('sf_error_404_action') == $this->getContext()->getActionName()) { sfAdminDash::setProperty('include_path', false); // we don't render the breadcrumbs when we are in a 404 error module/action $this->module_link = null; $this->action_link = null; } else { if (!sfAdminDash::routeExists($this->module_link = $this->getContext()->getModuleName(), $this->getContext())) { // if we cannot sniff the module link, we set it to null and later simply output is as a string in the breadcrumbs $this->module_link = null; // but before we do that, one last check - it's possible that the module name is different from the object name and that's the reason we can't sniff it foreach (sfAdminDash::getAllItems() as $name => $item) { if ($name == $this->getContext()->getModuleName()) { $this->module_link = $item['url']; break; } } } $this->module_link_name = sfAdminDash::getModuleName($this->getContext()); if ($this->getContext()->getActionName() != 'index') { $this->action_link = $this->getContext()->getRouting()->getCurrentInternalUri(); $this->action_link_name = sfAdminDash::getActionName($this->getContext()); } else { $this->action_link = null; } } }
/** * This is the right way to add stuff to the <head> tag after the page has been generated :) * The principle is the same as with the old sfCommonFilter and asset insertion in sf 1.0-1.2 * * @param sfEvent $event * @param string $content * * @return string */ public static function listenToResponseFilterContentEvent(sfEvent $event, $content = null) { $jquery_include_tag = '<script type="text/javascript" src="' . sfAdminDash::getProperty('web_dir') . '/js/' . sfAdminDash::getProperty('jquery_filename') . '"></script>'; $jquery_no_conflict_tag = '<script type="text/javascript">jQuery.noConflict();</script>'; if (false !== ($pos = strpos($content, $jquery_include_tag))) { $content = substr($content, 0, $pos + strlen($jquery_include_tag)) . $jquery_no_conflict_tag . substr($content, $pos + strlen($jquery_include_tag)); } return $content; }
/** * Executes the index action, which shows a list of all available modules * */ public function executeDashboard() { $this->items = sfAdminDash::getItems(); $this->categories = sfAdminDash::getCategories(); }
/** * This function primes the item for use, making sure all required fields are set * * @param array $item The item data, sent by reference * @param string|integer $key The key that points to the specific item */ public static function initItem(&$item, $key) { $image = isset($item['image']) ? $item['image'] : sfAdminDash::getProperty('default_image'); $image = substr($image, 0, 1) == '/' ? $image : sfAdminDash::getProperty('image_dir') . $image; $item['image'] = $image; //if name isn't specified - use key $item['name'] = isset($item['name']) ? $item['name'] : $key; //if url isn't specified - use key $item['url'] = isset($item['url']) ? $item['url'] : $key; //if in_menu isn't specified - use true $item['in_menu'] = isset($item['in_menu']) ? $item['in_menu'] : true; }
<?php echo link_to( $sf_user->getGuardUser()->getFirstName(), '/user/password-reset' ); ?> <?php echo link_to(__('Logout', null, 'sf_admin_dash'), sfAdminDash::getProperty('logout_route', '@sf_guard_signout ')); ?> </div> <?php endif; ?> <div class="clear"></div> </div> <!-- <?php if (sfAdminDash::getProperty('include_path')): ?> <div id='sf_admin_path'> <strong><a href='<?php echo url_for('homepage'); ?>'><?php echo sfAdminDash::getProperty('site'); ?></a></strong> <?php if ($sf_context->getModuleName() != 'sfAdminDash' && $sf_context->getActionName() != 'dashboard'): ?> / <?php echo null !== $module_link ? link_to($module_link_name, $module_link) : $module_link_name; ?> <?php if (null != $action_link): ?> / <?php echo link_to(__(ucfirst($action_link_name), null, 'sf_admin'), $action_link); ?> <?php endif ?> <?php endif; ?> </div> <?php endif; ?> --> <?php else: ?> <div id='sf_admin_menu'> <div id="logout"><?php echo link_to(__('Login', null, 'sf_admin_dash'), sfAdminDash::getProperty('login_route', '@sf_guard_signin ')); ?></div> <div class="clear"></div> </div> <?php endif; ?> <?php endif; // BC check if ?>
<?php /** * This file is part of the sfAdminDash package */ if (in_array('sfAdminDash', sfConfig::get('sf_enabled_modules', array()))) { // the plugin module is in the enabled modules, add assets: $this->dispatcher->connect('context.load_factories', array('sfAdminDashConfig', 'listenToContextLoadFactoriesEvent')); if (true == sfAdminDash::getProperty('include_jquery_no_conflict')) { // if include_jquery_no_conflict is set to true, we need to modify the response content $this->dispatcher->connect('response.filter_content', array('sfAdminDashConfig', 'listenToResponseFilterContentEvent')); } }
?> <?php if ($sf_user->isAuthenticated()): ?> <div id='sf_admin_theme_header'> <a href='<?php echo url_for('homepage') ?>'><?php echo image_tag(sfAdminDash::getProperty('web_dir').'/images/header_text', array('alt' => 'Home')); ?></a> </div> <div id='sf_admin_menu'> <?php include_partial('sfAdminDash/menu', array('items' => $items, 'categories' => $categories)); ?> <?php if (sfAdminDash::getProperty('logout') && $sf_user->isAuthenticated()): ?> <div id="logout"><?php echo link_to(__('Logout', null, 'sf_admin_dash'), sfAdminDash::getProperty('logout_route', '@sf_guard_signout ')); ?> <?php echo $sf_user; ?></div> <?php endif; ?> <div class="clear"></div> </div> <?php if (sfAdminDash::getProperty('include_path')): ?> <div id='sf_admin_path'> <strong><a href='<?php echo url_for('homepage'); ?>'><?php echo sfAdminDash::getProperty('site'); ?></a></strong> <?php if ($sf_context->getModuleName() != 'sfAdminDash' && $sf_context->getActionName() != 'dashboard'): ?> / <?php echo null !== $module_link ? link_to($module_link_name, $module_link) : $module_link_name; ?> <?php if (null != $action_link): ?> / <?php echo link_to(__(ucfirst($action_link_name), null, 'sf_admin'), $action_link); ?> <?php endif ?> <?php endif; ?> </div> <?php endif; ?> <?php endif; ?> <?php endif; // BC check if ?>
<a href="<?php echo url_for($item['url']); ?> "> <?php if (sfAdminDash::getProperty('resize_mode') == 'html') { ?> <?php echo image_tag($item['image'], array('alt' => $item['name'], 'width' => '16', 'height' => '16')); ?> <?php } else { ?> <?php echo image_tag($item['image'], array('alt' => $item['name'])); ?> <?php } ?> <span><?php echo $item['name']; ?> </span> </a>
<?php use_stylesheet(sfAdminDash::getProperty('web_dir') . '/css/default.css', 'first'); ?> <?php if (sfAdminDash::getProperty('include_jquery')) { use_javascript(sfAdminDash::getProperty('web_dir') . '/js/jquery-1.3.1.min.js', 'first'); } use_javascript(sfAdminDash::getProperty('web_dir') . '/js/sf_admin_dash', 'first'); ?> <div id='sf_admin_theme_header'> <a href='<?php echo url_for('homepage'); ?> '><?php echo image_tag(sfAdminDash::getProperty('web_dir') . '/images/header_text', array('alt' => 'Home')); ?> </a> </div>
<?php } ?> <?php include_partial('sfAdminDash/user_actions', array('user_actions' => $user_actions)); ?> <div class="clear"></div> </div> <?php if (sfAdminDash::getProperty('include_path')) { ?> <div id='sf_admin_path'> <strong> <?php echo link_to(sfAdminDash::getProperty('site'), sfAdminDash::getProperty('dashboard_url')); ?> </strong> <?php if ($sf_context->getModuleName() != 'sfAdminDash' && $sf_context->getActionName() != 'dashboard') { ?> / <?php echo null !== $module_link ? link_to($module_link_name, $module_link) : $module_link_name; ?> <?php if (null != $action_link) { ?> / <?php echo link_to(__(ucfirst($action_link_name)), $action_link); ?> <?php
<?php if ($items_in_menu && $item['in_menu'] || !$items_in_menu && !$item['in_menu']) { ?> <li <?php echo $item['in_menu'] ? 'class="item"' : 'class="item-menu"'; ?> > <a href="<?php echo url_for($item['url']); ?> " title="<?php echo __($item['name']); ?> "> <?php if (sfAdminDash::getProperty('resize_mode') == 'thumbnail') { ?> <?php echo image_tag(substr($item['image'], 0, strrpos($item['image'], '/')) . '/small/' . substr($item['image'], strrpos($item['image'], '/') + 1), array('alt' => __($item['name']), 'width' => '16', 'height' => '16')); ?> <?php } else { ?> <?php echo image_tag($item['image'], array('alt' => $item['name'], 'width' => '16', 'height' => '16')); ?> <?php } ?> <span><?php echo __($item['name']);
<ul> <?php if (sfAdminDash::hasItemsMenu($items)): ?> <li class="node"><a href="#">Menu</a> <ul> <?php include_partial('sfAdminDash/menu_list', array('items' => $items, 'items_in_menu' => true)); ?> </ul> </li> <?php endif; ?> <?php include_partial('sfAdminDash/menu_list', array('items' => $items, 'items_in_menu' => false)); ?> </ul> <?php endif; ?> <?php if (count($categories)): ?> <!-- <ul> --> <?php foreach ($categories as $name => $category): ?> <?php if (sfAdminDash::hasPermission($category, $sf_user)): ?> <?php if (sfAdminDash::hasItemsMenu($category['items'])): ?> <li class="node"><a href="#"><?php echo isset($category['name']) ? $category['name'] : $name ?></a> <ul> <?php include_partial('sfAdminDash/menu_list', array('items' => $category['items'], 'items_in_menu' => true)) ?> </ul> </li> <?php endif; ?> <?php endif; ?> <?php endforeach; ?> <?php foreach ($categories as $name => $category): ?> <?php include_partial('sfAdminDash/menu_list', array('items' => $category['items'], 'items_in_menu' => false)) ?> <?php endforeach; ?> <!-- </ul> --> <?php elseif (!count($items)): ?> <?php echo __('sfAdminDashPlugin is not configured. Please see the %documentation_link%.', array('%documentation_link%'=>link_to(__('documentation', null, 'sf_admin_dash'), 'http://www.symfony-project.org/plugins/sfAdminDashPlugin?tab=plugin_readme', array('title' => __('documentation', null, 'sf_admin_dash')))), 'sf_admin_dash'); ?> <?php endif; ?>
echo $form['password']->renderError(); ?> <?php echo $form['password']->render(array('class' => 'inputbox')); ?> </div> <div class="inputlabel"> <?php echo $form['remember']->renderLabel('Remember?'); ?> <?php echo $form['remember']->render(array('class' => 'inputcheck')); ?> </div> <div align="left"><input type="submit" name="submit" class="button clr" value="Login" /></div> </div> </form> </div> <div class="login-text"> <div class="ctr"><img alt="Security" src="/sfAdminDashPlugin/images/login_security.png" /></div> <p>Welcome to <?php echo sfAdminDash::getProperty('site'); ?> </p> <p>Use a valid username and password to gain access to the administration console.</p> </div> <div class="clr"></div> </div> </div>
<?php use_helper('I18N'); ?> <div id='sf_admin_theme_footer'> <?php echo __('Copyright © %current_year% %site_name%. All rights reserved', array('%current_year%' => date('Y'), '%site_name%' => sfAdminDash::getProperty('site'))); ?> </div>
<?php echo __('Passwort ändern') ?> </a> </li> <li class="divider"></li> <li> <a href="<?php echo url_for(sfAdminDash::getProperty('logout_route', '@sf_guard_signout ')); ?>"> <i class="icon-signout"></i> <?php echo __('Abmelden') ?> </a> </li> </ul> <?php endif; ?> </div><!--/.nav-collapse --> <?php else: ?> <div class="nav-collapse"> <ul class="nav pull-right"> <li> <?php echo link_to(__('<i class="icon-user icon-white" ></i> Login', null, 'sf_admin_dash'), sfAdminDash::getProperty('login_route', '@sf_guard_signin ')); ?> </li> </ul> </div><!--/.nav-collapse --> <?php endif; ?> </div> </div> <?php endif; // BC check if ?>
if (count($items)) { ?> <?php include_partial('dash_list', array('items' => $items)); ?> <?php } ?> <?php if (count($categories)) { ?> <?php foreach ($categories as $name => $category) { ?> <?php if (sfAdminDash::hasPermission($category, $sf_user)) { ?> <h2><?php echo __(isset($category['name']) ? $category['name'] : $name, null, 'sf_admin_dash'); ?> </h2> <?php include_partial('dash_list', array('items' => $category['items'])); ?> <?php } ?> <?php } ?> <?php
<?php if (isset($user_actions) && $user_actions) { ?> <ul id="sf_admin_user_actions"> <?php foreach ($user_actions as $action_name => $action) { ?> <?php if (sfAdminDash::hasPermission($action, $sf_user)) { ?> <li><?php echo link_to(__($action_name), $action['url']); ?> </li> <?php } ?> <?php } ?> </ul> <?php }
<div class="cpanel"> <?php foreach ($items as $key => $item) { ?> <?php if (sfAdminDash::hasPermission($item, $sf_user)) { ?> <div style="float: left"> <?php include_component('sfAdminDash', 'dash_item', array('item' => $item, 'key' => $key)); ?> </div> <?php } ?> <?php } ?> <div class="clear"></div> </div>
<?php if (sfAdminDash::getProperty('logout') && $sf_user->isAuthenticated()) { ?> <div id="logout">[<?php echo link_to('Выйти', 'sfGuardAuth/signout'); ?> ] <?php echo $sf_user; ?> </div> <?php } ?> <div class="clear"></div> </div> <div id='sf_admin_path'> <strong> <a href='<?php echo url_for('homepage'); ?> '><?php echo sfAdminDash::getProperty('site'); ?> </a> </strong> / <?php echo ucfirst(__(sfAdminDash::getModuleName($sf_context->getModuleName()))); ?> </div> <?php }