コード例 #1
0
ファイル: PageData.php プロジェクト: elijahGraff/stoma-dental
 /** DELETE page node
  * @return bool
  */
 public function delete($label)
 {
     $result = false;
     $errors = array();
     $label = $this->data["label"];
     if (!isset($label)) {
         $errors[] = RenderUtils::renderError("Label undefined!");
     } else {
         if (!PageUtils::validatePageParam($label, "label")) {
             $errors[] = RenderUtils::renderError("Label is invalid!");
         } else {
             if (!PageUtils::labelExists($label)) {
                 $errors[] = RenderUtils::renderError("Label does not exist!");
             } else {
             }
         }
     }
     /* !!!!!!!!!!!!!!!!!!!!! */
     if (PageUtils::isTechnicalPage($label)) {
         $errors[] = RenderUtils::renderError("This is technical page!");
     }
     //
     if (count($errors) == 0) {
         # TODO delete meta node
         // DELETE PAGE
         $result = PageUtils::deletePageNode($label);
         // check db errors
         if (intval(G::$db->errorCode()) != 0) {
             $error_info = G::$db->errorInfo();
             $text_error = " DB >> " . $error_info[1] . " > " . $error_info[2];
             $this->errors[] = RenderUtils::renderError($text_error);
         }
     }
     return $result;
 }
コード例 #2
0
 public static function renderNodeTableRow($node)
 {
     if (is_object($node)) {
         $node = (array) $node;
     }
     $str = "";
     $type_bkg = "";
     $row_bkg = "";
     $brand_bkg = "";
     $image_bkg = "";
     $label_bkg = "";
     $price_bkg = "";
     $amount_bkg = "";
     switch ($node["type"]) {
         default:
             $type = "unknown";
             $row_bkg = "#fcc";
             break;
         case TYPE_CATEGORY:
             $type = "category";
             $row_bkg = "#efe";
             break;
         case TYPE_PRODUCT_BIG:
             $type = "big";
             $row_bkg = "#def";
             break;
         case TYPE_PRODUCT_SMALL:
             $type = "small";
             break;
     }
     if ($node["hidden"] == "1") {
         $type = $type . " (hidden)";
         $row_bkg = "#999";
     }
     $brand = G::$pageData->getBrand($node["brand_id"]);
     if ($brand) {
         $brand_name = $brand->name;
     } else {
         if ($node["type"] == TYPE_CATEGORY) {
             $brand_name = "";
         } else {
             $brand_name = "unknown (id={$node['brand_id']})";
             $brand_bkg = "#fcc";
         }
     }
     if ($node["image"] == "") {
         $image_bkg = "#fcc";
     }
     $valid = PageUtils::validatePageParam($node["label"], "label");
     if (!$valid["result"]) {
         $label_bkg = "#fcc";
     }
     $price = $node["price"];
     $amount = $node["amount"];
     if ($node["type"] == TYPE_CATEGORY) {
         $price = "";
         $amount = "";
     } else {
         if ($node["price"] <= 0) {
             $price_bkg = "#fe3";
         }
         if ($node["amount"] <= 0) {
             $amount_bkg = "#fe3";
         }
     }
     $str .= "<tr " . ($row_bkg ? "bgcolor='{$row_bkg}'" : "") . " name={$node['id']}>" . "<td>{$node['id']}</td>" . "<td " . ($type_bkg ? "bgcolor='{$type_bkg}'" : "") . ">{$type}</td>" . "<td " . ($brand_bkg ? "bgcolor='{$brand_bkg}'" : "") . ">{$brand_name}</td>" . "<td>{$node['original_marking']}</td>" . "<td " . ($image_bkg ? "bgcolor='{$image_bkg}'" : "") . ">{$node['image']}</td>" . "<td " . ($label_bkg ? "bgcolor='{$label_bkg}'" : "") . ">{$node['label']}</td>" . "<td>{$node['title']}</td>" . "<td " . ($price_bkg ? "bgcolor='{$price_bkg}'" : "") . ">{$price}</td>" . "<td " . ($amount_bkg ? "bgcolor='{$amount_bkg}'" : "") . ">{$amount}</td>" . "</tr>\n";
     /*
     $str .= "<tr " . ($row_bkg ? "bgcolor=$row_bkg" : "") . " name=$node[id]>" .
         "<td>$node[id]</td>" .
         "<td " . ($type_bkg ? "bgcolor=$type_bkg" : "") . ">$type</td>" .
         "<td " . ($brand_bkg ? "bgcolor=$brand_bkg" : "") . ">$brand_name</td>" .
         "<td>$node[original_marking]</td>" .
         "<td " . ($image_bkg ? "bgcolor=$image_bkg" : "") . ">$node[image]</td>" .
         "<td " . ($label_bkg ? "bgcolor=$label_bkg" : "") . ">$node[label]</td>" .
         "<td>$node[title]</td>" .
         "<td " . ($price_bkg ? "bgcolor=$price_bkg" : "") . ">$price</td>" .
         "<td " . ($amount_bkg ? "bgcolor=$amount_bkg" : "") . ">$amount</td>" .
         "</tr>\n";    }
     */
     return self::encodingChecked($str);
 }