コード例 #1
0
 /**
  * Loads all available tasks.
  *
  * Looks for tasks in the symfony core, the current project and all project plugins.
  *
  * @param sfProjectConfiguration $configuration The project configuration
  */
 protected function loadTasks(sfProjectConfiguration $configuration)
 {
     // Symfony core tasks
     $dirs = array(sfConfig::get('sf_symfony_lib_dir') . '/task');
     // Plugin tasks
     foreach ($configuration->getPluginPaths() as $path) {
         if (is_dir($taskPath = $path . '/lib/task')) {
             $dirs[] = $taskPath;
         }
     }
     // project tasks
     $dirs[] = sfConfig::get('sf_lib_dir') . '/task';
     $finder = sfFinder::type('file')->name('*Task.class.php');
     foreach ($finder->in($dirs) as $file) {
         $this->taskFiles[basename($file, '.class.php')] = $file;
     }
     // register local autoloader for tasks
     spl_autoload_register(array($this, 'autoloadTask'));
     // require tasks
     foreach ($this->taskFiles as $task => $file) {
         // forces autoloading of each task class
         class_exists($task, true);
     }
     // unregister local autoloader
     spl_autoload_unregister(array($this, 'autoloadTask'));
 }
コード例 #2
0
 /**
  * @param sfProjectConfiguration $configuration
  * 
  * @return fpErrorNotifier
  */
 public static function initialize(sfProjectConfiguration $configuration)
 {
     if (empty(self::$instance)) {
         $configFiles = $configuration->getConfigPaths('config/notify.yml');
         $config = sfDefineEnvironmentConfigHandler::getConfiguration($configFiles);
         foreach ($config as $name => $value) {
             sfConfig::set("sf_notify_{$name}", $value);
         }
         self::$instance = new self($configuration->getEventDispatcher());
         self::getInstance()->handler()->initialize();
     }
     return self::$instance;
 }
コード例 #3
0
 /**
  * Constructor.
  * 
  * @param sfProjectConfiguration $configuration The project configuration
  * @param string                 $rootDir       The plugin root directory
  * @param string                 $name          The plugin name
  */
 public function __construct(sfProjectConfiguration $configuration, $rootDir = null, $name = null)
 {
     $this->configuration = $configuration;
     $this->dispatcher = $configuration->getEventDispatcher();
     $this->rootDir = null === $rootDir ? $this->guessRootDir() : realpath($rootDir);
     $this->name = null === $name ? $this->guessName() : $name;
     $this->setup();
     $this->configure();
     if (!$this->configuration instanceof sfApplicationConfiguration) {
         $this->initializeAutoload();
         $this->initialize();
     }
 }
コード例 #4
0
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $applicationConfig = sfProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
     $context = sfContext::createInstance($applicationConfig);
     ProjectConfiguration::registerCron();
     $quiet = (bool) $options['quiet'];
     $passed = array();
     $assigned = array();
     if ($arguments['subreddit'] == '%') {
         if (!$quiet) {
             echo "Advancing EpisodeAssignments for all Subreddits...";
         }
         SubredditTable::getInstance()->advanceEpisodeAssignments();
     } else {
         $subreddit = SubredditTable::getInstance()->findOneByName($arguments['subreddit']);
         if ($subreddit) {
             if (!$quiet) {
                 echo "Advancing EpisodeAssignments for {$subreddit} Subreddit...";
             }
             $subreddit->advanceEpisodeAssignments();
         } else {
             throw new sfException('Cannot find Subreddit: ' . $arguments['subreddit']);
         }
     }
     if (!$quiet) {
         echo "\n";
     }
 }
コード例 #5
0
 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());
     }
 }
コード例 #6
0
ファイル: EventForm.class.php プロジェクト: TheoJD/portail
 public function configure()
 {
     sfProjectConfiguration::getActive()->loadHelpers(array('Asset', 'Thumb'));
     $this->widgetSchema['asso_id'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['start_date'] = new sfWidgetDatePicker();
     $this->validatorSchema['start_date'] = new sfValidatorDatePicker(array());
     $this->widgetSchema['end_date'] = new sfWidgetDatePicker();
     $this->validatorSchema['end_date'] = new sfValidatorDatePicker(array());
     $this->widgetSchema['affiche'] = new sfWidgetFormInputFileEditable(array('file_src' => doThumb($this->getObject()->getAffiche(), 'events', array('width' => 150, 'height' => 150), 'scale'), 'is_image' => true, 'edit_mode' => !$this->isNew() && $this->getObject()->getAffiche(), 'with_delete' => true, 'delete_label' => "Supprimer cette illustration"));
     $this->validatorSchema['affiche'] = new sfValidatorFileImage(array('required' => false, 'path' => sfConfig::get('sf_upload_dir') . '/events/source', 'mime_types' => 'web_images', 'max_width' => 1000, 'max_height' => 1000));
     $this->widgetSchema['guest_asso_list']->setOption('method', 'getName');
     $this->widgetSchema->setLabel('guest_asso_list', 'Associations Partenaires');
     $this->widgetSchema['guest_asso_list']->setAttributes(array('style' => 'width:100%;', 'class' => 'select2'));
     $this->validatorSchema['affiche_delete'] = new sfValidatorBoolean();
     $this->widgetSchema->setLabel('name', 'Nom');
     $this->widgetSchema->setLabel('type_id', 'Type');
     $this->widgetSchema->setLabel('start_date', 'Début');
     $this->widgetSchema->setLabel('end_date', 'Fin');
     $this->widgetSchema->setLabel('summary', 'Résumé en une ligne');
     $this->widgetSchema->setLabel('description', 'Description');
     $this->widgetSchema->setLabel('place', 'Lieu');
     $this->widgetSchema->setLabel('is_public', 'Ouvert au public ?');
     $this->widgetSchema->setLabel('affiche', 'Illustration');
     $this->widgetSchema->setLabel('is_weekmail', 'Paraître dans le Weekmail ?');
     $this->widgetSchema['is_weekmail']->setAttribute('style', 'width: 15px;');
     $this->useFields(array('asso_id', 'name', 'type_id', 'start_date', 'end_date', 'summary', 'description', 'place', 'is_public', 'affiche', 'is_weekmail', 'guest_asso_list'));
 }
コード例 #7
0
 public static function get()
 {
     sfProjectConfiguration::getActive()->loadHelpers(array("Url"));
     sfProjectConfiguration::getActive()->loadHelpers(array("Tag"));
     //TODO: fix this
     return "<div id='skulebar'>\n\t\t<a id='skule' href='/'>Skule Courses</a>\n\t\t<form method='get' action='" . url_for("search/fuzzySearch") . "' name='frmSearchBar'>\n\t\t<div style='margin: 0pt; padding: 0pt; display: inline;'>\n\t\t</div>\n\t\t<input type='text' title='Quick search in Skule Courses' size='30' name='query' id='search_search' autocomplete='off'/>\n\t\t</form>\n\t\t<div id='user'>\n\t\t<a href='/login'>Login</a>\n\t\t</div>\n\t\t</div>";
 }
コード例 #8
0
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     parent::execute($arguments, $options);
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $options_task_server_backup = array('location' => $arguments['location'], 'filepath' => $arguments['filepath']);
     if ($arguments['snapshot']) {
         $options_task_server_backup['snapshot'] = $arguments['snapshot'];
     }
     if ($arguments['newsnapshot']) {
         $options_task_server_backup['newsnapshot'] = $arguments['newsnapshot'];
     }
     if ($arguments['delete']) {
         $options_task_server_backup['deletesnapshot'] = $arguments['delete'];
     }
     if ($arguments['location']) {
         if ($arguments['do_not_generate_tar'] && $arguments['do_not_generate_tar'] != 'false') {
             $options_task_server_backup['do_not_generate_tar'] = true;
         }
     }
     $task_server_backup = new serverBackupTask($this->dispatcher, new sfFormatter());
     return $task_server_backup->run(array('serverid' => $arguments['serverid']), $options_task_server_backup);
 }
コード例 #9
0
    protected function execute($arguments = array(), $options = array()) {
        $databaseManager = new sfDatabaseManager($this->configuration);
        $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
        $context = sfContext::createInstance($this->configuration);
        sfProjectConfiguration::getActive()->loadHelpers('Partial', 'I18N', 'Url');
        $serverUrl = $options['setenvironment'] == '' ? $serverUrl = $options['host'] : $serverUrl = $options['host'] . '/' . $options['setenvironment'];
        $workflows = WorkflowVersionTable::instance()->getWorkflowsToStart(time())->toArray();
        foreach($workflows as $workflow) {
            $sender = WorkflowTemplateTable::instance()->getWorkflowTemplateById($workflow['workflowtemplate_id'])->toArray();
            $userSettings = new UserMailSettings($sender[0]['sender_id']);
            $sendMail = new SendStartWorkflowEmail($userSettings, $context, $workflow, $sender, $serverUrl);
            $workflowTemplate = WorkflowTemplateTable::instance()->getWorkflowTemplateByVersionId($workflow['id']);
            WorkflowVersionTable::instance()->startWorkflowInFuture($workflow['id']);
            $sendToAllSlotsAtOnce = $workflowTemplate[0]->getMailinglistVersion()->toArray();
            if($sendToAllSlotsAtOnce[0]['sendtoallslotsatonce'] == 1) {
                $calc = new CreateWorkflow($workflow['id']);
                $calc->setServerUrl($serverUrl);
                $calc->setContext($context);
                $calc->addAllSlots();
            }
            else {
                $calc = new CreateWorkflow($workflow['id']);
                $calc->setServerUrl($serverUrl);
                $calc->setContext($context);
                $calc->addSingleSlot();
            }

        }
  }
コード例 #10
0
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $applicationConfig = sfProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
     $context = sfContext::createInstance($applicationConfig);
     // Go to the Subreddit and obtain the past few keys.
     $reddit_location = $options['subreddit'];
     $reddit = new RedditObject($reddit_location);
     $quiet = (bool) $options['quiet'];
     if (!$quiet) {
         echo "Obtaining the most recent comments from {$reddit_location}...";
     }
     $reddit->appendData();
     $found_keys = count($reddit->getComments());
     if (!$quiet) {
         echo "\nFound {$found_keys} keys.  Updating keys in the database...";
     }
     ValidationTable::getInstance()->storeNewKeys($reddit->getComments());
     // Now that new keys are stored in the database we need to update all applicable users
     $users = sfGuardUserTable::getInstance()->getUsersToBeValidated();
     $updated = sfGuardUserTable::getInstance()->validateUsers($users);
     if (!$quiet) {
         echo "\nSending emails...";
     }
     foreach ($users as $user_id) {
         $sf_user = $context->getUser();
         $sf_user->setApiUserId($user_id);
         $sf_user->sendMail('RedditValidationSucceeded');
     }
     if (!$quiet) {
         echo "\n{$updated} users validated and email sent.\n";
     }
 }
コード例 #11
0
 /**
  * Initializes the current sfGenerator instance.
  *
  * @param sfGeneratorManager $generatorManager A sfGeneratorManager instance
  */
 public function initialize(sfGeneratorManager $generatorManager)
 {
     parent::initialize($generatorManager);
     $configuration = sfProjectConfiguration::getActive();
     $this->databaseManager = new sfDatabaseManager($configuration);
     $this->setGeneratorClass('sfDoctrineModule');
 }
コード例 #12
0
ファイル: actions.class.php プロジェクト: rayku/rayku
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->user = $this->getUser();
     //$user_id = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
     $user = $this->getUser()->getRaykuUser();
     if ($user) {
         $user_id = $user->getId();
     }
     if (!$user_id) {
         $this->forward('/dashboard');
     }
     $this->setVar('user_id', $user_id);
     //Form submitted
     if (sfWebRequest::POST == $this->getRequest()->getMethod()) {
         $emails = $this->getRequestParameter('emails');
         $ref = $this->getRequestParameter('ref');
         if (!$emails) {
             echo "Invalid emails";
             return false;
         }
         $mail = Mailman::createMailer();
         $mail->setContentType('text/html');
         $mail->addAddress($emails);
         $mail->setSubject('Invitation');
         sfProjectConfiguration::getActive()->loadHelpers(array('Asset', 'Url', 'Partial'));
         $mail->setBody(get_partial('invitationEmailHtml', array('ref' => $ref, 'user' => $user)));
         $mail->send();
         //$this->forward('referrals', 'invitesSent');
     }
 }
コード例 #13
0
 public function executeNovaPagina(sfWebRequest $request)
 {
     if ($request->isXmlHttpRequest() || true) {
         //apenas por ajax
         sfConfig::set('sf_web_debug', false);
         sfProjectConfiguration::getActive()->loadHelpers(array('I18N', 'Date'));
         $cmspage = new Cmspage();
         $content = new Content();
         $content->setId(null);
         $cmspage->setContent($content);
         $cmspage->setId(null);
         $cmsGroupcontent = $this->getUser()->getAttribute('contentGroup');
         $this->forward404Unless($cmsGroupcontent);
         $cmspage->setCmsgroupcontent($cmsGroupcontent);
         $this->formContent = new PageContentForm($cmspage);
         if ($request->isMethod('post')) {
             //return $this->renderPartial('cms/debug',array('values'=>$request->getParameter('pagina')));
             $this->formContent->bind($request->getParameter('pagina'));
             if ($this->formContent->isValid()) {
                 $this->logMessage('O formContent foi válido. cms/actions: ' . __FILE__ . __LINE__);
                 try {
                     $this->formContent->save();
                     return $this->renderPartial("cms/viewPage", array('page' => $this->formContent->getCmspageobj(), 'isNew' => true, 'values' => $this->formContent->getValues()));
                 } catch (Exception $e) {
                     //TODO: We should to handle the error and render it.
                     throw $e;
                 }
                 //return $this->renderPartial("cms/viewPage",array('page'));
             }
         }
         //parent::executeNew($request);
         return $this->renderPartial('cms/content_form', array('formContent' => $this->formContent));
     }
 }
コード例 #14
0
 public function customize($params)
 {
     $params['moduleName'] = 'search';
     sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
     $generatorManager = new sfGeneratorManager(sfProjectConfiguration::getActive());
     sfGeneratorConfigHandler::getContent($generatorManager, 'xfGeneratorInterface', $params);
 }
コード例 #15
0
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', 'dev', true));
     parent::execute($arguments, $options);
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $con = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $this->log('[INFO] Flushing old data...' . "\n");
     $eventlog_flush = EtvaSettingPeer::retrieveByPK('eventlog_flush');
     $flush_range = $eventlog_flush->getValue();
     $con->beginTransaction();
     $affected = 0;
     try {
         $offset_date = date("c", time() - $flush_range * 24 * 60 * 60);
         /*
          * get event records that have creation date outdated
          */
         $c = new Criteria();
         $c->add(EtvaEventPeer::CREATED_AT, $offset_date, Criteria::LESS_THAN);
         $affected = EtvaEventPeer::doDelete($c, $con);
         $con->commit();
         $message = sprintf('Events Log - %d Record(s) deleted after %d day offset', $affected, $flush_range);
         $context->getEventDispatcher()->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message)));
         $this->log('[INFO] ' . $message);
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
     $logger = new sfFileLogger($context->getEventDispatcher(), array('file' => sfConfig::get("sf_log_dir") . '/cron_status.log'));
     // log the message!
     $logger->log("[INFO] The events flush task ran!", 6);
 }
コード例 #16
0
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $nid = $arguments['id'];
     $this->log("[INFO] node check id={$nid}");
     if (!($etva_node = EtvaNodePeer::retrieveByPK($nid))) {
         $msg_i18n = $context->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $nid));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     } else {
         $etva_node_va = new EtvaNode_VA($etva_node);
         $response = $etva_node_va->checkState();
         if (!$response['success']) {
             $this->log("[ERROR] " . $response['error']);
         } else {
             $this->log("[INFO] " . $response['response']);
         }
         return $response;
     }
 }
コード例 #17
0
  /**
   * Constructor.
   *
   * @param string              $rootDir    The project root directory
   * @param sfEventDispatcher   $dispatcher The event dispatcher
   */
  public function __construct($rootDir = null, sfEventDispatcher $dispatcher = null)
  {
    if (null === self::$active || $this instanceof sfApplicationConfiguration)
    {
      self::$active = $this;
    }

    $this->rootDir = null === $rootDir ? self::guessRootDir() : realpath($rootDir);
    $this->symfonyLibDir = realpath(dirname(__FILE__).'/..');
    $this->dispatcher = null === $dispatcher ? new sfEventDispatcher() : $dispatcher;

    ini_set('magic_quotes_runtime', 'off');

    sfConfig::set('sf_symfony_lib_dir', $this->symfonyLibDir);

    $this->setRootDir($this->rootDir);

    // provide forms the dispatcher
    sfFormSymfony::setEventDispatcher($this->dispatcher);

    $this->setup();

    $this->loadPlugins();
    $this->setupPlugins();
  }
コード例 #18
0
 public function reloadClasses($force = false)
 {
       if (self::$freshCache && !$force)
   {
     return false;
   }
   $configuration = sfProjectConfiguration::getActive();
   if (!$configuration || !$configuration instanceof sfApplicationConfiguration)
   {
     return false;
   }
   self::$freshCache = true;
   if (file_exists($configuration->getConfigCache()->getCacheName('config/autoload.yml')))
   {
     self::$freshCache = false;
     if ($force)
     {
       unlink($configuration->getConfigCache()->getCacheName('config/autoload.yml'));
     }
   }
   $file = $configuration->getConfigCache()->checkConfig('config/autoload.yml');
   $this->classes = include($file);
   foreach ($this->overriden as $class => $path)
   {
     $this->classes[$class] = $path;
   }
   return true;
 }
コード例 #19
0
 public function __construct($containerObject, $attributes = array())
 {
     $this->afExtjs = afExtjs::getInstance();
     if (isset($attributes['label'])) {
         $this->attributes['text'] = $attributes['label'];
         unset($attributes['label']);
     }
     if (isset($attributes['url'])) {
         $param_name = isset($attributes['param']) ? $attributes['param'] : "param";
         $url = $attributes['url'] . "&" . $param_name . "=";
         $param = $containerObject->privateName . '.stack["text"]';
         $cellDiv = $containerObject->privateName . '.stack["cellDiv"]';
         if (isset($attributes['ajax'])) {
             sfProjectConfiguration::getActive()->loadHelpers(array('afExtjsContextMenu'));
             $source = ajax_source($url . '"+' . $param);
         } else {
             $source = 'window.location.href="' . $url . '"+' . $param;
         }
         $this->attributes['handler'] = $this->afExtjs->asMethod(array('parameters' => '', 'source' => $source));
         unset($attributes['url']);
         unset($attributes['ajax']);
         unset($attributes['param']);
     }
     if (isset($attributes['source'])) {
         $this->attributes['handler'] = $this->afExtjs->asMethod(array('parameters' => '', 'source' => $attributes["source"]));
     }
     parent::__construct($containerObject, $attributes);
 }
コード例 #20
0
 public function setup()
 {
     parent::setup();
     sfProjectConfiguration::getActive()->loadHelpers(array('I18N'));
     $this->required = __('Required', array(), 'vjComment');
     $this->invalid_mail = __('Invalid Mail', array(), 'vjComment');
     $this->invalid_url = __('Invalid Url', array(), 'vjComment');
     $this->required_msg = __('Required message', array(), 'vjComment');
     $this->widgetSchema['record_model'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['record_id'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['reply'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['reply_author'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['user_name'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['reply'] = new sfValidatorPass();
     $this->validatorSchema['reply_author'] = new sfValidatorPass();
     $this->validatorSchema['user_name'] = new sfValidatorPass();
     $this->widgetSchema->setLabel('author_name', __('Name', array(), 'vjComment'));
     $this->widgetSchema->setLabel('author_email', 'Email');
     $this->widgetSchema->setLabel('author_website', __('Website', array(), 'vjComment'));
     $this->widgetSchema->setLabel('body', 'Message');
     $this->widgetSchema->setHelp('author_website', __('Must start with http:// or https://', array(), 'vjComment'));
     $this->validatorSchema['author_email'] = new sfValidatorEmail();
     $this->validatorSchema['author_website'] = new sfValidatorUrl();
     $this->validatorSchema['author_name']->setMessage('required', $this->required);
     $this->validatorSchema['author_email']->setMessage('required', $this->required)->setMessage('invalid', $this->invalid_mail);
     $this->validatorSchema['author_website']->setOption('required', false)->setMessage('invalid', $this->invalid_url);
     $this->validatorSchema['body']->setOption('required', true)->setMessage('required', $this->required_msg);
 }
コード例 #21
0
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // need a scriptname otherwise it uses the symfony file
     if ($arguments['env'] != 'prod') {
         $_SERVER['SCRIPT_NAME'] = '/' . $arguments['application'] . '_' . $arguments['env'] . '.php';
     } else {
         $_SERVER['SCRIPT_NAME'] = '/index.php';
     }
     sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration($arguments['application'], $arguments['env'], true));
     $searchIndex = new zsSearchIndex($arguments['index']);
     //optimize to increase speed
     $searchIndex->optimize();
     //loop thru all models specified in this index and update all entries
     foreach ($searchIndex->getModels() as $model => $config) {
         $this->logSection('update', 'model: ' . $model);
         foreach (Doctrine::getTable($model)->findAll() as $object) {
             $searchIndex->updateIndex($object);
             echo '.';
         }
         echo "\n";
     }
     //re-optimize index
     $searchIndex->optimize();
 }
コード例 #22
0
 public function reloadClasses($force = false)
 {
     // only (re)load the autoloading cache once per request
     if (self::$freshCache) {
         return;
     }
     $configuration = sfProjectConfiguration::getActive();
     if (!$configuration || !$configuration instanceof sfApplicationConfiguration) {
         return;
     }
     self::$freshCache = true;
     if (file_exists($configuration->getConfigCache()->getCacheName('config/autoload.yml'))) {
         self::$freshCache = false;
         if ($force) {
             unlink($configuration->getConfigCache()->getCacheName('config/autoload.yml'));
         }
     }
     $file = $configuration->getConfigCache()->checkConfig('config/autoload.yml');
     $this->classes = (include $file);
     //If the user has specified provided one or more class paths
     foreach ($this->overriden as $class => $path) {
         $this->classes[$class] = $path;
     }
     //Remove non Peer classes from the array.
     foreach ($this->classes as $className => $path) {
         if (substr($className, -4, 4) != 'Peer' || substr($className, -4, 4) == 'Peer' && substr($className, 0, 4) == 'Base') {
             unset($this->classes[$className]);
         }
     }
 }
コード例 #23
0
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $con = $databaseManager->getDatabase($options['connection'])->getConnection();
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', 'dev', true));
     if ($options['server'] !== null) {
         EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_SERVER_, $options['server']);
     }
     if ($options['port'] !== null) {
         EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_PORT_, $options['port']);
     }
     if ($options['security-type'] !== null) {
         EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_SECURITY_, $options['security-type']);
     }
     if ($options['use-auth'] !== null) {
         EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_USE_AUTH_, $options['use-auth']);
     }
     if ($options['username'] !== null) {
         EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_USERNAME_, $options['username']);
     }
     if ($options['password'] !== null) {
         EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_KEY_, $options['password']);
     }
     return;
 }
コード例 #24
0
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $applicationConfig = sfProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
     $context = sfContext::createInstance($applicationConfig);
     $one_day_users = sfGuardUserTable::getInstance()->getOneDayEmailReminders();
     $one_week_users = sfGuardUserTable::getInstance()->getOneWeekEmailReminders();
     $quiet = (bool) $options['quiet'];
     if (!$quiet) {
         echo "Sending one-day reminder emails to  " . count($one_day_users) . " users...";
     }
     foreach ($one_day_users as $user) {
         $sf_user = $context->getUser();
         $sf_user->setApiUserId($user->getIncremented());
         $sf_user->sendMail('RegisterOneDay');
     }
     if (!$quiet) {
         echo "\nSending one-week reminder emails to " . count($one_week_users) . " users...";
     }
     foreach ($one_week_users as $user) {
         $sf_user = $context->getUser();
         $sf_user->setApiUserId($user->getIncremented());
         $sf_user->sendMail('RegisterOneWeek');
     }
     if (!$quiet) {
         echo "\n";
     }
 }
コード例 #25
0
ファイル: LinkCell.php プロジェクト: THM068/orangehrm
 public function __toString()
 {
     $linkable = $this->getPropertyValue('linkable', true);
     if ($linkable instanceof sfOutputEscaperArrayDecorator || is_array($linkable)) {
         list($method, $params) = $linkable;
         $linkable = call_user_func_array(array($this->dataObject, $method), $params->getRawValue());
     }
     if ($linkable) {
         $placeholderGetters = $this->getPropertyValue('placeholderGetters');
         $urlPattern = $this->getPropertyValue('urlPattern');
         $url = $urlPattern;
         foreach ($placeholderGetters as $placeholder => $getter) {
             $placeholderValue = is_array($this->dataObject) ? $this->dataObject[$getter] : $this->dataObject->{$getter}();
             $url = preg_replace("/\\{{$placeholder}\\}/", $placeholderValue, $url);
         }
         if (preg_match('/^index.php/', $url)) {
             sfProjectConfiguration::getActive()->loadHelpers('Url');
             $url = public_path($url, true);
         }
         $linkAttributes = array('href' => $url);
         if ($this->hasProperty('labelGetter')) {
             $label = $this->getValue('labelGetter');
         } else {
             $label = $this->getPropertyValue('label', 'Undefined');
         }
         return content_tag('a', $label, $linkAttributes) . $this->getHiddenFieldHTML();
     } else {
         return $this->toValue() . $this->getHiddenFieldHTML();
     }
 }
 /**
  * Executes the current task.
  *
  * @param array $arguments An array of arguments
  * @param array $options An array of options
  *
  * @return integer 0 if everything went fine, or an error code
  */
 protected 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();
     /** @var $parametres Récupération des paramètres à charger */
     $parametres = $conn->execute("\n            SELECT *\n            FROM ei_function_has_param, ei_fonction\n            WHERE param_type = 'OUT'\n            AND (param_id, ei_fonction.id) NOT IN (SELECT ei_param_function_id, ei_function_id FROM ei_param_block_function_mapping)\n            AND ei_function_has_param.function_ref = ei_fonction.function_ref\n            AND ei_function_has_param.function_id = ei_fonction.function_id\n        ");
     $this->log('Récupération des paramètres...OK');
     // Création de la requête permettant
     $this->log('Création de la requête d\'insertion...');
     $requeteToInsert = "INSERT INTO ei_param_block_function_mapping (ei_param_function_id, created_at, updated_at, ei_function_id) ";
     $requeteToInsert .= "VALUES(#{PARAM_ID}, now(), now(), #{FONCTION_ID});";
     $pile = array();
     foreach ($parametres->fetchAll() as $parametre) {
         // Remplacement PARAM ID.
         $tmpRequete = str_replace("#{PARAM_ID}", $parametre["param_id"], $requeteToInsert);
         // Remplacement FONCTION ID.
         $tmpRequete = str_replace("#{FONCTION_ID}", $parametre["id"], $tmpRequete);
         // Ajout dans la requête globale.
         $pile[] = $tmpRequete;
     }
     // Préparation de la requête.
     $this->log("Préparation de la requête...");
     $requete = implode(" ", $pile);
     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());
     }
 }
コード例 #27
0
ファイル: sfPropel.class.php プロジェクト: ajith24/ajithworld
 public static function getDefaultCulture()
 {
     if (!self::$initialized && class_exists('sfProjectConfiguration', false)) {
         self::initialize(sfProjectConfiguration::getActive()->getEventDispatcher());
     }
     return self::$defaultCulture;
 }
コード例 #28
0
 /**
  * Initialize a sfDoctrineDatabase connection with the given parameters.
  *
  * <code>
  * $parameters = array(
  *    'name'       => 'doctrine',
  *    'dsn'        => 'sqlite:////path/to/sqlite/db');
  *
  * $p = new sfDoctrineDatabase($parameters);
  * </code>
  *
  * @param array $parameters  Array of parameters used to initialize the database connection
  * @return void
  */
 public function initialize($parameters = array())
 {
     parent::initialize($parameters);
     $dsn = $this->getParameter('dsn');
     $name = $this->getParameter('name');
     // Make sure we pass non-PEAR style DSNs as an array
     if (!strpos($dsn, '://')) {
         $dsn = array($dsn, $this->getParameter('username'), $this->getParameter('password'));
     }
     // Make the Doctrine connection for $dsn and $name
     $this->_doctrineConnection = Doctrine_Manager::connection($dsn, $name);
     $attributes = $this->getParameter('attributes', array());
     foreach ($attributes as $name => $value) {
         $this->_doctrineConnection->setAttribute($name, $value);
     }
     $encoding = $this->getParameter('encoding', 'UTF8');
     $eventListener = new sfDoctrineConnectionListener($this->_doctrineConnection, $encoding);
     $this->_doctrineConnection->addListener($eventListener);
     // Load Query Logger Listener
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $this->_doctrineConnection->addListener(new sfDoctrineLogger());
     }
     // Invoke the configuration methods for the connection if they exist
     $configuration = sfProjectConfiguration::getActive();
     $method = sprintf('configureDoctrineConnection%s', ucwords($this->_doctrineConnection->getName()));
     if (method_exists($configuration, 'configureDoctrineConnection') && !method_exists($configuration, $method)) {
         $configuration->configureDoctrineConnection($this->_doctrineConnection);
     }
     if (method_exists($configuration, $method)) {
         $configuration->{$method}($this->_doctrineConnection);
     }
 }
コード例 #29
0
ファイル: components.class.php プロジェクト: vcgato29/poff
 protected function generateMetaDescription()
 {
     sfProjectConfiguration::getActive()->loadHelpers('StringFunc');
     $result = '';
     switch ($this->getCurrentPageType()) {
         case self::ARTICLE_PAGE:
             //pealkiri. Sisu (250 chars)
             if ($this->getRoute()->getObject()->getMetadescription()) {
                 return $this->getRoute()->getObject()->getMetadescription();
             }
             $content = truncate(strip_tags($this->getRoute()->getObject()->getTitle() . '. ' . $this->getRoute()->getObject()->getContent()), 250, '');
             break;
         case self::CATEGORY_PAGE:
             // category name, products
             if ($this->getRoute()->getCategoryObject()->getMetaDescription()) {
                 return $this->getRoute()->getCategoryObject()->getMetaDescription();
             }
             $content = implode(',', $this->getProductCategoryPageWords($this->getRoute()->getCategoryObject()));
             break;
         case self::PRODUCT_PAGE:
             //toote nimi (kategooriad) - toode kirjelduse esimesed tähemärgid
             $content = $this->getRoute()->getProductObject()->getName() . ' (' . implode(', ', $this->getProductCategoryPageWords($this->getRoute()->getCategoryObject())) . ') ' . $this->getRoute()->getProductObject()->getDescription();
             break;
     }
     $result = truncate(strip_tags($content), 250, '');
     return $result;
 }
コード例 #30
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->class = $request->getParameter('class');
     if (empty($this->class)) {
         $this->class = $request->getGetParameter('class');
     }
     $this->method = $request->getParameter('method');
     if (empty($this->method)) {
         $this->method = $request->getGetParameter('method');
     }
     if (!empty($this->method)) {
         $this->class = array($this->class, $this->method);
     }
     $this->viewer = new sfCodeViewer($this->class);
     if ($request->isXmlHttpRequest()) {
         sfProjectConfiguration::getActive()->loadHelpers('Url');
         $this->renderText($this->viewer->render(url_for('sfCodeView')));
         return sfView::NONE;
     } else {
         // maintain history
         $this->history = $this->getUser()->getAttribute('history', array());
         if (false !== ($index = array_search($this->class, $this->history))) {
             unset($this->history[$index]);
         }
         array_unshift($this->history, $this->class);
         array_splice($this->history, 10);
         $this->getUser()->setAttribute('history', $this->history);
     }
 }