Author: Fabien Potencier (fabien.potencier@symfony-project.com)
Author: Sean Kerr (sean@code-box.org)
Inheritance: implements ArrayAccess
 public function setGaufretteService(sfContext $context)
 {
     $gaufrette = new sfGaufretteFactory($this->configuration->getConfigCache());
     // to finish, add it to the current context
     $context->set('gaufrette', $gaufrette);
     return $gaufrette;
 }
 public static function decomposeURL(sfContext $context, sfRequest $request)
 {
     $module = $context->getModuleName();
     $action = $context->getActionName();
     $parameters = $request->getParameterHolder()->getAll();
     return array("module" => $module, "action" => $action, "parameters" => $parameters);
 }
Example #3
0
 public function __construct(sfContext $context, sfEventDispatcher $dispatcher)
 {
     $this->mailer = $context->getMailer();
     $this->dispatcher = $dispatcher;
     $this->serviceContainer = $context->getServiceContainer();
     $this->initialize();
 }
Example #4
0
 /**
  * Initializes this view.
  *
  * @param  sfContext $context     The current application context
  * @param  string    $moduleName  The module name for this view
  * @param  string    $actionName  The action name for this view
  * @param  string    $viewName    The view name
  *
  * @return bool  true, if initialization completes successfully, otherwise false
  */
 public function initialize($context, $moduleName, $actionName, $viewName)
 {
     $this->moduleName = $moduleName;
     $this->actionName = $actionName;
     $this->viewName = $viewName;
     $this->context = $context;
     $this->dispatcher = $context->getEventDispatcher();
     sfOutputEscaper::markClassesAsSafe(array('sfForm', 'sfModelGeneratorHelper'));
     $this->attributeHolder = $this->initializeAttributeHolder();
     $this->parameterHolder = new sfParameterHolder();
     $this->parameterHolder->add(sfConfig::get('mod_' . strtolower($moduleName) . '_view_param', array()));
     $request = $context->getRequest();
     $format = $request->getRequestFormat();
     if (null !== $format) {
         if ('html' != $format) {
             $this->setExtension('.' . $format . $this->getExtension());
         }
         if ($mimeType = $request->getMimeType($format)) {
             $this->context->getResponse()->setContentType($mimeType);
             if ('html' != $format) {
                 $this->setDecorator(false);
             }
         }
     }
     $this->dispatcher->notify(new sfEvent($this, 'view.configure_format', array('format' => $format, 'response' => $context->getResponse(), 'request' => $context->getRequest())));
     // include view configuration
     $this->configure();
     return true;
 }
Example #5
0
 /**
  * Initializes this view.
  *
  * @param  sfContext $context     The current application context
  * @param  string    $moduleName  The module name for this view
  * @param  string    $actionName  The action name for this view
  * @param  string    $viewName    The view name
  *
  * @return bool  true, if initialization completes successfully, otherwise false
  */
 public function initialize($context, $moduleName, $actionName, $viewName)
 {
     $this->moduleName = $moduleName;
     $this->actionName = $actionName;
     $this->viewName = $viewName;
     $this->context = $context;
     $this->dispatcher = $context->getEventDispatcher();
     if (sfConfig::get('sf_logging_enabled')) {
         $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Initialize view for "%s/%s"', $moduleName, $actionName))));
     }
     sfOutputEscaper::markClassAsSafe('sfForm');
     $this->attributeHolder = $this->initializeAttributeHolder();
     $this->parameterHolder = new sfParameterHolder();
     $this->parameterHolder->add(sfConfig::get('mod_' . strtolower($moduleName) . '_view_param', array()));
     $request = $context->getRequest();
     if (!is_null($format = $request->getRequestFormat())) {
         if ('html' != $format) {
             $this->setExtension('.' . $format . $this->getExtension());
         }
         if ($mimeType = $request->getMimeType($format)) {
             $this->context->getResponse()->setContentType($mimeType);
             $this->setDecorator(false);
         }
         $this->dispatcher->notify(new sfEvent($this, 'view.configure_format', array('format' => $format, 'response' => $context->getResponse(), 'request' => $context->getRequest())));
     }
     // include view configuration
     $this->configure();
     return true;
 }
Example #6
0
 /**
  * Initializes this Filter.
  *
  * @param sfContext $context    The current application context
  * @param array     $parameters An associative array of initialization parameters
  *
  * @return boolean true
  */
 public function initialize($context, $parameters = array())
 {
     $this->request = $context->getRequest();
     $this->response = $context->getResponse();
     $this->user = $context->getUser();
     return parent::initialize($context, $parameters);
 }
 /**
  * Initializes this controller.
  *
  * @param sfContext $context A sfContext implementation instance
  */
 public function initialize($context)
 {
     $this->context = $context;
     $this->dispatcher = $context->getEventDispatcher();
     // set max forwards
     $this->maxForwards = sfConfig::get('sf_max_forwards');
 }
    /**
     * Function builds the data for the Extjs Grid, to change the order
     * of circulation overview Columns.
     *
     * @param array $data
     * @param sfContext, Context symfony object
     * @return array $data, resultset
     */
    public function buildUserColumns(array $data, sfContext $context) {
        for($a = 0;$a<count($data);$a++) {
            $data[$a]['column'] = $data[$a]['columntext'];
            $data[$a]['columntext'] = $context->getI18N()->__($data[$a]['columntext'],null,'systemsetting');

        }
        return $data;
    }
 /**
  * Initializes this component.
  *
  * @param sfContext $context The current application context
  *
  * @return boolean true, if initialization completes successfully, otherwise false
  */
 public function initialize($context)
 {
     $this->context = $context;
     $this->varHolder = new sfParameterHolder();
     $this->request = $context->getRequest();
     $this->response = $context->getResponse();
     $this->requestParameterHolder = $this->request->getParameterHolder();
     return true;
 }
Example #10
0
 /**
  * Initializes this controller.
  *
  * @param sfContext $context A sfContext implementation instance
  */
 public function initialize($context)
 {
     $this->context = $context;
     $this->dispatcher = $context->getEventDispatcher();
     if (sfConfig::get('sf_logging_enabled')) {
         $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Initialization')));
     }
     // set max forwards
     $this->maxForwards = sfConfig::get('sf_max_forwards');
 }
 /**
  * Initializes this component.
  *
  * @param sfContext $context    The current application context.
  * @param string    $moduleName The module name.
  * @param string    $actionName The action name.
  *
  * @return boolean true, if initialization completes successfully, otherwise false
  */
 public function initialize($context, $moduleName, $actionName)
 {
     $this->moduleName = $moduleName;
     $this->actionName = $actionName;
     $this->context = $context;
     $this->dispatcher = $context->getEventDispatcher();
     $this->varHolder = new sfParameterHolder();
     $this->request = $context->getRequest();
     $this->response = $context->getResponse();
     $this->requestParameterHolder = $this->request->getParameterHolder();
 }
 /**
  * Initializes the cache manager.
  *
  * @param sfContext $context  Current application context
  * @param sfCache   $cache    An sfCache instance
  */
 public function initialize($context, sfCache $cache)
 {
     $this->context = $context;
     $this->dispatcher = $context->getEventDispatcher();
     $this->controller = $context->getController();
     // empty configuration
     $this->cacheConfig = array();
     // cache instance
     $this->cache = $cache;
     // routing instance
     $this->routing = $context->getRouting();
 }
Example #13
0
 /**
  *
  * @param int $versionId, id of the current workflow
  * @param String $text, the text to replace
  * @param String $culture, the language
  * @param sfContext $context , context object
  */
 public function __construct($versionId, $text, $culture, $context = false) {
     if($context == false) {
         sfLoader::loadHelpers('Date');
     }
     else {
         $context->getConfiguration()->loadHelpers('Date');
     }
     $this->setWorkflow($versionId);
     $this->setWorkflowVersion($versionId);
     $this->culture = $culture;
     $this->theSender = new UserMailSettings($this->workflow['sender_id']);
     $this->newText = $this->replacePlaceholder($text);
 }
Example #14
0
 /**
  * Prepare data for displaxing in grid
  *
  * @param Doctrine_Collection $data, data from database
  * @param sfContext $context
  * @return array $result
  */
 public function buildField(Doctrine_Collection $data, sfContext $context) {
     $result = array();
     $a = 0;
     foreach($data as $item) {
         $result[$a]['#'] = $a+1;
         $result[$a]['id'] = $item->getId();
         $result[$a]['title'] = $item->getTitle();
         $result[$a]['type'] = $context->getI18N()->__($item->getType(),null,'field');
         $write = $item->getWriteprotected() == 1 ? 'yes' : 'no';
         $result[$a++]['writeprotected'] = $context->getI18N()->__($write,null,'field');
     }
     return $result;
 }
Example #15
0
 /**
  * Function creates data for displaying all additional textes in datagrid
  * 
  * @param Doctrine_Collection $data, all records for grid
  * @param sfContext $context, context object
  * @return array $resultset, resultset.
  */
 public function buildAllText(Doctrine_Collection $data, sfContext $context) {
     $a = 0;
     $result = array();
     foreach($data as $item) {
         $result[$a]['#'] = $a+1;
         $result[$a]['title'] = $item->getTitle();
         $result[$a]['contenttype'] = $context->getI18N()->__($item->getContenttype(),null,'additionaltext');
         $result[$a]['rawcontenttype'] = $item->getContenttype();
         $result[$a]['content'] = $item->getContent();
         $result[$a]['isactive'] = $item->getIsactive();
         $result[$a++]['id'] = $item->getId();
     }
     return $result;
 }
 /**
  * Initializes the cache manager.
  *
  * @param sfContext $context  Current application context
  * @param sfCache   $cache    An sfCache instance
  */
 public function initialize($context, sfCache $cache)
 {
     $this->context = $context;
     $this->dispatcher = $context->getEventDispatcher();
     $this->controller = $context->getController();
     if (sfConfig::get('sf_web_debug')) {
         $this->dispatcher->connect('view.cache.filter_content', array($this, 'decorateContentWithDebug'));
     }
     // empty configuration
     $this->cacheConfig = array();
     // cache instance
     $this->cache = $cache;
     // routing instance
     $this->routing = $context->getRouting();
 }
 public function configure()
 {
     $widgets = array();
     $validators = array();
     if ($this->getOption('is_use_id')) {
         $widgets += array('id' => new sfWidgetFormInputText());
         $validators += array('id' => new sfValidatorPass());
     }
     $widgets += array('name' => new sfWidgetFormInputText());
     $validators += array('name' => new opValidatorSearchQueryString(array('required' => false)));
     $culture = sfContext::getInstance()->getUser()->getCulture();
     foreach ($this->getProfiles() as $profile) {
         $profileI18n = $profile->Translation[$culture]->toArray();
         if ($profile->isPreset()) {
             $config = $profile->getPresetConfig();
             $profileI18n['caption'] = sfContext::getInstance()->getI18n()->__($config['Caption']);
         }
         $profileWithI18n = $profile->toArray() + $profileI18n;
         $widget = opFormItemGenerator::generateSearchWidget($profileWithI18n, array('' => '') + $profile->getOptionsArray());
         if ($widget) {
             $widgets[self::$profileFieldPrefix . $profile->getName()] = $widget;
             $validators[self::$profileFieldPrefix . $profile->getName()] = new sfValidatorPass();
         }
     }
     $this->setWidgets($widgets);
     $this->setValidators($validators);
     $this->widgetSchema->setLabel('name', '%nickname%');
     $this->widgetSchema->setNameFormat('member[%s]');
 }
 public function end()
 {
     $this->addCombo();
     @($this->afExtjs->public['init'] .= "\n\t    Ext.QuickTips.init();\n\t    Ext.apply(Ext.QuickTips.getQuickTip(), {\n\t\t    trackMouse: true\n\t\t});\n\t\tExt.form.Field.prototype.msgTarget = 'side';\n\t\tExt.History.init();\n\t\t");
     @($this->afExtjs->public['init'] .= "\n\t\tsetTimeout(function(){\n\t\t\tExt.get('loading').remove();\n\t        Ext.get('loading-mask').fadeOut({remove:true});\n\t    }, 250);\n\t    afApp.urlPrefix = '" . sfContext::getInstance()->getRequest()->getRelativeUrlRoot() . "';\n\t    ");
     $this->afExtjs->init();
 }
    public function sendSlotReachedMail() {
        $sf_i18n = sfContext::getInstance()->getI18N();
        $sf_i18n->setCulture($this->userSettings->userSettings['language']);
        $content['workflow'] = sfContext::getInstance()->getI18N()->__('Workflow' ,null,'slotreachedemail') . ' ' . $this->workflowTemplateSettings['name'];
        $content['currentslot'][0] = sfContext::getInstance()->getI18N()->__('The Slot' ,null,'slotreachedemail');
        $content['currentslot'][1] = $this->currentSlot['name'];
        $content['currentslot'][2] = sfContext::getInstance()->getI18N()->__('has been completed' ,null,'slotreachedemail');

        $content['nextSlot'][0] = sfContext::getInstance()->getI18N()->__('The new Slot' ,null,'slotreachedemail');
        $content['nextSlot'][1] = $this->nextSlot['name'];
        $content['nextSlot'][2] = sfContext::getInstance()->getI18N()->__('has been reached' ,null,'slotreachedemail');
        $subject = sfContext::getInstance()->getI18N()->__('CuteFlow: slot' ,null,'slotreachedemail') . ' ' . $this->nextSlot['name'] . ' ' . sfContext::getInstance()->getI18N()->__('reached' ,null,'slotreachedemail');
        $linkTo = sfContext::getInstance()->getI18N()->__('Direct link to workflow' ,null,'slotreachedemail');
        $this->setSender($this->userSettings->userSettings['systemreplyaddress']);
        $this->setReceiver(array ($this->userSettings->userData['email'] => $this->userSettings->userData['firstname'] . ' ' . $this->userSettings->userData['lastname']));
        $this->setSubject($subject);
        $this->setContentType('text/' . $this->userSettings->userSettings['emailformat']);
        $bodyData = array('text' => $content,
                          'userid' => $this->userSettings->userData['user_id'],
                          'workflowverion' => $this->workflowVersionId,
                          'workflow' => $this->workflowTemplateSettings['id'],
                          'linkto'  => $linkTo
                  );
        $this->setBody(get_partial('workflowdetail/' . $this->userSettings->userSettings['emailformat'] . 'SendSlotReached', $bodyData));
        $this->sendEmail();
    }
Example #20
0
 public function getDayString()
 {
     $context = sfContext::getInstance();
     $i18n = new sfI18N();
     $i18n->initialize($context);
     $i18n->setCulture($context->getUser()->getCulture());
     switch ($this->getDay()) {
         case '1':
             return $i18n->globalMessageFormat->format('_DAY_MONDAY_');
             break;
         case '2':
             return $i18n->globalMessageFormat->format('_DAY_TUESDAY_');
             break;
         case '3':
             return $i18n->globalMessageFormat->format('_DAY_WEDNESDAY_');
             break;
         case '4':
             return $i18n->globalMessageFormat->format('_DAY_THURSDAY_');
             break;
         case '5':
             return $i18n->globalMessageFormat->format('_DAY_FRIDAY_');
             break;
         case '6':
             return $i18n->globalMessageFormat->format('_DAY_SATURDAY_');
             break;
         case '7':
             return $i18n->globalMessageFormat->format('_DAY_SUNDAY_');
             break;
         default:
             return '-';
             break;
     }
 }
function forum_breadcrumb($params, $options = array())
{
    if (!$params) {
        return;
    }
    $first = true;
    $title = '';
    $id = isset($options['id']) ? $options['id'] : 'forum_navigation';
    $html = '<ul id="' . $id . '">';
    foreach ($params as $step) {
        $separator = $first ? '' : sfConfig::get('app_sfSimpleForumPlugin_breadcrumb_separator', ' » ');
        $first = false;
        $html .= '<li>' . $separator;
        $title .= $separator;
        if (is_array($step)) {
            $html .= link_to($step[0], $step[1]);
            $title .= $step[0];
        } else {
            $html .= $step;
            $title .= $step;
        }
        $html .= '</li>';
    }
    $html .= '</ul>';
    sfContext::getInstance()->getResponse()->setTitle($title);
    return $html;
}
Example #22
0
function sw_combine_debug()
{
    if (ProjectConfiguration::getActive()->isDebug()) {
        $response = sfContext::getInstance()->getResponse();
        echo "<!-- DEBUG MODE - \nCombined files : \n" . var_export($response->getCombinedAssets(), 1) . "\n -->\n";
    }
}
 public function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
     $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
     sfContext::createInstance($configuration);
     $conn = Doctrine_Manager::connection();
     // Récupération de toutes les notices.
     $noeuds = $conn->execute("SELECT id, name FROM ei_data_set_structure;");
     $this->log('Récupération des noeuds...OK');
     // Création de la requête permettant
     $this->log('Création de la requête de mise à jour...');
     $requeteToUpdate = "UPDATE ei_data_set_structure SET slug = #{NEW_SLUG} WHERE id = #{NODE_ID};";
     $requeteGlobale = array();
     foreach ($noeuds->fetchAll() as $noeud) {
         // Remplacement SLUG.
         $tmpRequete = str_replace("#{NEW_SLUG}", $conn->quote(MyFunction::sluggifyForXML($noeud["name"])), $requeteToUpdate);
         // Remplacement ID.
         $tmpRequete = str_replace("#{NODE_ID}", $noeud["id"], $tmpRequete);
         // Ajout dans la requête globale.
         $requeteGlobale[] = $tmpRequete;
     }
     // Préparation de la requête.
     $this->log("Préparation de la requête...");
     $requete = implode(" ", $requeteGlobale);
     try {
         // Exécution de la requête.
         $this->log("Exécution de la requête...");
         $conn->execute($requete);
         // Fin.
         $this->log("Processus terminé avec succès.");
     } catch (Exception $exc) {
         $this->log($exc->getMessage());
     }
 }
 /**
  * Gets the internal URI for the current request.
  *
  * @param boolean Whether to give an internal URI with the route name (@route)
  *                or with the module/action pair
  *
  * @return string The current internal URI
  */
 public function getCurrentInternalUri($with_route_name = false)
 {
     if ($this->current_route_name) {
         list($url, $regexp, $names, $names_hash, $defaults, $requirements, $suffix) = $this->routes[$this->current_route_name];
         $request = sfContext::getInstance()->getRequest();
         if ($with_route_name) {
             $internal_uri = '@' . $this->current_route_name;
         } else {
             $internal_uri = $request->getParameter('module', isset($defaults['module']) ? $defaults['module'] : '') . '/' . $request->getParameter('action', isset($defaults['action']) ? $defaults['action'] : '');
         }
         $params = array();
         // add parameters
         foreach ($names as $name) {
             if ($name == 'module' || $name == 'action') {
                 continue;
             }
             $params[] = $name . '=' . $request->getParameter($name, isset($defaults[$name]) ? $defaults[$name] : '');
         }
         // add * parameters if needed
         if (strpos($url, '*')) {
             foreach ($request->getParameterHolder()->getAll() as $key => $value) {
                 if ($key == 'module' || $key == 'action' || in_array($key, $names)) {
                     continue;
                 }
                 $params[] = $key . '=' . $value;
             }
         }
         // sort to guaranty unicity
         sort($params);
         return $internal_uri . ($params ? '?' . implode('&', $params) : '');
     }
 }
 public function configure()
 {
     $employee = $this->getOption('employee');
     $this->allowActivate = $this->getOption('allowActivate');
     $this->allowTerminate = $this->getOption('allowTerminate');
     $empTerminatedId = $employee->termination_id;
     $terminateReasons = $this->__getTerminationReasons();
     //creating widgets
     $widgets = array('date' => new ohrmWidgetDatePickerNew(array(), array('id' => 'terminate_date')), 'reason' => new sfWidgetFormSelect(array('choices' => $terminateReasons)), 'note' => new sfWidgetFormTextArea());
     if (!$this->allowTerminate && !$this->allowActivate) {
         foreach ($widgets as $widget) {
             $widget->setAttribute('disabled', 'disabled');
         }
     }
     $this->setWidgets($widgets);
     $inputDatePattern = sfContext::getInstance()->getUser()->getDateFormat();
     //Setting validators
     $this->setValidators(array('date' => new ohrmDateValidator(array('date_format' => $inputDatePattern, 'required' => true), array('invalid' => 'Date format should be ' . $inputDatePattern)), 'reason' => new sfValidatorChoice(array('required' => true, 'choices' => array_keys($terminateReasons))), 'note' => new sfValidatorString(array('required' => false, 'max_length' => 250, 'trim' => true))));
     $this->setDefault('date', set_datepicker_date_format(date('Y-m-d')));
     $this->setDefault('reason', 1);
     if (!empty($empTerminatedId)) {
         $employeeTerminationRecord = $employee->getEmployeeTerminationRecord();
         $this->setDefault('date', set_datepicker_date_format($employeeTerminationRecord->getDate()));
         $this->setDefault('reason', $employeeTerminationRecord->getReasonId());
         $this->setDefault('note', $employeeTerminationRecord->getNote());
     }
     $this->widgetSchema->setNameFormat('terminate[%s]');
 }
 /**
  * Renders the captcha for widget.
  *
  * @param  string $name        The element name
  * @param  string $value       The this widget is checked if value is not null
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  */
 public function renderCaptcha($name, $value = null, $attributes = array(), $errors = array())
 {
     $captcha = Text_CAPTCHA::factory('Figlet');
     $captcha->init(array('output' => $this->getOption('output'), 'width' => $this->getOption('width'), 'length' => $this->getOption('length'), 'options' => array('font_file' => $this->getOption('font'))));
     sfContext::getInstance()->getStorage()->write('captcha/phrase', $captcha->getPhrase());
     return $this->renderContentTag('div', $captcha->getCAPTCHA(), array_merge($attributes, array('id' => $this->generateId($name) . '_captcha', 'class' => 'captcha')));
 }
  /**
   * Returns an array of Doctrine query events.
   *
   * @return array
   */
  protected function getDoctrineEvents()
  {
    $databaseManager = sfContext::getInstance()->getDatabaseManager();

    $events = array();
    if ($databaseManager)
    {
      foreach ($databaseManager->getNames() as $name)
      {
        $database = $databaseManager->getDatabase($name);
        if ($database instanceof sfDoctrineDatabase && $profiler = $database->getProfiler())
        {
          foreach ($profiler->getQueryExecutionEvents() as $event)
          {
            $events[$event->getSequence()] = $event;
          }
        }
      }
    }

    // sequence events
    ksort($events);

    return $events;
  }
    /**
     * @param  string $name        The element name
     * @param  string $value       The value displayed in this widget
     * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
     * @param  array  $errors      An array of errors for the field
     *
     * @return string An HTML tag string
     *
     * @see sfWidgetForm
     */
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {
        $sfContext = sfContext::getInstance();
        $resp = $sfContext->getResponse();
        $resp->addJavascript('/majaxDoctrineMediaPlugin/js/grid.locale-en.js');
        $resp->addJavascript('/majaxDoctrineMediaPlugin/js/jquery.jqGrid.min.js');
        $resp->addStylesheet('/majaxDoctrineMediaPlugin/css/ui.jqgrid.css');
        $resp->addJavascript('/majaxDoctrineMediaPlugin/js/jquery.majax.media.js');
        $sfContext->getConfiguration()->loadHelpers(array('Url'));
        $id = $this->generateId($name);
        $fetch_url = url_for('majaxMediaAdminModule/list?sf_format=xml');
        $lookup_url = url_for('majaxMediaAdminModule/lookup');
        $out = $this->renderTag('input', array_merge(array('type' => 'text', 'name' => $name, 'value' => $value), $attributes));
        $out .= '<script type="text/javascript">
(function($){
  $(function(){
    var opts = {
      lookup_url: \'' . $lookup_url . '\',
      fetch_url: \'' . $fetch_url . '\',
    };
    $(\'#' . $id . '\').majaxmediaselector(opts);
  });
})(jQuery);
</script>
';
        return $out;
    }
Example #29
0
function get_pager_controls($pager)
{
    $route = url_for(sfContext::getInstance()->getRouting()->getCurrentInternalUri(true));
    if ($pager->getNbResults()) {
        $template = "<div class='pagination'>\n                    <span>Results <em>%first%-%last%<em> of <em>%total%<em></span>\n                    %pagination%\n                 </div>";
        $pagination = "";
        if ($pager->haveToPaginate()) {
            $pagination = "<ul>";
            // Previous
            if ($pager->getPage() != $pager->getFirstPage()) {
                $pagination .= "<li><a href='" . $route . "?page=1'>&lt;&lt;</a></li>";
                $pagination .= "<li><a href='" . $route . "?page=" . $pager->getPreviousPage() . "'>Previous</a></li>";
            }
            // In between
            foreach ($pager->getLinks() as $page) {
                if ($page == $pager->getPage()) {
                    $pagination .= "<li>{$page}</li>";
                } else {
                    $pagination .= "<li><a href='{$route}?page={$page}'>{$page}</a></li>";
                }
            }
            // Next
            if ($pager->getPage() != $pager->getLastPage()) {
                $pagination .= "<li><a href='{$route}?page=" . $pager->getNextPage() . "'>Next</a></li>";
                $pagination .= "<li><a href='{$route}?page=" . $pager->getLastPage() . "'>&gt;&gt;</a></li>";
            }
            $pagination .= "</ul>";
        }
        return strtr($template, array('%first%' => $pager->getFirstIndice(), '%last%' => $pager->getLastIndice(), '%total%' => $pager->getNbResults(), '%pagination%' => $pagination));
    }
}
 public static function getInstance($current_user = false)
 {
     global $CFG;
     if (!$current_user) {
         $role = 'NoUser';
     } else {
         if ($current_user->getRoleManager()->hasPrivilege('GCAdmin')) {
             $role = 'SiteAdmin';
         } else {
             if (sfContext::getInstance()->getModuleName() == 'course' && sfContext::getInstance()->getActionName() == 'view') {
                 return new GcrUserSymfonyCourseViewHeaderType($current_user);
             } else {
                 if ($current_user->getRoleManager()->hasPrivilege('EschoolAdmin')) {
                     $role = 'EschoolAdmin';
                 } else {
                     $role = 'User';
                 }
             }
         }
     }
     if ($CFG->current_app->isMoodle()) {
         $app = 'Mdl';
     } else {
         $app = 'Mhr';
     }
     $classname = 'Gcr' . $app . $role . 'SymfonyHeaderType';
     return new $classname($current_user);
 }