Esempio n. 1
0
 public static function dataInsert($tb_name, array $args, $multi = false, $seo = false, $images = false)
 {
     $new_args = self::match_field($tb_name, $args);
     if (!$new_args) {
         return false;
     }
     if ($multi) {
         $origin_parent = isset($new_args["parent"]) ? $new_args["parent"] : false;
         # 多重語系同步儲存
         foreach (CORE::$cfg["lang"] as $lang_array) {
             $new_args["langtag"] = $lang_array[1];
             # 自動關閉其他語系
             if ($new_args["langtag"] != CORE::$langtag && isset($new_args["status"])) {
                 $new_args["status"] = '0';
             }
             # 取得父系連結 id
             if (!empty($origin_parent)) {
                 if ($new_args["langtag"] != CORE::$langtag) {
                     $new_args["parent"] = self::getParent($tb_name, $origin_parent, $new_args["langtag"]);
                 } else {
                     $new_args["parent"] = $origin_parent;
                 }
             }
             DB::insert(CORE::$prefix . "_" . $tb_name, self::content_handle($new_args));
             $data_id[$new_args["langtag"]] = DB::get_id();
             # 自動排序
             if ($new_args["sort"]) {
                 SORT::auto($tb_name, $new_args["langtag"], $data_id[$new_args["langtag"]], $new_args["sort"]);
             }
             # 圖片處理
             if (is_array($args["images"]) && $images) {
                 IMAGES::add($tb_name, $args["images"], $data_id[$new_args["langtag"]]);
             }
             # SEO 設定
             if ($seo) {
                 SEO::add($tb_name, $data_id[$new_args["langtag"]], $args);
             }
         }
         if (is_array($data_id)) {
             self::dataLink($tb_name, $data_id);
         }
         self::$id = $data_id;
     } else {
         DB::insert(CORE::$prefix . "_" . $tb_name, self::content_handle($new_args));
         self::$id = DB::get_id();
         # 自動排序
         if ($new_args["sort"]) {
             SORT::auto($tb_name, CORE::$langtag, self::$id, $new_args["sort"]);
         }
         # 圖片處理
         if (is_array($args["images"]) && $images) {
             IMAGES::add($tb_name, $args["images"], self::$id);
         }
     }
 }