Source for file LC_Page_Admin_Contents.php
Documentation is available at LC_Page_Admin_Contents.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once(CLASS_PATH .
"pages/LC_Page.php");
* @author LOCKON CO.,LTD.
$this->tpl_subnavi =
'contents/subnavi.tpl';
$this->tpl_subno =
"index";
$this->selected_year =
date("Y");
$this->selected_month =
date("n");
$this->selected_day =
date("j");
$this->tpl_subtitle =
'新着情報管理';
$objDate =
new SC_Date(ADMIN_NEWS_STARTYEAR);
$this->arrYear =
$objDate->getYear();
$this->arrMonth =
$objDate->getMonth();
$this->arrDay =
$objDate->getDay();
if (!isset
($_POST['mode'])) $_POST['mode'] =
"";
if ( $_POST['mode'] ==
'regist'){
foreach($_POST as $key =>
$val) {
$this->selected_year =
$_POST["year"];
$this->selected_month =
$_POST["month"];
$this->selected_day =
$_POST["day"];
if (isset
($_POST['link_method']) ==
""){
$_POST['link_method'] =
1;
$this->registDate =
$_POST['year'] .
"/".
$_POST['month'] .
"/".
$_POST['day'];
if ($_POST["mode"] ==
"search" &&
is_numeric($_POST["news_id"])) {
$sql =
"SELECT *, cast(news_date as date) as cast_news_date FROM dtb_news WHERE news_id = ? ";
$result =
$conn->getAll($sql, array($_POST["news_id"]));
foreach($result[0] as $key =>
$val ){
$arrData =
split("-",$result[0]["cast_news_date"]);
$this->selected_year =
$arrData[0];
$this->selected_month =
$arrData[1];
$this->selected_day =
$arrData[2];
if ( $_POST['mode'] ==
'delete' &&
is_numeric($_POST["news_id"])) {
$pre_rank =
$conn->getone(" SELECT rank FROM dtb_news WHERE del_flg = 0 AND news_id = ? ", array( $_POST['news_id'] ));
//-- 削除する新着情報以降のrankを1つ繰り上げておく
$sql =
"UPDATE dtb_news SET rank = rank - 1, update_date = NOW() WHERE del_flg = 0 AND rank > ?";
$conn->query( $sql, array( $pre_rank ) );
$sql =
"UPDATE dtb_news SET rank = 0, del_flg = 1, update_date = NOW() WHERE news_id = ?";
$conn->query( $sql, array( $_POST['news_id'] ) );
$this->reload(); //自分にリダイレクト(再読込による誤動作防止)
if ( $_POST['mode'] ==
'move' &&
is_numeric($_POST["news_id"]) ) {
if ($_POST["term"] ==
"up") {
$objDb->sfRankUp("dtb_news", "news_id", $_POST["news_id"]);
} else if ($_POST["term"] ==
"down") {
$objDb->sfRankDown("dtb_news", "news_id", $_POST["news_id"]);
//sf_rebuildIndex($conn);
if ($_POST['mode'] ==
'moveRankSet') {
$key =
"pos-".
$_POST['news_id'];
$objDb->sfMoveRank("dtb_news", "news_id", $_POST['news_id'], $input_pos);
$sql =
"SELECT *, cast(news_date as date) as cast_news_date FROM dtb_news WHERE del_flg = '0' ORDER BY rank DESC";
$this->list_data =
$conn->getAll($sql);
$this->line_max =
count($this->list_data);
$sql =
"SELECT MAX(rank) FROM dtb_news WHERE del_flg = '0'"; // rankの最大値を取得
$this->max_rank =
$conn->getOne($sql);
$this->arrForm['news_select'] =
0;
$objView->assignobj($this);
$objView->display(MAIN_FRAME);
// 文字列の変換(mb_convert_kanaの変換オプション)
foreach ($arrFlag as $key=>
$line) {
$data[$key] = isset
($data[$key])
$rank =
$conn->getOne("SELECT rank FROM $tableName WHERE $keyIdColumn = ?", array($keyId));
if( $position >
$rank ) $term =
"- 1"; //入れ替え先の順位が入れ換え元の順位より大きい場合
if( $position <
$rank ) $term =
"+ 1"; //入れ替え先の順位が入れ換え元の順位より小さい場合
//-- 指定した順位の商品から移動させる商品までのrankを1つずらす
$sql =
"UPDATE $tableName SET rank = rank $term, update_date = NOW() WHERE rank BETWEEN ? AND ? AND del_flg = 0";
if( $position >
$rank ) $conn->query( $sql, array( $rank +
1, $position ) );
if( $position <
$rank ) $conn->query( $sql, array( $position, $rank -
1 ) );
$sql =
"UPDATE $tableName SET rank = ?, update_date = NOW() WHERE $keyIdColumn = ? AND del_flg = 0 ";
$conn->query( $sql, array( $position, $keyId ) );
$objErr->doFunc( array("移動順位", "moveposition", 4 ), array( "ZERO_CHECK", "NUM_CHECK", "EXIST_CHECK", "MAX_LENGTH_CHECK" ) );
$rank =
$conn->getOne("SELECT rank FROM $tableName WHERE $keyIdColumn = ?", array($keyId));
if ($rank ==
$position ) $objErr->arrErr["moveposition"] .=
"※ 指定した移動順位は現在の順位です。";
if( ! $objErr->arrErr["position"] ) {
$sql =
"SELECT MAX( rank ) FROM " .
$tableName.
" WHERE del_flg = 0";
$result =
$conn->getOne($sql);
if( $position >
$result ) $objErr->arrErr["moveposition"] .=
"※ 入力された順位は、登録数の最大値を超えています。";
$objErr->doFunc(array("日付(年)", "year"), array("EXIST_CHECK"));
$objErr->doFunc(array("日付(月)", "month"), array("EXIST_CHECK"));
$objErr->doFunc(array("日付(日)", "day"), array("EXIST_CHECK"));
$objErr->doFunc(array("日付", "year", "month", "day"), array("CHECK_DATE"));
$objErr->doFunc(array("タイトル", 'news_title', MTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK"));
$objErr->doFunc(array("本文", 'url', URL_LEN), array("MAX_LENGTH_CHECK"));
$objErr->doFunc(array("本文", 'news_comment', LTEXT_LEN), array("MAX_LENGTH_CHECK"));
if ($_POST["link_method"] ==
"") {
$_POST["link_method"] =
1;
$rank_max =
$conn->getone("SELECT MAX(rank) + 1 FROM dtb_news WHERE del_flg = '0'");
$sql =
"INSERT INTO dtb_news (news_date, news_title, creator_id, news_url, link_method, news_comment, rank, create_date, update_date)
VALUES ( ?,?,?,?,?,?,?,now(),now())";
$arrRegist =
array($this->registDate, $_POST["news_title"], $_SESSION['member_id'], $_POST["news_url"], $_POST["link_method"], $_POST["news_comment"], $rank_max);
$conn->query($sql, $arrRegist);
// 最初の1件目の登録はrankにNULLが入るので対策
$sql =
"UPDATE dtb_news SET rank = 1 WHERE del_flg = 0 AND rank IS NULL";
if ($_POST["link_method"] ==
"") {
$_POST["link_method"] =
1;
$sql =
"UPDATE dtb_news SET news_date = ?, news_title = ?, creator_id = ?, update_date = NOW(), news_url = ?, link_method = ?, news_comment = ? WHERE news_id = ?";
$arrRegist =
array($this->registDate, $_POST['news_title'], $_SESSION['member_id'], $_POST['news_url'], $_POST["link_method"], $_POST['news_comment'], $_POST['news_id']);
$conn->query($sql, $arrRegist);
Documentation generated on Tue, 28 Apr 2009 18:10:50 +0900 by phpDocumentor 1.4.2