Example #1
0
 public function saveItem($arrParam, $options = null)
 {
     if (!empty($arrParam['description'])) {
         $input = $arrParam['description'];
         $config = array("HTML.AllowedAttributes" => array("style"), "HTML.AllowedElements" => array("p", "b", "em", "span", "strong"));
         $filter = new \ZendVN\Filter\Purifier($config);
         $arrParam['description'] = $filter->filter($input);
     }
     //Quenr@i3
     if ($options['task'] == "add-item") {
         $arrParam['status'] = $arrParam['status'] == "active" ? 1 : 0;
         $arrParam['created'] = date("Y-m-d H:i:s");
         $this->insertNode($arrParam, $arrParam['parent'], array("position" => "right"));
         return $this->_tableGateway->getLastInsertValue();
     }
     if ($options['task'] == "edit-item") {
         $arrParam['status'] = $arrParam['status'] == "active" ? 1 : 0;
         $arrParam['modified'] = date("Y-m-d H:i:s");
         $nodeParentID = $arrParam['parent'] == $arrParam["id"] ? null : $arrParam['parent'];
         unset($arrParam['parent']);
         $this->updateNode($arrParam, $arrParam['id'], $nodeParentID);
         return $arrParam['id'];
     }
 }
Example #2
0
 public function index12Action()
 {
     $input = "<p id='le' class='trong' style='color:blue !important'>TrongBlue</p>";
     $options = array("Attr.EnableID" => true, "Output.SortAttr" => true, "HTML.AllowedAttributes" => array("class", "id"));
     $filter = new \ZendVN\Filter\Purifier($options);
     $output = $filter->filter($input);
     echo "<h3 style='color:red;font-weight:bold'>input : </h3>" . $input . "<br>";
     echo "<h3 style='color:red;font-weight:bold'>output : </h3>" . $output;
     return false;
 }
Example #3
0
 public function saveItem($arrParam, $options = null)
 {
     if (!empty($arrParam['sign'])) {
         $input = $arrParam['sign'];
         $config = array("HTML.AllowedAttributes" => array("style"), "HTML.AllowedElements" => array("p", "b", "em", "span", "strong"));
         $filter = new \ZendVN\Filter\Purifier($config);
         $arrParam['sign'] = $filter->filter($input);
     }
     //Quenr@i3
     if ($options['task'] == "add-item") {
         $arrParam['status'] = $arrParam['status'] == "active" ? 1 : 0;
         $arrParam['created'] = date("Y-m-d H:i:s");
         $arrParam['password'] = md5($arrParam['password']);
         $arrParam['group_id'] = $arrParam["group"];
         if (!empty($arrParam['image']['tmp_name'])) {
             $avatar = new Image();
             $arrParam['avatar'] = $avatar->upload("image");
         }
         unset($arrParam["group"]);
         unset($arrParam["image"]);
         $this->_tableGateway->insert($arrParam);
         return $this->_tableGateway->getLastInsertValue();
     }
     if ($options['task'] == "edit-item") {
         $arrParam['status'] = $arrParam['status'] == "active" ? 1 : 0;
         $arrParam['modified'] = date("Y-m-d H:i:s");
         $arrParam['group_id'] = $arrParam["group"];
         if (!empty($arrParam['image']['tmp_name'])) {
             $avatar = new Image();
             //xóa avatar cũ
             $avatar->removeAvatar($arrParam['avatar']);
             $arrParam['avatar'] = $avatar->upload("image");
         }
         unset($arrParam["group"]);
         unset($arrParam["image"]);
         //kiem tra neu co nhap password
         if (empty($arrParam["password"])) {
             unset($arrParam["password"]);
         } else {
             $arrParam["password"] = md5($arrParam["password"]);
         }
         $this->_tableGateway->update($arrParam, array("id" => $arrParam['id']));
         return $arrParam['id'];
     }
 }
Example #4
0
 public function saveItem($arrParam, $options = null)
 {
     if (!empty($arrParam['description'])) {
         $input = $arrParam['description'];
         $config = array("HTML.AllowedAttributes" => array("style"), "HTML.AllowedElements" => array("p", "b", "em", "span", "strong"));
         $filter = new \ZendVN\Filter\Purifier($config);
         $arrParam['description'] = $filter->filter($input);
     }
     //Quenr@i3
     if ($options['task'] == "add-item") {
         $arrParam['status'] = $arrParam['status'] == "active" ? 1 : 0;
         $arrParam['created'] = date("Y-m-d H:i:s");
         if (!empty($arrParam['image']['tmp_name'])) {
             $avatar = new Image();
             $arrParam['picture'] = $avatar->upload("image", "book_", array("task" => "book"));
         }
         unset($arrParam["image"]);
         //edit sale-off
         if (!empty($arrParam["sale_off_type"]) && !empty($arrParam["sale_off_value"])) {
             $arrParam["sale_off"] = Json::encode(array("type" => $arrParam["sale_off_type"], "value" => $arrParam["sale_off_value"]));
         }
         unset($arrParam["sale_off_value"]);
         unset($arrParam["sale_off_type"]);
         $this->_tableGateway->insert($arrParam);
         return $this->_tableGateway->getLastInsertValue();
     }
     if ($options['task'] == "edit-item") {
         $arrParam['status'] = $arrParam['status'] == "active" ? 1 : 0;
         $arrParam['modified'] = date("Y-m-d H:i:s");
         if (!empty($arrParam['image']['tmp_name'])) {
             $avatar = new Image();
             //xóa avatar cũ
             $avatar->removeAvatar($arrParam['picture'], array("task" => "book"));
             $arrParam['picture'] = $avatar->upload("image", "book_", array("task" => "book"));
         }
         unset($arrParam["image"]);
         //edit sale-off
         if (!empty($arrParam["sale_off_type"]) && !empty($arrParam["sale_off_value"])) {
             $arrParam["sale_off"] = Json::encode(array("type" => $arrParam["sale_off_type"], "value" => $arrParam["sale_off_value"]));
         } else {
             $arrParam["sale_off"] = null;
         }
         unset($arrParam["sale_off_value"]);
         unset($arrParam["sale_off_type"]);
         $this->_tableGateway->update($arrParam, array("id" => $arrParam['id']));
         return $arrParam['id'];
     }
 }