private static function index($args) { $output = array('url' => CORE::$cfg['host']); CHECK::is_array_exist($args); if (CHECK::is_pass()) { foreach (SYSTEM::$setting as $field => $var) { if (empty($var)) { continue; } switch ($field) { case "name": case "email": case "address": case "logo": $output[$field] = $var; break; case "tel": $output['telephone'] = $var; break; case "facebook": case "gplus": case "twitter": case "instagram": case "linkedin": $output['sameAs'][] = $var; break; } } } self::$schema[] = self::basic('Organization', $output); }
public static function register($msg, $path) { CHECK::is_array_exist($msg); if (CHECK::is_pass()) { foreach ($msg as $field => $var) { SESS::write('msg', $field, $var); } } else { SESS::write('msg', $msg); } header("location: {$path}"); }
public static function output() { CHECK::is_array_exist(self::$data); if (CHECK::is_pass()) { SCHEMA::breadcrumb(self::$data); foreach (self::$data as $key => $args) { VIEW::newBlock("TAG_CRUMBS_LIST"); foreach ($args as $field => $var) { VIEW::assign("CRUMBS_" . strtoupper($field), $var); } } } }
public static function cateList($nowID = false) { $cate = self::cateFetch(); CHECK::is_array_exist($cate); if (CHECK::is_pass()) { VIEW::newBlock('TAG_CATE_BLOCK'); foreach ($cate as $cateID => $cateStr) { VIEW::newBlock('TAG_CATE_LIST'); VIEW::assign(array('VALUE_ID' => $cateID, 'VALUE_SUBJECT' => $cateStr, 'VALUE_CURRENT' => !empty($nowID) && $nowID == $cateID ? 'current' : '')); } if (empty($nowID)) { VIEW::assignGlobal('NONE_CURRENT', 'current'); } } }
function __construct() { CHECK::is_array_exist(CORE::$args); if (CHECK::is_pass()) { self::notFound(); exit; } $temp = CORE::$temp_main; $temp_option = CORE::$temp_option; SEO::load('index'); SEO::output(); NEWS::idx_row(); new AD(); SCHEMA::make('index', SYSTEM::$setting); CORE::common_resource(); new VIEW('ogs-index-tpl.html', $temp, false, false); }
private static function replace() { CHECK::is_array_exist($_POST["id"]); if (CHECK::is_pass()) { $fieldArray = array('origin', 'target', 'status', 'id'); foreach ($_POST["id"] as $key => $ID) { unset($args); foreach ($fieldArray as $field) { switch ($field) { case "origin": $var = preg_replace('/(http:\\/\\/|https:\\/\\/)([^\\/]+)(.*)/si', '$1' . CORE::$cfg['url'] . '$3', $_POST[$field][$key]); break; default: $var = $_POST[$field][$key]; break; } $args[$field] = $var; } if (urlencode($args['origin']) == urlencode($args['target'])) { continue; } if (empty($ID)) { unset($args['id']); CRUD::dataInsert('rewrite', $args); } else { CRUD::dataUpdate('rewrite', $args); } if (!empty(DB::$error)) { $msg = DB::$error; } else { $msg = self::$lang["modify_done"]; } } } else { $msg = CHECK::$alert; } CORE::msg($msg, CORE::$manage . 'rewrite/'); }
public static function dirLoad($dirPath = false, $loadNum = false) { if (empty($dirPath)) { return false; } $realPath = ROOT_PATH . 'files/' . $dirPath; if (file_exists($realPath)) { $allFiles = glob($realPath . '/*.{jpg,png,gif,jpeg,JPG,PNG,GIF,JPEG}', GLOB_BRACE); CHECK::is_array_exist($allFiles); if (CHECK::is_pass()) { foreach ($allFiles as $key => $filePath) { $output[$key] = str_replace(ROOT_PATH, CORE::$root, $filePath); if ($loadNum !== false && is_numeric($loadNum) && ++$i >= $loadNum) { break; } } } } if (is_array($output)) { return self::indexSort($output); } else { return false; } }
private static function car() { $cartRow = SESS::get('cart'); CHECK::is_array_exist($cartRow); if (CHECK::is_pass()) { foreach ($cartRow as $id => $cart) { VIEW::newBlock("TAG_CAR_LIST"); foreach ($cart as $field => $var) { VIEW::assign("VALUE_" . strtoupper($field), $var); } VIEW::assign(array("VALUE_ID" => $id, "VALUE_ROW" => ++$i, "VALUE_AMOUNT_OPTION" => self::amount_select(99, $cart["amount"]), "VALUE_AMOUNT" => $cart["amount"])); $subtotal_array[] = $cart["subtotal"]; } self::$subtotal = array_sum($subtotal_array); self::$total = self::$subtotal + self::$ship; VIEW::assignGlobal("VALUE_TOTAL", self::$total); } else { self::$temp["MAIN"] = self::$option_temp["MSG"]; CORE::msg(CORE::$lang["cart_none"], CORE::$root . "products/"); } }
private static function images() { $rs = 'NONE'; if (!empty($_POST['call'])) { $args = GALLERY::dirLoad($_POST['call']); CHECK::is_array_exist($args); if (CHECK::is_pass()) { foreach ($args as $filePath) { VIEW::newBlock('TAG_GALLERY_IMAGE'); VIEW::assign('IMAGES_PATH', CORE::$cfg['dns'] . $filePath); } new VIEW('ogs-admin-gallery-image-tpl.html', array('IMAGE' => self::$temp_option["IMAGE"]), true, 1); $rs = VIEW::$output; } } echo $rs; }
private static function replace() { CHECK::is_array_exist($_POST["id"]); if (CHECK::is_pass()) { $sql = DB::field(CORE::$prefix . '_stock_bind'); while ($row = DB::fetch($sql)) { $field_array[] = $row["Field"]; } foreach ($_POST["id"] as $key => $id) { $rsnum = CRUD::dataFetch('stock_cate'); # 取得規格類別數量 foreach ($field_array as $field) { switch ($field) { case "item": for ($i = 0; $i < $rsnum; $i++) { if ($_POST['item_' . $i][$key] !== 'null') { $item[$i] = $_POST['item_' . $i][$key]; } if (empty($_POST["name"][$key])) { CRUD::dataFetch('stock_item', array('id' => $item[$i])); # 取得規格項目名稱 if (!empty(CRUD::$data[0]["name"])) { $name[$i] = CRUD::$data[0]["name"]; } } } $args["item"] = json_encode($item); $args["name"] = empty($_POST["name"][$key]) ? implode(" / ", $name) : $_POST["name"][$key]; break; default: $args[$field] = $_POST[$field][$key]; break; } } $args["sort"] = $key; if (empty($id)) { CRUD::dataInsert('stock_bind', $args); } else { CRUD::dataUpdate('stock_bind', $args); } if (empty($key)) { $p_id = $args["p_id"]; } if (!empty(DB::$error)) { CORE::msg(DB::$error, CORE::$manage . "stock/{$p_id}"); } } CORE::msg(self::$lang["modify_done"], CORE::$manage . "stock/{$p_id}"); } else { CORE::msg(self::$lang["no_args"], CORE::$manage . "stock/{$p_id}"); } }
private static function level_modify() { CHECK::is_array_exist($_POST["id"]); if (CHECK::is_pass()) { $field_array = array('id', 'name', 'status', 'class'); foreach ($_POST["id"] as $key => $id) { foreach ($field_array as $field) { switch ($field) { case "class": if (is_array(self::$class)) { foreach (self::$class as $cl_name) { $cl_array[$cl_name] = !empty($_POST[$field][$cl_name][$key]) ? '1' : '0'; } $args[$field] = json_encode($cl_array); } break; default: $args[$field] = $_POST[$field][$key]; break; } } if (empty($id)) { CRUD::dataInsert('level', $args); } else { CRUD::dataUpdate('level', $args); } if (DB::$error) { $msg = DB::$error; break; } else { $msg = self::$lang["modify_done"]; } } } else { $msg = CHECK::$alert; } CORE::msg($msg, CORE::$manage . 'manager/level/'); }
private static function seo() { CHECK::is_array_exist($_POST["id"]); CHECK::is_must($_POST["callback"]); if (CHECK::is_pass()) { $field_rs = DB::field(CORE::$prefix . '_seo'); while ($field_row = DB::fetch($field_rs)) { if ($field_row["Field"] != "langtag" && $field_row["Field"] != "name") { $field_array[] = $field_row["Field"]; } } foreach ($_POST["id"] as $key => $id) { foreach ($field_array as $field) { $args[$field] = $_POST[$field][$key]; } CRUD::dataUpdate('seo', $args); if (!empty(DB::$error)) { $msg = array(DB::$error, CORE::$manage . 'system/seo/'); CORE::msg($msg); return false; } } $msg = array(self::$lang["modify_done"], CORE::$manage . 'system/seo/'); } else { $msg = array(CHECK::$alert, CORE::$manage . 'system/seo/'); } CORE::msg($msg); }
public static function multi($tb_name = false, $path = false) { list($func, $action, $args) = CORE::$args; CHECK::is_array_exist($_POST["id"]); CHECK::is_must($action); if (CHECK::is_pass() && $tb_name !== false) { # 依照排序要求更改陣列排序, 以符合自動排序邏輯 if ($action == "sort") { asort($_POST["sort"]); foreach ($_POST["sort"] as $id => $sort) { if (isset($_POST["id"][$id]) && !empty($_POST["id"][$id])) { $new_args[] = $_POST["id"][$id]; } } } else { $new_args = $_POST["id"]; } foreach ($new_args as $key => $id) { switch ($action) { case "sort": CRUD::dataUpdate($tb_name, array('id' => $id, 'sort' => $_POST["sort"][$id])); if (!empty(DB::$error)) { $msg = DB::$error; } break; case "status": CRUD::dataUpdate($tb_name, array('id' => $id, 'status' => $args)); if (!empty(DB::$error)) { $msg = DB::$error; } break; case "clone": /* $rsnum = CRUD::dataFetch($tb_name,array('id' => $id)); if(!empty($rsnum)){ list($row) = CRUD::$data; unset($row["id"]); CRUD::dataInsert($tb_name,$row); if(!empty(DB::$error)){ $msg = DB::$error; } }else{ $msg = self::$lang["no_args"]; } */ break; case "del": $rs = CRUD::dataDel($tb_name, array('id' => $id)); if (!empty(DB::$error)) { $msg = DB::$error; } if (!$rs) { $msg = self::$lang["del_error"]; } break; } if (!empty($msg)) { break; } } } else { $msg = self::$lang["no_args"]; } if (empty($msg)) { $msg = self::$lang["modify_done"]; } else { $path = self::$temp_option["MSG"]; } CORE::msg($msg, $path); }
public static function dataUpdate($tb_name, array $args, $seo = false, $images = false, $primary = false) { $new_args = self::match_field($tb_name, $args); CHECK::is_array_exist($new_args); if (CHECK::is_pass()) { $new_args = array_reverse($new_args); DB::update(CORE::$prefix . "_" . $tb_name, self::content_handle($new_args), $primary); # 自動排序 if ($new_args["sort"]) { SORT::auto($tb_name, CORE::$langtag, $new_args["id"], $new_args["sort"]); } # 圖片處理 if (is_array($args["images"]) && $images) { IMAGES::modify($args["images"], $tb_name, $new_args["id"]); } if ($seo) { $args["id"] = $args["seo_id"]; SEO::modify($args); } } else { return false; } }
function args_combine($args = false) { CHECK::is_array_exist($args); if (CHECK::is_pass()) { foreach ($args as $args_key => $args_item) { if (is_array($args_item)) { $args_array[] = self::array_args_combine($args_item); } else { $args_array[] = "'{$args_item}'"; } } return implode(",", $args_array); } else { return $args; } }
public static function output($args = false) { if (is_array($args)) { $output = $args; } else { $output = self::$data; } CHECK::is_array_exist($output); if (CHECK::is_pass()) { foreach ($output as $field => $var) { switch ($field) { case "short_desc": $var = !empty($var) ? "<h2>{$var}</h2>" : ''; break; } self::$output[$field] = $var; VIEW::assignGlobal("SEO_" . strtoupper($field), $var); } } }