Ejemplo n.º 1
0
 /**
  * 推荐位删除计算
  * Enter description here ...
  * @param int $catid 栏目ID
  * @param int $id 文章id
  * @param array $input_posid 传入推荐位数组
  */
 private function position_del($catid, $id, $input_posid)
 {
     $array = array();
     $pos_data = M("Position_data");
     //查找已存在推荐位
     $olPosid = $pos_data->where(array('id' => $id, 'catid' => $catid))->getField('posid', true);
     if (empty($olPosid)) {
         return false;
     }
     //差集计算,需要删除的推荐
     $real_posid = array_diff($olPosid, $input_posid);
     if (empty($real_posid)) {
         return false;
     }
     $where = array();
     $where['catid'] = array("EQ", $catid);
     $where['modelid'] = getCategory($catid, 'modelid');
     $where['id'] = array("EQ", $id);
     $where['posid'] = array("IN", $real_posid);
     $status = $pos_data->where($where)->delete();
     if (false !== $status) {
         service("Attachment")->api_delete('position-' . $where['modelid'] . '-' . $where['id']);
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
 public function index()
 {
     $this->assign('LatestArticles', getLatest());
     $this->assign('categories', getCategory());
     $this->assign('allTags', getAllTags());
     $this->type = $this->_get('type');
     $this->typevalue = $this->_get('typevalue');
     $page = isset($_GET['page']) ? $_GET['page'] : 1;
     switch ($this->_get('type')) {
         case 'username':
             $this->UserName($this->_get('typevalue'), $page);
             break;
         case 'userid':
             $this->UserId($this->_get('typevalue'), $page);
             break;
         case 'tag':
             $this->Tag($this->_get('typevalue'), $page);
             break;
         case 'category':
             $this->Category($this->_get('typevalue'), $page);
             break;
         case 'search':
             $this->Search($this->_get('keywords'), $page);
             break;
         default:
             $this->error('出错了');
     }
     //模板输出
     $this->display('articlelist');
 }
Ejemplo n.º 3
0
 public function category()
 {
     $mid = Q('mid', 0, 'intval');
     $cid = Q('cid', 0, 'intval');
     $cache = cache('category');
     if (!$mid || !$cid || !isset($cache[$cid])) {
         _404();
     }
     $cachetime = C('CACHE_CATEGORY') >= 1 ? C('CACHE_CATEGORY') : null;
     if (!$this->isCache()) {
         $category = $cache[$cid];
         //外部链接,直接跳转
         if ($category['cattype'] == 3) {
             go($category['cat_redirecturl']);
         } else {
             $Model = ContentViewModel::getInstance($category['mid']);
             $catid = getCategory($category['cid']);
             $category['content_num'] = $Model->join()->where("cid IN(" . implode(',', $catid) . ")")->count();
             $category['comment_num'] = intval(M('comment')->where("cid IN(" . implode(',', $catid) . ")")->count());
             $this->assign("hdcms", $category);
             $this->display($category['template'], $cachetime);
         }
     } else {
         $this->display(null, $cachetime);
     }
 }
Ejemplo n.º 4
0
/**
 * 推荐字段类型表单组合处理
 * @param type $field 字段名
 * @param type $value 字段内容
 * @param type $fieldinfo 字段配置
 * @return string
 */
function posid($field, $value, $fieldinfo)
{
    //扩展配置
    $setting = unserialize($fieldinfo['setting']);
    //推荐位缓存
    $position = F("Position");
    if (empty($position)) {
        return '';
    }
    $array = array();
    foreach ($position as $_key => $_value) {
        if ($_value['modelid'] && $_value['modelid'] != $this->modelid || $_value['catid'] && strpos(',' . getCategory($_value['catid'], 'arrchildid') . ',', ',' . $this->catid . ',') === false) {
            continue;
        }
        $array[$_key] = $_value['name'];
    }
    $posids = array();
    if (ACTION_NAME == 'edit') {
        $this->position_data_db = M('Position_data');
        $result = $this->position_data_db->where(array('id' => $this->id, 'modelid' => $this->modelid))->getField("posid,id,catid,posid,module,modelid,thumb,data,listorder,expiration,extention,synedit");
        $posids = implode(',', array_keys($result));
    } else {
        $posids = $setting['defaultvalue'];
    }
    return "<input type='hidden' name='info[{$field}][]' value='-1'>" . Form::checkbox($array, $posids, "name='info[{$field}][]'", '', $setting['width']);
}
Ejemplo n.º 5
0
function getBacklink($id, $type, $category = true)
{
    $db =& JFactory::getDBO();
    if (!$category) {
        $query = "SELECT articleid from #__fieldsattach_values WHERE (value LIKE '%," . $id . ",%' OR value LIKE '" . $id . ",%' OR value LIKE '%," . $id . "' OR value LIKE '" . $id . "') AND fieldsid = 23";
    } else {
        $query = "SELECT catid from #__fieldsattach_categories_values WHERE (value LIKE '%," . $id . ",%' OR value LIKE '" . $id . ",%' OR value LIKE '%," . $id . "' OR value LIKE '" . $id . "') AND fieldsid = 22";
    }
    $db->setQuery($query);
    $result = $db->loadObjectList();
    $function = '';
    foreach ($result as $item) {
        if (!$category) {
            $parent = getParent(getCategory($item->articleid));
        } else {
            $parent = getParent($item->catid);
        }
        if ($parent == $type) {
            if (!$category) {
                $function .= '<li><a href="' . ContentHelperRoute::getArticleRoute($item->articleid, $parent) . '">' . getTitle($item->articleid, $category) . '</a></li>';
            } else {
                $function .= '<li><a href="' . ContentHelperRoute::getCategoryRoute($item->catid, $parent) . '">' . getTitle($item->catid, $category) . '</a></li>';
            }
        }
    }
    return $function;
}
Ejemplo n.º 6
0
Archivo: Stock.php Proyecto: frycnx/jxc
 public function detail()
 {
     if (isAjaxTable()) {
         return $this->_detail();
     }
     $this->view()->assign('my_shop', getMyShop())->assign('category', getCategory())->display();
 }
Ejemplo n.º 7
0
 /**
  * 信息管理 
  */
 public function public_item()
 {
     if (IS_POST) {
         $items = count($_POST['items']) > 0 ? $_POST['items'] : $this->error("没有信息被选择!");
         $db = D("Position_data");
         if (is_array($items)) {
             foreach ($items as $item) {
                 $_v = explode('-', $item);
                 $db->delete_item((int) $_POST['posid'], (int) $_v[0], (int) $_v[1]);
             }
         }
         $this->success("移除成功!");
     } else {
         $posid = $this->_get("posid");
         $db = M("Position_data");
         $Category = F("Category");
         $where = array();
         $where['posid'] = array("EQ", $posid);
         $count = $db->where($where)->count();
         $page = $this->page($count, 20);
         $data = $db->where($where)->order(array("listorder" => "DESC", "id" => "DESC"))->limit($page->firstRow . ',' . $page->listRows)->select();
         foreach ($data as $k => $v) {
             $data[$k]['data'] = unserialize($v['data']);
             $tab = ucwords(getModel(getCategory($v['catid'], 'modelid'), 'tablename'));
             $data[$k]['data']['url'] = M($tab)->where(array("id" => $v['id']))->getField("url");
         }
         $this->assign("Category", $Category);
         $this->assign("Page", $page->show('Admin'));
         $this->assign("data", $data);
         $this->assign("posid", $posid);
         $this->display();
     }
 }
Ejemplo n.º 8
0
/**
 * Validates imported data.
 */
function validate_data($courses)
{
    $errors = array();
    $coursecodes = array();
    foreach ($courses as $index => $course) {
        $course['line'] = $index + 1;
        // 1. Check whether mandatory fields are set.
        $mandatory_fields = array('Code', 'Title', 'CourseCategory');
        foreach ($mandatory_fields as $field) {
            if (!isset($course[$field]) || strlen($course[$field]) == 0) {
                $course['error'] = get_lang($field . 'Mandatory');
                $errors[] = $course;
            }
        }
        // 2. Check current course code.
        if (isset($course['Code']) && strlen($course['Code']) != 0) {
            // 2.1 Check whether code has been already used by this CVS-file.
            if (isset($coursecodes[$course['Code']])) {
                $course['error'] = get_lang('CodeTwiceInFile');
                $errors[] = $course;
            } else {
                // 2.2 Check whether course code has been occupied.
                $courseInfo = api_get_course_info($course['Code']);
                if (!empty($courseInfo)) {
                    $course['error'] = get_lang('CodeExists');
                    $errors[] = $course;
                }
            }
            $coursecodes[$course['Code']] = 1;
        }
        // 3. Check whether teacher exists.
        $teacherList = getTeacherListInArray($course['Teacher']);
        if (!empty($teacherList)) {
            foreach ($teacherList as $teacher) {
                $teacherInfo = api_get_user_info_from_username($teacher);
                if (empty($teacherInfo)) {
                    $course['error'] = get_lang('UnknownTeacher') . ' (' . $teacher . ')';
                    $errors[] = $course;
                } else {
                    /*if ($teacherInfo['status'] != COURSEMANAGER) {
                          $course['error'] = get_lang('UserIsNotATeacher').' ('.$teacher.')';
                          $errors[] = $course;
                      }*/
                }
            }
        }
        // 4. Check whether course category exists.
        if (isset($course['CourseCategory']) && strlen($course['CourseCategory']) != 0) {
            require_once api_get_path(LIBRARY_PATH) . 'course_category.lib.php';
            $categoryInfo = getCategory($course['CourseCategory']);
            if (empty($categoryInfo)) {
                //@todo this is so bad even all lang variables are wrong ...
                $course['error'] = get_lang('UnkownCategoryCourseCode') . ' (' . $course['CourseCategory'] . ')';
                $errors[] = $course;
            }
        }
    }
    return $errors;
}
Ejemplo n.º 9
0
 public function index()
 {
     $data = isset($_GET['page']) ? $_GET['page'] : 1;
     $this->show($data);
     $this->assign('LatestArticles', getLatest());
     $this->assign('categories', getCategory());
     $this->assign('allTags', getAllTags());
     $this->display();
 }
Ejemplo n.º 10
0
 public function add()
 {
     $sn = get('sn');
     if (empty($sn)) {
         $row = array('sn' => m('StockIncome')->getSn(), 'shop_id' => session('shop_id'), 'user_name' => session('user_name'), 'status' => '0');
     } else {
         $row = m('StockIncome')->getRowBySn($sn);
     }
     $this->view()->assign('row', $row)->assign('my_shop', getMyShop())->assign('category', getCategory())->display();
 }
Ejemplo n.º 11
0
 public function index()
 {
     $where = array();
     $catid = I('get.catid', 0, 'intval');
     $rssid = I('get.rssid', 0, 'intval');
     if ($rssid) {
         header("Content-Type: text/xml; charset=" . C("DEFAULT_CHARSET"));
         //检测缓存
         $data = S("Rss_{$rssid}");
         if ($data) {
             echo $data;
             exit;
         }
         $Cat = getCategory($rssid);
         //检查栏目是否存在
         if (empty($Cat)) {
             $this->error('该栏目不存在!');
         }
         //检查栏目类型
         if ($Cat['type'] != 0) {
             $this->error('栏目类型不正确!');
         }
         $where['status'] = array("EQ", 99);
         //判断是否有子栏目
         if (getCategory($rssid, 'child')) {
             $where['catid'] = array("IN", getCategory($rssid, 'arrchildid'));
         } else {
             $where['catid'] = array("EQ", $rssid);
         }
         //模型ID
         $modelid = getCategory($rssid, 'modelid');
         //获取表名
         $tablename = ucwords(getModel($modelid, 'tablename'));
         if (empty($tablename)) {
             $this->error('出现错误!');
         }
         //栏目配置
         $setting = getCategory($rssid, 'setting');
         $data = M($tablename)->where($where)->order(array("updatetime" => "DESC", "id" => "DESC"))->limit(50)->select();
         import('@.ORG.Rss');
         $Rss = new Rss($this->XMLstr(getCategory($rssid, 'catname') . ' - ' . CONFIG_SITENAME), $this->XMLstr(getCategory($rssid, 'url')), $this->XMLstr(getCategory($rssid, 'description')), $this->XMLstr(getCategory($rssid, 'image')));
         foreach ($data as $k => $v) {
             $v = $this->XMLstr($v);
             $Rss->AddItem($v['title'], $v['url'], $v['description'], date("Y-m-d H:i:s A", $v['updatetime']));
         }
         //进行缓存
         S("Rss_{$rssid}", $Rss->Fetch(), 900);
         $Rss->Display();
     }
     $this->assign('catid', $catid);
     $this->assign('rssid', $rssid);
     $this->assign("SEO", seo(0, 'Rss订阅中心'));
     $this->display();
 }
Ejemplo n.º 12
0
 /**
  * 推荐位数据获取
  * 参数名	 是否必须	 默认值	 说明
  * posid	 是	 null	 推荐位ID
  * catid	 否	 null	 调用栏目ID
  * thumb	 否	 0	 是否仅必须缩略图
  * order	 否	 null	 排序类型
  * num	 是	 null	 数据调用数量
  * @param type $data 
  */
 public function position($data)
 {
     //缓存时间
     $cache = (int) $data['cache'];
     $cacheID = to_guid_string($data);
     if ($cache && ($return = S($cacheID))) {
         return $return;
     }
     $posid = (int) $data['posid'];
     if ($posid < 1) {
         return false;
     }
     $catid = (int) $data['catid'];
     $thumb = isset($data['thumb']) ? $data['thumb'] : 0;
     $order = empty($data['order']) ? array("listorder" => "DESC", "id" => "DESC") : $data['order'];
     $num = (int) $data['num'];
     $db = M("PositionData");
     $Position = F("Position");
     if ($num == 0) {
         $num = $Position[$posid]['maxnum'];
     }
     $where = array();
     //设置SQL where 部分
     if (isset($data['where']) && $data['where']) {
         $where['_string'] = $data['where'];
     }
     $where['posid'] = array("EQ", $posid);
     if ($thumb) {
         $where['thumb'] = array("EQ", 1);
     }
     if ($catid > 0) {
         $cat = getCategory($catid);
         if ($cat) {
             //是否包含子栏目
             if ($cat['child']) {
                 $where['catid'] = array("IN", $cat['arrchildid']);
             } else {
                 $where['catid'] = array("EQ", $catid);
             }
         }
     }
     $data = $db->where($where)->order($order)->limit($num)->select();
     foreach ($data as $k => $v) {
         $data[$k]['data'] = unserialize($v['data']);
         $tab = ucwords(getModel($v['modelid'], 'tablename'));
         $data[$k]['data']['url'] = M($tab)->where(array("id" => $v['id']))->getField("url");
     }
     //结果进行缓存
     if ($cache) {
         S($cacheID, $data, $cache);
     }
     return $data;
 }
Ejemplo n.º 13
0
 public function add()
 {
     if (isPost()) {
         return $this->_add();
     }
     $sn = get('sn');
     if ($sn) {
         $row = m('GoodsBind')->getRowBySn($sn);
     } else {
         $row = array('sn' => m('GoodsBind')->getSn(), 'shop_id' => session('shop_id'), 'user_name' => session('user_name'), 'status' => '0');
     }
     $this->view()->assign('row', $row)->assign('my_shop', getMyShop())->assign('category', getCategory())->display();
 }
Ejemplo n.º 14
0
function bmiLogicHere($split)
{
    if (sizeof($split) < 2) {
        $responseMsg = "Invalid message content";
    } else {
        $weight = (double) $split[0];
        $height = (double) $split[1];
        $bmi = getBMIValue($weight, $height / 100);
        $category = getCategory($bmi);
        $responseMsg = "Your BMI :" . round($bmi, 2) . ", Category :" . $category;
    }
    return $responseMsg;
}
Ejemplo n.º 15
0
/**
 * 栏目字段
 * @param type $field 字段名
 * @param type $value 字段值
 * @param type $fieldinfo 该字段的配置信息
 * @return type
 */
function catid($field, $value, $fieldinfo)
{
    if (empty($value)) {
        //当值为空时,获取当前添加的栏目ID
        $value = $this->catid;
    }
    //html
    $publish_str = '';
    if (ACTION_NAME == 'add' && defined("IN_ADMIN") && IN_ADMIN) {
        $publish_str = "<a href='javascript:;' onclick=\"omnipotent('selectid','" . U("Contents/Content/public_othors", array("catid" => $this->catid)) . "','同时发布到其他栏目',1);return false;\" style='color:#B5BFBB'>[同时发布到其他栏目]</a>\n            <ul class='three_list cc' id='add_othors_text'></ul>";
    }
    $publish_str = '<input type="hidden" name="info[' . $field . ']" value="' . $value . '"/>' . getCategory($value, 'catname') . $publish_str;
    return $publish_str;
}
Ejemplo n.º 16
0
function processMatches($ds, $type)
{
    foreach ($ds as $d) {
        if (!is_null($d['label']) && !is_null($d['icon'])) {
            $q = "INSERT INTO matches (uri, poslabel, label, icon, type, category) VALUES ('" . mysql_real_escape_string($d['pos']) . "', '" . mysql_real_escape_string($d['poslabel']) . "', '" . mysql_real_escape_string($d['label']) . "', '" . mysql_real_escape_string($d['icon']) . "', '" . mysql_real_escape_string($type) . "', '" . mysql_real_escape_string(getCategory($d['icon'])) . "')";
        } elseif (!is_null($d['label'])) {
            $q = "INSERT INTO matches (uri, poslabel, label, type) VALUES ('" . mysql_real_escape_string($d['pos']) . "', '" . mysql_real_escape_string($d['poslabel']) . "', '" . mysql_real_escape_string($d['label']) . "', '" . mysql_real_escape_string($type) . "')";
        } elseif (!is_null($d['icon'])) {
            $q = "INSERT INTO matches (uri, poslabel, icon, type, category) VALUES ('" . mysql_real_escape_string($d['pos']) . "', '" . mysql_real_escape_string($d['poslabel']) . "', '" . mysql_real_escape_string($d['icon']) . "', '" . mysql_real_escape_string($type) . "', '" . mysql_real_escape_string(getCategory($d['icon'])) . "')";
        } else {
            $q = "INSERT INTO matches (uri, poslabel, type) VALUES ('" . mysql_real_escape_string($d['pos']) . "', '" . mysql_real_escape_string($d['poslabel']) . "', '" . mysql_real_escape_string($type) . "')";
        }
        runQuery($q);
    }
}
Ejemplo n.º 17
0
function getCategory($parentId = null)
{
    global $dbIn;
    if ($parentId == null) {
        $result = $dbIn->query("SELECT * FROM Categorieen WHERE Parent = -1 ORDER BY ID ASC");
    } else {
        $result = $dbIn->buildQuery("SELECT * FROM Categorieen WHERE Parent=%d", $parentId);
    }
    $categories = array();
    while ($row = $dbIn->fetchAssoc($result)) {
        $row['sub'] = getCategory($row['ID']);
        $categories[] = $row;
    }
    return $categories;
}
Ejemplo n.º 18
0
function getCategory($id)
{
    global $db;
    //    echo "SELECT * FROM catalog_categories WHERE `id`='$id'";
    $query_select = $db->query("SELECT * FROM catalog_categories WHERE `id`='{$id}'");
    $res = $db->fetch_assoc($query_select);
    $result[$res['id']] = $res;
    if ($res["parent"] == 0) {
        $result[$res['id']] = $res;
    } else {
        $result = getCategory($res["parent"]);
    }
    //    print_r($result);
    return $result;
}
Ejemplo n.º 19
0
 function category()
 {
     if (empty($_GET['cid'])) {
         return "Access Deny";
     }
     //Error::dbd();
     $this->common();
     $tplname = strtolower($this->app) . '_list.html';
     $cate_id = (int) $_GET['cid'];
     $cate = getCategory($cate_id);
     if (empty($cate)) {
         Swoole_js::js_back('不存在的分类!', '/index.php');
         exit;
     }
     if (!empty($cate['uptime']) and Swoole\Tool::httpExpire($cate['uptime']) === false) {
         exit;
     }
     if ($cate['fid'] == 0) {
         $this->swoole->tpl->assign("fid", $cate_id);
         $this->swoole->tpl->assign("ccate", $cate);
         if ($cate['tplname']) {
             $tplname = $cate['tplname'];
         }
         $gets['fid'] = $cate_id;
     } else {
         if ($cate['tplname']) {
             $tplname = $cate['tplname'];
         }
         $this->swoole->tpl->assign("cate", $cate);
         $ccate = $this->swoole->db->query("select * from st_catelog where id={$cate['fid']} limit 1")->fetch();
         $this->swoole->tpl->assign("ccate", $ccate);
         $gets['cid'] = $cate_id;
     }
     $pager = null;
     $gets['order'] = 'addtime desc';
     $gets['page'] = empty($_GET['page']) ? 1 : (int) $_GET['page'];
     $gets['pagesize'] = empty($this->_model->pagesize) ? $this->swoole->config['cms']['pagesize'] : $this->_model->pagesize;
     $gets['select'] = "id,title,addtime";
     $list = $this->_model->gets($gets, $pager);
     if ($this->swoole->config['cms']['html_static']) {
         $pager->page_tpl = WEBROOT . "/{$this->app}/list_{$cate_id}_%s.html";
     }
     $pager = array('total' => $pager->total, 'render' => $pager->render());
     $this->swoole->tpl->assign('pager', $pager);
     $this->swoole->tpl->assign("list", $list);
     $this->swoole->tpl->assign('cid', $cate_id);
     $this->swoole->tpl->display($tplname);
 }
Ejemplo n.º 20
0
 function parse()
 {
     $displayName = "Hoofdpagina";
     //Fetch all from SQL.
     $sql = "SELECT TOP 3 id,title,end_moment,start_bid,city FROM objects WHERE end_moment > GETDATE() ORDER BY end_moment ASC";
     $result = $this->db->query($sql);
     $soonEndingObjects = parseObjects($result);
     $sql = "SELECT TOP 3 id,title,end_moment,start_bid,city FROM objects ORDER BY start_moment DESC";
     $result = $this->db->query($sql);
     $newObjects = parseObjects($result);
     $categories = getCategory(array());
     //$this->addToBreadcrumbs("Home");
     $this->website->assign("categories", $categories);
     $this->website->assign("newObjects", $newObjects);
     $this->website->assign("soonEndingObjects", $soonEndingObjects);
     $this->render($displayName, 'index.tpl');
 }
Ejemplo n.º 21
0
function findCategories($search, $path = '', $showHidden = false)
{
    $params = array();
    $sqlSearch = array();
    if ($search) {
        $search = is_array($search) ? $search : array($search);
        for ($i = 0; $i < count($search); ++$i) {
            $sqlSearch[] = "(\r\n\t\t\t\tname LIKE CONCAT('%',:search{$i},'%') OR\r\n\t\t\t\tshort_descr LIKE CONCAT('%',:search{$i},'%') OR\r\n\t\t\t\tdescr LIKE CONCAT('%',:search{$i},'%')\r\n\t\t\t)";
            $params["search{$i}"] = $search[$i];
        }
    }
    $IDs = \cf\query2vector("\r\n\t\tSELECT id\r\n\t\tFROM cf_groups\r\n\t\tWHERE " . implode(' AND ', $sqlSearch) . ($showHidden ? '' : ' AND (hidden IS NULL OR hidden=0)'), $params);
    $categories = array();
    foreach ($IDs as $id) {
        $categories[] = getCategory($id, $path);
    }
    return $categories;
}
Ejemplo n.º 22
0
 function getComboCat()
 {
     $p = '';
     $p .= '<option value="">None</option>';
     $dParent = getCategory();
     if (!empty($dParent)) {
         foreach ($dParent as $rParent) {
             $p .= '<option value="' . $rParent->term_id . '">' . $rParent->name . '</option>';
             $dChild = getCategory($rParent->term_id);
             if (!empty($dChild)) {
                 foreach ($dChild as $rChild) {
                     $p .= '<option value="' . $rChild->term_id . '">&#8212; ' . $rChild->name . '</option>';
                 }
             }
         }
     }
     echo $p;
 }
Ejemplo n.º 23
0
 public function index()
 {
     //栏目ID
     $catid = I('get.catid', 0, 'intval');
     //信息ID
     $id = I('get.id', 0, 'intval');
     //模型ID
     $modelid = (int) getCategory($catid, 'modelid');
     if (empty($modelid)) {
         exit;
     }
     $this->db = \Content\Model\ContentModel::getInstance($modelid);
     $r = $this->db->where(array('id' => $id))->field('catid,id,dayviews,monthviews,views,weekviews,yesterdayviews,viewsupdatetime')->find();
     if (empty($r)) {
         exit;
     }
     $r['modelid'] = $modelid;
     //增加点击率
     $this->hits($r);
     echo json_encode($r);
 }
Ejemplo n.º 24
0
 function parse($id, $p)
 {
     $categoryResult = $this->db->buildQuery("SELECT * FROM categories WHERE id=%i", $id);
     $category = $this->db->fetchAssoc($categoryResult);
     //Fetch number of objects in this category:
     $countResult = $this->db->buildQuery("SELECT COUNT(object_id) AS c FROM object_in_category WHERE category_id=%i", $id);
     $c = $this->db->fetchAssoc($countResult)['c'];
     $sql = "SELECT id,title,end_moment,start_bid,city FROM objects WHERE id IN (SELECT object_id FROM object_in_category WHERE category_id=%i) ORDER BY start_moment DESC";
     $result = null;
     $maxPerPage = 18;
     if ($c > $maxPerPage) {
         if ($p > 0) {
             $fo = $p * $maxPerPage;
         } else {
             $fo = 0;
         }
         $fe = $fo + $maxPerPage;
         $sql .= " OFFSET %i ROWS FETCH NEXT %i ROWS ONLY;";
         $result = $this->db->buildQuery($sql, $id, $fo, $fe);
         $this->website->assign("paginationNeeded", true);
         $this->website->assign("page", $p + 1);
         $this->website->assign("maxPages", $c / $maxPerPage - 1);
     } else {
         $result = $this->db->buildQuery($sql, $id);
     }
     $objects = parseObjects($result);
     $categoriesCrumbs = array();
     getCategoryFromBottom($categoriesCrumbs, $id);
     array_pop($categoriesCrumbs);
     $this->addToBreadcrumbs("Home", baseurl(""));
     foreach ($categoriesCrumbs as $cat) {
         $this->addToBreadcrumbs($cat['name'], baseurl("Rubriek/" . $cat['id']));
     }
     $this->addToBreadcrumbs($category['name']);
     $categories = getCategory($categoriesCrumbs);
     $this->website->assign("category", $category);
     $this->website->assign("categories", $categories);
     $this->website->assign("objects", $objects);
     $this->render("Categorie", 'lot/objects.tpl');
 }
Ejemplo n.º 25
0
 public function category($cid, $page = 1)
 {
     $categoryCache = cache('category');
     $cat = $categoryCache[$cid];
     $GLOBALS['totalPage'] = 0;
     if ($cat['cat_url_type'] == 2 || $cat['cattype'] == 3) {
         return true;
     }
     //单文章
     if ($cat['cattype'] == 4) {
         $Model = ContentViewModel::getInstance($cat['mid']);
         $result = $Model->join()->where("cid={$cat['cid']}")->find();
         if ($result) {
             $Content = new Content($cat['mid']);
             $data = $Content->find($result['aid']);
             return $this->content($data);
         }
     } else {
         //普通栏目与封面栏目
         $htmlDir = C("HTML_PATH") ? C("HTML_PATH") . '/' : '';
         $_REQUEST['page'] = $_GET['page'] = $page;
         $_REQUEST['mid'] = $cat['mid'];
         $_REQUEST['cid'] = $cat['cid'];
         $Model = ContentViewModel::getInstance($cat['mid']);
         $catid = getCategory($cat['cid']);
         $cat['content_num'] = $Model->join()->where("cid IN(" . implode(',', $catid) . ")")->count();
         $cat['comment_num'] = intval(M('comment')->where("cid IN(" . implode(',', $catid) . ")")->count());
         $htmlFile = $htmlDir . str_replace(array('{catdir}', '{cid}', '{page}'), array($cat['catdir'], $cat['cid'], $page), $cat['cat_html_url']);
         $info = explode('.', $htmlFile);
         $this->assign("hdcms", $cat);
         $this->createHtml(basename($info[0]), dirname($htmlFile) . '/', $cat['template']);
         //第1页时复制index.html
         if ($page == 1) {
             copy($htmlFile, dirname($htmlFile) . '/index.html');
         }
         return true;
     }
 }
Ejemplo n.º 26
0
 function index($pid = 0)
 {
     $type = $this->type;
     $map['type'] = $type;
     $title = I('title');
     $search_type = I('search_type');
     if ($title) {
         if ($search_type == 2) {
             $map['id'] = intval($title);
         } else {
             $map['title'] = array('like', '%' . $title . '%');
         }
         $data['title'] = $title;
         $data['search_type'] = $search_type;
     }
     $map['pid'] = $pid;
     $list = $this->page($this->table, $map, "sort desc");
     $data['_list'] = int_to_string($list, $map = array('status' => array(1 => '正常', -1 => '删除', 0 => '禁用'), 'is_fixed' => array(0 => '否', 1 => '是')));
     $data['type'] = $type;
     $this->assign($data);
     $this->assign('meta_title', "分类");
     getCategory($type);
     $this->display();
 }
			<form action="index/addgallery.php?mode=add" method="POST" enctype="multipart/form-data" id="addgallery_form" >
				<div class="div-row">
					<div class="input-div" style="width: 700px;" >
						<div class="lable" ><span class="red" >*</span>Albums</div>
						<select class="textbykk" id="album" name="album" >
							<option value=""  ></option>
							<?php 
                        $pid = $_GET["pid"];
                        $query = mysql_query("SELECT album FROM gallerybykk_" . $sitelang . " WHERE state = 1  ORDER BY album ASC ; ", $db);
                        if (!$query) {
                            die("Error reading query: " . mysql_error());
                        }
                        $category = "";
                        while ($row = mysql_fetch_row($query)) {
                            if ($category != $row[0]) {
                                echo "\n\t\t\t\t\t\t\t\t\t\t<option value='" . $row[0] . "' >" . getCategory($row[0]) . "</option>\n\t\t\t\t\t\t\t\t\t\t";
                                $category = $row[0];
                            }
                        }
                        ?>
							<option value="other" >Other...</option>
						</select>
						<input type="text" class="textbykk" id="album_name" name="album_name" >
					</div>
				</div>
				<div class="div-row" >
					<div class="input-div" >
						<div class="lable" ><span class="red" >*</span>Picture (You can select more than one pictures!)</div>
						<input type="file" class="textbykk" id="picture" name="picture[]" style="width: 400px;" multiple="multiple" >
					</div>
				</div>
Ejemplo n.º 28
0
 /**
  * 生成缓存,以栏目ID为数组下标,以排序字段listorder ASC排序
  */
 public function category_cache()
 {
     $data = $this->order("listorder ASC")->select();
     $categorys = array();
     foreach ($data as $r) {
         //更新缓存
         getCategory($r['catid'], '', true);
         $categorys[$r['catid']] = array('catid' => $r['catid'], 'parentid' => $r['parentid'], 'arrparentid' => $r['arrparentid'], 'child' => $r['child'], 'arrchildid' => $r['arrchildid'], 'type' => $r['type'], 'modelid' => $r['modelid'], 'catname' => $r['catname'], 'url' => $r['url'], 'catdir' => $r['catdir'], 'ismenu' => $r['ismenu'], 'sethtml' => $r['sethtml']);
     }
     F("Category", $categorys);
     return true;
 }
Ejemplo n.º 29
0
 /**
  * 扩展字段处理
  * @param type $catid 栏目ID
  * @param type $post 数据
  * @return boolean
  */
 public function extendField($catid, $post)
 {
     if (empty($catid) || intval($catid) < 1 || empty($post)) {
         return false;
     }
     C('TOKEN_ON', false);
     //时间
     $time = time();
     //栏目信息
     $info = $this->where(array('catid' => $catid))->find();
     if (empty($info)) {
         return false;
     }
     $info['setting'] = unserialize($info['setting']);
     //删除不存在的选项
     if (!empty($post['extenddelete'])) {
         $extenddelete = explode('|', $post['extenddelete']);
         M('CategoryField')->where(array('fid' => array('IN', $extenddelete)))->delete();
     }
     //查询出该栏目扩展字段列表
     $extendFieldLisr = array();
     foreach (M('CategoryField')->where(array('catid' => $catid))->field('fieldname')->select() as $rs) {
         $extendFieldLisr[] = $rs['fieldname'];
     }
     //检查是否有新怎字段
     if (!empty($post['extend_config']) && is_array($post['extend_config'])) {
         $validate = array(array('catid', 'require', '栏目ID不能为空!', 1, 'regex', 3), array('fieldname', 'require', '键名不能为空!', 1, 'regex', 3), array('type', 'require', '类型不能为空!', 1, 'regex', 3), array('fieldname', '/^[a-z_0-9]+$/i', '键名只支持英文、数字、下划线!', 0, 'regex', 3));
         foreach ($post['extend_config'] as $field => $rs) {
             //如果已经存在则跳过
             if (in_array($field, $extendFieldLisr)) {
                 continue;
             }
             $rs['catid'] = $catid;
             $data = M('CategoryField')->validate($validate)->create($rs);
             if ($data) {
                 $data['createtime'] = $time;
                 $setting = $data['setting'];
                 if ($data['type'] == 'radio' || $data['type'] == 'checkbox') {
                     $option = array();
                     $optionList = explode("\n", $setting['option']);
                     if (is_array($optionList)) {
                         foreach ($optionList as $rs) {
                             $rs = explode('|', $rs);
                             if (!empty($rs)) {
                                 $option[] = array('title' => $rs[0], 'value' => $rs[1]);
                             }
                         }
                         $setting['option'] = $option;
                     }
                 }
                 $data['setting'] = serialize($setting);
                 $fieldId = M('CategoryField')->add($data);
                 if ($fieldId) {
                     $extendFieldLisr[] = $field;
                 }
             } else {
                 continue;
             }
         }
     }
     //值更新
     $extend = array();
     if (!empty($post['extend']) || is_array($post['extend'])) {
         foreach ($post['extend'] as $field => $value) {
             if (in_array($field, $extendFieldLisr)) {
                 $extend[$field] = $value;
             }
         }
         $info['setting']['extend'] = $extend;
     }
     //更新栏目
     $status = $this->where(array('catid' => $catid))->save(array('setting' => serialize($info['setting'])));
     //删除缓存
     getCategory($catid, '', true);
     return $status !== false ? true : false;
 }
Ejemplo n.º 30
0
    <td>&nbsp;</td>
    <td>&nbsp;</td>
	<?php 
foreach ($arr as $key => $value) {
    ?>
    <td><?php 
    echo $returnArray[$key];
    ?>
 hours&nbsp;</td>
	<?php 
}
?>
	<td>&nbsp;</td>
  </tr>
  <?php 
$category = getCategory($_GET['user_id'], $fromdate, $todate);
if ($category) {
    foreach ($category as $categoryKey => $categoryValue) {
        $categorycnt[$categoryValue] = 1;
        $project = getProject($_GET['user_id'], $categoryKey, $fromdate, $todate);
        if ($project) {
            foreach ($project as $projectKey => $projectValue) {
                $projectcnt[$projectValue] = 1;
                $task = getTask($_GET['user_id'], $categoryKey, $projectKey, $fromdate, $todate);
                if ($task) {
                    $j = 0;
                    foreach ($task as $taskKey => $taskValue) {
                        ?>
  <tr>
	<td><?php 
                        if ($categorycnt[$categoryValue] == 1) {