本文整理汇总了PHP中Section::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Section::getInstance方法的具体用法?PHP Section::getInstance怎么用?PHP Section::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Section
的用法示例。
在下文中一共展示了Section::getInstance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$name = trim($this->params['name']);
$parent = $ret = false;
if ($name == "") {
$this->notice = "讨论区列表";
$secs = Configure::read("section");
foreach ($secs as $k => $v) {
$ret[] = array("name" => $v[0], "desc" => $v[1], "url" => "/section/" . $k, "hot" => "/hot/" . $k, "dir" => true);
}
} else {
try {
$sec = Section::getInstance($name, Section::$NORMAL);
$this->notice = "讨论区-" . $sec->getDesc();
$brds = $sec->getAll();
$ret = array();
foreach ($brds as $b) {
$ret[] = array("name" => $b->DESC, "desc" => $b->NAME, "url" => ($b->isDir() ? "/section/" : "/board/") . $b->NAME, "dir" => $b->isDir());
}
if ($sec->isRoot()) {
$parent = "/section";
} else {
$parent = $sec->getParent();
$parent = "/section/" . $parent->getName();
}
} catch (SectionNullException $e) {
$this->error(ECode::$SEC_NOSECTION);
}
}
$this->set("boards", $ret);
$this->set("parent", $parent);
}
示例2: root
public function root()
{
App::import("vendor", "model/section");
$secs = Configure::read('section');
$wrapper = Wrapper::getInstance();
$data = array();
foreach (array_keys($secs) as $v) {
try {
$sec = Section::getInstance($v, Section::$NORMAL);
} catch (SectionNullException $e) {
$this->error(ECode::$SEC_NOSECTION);
} catch (BoardNullException $e) {
$this->error(ECode::$BOARD_NOBOARD);
}
$data[] = $wrapper->section($sec, array('status' => true));
}
$data = array('section_count' => count($data), 'section' => $data);
$this->set('data', $data);
$this->set('root', 'sections');
}
示例3: ajax_list
public function ajax_list()
{
$this->requestLogin();
if (!isset($this->params['url']['t'])) {
$this->error();
}
$type = $this->params['url']['t'];
if (!isset($this->params['url']['tt'])) {
$this->error();
}
$ret = array();
try {
$widgets = Widget::wGet(User::getInstance());
$my = array();
foreach ($widgets as $v) {
$my[] = $v["name"];
}
switch ($type) {
case 'section':
//$tt is for 0:root or 1:dir
$tt = $this->params['url']['tt'];
if ($tt != 0 && $tt != 1) {
$this->error();
}
$secs = Configure::read('section');
foreach ($secs as $k => $v) {
$w = Widget::getInstance("section-" . $k);
if ($tt == 0) {
if (!in_array($w->wGetName(), $my)) {
$title = $w->wGetTitle();
$title = $title["text"];
$ret[] = array('wid' => $w->wGetName(), 'title' => $title, 'p' => file_exists(IMAGES . 'app/icon/' . $w->wGetName() . '.png') ? $w->wGetName() : "default");
}
} else {
if ($tt == 1) {
foreach ($w->getDir() as $dir) {
$ww = Widget::getInstance("section-" . $dir->NAME);
if (!in_array($ww->wGetName(), $my)) {
$title = $ww->wGetTitle();
$title = $title["text"];
$ret[] = array('wid' => $ww->wGetName(), 'title' => $title, 'p' => file_exists(IMAGES . 'app/icon/' . $ww->wGetName() . '.png') ? $ww->wGetName() : "default");
}
}
}
}
}
break;
case 'favor':
//tt is for favor level
//favor is only one level!!! the structure error!!!
$tt = intval($this->params['url']['tt']);
$favor = Favor::getInstance($tt);
if (!in_array($favor->wGetName(), $my)) {
$title = $favor->wGetTitle();
$title = $title["text"];
$ret[] = array('wid' => $favor->wGetName(), 'title' => $title, 'p' => file_exists(IMAGES . 'app/icon/' . $favor->wGetName() . '.png') ? $favor->wGetName() : "default");
}
foreach ($favor->getDir() as $w) {
if (!in_array("favor-" . $w->BID, $my) && $w->NAME == "") {
$ret[] = array('wid' => "favor-" . $w->BID, 'title' => $w->DESC, 'p' => "default");
}
}
break;
case 'board':
if (!isset($this->params['url']['tt'])) {
$this->error();
}
//$tt is for section num
$tt = intval($this->params['url']['tt']);
$secs = Configure::read('section');
if (!in_array($tt, array_keys($secs))) {
$this->error();
}
$w = Section::getInstance($tt, Section::$ALL);
foreach ($w->getList() as $brd) {
$ww = Widget::getInstance("board-" . $brd->NAME);
if (!in_array($ww->wGetName(), $my)) {
$title = $ww->wGetTitle();
$title = $title["text"];
$ret[] = array('wid' => $ww->wGetName(), 'title' => $title, 'p' => file_exists(IMAGES . 'app/icon/' . $ww->wGetName() . '.png') ? $ww->wGetName() : "default");
}
}
break;
case 'ext':
if (!isset($this->params['url']['tt'])) {
$this->error();
}
//$tt is for category
$tt = $this->params['url']['tt'];
$ext = Configure::read('widget.ext');
if (!in_array($tt, array_keys($ext))) {
$this->error();
}
foreach ($ext[$tt][1] as $v) {
try {
$w = Widget::getInstance($v);
} catch (WidgetNullException $e) {
continue;
}
if (!in_array($w->wGetName(), $my)) {
//.........这里部分代码省略.........
示例4: ajax_list
public function ajax_list()
{
$ret = array();
if (!isset($this->params['url']['root'])) {
$this->_stop();
}
$root = $this->params['url']['root'];
try {
$sec = substr($root, 0, 2) == "s-" ? 1 : 0;
$root = $root == "list-favor" ? 0 : substr($root, 2);
try {
if ($sec) {
$fav = Section::getInstance($root, Section::$NORMAL);
} else {
$fav = Favor::getInstance($root);
}
} catch (SectionNullException $e) {
$this->_stop();
} catch (FavorNullException $e) {
$this->_stop();
}
$ret = array();
if (!$fav->isNull()) {
$brds = $fav->getAll();
foreach ($brds as $v) {
//user dir
if ($v->NAME == "") {
$ret[] = array("t" => "<a href=\"javascript:void(0)\" title=\"{$v->DESC}\">{$v->DESC}</a>", "id" => "f-" . $v->BID);
} elseif ($v->isDir()) {
$ret[] = array("t" => "<a href=\"{$this->base}/section/{$v->NAME}\" title=\"{$v->DESC}\">{$v->DESC}</a>", "id" => "s-" . $v->NAME);
} else {
$ret[] = array("t" => "<a href=\"{$this->base}/board/{$v->NAME}\" title=\"{$v->DESC}\">{$v->DESC}</a>");
}
}
}
$this->cache(true, $fav->wGetTime(), 10);
$this->set('no_html_data', $ret);
$this->set('no_ajax_info', true);
} catch (FavorNullException $e) {
$this->_stop();
}
}
示例5: article
public function article()
{
$this->js[] = "forum.board.js";
$this->css[] = "board.css";
$this->notice[] = array("url" => "", "text" => "ËÑË÷½á¹û");
App::import('Sanitize');
$day = $title1 = $title2 = $title3 = $author = $t = "";
if (isset($this->params['url']['t1'])) {
$title1 = trim(rawurldecode($this->params['url']['t1']));
}
if (isset($this->params['url']['t2'])) {
$title2 = trim(rawurldecode($this->params['url']['t2']));
}
if (isset($this->params['url']['tn'])) {
$title3 = trim(rawurldecode($this->params['url']['tn']));
}
if (isset($this->params['url']['au'])) {
$author = trim($this->params['url']['au']);
}
if (isset($this->params['url']['d'])) {
$day = intval($this->params['url']['d']);
}
$title1 = nforum_iconv('utf-8', $this->encoding, $title1);
$title2 = nforum_iconv('utf-8', $this->encoding, $title2);
$title3 = nforum_iconv('utf-8', $this->encoding, $title3);
$m = isset($this->params['url']['m']);
$a = isset($this->params['url']['a']);
$full = isset($this->params['url']['f']);
$site = Configure::read('search.site');
$return = Configure::read("search.max");
$res = array();
$u = User::getInstance();
if ($title1 == '' && $title3 == '' && $author == '' && !$m && !$a) {
$res = array();
} else {
if ($full && $site && $u->isAdmin()) {
App::import('vendor', 'model/section');
$secs = array_keys(Configure::read("section"));
foreach ($secs as $v) {
$sec = Section::getInstance($v, Section::$ALL);
foreach ($sec->getList() as $brd) {
if (!$brd->isNormal()) {
continue;
}
$res = array_merge($res, Threads::search($brd, $title1, $title2, $title3, $author, $day, $m, $a, $return));
}
}
} else {
$b = @$this->params['url']['b'];
try {
$brd = Board::getInstance($b);
} catch (BoardNullException $e) {
$this->error(ECode::$BOARD_NONE);
}
$res = Threads::search($brd, $title1, $title2, $title3, $author, $day, $m, $a, $return);
}
}
$p = 1;
if (isset($this->params['url']['p'])) {
$p = $this->params['url']['p'];
}
App::import("vendor", "inc/pagination");
$page = new Pagination(new ArrayPageableAdapter($res), Configure::read("pagination.search"));
$threads = $page->getPage($p);
$info = false;
$curTime = strtotime(date("Y-m-d", time()));
$pageArticle = Configure::read("pagination.article");
foreach ($threads as $v) {
$tabs = ceil($v->articleNum / $pageArticle);
$last = $v->LAST;
$postTime = $curTime > $v->POSTTIME ? date("Y-m-d", $v->POSTTIME) : date("H:i:s", $v->POSTTIME) . " ";
$replyTime = $curTime > $last->POSTTIME ? date("Y-m-d", $last->POSTTIME) : date("H:i:s", $last->POSTTIME) . " ";
$info[] = array("title" => Sanitize::html($v->TITLE), "poster" => $v->isSubject() ? $v->OWNER : "ÔÌûÒÑɾ³ý", "postTime" => $postTime, "gid" => $v->ID, "last" => $last->OWNER, "replyTime" => $replyTime, "page" => $tabs, "bName" => $v->getBoard()->NAME, "num" => $v->articleNum - 1);
}
$this->set("info", $info);
$query = $this->params['url'];
unset($query['url']);
unset($query['p']);
unset($query['ext']);
foreach ($query as $k => &$v) {
$v = $k . '=' . rawurlencode($v);
}
$query[] = "p=%page%";
$link = "{$this->base}/s/article?" . join("&", $query);
$this->set("pageBar", $page->getPageBar($p, $link));
$this->set("pagination", $page);
}
示例6: ajax_list
public function ajax_list()
{
$this->cache(true, strtotime(date("Y-m-d", time() + 86400)));
$ret = array();
if (!isset($this->params['url']['root'])) {
$this->_stop();
}
$root = $this->params['url']['root'];
if ($root == "list-section") {
$sections = Configure::read("section");
foreach ($sections as $k => $v) {
$ret[] = array("t" => "<a href=\"{$this->base}/section/{$k}\">{$v[0]}</a>", "id" => "sec-{$k}");
}
$this->set('no_html_data', $ret);
$this->set('no_ajax_info', true);
return;
} else {
try {
$boardOnly = isset($this->params['url']['bo']);
$root = Section::getInstance(substr($root, 4), $boardOnly ? Section::$ALL : Section::$NORMAL);
$sections = $boardOnly ? $root->getList() : $root->getAll();
foreach ($sections as $v) {
$tmp = array();
if ($boardOnly) {
$ret[] = array('name' => $v->NAME, 'desc' => $v->DESC);
continue;
}
if ($v->isDir()) {
$tmp['t'] = "<a href=\"{$this->base}/section/{$v->NAME}\" title=\"{$v->DESC}\">{$v->DESC}</a>";
$tmp['id'] = 'sec-' . $v->NAME;
} else {
$tmp['t'] = "<a href=\"{$this->base}/board/{$v->NAME}\" title=\"{$v->DESC}\">{$v->DESC}</a>";
}
$ret[] = $tmp;
}
$this->set('no_html_data', $ret);
$this->set('no_ajax_info', true);
} catch (SectionNullException $e) {
$this->_stop();
} catch (BoardNullException $e) {
$this->_stop();
}
}
}
示例7: _favor
private function _favor($fav)
{
App::import('vendor', 'model/section');
$wrapper = Wrapper::getInstance();
$f = $s = $b = array();
if (!$fav->isNull()) {
$brds = $fav->getAll();
foreach ($brds as $k => $v) {
if ($v->NAME == '') {
$f[] = $wrapper->favorite($v);
} else {
if ($v->isDir()) {
$s[] = $wrapper->section(Section::getInstance($v));
} else {
$b[] = $wrapper->board($v);
}
}
}
}
return array('sub_favorite' => $f, 'section' => $s, 'board' => $b);
}