public function delDefaultFor($d) { $def = $this->getDefaultFor(); array_remove_value($def, $d); $this->setDefaultFor($def); return $this; }
public function createForm() { $form = new Am_Form_Admin(); $options = Am_Currency::getSupportedCurrencies(); array_remove_value($options, Am_Currency::getDefault()); $sel = $form->addSelect('currency', array('class' => 'am-combobox'))->setLabel(___('Currency'))->loadOptions($options)->addRule('required'); $date = $form->addDate('date')->setLabel(___('Date'))->addRule('required')->addRule('callback2', "--wrong date--", array($this, 'checkDate')); $rate = $form->addText('rate', array('length' => 8))->setLabel(___("Exchange Rate\nenter cost of 1 (one) %s", Am_Currency::getDefault()))->addRule('required'); return $form; }
/** * show help on a page */ function show_help() { if ( !empty($_POST['anchor']) and preg_match("/^[a-z]+$/", $_POST['anchor']) ) { $identifier = BN."#".$_POST['anchor']; } else { $identifier = BN; } if (Login::$member) { $hide = Login::$member->hide_help(); array_remove_value($hide, $identifier); Login::$member->update_help($hide); } else { if (empty($_SESSION['show_help'])) { $_SESSION['show_help'] = array($identifier); } elseif (!in_array($identifier, $_SESSION['show_help'])) { $_SESSION['show_help'][] = $identifier; } } }
/** * Removes the specified automatically-removed path. * * @param $path */ public function removeAutomaticallyRemovedPath($path) { array_remove_value($this->automaticallyRemovedPaths, $path); $this->automaticallyRemovedPaths = array_values($this->automaticallyRemovedPaths); }
ob_end_clean(); header("Location: ?page={$page}"); exit; } // uninstall if ($act == "uninstall") { $plug = $_GET['plugin']; if ($_POST['yes']) { // if it's active if (in_array($plug, unserialize($set->sinfo->active_plugins))) { // we deactivate $active_plugins = unserialize($set->sinfo->active_plugins); if (!is_array($active_plugins)) { $active_plugins = array(); } $active_plugins = array_remove_value($active_plugins, $plug); $db->query("UPDATE `" . MAI_PREFIX . "settings` SET `active_plugins` = '" . serialize(array_unique($active_plugins)) . "'"); if (is_callable($plug . "_deactivate")) { call_user_func($plug . "_deactivate"); } } // we uninstall if (is_callable($plug . "_uninstall")) { call_user_func($plug . "_uninstall"); } ob_end_clean(); header("Location: ?page={$page}"); exit; } else { $content = "<div class='content'>\n\t<form action='#' method='post'>\n\t{$lang->are_you_sure} <br/>\n\t<input type='submit' name='yes' value='{$lang->yes}'> <a href='?'>{$lang->cancel}</a>\n\t</form>\n\t</div>"; }
/** * 调用相册显示数据标签 * * @version $Id: getphotolist.lib.php netman * @package Stourweb.Taglib * @copyright Copyright (c) 2007 - 2011, Stourweb, Inc. * @link http://www.stourweb.com */ function lib_getphotolist(&$ctag, &$refObj) { global $dsql, $cfg_indexphoto; include SLINEDATA . "/webinfo.php"; $attlist = "row|10,flag|,type|top,limit|0"; FillAttsDefault($ctag->CAttribute->Items, $attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $innertext = trim($ctag->GetInnertext()); $basefield = 'a.aid,a.title,a.seotitle,a.litpic,a.content,a.title as littitle,a.alt,a.author,a.shownum,a.webid,a.headimgid'; $revalue = ''; //加目的地页面显示条件 $destwhere = isset($refObj->Fields['kindid']) ? "and FIND_IN_SET({$refObj->Fields['kindid']},kindlist) " : ''; //用于聚合页面 if ($type == 'mdd') { if (isset($refObj->Fields['kindid'])) { $sonid = $refObj->Fields['kindid']; $number = isset($refObj->Fields['shownumber']) ? $refObj->Fields['shownumber'] : $row; //如果模块设置了显示数量则使用. $sql = "select {$basefield} from #@__photo as a left join #@__kindorderlist as c on (c.classid={$sonid} and a.id=c.aid and c.typeid=6) where FIND_IN_SET({$sonid},a.kindlist) order by c.isding desc,case when c.displayorder is null then 9999 end,c.displayorder asc,a.addtime desc limit {$limit},{$number}"; } else { return ''; } } else { if ($type == 'sonhot') { if (isset($refObj->Fields['kindid'])) { $sonid = $refObj->Fields['kindid']; $sql = "select {$basefield} from #@__photo a where FIND_IN_SET({$sonid},kindlist) order by shownum desc limit {$limit},{$row}"; } else { return ''; } } else { if ($type == 'attr') { if (isset($attrid)) { $sql = "select {$basefield} from #@__photo a where FIND_IN_SET({$attrid},attrid) order by displayorder asc,shownum desc limit {$limit},{$row}"; } else { return ''; } } else { if ($type == 'relative') { $kindlist = $refObj->Fields['kindlist']; $maxkindid = array_remove_value($kindlist); //最后一级. $where = " FIND_IN_SET({$maxkindid},kindlist) "; $sql = "select {$basefield} from #@__photo a where {$where} order by modtime desc,addtime desc limit {$limit},{$row}"; } else { if ($type == 'sonj') { if (isset($refObj->Fields['sonid'])) { $sonid = $refObj->Fields['sonid']; $sql = "select aid,title,seoname,headimg,content,title as littitle,alt,author,shownum,webid,headimgid from #@__photo where webid!='' {$destwhere} and photokind={$sonid} order by modtime desc,addtime desc limit {$limit},{$row}"; } else { return ''; } } else { if ($flag == 'recommend') { $sql = "select {$basefield} ,b.isjian,b.isding ,b.displayorder from #@__photo a left join #@__allorderlist b on(a.id=b.aid and b.typeid=6) order by case when b.displayorder is null then 9999 end,b.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'isding') { $sql = "select {$basefield} from #@__photo where webid={$sys_webid} and isding=1 order by addtime desc limit {$limit},{$row}"; } else { if ($flag == 'roll') { //首页相册显示方式 if ($GLOBALS['cfg_indexphoto'] == "0") { $sql = "select {$basefield} from #@__photo where webid={$sys_webid} order by modtime desc,addtime desc"; } else { if ($GLOBALS['cfg_indexphoto'] == "-1") { $sql = "select id,pictname as photoname,litpic as headimg,pid as aid from #@__photo_picture where webid={$sys_webid} order by modtime desc"; } else { $sql = "select id,pictname as photoname,litpic as headimg,pid as aid from #@__photo_picture where webid={$sys_webid} and pid={$GLOBALS['cfg_indexphoto']} order by modtime desc"; } } } else { return ''; } } } } } } } } $dsql->SetQuery($sql); $dsql->Execute(); $ctp = new STTagParse(); $ctp->SetNameSpace("field", "[", "]"); $ctp->LoadSource($innertext); $GLOBALS['autoindex'] = 0; while ($row = $dsql->GetArray()) { $GLOBALS['autoindex']++; $weburl = GetWebURLByWebid($row['webid']); $row['url'] = $weburl . "/photos/show_{$row['aid']}.html"; $row['title'] = !empty($row['seotitle']) ? $row['seotitle'] : $row['photoname']; $row['litpic'] = !empty($row['litpic']) ? $row['litpic'] : getDefaultImage(); $row['lit240'] = getPicByName($row['litpic'], 'lit240'); $row['lit160'] = getPicByName($row['litpic'], 'lit160'); $row['alt'] = !empty($row['alt']) ? $row['alt'] : $row['photoname']; /*if($row['littitle']!="") { $row['imgtitle']="title='".$row['littitle']."'"; }*/ //$row['headimg']=!empty($row['headimg'])?$row['headimg']:"sdfsf"; foreach ($ctp->CTags as $tagid => $ctag) { if ($ctag->GetName() == 'array') { $ctp->Assign($tagid, $row); } else { if (!empty($row[$ctag->GetName()])) { $ctp->Assign($tagid, $row[$ctag->GetName()]); } } } $revalue .= $ctp->GetResult(); } return $revalue; }
function array_remove_value(&$arr, $var) { foreach ($arr as $key => $value) { if (is_array($value)) { array_remove_value($arr[$key], $var); } else { $value = trim($value); if ($value == $var) { unset($arr[$key]); } else { $arr[$key] = $value; } } } $tmp_arr = array(); foreach ($arr as $value) { $tmp_arr[] = $value; } $arr = $tmp_arr; unset($tmp_arr); }
//编辑附加属性 $delmeta = $metavalue; $idarr = $_POST["chk"]; if (count($idarr) > 0) { foreach ($idarr as $id) { $varid = $_POST["extid"]; $varname = $_POST["extname"]; $varvalue = $_POST["extvalue"]; if (is_numeric($id)) { if ($metadata->ExistMetaName($posttype, $varname[$id], $aid)) { $sql = "UPDATE yiqi_meta SET metaname = '" . $varname[$id] . "',metavalue = '" . $varvalue[$id] . "' where metaid = '" . $varid[$id] . "'"; } else { $sql = "INSERT INTO yiqi_meta (metaid,metatype,objectid,metaname,metavalue) VALUES (NULL,'{$posttype}','{$aid}','" . $varname[$id] . "','" . $varvalue[$id] . "')"; } $yiqi_db->query(CheckSql($sql)); $delmeta = array_remove_value($delmeta, $varname[$id]); } } } if (count($delmeta) > 0) { foreach ($delmeta as $delmetainfo) { if ($delmetainfo != '' && $delmetainfo != '-') { $sql = "DELETE FROM yiqi_meta WHERE metaname = '{$delmetainfo}' and metatype = '{$posttype}' and objectid = '{$aid}'"; $yiqi_db->query(CheckSql($sql)); } } } exit("文章修改成功!"); } else { exit("文章修改失败,请与管理员联系!"); }
/** * 调用文章显示数据标签 * * @version $Id: getarclist.lib.php netman * @package Stourweb.Taglib * @copyright Copyright (c) 2007 - 2011, Stourweb, Inc. * @link http://www.stourweb.com */ function lib_getarclist(&$ctag, &$refObj) { global $dsql; include SLINEDATA . "/webinfo.php"; $attlist = "row|8,flag|,type|top,limit|0,haspic|,attrid|0,attrname|"; FillAttsDefault($ctag->CAttribute->Items, $attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $webid = empty($sys_webid) ? 0 : $sys_webid; $innertext = trim($ctag->GetInnertext()); $revalue = ''; $basefield = 'a.id,a.aid,a.webid,a.title,a.seotitle,a.shownum,a.content,a.addtime,a.webid,a.attrid,a.litpic as litpic,a.kindlist,a.author'; //是否有图片 $picwhere = !empty($haspic) ? " and (a.litpic is not null and a.litpic!='') and a.ishidden=0 " : ''; $picwhere2 = !empty($haspic) ? " where (a.litpic is not null and a.litpic!='') and a.ishidden=0 " : ''; if ($type == 'mdd') { if ($flag == 'recommend') { $orderby = 'order by case when c.displayorder is null then 9999 end,c.displayorder asc'; } else { if ($flag == 'hot') { $orderby = 'order by case when c.displayorder is null then 9999 end,c.displayorder asc'; } else { if ($flag == 'new') { $orderby = 'order by a.addtime desc'; } else { if ($flag == 'imagehot') { $orderby = " and a.litpic!='' order by case when c.displayorder is null then 9999 end,c.displayorder asc"; } else { $orderby = 'order by case when c.displayorder is null then 9999 end,c.displayorder asc'; } } } } $orderby .= ",a.modtime desc,a.addtime desc"; $sonid = isset($definekind) ? $definekind : $refObj->Fields['kindid']; //这里增加子站的判断 if ($GLOBALS['sys_child_webid'] != 0) { $dest_id = $GLOBALS['sys_child_webid']; } $sonid = $sonid ? $sonid : $dest_id; if (isset($sonid)) { $number = isset($refObj->Fields['shownumber']) ? $refObj->Fields['shownumber'] : $row; //如果模块设置了显示数量则使用. $where = " FIND_IN_SET({$sonid},a.kindlist) and a.ishidden=0 "; $where .= !empty($haspic) ? " and a.litpic is not null" : ''; $sql = "select {$basefield} from #@__article as a left join #@__kindorderlist as c on (c.classid={$sonid} and a.id=c.aid and c.typeid=4) where {$where} {$orderby} limit {$limit},{$number}"; } else { return ''; } } else { if ($type == 'theme') { $themeid = $refObj->Fields['themeid']; if (empty($themeid)) { return ''; } $sql = "select a.* from #@__article a where FIND_IN_SET({$themeid},a.themelist) {$picwhere} order by a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($type == 'pinlun') { $sql = "select a.*,b.id as plid,b.memberid,b.content as plcontent,b.addtime as pltime from #@__article a inner join #@__comment b on (a.id = b.articleid) order by b.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'specical') { $sql = "select {$basefield} from #@__article a where ishidden=0 and isindex =1 {$picwhere} order by modtime desc,addtime desc limit {$limit},{$row}"; } else { if ($flag == 'recommend') { $sql = "select {$basefield},b.isjian,b.isding as isding,b.displayorder from #@__article a left join #@__allorderlist b on (a.id=b.aid and b.typeid=4) {$picwhere2} order by case when b.displayorder is null then 9999 end,b.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'kindrecommend') { $kid = $refObj->Fields['kid']; $sql = "select {$basefield} from #@__article a where a.ishidden=0 and FIND_IN_SET({$kid},a.kindlist) {$picwhere} order by a.displayorder asc, a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'isindex') { $sql = "select {$basefield} from #@__article a where a.isindex=1 {$picwhere} order by a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'new') { $sql = "select {$basefield} from #@__article a {$picwhere2} order by a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'hot') { $sql = "select {$basefield} from #@__article a where a.webid IS NOT NULL {$picwhere} order by a.shownum desc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'photo') { $sql = "select {$basefield} from #@__article a where webid IS NOT NULL and a.litpic !='' {$picwhere} order by a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'jieban') { $getsql = "select id from #@__article_attr where aid=0 and webid=0"; $arr = $dsql->GetOne($getsql); $jiebanid = $arr['id']; //获取id $sql = "select {$basefield},b.isding,b.displayorder,b.isjian from #@__article a left join #@__attrorderlist b on a.aid=b.aid and a.webid=b.webid where FIND_IN_SET({$jiebanid},a.attrid) {$picwhere} order by b.displayorder asc, a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'relative') { $kindlist = $refObj->Fields['kindlist']; $maxkindid = array_remove_value($kindlist); //最后一级. $destid = $GLOBALS['dest_id']; if (empty($destid)) { $maxkindid = array_remove_value($kindlist); //最后一级. $maxkindid = empty($maxkindid) ? 0 : $maxkindid; } else { $maxkindid = $destid; } $where = " FIND_IN_SET({$maxkindid},a.kindlist) "; //排序顺序:置顶+tag关联》排序+ tag关联》最新更新+tag关联 $sql = "select a.* from #@__article a left join #@__kindorderlist b on (a.id=b.aid and b.typeid=4 and b.classid='{$maxkindid}') where {$where} order by ifnull(b.displayorder,9999) asc,a.modtime desc,a.addtime desc limit {$limit},{$row} "; } else { if ($flag == 'attr') { $attrid = $refObj->Fields['attrid']; $sql = "select a.* from #@__article a where FIND_IN_SET({$attrid},a.attrid) and a.ishidden=0 order by a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'byattr') { if (!empty($attrid)) { $where = " (find_in_set({$attrid},a.attrid)" . loc_getsubattrid($attrid) . ')'; $sql = "select a.* from #@__article a left join #@__attrorderlist b on a.aid=b.aid and a.webid=b.webid where {$where} {$picwhere} order by b.displayorder asc, a.modtime desc,a.modtime desc limit {$limit},{$row}"; } else { if (!empty($attrname)) { $temp_one = $dsql->GetOne("select id from #@__article_attr where attrname='{$attrname}'"); if (empty($temp_one)) { return; } else { $sql = "select a.* from #@__article a where FIND_IN_SET({$temp_one['id']},a.attrid) and a.ishidden=0 order by a.modtime desc,a.modtime desc limit {$limit},{$row}"; } } } } else { return ''; } } } } } } } } } } } } } } $dsql->SetQuery($sql); $dsql->Execute(); $ctp = new STTagParse(); $ctp->SetNameSpace("field", "[", "]"); $ctp->LoadSource($innertext); $GLOBALS['autoindex'] = 0; while ($row = $dsql->GetArray()) { $GLOBALS['autoindex']++; $webroot = GetWebURLByWebid($row['webid']); $sonid = $refObj->Fields['sonid']; $row['url'] = $webroot . "/raiders/show_{$row['aid']}.html"; $row['haspic'] = empty($row['litpic']) ? 0 : 1; $litpic = getUploadFileUrl($row['litpic']); $row['lit240'] = getUploadFileUrl(str_replace('litimg', 'lit240', $row['litpic'])); $row['lit160'] = getUploadFileUrl(str_replace('litimg', 'lit160', $row['litpic'])); $row['litpic'] = $litpic; if ($row['allow'] == "usecontentpic" && !empty($row['litpic'])) { $row['imgtitle'] = $row['title'] . '<img src="' . $GLOBALS['cfg_templets_skin'] . '/images/gl_yt.gif" />'; } else { $row['imgtitle'] = $row['title']; } $row['title'] = $row['title']; $row['attrname'] = getAttrname($row['attrid']); $row['attrnamearr'] = getAttrname($row['attrid'], true); $row['destname'] = Helper_Archive::getBelongDestName($row['kindlist']); //所属目的地 $row['destid'] = array_remove_value($row['kindlist']); $row['pinyin'] = Helper_Archive::getDestPinyin($row['destid']); //最新评论及评论数量 $row['commentnum'] = Helper_Archive::getCommentNum($row['id'], 4); if ($type == 'pinlun') { $userinfo = $GLOBALS['User']->getInfoByMid($row['memberid']); $row['commentlitpic'] = getUploadFileUrl($userinfo['litpic']); $row['commentnickname'] = empty($userinfo['nickname']) ? '匿名' : $userinfo['nickname']; $row['commentid'] = $row['plid']; $row['commentcontent'] = $row['plcontent']; $row['commentaddtime'] = $row['pltime']; } //攻略首页读取评论 if ($type == 'pinlun') { $row['pinlun'] = getArticlePinLun($row['id']); } foreach ($ctp->CTags as $tagid => $ctag) { if ($ctag->GetName() == 'array') { $ctp->Assign($tagid, $row); } else { if (isset($row[$ctag->GetName()])) { $ctp->Assign($tagid, $row[$ctag->GetName()]); } } } $revalue .= $ctp->GetResult(); } return $revalue; }
public function __unset($name) { unset($this->data[$name]); if (array_key_exists('update', $this->query)) { array_remove_value($this->query['update'], $name); } }
/** * Возвращает полный список сущностей, не проверяя права доступа */ public final function getAllIdents($includePattern = false) { if (!is_array($this->IDENTS)) { $all = array_keys(FoldedStorage::getEntities($this->UNIQUE)); $this->IDENTS['full'] = $all; $this->IDENTS['short'] = array_values(array_remove_value($all, self::PATTERN_NAME)); } return $this->IDENTS[$includePattern ? 'full' : 'short']; }
function lib_getlinelist(&$ctag, &$refObj) { global $startcity; global $dsql; include SLINEDATA . "/webinfo.php"; $attlist = "row|8,flag|,type|top,sonid|,limit|0,"; FillAttsDefault($ctag->CAttribute->Items, $attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $webid = 0; $innertext = trim($ctag->GetInnertext()); $revalue = ''; $basefield = "a.aid,a.id,a.webid,a.title,a.seotitle,a.sellpoint,a.litpic,a.storeprice,a.price,a.linedate,a.features,a.transport,a.lineday,a.startcity,a.overcity,a.shownum,a.satisfyscore,a.bookcount,a.attrid,a.kindlist,a.color,a.iconlist"; if ($type == 'top' && empty($flag)) { return ''; } //如果调用二级栏目则必须在显示类里指定sonid $limit = !empty($limit) ? $limit : 0; if ($type == 'startcity') { $sql = "select {$basefield} from #@__line as a left join #@__kindorderlist as c on (a.id=c.aid) where a.ishidden=0 and c.typeid=1 and startcity='{$startcity}' and c.classid={$sonid} and FIND_IN_SET({$sonid},a.kindlist) {$orderby} limit {$limit},{$row}"; } if ($type == 'mdd') { if ($flag == 'hot') { $orderby = 'order by case when c.displayorder is null then 9999 end,c.displayorder asc,a.modtime desc,a.addtime desc'; } else { if ($flag == 'recommend') { $orderby = 'order by case when c.displayorder is null then 9999 end,c.displayorder asc,a.modtime desc,a.addtime desc'; } else { if ($flag == 'specical') { $orderby = 'order by case when c.displayorder is null then 9999 end,c.displayorder asc,a.modtime desc,a.addtime desc '; } else { $orderby = 'order by case when c.displayorder is null then 9999 end,c.displayorder asc,a.modtime desc,a.addtime desc'; } } } $sonid = isset($definekind) ? $definekind : $refObj->Fields['kindid']; //这里增加子站的判断 if ($GLOBALS['sys_child_webid'] != 0) { $dest_id = $GLOBALS['sys_child_webid']; } $sonid = $sonid ? $sonid : $dest_id; $shownum = isset($row) ? $row : $refObj->Fields['shownum']; $shownum = empty($shownum) ? 6 : $shownum; if (isset($sonid)) { $number = isset($refObj->Fields['shownumber']) ? $refObj->Fields['shownumber'] : $row; //如果模块设置了显示数量则使用. $sql = "select {$basefield},c.isjian,c.istejia,c.isding from #@__line as a left join #@__kindorderlist as c on (c.classid={$sonid} and a.id=c.aid and c.typeid=1) where a.ishidden=0 and FIND_IN_SET({$sonid},a.kindlist) {$orderby} limit {$limit},{$shownum}"; } else { return ''; } } else { if ($type == 'searchrec') { if ($GLOBALS['childid'] != 0) { $kchild = $GLOBALS['childid']; $sql = "select distinct {$basefield} from #@__line as a left join #@__kindorderlist as c on (c.classid={$kchild} and a.id=c.aid and c.typeid=1) where a.ishidden=0 and c.isjian=1 and FIND_IN_SET({$kchild},a.kindlist) order by case when c.displayorder is null then 9999 end,c.displayorder asc,a.modtime desc,a.addtime desc limit 0,4"; } else { $sql = "select {$basefield} a from #@__line where a.ishidden=0 and a.isjian=1 order by a.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } } else { if ($type == 'destsearchrec') { if ($GLOBALS['destid'] != 0) { $kchild = $GLOBALS['destid']; $sql = "select {$basefield} from #@__line as a left join #@__kindorderlist as c on (c.classid={$kchild} and a.id=c.aid and c.typeid=1) where a.ishidden=0 and FIND_IN_SET({$kchild},a.kindlist) {$orderby} limit 0,4"; } else { $sql = "select {$basefield} from #@__line a where a.ishidden=0 and a.isjian=1 order by a.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } } else { if ($type == 'top') { if ($flag == 'recommend') { $sql = "select {$basefield},b.isding,b.istejia,b.displayorder from #@__line as a left join #@__allorderlist b on (a.id=b.aid and b.typeid=1) where a.ishidden=0 order by case when b.displayorder is null then 9999 end, b.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'specical') { $sql = "select {$basefield},b.isding,b.istejia,b.displayorder from #@__line as a left join #@__allorderlist b on (a.id=b.aid and b.typeid=1) where a.ishidden=0 order by b.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'hot') { $sql = "select {$basefield} from #@__line a where a.ishidden=0 order by a.shownum desc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'attribute') { if (empty($attrid)) { $attrid = $refObj->Fields['attrid']; } $sql = "select {$basefield} from #@__line a where FIND_IN_SET('{$attrid}',a.attrid) and a.ishidden=0 order by a.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'relative') { $kindlist = $refObj->Fields['kindlist']; $maxkindid = array_remove_value($kindlist); //最后一级. $maxkindid = empty($maxkindid) ? $GLOBALS['dest_id'] : $maxkindid; $maxkindid = empty($maxkindid) ? 0 : $maxkindid; $where = " FIND_IN_SET({$maxkindid},a.kindlist) "; $sql = "select {$basefield} from #@__line a where {$where} and a.ishidden=0 order by a.shownum desc,a.modtime desc,a.addtime desc limit 0,{$row}"; } else { if ($flag == 'listexcept') { $sql = "select aid from #@__line where isjian=1 and a.ishidden=0 order by isjian desc,displayorder asc limit 0,5"; $dsql->Execute("list", $sql); $a = ""; while ($str = $dsql->GetArray("list")) { $a .= $str["aid"] . ","; } $a = substr($a, 0, -1); if (!$a == "") { $a = "and aid not in ({$a})"; } $sql = "select {$basefield} from #@__line a where {$a} order by a.shownum desc limit {$limit},{$row}"; } } } } } } } else { if ($type == 'theme') { $themeid = $refObj->Fields['themeid']; if (empty($themeid)) { return ''; } $sql = "select {$basefield} from #@__line a where a.ishidden=0 and FIND_IN_SET({$themeid},a.themelist) order by a.modtime desc,a.addtime desc limit 0,{$row}"; } else { if ($type = "day") { $dayid = $refObj->Fields['groupid']; if (empty($dayid)) { return ''; } $sql = "select {$basefield} from #@__line a where a.ishidden=0 and a.lineday={$dayid} order by a.modtime desc,a.addtime desc limit 0,{$row}"; } } } } } } $dsql->SetQuery($sql); $dsql->Execute(); $ctp = new STTagParse(); $ctp->SetNameSpace("field", "[", "]"); $ctp->LoadSource($innertext); $GLOBALS['autoindex'] = 0; $num = 0; while ($row = $dsql->GetArray()) { $GLOBALS['autoindex']++; $webroot = GetWebURLByWebid($row['webid']); $url = $webroot . "/lines/show_{$row['aid']}.html"; $row['url'] = $url; $row['bookurl'] = "{$webroot}/lines/booking_{$row['aid']}.html"; $startcity = getStartCityName($row['startcity']); $startcity = !empty($startcity) ? "[{$startcity}出发]" : ''; if (!empty($GLOBALS['cfg_startcity_open'])) { $row['title'] = "{$startcity}{$row['title']}"; } else { $row['title'] = "{$row['title']}"; } $row['startcity'] = $startcity; $row['color'] = !empty($row['color']) ? "color:{$row['color']}" : ''; $real = getLineRealPrice($row['aid'], $row['webid']); $row['lineprice'] = $real ? $real : $row['price']; $row['commentnum'] = Helper_Archive::getCommentNum($row['id'], 1); //评论次数 $row['sellnum'] = Helper_Archive::getSellNum($row['id'], 1); //销售数量 //$row['satisfyscore']=Helper_Archive::getSatisfyScore($row['id'],1); //满意度 //获取后台满意度拼接% $row['satisfyscore'] = !empty($row['satisfyscore']) ? $row['satisfyscore'] . "%" : ""; if (!empty($row['lineprice']) && !empty($row['storeprice'])) { $row['discount'] = abs((int) $row['storeprice'] - (int) $row['price']); } else { $row['discount'] = 0; } $row['price'] = empty($row['lineprice']) ? '<span class="rmb_1">电询</span>' : "<span class='rmb_1'>¥</span><span class='rmb_2'>" . $row['lineprice'] . '</span>'; $row['price2'] = empty($row['lineprice']) ? '<span>电询</span>' : '<span>¥</span><strong>' . $row['lineprice'] . '</strong><i>起</i>'; $row['agentprice'] = intval($row['storeprice']); $row['sellprice'] = empty($row['lineprice']) ? '0' : $row['lineprice']; //没有HTML标识的价格 $row['storeprice'] = !empty($row['storeprice']) ? "<span class=\"rmb_2\">¥</span>" . $row['storeprice'] : "<span class=\"rmb_1\">电询</span>"; $row['lineseries'] = getSeries($row['id'], '01'); //$row['lit240']=getPicByName($row['linepic'],'lit240'); //$row['lit160']=getPicByName($row['linepic'],'lit160'); $row['litpic'] = getUploadFileUrl($row['litpic']); $row['lit240'] = getUploadFileUrl(str_replace('litimg', 'lit240', $row['litpic'])); $row['lit160'] = getUploadFileUrl(str_replace('litimg', 'lit160', $row['litpic'])); $row['jifentprice'] = !empty($row['jifentprice']) ? '¥' . $row['jifentprice'] : '无'; $row['startdate'] = getLine_StartDate($row); //团期 $row['jifentprice'] = MLine::getMinTprice($row['id']); $row['list'] = $num; foreach ($ctp->CTags as $tagid => $ctag) { if ($ctag->GetName() == 'array') { $ctp->Assign($tagid, $row); } else { $ctp->Assign($tagid, $row[$ctag->GetName()]); } } $revalue .= $ctp->GetResult(); } return $revalue; }
/** * 调用团购显示数据标签 * * @version $Id: gettuanlist.lib.php netman * @package Stourweb.Taglib * @copyright Copyright (c) 2007 - 2011, Stourweb, Inc. * @link http://www.stourweb.com */ function lib_gettuanlist(&$ctag, &$refObj) { global $dsql; include SLINEDATA . "/webinfo.php"; $attlist = "row|8,flag|,type|top,limit|0,haspic|1,day|"; FillAttsDefault($ctag->CAttribute->Items, $attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $innertext = trim($ctag->GetInnertext()); $revalue = ''; $basefield = 'a.*'; $time = time(); if ($type == 'mdd') { if ($flag == 'recommend') { $orderby = 'order by case when c.displayorder is null then 9999 end,c.displayorder asc,a.addtime desc'; } else { if ($flag == 'hot') { $orderby = 'order by case when c.displayorder is null then 9999 end,c.displayorder asc,a.addtime desc'; } else { if ($flag == 'new') { $orderby = 'order by a.addtime desc'; } else { $orderby = 'order by case when c.displayorder is null then 9999 end,c.displayorder asc,a.addtime desc'; } } } if (isset($refObj->Fields['kindid'])) { $sonid = $refObj->Fields['kindid']; $number = isset($refObj->Fields['shownumber']) ? $refObj->Fields['shownumber'] : $row; //如果模块设置了显示数量则使用. $where = "a.ishidden=0 and FIND_IN_SET({$sonid},a.kindlist) and a.endtime>{$time} and a.starttime<={$time}"; $where .= !empty($haspic) ? " and a.litpic is not null" : ''; $sql = "select {$basefield} from #@__tuan as a left join #@__kindorderlist as c on (c.classid={$sonid} and a.id=c.aid and c.typeid=4) where {$where} {$orderby} limit {$limit},{$number}"; } else { return ''; } } else { if ($type == 'daytime') { if (!empty($day)) { $day = date('Y-m-d', strtotime($day)); $day = strtotime($day); $sql = "select {$basefield} from #@__tuan a where a.ishidden=0 and starttime={$day} and endtime!='' order by a.addtime asc,a.endtime asc limit {$limit},{$row}"; } else { $sql = "select {$basefield} from #@__tuan a where a.ishidden=0 and endtime>{$time} and endtime!='' and a.starttime>{$time} order by a.starttime asc,a.addtime desc limit {$limit},{$row}"; } } else { if ($flag == 'recommend') { $sql = "select {$basefield},b.isjian,b.isding as isding,b.displayorder from #@__tuan a left join #@__allorderlist b on (a.id=b.aid and b.typeid=13) where a.ishidden=0 and a.endtime>{$time} order by case when b.displayorder is null then 9999 end,b.displayorder asc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'new') { $sql = "select {$basefield} from #@__tuan a where a.ishidden=0 and endtime>{$time} and endtime!='' and a.starttime<={$time} order by a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'hot') { $sql = "select {$basefield} from #@__tuan a where a.ishidden=0 and endtime>{$time} and endtime!='' and a.starttime<={$time} order by a.shownum desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'byendtime') { $sql = "select {$basefield} from #@__tuan a where a.ishidden=0 and endtime>{$time} and endtime!='' and a.starttime<={$time} order by a.endtime asc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'photo') { $sql = "select {$basefield} from #@__tuan a where a.ishidden=0 and a.litpic !='' and endtime>{$time} and endtime!='' and a.starttime<={$time} order by a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'nostart') { $sql = "select {$basefield} from #@__tuan a where a.ishidden=0 and endtime>{$time} and endtime!='' and a.starttime>{$time} order by a.starttime asc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'relative') { $kindlist = $refObj->Fields['kindlist']; $maxkindid = get_exist_kind($kindlist); //最后一级. $maxkindid = empty($maxkindid) ? 0 : $maxkindid; $where = " FIND_IN_SET({$maxkindid},a.kindlist) "; //排序顺序:置顶+tag关联》排序+ tag关联》最新更新+tag关联 $sql = "select a.* from #@__tuan a where find_in_set('{$attrid}',a.attrid) where a.ishidden=0 and endtime>{$time} and endtime!='' and a.starttime<={$time} order by a.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row} "; } else { if ($type == 'theme') { $themeid = $refObj->Fields['themeid']; if (empty($themeid)) { return ''; } $sql = "select a.* from #@__tuan a where a.ishidden=0 and FIND_IN_SET({$themeid},a.themelist) and endtime>{$time} and endtime!='' and a.starttime<={$time} order by a.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { return ''; } } } } } } } } } } $dsql->SetQuery($sql); $dsql->Execute(); $ctp = new STTagParse(); $ctp->SetNameSpace("field", "[", "]"); $ctp->LoadSource($innertext); $GLOBALS['autoindex'] = 0; while ($row = $dsql->GetArray()) { $GLOBALS['autoindex']++; $webroot = GetWebURLByWebid($row['webid']); $sonid = $refObj->Fields['sonid']; $row['url'] = $webroot . "/tuan/show_{$row['aid']}.html"; $row['litpic'] = getUploadFileUrl($row['litpic']); $row['lit240'] = str_replace('litimg', 'lit240', $row['litpic']); $row['lit160'] = str_replace('litimg', 'lit160', $row['litpic']); $row['attrname'] = getTuanAttrname($row['attrid']); $row['attrnamearr'] = getTuanAttrname($row['attrid'], true); $row['destname'] = Helper_Archive::getBelongDestName($row['kindlist']); //所属目的地 $row['destid'] = array_remove_value($row['kindlist']); $row['discount'] = floor($row['price'] / $row['sellprice'] * 100) / 10; //折扣 $row['booknum'] = Helper_Archive::getSellNum($row['id'], 13) + $row['virtualnum']; $row['satisfyscore'] = Helper_Archive::getSatisfyScore($row['id'], 13); //满意度 $row['price'] = $row['price']; foreach ($ctp->CTags as $tagid => $ctag) { if ($ctag->GetName() == 'array') { $ctp->Assign($tagid, $row); } else { if (isset($row[$ctag->GetName()])) { $ctp->Assign($tagid, $row[$ctag->GetName()]); } } } $revalue .= $ctp->GetResult(); } return $revalue; }
/** * 调用酒店数据标签 * * @version $Id: gethotellist.lib.php netman * @package Stourweb.Taglib * @copyright Copyright (c) 2007 - 2011, Stourweb, Inc. * @link http://www.stourweb.com */ function lib_gethotellist(&$ctag, &$refObj) { global $dsql; $attlist = "row|8,flag|,type|top,sonid|,limit|0"; FillAttsDefault($ctag->CAttribute->Items, $attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $innertext = trim($ctag->GetInnertext()); $revalue = ''; $basefield = 'a.id,a.sellpoint,a.aid,a.kindlist,a.title,a.address,a.litpic,a.ishidden,a.hotelrankid,a.webid,a.hotelrankid as hotelrankids,a.shownum,a.iconlist'; if ($type == 'top' && empty($flag)) { return ''; } //如果调用二级栏目则必须在显示类里指定sonid $limit = !empty($limit) ? $limit : 0; //加目的地页面显示条件 $destwhere = isset($refObj->Fields['kindid']) ? "and FIND_IN_SET({$refObj->Fields['kindid']},a.kindlist) " : ''; //用于聚合页面 if ($type == 'mdd') { $sonid = $refObj->Fields['kindid']; if ($GLOBALS['sys_child_webid'] != 0) { $dest_id = $GLOBALS['sys_child_webid']; //当前级目的地id. } $sonid = $sonid ? $sonid : $dest_id; if (!isset($sonid)) { return ''; } if ($flag == 'hot') { $orderby = 'order by case when b.displayorder is null then 9999 end,b.displayorder asc'; } else { if ($flag == 'recommend') { $orderby = 'order by case when b.displayorder is null then 9999 end,b.displayorder asc'; } else { if ($flag == 'specical') { $orderby = 'case when b.displayorder is null then 9999 end,b.displayorder asc'; } else { $orderby = 'order by case when b.displayorder is null then 9999 end,b.displayorder asc'; } } } $orderby .= ",a.modtime desc,a.addtime desc"; $where = "FIND_IN_SET({$sonid},a.kindlist)"; $sql = "select {$basefield},b.isding,b.isjian,b.istejia from #@__hotel a left join #@__kindorderlist as b on (a.id=b.aid and b.classid='{$sonid}' and b.typeid='2') where " . $where . " and (a.ishidden='0' or a.ishidden is null){$orderby} limit {$limit},{$row}"; } else { if ($type == 'rank') { if (isset($refObj->Fields['sonid'])) { $sonid = $refObj->Fields['sonid']; $sql = "select a.*,b.hotelrank from #@__hotel a left join #@__hotel_rank b on a.hotelrankid=b.aid where a.webid=0 and a.hotelrankid={$sonid} and a.ishidden='0' order by a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { return ''; } } else { if ($type == 'rankhot') { $sql = "select a.*,b.hotelrank from #@__hotel a left join #@__hotel_rank b on a.hotelrankid=b.aid where a.ishidden='0' order by a.shownum desc limit {$limit},{$row}"; } else { if ($type == 'theme') { $themeid = $refObj->Fields['themeid']; if (empty($themeid)) { return ''; } $sql = "select a.*,b.hotelrank,a.price as price from #@__hotel a left join #@__hotel_rank b on (a.hotelrankid=b.aid and a.webid=b.webid) where a.ishidden='0' and FIND_IN_SET({$themeid},a.themelist) order by a.modtime desc,a.addtime desc,a.shownum desc limit {$limit},{$row}"; } else { if ($type == 'top') { if ($flag == 'recommend') { $sql = "select {$basefield},b.displayorder,b.isding,b.isjian,b.istejia,a.ishidden,a.price from #@__hotel a left join #@__allorderlist b on(a.id=b.aid and b.typeid=2) where a.ishidden='0' order by case when b.displayorder is null then 9999 end,b.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'special') { $sql = "select {$basefield},b.displayorder,b.isding,b.isjian,b.istejia as istehui,a.ishidden from #@__hotel a left join #@__allorderlist b on(a.id=b.aid and b.typeid=2) order by case when b.displayorder is null then 9999 end,b.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'hot') { $sql = "select a.*,b.hotelrank,a.price as price from #@__hotel a left join #@__hotel_rank b on (a.hotelrankid=b.aid and a.webid=b.webid) where a.ishidden='0' group by a.title order by a.shownum desc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'relative') { $kindlist = $refObj->Fields['kindlist']; $maxkindid = array_remove_value($kindlist); //最后一级. $maxkindid = empty($maxkindid) ? $GLOBALS['dest_id'] : $maxkindid; $maxkindid = empty($maxkindid) ? 0 : $maxkindid; $where = " FIND_IN_SET({$maxkindid},a.kindlist) "; //排序顺序:置顶+tag关联》排序+ tag关联》最新更新+tag关联 $sql = "select a.*,b.hotelrank from #@__hotel a left join #@__hotel_rank b on (a.hotelrankid=b.aid and a.webid=b.webid) where a.ishidden='0' and {$where} order by a.modtime desc,a.addtime desc limit {$limit},{$row} "; } else { return ''; } } } } } } } } } $dsql->SetQuery($sql); $dsql->Execute(); $ctp = new STTagParse(); $ctp->SetNameSpace("field", "[", "]"); $ctp->LoadSource($innertext); $GLOBALS['autoindex'] = 0; while ($row = $dsql->GetArray()) { $GLOBALS['autoindex']++; $urlname = GetPinyin($row['kindname']); $flag != "channel" ? $webroot = GetWebURLByWebid($row['webid']) : ""; $row['url'] = GetWebURLByWebid($row['webid']) . "/hotels/show_{$row['aid']}.html"; $row['title'] = $row['title']; //$row['price']=empty($row['price'])?GetHotelMinPrice($row['webid'],$row['aid']):$row['price']; $row['kindname'] = getHotelKindCity2($row['kindlist']); $row['commentnum'] = Helper_Archive::getCommentNum($row['id'], 2); //评论次数 $row['sellnum'] = Helper_Archive::getSellNum($row['id'], 2) + $row['bookcount']; //销售数量 $row['satisfyscore'] = Helper_Archive::getSatisfyScore($row['id'], 2); //满意度 $row['listingprice'] = getHotelSellPrice2($row['id']); //挂牌价 $row['price'] = Helper_Archive::getHotelMinPrice($row['id']); $row['sellprice'] = empty($row['price']) ? '0' : $row['price']; $row['price2'] = empty($row['price']) ? '电询' : '¥' . $row['price'] . '起'; //样式2 $row['price3'] = empty($row['price']) ? '电询' : '<strong>¥' . $row['price'] . '</strong><span>起</span>'; $row['price4'] = empty($row['price']) ? '电询' : '<span>¥</span><strong>' . $row['price'] . '</strong><i>起</i>'; //目的地页面用 $row['price'] = empty($row['price']) ? '<span class="rmb_1">电询</span>' : "<span class='rmb_1'>¥</span>" . $row['price'] . "<span>起</span>"; $litpic = getUploadFileUrl($row['litpic']); $row['lit240'] = getUploadFileUrl(str_replace('litimg', 'lit240', $row['litpic'])); $row['lit160'] = getUploadFileUrl(str_replace('litimg', 'lit160', $row['litpic'])); $row['litpic'] = $litpic; $row['typeurl'] = $GLOBALS['cfg_cmsurl'] . "/hotels/{$urlname}_{$row['id']}.html"; foreach ($ctp->CTags as $tagid => $ctag) { if ($ctag->GetName() == 'array') { $ctp->Assign($tagid, $row); } else { if (!empty($row[$ctag->GetName()])) { $ctp->Assign($tagid, $row[$ctag->GetName()]); } else { $ctp->Assign($tagid, ''); } } } $revalue .= $ctp->GetResult(); } return $revalue; }
/** * list the child comments for one parent-comment * * @param mixed $parent ID of parent comment or "pro"/"contra"/"discussion" * @param integer $level (optional) folding level, top level is 0 * @param boolean $full (optional) allow showing full text */ private function display_comments($parent, $level=0, $full=true) { $sql = "SELECT comment.*, rating.score"; if (Login::$member) { $sql .= ", seen.comment AS seen FROM comment LEFT JOIN rating ON rating.comment = comment.id AND rating.member = ".intval(Login::$member->id)." LEFT JOIN seen ON seen.comment = comment.id AND seen.member = ".intval(Login::$member->id); } else { $sql .= " FROM comment LEFT JOIN rating ON rating.comment = comment.id AND rating.session = ".DB::esc(session_id()); } // intval($parent) gives parent=0 for "pro"/"contra"/"discussion" $sql .= " WHERE proposal=".intval(self::$proposal->id)." AND rubric=".DB::esc($this->rubric)." AND parent=".intval($parent)." ORDER BY removed, rating DESC, created"; $result = DB::query($sql); $comments = array(); $open_ids = array(); while ( $comment = DB::fetch_object($result, "Comment") ) { /** @var Comment $comment */ $comments[] = $comment; if (in_array($comment->id, self::$open_ids)) $open_ids[] = $comment->id; } if (!$comments and self::$parent!=$parent) return; ?> <ul> <? $position = 1; $remaining = 0; $new = 0; $highlight_started = false; $comments_head = self::comments_head($level); $open = in_array($parent, self::$open); foreach ( $comments as $comment ) { $limit_reached = $position > $comments_head; if ( $limit_reached and !$open and !$open_ids // display comments until all to be open have been displayed ) { $remaining++; if (Login::$member and !$comment->seen) $new++; } else { // highlight if ( $limit_reached and isset($_GET['openhl']) and $_GET['openhl']==$parent and !$highlight_started ) { ?> <div id="openhl"> <? $highlight_started = true; } // display one comment and its children $this->display_comment($comment, $position, $level, $full); array_remove_value($open_ids, $comment->id); } $position++; } if ($highlight_started) { ?> </div> <? } // links to remaining comments only under fully shown comments if ($remaining and $full) { $open = self::$open; $show = self::$show; $open[] = $parent; $open = array_unique($open); ?> <li><a href="<?php echo URI::append(['open' => $open, 'show' => $show, 'openhl' => $parent]); ?> #openhl"><? if (!intval($parent)) { if ($this->rubric=="discussion") { if ($new) printf(ngettext("show remaining 1 new comment", "show remaining %d comments, %d of them new", $remaining), $remaining, $new); else printf(ngettext("show remaining 1 comment", "show remaining %d comments", $remaining), $remaining); } else { if ($new) printf(ngettext("show remaining 1 new argument", "show remaining %d arguments, %d of them new", $remaining), $remaining, $new); else printf(ngettext("show remaining 1 argument", "show remaining %d arguments", $remaining), $remaining); } } else { if ($position==1) { if ($new) printf(ngettext("show 1 new reply", "show %d replys, %d of them new", $remaining), $remaining, $new); else printf(ngettext("show 1 reply", "show %d replys", $remaining), $remaining); } else { if ($new) printf(ngettext("show remaining 1 new reply", "show remaining %d replys, %d of them new", $remaining), $remaining, $new); else printf(ngettext("show remaining 1 reply", "show remaining %d replys", $remaining), $remaining); } } ?></a></li> <? } if ( isset($_GET['parent']) and $_GET['parent']==$parent and Login::access_allowed("comment") and self::$proposal->allowed_add_comments($this->rubric) ) { ?> <li id="form" class="anchor"> <div class="comment"> <? form(URI::append(['parent'=>$parent]), "", "comment", "comment", true); ?> <div class="time"><? if (intval($parent)) echo _("New reply"); elseif ($this->rubric=="discussion") echo _("New comment"); else echo _("New argument"); ?>:</div> <input name="title" type="text" maxlength="<?php echo Comment::title_length; ?> " value="<?php echo h(isset($_POST['title']) ? $_POST['title'] : ""); ?> " required><br> <textarea name="content" rows="5" maxlength="<?php echo Comment::content_length; ?> " required><?php echo h(isset($_POST['content']) ? $_POST['content'] : ""); ?> </textarea><br> <input type="hidden" name="action" value="add_comment"> <input type="hidden" name="parent" value="<?php echo $parent; ?> "> <input type="submit" value="<?php echo _("save"); ?> "> <? form_end(); ?> </div> </li> <? } ?> </ul> <? }
function executeProcess(array $argv) { $CLASS_PATTERN = file_get_contents(file_path(__DIR__, 'class.txt')); $METHOD_PATTERN = file_get_contents(file_path(__DIR__, 'method.txt')); /* * Название тестового файла. * Для проверки мы сначала удалим класс для него, если он был, потом проверим, что за класс был сгенерирован. */ $TEST_MESSAGES_FILE = 'ExampleSdkProcessMessages'; //Убедимся, что тестовый .msgs существует и удалим тестовый .php файл $TEST_PHP_DI = DirItem::inst(__DIR__ . '/classes', $TEST_MESSAGES_FILE, PsConst::EXT_PHP)->remove(); $TEST_MSGS_DI = DirItem::inst(__DIR__ . '/classes', $TEST_MESSAGES_FILE, PsConst::EXT_MSGS); check_condition($TEST_MSGS_DI->isFile(), "File {$TEST_MSGS_DI->getAbsPath()} must exists"); dolog('Loading all files, ended with Messages.msgs'); //TODO - после нужно получать эту информацию из какого-нибудь места $exceptDirs[] = DirManager::autogen()->relDirPath(); $exceptDirs[] = DirManager::resources()->relDirPath(); $exceptDirs[] = DirManager::stuff()->relDirPath(); //$exceptDirs = array(); $items = DirManager::inst()->getDirContentFull(null, function (DirItem $di) { dolog($di->getAbsPath()); return $di->isFile() && ends_with($di->getName(), 'Messages.msgs'); }, $exceptDirs); dolog('Message files for processing: {}', count($items)); //Проверим, что был выбран тестовый файл check_condition(in_array($TEST_MSGS_DI, $items, true), "Test file [{$TEST_MESSAGES_FILE}] is not included"); //Удалим его из массива... array_remove_value($items, $TEST_MSGS_DI, true); //И поместим наверх, чтобы он был обработан первым array_unshift($items, $TEST_MSGS_DI); /* @var $msgsDi DirItem */ foreach ($items as $msgsDi) { dolog('PROCESSING [{}]', $msgsDi->getAbsPath()); //Сбросим методы $METHODS = array(); //Извлечём название класса $CLASS = $msgsDi->getNameNoExt(); //DirItem файла с сообщениями php $classDi = DirItem::inst($msgsDi->getDirname(), $CLASS, PsConst::EXT_PHP); //Получаем сообщения из файла .msgs $messages = $msgsDi->getFileAsProps(); foreach ($messages as $MSG_KEY => $MGG_VALUE) { dolog(' >> {}={}', $MSG_KEY, $MGG_VALUE); //Получим список всех параметров из макросов ({0}, {1}, {2} и т.д.) preg_match_all("/\\{(.+?)\\}/", $MGG_VALUE, $args); $args = array_values(array_unique($args[1])); sort($args, SORT_NUMERIC); $ARGS = array(); for ($index = 0; $index < count($args); $index++) { $arg = $args[$index]; $lineDescr = PsStrings::replaceWithBraced('[{}] in line [{}={}]', $msgsDi->getRelPath(), $MSG_KEY, $MGG_VALUE); check_condition(is_inumeric($arg), "Invalid argument [{$arg}] for {$lineDescr}"); check_condition($index == $args[$index], "Missing index [{$index}] for {$lineDescr}"); $ARGS[] = '$p' . $index; } $ARGS = join(', ', $ARGS); //Добавляем метод dolog(" A: {}::{} ({})", $CLASS, $MSG_KEY, $ARGS); $PARAMS['SUPPORT_CLASS'] = PsMsgs::getClass(); $PARAMS['MESSAGE'] = $MGG_VALUE; $PARAMS['FUNCTION'] = $MSG_KEY; $PARAMS['ARGS'] = $ARGS; $METHODS[] = PsStrings::replaceMapBracedKeys($METHOD_PATTERN, $PARAMS); } dolog('Made methods: ({})', count($METHODS)); if ($METHODS) { $PARAMS['FILE'] = $msgsDi->getAbsPath(); $PARAMS['CLASS'] = $CLASS; $PARAMS['DATE'] = date(DF_PS); $PARAMS['METHODS'] = "\n" . join("\n\n", $METHODS) . "\n"; $CLASS_PHP = PsStrings::replaceMapBracedKeys($CLASS_PATTERN, $PARAMS); $classDi->putToFile($CLASS_PHP); } /* * Если обрабатываем тестовый файл - проверим его */ //TEST CLASS VALIDATION START >>> if ($msgsDi->equals($TEST_MSGS_DI)) { dolog(''); dolog('Validating test class {}', $TEST_MESSAGES_FILE); //Проверим, что .php был сгенерирован check_condition($TEST_PHP_DI->isFile(), "File {$TEST_PHP_DI->getAbsPath()} was not created!"); //Проверим, что для каждого сообщения был создан метод $methods = PsUtil::newReflectionClass($TEST_MESSAGES_FILE)->getMethods(); $messages = $TEST_MSGS_DI->getFileAsProps(); check_condition(count($methods) == count($messages), 'Methods count missmatch, check ' . $TEST_PHP_DI->getAbsPath()); /* @var $method ReflectionMethod */ foreach ($methods as $method) { check_condition(array_key_exists($method->getName(), $messages), "No method {$TEST_MESSAGES_FILE}::" . $method->getName()); } //Проверим, что возвращают методы тестового сгенерированного класса function doTest($className, $methodName, array $params, $expected) { $method = "{$className}::{$methodName}"; $actual = call_user_func_array($method, $params); dolog("{}({})='{}', Expected='{}'", $method, join(', ', $params), $actual, $expected); check_condition($actual == $expected, "{$actual} != {$expected}"); } doTest($TEST_MESSAGES_FILE, 'message1', array(), 'Message 1'); doTest($TEST_MESSAGES_FILE, 'message2', array('a', 'b', 'c'), 'Parametred a,c,b'); dolog('Test class is valid!'); } //TEST CLASS VALIDATION END <<< } //# DirItems validation end }
function initElements() { /* @var $bootstrap Bootstrap */ $modules = $this->addMagicSelect('modules')->setLabel(___('Enabled Modules')); $this->setDefault('modules', array()); foreach (Am_Di::getInstance()->modules->getAvailable() as $module) { $fn = APPLICATION_PATH . '/' . $module . '/module.xml'; if (!file_exists($fn)) { continue; } $xml = simplexml_load_file($fn); if (!$xml) { continue; } $modules->addOption($module . ' - ' . $xml->desc, $module); } $plugins = self::getPluginsList(Am_Di::getInstance()->plugins_payment->getPaths()); array_remove_value($plugins, 'free'); $this->addMagicSelect('plugins.payment')->setLabel(___('Payment Plugins') . "\n" . ___("plugins that process credit cards on your website\n" . "will appear in the list once you enable [cc] module above"))->loadOptions($plugins); $this->setDefault('plugins.payment', array()); $this->addMagicSelect('plugins.protect')->setLabel(___('Integration Plugins'))->loadOptions(self::getPluginsList(Am_Di::getInstance()->plugins_protect->getPaths())); $this->setDefault('plugins.protect', array()); $this->addMagicSelect('plugins.misc')->setLabel(___('Other Plugins'))->loadOptions(self::getPluginsList(Am_Di::getInstance()->plugins_misc->getPaths())); $this->setDefault('plugins.misc', array()); }
/** * @param array $args * name: 帐目摘要 * received: 是否到帐 * reviewed: 已审核 * count: 计入创收 * project: 指定项目id * project_labels * project_without_labels * project_is_active * show_payer: 获得付款人信息payer, payer_name * date: (预估)到账日期 * array( * from=>日期字符串 * to=>日期字符串 * ) * contract_date: 签约日期 * array( * from=>日期字符串 * to=>日期字符串 * ) * group_by: * account: 根据帐目编号分组并获得帐目中创收金额received, 总额total, receive_date, receivable_date, comment * team: 根据团组分组并获得team_name, team * people: 根据项目人员分组并获得people_name, people,role,type * month: 根据收款月份分组并获得month * month_contract: 根据签约月份分组并获得month * team: 团队 * people: 指定项目人员 * role: 指定项目人员角色(需配合group:people或people) * account: 指定帐目编号 * sum: 获得amount求和,此操作将使除group获得的其他值失去意义 * @return array */ function getList(array $args = array()) { $this->db->select('account.*')->join('project', 'project.id = account.project', 'LEFT'); if (isset($args['received'])) { $this->db->where('account.received', (bool) intval($args['received'])); } if (isset($args['project'])) { $this->db->where('project', $args['project']); } if (isset($args['project_labels'])) { foreach ($args['project_labels'] as $id => $label_name) { $this->db->join("project_label t_{$id}", "account.project = t_{$id}.project AND t_{$id}.label_name = '{$label_name}'", 'inner'); } } if (isset($args['project_without_labels'])) { foreach ($args['project_without_labels'] as $id => $label_name) { $this->db->where("account.project NOT IN (SELECT project FROM project_label WHERE label_name = '{$label_name}')"); } } if (isset($args['project_is_active'])) { $this->db->where('project.active', (bool) $args['project_is_active']); } if (isset($args['show_project'])) { $this->db->select('project.id project, project.type project_type, project.name project_name'); if (isset($args['project_name'])) { $this->db->like('project.name', $args['project_name']); } } if (isset($args['show_payer'])) { $this->db->join('people payer', "payer.id = account.people", 'left')->select('IF(payer.abbreviation IS NULL, payer.name, payer.abbreviation) AS payer_name,payer.id AS payer', false); if (isset($args['payer_name'])) { $this->db->like('payer.name', $args['payer_name']); } } if (isset($args['show_account'])) { $this->db->join('account a', 'a.id = account.account', 'inner')->select('a.name AS name, a.type AS type'); } foreach (array('date', 'contract_date') as $date_args) { if (!isset($args[$date_args])) { $args[$date_args] = array_prefix($args, $date_args); } } if (isset($args['date']['from']) && $args['date']['from']) { $this->db->where("TO_DAYS(account.date) >= TO_DAYS('{$args['date']['from']}')", NULL, FALSE); } if (isset($args['date']['to']) && $args['date']['to']) { $this->db->where("TO_DAYS(account.date) <= TO_DAYS('{$args['date']['to']}')", NULL, FALSE); } if (isset($args['contract_date']['from']) && $args['contract_date']['from']) { $this->db->where("TO_DAYS(project.time_contract) >= TO_DAYS('{$args['contract_date']['from']}')", NULL, FALSE); } if (isset($args['contract_date']['to']) && $args['contract_date']['to']) { $this->db->where("TO_DAYS(project.time_contract) <= TO_DAYS('{$args['contract_date']['to']}')", NULL, FALSE); } if (isset($args['team'])) { $team = intval($args['team']); $this->db->where('account.team', $team); } if (isset($args['people'])) { $people = intval($args['people']); $this->db->join('project_people', "project_people.project = project.id AND project_people.people = {$people}", 'inner'); if (isset($args['role'])) { $this->db->select('weight', false); if (is_array($args['role'])) { $this->db->where_in('project_people.role', $args['role']); } else { $this->db->where('project_people.role', $args['role']); } } } if (isset($args['account'])) { $account = intval($args['account']); $this->db->where('account.account', $account); } if (isset($args['amount'])) { $this->db->where('account.amount', $args['amount']); } if (isset($args['reviewed'])) { $this->db->where('account.received', (bool) intval($args['reviewed'])); } if (isset($args['count'])) { $this->db->where('account.count', (bool) intval($args['count'])); unset($args['count']); } if (isset($args['group_by'])) { if ($args['group_by'] === 'account') { $this->db->group_by('account.account')->select(' MAX(account.type) AS type, SUM(IF(account.received,account.amount,0)) AS received_amount, SUM(IF(account.received,0,account.amount)) AS total_amount, SUM(IF(account.received,0,account.amount)) - SUM(IF(account.received,account.amount,0)) AS receivable_amount, MAX(IF(account.received,account.date,NULL)) AS received_date, MAX(IF(account.received,NULL,account.date)) AS receivable_date, GROUP_CONCAT(account.comment) AS comment ', false); } elseif ($args['group_by'] === 'team') { $this->db->group_by('account.team')->join('team', 'team.id = account.team', 'inner')->select('team.name AS team_name, team.id AS team'); } elseif ($args['group_by'] === 'people') { if ($args['role']) { $this->db->join('project_people', 'project_people.project = account.project', 'inner')->select('project_people.role, project_people.weight, account.amount * project_people.weight `amount`', false); if (is_array($args['role'])) { $this->db->where_in('project_people.role', $args['role']); } else { $this->db->where('project_people.role', $args['role']); } } else { $this->db->join('project_people', 'project_people.project = account.project', 'inner'); } $this->db->join('people', 'people.id = project_people.people', 'inner')->group_by('project_people.people')->select('people.name AS people_name, people.id AS people'); } elseif ($args['group_by'] === 'month') { $this->db->group_by('LEFT(account.date,7)', false)->order_by('month')->select('LEFT(account.date,7) AS month', false); } elseif ($args['group_by'] === 'month_contract') { $this->db->group_by('LEFT(project.time_contract,7)', false)->order_by('month')->select('LEFT(project.time_contract,7) AS month', false); } elseif ($args['group_by'] === 'project') { $this->db->group_by('account.project')->select('account.project'); } if (isset($args['having'])) { $this->db->having($args['having']); } } if (isset($args['sum']) && $args['sum'] === true) { array_remove_value($this->db->ar_select, 'account.*'); array_remove_value($this->db->ar_select, '`amount`', true); if (isset($args['role'])) { if (isset($args['ten_thousand_unit']) && $args['ten_thousand_unit']) { $this->db->select('ROUND(SUM(account.amount * weight)/1E4,1) `sum`', false); } else { $this->db->select('ROUND(SUM(account.amount * weight)) `sum`', false); } } else { if (isset($args['ten_thousand_unit']) && $args['ten_thousand_unit']) { $this->db->select('ROUND(SUM(account.amount)/1E4,1) `sum`', false); } else { $this->db->select('ROUND(SUM(account.amount)) `sum`', false); } } //$this->db->having('sum >',0); } else { if (isset($args['ten_thousand_unit']) && $args['ten_thousand_unit']) { $this->db->select('ROUND(account.amount/1E4,1) `amount`', false); } } return parent::getList($args); }
function lib_getspotlist(&$ctag, &$refObj) { global $dsql; include SLINEDATA . "/webinfo.php"; $attlist = "row|8,flag|,type|top,sonid|,limit|0,kindid|"; FillAttsDefault($ctag->CAttribute->Items, $attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $innertext = trim($ctag->GetInnertext()); $revalue = ''; $basefield = 'a.aid,a.id,a.title,a.litpic,a.area,a.tagword,a.kindlist,a.webid,a.attrid,a.shownum,a.want,a.went,a.sellpoint,a.iconlist'; if ($type == 'top' && empty($flag)) { return ''; } //如果调用二级栏目则必须在显示类里指定sonid //加目的地页面显示条件 $destwhere = isset($refObj->Fields['kindid']) ? "and FIND_IN_SET({$refObj->Fields['kindid']},kindlist) " : ''; if ($type == 'mdd') { if ($flag == 'recommend') { $orderby = ' order by case when c.displayorder is null then 9999 end,c.displayorder asc'; } else { if ($flag == 'hot') { $orderby = 'order by case when c.displayorder is null then 9999 end,c.displayorder asc'; } else { $orderby = 'order by case when c.displayorder is null then 9999 end,c.displayorder asc'; } } $orderby .= ",a.modtime desc,a.addtime desc"; //这里增加子站的判断 if ($GLOBALS['sys_child_webid'] != 0) { $dest_id = $GLOBALS['sys_child_webid']; } if (!empty($refObj->Fields['kindid']) || $dest_id) { $sonid = $refObj->Fields['kindid']; $sonid = empty($sonid) ? $dest_id : $sonid; $where = "where FIND_IN_SET({$sonid},a.kindlist) {$orderby} limit {$limit},{$row}"; $sql = "select a.* from #@__spot as a left join #@__kindorderlist as c on (c.classid={$sonid} and a.id=c.aid and c.typeid=5) {$where}"; //echo $sql; } else { $sql = "select {$basefield},b.isding as isding,b.isjian,b.displayorder from #@__spot as a left join #@__allorderlist b on (a.id=b.aid and b.typeid=5) order by case when b.displayorder is null then 9999 end,b.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } } else { if ($type == 'aroundspot') { $kindid = array_remove_value($refObj->Fields['kindlist']); $sql = "select * from #@__spot where FIND_IN_SET({$kindid},kindlist) order by modtime desc,addtime desc limit {$limit},{$row}"; } else { if ($type == 'top') { if ($flag == 'recommend') { $sql = "select a.ishidden,{$basefield},b.isding as isding,b.isjian,b.displayorder from #@__spot as a left join #@__allorderlist b on (a.id=b.aid and b.typeid=5) where a.ishidden=0 order by case when b.displayorder is null then 9999 end,b.displayorder asc,a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'hot') { $sql = "select {$basefield} from #@__spot a where webid is not null {$destwhere} order by a.modtime desc,a.addtime desc,a.shownum desc limit {$limit},{$row}"; } else { if ($flag == 'want') { $sql = "select {$basefield} from #@__spot a where a.webid is not null {$destwhere} order by a.want desc,a.shownum desc limit {$limit},{$row}"; } else { if ($flag == 'went') { $sql = "select {$basefield} from #@__spot a where a.webid is not null {$destwhere} order by a.went desc limit {$limit},{$row}"; } else { if ($flag == 'attr') { $attrid = $refObj->Fields['attrid']; $sql = "select {$basefield} from #@__spot a where FIND_IN_SET({$attrid},a.attrid) order by a.modtime desc,a.addtime desc limit {$limit},{$row}"; } else { if ($flag == 'relative') { $kindlist = $refObj->Fields['kindlist']; $maxkindid = array_remove_value($kindlist); //最后一级. $where = " FIND_IN_SET({$maxkindid},a.kindlist) "; $sql = "select {$basefield} from #@__spot a where {$where} order by a.modtime desc,a.addtime desc,a.shownum desc limit {$limit},{$row}"; } else { return ''; } } } } } } } else { if ($type == 'theme') { $themeid = $refObj->Fields['themeid']; if (empty($themeid)) { return ''; } $sql = "select {$basefield} from #@__spot a where FIND_IN_SET({$themeid},a.themelist) order by a.modtime desc,a.addtime desc limit {$limit},{$row}"; } } } } $dsql->SetQuery($sql); $dsql->Execute(); $ctp = new STTagParse(); $ctp->SetNameSpace("field", "[", "]"); $ctp->LoadSource($innertext); $GLOBALS['autoindex'] = 0; while ($row = $dsql->GetArray()) { $GLOBALS['autoindex']++; $webroot = GetWebURLByWebid($row['webid']); $url = $webroot . "/spots/show_{$row['aid']}.html"; $row['url'] = $url; $price = getSpotPrice($row['id']); //本站的价格 $sellprice = getSpotsellPrice($row['id']); //票面价格 $row['title'] = $row['title']; $row['lit240'] = getUploadFileUrl(str_replace('litpic', 'lit240', $row['litpic'])); $row['lit160'] = getUploadFileUrl(str_replace('litpic', 'lit160', $row['litpic'])); $row['litpic'] = getUploadFileUrl($row['litpic']); $row['sellprice'] = $price; $row['oldprice'] = $sellprice; $row['price'] = !empty($price) ? "<b>¥" . $price . "</b>起" : '电询'; $row['price2'] = empty($price) ? '电询' : '<span>¥</span><strong>' . $price . '</strong><i>起</i>'; //目的地页面用 $row['price3'] = $price; $row['satisfyscore'] = Helper_Archive::getSatisfyScore($row['id'], 5); //满意度 foreach ($ctp->CTags as $tagid => $ctag) { if ($ctag->GetName() == 'array') { $ctp->Assign($tagid, $row); } else { if (!empty($row[$ctag->GetName()]) || $row[$ctag->GetName()] == '0') { $ctp->Assign($tagid, $row[$ctag->GetName()]); } else { $ctp->Assign($tagid, ''); } } } $revalue .= $ctp->GetResult(); } return $revalue; }
public function testArrayRemoveValueRemovesCorrectValue() { $array = ['test', 'test2']; array_remove_value($array, 'test2'); $this->assertEquals('test', $array[0]); }
/** * * @param array $args * project: get schedule only under this project * project_type * project_labels: 仅获取带有给定标签的事务的日程 * people: * people_type: * people_labels: 仅获取带有给定标签的人员的相关日程 * group_by * people * in_todo_list 仅在指定people或group_by people的时候有效 * enrolled 仅在指定people或group_by people的时候有效 * completed 仅在指定people或group_by people的时候有效 * time array or boolean 时间段的范围 * false * array( * from=>timestamp/date string/datetime string * to=>timestamp/date string/datetime string * input_format=>timestamp, date(default) * date_form=>mysql date form string, or false (default: '%Y-%m-%d') * ) * in_project_of_people bool * show_creater * show_project * id_in_set * @return array */ function getList(array $args = array()) { $this->db->select('schedule.*'); if (isset($args['project']) && $args['project']) { $this->db->where('schedule.project', $args['project']); } if (isset($args['project_type']) && $args['project_type']) { $this->db->where("schedule.project IN (SELECT id FROM project WHERE type ={$this->db->escape($args['project_type'])} AND company = {$this->company->id} )"); } if (isset($args['project_labels']) && $args['project_labels']) { foreach ($args['project_labels'] as $id => $label_name) { $this->db->join("project_label t_{$id}", "schedule.project = t_{$id}.project AND t_{$id}.label_name = {$this->db->escape($label_name)}", 'inner'); } } //判断需要内联schedule_people表的参数 if (isset($args['people']) || isset($args['people_labels']) || isset($args['group_by']) && $args['group_by'] === 'people') { $this->db->join('schedule_people', 'schedule_people.schedule = schedule.id', 'inner'); } //依赖schedule_people表 //TODO 判断多个人同时属于一个日程,并区分对待人员状态(如统计一个律师对一个客户的时间) if (isset($args['people']) && $args['people']) { $this->db->where('schedule_people.people' . $this->db->escape_int_array($args['people']), NULL, FALSE); } //依赖schedule_people表 if (isset($args['people_type']) && $args['people_type']) { $this->db->where("schedule.id IN (\n\t\t\t\tSELECT schedule FROM schedule_people WHERE people IN (\n\t\t\t\t\tSELECT id FROM people WHERE type = {$this->db->escape($args['people_type'])}\n\t\t\t\t)\n\t\t\t)"); } //依赖schedule_people表 if (isset($args['people_labels']) && $args['people_labels']) { foreach ($args['people_labels'] as $id => $label_name) { $this->db->join("people_label t_{$id}", "schedule_people.people = t_{$id}.people AND t_{$id}.label_name = {$label_name}", 'inner'); } } if (isset($args['group_by'])) { //依赖schedule_people表 //TODO 判断多个人同时属于一个日程,并区分对待人员状态(如统计一个律师对一个客户的时间) if ($args['group_by'] === 'people') { if (isset($args['people_is_staff']) && $args['people_is_staff']) { $this->db->where('schedule_people.people IN (SELECT id FROM staff)', NULL, false); } $this->db->group_by('schedule_people.people')->join('people', 'people.id = schedule_people.people', 'inner')->select('people.id people, people.name people_name'); } } if ((isset($args['people']) || isset($args['group_by']) && $args['group_by'] === 'people') && isset($args['in_todo_list'])) { //依赖人员参数 $this->db->where('schedule_people.in_todo_list', $args['in_todo_list']); } if ((isset($args['people']) || isset($args['group_by']) && $args['group_by'] === 'people') && isset($args['enrolled'])) { //依赖人员参数 $this->db->where('schedule_people.enrolled', $args['enrolled']); } if (isset($args['people']) || isset($args['group_by']) && $args['group_by'] === 'people') { //依赖人员参数 !isset($args['deleted']) && ($args['deleted'] = false); $this->db->where('schedule_people.deleted', $args['deleted']); } if (isset($args['completed'])) { $this->db->where('schedule.completed', $args['completed']); } if (!isset($args['time'])) { $args['time'] = array_prefix($args, 'time'); } if ($args['time']) { if ($args['time'] === false) { $this->db->where(array('schedule.start' => NULL, 'schedule.end' => NULL)); } if (isset($args['time']['from']) && $args['time']['from']) { if (isset($args['time']['input_format']) && $args['time']['input_format'] !== 'timestamp') { $args['time']['from'] = strtotime($args['time']['from']); } $this->db->where('schedule.start >=', $args['time']['from']); } if (isset($args['time']['to']) && $args['time']['to']) { if (isset($args['time']['input_format']) && $args['time']['input_format'] !== 'timestamp') { $args['time']['to'] = strtotime($args['time']['to']); } if (isset($args['time']['input_format']) && $args['time']['input_format'] === 'date') { $args['time']['to'] += 86400; } $this->db->where('schedule.end <', $args['time']['to']); } if (!isset($args['date_form'])) { $args['date_form'] = '%Y-%m-%d'; } if ($args['date_form'] !== false) { $this->db->select(array("FROM_UNIXTIME(schedule.start, '{$args['date_form']}') `start`", "FROM_UNIXTIME(schedule.end, '{$args['date_form']}') `end`", "FROM_UNIXTIME(schedule.deadline, '{$args['date_form']}') `deadline`"), false); } unset($args['time']); } if (isset($args['in_project_of_people']) && $args['in_project_of_people']) { $this->db->where("\n\t\t\t\tschedule.project IN (\n\t\t\t\t\tSELECT project FROM project_people WHERE people{$this->db->escape_int_array($args['in_project_of_people'])}\n\t\t\t\t)", NULL, FALSE); } if (isset($args['show_project']) && $args['show_project']) { $this->db->join('project', 'project.id = schedule.project', 'left')->select('project.name project_name'); } if (isset($args['show_creater']) && $args['show_creater']) { $this->db->join('people creater', 'creater.id = schedule.uid', 'inner')->select('creater.id creater, creater.name creater_name'); } if (isset($args['id_in_set'])) { $args['id_in'] = $args['id_in_set']; if ($args['id_in_set']) { $this->db->order_by("FIELD(schedule.id, " . implode(', ', $args['id_in_set']) . ")", '', false); $args['order_by'] = false; } } if (isset($args['sum']) && $args['sum']) { array_remove_value($this->db->ar_select, 'schedule.*'); array_remove_value($this->db->ar_select, '`deadline`', true); array_remove_value($this->db->ar_select, '`start`', true); array_remove_value($this->db->ar_select, '`end`', true); $this->db->select('SUM(IF(hours_checked IS NULL, hours_own, hours_checked)) sum', false); } $schedules = parent::getList($args); !isset($args['sum']) && array_walk($schedules, function (&$schedule, $index) { if ($schedule['completed']) { $schedule['color'] = '#36C'; } else { if ($schedule['start'] < $this->date->now) { $schedule['color'] = '#555'; } else { $schedule['color'] = '#E35B00'; } } $schedule['all_day'] = (bool) $schedule['all_day']; $schedule['completed'] = (bool) $schedule['completed']; }, $this); return $schedules; }
public function run($request_method = REQUEST_METHOD) { global $controller; if (empty($this->route) || !array_key_exists('controller', $this->route) || !array_key_exists('action', $this->route)) { error(); } // Module $controller = $this->route['controller']; $module = array_value($this->module_for_controller, $controller, array_value($this->route, 'module', 'main')); // Layout $format = array_value($this->route, 'format', 'html'); $layout_path = MODULES_PATH . array_value($this->route, 'layout', "{$module}/{$controller}/{$controller}") . ".{$format}.php"; if (!file_exists($layout_path)) { $layout_path = MODULES_PATH . array_value($this->layouts, $controller, "{$module}/{$module}") . ".{$format}.php"; if (!file_exists($layout_path)) { $layout_path = MODULES_PATH . "main/application/application.{$format}.php"; if (!file_exists($layout_path)) { $layout_path = ''; } } } // Controller $helpers_path = MODULES_PATH . "{$module}/{$module}_helpers.php"; if (file_exists($helpers_path)) { include_once $helpers_path; } $controller_path = MODULES_PATH . "{$module}/{$module}_controller.php"; if (file_exists($controller_path)) { include_once $controller_path; } if ($controller != 'application') { $helpers_path = MODULES_PATH . "{$module}/{$controller}/{$controller}_helpers.php"; if (file_exists($helpers_path)) { include_once $helpers_path; } $controller_path = MODULES_PATH . "{$module}/{$controller}/{$controller}_controller.php"; if (file_exists($controller_path)) { include_once $controller_path; } else { error(); } } $controller = camelize($controller) . 'Controller'; $controller = new $controller(); $controller->params = $this->route; $controller->module = $module; $controller->controller = $this->route['controller']; $controller->render_format = $format; $controller->request_method = $request_method; // Action $action = $this->route['action']; $controller->i18n_init(); // Translations global $i18n_all; $i18n_all = []; $translations = $controller->required_locales($action); if (!in_array('default', $translations)) { $translations[] = 'default'; } $translation_found = false; foreach ($translations as $locale) { $i18n_all[$locale] = []; $i18n =& $i18n_all[$locale]; $translations_path = "i18n/application.{$locale}.i18n.php"; if (file_exists($translations_path)) { $translation_found = true; include_once $translations_path; } $translations_path = "i18n/{$module}/{$module}.{$locale}.i18n.php"; if (file_exists($translations_path)) { $translation_found = true; include_once $translations_path; } $translations_path = "i18n/{$module}/{$controller->controller}/{$controller->controller}.{$locale}.i18n.php"; if (file_exists($translations_path)) { $translation_found = true; include_once $translations_path; } if (!$translation_found) { array_remove_value($translations, $locale); } } $controller->set_locale(array_value($translations, 0, 'default')); $controller->init_all(); $controller->render_layout_with_action($layout_path, $action); return $controller; }
/** * Метод просматривает дерево и возвращает группы, зависящие от указанного дочернего элемента. * * Если после удаления этого дочернего элемента группа больше не зависит ни от одного элемента * этого типа, то данная группа будет исключена из ветки зависимости для этого типа. * * $cleanAffectedGroups - данный флаг позволяет сказать, что группа должна быть сразу очищена * при обнаружении, что она зависит от переданной дочерней сущности. Это нужно для того, чтобы * отметить всю группу - провалидированной в случае, если дочерняя сущность была изменена. */ private function scanTreeAndGetAffectedGroups($type, $child, &$TREE, $cleanAffectedGroups = false) { $affectedGroups = array(); if (array_key_exists($type, $TREE)) { foreach ($TREE[$type] as $group => &$childEntitys) { if (in_array($child, $childEntitys)) { $affectedGroups[] = $group; if ($cleanAffectedGroups) { unset($TREE[$type][$group]); } else { array_remove_value($childEntitys, $child); if (empty($childEntitys)) { unset($TREE[$type][$group]); } } if (empty($TREE[$type])) { unset($TREE[$type]); } } } } return array_unique($affectedGroups); }
head404(); } if (is_array($row)) { JieBan::updateVisit($row['id']); $memberinfo = Helper_Archive::getMemberInfo($row['memberid']); $row['title'] = JieBan::getJiebanTitle($row); $row['kindnamelist'] = JieBan::getKindnameList($row, '-'); $row['membername'] = $memberinfo['nickname']; $row['memberlitpic'] = $memberinfo['litpic'] ? $memberinfo['litpic'] : $GLOBALS['cfg_templets_skin'] . '/images/member_default.gif'; $row['url'] = $GLOBALS['cfg_cmsurl'] . '/jieban/show_' . $row['id'] . '.html'; $row['attrlist'] = JieBan::getAttrList($row['attrid']); $row['joinnum'] = JieBan::getJoinNumber($row['id']); $row['memo'] = $row['memo'] == 'null' ? '' : $row['memo']; $row['vartime'] = empty($row['vartime']) ? 0 : $row['vartime']; $row['pkname'] = get_par_value($row['kindlist'], $typeid); $row['destid'] = array_remove_value($row['kindlist']); $row['pinyin'] = Helper_Archive::getDestPinyin($row['destid']); $row['kindid'] = $row['destid']; if (!empty($row['lineid'])) { $row['lineinfo'] = JieBan::getLineInfo($row['lineid']); $GLOBALS['condition']['_hasline'] = 1; } //短信状态判断 $msgInfo = Helper_Archive::getDefineMsgInfo2('reg_msgcode'); if ($msgInfo['isopen'] == 1) { $GLOBALS['condition']['_msgcode'] = 1; $row['msgtype'] = 'msg'; } else { $GLOBALS['condition']['_txtcode'] = 1; $row['msgtype'] = 'txt'; }
/** @return FoldedResources */ private function IDENTS() { if ($this->IDENTS_LOADED) { return $this; } $this->IDENTS_LOADED = true; $this->profilerStart(__FUNCTION__); /* * 1. Загружаем список существующих сущностей фолдинга */ $full = $this->getResourcesDm()->getSubDirNames(); $this->ALL_IDENTS['full'] = $full; //С шаблоном $short = $full; array_remove_value($short, self::PATTERN_NAME); $short = array_values($short); $this->ALL_IDENTS['short'] = $short; //Без шаблона (+ нужно реиндексировать массив) /* * 2. Загружаем список видимых сущностей фолдинга */ if ($this->isWorkWithTable()) { $this->VISIBLE_IDENTS = array_values(array_intersect($short, FoldingBean::inst()->getIdents($this, false))); } else { $this->VISIBLE_IDENTS = $short; } /* * 3. Строим список сущностей фолдинга, к которым пользователь имеет доступ */ if (AuthManager::isAuthorizedAsAdmin()) { //Админ имеет доступ и к шаблону $this->ACCESS_IDENTS['full'] = $full; $this->ACCESS_IDENTS['short'] = $short; } else { $this->ACCESS_IDENTS['full'] = $this->VISIBLE_IDENTS; $this->ACCESS_IDENTS['short'] = $this->VISIBLE_IDENTS; } /* * 5. Отлогируем то, что получилось */ if ($this->LOGGER->isEnabled()) { $this->LOGGER->info(); $this->LOGGER->info('Загружаем список доступных сущностей'); $this->LOGGER->info('Все сущности ({}): {}', count($full), array_to_string($full)); $hidden = array_diff($full, $this->VISIBLE_IDENTS); if (empty($hidden)) { $this->LOGGER->info('Скрытых сущностей нет'); } else { $this->LOGGER->info('Cкрытые сущности ({}): {}', count($hidden), array_to_string($hidden)); } $this->LOGGER->info('Доступные пользователю сущности ({}): {}', count($this->ACCESS_IDENTS['full']), array_to_string($this->ACCESS_IDENTS['full'])); $this->LOGGER->info(); $this->profilerStop(); } return $this; }
public function __sleep() { $ret = array_keys(get_object_vars($this)); array_remove_value($ret, '_db'); array_remove_value($ret, '_di'); return $ret; }
function initElements() { /* @var $bootstrap Bootstrap */ $modules = $this->addMagicSelect('modules', null, array('help-id' => '#Enabling.2FDisabling_Modules'))->setLabel(___('Enabled Modules')); $this->setDefault('modules', array()); foreach (Am_Di::getInstance()->modules->getAvailable() as $module) { $fn = APPLICATION_PATH . '/' . $module . '/module.xml'; if (!file_exists($fn)) { continue; } $xml = simplexml_load_file($fn); if (!$xml) { continue; } $modules->addOption($module . ' - ' . $xml->desc, $module); } foreach (Am_Di::getInstance()->plugins as $type => $mgr) { if ($type == 'modules') { continue; } /* @var $mgr Am_Plugins */ switch ($type) { case 'payment': $help_id = '#Enabling.2FDisabling_Payment_Plugins'; break; case 'protect': $help_id = '#Enabling.2FDisabling_Integration_Plugins'; break; case 'misc': $help_id = '#Enabling.2FDisabling_Other_Plugins'; break; default: $help_id = ''; break; } $el = $this->addMagicSelect('plugins.' . $type, array('class' => 'magicselect am-combobox'), array('help-id' => $help_id))->setLabel(___('%s Plugins', ___($mgr->getTitle()))); $paths = $mgr->getPaths(); $plugins = self::getPluginsList($paths); if ($type == 'payment') { if (!Am_Di::getInstance()->modules->isEnabled('cc')) { $this->plugins_cc = self::getPluginsList(array(APPLICATION_PATH . '/cc/plugins')); $plugins = array_merge($plugins, $this->plugins_cc); ksort($plugins); } array_remove_value($plugins, 'free'); } elseif ($type == 'storage') { $plugins = array('upload' => 'upload', 'disk' => 'disk') + $plugins; } $el->loadOptions($plugins); } $this->setDefault('plugins.payment', array()); $this->setDefault('plugins.protect', array()); $this->setDefault('plugins.misc', array()); $this->setDefault('plugins.storage', array('upload', 'disk')); }
/** * @param $arr * @param string $delval * @return array */ function array_remove_value($arr, $delval = '') { if (empty($arr)) { return null; } foreach ($arr as $key => $value) { if (is_array($value)) { $arr[$key] = array_remove_value($value); } else { if ($delval === $value) { unset($arr[$key]); } else { $arr[$key] = $value; } } } return $arr; }
/** * Changes the file-extension priority (order on spl-file-extension stack) * * This method is intend to change the file-extension priority (order on spl-file-extension stack). * * @param string $fileExtension The file-extension to change priority for * @param int $priority The new priority of the file-extension * * @author Benjamin Carl <*****@*****.**> * @return bool TRUE on success, otherwise FALSE * @access public * @static */ public static function changeFileExtensionPriority($fileExtension = '.php', $priority = 0) { // get current active extension order $extensionPriority = explode(',', spl_autoload_extensions()); // count of current file-extensions $extensionCount = count($extensionPriority); // set prio to max possible $priority > $extensionCount - 1 ? $priority = $extensionCount - 1 : ''; // check if reposition needed if (!(isset($extensionPriority[$priority]) && $extensionPriority[$priority] == $fileExtension)) { // remove element by value $extensionPriority = array_remove_value($extensionPriority, $fileExtension); // and insert array_splice($extensionPriority, $priority, 0, $fileExtension); // and set to spl's list of autoload extensions spl_autoload_extensions(implode(',', $extensionPriority)); } else { // nothing to do return false; } // success return true; }