Example #1
0
 public function getResourceRouting()
 {
     $admin_app = Application::getInstance('admin');
     $resource_routing = $admin_app->getResourceRouting();
     array_unshift($resource_routing['default'], 'applications/cli');
     return $resource_routing;
 }
Example #2
0
 /**
  * Returns a Csrf instance
  *
  * @return Csrf
  */
 public function csrf()
 {
     if (!$this->csrf) {
         $this->csrf = \Dependency::resolve('security.csrf', array($this->config, \Application::getInstance()->getSession()));
     }
     return $this->csrf;
 }
Example #3
0
 public function actionIndex()
 {
     $poll = Application::getInstance()->fetchers->poll->getByOpenAttribute();
     $questions = Application::getInstance()->fetchers->questions->getByPollId($poll['id']);
     $answers = Application::getInstance()->fetchers->answers->getByPollId($poll['id']);
     $this->render('index', array('poll' => $poll, 'questions' => $questions, 'answers' => $answers));
 }
Example #4
0
 /**
  * @param	Product $product
  * @param	integer $qtd
  */
 public function __construct(Product $product, $qtd)
 {
     parent::__construct();
     $resourceBundle = Application::getInstance()->getBundle();
     $idProduct = $product->getIdProduct();
     $moneyformat = $resourceBundle->getString('MONEY_FORMAT');
     $productName = $product->getProductName();
     $productDescription = $product->getProductDescription();
     $productPrice = $product->getProductPrice();
     $form = $this->addChild(new Form('/?c=cart&a=change&p=' . $idProduct));
     //Imagem do produto
     $form->addChild(new Image($product->getProductImage(), $productName))->setTitle($productName)->setAttribute('width', 80)->setAttribute('height', 80);
     //Nome e descrição do produto
     $form->addChild(new Span())->addStyle('name')->addChild(new Text($productName));
     $form->addChild(new Span())->addStyle('desc')->addChild(new Text($productDescription));
     //Input com a quantidade de itens
     $form->addChild(new Label(new Text($resourceBundle->getString('QUANTITY'))))->addChild(new Input('qtd'))->setValue($qtd);
     //Preço unitário
     $form->addChild(new Span())->addStyle('price')->addChild(new Text(money_format($moneyformat, $productPrice)));
     //Preço total
     $form->addChild(new Span())->addStyle('total')->addChild(new Text(money_format($moneyformat, $qtd * $productPrice)));
     //Botões para edição e exclusão do item do carrinho
     $form->addChild(new Input('save', Input::SUBMIT))->setValue($resourceBundle->getString('SAVE'));
     $form->addChild(new Input('del', Input::SUBMIT))->setValue($resourceBundle->getString('DELETE'));
 }
Example #5
0
 public function __construct()
 {
     $this->session = Application::getInstance('Session');
     if (!isset($this->session->{self::KEY})) {
         $this->session->{self::KEY} = array();
     }
 }
 /**
  * @covers QueueController::Add
  * @todo Implement testAdd().
  */
 public function testAdd()
 {
     $person = Person::factory('adult');
     $person->name = 'Poehavshiy';
     $person->add();
     $store = Store::factory('Grocery');
     $store->name = 'Prison';
     $store->add();
     $product = new Product();
     $product->name = 'Sladkiy hleb';
     $product->add();
     $request = Application::getInstance()->request;
     $request->setParams(array('storeId' => $store->id, 'personId' => $person->id, 'product_' . $product->id => 'on'));
     $personId = $request->p('personId');
     $storeId = $request->p('storeId');
     $store = Store::get($storeId);
     $person = Person::get($personId);
     $store->queue->add($person);
     $person->basket->drop();
     $name = 'product_' . $product->id;
     $value = $product;
     if (preg_match_all('/^product_(\\d+)$/', $name, $matches)) {
         $person->basket->add(Product::get($matches[1][0]));
     }
 }
Example #7
0
 private function __construct()
 {
     $this->_viewPath = Application::getInstance()->getConfig()->app['views'];
     if ($this->_viewPath == null) {
         $this->_viewPath = realpath('../Views/');
     }
 }
 /**
  * @covers AssortmentController::Store
  * @todo Implement testStore().
  */
 public function testStore()
 {
     $request = Application::getInstance()->request;
     $request->setParam('storeId', '6');
     $c = new AssortmentController();
     $result = $c->Store();
 }
 public function actionDelete()
 {
     $questions = Application::getInstance()->fetchers->questions->getById($_GET['id']);
     Application::getInstance()->fetchers->questions->delete($_GET['id']);
     $poll_id = $questions['poll_id'];
     header("Location: /index.php?r=adminQuestion/index&poll_id={$poll_id}");
 }
Example #10
0
 public static function __callStatic($func, ...$args)
 {
     if (!in_array($func, self::FUNC_ALLOWED)) {
         throw new \Exception("method {$func} not found");
     }
     $obj = Application::getInstance()->produce('router');
     return call_user_func_array([$obj, $func], ...$args);
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 public static function getInstance()
 {
     // get the current session via the active request instance
     if ($request = \Request::getInstance()) {
         return $request->getApplication()->getSession();
     }
     return Application::getInstance()->getSession();
 }
 private function saveText($question)
 {
     foreach ($_POST['answers'] as $answers) {
         if (!empty($answers)) {
             Application::getInstance()->fetchers->answers->addSting($answers, $_GET['question_id'], $question);
         }
     }
 }
Example #13
0
 public static function getFromDomain($domain)
 {
     $db =& Application::getInstance()->db;
     $s = $db->prepare("select " . School::fieldList . " from School where domain=:d");
     $s->bindParam(':d', $domain);
     $s->execute();
     return $s->fetchObject();
 }
 public static function add($moduleName)
 {
     $con = Application::getDbConnection();
     $con->queryExecute("INSERT INTO b_module(ID) VALUES('" . $con->getSqlHelper()->forSql($moduleName) . "')");
     self::$installedModules = array();
     $cacheManager = Application::getInstance()->getManagedCache();
     $cacheManager->clean("b_module");
 }
Example #15
0
 public function __construct()
 {
     $registry = Registry::getInstance();
     if (!$registry->has('pdo')) {
         $resourceBundle = Application::getInstance()->getBundle();
         $registry->set('pdo', new PDO($resourceBundle->getString('MYSQL_DSN'), $resourceBundle->getString('MYSQL_USER'), $resourceBundle->getString('MYSQL_PSWD')));
     }
 }
Example #16
0
 public function enabled($params = '{}')
 {
     $sdk = \Application::getInstance();
     $final = $sdk->enabled();
     //
     //var_dump( $final );
     return $final;
 }
Example #17
0
 /**
  * @param String $config
  */
 public function setConfig($config)
 {
     if (is_string($config)) {
         self::$_config = Application::getInstance()->getConfig()->{$config};
     } else {
         throw new \Exception('Invalid config, string name expected!', 500);
     }
 }
Example #18
0
 /**
  * {@inheritdoc}
  */
 public static function getInstance()
 {
     // get the current request instance
     if ($request = \Request::getInstance()) {
         return $request->getInput();
     }
     // no active request, return the current application instance
     return \Application::getInstance()->getRootComponent()->getInput();
 }
Example #19
0
 public static function unRegisterModule($moduleName)
 {
     $con = Application::getInstance()->getConnection();
     $con->queryExecute("DELETE FROM b_agent WHERE MODULE_ID='" . $con->getSqlHelper()->forSql($moduleName) . "'");
     \CMain::DelGroupRight($moduleName);
     static::delete($moduleName);
     $event = new Event("main", "OnAfterUnRegisterModule", array($moduleName));
     $event->send();
 }
Example #20
0
 public static function launch($strBoardName)
 {
     $strBoardFullPath = sprintf('%s\\board\\%s', Application::getInstance()->strApplicationClassesPrefix, $strBoardName);
     $objSpecifiedBoard = new $strBoardFullPath();
     $objBoardMethod = new \ReflectionMethod($strBoardFullPath, 'index');
     $arrRequestParams = Request::getParams();
     $objResponse = $objBoardMethod->invokeArgs($objSpecifiedBoard, $arrRequestParams);
     return $objResponse;
 }
Example #21
0
 protected static function init()
 {
     if (!is_array(self::$language)) {
         $session = Application::getInstance('Session');
         $language = isset($session->language) ? $session->language : self::DEFAULT_LANGUAGE;
         require_once getcwd() . '/application/language/' . $language . '.php';
         self::$language = $language;
     }
 }
Example #22
0
 function __construct()
 {
     $name = strtolower(str_replace('App\\Model\\', '', get_class($this)));
     if (!empty(Application::getInstance()->config['model'][$name]['observer'])) {
         $observers = Application::getInstance()->config['model'][$name]['observer'];
         foreach ($observers as $class) {
             $this->observers[] = new $class();
         }
     }
 }
Example #23
0
 public function __construct()
 {
     $session = Application::getInstance('Session');
     $mongo = PHPMongoDB::getInstance($session->server, $session->options);
     $exception = $mongo->getExceptionMessage();
     if ($exception) {
         exit($exception);
     }
     $this->mongo = $mongo->getConnection();
 }
Example #24
0
File: View.php Project: zhxia/nspf
 public function displayJsonp($callback, $data)
 {
     Application::getInstance()->getDispatcher()->getResponse()->setContentType('application/javascript');
     echo '
         try{
             ' . $callback . '(' . json_encode($data) . ');
         }
         catch(e){
         }
     ';
 }
 /**
  * @covers PersonController::Remove
  * @todo Implement testRemove().
  */
 public function testRemove()
 {
     $request = Application::getInstance()->request;
     $request->setParams(array('name' => 'Louise the Zero', 'type' => 'adult'));
     $res = $this->object->Add();
     $this->assertTrue(isset($res['id']));
     $id = $res['id'];
     $request->setParams(array('id' => $id));
     $res = $this->object->Remove();
     $this->assertFalse(isset($res['error']));
 }
Example #26
0
 public function actionSendPoll()
 {
     $poll = Application::getInstance()->fetchers->poll->getByOpenAttribute();
     $questions = Application::getInstance()->fetchers->questions->getByPollId($poll['id']);
     $answers = Application::getInstance()->fetchers->answers->getByPollId($poll['id']);
     if (!empty($_POST['answer'])) {
         Application::getInstance()->fetchers->vote->addStrings($_POST['answer'], $poll['id']);
         header("Location: /index.php?r=vote/index");
     }
     $this->render('sendPoll', array('poll' => $poll, 'questions' => $questions, 'answers' => $answers));
 }
Example #27
0
 /**
  * @see		ApplicationView::createUserInterface()
  */
 protected function createUserInterface()
 {
     parent::createUserInterface();
     //Recupera o título da página de erro
     $title = Application::getInstance()->getBundle()->getString('ERROR_TITLE');
     //Define o título da página
     $this->setTitle($title);
     //Adiciona as informações sobre o erro
     $this->contentPanel->addChild(new Heading(2))->addChild(new Text($title));
     $this->contentPanel->addChild(new Paragraph())->addChild(new Text($this->errorMessage));
 }
Example #28
0
 /**
  * Returns a new Agent instance
  *
  * @return \Fuel\Agent\Agent
  */
 public static function forge($name = null)
 {
     // get the current application name via the active request instance
     if (!$name) {
         $name = \Application::getInstance()->getName();
     }
     // get the arguments, and remove the name
     $args = func_get_args();
     array_shift($args);
     return static::getContainer()->multiton('agent', $name, $args);
 }
Example #29
0
 public function getSender()
 {
     if ($this->getSenderId()) {
         $objConn = Application::getInstance()->getConnection();
         $objStatement = $objConn->prepare("SELECT * FROM user WHERE id = :id");
         $objStatement->execute(array(":id" => $this->getUserId()));
         $arrRow = $objStatement->fetch(PDO::FETCH_ASSOC);
     } else {
         $arrRow["login"] = "******";
     }
     return new User($arrRow);
 }
Example #30
0
 /**
  * @see		ApplicationView::createUserInterface()
  */
 protected function createUserInterface()
 {
     parent::createUserInterface();
     $this->addStyle('/css/home.css');
     $resourceBundle = Application::getInstance()->getBundle();
     $products = $this->products->getProducts();
     if (count($products) == 0) {
         $this->contentPanel->addChild(new Heading(2))->addChild(new Text($resourceBundle->getString('NO_PRODUCT')));
     } else {
         $this->contentPanel->addChild(new ProductList())->setProductList($products);
     }
 }