Example #1
0
 /**
  * @test
  */
 public function stateShouldKeepItemsByRuleNumberAndPosition()
 {
     $item1 = new Item(new Rule(1, 'E', array('E', '+', 'T')), 0);
     $state = new State(0, array($item1));
     $this->assertSame($item1, $state->get(1, 0));
     $item2 = new Item(new Rule(2, 'T', array('T', '+', 'F')), 0);
     $state->add($item2);
     $this->assertSame($item2, $state->get(2, 0));
 }
 public function load_states()
 {
     $country_id = $_POST['country_id'];
     $states = new State();
     if ($country_id > 0) {
         $states->where('country_id', $country_id);
     }
     $states->get();
     echo '<select name="state_id" class="form-control">';
     echo '<option value="">-- select state --</option>';
     foreach ($states as $key => $state_item) {
         echo '<option value="' . $state_item->id . '">' . $state_item->state_name . '</option>';
     }
     echo '</select>';
 }
Example #3
0
 /**
  * Register a notification.
  * 
  * @param   string $message The message to print.
  * @param   string $type    The type of notification [self::ERROR|self::SUCCESS|self::INFO].
  */
 static function notify($message, $type)
 {
     $nots = State::get('notifications');
     array_push($nots, array('message' => $message, 'type' => $type));
     State::set('notifications', $nots);
 }
Example #4
0
 /**
  * Save/reset/load component values.
  */
 private function update()
 {
     $errors = array();
     switch (State::get('action')) {
         case 'save':
             $errors = $this->save();
             Notifier::success('Settings saved.');
             break;
         case 'reset-section':
             $section = $this->config->get_section_by_slug(State::get('active_section'));
             $this->reset($section);
             Notifier::success('<strong>' . $section->title . '</strong> section was reset to its default settings.');
             break;
         case 'reset-all':
             $this->reset();
             Notifier::success('All sections were reset to their default settings.');
             break;
             // No submission (simple request)
         // No submission (simple request)
         default:
             $this->load();
     }
     $this->set_errors($errors);
 }
Example #5
0
<!DOCTYPE html>
<html lang="es"><head>
	<title><?php 
echo State::get('title');
?>
</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">

	<link rel="stylesheet" type="text/css" href="<?php 
echo Settings::host();
?>
lib/stys/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="<?php 
echo Settings::host();
?>
lib/stys/font-awesome.min.css">
	<link rel="stylesheet" type="text/css" href="<?php 
echo Settings::host();
?>
lib/stys/global.css"> 

	<script type="text/javascript" src="<?php 
echo Settings::host();
?>
lib/scrs/jquery.min.js"></script> 
	<script type="text/javascript" src="<?php 
echo Settings::host();
?>
lib/scrs/jquery-ui.min.js"></script> 
	<script type="text/javascript" src="<?php 
echo Settings::host();
Example #6
0
    $request = \Slim\Slim::getInstance()->request();
    $rating = json_decode($request->getBody());
    $ratingDAO = new Rating();
    $ratingDAO->update($rating);
    echo '{"result":"ok"}';
});
$app->delete('/rating', function () {
    $request = \Slim\Slim::getInstance()->request();
    $rating = json_decode($request->getBody());
    $ratingDAO = new Rating();
    $ratingDAO->delete($rating);
    echo '{"result":"ok"}';
});
$app->get('/state', function () {
    $stateDAO = new State();
    $result = $stateDAO->get();
    echo json_encode($result);
});
$app->post('/state', function () {
    $request = \Slim\Slim::getInstance()->request();
    $state = json_decode($request->getBody());
    $stateDAO = new State();
    $stateDAO->insert($state);
    echo '{"result":"ok"}';
});
$app->put('/state', function () {
    $request = \Slim\Slim::getInstance()->request();
    $state = json_decode($request->getBody());
    $stateDAO = new State();
    $stateDAO->update($state);
    echo '{"result":"ok"}';