Beispiel #1
0
 public function generateTables()
 {
     $this->removeTables();
     Doctrine_Core::createTablesFromModels(MODELS);
     FlashComponent::set('info', 'Generate Table terminé.');
     $this->redirect(array('action' => 'index'));
 }
 public function __call($name, $args)
 {
     if (in_array($name, $this->_bootstrapFlashClasses)) {
         // Duplicating most of the parent::__call functionality
         $options = array('element' => 'bootstrap_default', 'params' => array('type' => $name));
         if (count($args) < 1) {
             throw new InternalErrorException('Flash message missing.');
         }
         if (!empty($args[1])) {
             $options += (array) $args[1];
         }
         $this->set($args[0], $options);
     } else {
         return parent::__call($name, $args);
     }
 }
Beispiel #3
0
 public function preExecute()
 {
     if ($this->options['basic']['username'] && $this->options['basic']['password']) {
         if (!$this->basic($this->options['basic']['username'], $this->options['basic']['password'])) {
             die('Cette partie est privée, vous devez vous identifier.');
         }
     } else {
         session_start();
         $User = isset($_SESSION['_protection']) ? $_SESSION['_protection'] : null;
         session_write_close();
         if (!isset($User) && !in_array($this->Controller->action, $this->options['authorize'])) {
             FlashComponent::set('info', "Cette partie est privée, vous devez vous identifier.");
             $this->Controller->redirect($this->options['login'], 403);
         } else {
             $this->setUser($User);
             $this->Controller->View->set('ProtectionComponent', $User);
         }
     }
 }
Beispiel #4
0
<? if (FlashComponent::has('error')): ?>
	<div class="message error"><strong>Erreur :</strong> <?php 
echo FlashComponent::get('error');
?>
</div>
<? endif ?>
<? if (FlashComponent::has('warning')): ?>
	<div class="message warning"><strong>Attention :</strong> <?php 
echo FlashComponent::get('warning');
?>
</div>
<? endif ?>
<? if (FlashComponent::has('info')): ?>
	<div class="message info"><strong>Information :</strong> <?php 
echo FlashComponent::get('info');
?>
</div>
<? endif ?>
<? if (FlashComponent::has('success')): ?>
	<div class="message success"><strong>Message :</strong> <?php 
echo FlashComponent::get('success');
?>
</div>
<? endif ?>
<? if (FlashComponent::has('neutral')): ?>
	<div class="message neutral"><strong>Message :</strong> <?php 
echo FlashComponent::get('neutral');
?>
</div>
<? endif ?>
Beispiel #5
0
 public function batch()
 {
     $id = $this->Request()->post('id');
     $action = $this->Request()->post('action');
     if (!$action) {
         FlashComponent::set('error', "Une action doit être choisie.");
         $this->redirect(array('action' => 'index'));
     }
     if (!count($id)) {
         FlashComponent::set('error', "Un ou plusieurs Images doivent être cochées.");
         $this->redirect(array('action' => 'index'));
     }
     switch ($action) {
         case "delete":
             $Items = Doctrine::getTable('Library')->createQuery()->whereIn('id', $id)->execute();
             foreach ($Items as $Item) {
                 $Item->delete();
             }
             FlashComponent::set('success', pluralize(count($id), "{Image|Images} effacée{s}"));
             break;
     }
     $this->redirect(array('action' => 'index'));
 }
 /**
  * FlashComponentTest::testFlashMessage()
  *
  * @return void
  */
 public function testFlashComplexMocked()
 {
     $this->View = $this->getMock('View', ['element']);
     $this->Flash = new FlashHelper($this->View);
     $this->Flash->settings['useElements'] = true;
     FlashComponent::transientMessage('efg', ['type' => 'success', 'escape' => true, 'useElements' => true, 'element' => 'PluginName.default_element', 'params' => ['foo' => 'bar']]);
     $this->View->expects($this->once())->method('element')->with('PluginName.Flash/default_element')->will($this->returnValue('xyz'));
     $res = $this->Flash->flash();
     $this->assertTrue(!empty($res));
     $expected = '<div class="flash-messages flashMessages">xyz</div>';
     $this->assertSame($expected, $res);
 }
Beispiel #7
0
 /**
  * Adds a message on the fly.
  *
  * Only works with static Configure configuration.
  *
  * @param string $msg
  * @param string $class
  * @return void
  */
 public function addTransientMessage($msg, $options = [])
 {
     FlashComponent::transientMessage($msg, $options);
 }