/** * * @param type $element * @param type $createThread * @param type $bean * @param type $externalAction * @param type $args * @return type */ public function executeRequest($args = array(), $createThread = false, $bean = null, $externalAction = '') { $this->logger->info('Processing a direct request.'); $this->logger->debug('Direct request params: ' . print_r($args)); $this->request->setCreateThread($createThread); $this->request->setExternalAction($externalAction); $this->request->setBean($bean); $this->request->setArguments($args); $preProcessor = $this->preProcessor->getInstance(); $response = $preProcessor->processRequest($this->request); return $response; }
static function typeinfo($id) { $type = type::getInstance (); if (is_array ( $id )) $id = $id ['typeid']; $typeinfo [] = $type->type [$id]; $typeinfo [0] ['url'] = type::url ( $id ); if(!$typeinfo){ return; } $types = $type->son ( $id ); $tys = array (); foreach ( $types as $typeid ) { $_type = $type->type [$typeid]; if ($stype && ! preg_match ( '/-/', $stype ) && $_type ['stype'] != $stype) continue; if ($stype && preg_match ( '/-/', $stype ) && '-' . $_type ['stype'] == $stype) continue; $_type ['url'] = type::url ( $_type ['typeid'] ); $tys [] = $_type; } if(!empty($tys)){ $typeinfo = array_merge($typeinfo,$tys); } //var_dump($typeinfo); return $typeinfo; }
static function select($name,$value,$data,$option=null) { $select="<select id=\"$name\" name=\"$name\" $option>"; if (!isset($data[0]) &&@$data[0] != null) { $select.="<option value=\"0\">请选择...</option>"; } if (@$data[0] == null ||(isset($data[0]) &&!$data[0])) unset($data[0]); if($_GET['table'] == 'category'){ $category = category::getInstance(); $subids = $category->sons($_GET['id']); } if($_GET['table'] == 'type'){ $category = type::getInstance(); $subids = $category->sons($_GET['id']); } foreach ($data as $k=>$d) { $select .= "<option value=\"$k\""; if($k == $value){ $select .= ' selected '; }else if(isset($_GET['id']) && ($_GET['table'] == 'category' || $_GET['table'] == 'type') && !preg_match('/htmlrule/is', $name)){ if($_GET['id'] == $k || in_array($k,$subids)){ $select .= ' disabled '; } } $select .= ">$d</option>"; //$select.="<option value=\"$k\" ".($k == $value ?'selected': '').">$d</option>"; } $select.="</select>"; return $select; }
function list_action() { $this->view->page=front::get('page') ?front::get('page') : 1; $this->pagesize=config::get('list_pagesize'); $limit=(($this->view->page -1) * $this->pagesize).','.$this->pagesize; $type=new type(); $types=array(); $types=$type->sons(front::get('typeid')); $types[]=front::get('typeid'); $where='typeid in ('.implode(',',$types).') AND checked=1 AND state=1'; $this->view->type=$type->getrow('typeid='.front::get('typeid')); $this->view->pages=@$this->view->type['ispages']; $this->view->typeid=front::get('typeid'); $archive=new archive(); $archives=$archive->getrows($where,$limit,'listorder desc,aid desc'); foreach ($archives as $order=>$arc) { $archives[$order]['url']=archive::url($arc); $archives[$order]['typename']=type::name($arc['typeid']); $archives[$order]['typeurl']=type::url($arc['typeid']); $archives[$order]['adddate']=sdate($arc['adddate']); $archives[$order]['stitle']=strip_tags($arc['title']); $archives[$order]['sthumb'] = @strstr($arc['thumb'], "http://") ? $arc['thumb'] : config::get('base_url') . '/' . $arc['thumb']; } $this->view->archives=$archives; $this->view->record_count=$archive->rec_count($where); front::$record_count=$this->view->record_count; $this->type=type::getInstance(); if (front::get('t') == 'wap') { $this->out('wap/type_list.html'); return; } $template=$this->type->type[front::get('typeid')]['template']; if ($template&&file_exists(TEMPLATE.'/'.$this->view->_style.'/'.$template)) $this->out($template); else { $tpl=type::gettemplate($this->view->typeid); if (type::getishtml($this->view->typeid)) { $path=ROOT.type::url($this->view->typeid,@front::$get['page']>1 ?front::$get['page'] : null); if (!preg_match('/\.[a-zA-Z]+$/',$path)) $path=rtrim(rtrim($path,'/'),'\\').'/index.html'; $this->cache_path=$path; } $this->out($tpl); } }
/** * Obtains a new instance of $modelClassName, using a dependency injection * container if possible. * * @param string $modelClassName name of the model */ public static function factory($modelClassName) { if (self::$dependencyInjector) { return self::$dependencyInjector->getInstance($modelClassName); } return new $modelClassName(); }
function archive($catid='0',$typeid='0',$spid=0,$area='0,0,0',$length=20,$ordertype='aid',$limit=10,$image=false,$attr1=null,$son=true,$wheretype='',$tpl=null,$intro_len='0',$istop=0) { $_ordertype=$ordertype; $cache_id=md5($catid.$typeid.$spid.$area.$length.$ordertype.$limit.$son.$wheretype.$tpl.$intro_len.$istop); if ($ordertype == 'rand()') $cache_id=$cache_id.time(); if (cache::get($cache_id)) $archives=cache::get($cache_id); else { $ordertype=str_replace('-',' ',$ordertype); $wheretype=str_replace('-',' ',$wheretype); $order = 'listorder=0,listorder ASC '; if (preg_match('/^\w+$/',$ordertype)) $order .= ','.$ordertype.' desc'; elseif ($ordertype) $order .= ','.$ordertype; $where=array(); if ($wheretype) foreach (explode(',',$wheretype) as $_wheretype) switch ($_wheretype) { case 'day': $where[]='adddate>'.date('Y-m-d H:i:s',time() -3600 * 24); break; case 'week': $where[]='adddate>'.date('Y-m-d H:i:s',time() -3600 * 24 * 7); break; case 'month': $where[]='adddate>'.date('Y-m-d H:i:s',time() -3600 * 24 * 30); break; default: if (preg_match('/commend=(\d+)/i',$_wheretype,$match)) $where[]=" attr1 REGEXP '(^|,)$match[1](,|$)' "; else if (preg_match('/^\w+$/',$_wheretype)) $where[]=$_wheretype."<>''"; else $where[]=$_wheretype; break; } if (!empty($where)) $where=' and '.implode(' and ',$where); else $where=''; $archive=archive::getInstance(); $category=category::getInstance(); $categories=array(); if (isset($catid) &&$catid != '0') { $catid=explode('-',$catid); //var_dump($catid); $categories=$catid; $_categories1=array(); if ($son) { foreach ($categories as $key=>$val) { $_categories[$key]=$category->sons($val); $_categories1=array_merge($_categories[$key],$_categories1); } //var_dump($_categories); } //var_dump($categories); $categories=array_merge($categories,$_categories1); //var_dump($categories); } //var_dump($categories); $type=type::getInstance(); $types=array(); if (isset($typeid) &&$typeid != '0') { $types[]=$typeid; if ($son) { $_types=$type->sons($typeid); } $types=array_merge($types,$_types); } $where='1'; if (!empty($types)) $where.=' and typeid in ('.implode(',',$types).')'; if (!empty($categories)) $where.=' and catid in ('.implode(',',$categories).')'; if ($spid) $where.=' and spid='.$spid; list($province_id,$city_id,$section_id)=explode(',',$area); if ($province_id) $where.=' and province_id='.$province_id; if ($city_id) $where.=' and city_id='.$city_id; if ($section_id) $where.=' and section_id='.$section_id; if ($image) $where.=' and thumb <> "" '; if ($attr1) $where.=" and FIND_IN_SET('$attr1',attr1) "; if ($_ordertype == 'aid-asc') { $order .=',aid asc'; } if ($_ordertype == 'new') { $order .= ',adddate desc'; } if($istop){ $tops = $archive->getrows($where." AND checked=1 AND state=1 AND toppost!=0",0,'toppost DESC,listorder=0,listorder ASC,aid DESC'); } $archives = $archive->getrows($where.' AND state=1 AND checked=1',$limit-count($tops),$order,$archive->getcols('list')); if(is_array($tops) && !empty($tops)){ foreach($tops as $order => $arc){ if($arc['toppost'] == 3){ $tops[$order]['title'] = "[全站置顶]".$arc['title']; } if($arc['toppost'] == 2){ $subcatids = $category->sons($arc['catid']); if($arc['catid'] != $catid[0] && !in_array($catid[0], $subcatids)){ unset($tops[$order]); }else{ $tops[$order]['title'] = "[栏目置顶]".$arc['title']; } } } $archives = array_merge($tops , $archives); } foreach ($archives as $order=>$arc) { if (!$arc['introduce']) $arc['introduce']=cut($arc['content'],$arc['introduce_len'] ?$arc['introduce_len'] : 200); $archives[$order]['url']=$arc['linkto'] ?$arc['linkto'] : archive::url($arc); $archives[$order]['catname']=category::name($arc['catid']); $archives[$order]['caturl']=category::url($arc['catid']); $archives[$order]['image']=@strstr($arc['image'],"http://") ?$arc['image'] : config::get('base_url').'/'.$arc['image']; $archives[$order]['adddate']=sdate($arc['adddate']); $archives[$order]['stitle']=strip_tags($arc['title']); $archives[$order]['title']=tool::cn_substr($arc['title'],$length); $archives[$order]['strgrade'] = archive::getgrade($arc['grade']); $archives[$order]['buyurl']=url('archive/orders/aid/'.$arc['aid']); $prices = getPrices($arc['attr2']); $archives[$order]['oldprice'] = $prices['oldprice']; $archives[$order]['attr2'] = $prices['price']; if(!$intro_len){ $archives[$order]['intro'] = ''; }else if($intro_len == '-1'){ $archives[$order]['intro'] = $arc['introduce']; }else{ $archives[$order]['intro'] = cut($arc['introduce'],$intro_len); } if(strtolower(substr($arc['thumb'],0,7)) == 'http://'){ $archives[$order]['sthumb'] = $arc['thumb']; }else{ $archives[$order]['sthumb'] = config::get('base_url').'/'.$arc['thumb']; } if($arc['strong']){ $archives[$order]['title'] = '<strong>'.$archives[$order]['title'].'</strong>'; } if($arc['color'] !="#000000"){ $archives[$order]['title'] = '<font style="color:'.$arc['color'].';">'.$archives[$order]['title'].'</font>'; } cb_data($archives[$order]); /*if($arc['toppost'] == '3'){ $tmp[] = $archives[$order]; unset($archives[$order]); } if($arc['toppost'] == '2' && front::get('catid') == $arc['catid']) { $tmp2[] = $archives[$order]; unset($articles[$order]); }*/ /*foreach ($archives[$order] as $key => $value){ if(!preg_match('/^my/',$key) || !$value) continue; $category = category::getInstance(); $sonids = $category->sons(setting::$var['archive'][$key]['catid']); if(setting::$var['archive'][$key]['catid'] != $archive['catid'] && !in_array($archive['catid'],$sonids) && (setting::$var['archive'][$key]['catid'])){ unset($field[$key]); continue; $archives[$order][$key] = $value; } }*/ } /*if(is_array($tmp)){ $archives = array_merge($tmp,$archives); }*/ if ($ordertype != 'rand()') cache::set($cache_id,$archives); } //run::_start(); if ($tpl) { front::$view->_var->articles=$archives; return template($tpl); } else return $archives; }
function mail_action() { chkpw('seo_mail_usersend'); $where=null; $ordre='1 desc'; if ($this->table == 'archive') { $ordre="`order`,1 DESC"; $where=$this->_table->get_where('manage'); if (!front::post('_typeid')) session::del('_typeid'); if (get('_typeid')) { $typeid=get('_typeid'); session::set('_typeid',$typeid); $this->type=type::getInstance(); $types=$this->type->sons($typeid); $types[]=$typeid; $where .=' and typeid in('.trim(implode(',',$types),',').')'; } if (get('typeid')) { $typeid=get('typeid'); $where .=' and typeid='.$typeid; } if (!front::post('_title')) session::del('_title'); if (get('_title')) { $title=get('_title'); session::set('_title',$title); $where .=" and title like '%$title%' "; } } if ($this->table == 'templatetag') { if (front::get('tagfrom')) { $where="tagfrom='".front::get('tagfrom')."'"; } else $where="tagfrom='define'"; $where .=" and (`tagvar` IS NULL OR `tagvar` = '') "; } if ($this->table == 'option') { $ballot=new ballot(); $where=array('bid'=>front::$get['bid']); session::set('bid',front::$get['bid']); $row=$ballot->getrow(array('id'=>front::$get['bid'])); $this->view->ballot=$row; } $limit=((front::get('page') -1) * $this->_pagesize).','.$this->_pagesize; $this->_view_table=$this->_table->getrows($where,$limit,$ordre,$this->_table->getcols('manage')); $this->view->record_count=$this->_table->record_count; }
function make_type_action() { chkpw('cache_type'); header('Cache-control: private, must-revalidate'); @set_time_limit(0); if (!front::post('submit')) return; $case = 'type'; $act = 'list'; $_GET = array('case' => $case, 'act' => $act); $front = new front(); front::$admin = false; front::$html = true; front::$rewrite = false; $case = $case . '_act'; $case = new $case(); $case->init(); $method = $act . '_action'; $totalpage = 100; $time_start = time::getTime(); $type = type::getInstance(); $typeid = front::post('typeid'); if ($typeid && !$type->getishtml($typeid)) { front::flash("该分类不需要生成html!"); return; } if($typeid){ $arrtype = $type->getrows($typeid); }else{ $arrtype = $type->getrows('',0); } $cpage = 0; if(is_array($arrtype) && !empty($arrtype)){ foreach($arrtype as $v){ if (!$type->getishtml($v['typeid'])) { continue; } $types=array(); $types=$type->sons($v['typeid']); $types[]=$v['typeid']; $where='typeid in ('.implode(',',$types).') AND checked=1 AND state=1'; $archive_all = new archive(); $archive_num = $archive_all->rec_count($where); for (front::$get['page'] = 1;; front::$get['page']++) { $view = $case->view; $pagesize = config::get('list_pagesize'); $limit = ((front::$get['page'] - 1) * $pagesize) . ',' . $pagesize; $archive = new archive(); $case->view->archives = $archive->getrows($where, $limit, '`listorder` desc,aid desc'); $case->view->page = front::$get['page']; $case->view->type = $v; $case->view->typeid = $v['typeid']; $case->view->pages = $v['ispages']; foreach ($case->view->archives as $order => $arc) { $articles = $arc; if (!$arc['introduce']) $arc['introduce'] = cut($arc['content'], 200); $articles['url'] = archive::url($arc); $articles['catname'] = category::name($arc['catid']); $articles['caturl'] = category::url($arc['catid']); $articles['sthumb'] = @strstr($arc['thumb'], "http://") ? $arc['thumb'] : config::get('base_url') . '/' . $arc['thumb']; $articles['strgrade'] = archive::getgrade($arc['grade']); $articles['adddate'] = sdate($arc['adddate']); $articles['buyurl'] = url('archive/orders/aid/' . $arc['aid']); $articles['stitle'] = strip_tags($arc['title']); $case->view->archives[$order] = $articles; } if (!isset($page_count)) { front::$record_count = $case->view->record_count = $archive_num; $case->view->page_count = ceil($case->view->record_count / $pagesize); $page_count = $case->view->page_count; } if (front::get('page') > 1 && front::get('page') > $case->view->page_count) { $page_count = null; break; } $tpl = type::gettemplate($v['typeid']); $content = $case->fetch($tpl); $path = type::url($v['typeid'], front::$get['page'], true); if (!preg_match('/\.[a-zA-Z]+$/', $path)) $path = rtrim(rtrim($path, '/'), '\\') . '/index.html'; $path = rtrim($path, '/'); $path = rtrim($path, '\\'); $path = str_replace('//', '/', $path); if(config::get('base_url') == '/'){ $path = ROOT.substr($path,1); }else{ $path = ROOT.str_replace(config::get('base_url'), '', $path); } tool::mkdir(dirname($path)); if (!file_put_contents($path, $content)) { front::flash("写入HTML失败!"); } $indexpath = dirname($path) . '/index.html'; if (front::$get['page'] == 1 && $indexpath != ROOT . '/index.html') { file_put_contents($indexpath, $content); $cpage++; } $cpage++; $case->view = $view; } } } if ($cpage > 0) front::flash("成功生成html <b>$cpage</b> 页!"); else front::flash("没有生成html!"); front::$admin = true; }
/** * Get instance of Thrift Model classes * @param string $classe * @param mixed $param * @return mixed */ public function getInstance($classe, $param = null) { return $this->factory->getInstance($classe, $param); }