Example #1
0
 public function ExceptionHandler(sfEvent $event)
 {
     $exception = $event->getSubject();
     if (get_class($exception) == 'OAuthException') {
         $response = sfContext::getInstance()->getResponse();
         $response->setContentType('text/html');
         $request = sfContext::getInstance()->getRequest();
         $format = $request->getRequestFormat();
         if (!$format) {
             $format = 'html';
         }
         if ($mimeType = $request->getMimeType($format)) {
             $response->setContentType($mimeType);
         }
         if ($format == 'json') {
             $response->setContentType('text/javascript');
         }
         // By default, symfony set 'application/json' and the response is not show in the brower
         $response->sendHttpHeaders();
         $template = sprintf('error.%s.php', $format);
         $path = dirname(__FILE__) . './../config/error/' . $template;
         $type = get_class($exception);
         $message = $exception->getMessage();
         include $path;
         return true;
     }
 }
 public function contextLoadFactories(sfEvent $event)
 {
     $context = $event->getSubject();
     $context->response->addStylesheet('/css/classic', 'last', array('media' => 'all'));
     $context->response->addStylesheet('/plugins/sfCaribouPlugin/css/style', 'last', array('media' => 'all'));
     $context->response->addJavaScript('/plugins/sfCaribouPlugin/js/navigation', 'last');
 }
 /**
  * Filters form values before they're bound.
  *
  * Re-embeds all dynamically embedded relations to match up with the input values.
  *
  * @param sfEvent $event  A "form.filter_values" event
  * @param array   $values Tainted form values
  */
 public function filterValues(sfEvent $event, $values)
 {
     $form = $event->getSubject();
     $this->reEmbed($form, $values);
     $this->correctValidators($form);
     return $values;
 }
Example #4
0
 /**
  * Listens to the routing.load_configuration event.
  *
  * @param sfEvent An sfEvent instance
  */
 public static function listenToRoutingLoadConfigurationEvent(sfEvent $event)
 {
     $r = $event->getSubject();
     // preprend our routes
     $r->prependRoute('sf_guard_signin', new sfRoute('/login', array('module' => 'sfGuardAuth', 'action' => 'signin')));
     $r->prependRoute('sf_asset_library_dir', new sfRoute('/sfAsset/dir/:dir', array('module' => 'sfAsset', 'action' => 'list', 'dir' => sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media')), array('dir' => '.*?')));
 }
 public function run(sfEvent $event)
 {
     $record = Doctrine_Core::getTable(sfSympalConfig::get('user_model'))->getRecordInstance();
     $this->_dispatcher->notify(new sfEvent($record, 'sympal.user.set_table_definition', array('object' => $record)));
     $this->_symfonyContext = $event->getSubject();
     $this->_invoker->setCache(new sfSympalCache($this->_invoker));
     $this->_invoker->setSymfonyContext($this->_symfonyContext);
     $this->_sympalContext = sfSympalContext::createInstance($this->_symfonyContext, $this->_invoker);
     $this->_invoker->setSympalContext($this->_sympalContext);
     $this->_enableModules();
     $this->_checkInstalled();
     $this->_invoker->initializeTheme();
     $helpers = array('Sympal', 'SympalContentSlot', 'SympalMenu', 'SympalPager', 'I18N', 'Asset', 'Url', 'Partial');
     if ($this->_invoker->isAdminModule()) {
         sfConfig::set('sf_login_module', 'sympal_admin');
         $helpers[] = 'Admin';
     }
     $this->_invoker->getProjectConfiguration()->loadHelpers($helpers);
     $this->_dispatcher->notify(new sfEvent($this, 'sympal.load'));
     new sfSympalContextLoadFactoriesListener($this->_dispatcher, $this->_invoker);
     new sfSympalComponentMethodNotFoundListener($this->_dispatcher, $this->_invoker);
     new sfSympalControllerChangeActionListener($this->_dispatcher, $this->_invoker);
     new sfSympalTemplateFilterParametersListener($this->_dispatcher, $this->_invoker);
     new sfSympalFormMethodNotFoundListener($this->_dispatcher, $this->_invoker);
     new sfSympalFormPostConfigureListener($this->_dispatcher, $this->_invoker);
     new sfSympalFormFilterValuesListener($this->_dispatcher, $this->_invoker);
 }
 public static function listenToCommandPostCommandEvent(sfEvent $event)
 {
     $task = $event->getSubject();
     if ($task->getFullName() === 'apostrophe:migrate') {
         self::migrate();
     }
 }
 public function configureDoctrineConnection(sfEvent $event)
 {
     $parameters = $event->getParameters();
     if ('doctrine2' === $parameters['connection']->getName()) {
         $parameters['connection']->setAttribute(Doctrine_Core::ATTR_VALIDATE, false);
     }
 }
Example #8
0
 public static function listenToRoutingAdminLoadConfigurationEvent(sfEvent $event)
 {
     $r = $event->getSubject();
     $enabledModules = array_flip(sfConfig::get('sf_enabled_modules', array()));
     if (isset($enabledModules['aUserAdmin'])) {
         $r->prependRoute('a_user_admin', new sfDoctrineRouteCollection(array('name' => 'a_user_admin', 'model' => 'sfGuardUser', 'module' => 'aUserAdmin', 'prefix_path' => 'admin/user', 'column' => 'id', 'with_wildcard_routes' => true)));
     }
     if (isset($enabledModules['aGroupAdmin'])) {
         $r->prependRoute('a_group_admin', new sfDoctrineRouteCollection(array('name' => 'a_group_admin', 'model' => 'sfGuardGroup', 'module' => 'aGroupAdmin', 'prefix_path' => 'admin/group', 'column' => 'id', 'with_wildcard_routes' => true)));
     }
     if (isset($enabledModules['aPermissionAdmin'])) {
         $r->prependRoute('a_permission_admin', new sfDoctrineRouteCollection(array('name' => 'a_permission_admin', 'model' => 'sfGuardPermission', 'module' => 'aPermissionAdmin', 'prefix_path' => 'admin/permission', 'column' => 'id', 'with_wildcard_routes' => true)));
     }
     // Used by apostrophe:deploy to clear the APC cache, needs a consistent path
     if (isset($enabledModules['aSync'])) {
         $r->prependRoute('a_sync', new sfRoute('/async/:action', array('module' => 'aSync', 'url' => '/async/:action')));
     }
     // Right now the admin engine isn't terribly exciting,
     // it just redirects away from the /admin page that belongs to it.
     // Longer URLs starting with /admin are left alone as they often belong
     // to non-engine modules like the users module
     if (isset($enabledModules['aAdmin'])) {
         $r->prependRoute('a_admin', new aRoute('/', array('module' => 'aAdmin', 'action' => 'index', 'url' => '/')));
     }
 }
Example #9
0
 public function listenToContextLoadedEvent(sfEvent $e)
 {
     $this->setBrowser($e->getSubject()->get('browser'));
     if (!$e->getSubject()->getI18n()->cultureExists($this->getCulture())) {
         $this->setCulture(sfConfig::get('sf_default_culture'));
     }
 }
 public static function listenToRoutingLoadConfigurationEvent(sfEvent $event)
 {
     $routing = $event->getSubject();
     $routing->prependRoute('image_nodefaults', new sfRoute('/image/*', array('module' => 'default', 'action' => 'error')));
     $routing->prependRoute('image', new sfRoute('/cache/img/:format/:width_:height/:filename.:noice', array('module' => 'image', 'action' => 'index', 'width' => 'w', 'height' => 'h'), array('filename' => '^[\\w\\d_\\.\\-]+$', 'format' => '^(jpg|png|gif)$', 'width' => '^w[0-9]*$', 'height' => '^h[0-9]*$', 'noice' => '^(jpg|png|gif)$'), array('segment_separators' => array('_', '/', '.'), 'variable_regex' => '[a-zA-Z0-9]+')));
     $routing->prependRoute('image_with_suffix', new sfRoute('/cache/img/:format/:width_:height_:suffix/:filename.:noice', array('module' => 'image', 'action' => 'index', 'width' => 'w', 'height' => 'h'), array('filename' => '^[\\w\\d_\\.\\-]+$', 'format' => '^(jpg|png|gif)$', 'width' => '^w[0-9]*$', 'height' => '^h[0-9]*$', 'suffix' => 'sq', 'noice' => '^(jpg|png|gif)$'), array('segment_separators' => array('_', '/', '.'), 'variable_regex' => '[a-zA-Z0-9]+')));
 }
 public function processApplicationConfirm(sfEvent $event)
 {
     $app = sfConfig::get('sf_app');
     $invite = Doctrine::getTable('ApplicationInvite')->find($event['id']);
     if (!$invite) {
         return false;
     }
     $application = $invite->getApplication();
     if ('pc_frontend' === $app) {
         if (!$application->getIsPc()) {
             return false;
         }
     } elseif ('mobile_frontend' === $app) {
         if (!$application->getIsMobile()) {
             return false;
         }
     }
     if ($event['is_accepted']) {
         $action = $event->getSubject();
         if ($action instanceof sfAction) {
             $action->redirect('@application_add?id=' . $application->getId() . '&invite=' . $invite->getId());
         }
     } else {
         $invite->delete();
         $event->setReturnValue("You have just rejected request of invitation to app.");
     }
     return true;
 }
 /**
  * Listens to the routing.load_configuration event.
  *
  * @param sfEvent An sfEvent instance
  */
 public static function listenToRoutingLoadConfigurationEvent(sfEvent $event)
 {
     $r = $event->getSubject();
     // preprend our routes
     //    $r->prependRoute('download_packed_files','/packed/:type/:cachefilename/packed.*', array( 'module' => 'sfCombineFilter', 'action' => 'download', 'target_action' => 'index'));
     $r->prependRoute('download_packed_files', new sfRoute('/packed/:type/:cachefilename/packed.*', array('module' => 'sfCombineFilter', 'action' => 'download', 'target_action' => 'index')));
 }
Example #13
0
 public static function SendExceptionNotify(sfEvent $event)
 {
     $routing = sfContext::getInstance()->getRouting();
     $uri = $routing->getCurrentInternalUri();
     $text = 'Ошибка: ' . $event->getSubject()->getMessage() . ' по адресу ' . $uri;
     sfJabber::SendMessage($text);
 }
 /**
  * configure - configures the routing when main project will load it
  *
  * @listen routing.load_configuration
  *
  * @param  sfEvent $e
  * @return void
  */
 public static function configure(sfEvent $event)
 {
     self::checkSymfonyVersion();
     $routing = $event->getSubject();
     $prefix = self::getBaseRoute();
     self::addRoute($routing, 'asset', $prefix . '/:name', array('module' => 'sfDynamics', 'action' => 'asset'), array(), array('segment_separators' => array('/')));
 }
 /**
  * Listens to the routing.load_configuration event.
  *
  * @param sfEvent An sfEvent instance
  */
 public static function listenToRoutingLoadConfigurationEvent(sfEvent $event)
 {
     $routing = $event->getSubject();
     $config = sfConfig::get('app_swToolbox_cross_link_application', array());
     if (!sfContext::hasInstance() || !$routing instanceof swPatternRouting) {
         return;
     }
     $configuration = sfContext::getInstance()->getConfiguration();
     $env = $configuration->getEnvironment();
     $app = $configuration->getApplication();
     if (!array_key_exists('enabled', $config[$app]) || !$config[$app]['enabled']) {
         return;
     }
     if (!array_key_exists('load', $config[$app]) || !is_array($config[$app]['load'])) {
         return;
     }
     foreach ($config[$app]['load'] as $app_to_load => $options) {
         $envs = $options['env'];
         $routes = isset($options['routes']) && is_array($options['routes']) ? $options['routes'] : array();
         if (!array_key_exists($env, $envs)) {
             continue;
         }
         $config_handler = new swCrossApplicationRoutingConfigHandler();
         $config_handler->setApp($app_to_load);
         $config_handler->setHost($envs[$env]);
         $config_handler->setRoutes($routes);
         $routes = $config_handler->evaluate(array(sfConfig::get('sf_apps_dir') . '/' . $app_to_load . '/config/routing.yml'));
         foreach ($routes as $name => $route) {
             $routing->appendRoute($name, $route);
         }
     }
 }
 /**
  * Listens to the routing.load_configuration event.
  *
  * @param sfEvent An sfEvent instance
  * @static
  */
 public static function listenToRoutingLoadConfigurationEvent(sfEvent $event)
 {
     $r = $event->getSubject();
     /* @var $r sfPatternRouting */
     // preprend our routes
     $r->prependRoute('sf_oauth_server_consumer_sfOauthAdmin', new sfDoctrineRouteCollection(array('name' => 'sf_oauth_server_consumer_sfOauthAdmin', 'model' => 'sfOauthServerConsumer', 'module' => 'sfOauthAdmin', 'prefix_path' => '/oauth/admin', 'with_wildcard_routes' => true)));
 }
  /**
   * Adds routes for the kdGuardAuthFacebookConnect plugin.
   * 
   * @param sfEvent $event 
   */
  static public function addRouteForkdGuardAuthFacebookConnect(sfEvent $event)
  {
    $r = $event->getSubject();

    $r->prependRoute('kd_guard_signin', new sfRoute('/guard/fb_signin', array('module' => 'kdGuardAuthFacebookConnect', 'action' => 'signin')));
    $r->prependRoute('kd_guard_signout', new sfRoute('/guard/fb_signout', array('module' => 'kdGuardAuthFacebookConnect', 'action' => 'signout')));
  }
 /**
  * Listens to the routing.load_configuration event.
  *
  * @param sfEvent An sfEvent instance
  */
 public static function listenToRoutingLoadConfigurationEvent(sfEvent $event)
 {
     $r = $event->getSubject();
     // preprend our routes
     //$r->prependRoute('sf_captchagd', '/captcha', array('module' => 'sfCaptchaGD', 'action' => 'GetImage'));
     $r->prependRoute('sf_captchagd', new sfRequestRoute('/captcha', array('module' => 'sfCaptchaGD', 'action' => 'GetImage')));
 }
 public static function listenToMediaLibraryControlMenuEvent(sfEvent $event)
 {
     /** @var dmMediaLibraryControlMenu */
     $media_library_menu = $event->getSubject();
     $media_library_menu->addChild($media_library_menu->getI18n()->__('Add multiple files'), $media_library_menu->getHelper()->link('+/dmMediaUploadifyerAdmin/newMultipleFile?folder_id=' . $event['folder']->id)->set('.new_multiple_file.uploadify_dialog_me.s16.s16_file_add'))->end();
     dmContext::getInstance()->getResponse()->addJavascript('dmMediaUploadifyerPlugin.adminCtrl');
 }
Example #20
0
 /**
  * Listens to the routing.load_configuration event.
  *
  * @param sfEvent An sfEvent instance
  */
 public static function listenToRoutingLoadConfigurationEvent(sfEvent $event)
 {
     $r = $event->getSubject();
     $r->prependRoute('bh_ldap_signin', new sfRoute('/login', array('module' => 'bhLDAPAuth', 'action' => 'signin')));
     $r->prependRoute('sf_guard_signin', new sfRoute('/login', array('module' => 'bhLDAPAuth', 'action' => 'signin')));
     parent::listenToRoutingLoadConfigurationEvent($event);
 }
 /**
  * Automatic plugin modules and helper loading
  *
  * @param  sfEvent  $event
  */
 public function listenToContextLoadFactories(sfEvent $event)
 {
     // Enable module automatically
     sfConfig::set('sf_enabled_modules', array_merge(sfConfig::get('sf_enabled_modules', array()), array('sfEditableComponent')));
     // Load helper as well
     $event->getSubject()->getConfiguration()->loadHelpers(array('sfEditable'));
 }
 /**
  * Listen the context load factories to get the configure service after the service container is available
  *
  * @param sfEvent $event
  *
  * @return void
  */
 public function listenContextLoadFactoriesEvent(sfEvent $event)
 {
     $context = $event->getSubject();
     /* @var $context sfContext */
     $this->setLogger($context->getService($this->loggerServiceId));
     $this->dispatcher->disconnect('context.load_factories', array($this, 'listenContextLoadFactoriesEvent'));
 }
 /**
  * Clears the super cache by listening to the task.cache.clear event.
  *
  * @param sfEvent An sfEvent instance
  */
 public static function clearCache(sfEvent $event)
 {
     $config = sfFilterConfigHandler::getConfiguration($event['app']->getConfigPaths('config/filters.yml'));
     $event->getSubject()->logSection('cache', 'Clearing super cache');
     // find super cache configuration
     $found = false;
     $cacheDir = 'cache';
     foreach ($config as $value) {
         if ('sfSuperCacheFilter' == $value['class']) {
             $found = true;
             if (isset($value['param']['cache_dir'])) {
                 $cacheDir = $value['param']['cache_dir'];
             }
             break;
         }
     }
     if ($found) {
         // clear the cache
         $cacheDir = sfConfig::get('sf_web_dir') . '/' . $cacheDir;
         if (is_dir($cacheDir)) {
             // remove cache files
             $event->getSubject()->getFilesystem()->remove(sfFinder::type('file')->ignore_version_control()->discard('.sf')->in($cacheDir));
         }
     }
 }
Example #24
0
 public static function listenToRoutingLoadConfigurationEvent(sfEvent $event)
 {
     $r = $event->getSubject();
     if (aMediaTools::getOption("routes_register") && in_array('aMedia', sfConfig::get('sf_enabled_modules'))) {
         // Since the media plugin is now an engine, we need our own
         // catch-all rule for administrative URLs in the media area.
         // Prepending it first means it matches last
         $r->prependRoute('a_media_other', new aRoute('/:action', array('module' => 'aMedia')));
         $r->prependRoute('a_media_image_show', new aRoute('/view/:slug', array('module' => 'aMedia', 'action' => 'show'), array('slug' => '^[\\w\\-]+$')));
         // Allow permalinks for PDF originals
         $r->prependRoute('a_media_image_original', new sfRoute('/uploads/media_items/:slug.original.:format', array('module' => 'aMediaBackend', 'action' => 'original'), array('slug' => '^[\\w\\-]+$', 'format' => '^(jpg|png|gif|pdf)$')));
         $r->prependRoute('a_media_image', new sfRoute('/uploads/media_items/:slug.:width.:height.:resizeType.:format', array('module' => 'aMediaBackend', 'action' => 'image'), array('slug' => '^[\\w\\-]+$', 'width' => '^\\d+$', 'height' => '^\\d+$', 'resizeType' => '^\\w$', 'format' => '^(jpg|png|gif)$')));
         // What we want:
         // /media   <-- everything
         // /image   <-- media of type image
         // /video   <-- media of type video
         // /tag/tagname <-- media with this tag
         // /image/tag/tagname <-- images with this tag
         // /video/tag/tagname <-- video with this tag
         // /media?search=blah blah blah  <-- searches are full of
         //                                   dirty URL-unfriendly characters and
         //                                   are traditionally query strings.
         $r->prependRoute('a_media_index', new aRoute('/', array('module' => 'aMedia', 'action' => 'index')));
         $r->prependRoute('a_media_index_type', new aRoute('/:type', array('module' => 'aMedia', 'action' => 'index'), array('type' => '(image|video)')));
         $r->prependRoute('a_media_index_category', new aRoute('/category/:category', array('module' => 'aMedia', 'action' => 'index'), array('category' => '.*')));
         $r->prependRoute('a_media_index_tag', new aRoute('/tag/:tag', array('module' => 'aMedia', 'action' => 'index'), array('tag' => '.*')));
         $r->prependRoute('a_media_select', new aRoute('/select', array('class' => 'aRoute', 'module' => 'aMedia', 'action' => 'select')));
         $r->prependRoute('a_media_info', new sfRoute('/info', array('module' => 'aMediaBackend', 'action' => 'info')));
         $r->prependRoute('a_media_tags', new sfRoute('/tags', array('module' => 'aMediaBackend', 'action' => 'tags')));
         $r->prependRoute('a_media_upload_images', new aRoute('/uploadImages', array('module' => 'aMedia', 'action' => 'uploadImages')));
         $r->prependRoute('a_media_edit_images', new aRoute('/editImages', array('module' => 'aMedia', 'action' => 'editImages')));
         $r->prependRoute('a_media_new_video', new aRoute('/newVideo', array('module' => 'aMedia', 'action' => 'newVideo')));
         $r->prependRoute('a_media_edit_video', new aRoute('/editVideo', array('module' => 'aMedia', 'action' => 'editVideo')));
     }
 }
    public function run(sfEvent $event, $content)
    {
        // The following were removed, but should probably be there
        //$request->isXmlHttpRequest()
        //$controller->getRenderMode() != sfView::RENDER_CLIENT ||
        $response = $event->getSubject();
        if (strpos($response->getContentType(), 'html') === false || $response->getStatusCode() == 304 || in_array($response->getStatusCode(), array(302, 301)) || $response->isHeaderOnly()) {
            return $content;
        }
        if ($code = sfSympalConfig::get('google_analytics_code')) {
            $js = <<<EOF
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
\tdocument.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
\tvar pageTracker = _gat._getTracker("{$code}");
\tpageTracker._trackPageview();
} catch(err) {}</script>
EOF;
            return str_replace('</body>', $js . '</body>', $content);
        } else {
            return $content;
        }
    }
Example #26
0
 public static function observeMethodNotFound(sfEvent $event)
 {
     if (method_exists('sfActionExtra', $event['method'])) {
         $args = array_merge(array($event->getSubject()), $event['arguments']);
         return call_user_func_array(array('sfActionExtra', $event['method']), $args);
     }
 }
 /**
  * Listens to the routing.load_configuration event.
  *
  * @param sfEvent An sfEvent instance
  * @static
  */
 public static function listenToRoutingLoadConfigurationEvent(sfEvent $event)
 {
     $r = $event->getSubject();
     // preprend our routes
     $r->prependRoute('knp_sso_signin', new sfRoute('/sso/login', array('module' => 'knpSsoAuth', 'action' => 'signin')));
     $r->prependRoute('knp_sso_signout', new sfRoute('/sso/logout', array('module' => 'knpSsoAuth', 'action' => 'signout')));
 }
 public static function listenToRoutingLoadConfigurationEvent(sfEvent $event)
 {
     $event->getSubject()->prependRoute('izarus_advanced_layout_customize', new sfRoute('/customize/modules', array('module' => 'izarusAdvancedCustomize', 'action' => 'index')));
     $event->getSubject()->prependRoute('izarus_advanced_layout_users', new sfRoute('/customize/permissions', array('module' => 'izarusAdvancedCustomize', 'action' => 'permissions')));
     $event->getSubject()->prependRoute('izarus_advanced_layout_lateral', new sfRoute('/customize/lateral', array('module' => 'izarusAdvancedCustomize', 'action' => 'lateral')));
     $event->getSubject()->prependRoute('izarus_advanced_layout_select_profile', new sfRoute('/p', array('module' => 'izarusAdvancedCustomize', 'action' => 'selectProfile')));
 }
 /**
  * Listens to the response.filter_content event.
  *
  * @param  sfEvent $event   The sfEvent instance
  * @param  string  $context The response content
  *
  * @return string  The filtered response content
  */
 public function filterResponseContent(sfEvent $event, $content)
 {
     if (!sfConfig::get('sf_web_debug')) {
         return $content;
     }
     // log timers information
     $messages = array();
     foreach (sfTimerManager::getTimers() as $name => $timer) {
         $messages[] = sprintf('%s %.2f ms (%d)', $name, $timer->getElapsedTime() * 1000, $timer->getCalls());
     }
     $this->dispatcher->notify(new sfEvent($this, 'application.log', $messages));
     // don't add debug toolbar:
     // * for XHR requests
     // * if 304
     // * if not rendering to the client
     // * if HTTP headers only
     $response = $event->getSubject();
     if (!$this->context->has('request') || !$this->context->has('response') || !$this->context->has('controller') || $this->context->getRequest()->isXmlHttpRequest() || strpos($response->getContentType(), 'html') === false || $response->getStatusCode() == 304 || $this->context->getController()->getRenderMode() != sfView::RENDER_CLIENT || $response->isHeaderOnly()) {
         return $content;
     }
     // add needed assets for the web debug toolbar
     $root = $this->context->getRequest()->getRelativeUrlRoot();
     $assets = sprintf('
   <script type="text/javascript" src="%s"></script>
   <link rel="stylesheet" type="text/css" media="screen" href="%s" />', $root . sfConfig::get('sf_web_debug_web_dir') . '/js/main.js', $root . sfConfig::get('sf_web_debug_web_dir') . '/css/main.css');
     $content = str_ireplace('</head>', $assets . '</head>', $content);
     // add web debug information to response content
     $webDebugContent = $this->webDebug->getResults();
     $count = 0;
     $content = str_ireplace('</body>', $webDebugContent . '</body>', $content, $count);
     if (!$count) {
         $content .= $webDebugContent;
     }
     return $content;
 }
 public static function log500(sfEvent $event)
 {
     $exception = $event->getSubject();
     $context = sfContext::getInstance();
     //print_r($context);
     // is database configured?
     try {
         Propel::getConnection();
         // log exception in db
         //$log = new sfErrorLog();
         //$log->setType('sfError404Exception' == get_class($exception) ? 404 : 500);
         //$log->setClassName(get_class($exception));
         //$log->setMessage(!is_null($exception->getMessage()) ? $exception->getMessage() : 'n/a');
         //$log->setModuleName($context->getModuleName());
         //$log->setActionName($context->getActionName());
         //$log->setExceptionObject($exception);
         //$log->setRequest($context->getRequest());
         //$log->setUri($context->getRequest()->getUri());
         //$log->save();
         // send email
         if (strtolower(SF_ENVIRONMENT) == "prod") {
             $mail = new sfMail();
             $mail->initialize();
             $mail->setMailer('smtp');
             $mail->setHostname(sfConfig::get('app_smtp_server'));
             $mail->setPort(sfConfig::get('app_smtp_port'));
             $mail->setUsername(sfConfig::get('app_smtp_user'));
             $mail->setPassword(sfConfig::get('app_smtp_password'));
             $mail->setCharset('utf-8');
             $mail->setContentType('text/html');
             $mail->setFrom(sfConfig::get('app_email_default_address_from'), sfConfig::get('app_email_default_name_from'));
             $mail->addAddress(sfConfig::get('app_bugreport_mail_recipient1'));
             //$mail->addAddress(sfConfig::get('app_bugreport_mail_recipient2'));
             $mail->setSubject("Automatic: " . sfConfig::get('app_bugreport_mail_subject'));
             $cuerpo = "Type: 500<br />";
             $cuerpo .= "Class: " . get_class($exception) . "<br />";
             $cuerpo .= "Msg: " . (null !== $exception->getMessage()) ? $exception->getMessage() : 'n/a' . "<br />";
             $cuerpo .= "Module: " . $context->getModuleName() . "<br />";
             $cuerpo .= "Action: " . $context->getActionName() . "<br />";
             $cuerpo .= "Uri: " . $context->getRequest()->getUri() . "<br />";
             $cuerpo .= "Referer: " . $context->getRequest()->getReferer() . "<br />";
             $cuerpo .= "Method: " . $context->getRequest()->getMethodName() . "<br />";
             $cuerpo .= "Parameters: <br />";
             foreach ($context->getRequest()->getParameterHolder()->getAll() as $key => $value) {
                 $cuerpo .= "&nbsp;&nbsp;&nbsp;&nbsp;" . $key . ": " . $value . "<br />";
             }
             $cuerpo .= "Cookies: " . $context->getRequest()->getHttpHeader('cookie') . "<br />";
             $cuerpo .= "User Agent: " . $context->getRequest()->getHttpHeader('user-agent') . "<br />";
             $cuerpo .= "Accept: " . $context->getRequest()->getHttpHeader('accept') . "<br />";
             $cuerpo .= "Accept encoding: " . $context->getRequest()->getHttpHeader('accept-encoding') . "<br />";
             $cuerpo .= "Accept language: " . $context->getRequest()->getHttpHeader('accept-language') . "<br />";
             $cuerpo .= "Accept charset: " . $context->getRequest()->getHttpHeader('accept-charset') . "<br />";
             $cuerpo .= "<br/><br/>";
             $mail->setBody($cuerpo);
             $result = $mail->send();
         }
         // end send email
     } catch (PropelException $e) {
     }
 }