本文整理汇总了PHP中Category_Model::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Category_Model::getInstance方法的具体用法?PHP Category_Model::getInstance怎么用?PHP Category_Model::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category_Model
的用法示例。
在下文中一共展示了Category_Model::getInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
<?php
require 'admin_init.php';
login();
//删除单个文章
if (isset($_GET['post_id'])) {
$post_id = $_GET['post_id'];
Post_Model::getInstance()->deleteLog($post_id);
} elseif (isset($_GET['post_ids'])) {
$ids = explode(',', $_GET['post_ids']);
foreach ($ids as $id) {
Post_Model::getInstance()->deleteLog($id);
}
} elseif (isset($_GET['term_id'])) {
Category_Model::getInstance()->deleteTerm($_GET['term_id']);
} elseif (isset($_GET['term_ids'])) {
$ids = explode(',', $_GET['term_ids']);
foreach ($ids as $id) {
Category_Model::getInstance()->deleteTerm($id);
}
}
示例2: json_decode
?>
">
<div class="dd-handle dd3-handle">Drag</div>
<div class="dd3-content"><?php
echo $term['term_name'];
?>
</div>
</li>
<?php
}
echo '</ol></div>';
}
$menu_arr = json_decode($menu, true);
// 已经被添加到菜单中的分类
create_nest_menu($menu_arr, $menu_selected, $terms_selected);
$terms = Category_Model::getInstance()->getTermsAll();
$term_ids = array();
foreach ($terms as $term) {
$term_ids[] = $term['term_id'];
}
// 还未被添加到菜单中的分类
$terms_not_selected = array_diff($term_ids, $terms_selected);
foreach ($terms_not_selected as $term_id) {
$menu_not_selected = '<li class="dd-item dd3-item" data-id="' . $term_id . '">' . "\n";
$menu_not_selected .= '<div class="dd-handle dd3-handle">Drag</div>' . "\n";
$menu_not_selected .= '<div class="dd3-content">' . $cat->getTermName($term_id) . '</div>' . "\n";
$menu_not_selected .= '<li>' . "\n";
}
if (empty($menu_not_selected)) {
$menu_not_selected = '<h2>无还未添加到菜单的分类</h2>';
} else {
示例3:
echo $term['term_description'];
?>
</td>
<td><a href="<?php
echo SITE_URL . 'category.php?term_id=' . $term['term_id'];
?>
"><img src="<?php
echo SITE_URL;
?>
img/open-new-window.gif" /></a></td>
<td><a href="<?php
echo SITE_URL . 'admin/admin_log.php?term_id=' . $term['term_id'];
?>
">
<?php
echo Category_Model::getInstance()->getPostsNumByTerm($term['term_id']);
?>
</a></td>
<td>
<a href="" class="admin-btn-edit btn-small">编辑 </a>
<a href="" class="text-danger admin-btn-delete btn-small">删除</a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="table-bottom-nav">
<span>选中项:</span><a id="delete-selected" class="text-danger btn-small" href="" >删除</a>
</div>
示例4: widget_navibar
function widget_navibar()
{
?>
<div id="navigation" class="clearfix">
<div class="menu-main-container">
<ul class="sf-menu">
<li class="current"><a href="<?php
echo SITE_URL;
?>
index.php">主页</a>
</li>
<li><a href='#'>分类</a>
<ul>
<?php
$terms = Category_Model::getInstance()->getTermsAll();
foreach ($terms as $term) {
?>
<li><a href="<?php
echo SITE_URL;
?>
category.php?term_id=<?php
echo $term['term_id'];
?>
"
title=""><?php
echo $term['term_name'];
?>
</a></li>
<?php
}
?>
</ul>
</li>
<li><a href="<?php
echo SITE_URL;
?>
admin/write_log.php" title="">写博客</a>
</li>
<li><a href='#'>管理</a>
<ul>
<li><a href='#'>管理博客</a>
<ul>
<li><a href="<?php
echo SITE_URL;
?>
admin/admin_log.php" title="">管理</a></li>
<li><a href="<?php
echo SITE_URL;
?>
admin/write_log.php" title="">写博客</a></li>
</ul>
</li>
<li><a href='#'>管理收藏</a>
<ul>
<li><a href="<?php
echo SITE_URL;
?>
admin/admin_link.php"
title="">管理</a></li>
<li><a href="<?php
echo SITE_URL;
?>
collect.php" title="">查看</a></li>
<li><a href="<?php
echo SITE_URL;
?>
link.php" title="">添加</a></li>
</ul>
</li>
<li><a href='#'>管理相册</a>
<ul>
<li><a href="<?php
echo SITE_URL;
?>
admin/admin_album.php"
title="">管理 </a></li>
<li><a href="<?php
echo SITE_URL;
?>
link.php" title="">添加</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<?php
}
示例5: json_decode
<?php
require "../init.php";
$menu = '[{"id":1},{"id":4,"children":[{"id":3},{"id":2}]}]';
$menu = json_decode($menu, true);
//print_r($menu);
$cat = Category_Model::getInstance();
function traverse($root, &$nest_menu)
{
global $cat;
if (!is_array($root)) {
return;
}
// 叶节点
if (count($root) == 1 and array_key_exists('id', $root)) {
$nest_menu .= '<li class="dd-item dd3-item" data-id="' . $root['id'] . '">' . "\n";
$nest_menu .= '<div class="dd-handle dd3-handle">Drag</div>' . "\n";
$nest_menu .= '<div class="dd3-content">' . $cat->getTermName($root['id']) . '</div>' . "\n";
$nest_menu .= '<li>' . "\n";
return;
}
// 父目录
if (count($root) == 2 and array_key_exists('id', $root)) {
$nest_menu .= '<li class="dd-item dd3-item" data-id="' . $root['id'] . '">' . "\n";
$nest_menu .= '<div class="dd-handle dd3-handle">Drag</div>' . "\n";
$nest_menu .= '<div class="dd3-content">' . $cat->getTermName($root['id']) . '</div>' . "\n";
// 该目录的子目录
traverse($root['children'], $nest_menu);
$nest_menu .= "</li>" . "\n";
return;
}
示例6: escape_data
$log_data[] = $post_title;
$log_data[] = escape_data($post_content);
$log_data[] = isset($post_excerpt) ? escape_data($post_excerpt) : null;
$log_data[] = $post_status;
$log_data[] = $post_term;
if (isset($_POST['publish_submit'])) {
$post_id = Post_Model::getInstance()->addLog($log_data);
} elseif (isset($_POST['update_publish'])) {
$post_id = $_GET['pageid'];
Post_Model::getInstance()->updateLog($post_id, $log_data);
}
$post_url = SITE_URL . "post.php?pageid={$post_id}";
$publish_success_div = "<div class=\"submit-success span6\"><span>保存成功 </span><a href=\"{$post_url}\" target='_blank'>查看文章</a></div>";
}
} elseif (isset($_GET['action']) && $_GET['action'] == 'edit') {
$post_id = $_GET['pageid'];
$post = Post_Model::getInstance()->getPostById($post_id, false);
$post_title = $post['post_title'];
$post_excerpt = $post['post_excerpt'];
//$post_excerpt = isset($post['post_excerpt']) ? $post['post_excerpt'] : null;
$post_content = $post['post_content'];
$post_status = isset($_POST['update_draft']) ? 'draft' : 'publish';
$term_id = $post['term_id'];
$post_term = Category_Model::getInstance()->getTermName($term_id);
}
if (isset($_GET['action']) && $_GET['action'] == 'edit') {
require ADMIN_VIEW_PATH . 'edit_log.php';
} else {
require ADMIN_VIEW_PATH . 'write_log.php';
}
require ADMIN_VIEW_PATH . 'footer.php';
示例7: getPostsByTerm
/**
* 按分类获取文章
* @param $term_id
* @param string $order
* @param int $paging_id
* @return array
*/
function getPostsByTerm($term_id, $order = 'post_date desc', $paging_id = 1)
{
if (isset($paging_id)) {
$item_start = ($paging_id - 1) * ITEM_NUM;
$limit_query = "{$item_start}," . ITEM_NUM;
} else {
$limit_query = '0,' . ITEM_NUM;
}
$posts = array();
$select_query = 'post_id, post_date, post_title, post_excerpt, post_status, term_id';
$where_query = "post_status = 'publish' and term_id={$term_id}";
$sql = "select {$select_query} from blog_posts where {$where_query} order by {$order} limit {$limit_query}";
$res = $this->db->query($sql);
while ($row = $this->db->fetch_array($res)) {
list($row['post_date'], $row['post_time']) = explode(' ', $row['post_date']);
$row['post_title'] = htmlspecialchars($row['post_title']);
$row['post_excerpt'] = htmlspecialchars($row['post_excerpt']);
$term_name = Category_Model::getInstance()->getTermName($row['term_id']);
$row['term_name'] = htmlspecialchars($term_name);
$posts[] = $row;
}
return $posts;
}
示例8:
<?php
require '../../../init.php';
$term_id = $_GET['term_id'];
$posts = Post_Model::getInstance()->getPostsByTerm($term_id);
$term_name = Category_Model::getInstance()->getTermName($term_id);
$page_title = $term_name . ' | ' . SITE_TITLE;
require TEMPLATE_PATH . 'header.php';
echo "<div id='main'>";
echo "<div id='term_name'><h1>{$term_name}</h1></div>";
require TEMPLATE_PATH . 'post_list.php';
widget_paging();
?>
</div>
<!-- main end -->
<?php
require TEMPLATE_PATH . 'right_side.php';
require TEMPLATE_PATH . 'footer.php';