예제 #1
0
 function render()
 {
     if ($this->loginQueued) {
         FlashBag::add('success', "Login Success");
         $this->doLogin();
         return array('type' => 'redirect', 'url' => $this->route->root());
     }
     return array('type' => 'template', 'template' => 'pages/login.twig', 'data' => ['staticRoot' => $this->app->getStaticRoot(), 'title' => $this->app->getAppName(), 'welcomeMessage' => $this->welcomeMessage, 'endpoint' => $this->route->root(), 'valueBag' => json_encode(ValueBag::getValues()), 'bodyclass' => 'login-page', 'error' => $this->error, 'username' => $this->url->get('username', '')]);
 }
예제 #2
0
 public function handle_set_form_values()
 {
     $form = new FormHelper(array(), $this->dataProvider->getEditFormConfig());
     $url = new UrlHelper();
     // let's not worry about validation right now.
     $values = json_decode($url->get("values_json", "{}"), true);
     if ($form->validate($values)) {
         $this->dataProvider->setRow($url->get("item_id", null), $values);
         FlashBag::add("alert", "Item has been updated", "success");
         return array('type' => 'json', 'data' => array('success' => true));
     } else {
         // TODO show errors on validation fail
         throw new \Exception("Cannot validate values");
     }
 }
예제 #3
0
 public static function logObject($object)
 {
     FlashBag::add("log", json_encode($object), "json");
 }
예제 #4
0
 public function handle_set_form_values()
 {
     $form = new FormHelper(array(), $this->dataProvider->getEditFormConfig());
     $url = new UrlHelper();
     $values = json_decode($url->get("values_json", "{}"), true);
     if (empty($values)) {
         return array('type' => 'json', 'data' => array('success' => true));
     }
     //validate
     $failedValues = $this->dataProvider->validateRow($values);
     if (empty($failedValues)) {
         $this->dataProvider->setRow($url->get("item_id", null), $values);
         FlashBag::add("alert", "Item has been updated", "success");
         return array('type' => 'json', 'data' => array('success' => true, 'dataValid' => true));
     } else {
         FlashBag::add("alert", "Could not update certain fields", "error");
         return array('type' => 'json', 'data' => array('success' => true, 'dataValid' => false, 'failedValues' => $failedValues));
         //throw new \Exception("Cannot validate values");
     }
 }
예제 #5
0
 public function handle_set_form_values()
 {
     if ($this->app->isReadOnly()) {
         throw new Exception("Read Only");
     }
     $form = new FormHelper(array(), $this->dataProvider->getEditFormConfig());
     $url = new UrlHelper();
     $values = json_decode($url->get("values_json", "{}"), true);
     if (empty($values)) {
         return array('type' => 'json', 'data' => array('success' => true));
     }
     //validate
     $failedValues = $this->dataProvider->validateRow($values);
     if (empty($failedValues)) {
         $url = new UrlHelper();
         $rowId = $url->get("item_id", null);
         $summaryKey = $this->dataProvider->getSummaryColumns()[0]['key'];
         $rowData = $this->dataProvider->getRow($rowId);
         $rowName = $rowData[$summaryKey];
         $this->dataProvider->setRow($url->get("item_id", null), $values);
         FlashBag::add("alert", "Item {$rowName} has been updated", "success");
         return array('type' => 'json', 'data' => array('success' => true, 'dataValid' => true));
     } else {
         FlashBag::add("alert", "Could not update certain fields", "error");
         return array('type' => 'json', 'data' => array('success' => true, 'dataValid' => false, 'failedValues' => $failedValues));
         //throw new \Exception("Cannot validate values");
     }
 }