本文整理汇总了PHP中map::diff方法的典型用法代码示例。如果您正苦于以下问题:PHP map::diff方法的具体用法?PHP map::diff怎么用?PHP map::diff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map
的用法示例。
在下文中一共展示了map::diff方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_batch
function do_batch()
{
$idArray = (array) $_POST['id'];
$idArray or iPHP::alert("请选择要操作的标签");
$ids = implode(',', $idArray);
$batch = $_POST['batch'];
switch ($batch) {
case 'dels':
iPHP::$break = false;
foreach ($idArray as $id) {
$this->do_del($id, false);
}
iPHP::$break = true;
iPHP::success('标签全部删除完成!', 'js:1');
break;
case 'move':
$_POST['cid'] or iPHP::alert("请选择目标栏目!");
iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
map::init('category', $this->appid);
$cid = (int) $_POST['cid'];
foreach ($idArray as $id) {
$_cid = iDB::value("SELECT `cid` FROM `#iCMS@__tags` where `id` ='{$id}'");
iDB::update("tags", compact('cid'), compact('id'));
if ($_cid != $cid) {
map::diff($cid, $_cid, $id);
$this->categoryApp->update_count_one($_cid, '-');
$this->categoryApp->update_count_one($cid);
}
}
iPHP::success('成功移动到目标栏目!', 'js:1');
break;
case 'mvtcid':
$_POST['tcid'] or iPHP::alert("请选择目标分类!");
iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
map::init('category', $this->appid);
$tcid = (int) $_POST['tcid'];
foreach ($idArray as $id) {
$_tcid = iDB::value("SELECT `tcid` FROM `#iCMS@__tags` where `id` ='{$id}'");
iDB::update("tags", compact('tcid'), compact('id'));
if ($_tcid != $tcid) {
map::diff($tcid, $_tcid, $id);
$this->categoryApp->update_count_one($_tcid, '-');
$this->categoryApp->update_count_one($tcid);
}
}
iPHP::success('成功移动到目标分类!', 'js:1');
break;
case 'prop':
iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
map::init('prop', $this->appid);
$pid = implode(',', (array) $_POST['pid']);
foreach ((array) $_POST['id'] as $id) {
$_pid = iDB::value("SELECT pid FROM `#iCMS@__tags` WHERE `id`='{$id}'");
iDB::update("tags", compact('pid'), compact('id'));
map::diff($pid, $_pid, $id);
}
iPHP::success('属性设置完成!', 'js:1');
break;
case 'weight':
$weight = _int($_POST['mweight']);
$sql = "`weight` = '{$weight}'";
break;
case 'tpl':
$tpl = iS::escapeStr($_POST['mtpl']);
$sql = "`tpl` = '{$tpl}'";
break;
case 'keyword':
if ($_POST['pattern'] == 'replace') {
$sql = "`keywords` = '" . iS::escapeStr($_POST['mkeyword']) . "'";
} elseif ($_POST['pattern'] == 'addto') {
foreach ($idArray as $id) {
$keywords = iDB::value("SELECT keywords FROM `#iCMS@__tags` WHERE `id`='{$id}'");
$sql = "`keywords` = '" . ($keywords ? $keywords . ',' . iS::escapeStr($_POST['mkeyword']) : iS::escapeStr($_POST['mkeyword'])) . "'";
iDB::query("UPDATE `#iCMS@__tags` SET {$sql} WHERE `id`='{$id}'");
}
iPHP::success('关键字更改完成!', 'js:1');
}
break;
case 'tag':
if ($_POST['pattern'] == 'replace') {
$sql = "`related` = '" . iS::escapeStr($_POST['mtag']) . "'";
} elseif ($_POST['pattern'] == 'addto') {
foreach ($idArray as $id) {
$keywords = iDB::value("SELECT related FROM `#iCMS@__tags` WHERE `id`='{$id}'");
$sql = "`related` = '" . ($keywords ? $keywords . ',' . iS::escapeStr($_POST['mtag']) : iS::escapeStr($_POST['mtag'])) . "'";
iDB::query("UPDATE `#iCMS@__tags` SET {$sql} WHERE `id`='{$id}'");
}
iPHP::success('相关标签更改完成!', 'js:1');
}
break;
default:
if (strpos($batch, ':')) {
$data = iACP::fields($batch);
foreach ($idArray as $id) {
$data && iDB::update("tags", $data, array('id' => $id));
}
iPHP::success('操作成功!', 'js:1');
} else {
iPHP::alert('请选择要操作项!', 'js:1');
}
//.........这里部分代码省略.........
示例2: do_save
//.........这里部分代码省略.........
$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;
$data['createtime'] = time();
$data['count'] = '0';
$data['comments'] = '0';
$cid = iDB::insert('category', $data);
$pid && map::add($pid, $cid);
$this->cache(false, $this->appid);
$this->cahce_one($cid);
}
$msg = $this->category_name . "添加完成!";
} else {
if (empty($dir) && empty($url)) {
$dir = strtolower(pinyin($name));
}
iACP::CP($cid, 'e', 'alert');
$this->check_dir($dir, $appid, $url, $cid);
$data['dir'] = $dir;
iDB::update('category', $data, array('cid' => $cid));
map::diff($pid, $_pid, $cid);
$this->cahce_one($cid);
$msg = $this->category_name . "编辑完成!";
}
$hasbody && iCache::set('iCMS/category/' . $cid . '.body', $body, 0);
iPHP::success($msg, 'url:' . $this->category_uri);
}
示例3: do_save
//.........这里部分代码省略.........
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);
$tagArray && tag::map_iid($tagArray, $aid);
$url or $this->article_data($body, $aid, $haspic);
$this->categoryApp->update_count_one($cid);
$article_url = iURL::get('article', array(array('id' => $aid, 'url' => $url, 'cid' => $cid, 'pubdate' => $pubdate), $this->category[$cid]))->href;
if ($status && iCMS::$config['api']['baidu']['sitemap']['sync']) {
baidu_ping($article_url);
}
if ($callback) {
return array("code" => $callback, 'indexid' => $aid);
}
$moreBtn = array(array("text" => "查看该文章", "target" => '_blank', "url" => $article_url, "o" => 'target="_blank"'), array("text" => "编辑该文章", "url" => APP_URI . "&do=add&id=" . $aid), array("text" => "继续添加文章", "url" => APP_URI . "&do=add&cid=" . $cid), array("text" => "返回文章列表", "url" => $SELFURL), array("text" => "查看网站首页", "url" => iCMS_URL, "target" => '_blank'));
iPHP::$dialog['lock'] = true;
iPHP::dialog('success:#:check:#:文章添加完成!<br />10秒后返回文章列表', 'url:' . $SELFURL, 10, $moreBtn);
} else {
if ($tags) {
iPHP::app('tag.class', 'static');
tag::diff($tags, $_tags, iMember::$userid, $aid, $cid);
}
$picdata = $this->picdata($pic, $mpic, $spic);
articleTable::update(compact($fields), array('id' => $aid));
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);
}
}
map::init('prop', $this->appid);
map::diff($pid, $_pid, $aid);
map::init('category', $this->appid);
map::diff($cid, $_cid, $aid);
map::diff($scid, $_scid, $aid);
$url or $this->article_data($body, $aid, $haspic);
//$ischapter && $this->chapter_count($aid);
if ($_cid != $cid) {
$this->categoryApp->update_count_one($_cid, '-');
$this->categoryApp->update_count_one($cid);
}
if ($callback) {
return array("code" => $callback, 'indexid' => $aid);
}
// if(!strstr($this->category[$cid]['contentRule'],'{PHP}')&&!$this->category[$cid]['url']&&$this->category[$cid]['mode']=="1" && $status) {
// $htmlApp = iACP::app('html');
// $htmlApp->Article($aid);
// }
iPHP::success('文章编辑完成!<br />3秒后返回文章列表', 'url:' . $SELFURL);
}
}
示例4: __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);
}
示例5: do_batch
function do_batch()
{
$idA = (array) $_POST['id'];
$idA or iPHP::alert("请选择要操作的用户");
$ids = implode(',', (array) $_POST['id']);
$batch = $_POST['batch'];
switch ($batch) {
case 'prop':
iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
map::init('prop', iCMS_APP_USER);
$pid = implode(',', (array) $_POST['pid']);
foreach ((array) $_POST['id'] as $id) {
$_pid = iDB::value("SELECT `pid` FROM `#iCMS@__user` where `uid`='{$id}' LIMIT 1");
iDB::update('user', compact('pid'), array('uid' => $id));
map::diff($pid, $_pid, $id);
}
iPHP::success('用户属性设置完成!', 'js:1');
break;
case 'dels':
iPHP::$break = false;
foreach ($idA as $id) {
$this->do_del($id, false);
}
iPHP::$break = true;
iPHP::success('用户全部删除完成!', 'js:1');
break;
}
}