Beispiel #1
0
         $context = "";
         $save = "save";
     }
     $template = file_get_contents($basePath . "assets/modules/easy_board/tpl/add.tpl");
     $template = str_replace("[+id+]", $id, $template);
     $template = str_replace("[+pagetitle+]", $pagetitle, $template);
     $template = str_replace("[+content+]", $content, $template);
     $template = str_replace("[+createdby+]", $createdby, $template);
     $template = str_replace("[+contact+]", $contact, $template);
     $template = str_replace("[+price+]", $price, $template);
     $template = str_replace("[+hit+]", $hit, $template);
     $template = str_replace("[+parent+]", genOptionList($categoryID, $parent), $template);
     $template = str_replace("[+city+]", genOptionList($cityID, $city, false), $template);
     $template = str_replace("[+contexts+]", genOptionListContext($contexts, $context), $template);
     $template = str_replace("[+published+]", genCheckbox($published), $template);
     $template = str_replace("[+allcity+]", genCheckbox($allcity), $template);
     $template = str_replace("[+image+]", genImageForm($image, $id), $template);
     echo $template;
     echo '
 <button class="styler" href="#" onclick="postForm(\'' . $save . '\',\'' . $id . '\');return false;">Save</button>
 &nbsp;&nbsp;
 <a href="#" onclick="postForm(\'reload\',null);return false;">Cancel</a>
 ';
     break;
     //Сохранение записи в БД
 //Сохранение записи в БД
 case 'save':
     $fields = array();
     $fields = array('pagetitle' => $modx->db->escape($_POST[pagetitle]), 'content' => $modx->db->escape($_POST[content]), 'contact' => $modx->db->escape($_POST[contact]), 'price' => (int) $_POST[price], 'parent' => (int) $_POST[parent], 'city' => (int) $_POST[city], 'hit' => (int) $_POST[hit], 'createdby' => (int) $_POST[createdby], 'image' => loadImage($imageDir), 'createdon' => time(), 'context' => $modx->db->escape($_POST[context]));
     $fields['published'] = isset($_POST[published]) ? 1 : 0;
     $fields['allcity'] = isset($_POST[allcity]) ? 1 : 0;
Beispiel #2
0
                            die;
                        } else {
                            $query = $modx->db->update($fields, $mod_table, "id = {$id}");
                        }
                        header("Location: http://" . $_SERVER['SERVER_NAME'] . $modx->makeUrl($idafterediturl));
                    } else {
                        die($_lang['eb_accessdenied']);
                    }
                    die("");
                }
                if ($tpledit == "") {
                    $template = file_get_contents($snippetPath . "tpl/edit.tpl");
                } else {
                    $template = $modx->getChunk($tpledit);
                }
                $pl = array("id" => $data['id'], "pagetitle" => $data['pagetitle'], "content" => $data['content'], "contact" => $data['contact'], "price" => $data['price'], "username" => $data['username'], "cityname" => $data['cityname'], "parentname" => $data['parentname'], "parent" => $data['parent'], "parentIds" => genOptionList($parentIds, $data['parent']), "cityIds" => genOptionList($cityIds, $data['city'], false), "allcity" => genCheckbox($data['allcity']), "published" => genCheckbox($data['published']), "date" => date("Y.m.d G:i:s", $data['createdon']));
                // photo
                if ($jquery == 1) {
                    $modx->regClientStartupScript("assets/js/jquery.min.js");
                }
                $modx->regClientStartupScript('<script language="JavaScript" type="text/javascript">
			function ItemAjax(act, id, elementID){
				$("#"+elementID+""+id).load("/assets/snippets/easy_board/easy_board.ajax.php","act="+act+"&item_id="+id);
				}
			</script>');
                $tmp = "<div id=\"picdel{$id}\">" . $_lang['eb_photo'];
                $image = $data['image'];
                if ($image == "") {
                    $tmp .= "<input name=\"image\" type=\"file\" />";
                } else {
                    if (is_file($modx->config['base_path'] . $image)) {
Beispiel #3
0
/**
 * 生成checkbox复选框组
 * @param  string  $name    复选框的name
 * @param  array   $list    复选框列表
 * @param  string  $checked 是否选中,','隔开
 * @param  string  $class   css类
 * @return string
 */
function genCheckboxs($name, array $list, $checked, $class = '')
{
    $html = '';
    $checked = array_filter(explode(',', $checked), function ($pos) {
        return !(empty($pos) && 0 !== $pos && '0' !== $pos);
    });
    $i = 0;
    foreach ($list as $text => $value) {
        $html .= in_array($i, $checked) ? genCheckbox($name, $text, $value, true, $class) : genCheckbox($name, $text, $value);
        $i++;
    }
    return $html;
}