<commit_before><?php

/**
 * Plugin configuration for the theme plugin
 * 
 * @package     sfSympalThemePlugin
 * @subpackage  config
 * @author      <NAME> <<EMAIL>>
 * @since       2010-03-27
 * @version     svn:$Id$ $Author$
 */
class sfSympalThemePluginConfiguration extends sfPluginConfiguration
{
  protected
    $_sympalContext;

  public function initialize()
  {
    // Only bootstrap if theming is disabled
    if (sfSympalConfig::get('theme', 'enabled'))
    {
      $this->dispatcher->connect('sympal.load', array($this, 'bootstrap'));
      $this->dispatcher->connect('controller.change_action', array($this, 'listenControllerChangeAction'));
    }
    
    $themeUser = new sfSympalThemeUser();
    $this->dispatcher->connect('user.method_not_found', array($themeUser, 'extend'));

    // Connect to the sympal.load_admin_menu event
    $this->dispatcher->connect('sympal.load_admin_menu', array($this, 'setupAdminMenu'));

    // Connect to the sympal.load_config_form evnet
    $this->dispatcher->connect('sympal.load_config_form', array($this, 'loadConfigForm'));
  }
  
  /**
   * Listens to sympal.load. Bootstraps the plugin
   */
  public function bootstrap(sfEvent $event)
  {
    $this->_sympalContext = $event->getSubject();
    
    // extend the actions class to sfSympalThemeActions
    $actionObject = new sfSympalThemeActions();
    $this->dispatcher->connect('component.method_not_found', array($actionObject, 'extend'));
    
    $themeDispatcher = $this->_sympalContext->getService('theme_dispatcher');
    $theme = $themeDispatcher->getThemeForRequest($this->_sympalContext->getSymfonyContext());
    
    if ($theme)
    {
      $this->_sympalContext->getService('theme_manager')->setCurrentTheme($theme);
    }
  }

  /**
   * Listens to the controller.change_action event to set the correct theme
   * when the action changes
   * 
   * @param sfEvent $event The controller.change_action event object
   */
  public function listenControllerChangeAction(sfEvent $event)
  {
    $sympalContext = sfSympalContext::getInstance();
    $themeDispatcher = $sympalContext->getService('theme_dispatcher');
    $theme = $themeDispatcher->getThemeForRequest($sympalContext->getSymfonyContext());
  }

  /**
   * Listens to the sympal.load_admin_menu to configure the admin menu
   */
  public function setupAdminMenu(sfEvent $event)
  {
    $administration = $menu->getChild('administration');
    
    $administration->addChild('Themes', '@sympal_themes')
      ->setCredentials(array('ManageThemes'));
  }

  /**
   * Listens to the sympal.load_config_form and allows for customization
   * of the config form
   */
  public function loadConfigForm(sfEvent $event)
  {
    $form = $event->getSubject();

    $array = $this->_sympalContext->getService('theme_form_toolkit')->getThemeWidgetAndValidator();
    $form->addSetting('theme', 'default_theme', 'Default Theme', $array['widget'], $array['validator']);
  }
}<commit_msg>Fixing bad variable reference in admin menu<commit_after><?php

/**
 * Plugin configuration for the theme plugin
 * 
 * @package     sfSympalThemePlugin
 * @subpackage  config
 * @author      <NAME> <<EMAIL>>
 * @since       2010-03-27
 * @version     svn:$Id$ $Author$
 */
class sfSympalThemePluginConfiguration extends sfPluginConfiguration
{
  protected
    $_sympalContext;

  public function initialize()
  {
    // Only bootstrap if theming is disabled
    if (sfSympalConfig::get('theme', 'enabled'))
    {
      $this->dispatcher->connect('sympal.load', array($this, 'bootstrap'));
      $this->dispatcher->connect('controller.change_action', array($this, 'listenControllerChangeAction'));
    }
    
    $themeUser = new sfSympalThemeUser();
    $this->dispatcher->connect('user.method_not_found', array($themeUser, 'extend'));

    // Connect to the sympal.load_admin_menu event
    $this->dispatcher->connect('sympal.load_admin_menu', array($this, 'setupAdminMenu'));

    // Connect to the sympal.load_config_form evnet
    $this->dispatcher->connect('sympal.load_config_form', array($this, 'loadConfigForm'));
  }
  
  /**
   * Listens to sympal.load. Bootstraps the plugin
   */
  public function bootstrap(sfEvent $event)
  {
    $this->_sympalContext = $event->getSubject();
    
    // extend the actions class to sfSympalThemeActions
    $actionObject = new sfSympalThemeActions();
    $this->dispatcher->connect('component.method_not_found', array($actionObject, 'extend'));
    
    $themeDispatcher = $this->_sympalContext->getService('theme_dispatcher');
    $theme = $themeDispatcher->getThemeForRequest($this->_sympalContext->getSymfonyContext());
    
    if ($theme)
    {
      $this->_sympalContext->getService('theme_manager')->setCurrentTheme($theme);
    }
  }

  /**
   * Listens to the controller.change_action event to set the correct theme
   * when the action changes
   * 
   * @param sfEvent $event The controller.change_action event object
   */
  public function listenControllerChangeAction(sfEvent $event)
  {
    $sympalContext = sfSympalContext::getInstance();
    $themeDispatcher = $sympalContext->getService('theme_dispatcher');
    $theme = $themeDispatcher->getThemeForRequest($sympalContext->getSymfonyContext());
  }

  /**
   * Listens to the sympal.load_admin_menu to configure the admin menu
   */
  public function setupAdminMenu(sfEvent $event)
  {
    $menu = $event->getSubject();
    
    $administration = $menu->getChild('administration');
    
    $administration->addChild('Themes', '@sympal_themes')
      ->setCredentials(array('ManageThemes'));
  }

  /**
   * Listens to the sympal.load_config_form and allows for customization
   * of the config form
   */
  public function loadConfigForm(sfEvent $event)
  {
    $form = $event->getSubject();

    $array = $this->_sympalContext->getService('theme_form_toolkit')->getThemeWidgetAndValidator();
    $form->addSetting('theme', 'default_theme', 'Default Theme', $array['widget'], $array['validator']);
  }
}
{'fraction_non_alphanumeric': 0.13752718755228374, 'fraction_numerical': 0.002676928224861971, 'mean_word_length': 4.144578313253012, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 76, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3742383', 'n_tokens_mistral': 1779, 'n_tokens_neox': 1731, 'n_words': 350}