示例#1
0
 public function edit()
 {
     if (!$_POST['submit']) {
         $id = intval($_GET['id']);
         if ($id) {
             $data = $this->mdata('pages')->where("id={$id}")->get();
             $this->view['data'] = $data;
         }
         $this->editor_header();
         $this->editor('content', $data['content'], 'content_txtkey_', $data['content_txtkey_'], 'article_desc');
         $this->editor_uploadbutton('image', $data['image'], 'article_img');
         $this->view('pages/edit.html');
     } else {
         if (!$_POST['title']) {
             $this->error('title_null');
         }
         $data = array('title_key_' => trim($_POST['title_key_']), 'title' => trim($_POST['title']), 'urlkey' => to_url(trim($_POST['urlkey'])), 'content_txtkey_' => trim($_POST['content_txtkey_']), 'content' => $_POST['content'], 'sort_order' => intval($_POST['sort_order']), 'image' => trim($_POST['image']), 'meta_title_key_' => $_POST['meta_title_key_'], 'meta_title' => trim($_POST['meta_title']), 'meta_keywords_txtkey_' => $_POST['meta_keywords_txtkey_'], 'meta_keywords' => trim($_POST['meta_keywords']), 'meta_description_txtkey_' => $_POST['meta_description_txtkey_'], 'meta_description' => trim($_POST['meta_description']));
         if ($_POST['id']) {
             $id = intval($_POST['id']);
             $this->mdata('pages')->where("id={$id}")->save($data);
         } else {
             $id = $this->mdata('pages')->add($data);
         }
         $this->model('urlkey')->set_page($id, $data['urlkey']);
         $this->ok('edit_success', url('pages/index'));
     }
 }
示例#2
0
 public function addcate()
 {
     $catelist = $this->model('goodscate')->getlist();
     if (!$_POST['submit']) {
         if ($_GET['id']) {
             $id = intval($_GET['id']);
             $data = $this->mdata('goods_cate')->where("id={$id}")->get();
         } else {
             $data = array();
         }
         $this->editor_header();
         $this->editor('description', $data['description'], 'description_txtkey_', $data['description_txtkey_'], 'article_desc');
         $this->editor_uploadbutton('image', $data['image'], 'goods_cate');
         $this->view['data'] = $data;
         $this->view['title'] = lang('edit_category');
         $this->view['catelist'] = $catelist;
         $this->view('goodscate/addcate.html');
     } else {
         if (!$_POST['name']) {
             $this->error('name_null');
         }
         //if image is not uploaded
         $image = trim($_POST['image']);
         $image = $this->model('image')->check_img($image, 'goods_cate');
         $data = array('pid' => intval($_POST['pid']), 'name_key_' => trim($_POST['name_key_']), 'name' => trim($_POST['name']), 'description_txtkey_' => $_POST['description_txtkey_'], 'description' => $_POST['description'], 'meta_title_key_' => $_POST['meta_title_key_'], 'meta_title' => trim($_POST['meta_title']), 'meta_keywords_txtkey_' => $_POST['meta_keywords_txtkey_'], 'meta_keywords' => trim($_POST['meta_keywords']), 'meta_description_txtkey_' => $_POST['meta_description_txtkey_'], 'meta_description' => trim($_POST['meta_description']), 'urlkey' => to_url(trim($_POST['urlkey'])), 'image' => $image, 'sort_order' => intval($_POST['sort_order']));
         if ($_POST['id']) {
             $cate_id = intval($_POST['id']);
             $this->mdata('goods_cate')->where("id={$cate_id}")->save($data);
         } else {
             $cate_id = $this->mdata('goods_cate')->add($data);
         }
         $this->model('urlkey')->set_goodscate($cate_id, $data['urlkey']);
         $this->ok('edit_success', url('goodscate/index'));
     }
 }
示例#3
0
 public function write_url()
 {
     return "/movie/" . $this->id . "/" . to_url($this->title);
 }
        $src = src_expand($src);
    }
    $query = "\n        SELECT\n            source_id,\n            is_unused(source_id) AS unused,\n            get_source_text(source_id) AS src_txt,\n            source_date\n        FROM\n            sources\n        WHERE\n            source_text SIMILAR TO '%{$src}%'\n    ";
    if ($scope != 0) {
        $query .= "\n            AND\n                part_type = {$scope}\n        ";
    }
    if ($yr && $diff) {
        $query .= "\n            AND\n                EXTRACT(YEAR FROM source_date)\n                    BETWEEN {$yr} - {$diff} AND {$yr} + {$diff}\n        ";
    }
    if ($yr && !$diff) {
        $query .= "\n            AND\n                EXTRACT(YEAR FROM source_date) = {$yr}\n        ";
    }
    $query .= "\n        ORDER BY\n            source_date\n    ";
    $handle = pg_query($query);
    echo "<table>\n";
    while ($row = pg_fetch_assoc($handle)) {
        $id = $row['source_id'];
        echo '<tr>';
        echo td_numeric(square_brace(to_url('./source_manager.php', array('node' => $id), $id)));
        if ($row['unused'] == 't') {
            echo td(span_type(square_brace(italic($row['source_date'])) . ' ' . $row['src_txt'], 'faded'));
        } else {
            echo td(square_brace(italic($row['source_date'])) . ' ' . $row['src_txt']);
        }
        echo "</tr>\n";
    }
    echo "</table>\n";
    echo '<p>' . pg_num_rows($handle) . ' treff.</p>';
}
echo "</div>\n";
include "./footer.php";
function list_mentioned($node, $hotlink = 0)
{
    global $app_path, $_edit, $_delete;
    echo "<ol>\n";
    $handle = pg_query("\n        SELECT\n            per_id,\n            get_role(role_fk) AS rolle,\n            person_fk,\n            get_surety(surety_fk) AS surety,\n            s_name,\n            link_expand(sl_note) AS note\n        FROM\n            source_linkage\n        WHERE\n            source_fk = {$node}\n        ORDER BY\n            role_fk,\n            per_id\n    ");
    while ($row = pg_fetch_assoc($handle)) {
        echo '<li>' . $row['rolle'] . ': ';
        echo '«' . $row['s_name'] . '»';
        if ($row['person_fk']) {
            echo conc(curly_brace($row['surety'])) . conc(linked_name($row['person_fk'], "{$app_path}/family.php"));
        }
        if (has_parents($row['person_fk'])) {
            echo conc(child_of($row['person_fk']));
        }
        if ($row['note']) {
            echo ': ' . $row['note'];
        }
        if ($hotlink) {
            echo conc(paren(to_url("{$app_path}/forms/linkage_edit.php", array('node' => $node, 'id' => $row['per_id']), $_edit) . ' / ' . to_url("{$app_path}/forms/linkage_delete.php", array('node' => $node, 'id' => $row['per_id']), $_delete)));
        }
        echo "</li>\n";
    }
    if ($hotlink) {
        echo '<li>' . to_url("{$app_path}/forms/linkage_add.php", array('node' => $node), "Legg til lenke") . "</li>\n";
    }
    echo "</ol>\n";
}
            pg_query("\n                DELETE FROM relations\n                WHERE relation_id = {$relid_s}\n            ");
        }
        // transfer remaining relations
        pg_query("\n            UPDATE relations\n            SET child_fk = {$target}\n            WHERE child_fk = {$source}\n        ");
        pg_query("\n            UPDATE relations\n            SET parent_fk = {$target}\n            WHERE parent_fk = {$source}\n        ");
        // update source_linkage
        pg_query("\n            UPDATE source_linkage\n            SET person_fk = {$target}\n            WHERE person_fk = {$source}\n        ");
        // insert "event" for source person with a link to target person
        $event_note = " [p={$target}|ID #{$target}]";
        $event = fetch_val("\n            INSERT INTO events (\n                tag_fk,\n                place_fk,\n                event_date,\n                sort_date,\n                event_note\n            )\n            VALUES (\n                1040,\n                1,\n                '000000003000000001',\n                '00010101',\n                '{$event_note}'\n            )\n            RETURNING event_id\n        ");
        add_participant($source, $event);
        pg_query("\n            INSERT INTO merged (old_person_fk,new_person_fk)\n            VALUES ({$source}, {$target})\n        ");
        set_last_edit($source);
        set_last_edit($target);
        pg_query("\n            COMMIT\n        ");
        // return to main view of "stripped" person.
        header("Location: {$app_root}/family.php?person={$source}");
    } else {
        // explain why the merge failed
        $title = "{$_App_name}: {$_Merge_persons_failed}";
        require "./form_header.php";
        echo "<h2>{$title}!</h2>\n";
        $name_1 = get_name($person_1);
        $name_2 = get_name($person_2);
        echo "<p>{$_Cannot_merge} {$name_1} ({$_born} {$bdate_1}), {$_with} {$name_2} ({$_born} {$bdate_2}).<br />\n";
        echo "{$_Reason}: {$reason}</p>\n";
        echo para(to_url('../family.php', array(person => $person_1), "{$_Return_to} {$person_1} {$name_1}"));
        echo para(to_url('../family.php', array(person => $person_2), "{$_Return_to} {$person_2} {$name_2}"));
        echo "</body>\n</html>\n";
    }
}
function format_link()
{
    global $post;
    $link_url = get_post_meta($post->ID, 'format_link_url', true);
    $url = !empty($link_url) ? to_url($link_url) : "#";
    echo '<div class="link-content">';
    echo '<h2 class="link-text"><a href="' . $url . '" target="_blank">' . get_the_title() . '</a></h2>';
    echo '<a href="' . $url . '" target="_blank"><span class="sub-title">' . $url . '</span></a></div>';
}
示例#8
0
function show_parent($person, $gender)
{
    // print names and lifespans of parents.
    // valid $gender values are 1=father, 2=mother
    global $language, $_Add, $_Insert, $_edit, $_delete, $_Father, $_father, $_Mother, $_mother, $_toolhelp_edit_parent, $_toolhelp_add_parent, $_toolhelp_insert_parent, $_toolhelp_delete_parent;
    $parent_id = fetch_val("SELECT get_parent({$person}, {$gender})");
    $surety = fetch_val("\n        SELECT get_lsurety((\n            SELECT surety_fk\n            FROM relations\n            WHERE parent_fk = {$parent_id}\n            AND child_fk = {$person}\n        ), '{$language}')\n    ");
    if ($gender == 1) {
        $Parent = $_Father;
        $parent = $_father;
        $para = '<p>';
        $newline = '<br />';
    } else {
        // $gender == 2
        $Parent = $_Mother;
        $parent = $_mother;
        $para = '';
        $newline = '</p>';
    }
    echo $para . conc(bold($Parent) . ':') . conc(get_name_and_dates('', $parent_id));
    if ($parent_id) {
        echo conc(curly_brace($surety)) . conc(span_type(paren(to_url('./forms/relation_edit.php', array('person' => $person, 'parent' => $parent_id), $_edit, sprintf($_toolhelp_edit_parent, $parent)) . ' / ' . to_url('./forms/relation_delete.php', array('person' => $person, 'parent' => $parent_id), $_delete, sprintf($_toolhelp_delete_parent, $parent))), "hotlink")) . cite(get_relation_id($person, $gender), 'relation', $person);
    } else {
        echo conc(span_type(paren(to_url('./forms/person_insert.php', array('person' => $person, 'addparent' => 'true', 'gender' => $gender), "{$_Add} {$parent}", sprintf($_toolhelp_add_parent, $parent)) . ' / ' . to_url('./forms/relation_edit.php', array('person' => $person, 'gender' => $gender), "{$_Insert} {$parent}", sprintf($_toolhelp_insert_parent, $parent))), "hotlink"));
    }
    echo "{$newline}\n";
}
示例#9
0
文件: catalog.php 项目: NazarK/sqp
function catalog_menu_with_links($parent_id)
{
    $items = catalog_items(0);
    global $lang_dir;
    foreach ($items as &$item) {
        $item->link = "{$lang_dir}catalog/" . to_url(fld_trans($item->title, "eng"));
        $item->altlink = $item->link;
    }
    $o = "";
    foreach ($items as &$item) {
        $item->title = fld_trans($item->title);
        $o .= "<div class='menuItemDiv level2'><div class=title><a class=menuItem href='{$item->link}'  althref='{$item->altlink}'>{$item->title}</a></div></div>";
    }
    return $o;
}
 function shortcode_jw_partner($atts, $content)
 {
     $category_list = isset($atts['partner_category_list']) ? $atts['partner_category_list'] : '';
     //$arrow = '<div class="carousel-arrow jw-carrow">';
     //$arrow .= '<a class="carousel-prev" href="#"><i class="icon-angle-left"></i></a>';
     //$arrow .= '<a class="carousel-next" href="#"><i class="icon-angle-right"></i></a>';
     //$arrow .= '</div>';
     $output = '<div class="carousel-container">';
     $output .= '<div class="jw-carousel-partner list_carousel">';
     $output .= '<ul class="jw-carousel">';
     $query = array('post_type' => 'jw_partner', 'posts_per_page' => -1);
     $cats = explode(",", $category_list);
     $imgwidth = 270;
     if (!empty($cats[0])) {
         $query['tax_query'] = array(array('taxonomy' => 'cat_partner', 'terms' => $cats, 'field' => 'id'));
     }
     if (!empty($atts['order'])) {
         switch ($atts['order']) {
             case "date_asc":
                 $query['orderby'] = 'date';
                 $query['order'] = 'ASC';
                 break;
             case "title_asc":
                 $query['orderby'] = 'title';
                 $query['order'] = 'ASC';
                 break;
             case "title_desc":
                 $query['orderby'] = 'title';
                 $query['order'] = 'DESC';
                 break;
             case "random":
                 $query['orderby'] = 'rand';
                 break;
         }
     }
     // START - LOOP
     query_posts($query);
     while (have_posts()) {
         the_post();
         $imgheight = $atts['image_height'];
         $output .= '<li>';
         if (get_metabox('link') != '') {
             $output .= '<a href="' . to_url(get_metabox('link')) . '" target="_blank">';
             $output .= post_image_show($imgwidth, $imgheight);
             $output .= '</a>';
         } else {
             $output .= post_image_show($imgwidth, $imgheight);
         }
         $output .= '</li>';
     }
     wp_reset_query();
     // END   - LOOP
     $output .= '</ul>';
     $output .= '<div class="clearfix"></div>';
     //$output .= $arrow;
     $output .= '</div>';
     $output .= '</div>';
     return $output;
 }
示例#11
0
function get_sidebar_name($p)
{
    $name = get_name($p);
    $name .= has_descendants($p) ? '+' : '';
    return to_url('./pedigree.php', array('person' => $p), $name);
}
示例#12
0
 *   Copyright (C) 2011 by Leif B. Kristensen <*****@*****.**>        *
 *   All rights reserved. For terms of use, see LICENSE.txt                *
 ***************************************************************************/
// This script is basically a report listing sources of one type.
// It is accessed from the Source Part Type Manager via the 'report' link.
require "./settings/settings.php";
require "./functions.php";
require_once "./langs/{$language}.php";
$spt = $_GET['spt'];
$label = 'label_' . $language;
$spt_name = fetch_val("\n    SELECT {$label} FROM source_part_types WHERE part_type_id = {$spt}\n");
$title = "{$_All} {$_sources} {$_of} type {$spt_name}";
require "./header.php";
echo "<div class=\"normal\">\n";
echo "<h2>{$title}</h2>\n";
echo "<table>";
$handle = pg_query("\n    SELECT\n        source_id,\n        link_expand(source_text) AS txt,\n        source_date,\n        ecc(source_id) AS e,\n        rcc(source_id) AS r,\n        ssc(source_id) AS s,\n        usc(source_id) AS u,\n        spt.{$label} AS {$label}\n    FROM\n        sources, source_part_types spt\n    WHERE\n        spt.part_type_id = sources.part_type\n    AND\n        spt.part_type_id = {$spt}\n    AND\n        source_id <> 0\n    ORDER BY\n        source_date,\n        source_text\n");
while ($row = pg_fetch_assoc($handle)) {
    $id = $row['source_id'];
    echo '<tr>';
    echo td(paren(to_url('source_manager.php', array('node' => $id), $_Select) . '&nbsp;/&nbsp;' . to_url('./forms/source_edit.php', array('person' => 0, 'source' => $id), $_Edit)));
    if ($row['e'] || $row['r'] || $row['s']) {
        echo td(square_brace(italic($row['source_date'])) . ' ' . $row['txt'] . node_details($row['e'], $row['r'], $row['s'], $row['u']));
    } else {
        // source is unused, print with gray text
        echo td(span_type(square_brace(italic($row['source_date'])) . conc($row['txt']), "faded"));
    }
    echo "</tr>\n";
}
echo "</table>\n";
include "./footer.php";
示例#13
0
 public function editcate()
 {
     if (!$_POST['submit']) {
         $id = intval($_GET['cate_id']);
         if ($id) {
             $data = $this->mdata('article_cate')->where("cate_id={$id}")->get();
             $this->view['data'] = $data;
         }
         $this->editor_header();
         $this->editor_uploadbutton('image', $data['image'], 'articlecate_img');
         $this->view('article/editcate.html');
     } else {
         if (!$_POST['name']) {
             $this->error('name_null');
         }
         $data = array('name_key_' => trim($_POST['name_key_']), 'name' => trim($_POST['name']), 'urlkey' => to_url(trim($_POST['urlkey'])), 'image' => trim($_POST['image']), 'sort_order' => intval($_POST['sort_order']), 'status' => intval($_POST['status']));
         if ($_POST['cate_id']) {
             $id = intval($_POST['cate_id']);
             $this->mdata('article_cate')->where("cate_id={$id}")->save($data);
         } else {
             $id = $this->mdata('article_cate')->add($data);
         }
         $this->model('urlkey')->set_articlecate($id, $data['urlkey']);
         $this->ok('edit_success', url('article/cate'));
     }
 }
示例#14
0
文件: msg.php 项目: PoppyLi/PCMS
	<div class='btn-group'>
		<a class='btn' href="<?php 
            echo to_url($this->router->class . '/edit/' . $id);
            ?>
" target="_self"> 继续编辑该条信息 </a>
		<a class='btn btn-info' href="<?php 
            echo $back_url;
            ?>
" target="_self"> 回到列表页 </a>
	</div>
	<?php 
            break;
        default:
            ?>
		<a class='btn btn-info' href="<?php 
            echo to_url($this->router->class . '/index/');
            ?>
" target="_self"> 返回 </a>
	<?php 
    }
    // end switch
} else {
    ?>
		<a class='btn btn-info' href="<?php 
    echo $back_url;
    ?>
" target="_self"> 返回默认 </a>
	<?php 
}
?>
示例#15
0
 public function update()
 {
     $group_id = intval($_POST['group_id']);
     $title = trim($_POST['title']);
     $title_key_ = $_POST['title_key_'];
     $urlkey = to_url(trim($_POST['urlkey']));
     $sku = trim($_POST['sku']);
     $cate_id = $_POST['cate_id'];
     $price = floatval($_POST['price']);
     $stock = intval($_POST['stock']);
     $sort_order = intval($_POST['sort_order']);
     $goods_id = intval($_POST['goods_id']);
     if (!$title || !$sku) {
         $this->error('required_null');
     }
     //check sku
     $row = $this->db->table('goods')->where("sku='{$sku}'")->get();
     if ($row && $row['goods_id'] != $goods_id) {
         $this->error('sku_repeated');
     }
     //if image is not uploaded
     $image = trim($_POST['image']);
     $image = $this->model('image')->check_img($image, 'goods_main_img');
     $data = array('group_id' => $group_id, 'title' => $title, 'title_key_' => $title_key_, 'urlkey' => $urlkey, 'sku' => $sku, 'price' => $price, 'price_origin' => floatval($_POST['price_origin']), 'weight' => intval($_POST['weight']), 'brief_txtkey_' => $_POST['brief_txtkey_'], 'brief' => trim($_POST['brief']), 'description_txtkey_' => $_POST['description_txtkey_'], 'description' => $_POST['description'], 'meta_title_key_' => $_POST['meta_title_key_'], 'meta_title' => trim($_POST['meta_title']), 'meta_keywords_txtkey_' => $_POST['meta_keywords_txtkey_'], 'meta_keywords' => trim($_POST['meta_keywords']), 'meta_description_txtkey_' => $_POST['meta_description_txtkey_'], 'meta_description' => trim($_POST['meta_description']), 'image' => $image, 'stock' => $stock, 'is_sale' => intval($_POST['is_sale']), 'sort_order' => $sort_order);
     if ($goods_id > 0) {
         $this->mdata('goods')->where("goods_id={$goods_id}")->save($data);
     } else {
         $data['addtime'] = time();
         $goods_id = $this->mdata('goods')->add($data);
         if ($goods_id < 1) {
             $this->error('add_error');
         }
     }
     $this->model('urlkey')->set_goods($goods_id, $data['urlkey']);
     //category
     if ($cate_id && is_array($cate_id)) {
         $this->model('goods')->update_cate($goods_id, $cate_id);
     }
     //attribute
     $attr = $_POST['attr'];
     $attr_value = $_POST['attr_value'];
     if ($attr && is_array($attr) && $attr_value && is_array($attr_value)) {
         $this->db->table('goods_attr')->where("goods_id={$goods_id}")->delete();
         foreach ($attr as $aid) {
             if ($attr_value[$aid]) {
                 foreach ($attr_value[$aid] as $av_id) {
                     $this->db->table('goods_attr')->insert(array('goods_id' => $goods_id, 'attr_id' => $aid, 'av_id' => $av_id));
                 }
             }
         }
     }
     //extend
     $extend = $_POST['extend'];
     if ($extend && is_array($extend)) {
         $extend_at = array();
         $extendlist = $this->db->table('goods_extend')->where("goods_id={$goods_id}")->getlist();
         foreach ($extendlist as $v) {
             $extend_at[$v['extend_id']] = $v['val'];
         }
         foreach ($extend as $extend_id => $v) {
             if (is_array($v)) {
                 $v = implode(',', $v);
             } else {
                 //is file
                 $type = $this->model('extend')->get_type($extend_id);
                 if ($type == 5) {
                     $file = $this->model('extend')->get_file($extend_id);
                     if ($file) {
                         $v = $file;
                     }
                 }
             }
             $v = trim($v);
             if (!empty($v)) {
                 if (!$extend_at[$extend_id]) {
                     $this->db->table('goods_extend')->insert(array('goods_id' => $goods_id, 'extend_id' => $extend_id, 'val' => $v));
                 } elseif ($v != $extend_at[$extend_id]) {
                     $this->db->table('goods_extend')->where("goods_id={$goods_id} and extend_id={$extend_id}")->update(array('val' => $v));
                 }
             } else {
                 $type = $this->model('extend')->get_type($extend_id);
                 if ($type == 5) {
                     $this->model('extend')->del_file($goods_id, $extend_id);
                 }
                 $this->db->table('goods_extend')->where("goods_id={$goods_id} and extend_id={$extend_id}")->delete();
             }
         }
     }
     //image
     $imagemore = $_POST['imagemore'];
     $imagemore_label = $_POST['imagemore_label'];
     $imagemore_label_key = $_POST['imagemore_label_key'];
     if ($imagemore && is_array($imagemore)) {
         $imglist = array();
         $list = $this->db->table('goods_image')->where("goods_id={$goods_id}")->getlist();
         foreach ($list as $v) {
             $imglist[] = $v['image'];
         }
         $s_arr = array();
         foreach ($imagemore as $key => $img) {
             if (!in_array($img, $imglist)) {
                 $goods_image = array('goods_id' => $goods_id, 'image' => $img, 'label_key_' => $imagemore_label_key[$key], 'label' => $imagemore_label[$key]);
                 $this->mdata('goods_image')->add($goods_image);
             } else {
                 $goods_image = array('label_key_' => $imagemore_label_key[$key], 'label' => $imagemore_label[$key]);
                 $this->mdata('goods_image')->where("goods_id={$goods_id} and image='{$img}'")->save($goods_image);
                 $s_arr[] = $img;
             }
         }
         $diff_arr = array_diff($imglist, $s_arr);
         if ($diff_arr) {
             foreach ($diff_arr as $v) {
                 $this->mdata('goods_image')->where("goods_id={$goods_id} and image='{$v}'")->delete();
             }
         }
     }
     //option
     $op_name_id = $_POST['op_name_id'];
     $op_name = $_POST['op_name'];
     $op_name_key = $_POST['op_name_key'];
     $op_price = $_POST['op_price'];
     if ($op_name && is_array($op_name) && is_array($op_price)) {
         $option = array();
         $optionlist = $this->mdata('goods_option')->where("goods_id={$goods_id}")->getlist();
         if ($optionlist) {
             foreach ($optionlist as $v) {
                 $op_id = $v['op_id'];
                 $oid = $v['id'];
                 $option[$op_id][$oid] = $v;
             }
         }
         foreach ($op_name as $op_id => $v) {
             $n = 1;
             foreach ($v as $k => $name) {
                 $oid = $op_name_id[$op_id][$k];
                 $name = trim($name);
                 if ($name) {
                     $price = floatval($op_price[$op_id][$k]);
                     $name_key = $op_name_key[$op_id][$k];
                     if ($option[$op_id][$oid]) {
                         $data = array('name_key_' => $name_key ? $name_key : $option[$op_id][$oid]['name_key_'], 'name' => $name, 'price' => $price, 'sort_order' => $n);
                         $this->mdata('goods_option')->where("id={$oid}")->save($data);
                         unset($option[$op_id][$oid]);
                     } else {
                         $data = array('goods_id' => $goods_id, 'op_id' => $op_id, 'name_key_' => $name_key, 'name' => $name, 'image' => '', 'price' => $price, 'sort_order' => $n);
                         $this->mdata('goods_option')->add($data);
                     }
                     $n++;
                 }
             }
         }
         if ($option) {
             foreach ($option as $op_id => $val) {
                 if ($val) {
                     foreach ($val as $id => $v) {
                         $this->mdata('goods_option')->where("id={$id}")->delete();
                     }
                 }
             }
         }
     }
     //cross sell
     $cross_sell = $_POST['cross_sell'];
     if ($cross_sell && is_array($cross_sell)) {
         $cs_ids = implode(',', $cross_sell);
         $n = $this->db->table('goods_crosssell')->where("goods_id={$goods_id}")->count();
         if ($n > 0) {
             $this->db->table('goods_crosssell')->where("goods_id={$goods_id}")->update(array('relate_ids' => $cs_ids));
         } else {
             $data = array('goods_id' => $goods_id, 'relate_ids' => $cs_ids);
             $this->db->table('goods_crosssell')->insert($data);
         }
     }
     $this->ok('edit_success', url('goods/index'));
 }
示例#16
0
/***************************************************************************
 *   nolink.php                                                            *
 *   Yggdrasil: Unidentified people mentioned in sources                   *
 *   (Part of the experimental source linkage                              *
 *                                                                         *
 *   Copyright (C) 2009-2011 by Leif B. Kristensen <*****@*****.**>   *
 *   All rights reserved. For terms of use, see LICENSE.txt                *
 ***************************************************************************/
require "./settings/settings.php";
require_once "./langs/{$language}.php";
require "./functions.php";
$title = 'Uidentifiserte personer';
require "./header.php";
echo "<div class=\"normal\">\n";
echo "<h2>Uidentifiserte personer fra lenking:</h2>\n";
$handle = pg_query("\n    SELECT\n        s.source_id AS source,\n        part_ldesc(s.part_type) AS s_type,\n        get_lsurety(l.surety_fk) AS surety,\n        get_lrole(l.role_fk) AS rolle,\n        l.s_name AS name,\n        get_source_text(s.source_id) AS txt,\n        link_expand(l.sl_note) AS note\n    FROM\n        sources s,\n        source_linkage l\n    WHERE\n        l.source_fk = s.source_id\n    AND\n        l.person_fk IS NULL\n    ORDER BY\n        s.source_date,\n        s.sort_order,\n        l.per_id\n");
echo "<ol>\n";
while ($row = pg_fetch_assoc($handle)) {
    $principal = fetch_val("\n        SELECT person_fk FROM source_linkage\n        WHERE source_fk = " . $row['source'] . " AND role_fk = 1\n    ");
    echo "<li>" . bold($row['name']) . '<br />' . $row['surety'] . ' ' . $row['rolle'] . ' ved ' . $row['s_type'];
    if ($principal) {
        echo ' av ' . linked_name($principal, './family.php');
    }
    echo '. ' . $row['txt'];
    echo conc(italic($row['note']));
    echo conc(paren(to_url('./source_manager.php', array('node' => $row['source']), 'Til kildebehandler')));
    echo "</li>\n";
}
echo "</ol>\n";
echo "</div>\n";
include "./footer.php";
        $id = $row['source_id'];
        echo '<tr>';
        if ($friendly) {
            echo td(paren(to_url($_SERVER['PHP_SELF'], array('node' => $id), $_Select) . '&nbsp;/&nbsp;' . to_url('./forms/source_edit.php', array('person' => 0, 'source' => $id), $_Edit)));
            echo td_numeric(square_brace($row['sort_order']));
            echo td(paren($row[$label]));
        } else {
            echo td_numeric(square_brace(to_url($_SERVER['PHP_SELF'], array('node' => $id), $id, $_goto)));
            echo td_numeric(square_brace($row['sort_order']));
            echo td(paren(to_url('./forms/source_edit.php', array('person' => 0, 'source' => $id), $row[$label], $_edit)));
        }
        if ($row['e'] || $row['r'] || $row['s']) {
            echo td(square_brace(italic($row['source_date'])) . ' ' . $row['txt'] . node_details($row['e'], $row['r'], $row['s'], $row['u']));
        } else {
            // source is unused, print with gray text
            if ($show_delete) {
                // show link for source deletion
                echo td(span_type(square_brace(italic($row['source_date'])) . conc($row['txt']), "faded") . conc(paren(to_url('./forms/source_delete.php', array('node' => $self, 'id' => $id), bold($_delete)))));
            } else {
                echo td(span_type(square_brace(italic($row['source_date'])) . conc($row['txt']), "faded"));
            }
        }
        echo "</tr>\n";
    }
    echo "</table>\n";
}
if ($props['is_leaf'] == "f") {
    echo para(to_url('./forms/source_add.php', array('node' => $self), $_Add_source));
}
echo "</div>\n";
include "./footer.php";