当前位置: 首页>>代码示例>>PHP>>正文


PHP map::add方法代码示例

本文整理汇总了PHP中map::add方法的典型用法代码示例。如果您正苦于以下问题:PHP map::add方法的具体用法?PHP map::add怎么用?PHP map::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在map的用法示例。


在下文中一共展示了map::add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: do_save

 function do_save()
 {
     $id = (int) $_POST['id'];
     $uid = (int) $_POST['uid'];
     $rootid = (int) $_POST['rootid'];
     $cid = implode(',', (array) $_POST['cid']);
     $tcid = implode(',', (array) $_POST['tcid']);
     $pid = implode(',', (array) $_POST['pid']);
     $_cid = iS::escapeStr($_POST['_cid']);
     $_tcid = iS::escapeStr($_POST['_tcid']);
     $_pid = iS::escapeStr($_POST['_pid']);
     $name = iS::escapeStr($_POST['name']);
     $subtitle = iS::escapeStr($_POST['subtitle']);
     $tkey = iS::escapeStr($_POST['tkey']);
     $seotitle = iS::escapeStr($_POST['seotitle']);
     $keywords = iS::escapeStr($_POST['keywords']);
     $pic = iS::escapeStr($_POST['pic']);
     $bpic = iS::escapeStr($_POST['bpic']);
     $mpic = iS::escapeStr($_POST['mpic']);
     $spic = iS::escapeStr($_POST['spic']);
     $description = iS::escapeStr($_POST['description']);
     $url = iS::escapeStr($_POST['url']);
     $related = iS::escapeStr($_POST['related']);
     $tpl = iS::escapeStr($_POST['tpl']);
     $weight = _int($_POST['weight']);
     $ordernum = _int($_POST['ordernum']);
     $status = (int) $_POST['status'];
     $haspic = $pic ? '1' : '0';
     $pubdate = time();
     $metadata = $_POST['metadata'];
     $uid or $uid = iMember::$userid;
     if ($callback) {
         if (empty($name)) {
             echo '标签名称不能为空!';
             return false;
         }
     }
     $name or iPHP::alert('标签名称不能为空!');
     $cid or iPHP::alert('请选择标签所属栏目!');
     if ($metadata) {
         if ($metadata['key']) {
             $md = array();
             foreach ($metadata['key'] as $_mk => $_mval) {
                 !preg_match("/[a-zA-Z0-9_\\-]/", $_mval) && iPHP::alert($this->name_text . '附加属性名称只能由英文字母、数字或_-组成(不支持中文)');
                 $md[$_mval] = $metadata['value'][$_mk];
             }
         } else {
             $md = $metadata;
         }
         $metadata = addslashes(json_encode($md));
     }
     if (empty($id)) {
         $hasNameId = iDB::value("SELECT `id` FROM `#iCMS@__tags` where `name` = '{$name}'");
         if ($hasNameId) {
             if (isset($_POST['spider_update'])) {
                 $id = $hasNameId;
             } else {
                 iPHP::alert('该标签已经存在!请检查是否重复');
             }
         }
     }
     if (empty($tkey) && $url) {
         $tkey = substr(md5($url), 8, 16);
         $hasTkey = iDB::value("SELECT `id` FROM `#iCMS@__tags` where `tkey` = '{$tkey}'");
         if ($hasTkey) {
             if (isset($_POST['spider_check_tkey'])) {
                 echo '该自定义链接已经存在!请检查是否重复';
                 return false;
             } else {
                 iPHP::alert('该自定义链接已经存在!请检查是否重复');
             }
         }
     }
     $tkey or $tkey = strtolower(pinyin($name));
     iFS::$forceExt = "jpg";
     iFS::checkHttp($pic) && ($pic = iFS::http($pic));
     iFS::checkHttp($bpic) && ($bpic = iFS::http($bpic));
     iFS::checkHttp($mpic) && ($mpic = iFS::http($mpic));
     iFS::checkHttp($spic) && ($spic = iFS::http($spic));
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     $fields = array('uid', 'rootid', 'cid', 'tcid', 'pid', 'tkey', 'name', 'seotitle', 'subtitle', 'keywords', 'description', 'metadata', 'haspic', 'pic', 'bpic', 'mpic', 'spic', 'url', 'related', 'count', 'weight', 'tpl', 'ordernum', 'pubdate', 'status');
     $data = compact($fields);
     if (empty($id)) {
         $data['postime'] = $pubdate;
         $data['count'] = '0';
         $data['comments'] = '0';
         $id = iDB::insert('tags', $data);
         tag::cache($id, 'id');
         map::init('prop', $this->appid);
         $pid && map::add($pid, $id);
         map::init('category', $this->appid);
         map::add($cid, $id);
         $tcid && map::add($tcid, $id);
         $msg = '标签添加完成';
     } else {
         if (isset($_POST['spider_update'])) {
             // $data = array();
             $hasTag = iDB::row("SELECT * FROM `#iCMS@__tags` where `id` = '{$id}'", ARRAY_A);
             $this->check_spider_data($data, $hasTag, 'subtitle', $subtitle);
             $this->check_spider_data($data, $hasTag, 'description', $description);
//.........这里部分代码省略.........
开发者ID:sunhk25,项目名称:iCMS,代码行数:101,代码来源:tags.app.php

示例2: do_save

 function do_save()
 {
     $appid = $this->appid;
     $cid = (int) $_POST['cid'];
     $rootid = (int) $_POST['rootid'];
     $status = (int) $_POST['status'];
     $isucshow = (int) $_POST['isucshow'];
     $issend = (int) $_POST['issend'];
     $isexamine = (int) $_POST['isexamine'];
     $ordernum = (int) $_POST['ordernum'];
     $mode = (int) $_POST['mode'];
     $pid = implode(',', (array) $_POST['pid']);
     $_pid = iS::escapeStr($_POST['_pid']);
     $_rootid_hash = iS::escapeStr($_POST['_rootid_hash']);
     $name = iS::escapeStr($_POST['name']);
     $subname = iS::escapeStr($_POST['subname']);
     $domain = iS::escapeStr($_POST['domain']);
     $htmlext = iS::escapeStr($_POST['htmlext']);
     $url = iS::escapeStr($_POST['url']);
     $password = iS::escapeStr($_POST['password']);
     $pic = iS::escapeStr($_POST['pic']);
     $mpic = iS::escapeStr($_POST['mpic']);
     $spic = iS::escapeStr($_POST['spic']);
     $dir = iS::escapeStr($_POST['dir']);
     $title = iS::escapeStr($_POST['title']);
     $keywords = iS::escapeStr($_POST['keywords']);
     $description = iS::escapeStr($_POST['description']);
     $categoryURI = iS::escapeStr($_POST['categoryURI']);
     $categoryRule = iS::escapeStr($_POST['categoryRule']);
     $contentRule = iS::escapeStr($_POST['contentRule']);
     $urlRule = iS::escapeStr($_POST['urlRule']);
     $indexTPL = iS::escapeStr($_POST['indexTPL']);
     $listTPL = iS::escapeStr($_POST['listTPL']);
     $contentTPL = iS::escapeStr($_POST['contentTPL']);
     $metadata = iS::escapeStr($_POST['metadata']);
     $contentprop = iS::escapeStr($_POST['contentprop']);
     $body = $_POST['body'];
     $hasbody = (int) $_POST['hasbody'];
     $hasbody or $hasbody = $body ? 1 : 0;
     if ($_rootid_hash) {
         $_rootid = authcode($_rootid_hash);
         if ($rootid != $_rootid) {
             iPHP::alert('非法数据提交!');
         } else {
             iACP::CP($_rootid, 'a', 'alert');
             exit;
         }
     }
     $cid && $cid == $rootid && iPHP::alert('不能以自身做为上级' . $this->category_name);
     empty($name) && iPHP::alert($this->category_name . '名称不能为空!');
     if ($metadata) {
         $md = array();
         foreach ($metadata['key'] as $_mk => $_mval) {
             !preg_match("/[a-zA-Z0-9_\\-]/", $_mval) && iPHP::alert($this->category_name . '附加属性名称只能由英文字母、数字或_-组成(不支持中文)');
             $md[$_mval] = $metadata['value'][$_mk];
         }
         $metadata = addslashes(serialize($md));
     }
     if ($contentprop) {
         $ca = array();
         foreach ($contentprop['key'] as $_cak => $_caval) {
             $_caval or $_caval = strtolower(pinyin($contentprop['name'][$_cak]));
             !preg_match("/[a-zA-Z0-9_\\-]/", $_caval) && iPHP::alert('内容附加属性字段只能由英文字母、数字或_-组成(不支持中文)');
             $ca[$_caval] = $contentprop['name'][$_cak];
         }
         $contentprop = addslashes(serialize($ca));
     }
     if ($mode == "2") {
         if (strpos($categoryRule, '{CDIR}') === FALSE && strpos($categoryRule, '{CID}') === FALSE && strpos($categoryRule, '{0xCID}') === FALSE) {
             iPHP::alert('伪静态模式下版块URL规则<hr />必需要有<br />{CDIR}版块目录<br />或者<br />{CID},{0xCID}版块ID');
         }
         if (strpos($contentRule, '{ID}') === FALSE && strpos($contentRule, '{0xID}') === FALSE && strpos($contentRule, '{LINK}') === FALSE) {
             iPHP::alert('伪静态模式下内容URL规则<hr />必需要有<br />{ID}' . $this->_app_name . 'ID <br />或者<br />{0xID}' . $this->_app_name . 'ID补零<br />或者<br />{LINK}' . $this->_app_name . '自定义链接');
         }
     }
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     map::init('prop', iCMS_APP_CATEGORY);
     $fields = array('rootid', 'appid', 'ordernum', 'name', 'subname', 'password', 'title', 'keywords', 'description', 'dir', 'mode', 'domain', 'url', 'pic', 'mpic', 'spic', 'htmlext', 'categoryURI', 'categoryRule', 'contentRule', 'urlRule', 'indexTPL', 'listTPL', 'contentTPL', 'metadata', 'contentprop', 'hasbody', 'pid', 'isexamine', 'issend', 'isucshow', 'status');
     $data = compact($fields);
     if (empty($cid)) {
         iACP::CP($rootid, 'a', 'alert');
         $nameArray = explode("\n", $name);
         $_count = count($nameArray);
         foreach ($nameArray as $nkey => $_name) {
             $_name = trim($_name);
             if (empty($_name)) {
                 continue;
             }
             if ($_count == "1") {
                 if (empty($dir) && empty($url)) {
                     $dir = strtolower(pinyin($_name));
                 }
             } else {
                 empty($url) && ($dir = strtolower(pinyin($_name)));
             }
             $this->check_dir($dir, $appid, $url);
             $data['name'] = $_name;
             $data['dir'] = $dir;
             $data['userid'] = iMember::$userid;
             $data['creator'] = iMember::$nickname;
//.........这里部分代码省略.........
开发者ID:World3D,项目名称:iCMS,代码行数:101,代码来源:category.app.php

示例3: __action_manage_publish

 private function __action_manage_publish()
 {
     $aid = (int) $_POST['id'];
     $cid = (int) $_POST['cid'];
     $_cid = (int) $_POST['_cid'];
     $ucid = (int) $_POST['ucid'];
     $_ucid = (int) $_POST['_ucid'];
     $mobile = (int) $_POST['mobile'];
     $title = iS::escapeStr($_POST['title']);
     $source = iS::escapeStr($_POST['source']);
     $keywords = iS::escapeStr($_POST['keywords']);
     $description = iS::escapeStr($_POST['description']);
     $creative = (int) $_POST['creative'];
     $userid = user::$userid;
     $author = user::$nickname;
     $editor = user::$nickname;
     if (iCMS::$config['user']['post']['seccode']) {
         $seccode = iS::escapeStr($_POST['seccode']);
         iPHP::seccode($seccode, true) or iPHP::alert('iCMS:seccode:error');
     }
     if (iCMS::$config['user']['post']['interval']) {
         $last_postime = iDB::value("\n                SELECT MAX(postime)\n                FROM `#iCMS@__article`\n                WHERE userid='" . user::$userid . "'");
         if ($_SERVER['REQUEST_TIME'] - $last_postime < iCMS::$config['user']['post']['interval']) {
             iPHP::alert('user:publish:interval');
         }
     }
     if ($mobile) {
         $_POST['body'] = ubb2html($_POST['body']);
         $_POST['body'] = trim($_POST['body']);
     }
     $body = iPHP::cleanHtml($_POST['body']);
     empty($title) && iPHP::alert('标题不能为空!');
     empty($cid) && iPHP::alert('请选择所属栏目!');
     empty($body) && iPHP::alert('文章内容不能为空!');
     $fwd = iCMS::filter($title);
     $fwd && iPHP::alert('user:publish:filter_title');
     $fwd = iCMS::filter($description);
     $fwd && iPHP::alert('user:publish:filter_desc');
     $fwd = iCMS::filter($body);
     $fwd && iPHP::alert('user:publish:filter_body');
     $articleApp = iPHP::app("admincp.article.app");
     if (empty($description)) {
         $description = $articleApp->autodesc($body);
     }
     $pubdate = time();
     $postype = "0";
     $category = iCache::get('iCMS/category/' . $cid);
     $status = $category['isexamine'] ? 3 : 1;
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     iPHP::app('article.table');
     $fields = articleTable::fields($aid);
     $data_fields = articleTable::data_fields($aid);
     if (empty($aid)) {
         $postime = $pubdate;
         $chapter = $hits = $good = $bad = $comments = 0;
         $data = compact($fields);
         $aid = articleTable::insert($data);
         $article_data = compact($data_fields);
         articleTable::data_insert($article_data);
         map::init('category', iCMS_APP_ARTICLE);
         map::add($cid, $aid);
         iDB::query("UPDATE `#iCMS@__user_category` SET `count` = count+1 WHERE `cid` = '{$ucid}' AND `uid`='" . user::$userid . "' AND `appid`='" . iCMS_APP_ARTICLE . "';");
         user::update_count(user::$userid, 1, 'article');
         $lang = array('1' => 'user:article:add_success', '3' => 'user:article:add_examine');
     } else {
         if (articleTable::update(compact($fields), array('id' => $aid, 'userid' => user::$userid))) {
             articleTable::data_update(compact($data_fields), array('aid' => $aid));
         }
         map::init('category', iCMS_APP_ARTICLE);
         map::diff($cid, $_cid, $aid);
         if ($ucid != $_ucid) {
             iDB::query("UPDATE `#iCMS@__user_category` SET `count` = count+1 WHERE `cid` = '{$ucid}' AND `uid`='" . user::$userid . "' AND `appid`='" . iCMS_APP_ARTICLE . "';");
             iDB::query("UPDATE `#iCMS@__user_category` SET `count` = count-1 WHERE `cid` = '{$_ucid}' AND `uid`='" . user::$userid . " AND `count`>0' AND `appid`='" . iCMS_APP_ARTICLE . "';");
         }
         $lang = array('1' => 'user:article:update_success', '3' => 'user:article:update_examine');
     }
     $url = iPHP::router('/user/article', iPHP_ROUTER_REWRITE);
     iPHP::success($lang[$status], 'url:' . $url);
 }
开发者ID:sunhk25,项目名称:iCMS,代码行数:79,代码来源:user.app.php

示例4: do_save

 function do_save($callback = false)
 {
     $aid = (int) $_POST['aid'];
     $cid = (int) $_POST['cid'];
     $userid = (int) $_POST['userid'];
     $scid = implode(',', (array) $_POST['scid']);
     $pid = implode(',', (array) $_POST['pid']);
     $status = (int) $_POST['status'];
     $chapter = (int) $_POST['chapter'];
     $ordernum = _int($_POST['ordernum']);
     $_cid = iS::escapeStr($_POST['_cid']);
     $_pid = iS::escapeStr($_POST['_pid']);
     $_scid = iS::escapeStr($_POST['_scid']);
     $_tags = iS::escapeStr($_POST['_tags']);
     $title = iS::escapeStr($_POST['title']);
     $stitle = iS::escapeStr($_POST['stitle']);
     $pic = iS::escapeStr($_POST['pic']);
     $mpic = iS::escapeStr($_POST['mpic']);
     $spic = iS::escapeStr($_POST['spic']);
     $source = iS::escapeStr($_POST['source']);
     $author = iS::escapeStr($_POST['author']);
     $editor = iS::escapeStr($_POST['editor']);
     $description = iS::escapeStr($_POST['description']);
     $keywords = iS::escapeStr($_POST['keywords']);
     $tags = str_replace(',', ',', iS::escapeStr($_POST['tags']));
     $clink = iS::escapeStr($_POST['clink']);
     $url = iS::escapeStr($_POST['url']);
     $tpl = iS::escapeStr($_POST['tpl']);
     $metadata = iS::escapeStr($_POST['metadata']);
     $metadata = $metadata ? addslashes(serialize($metadata)) : '';
     $body = (array) $_POST['body'];
     $creative = (int) $_POST['creative'];
     iACP::CP($cid, $aid ? 'ce' : 'ca', 'alert');
     empty($_POST['pubdate']) && ($_POST['pubdate'] = get_date(0, 'Y-m-d H:i:s'));
     $pubdate = iPHP::str2time($_POST['pubdate']);
     $weight = _int($_POST['weight']);
     $postype = $_POST['postype'] ? $_POST['postype'] : 0;
     $ischapter = isset($_POST['ischapter']) ? 1 : 0;
     isset($_POST['inbox']) && ($status = "0");
     $tags && ($tags = preg_replace('/<[\\/\\!]*?[^<>]*?>/is', '', $tags));
     empty($title) && iPHP::alert('标题不能为空!');
     empty($cid) && iPHP::alert('请选择所属栏目');
     empty($body) && empty($url) && iPHP::alert('文章内容不能为空!');
     $userid or $userid = iMember::$userid;
     iFS::$userid = $userid;
     if (empty($aid) && iCMS::$config['publish']['repeatitle']) {
         articleTable::check_title($title) && iPHP::alert('该标题的文章已经存在!请检查是否重复');
     }
     if (strstr($this->category[$cid]['contentRule'], '{LINK}') !== false) {
         empty($clink) && ($clink = strtolower(pinyin($title)));
         if (empty($aid) && $clink) {
             articleTable::check_clink($clink) && iPHP::alert('该文章自定义链接已经存在!请检查是否重复');
         }
     }
     if (empty($description) && empty($url)) {
         $description = $this->autodesc($body);
     }
     stripos($pic, 'http://') === false or $pic = iFS::http($pic);
     stripos($mpic, 'http://') === false or $mpic = iFS::http($mpic);
     stripos($spic, 'http://') === false or $spic = iFS::http($spic);
     $haspic = empty($pic) ? 0 : 1;
     $SELFURL = __SELF__ . $_POST['REFERER'];
     if (empty($_POST['REFERER']) || strstr($_POST['REFERER'], '=save')) {
         $SELFURL = __SELF__ . '?app=article&do=manage';
     }
     $editor or $editor = empty(iMember::$data->nickname) ? iMember::$data->username : iMember::$data->nickname;
     // if($aid && $ischapter){
     //     $this->article_data($body,$aid);
     //     iDB::query("UPDATE `#iCMS@__article` SET `chapter`=chapter+1  WHERE `id` = '$aid'");
     //     iPHP::success('章节添加完成!','url:'.$SELFURL);
     // }
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     $picdata = '';
     $ucid = 0;
     $fields = articleTable::fields($aid);
     if (empty($aid)) {
         $postime = $pubdate;
         $hits = 0;
         $good = $bad = $comments = 0;
         $ischapter && ($chapter = 1);
         $mobile = 0;
         $aid = articleTable::insert(compact($fields));
         if ($this->callback['primary']) {
             $PCB = $this->callback['primary'];
             $handler = $PCB[0];
             $params = (array) $PCB[1] + array('indexid' => $aid);
             if (is_callable($handler)) {
                 call_user_func_array($handler, $params);
             }
         }
         if ($tags) {
             iPHP::app('tag.class', 'static');
             tag::add($tags, $userid, $aid, $cid);
             //articleTable::update(compact('tags'),array('id'=>$aid));
         }
         map::init('prop', $this->appid);
         $pid && map::add($pid, $aid);
         map::init('category', $this->appid);
         map::add($cid, $aid);
         $scid && map::add($scid, $aid);
//.........这里部分代码省略.........
开发者ID:World3D,项目名称:iCMS,代码行数:101,代码来源:article.app.php

示例5: do_save

 function do_save()
 {
     $uid = (int) $_POST['uid'];
     $pid = implode(',', (array) $_POST['pid']);
     $_pid = iS::escapeStr($_POST['_pid']);
     $user = $_POST['user'];
     $userdata = $_POST['userdata'];
     $username = $user['username'];
     $nickname = $user['nickname'];
     $password = $user['password'];
     unset($user['password']);
     $username or iPHP::alert('账号不能为空');
     preg_match("/^[\\w\\-\\.]+@[\\w\\-]+(\\.\\w+)+\$/i", $username) or iPHP::alert('该账号格式不对');
     $nickname or iPHP::alert('昵称不能为空');
     $user['regdate'] = iPHP::str2time($user['regdate']);
     $user['lastlogintime'] = iPHP::str2time($user['lastlogintime']);
     $user['pid'] = $pid;
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     if (empty($uid)) {
         $password or iPHP::alert('密码不能为空');
         $user['password'] = md5($password);
         iDB::value("SELECT `uid` FROM `#iCMS@__user` where `username` ='{$username}' LIMIT 1") && iPHP::alert('该账号已经存在');
         iDB::value("SELECT `uid` FROM `#iCMS@__user` where `nickname` ='{$nickname}' LIMIT 1") && iPHP::alert('该昵称已经存在');
         $uid = iDB::insert('user', $user);
         map::init('prop', iCMS_APP_USER);
         $pid && map::add($pid, $uid);
         $msg = "账号添加完成!";
     } else {
         iDB::value("SELECT `uid` FROM `#iCMS@__user` where `username` ='{$username}' AND `uid` !='{$uid}' LIMIT 1") && iPHP::alert('该账号已经存在');
         iDB::value("SELECT `uid` FROM `#iCMS@__user` where `nickname` ='{$nickname}' AND `uid` !='{$uid}' LIMIT 1") && iPHP::alert('该昵称已经存在');
         $password && ($user['password'] = md5($password));
         iDB::update('user', $user, array('uid' => $uid));
         map::init('prop', iCMS_APP_USER);
         map::diff($pid, $_pid, $uid);
         if (iDB::value("SELECT `uid` FROM `#iCMS@__user_data` where `uid`='{$uid}' LIMIT 1")) {
             iDB::update('user_data', $userdata, array('uid' => $uid));
         } else {
             $userdata['uid'] = $uid;
             iDB::insert('user_data', $userdata);
         }
         $msg = "账号修改完成!";
     }
     iPHP::success($msg, 'url:' . APP_URI);
 }
开发者ID:sunhk25,项目名称:iCMS,代码行数:44,代码来源:user.app.php

示例6: do_save

 function do_save()
 {
     $id = (int) $_POST['id'];
     $uid = (int) $_POST['uid'];
     $cid = implode(',', (array) $_POST['cid']);
     $tcid = implode(',', (array) $_POST['tcid']);
     $pid = implode(',', (array) $_POST['pid']);
     $_cid = iS::escapeStr($_POST['_cid']);
     $_tcid = iS::escapeStr($_POST['_tcid']);
     $_pid = iS::escapeStr($_POST['_pid']);
     $name = iS::escapeStr($_POST['name']);
     $subtitle = iS::escapeStr($_POST['subtitle']);
     $tkey = iS::escapeStr($_POST['tkey']);
     $seotitle = iS::escapeStr($_POST['seotitle']);
     $keywords = iS::escapeStr($_POST['keywords']);
     $pic = iS::escapeStr($_POST['pic']);
     $description = iS::escapeStr($_POST['description']);
     $url = iS::escapeStr($_POST['url']);
     $related = iS::escapeStr($_POST['related']);
     $tpl = iS::escapeStr($_POST['tpl']);
     $weight = _int($_POST['weight']);
     $ordernum = _int($_POST['ordernum']);
     $status = (int) $_POST['status'];
     $haspic = $pic ? '1' : '0';
     $pubdate = time();
     $metadata = iS::escapeStr($_POST['metadata']);
     $uid or $uid = iMember::$userid;
     $name or iPHP::alert('标签名称不能为空!');
     $cid or iPHP::alert('请选择标签所属栏目!');
     if ($metadata) {
         $md = array();
         foreach ($metadata['key'] as $_mk => $_mval) {
             !preg_match("/[a-zA-Z0-9_\\-]/", $_mval) && iPHP::alert($this->name_text . '附加属性名称只能由英文字母、数字或_-组成(不支持中文)');
             $md[$_mval] = $metadata['value'][$_mk];
         }
         $metadata = addslashes(serialize($md));
     }
     if (empty($id)) {
         iDB::value("SELECT `id` FROM `#iCMS@__tags` where `name` = '{$name}'") && iPHP::alert('该标签已经存在!请检查是否重复');
     }
     if (empty($tkey) && $url) {
         $tkey = substr(md5($url), 8, 16);
         iDB::value("SELECT `id` FROM `#iCMS@__tags` where `tkey` = '{$tkey}'") && iPHP::alert('该自定义链接已经存在!请检查是否重复');
     }
     $tkey or $tkey = strtolower(pinyin($name));
     strstr($pic, 'http://') && ($pic = iFS::http($pic));
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     $fields = array('uid', 'cid', 'tcid', 'pid', 'tkey', 'name', 'seotitle', 'subtitle', 'keywords', 'description', 'metadata', 'haspic', 'pic', 'url', 'related', 'count', 'weight', 'tpl', 'ordernum', 'pubdate', 'status');
     $data = compact($fields);
     if (empty($id)) {
         $data['count'] = '0';
         $data['comments'] = '0';
         $id = iDB::insert('tags', $data);
         tag::cache($id, 'id');
         map::init('prop', $this->appid);
         $pid && map::add($pid, $id);
         map::init('category', $this->appid);
         map::add($cid, $id);
         $tcid && map::add($tcid, $id);
         iPHP::success('标签添加完成', "url:" . APP_URI);
     } else {
         unset($data['count'], $data['comments']);
         iDB::update('tags', $data, array('id' => $id));
         tag::cache($id, 'id');
         map::init('prop', $this->appid);
         map::diff($pid, $_pid, $id);
         map::init('category', $this->appid);
         map::diff($cid, $_cid, $id);
         map::diff($tcid, $_tcid, $id);
         iPHP::success('标签更新完成', "url:" . APP_URI);
     }
 }
开发者ID:World3D,项目名称:iCMS,代码行数:72,代码来源:tags.app.php


注:本文中的map::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。