getInstance() public static method

Retrieves the singleton instance of this class.
public static getInstance ( string $name = null, string $class = __CLASS__ ) : sfContext
$name string The name of the sfContext to retrieve.
$class string The context class to use (sfContext by default)
return sfContext An sfContext implementation instance.
 /**
  * Add fallback query criteria to $criteria
  *
  * @param Criteria $criteria
  * @param array $options
  * @return QubitQuery array of objects
  */
 public static function addFallbackCriteria($criteria, $fallbackClassName, $options = array())
 {
     if (isset($options['culture'])) {
         $culture = $options['culture'];
     } else {
         $culture = sfContext::getInstance()->user->getCulture();
     }
     // Expose class constants so we can call them using a dynamic class name
     $fallbackClass = new ReflectionClass($fallbackClassName);
     $fallbackClassI18n = new ReflectionClass("{$fallbackClassName}I18n");
     // Add fallback columns (calculated)
     $criteria = self::addFallbackColumns($criteria, $fallbackClassI18n->getName());
     // Get i18n "CULTURE" column name, with "<tablename>." stripped off the front
     $cultureColName = str_replace($fallbackClassI18n->getConstant('TABLE_NAME') . '.', '', $fallbackClassI18n->getConstant('CULTURE'));
     // Build join strings
     $currentJoinString = 'current.id AND current.' . $cultureColName . ' = \'' . $culture . '\'';
     $sourceJoinString = 'source.id AND source.' . $cultureColName . ' = ' . $fallbackClass->getConstant('SOURCE_CULTURE');
     $sourceJoinString .= ' AND source.' . $cultureColName . ' <> \'' . $culture . '\'';
     // Build fancy criteria to get fallback values
     $criteria->addAlias('current', $fallbackClassI18n->getConstant('TABLE_NAME'));
     $criteria->addAlias('source', $fallbackClassI18n->getConstant('TABLE_NAME'));
     $criteria->addJoin(array($fallbackClass->getConstant('ID'), 'current.' . $cultureColName), array('current.id', '\'' . $culture . '\''), Criteria::LEFT_JOIN);
     $criteria->addJoin(array($fallbackClass->getConstant('ID'), 'source.' . $cultureColName), array('source.id', $fallbackClass->getConstant('SOURCE_CULTURE') . ' AND source.' . $cultureColName . ' <> \'' . $culture . '\''), Criteria::LEFT_JOIN);
     return $criteria;
 }
 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();
 }
    /**
     * @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;
    }
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";
    }
}
Example #5
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;
     }
 }
  /**
   * 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;
  }
 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]');
 }
Example #8
0
 public static function getGuard()
 {
     if (sfContext::getInstance()->getUser()->isAuthenticated()) {
         return sfContext::getInstance()->getUser()->getGuardUser();
     }
     return null;
 }
 static function get($key, $default = null, $class = false)
 {
     $tagger = sfContext::getInstance()->getViewCacheManager()->getTagger();
     if ($tagger instanceof sfTagCache) {
         $cache_key = 'registry_' . $key;
         $value = $tagger->get($cache_key);
         if (is_array($value)) {
             if ($class) {
                 return $value;
             } else {
                 return reset($value);
             }
         }
     }
     $reg = Doctrine_Core::getTable('Registry')->createQuery('r')->where('r.regkey = ?', $key)->fetchOne();
     if (!$reg) {
         return $default;
     }
     if ($tagger instanceof sfTagCache) {
         $tagger->set($cache_key, array($reg['value'], $reg['regclass']), null, array($reg->getTagName() => $reg->getObjectVersion()));
     }
     if ($class) {
         return array($reg['value'], $reg['regclass']);
     } else {
         return $reg['value'];
     }
 }
 public function postValidateForm($validator, $values)
 {
     if (isset($values['promo_code'])) {
         $promo_code = PromoCodeTable::getInstance()->findOneByCode($values['promo_code']);
         if (!$promo_code) {
             throw new sfValidatorError($validator, 'Promotion Code is invalid');
         } else {
             $values['account_type'] = $promo_code->account_type;
         }
     }
     /** @var sfGuardUser $user */
     $user = sfGuardUserTable::getInstance()->createQuery('u')->where('u.email_address = ?', $values['email_address'])->fetchOne();
     if ($user && $values['password']) {
         if ($user->getIsActive() && $user->checkPassword($values['password'])) {
             sfContext::getInstance()->getUser()->signIn($user);
             sfContext::getInstance()->getController()->redirect('/project');
         } else {
             throw new sfValidatorError($validator, 'The email and/or password is invalid');
         }
     }
     $email = $values['email_address'];
     $domain = strtolower(substr($email, strpos($email, '@') + 1));
     if (DomainTable::getInstance()->findOneBy('name', $domain)) {
         $error = new sfValidatorError($validator, 'That looks like a personal email address. Please use your company email.');
         throw new sfValidatorErrorSchema($validator, array('email_address' => $error));
     }
     return $values;
 }
 public function executeAjaxSearch(sfWebRequest $request)
 {
     if ($request->hasParameter('models')) {
         $query = Doctrine::getTable('rtIndex')->getStandardSearchComponentInQuery($request->getParameter('q', ''), $this->getUser()->getCulture(), Doctrine::getTable('rtIndex')->getModelTypeRestrictionQuery(explode(',', $request->getParameter('models'))));
     } else {
         $query = Doctrine::getTable('rtIndex')->getBasePublicSearchQuery($request->getParameter('q'), $this->getUser()->getCulture());
     }
     $this->logMessage('{testing}' . $request->getParameter('q', ''), 'notice');
     $query->limit(100);
     $rt_indexes = $query->execute();
     $routes = $this->getContext()->getRouting()->getRoutes();
     $items = array();
     foreach ($rt_indexes as $rt_index) {
         $route = Doctrine_Inflector::tableize($rt_index->getCleanModel()) . '_show';
         $url = '';
         if (isset($routes[Doctrine_Inflector::tableize($rt_index->getCleanModel()) . '_show'])) {
             $url = sfContext::getInstance()->getController()->genUrl(array('sf_route' => $route, 'sf_subject' => $rt_index->getObject()));
             $url = str_replace('/frontend_dev.php', '', $url);
         }
         $object = $rt_index->getObject();
         $item = array('title' => $object->getTitle(), 'link' => $url);
         $item['placeholder'] = $object instanceof rtSnippet ? '![' . $object->getTitle() . '](snippet:' . $object->getCollection() . ')' : '';
         $items[] = $item;
     }
     return $this->returnJSONResponse(array('status' => 'success', 'items' => $items), $request);
 }
 public function getContext()
 {
     if (!class_exists('sfContext') || !\sfContext::getInstance()) {
         $this->initialiseSf1Context();
     }
     return \sfContext::getInstance();
 }
 /**
  * Constructor
  */
 public function __construct(Invoice $invoice)
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url'));
     $defaults = array('WMI_MERCHANT_ID' => sfConfig::get('app_w1_merchant'), 'WMI_PAYMENT_AMOUNT' => sprintf('%01.2f', $invoice->getAmount()), 'WMI_CURRENCY_ID' => 980, 'WMI_PAYMENT_NO' => $invoice->getId(), 'WMI_DESCRIPTION' => $invoice->geDescription(), 'WMI_SUCCESS_URL' => url_for('payment_w1_success', array(), true), 'WMI_FAIL_URL' => url_for('payment_w1_fail', array(), true), 'WMI_PTENABLED' => 'CashTerminalUAH');
     $defaults['WMI_SIGNATURE'] = $this->createSign($defaults);
     parent::__construct($defaults);
 }
Example #14
0
 public function configure()
 {
     $this->setWidgets(array('file' => new sfWidgetFormInputFile(), 'imageName' => new sfWidgetFormInputText()));
     $this->widgetSchema->setLabels(array('file' => sfContext::getInstance()->getI18N()->__('็”ปๅƒใƒ•ใ‚กใ‚คใƒซ'), 'imageName' => sfContext::getInstance()->getI18N()->__('็”ปๅƒใƒ•ใ‚กใ‚คใƒซๅ')));
     $this->setValidators(array('file' => new opValidatorImageFile(), 'imageName' => new sfValidatorRegex(array('pattern' => '/^[\\w\\-]+$/'))));
     $this->widgetSchema->setNameFormat('image[%s]');
 }
 /**
  * Executes this configuration handler.
  *
  * @param array $configFiles An array of absolute filesystem path to a configuration file
  *
  * @return string Data to be written to a cache file
  *
  * @throws sfConfigurationException If a requested configuration file does not exist or is not readable
  * @throws sfParseException If a requested configuration file is improperly formatted
  * @throws sfInitializationException If a generator.yml key check fails
  */
 public function execute($configFiles)
 {
     // parse the yaml
     $config = self::getConfiguration($configFiles);
     if (!$config) {
         return '';
     }
     if (!isset($config['generator'])) {
         throw new sfParseException(sprintf('Configuration file "%s" must specify a generator section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0]));
     }
     $config = $config['generator'];
     if (!isset($config['class'])) {
         throw new sfParseException(sprintf('Configuration file "%s" must specify a generator class section under the generator section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0]));
     }
     foreach (array('fields', 'list', 'edit') as $section) {
         if (isset($config[$section])) {
             throw new sfParseException(sprintf('Configuration file "%s" can specify a "%s" section but only under the param section.', isset($configFiles[1]) ? $configFiles[1] : $configFiles[0], $section));
         }
     }
     // generate class and add a reference to it
     $generatorManager = new sfGeneratorManager(sfContext::getInstance()->getConfiguration());
     // generator parameters
     $generatorParam = isset($config['param']) ? $config['param'] : array();
     // hack to find the module name (look for the last /modules/ in path)
     preg_match('#.*/modules/([^/]+)/#', $configFiles[0], $match);
     $generatorParam['moduleName'] = $match[1];
     // compile data
     $retval = "<?php\n" . "// auto-generated by sfGeneratorConfigHandler\n" . "// date: %s\n%s\n";
     $retval = sprintf($retval, date('Y/m/d H:i:s'), self::getContent($generatorManager, $config['class'], $generatorParam));
     return $retval;
 }
Example #16
0
 /**
  * Authenticates this user and signs them in, if the API key or session is valid
  * 
  * Overridden because currently sfAltumoPlugin's version is specific to ApiUser.
  * @todo that behavior needs to be changed and updated on applications that rely on it.
  * 
  * @param sfActions $action
  * @return void
  * @throws Exception if validation fails.
  */
 public function authenticate()
 {
     //require SSL, if applicable
     $this->assertSslApiRequest();
     //authenticate via the API key, if provided
     $api_key = $this->getHttpRequestHeader('Authorization', null);
     if (!is_null($api_key)) {
         if (preg_match('/\\s*Basic\\s+(.*?)\\s*$/im', $api_key, $regs)) {
             $api_key = $regs[1];
             $user = \UserQuery::create()->filterByActive(true)->filterByApiKey($api_key)->findOne();
             if (!$user) {
                 throw new \Exception('Unknown or inactive user.');
             }
             $sf_guard_user = $user->getsfGuardUser();
             if ($sf_guard_user->getIsActive()) {
                 \sfContext::getInstance()->getUser()->signIn($sf_guard_user, false);
                 return;
             } else {
                 throw new \Exception('Unknown or inactive user.');
             }
         } else {
             throw new \Exception('API key format not recognized');
         }
     }
     //try to authenticate via the session, if the api key was not provided
     if (is_null($api_key)) {
         $sf_user = sfContext::getInstance()->getUser();
         if (!$sf_user || !$sf_user->isAuthenticated()) {
             throw new \Exception('Your session is not valid for API usage.');
         }
     } else {
         throw new \Exception('Please provide either a valid session or valid API key.');
     }
 }
 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);
 }
 /**
  * Renders the widget.
  *
  * @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::getInstance()->getConfiguration()->loadHelpers(array('I18N'));
     $default_text = $this->getOption('default_text', null);
     if ($default_text) {
         $default_text = __($default_text);
     } else {
         $default_text = $this->getOption('multiple') ? __("Select Some Options") . '...' : __("Select an Option") . '...';
     }
     $align_right = $this->getOption('align_right', null);
     if ($align_right) {
         if (!isset($attributes['class'])) {
             $attributes['class'] = '';
         }
         $attributes['class'] .= ' chzn-select chzn-rtl';
     }
     if (!isset($attributes['style'])) {
         $attributes['style'] = 'min-width: 300px; max-width: 700px;';
     } else {
         $attributes['style'] = '; min-width: 300px; max-width: 700px;';
     }
     $html = parent::render($name, $value, $attributes, $errors);
     $html .= dcWidgetFormChosenChoice::getWidgetInitializationJS($this->generateId($name), $value, $default_text, $this->getOption('config'));
     return $html;
 }
 /**
  * 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')));
 }
 public function executeSidebar(sfWebRequest $request)
 {
     $route = sfContext::getInstance()->getRouting()->getCurrentRouteName();
     $this->route = $route;
     $id = $request->getParameter('catalogId');
     $stm = Propel::getConnection()->prepare('
         SELECT title,id FROM category WHERE parent_id=4
     ');
     $stm->execute();
     $menu = $stm->fetchAll(PDO::FETCH_OBJ);
     $this->menu = $menu;
     $stm = Propel::getConnection()->prepare('
         SELECT
             title,id
         FROM
             category_has_product
         INNER JOIN product ON product.id = category_has_product.product_id
         WHERE
             category_has_product.category_id = :id
     ');
     $stm->bindParam(':id', $id);
     $stm->execute();
     $product = $stm->fetchAll(PDO::FETCH_OBJ);
     $this->product = $product;
 }
 /**
  * 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 retrieveByMemberIdAndProfileName($memberId, $profileName, $hydrationMode = Doctrine::HYDRATE_RECORD)
 {
     static $queryCacheHash;
     $profileId = Doctrine::getTable('Profile')->getProfileNameById($profileName);
     if ($profileId) {
         $q = $this->createQuery()->where('member_id = ?', $memberId)->andWhere('profile_id = ?', $profileId);
         if (!$queryCacheHash) {
             $result = $q->fetchOne(array(), $hydrationMode);
             $queryCacheHash = $q->calculateQueryCacheHash();
         } else {
             $q->setCachedQueryCacheHash($queryCacheHash);
             $result = $q->fetchOne(array(), $hydrationMode);
         }
         if (Doctrine::HYDRATE_SCALAR == $hydrationMode) {
             if (!$result['MemberProfile_profile_option_id']) {
                 return $result;
             }
             $option = Doctrine::getTable('ProfileOptionTranslation')->createQuery()->select('value')->where('id = ?', $result['MemberProfile_profile_option_id'])->andWhere('lang = ?', sfContext::getInstance()->getUser()->getCulture())->fetchOne(array(), Doctrine::HYDRATE_NONE);
             if ($option) {
                 $result['MemberProfile_value'] = $option[0];
             }
         }
         return $result;
     }
     return null;
 }
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;
}
 /**
  * Constructor
  * @param object         $class
  * @param integer        $maxPerPage
  * @param sfSphinxClient $sphinx
  */
 public function __construct($class, $maxPerPage = 10, sfSphinxClient $sphinx)
 {
     if (sfConfig::get('sf_logging_enabled')) {
         sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent(null, 'application.log', array('Class ' . __CLASS__ . ' is deprecated in favor of sfSphinxPropelPager.', 'priority' => sfLogger::ERR)));
     }
     parent::__construct($class, $maxPerPage, $sphinx);
 }
    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 #26
0
 public function getStartAndEndDates($employeeId)
 {
     $userEmployeeNumber = null;
     $timesheetService = new TimesheetService();
     $timesheets = $timesheetService->getTimesheetByEmployeeId($employeeId);
     $dateOptions = array();
     $dateOptionsToDrpDwn = array();
     $userObj = sfContext::getInstance()->getUser()->getAttribute('user');
     $userId = $userObj->getUserId();
     $userEmployeeNumber = $userObj->getEmployeeNumber();
     if ($userEmployeeNumber == $employeeId) {
         $user = new User();
         $decoratedUser = new EssUserRoleDecorator($user);
     } else {
         $userRoleFactory = new UserRoleFactory();
         $decoratedUser = $userRoleFactory->decorateUserRole($userId, $employeeId, $userEmployeeNumber);
     }
     $i = 0;
     if ($timesheets != null) {
         foreach ($timesheets as $timesheet) {
             $allowedActions = $decoratedUser->getAllowedActions(WorkflowStateMachine::FLOW_TIME_TIMESHEET, $timesheet->getState());
             if (in_array(WorkflowStateMachine::TIMESHEET_ACTION_VIEW, $allowedActions)) {
                 $dateOptions[$i] = $timesheet->getStartDate() . " " . __("to") . " " . $timesheet->getEndDate();
                 $dateOptionsToDrpDwn[$i] = set_datepicker_date_format($timesheet->getStartDate()) . " " . __("to") . " " . set_datepicker_date_format($timesheet->getEndDate());
                 $i++;
             }
         }
     }
     $this->dateOptions = array_reverse($dateOptions);
     return array_reverse($dateOptionsToDrpDwn);
 }
 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]');
 }
Example #28
0
 public function executeDelete()
 {
     $userId = sfContext::getInstance()->getUser()->getAttribute('subscriber_id', null, 'subscriber');
     $this->bikeid = $this->getRequestParameter('bikeid');
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         //delete user_stat and equipment
         $c = new Criteria();
         $c->add(UserStatsPeer::USER_ID, $userId);
         $c->add(UserStatsPeer::BIKE_ID, $this->bikeid);
         $s = UserStatsPeer::doSelectJoinAll($c);
         foreach ($s as $stat) {
             foreach ($stat->getUserStatEquips() as $equip) {
                 $equip->delete();
             }
             $stat->delete();
         }
         //move equipment to shelf
         $c = new Criteria();
         $c->add(UserEquipementPeer::USER_ID, $userId);
         $c->add(UserEquipementPeer::BIKE_ID, $this->bikeid);
         $equip = UserEquipementPeer::doSelect($c);
         foreach ($equip as $e) {
             $e->setBikeId(null);
             $e->save();
         }
         //now delete bike
         $user_bikes = UserBikesPeer::retrieveByPk($this->bikeid);
         $user_bikes->delete();
         return $this->redirect('userbike/index');
     }
 }
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 function isSelf($memberId = null)
 {
     if (is_null($memberId)) {
         $memberId = sfContext::getInstance()->getUser()->getMemberId();
     }
     return (int) $this->getMemberId() === (int) $memberId;
 }