本文整理汇总了PHP中Category::getByID方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getByID方法的具体用法?PHP Category::getByID怎么用?PHP Category::getByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category::getByID方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getElementFromCode
public static function getElementFromCode($string)
{
if (strstr($string, "c")) {
return Category::getByID(intval(str_replace("c", "", $string)));
} else {
if (strstr($string, "b")) {
return Board::getByID(intval(str_replace("b", "", $string)));
} else {
if (strstr($string, "t")) {
return Thread::getByID(intval(str_replace("t", "", $string)));
} else {
if (strstr($string, "p")) {
return Post::getByID(intval(str_replace("p", "", $string)));
}
}
}
}
return null;
}
示例2: time
if (strstr($_GET["p"], "t")) {
$thread = Thread::getByID(intval(str_replace("t", "", $_GET["p"])));
if ($thread != null) {
if ($_GET["a"] == "new" && $_POST["editableContent"]) {
if ($currentUser != null) {
if ($currentUser->id > 0) {
$post = $thread->createPost(clean($_POST["editableContent"]), $currentUser, time(), $con);
}
}
}
$printContent .= $thread->printThreadContent($currentUser, $con, intval($_GET["page"]));
$thread->view($currentUser, $con);
}
} else {
if (strstr($_GET["p"], "c")) {
$category = Category::getByID(intval(str_replace("c", "", $_GET["p"])));
if ($category != null) {
if ($_GET["a"] == "new" && !empty($_POST["title"])) {
if (empty($_POST["editableContent"])) {
$_POST["editableContent"] = " ";
}
$category->createBoard($currentUser, clean($_POST["title"], true), clean($_POST["editableContent"], true))->save($con);
}
$printContent .= $category->printCategory($currentUser);
}
}
}
}
if (empty($printContent)) {
header("Location: forum.php");
die;
示例3: __construct
public function __construct($type, $id)
{
$this->type = $type;
$this->id = $id;
if( $type == 'item' )
{
$item = Item::getByID($id);
if( $item instanceof Item )
{
$cat = $item->category;
$categories = array($cat);
while( $cat->getParent() instanceof Category )
{
$cat = $cat->getParent();
array_push($categories, $cat);
}
$categories = array_reverse($categories);
$this->path = '<a href="menu.php" class="button"><span class="icon book"></span>Menu</a>';
foreach( $categories as $cat )
{
$this->path .= '|<a href="menu.php?cat=' . $cat->categoryid . '" class="button">' . $cat->name . '</a>';
}
$this->path .= '|<a href="#" class="button">' . $item->name . '</a>';
}
}
elseif( $type == 'menu' )
{
$c = Category::getByID($id);
if( $c instanceof Category )
{
$categories = array($c);
while( $c->getParent() instanceof Category )
{
$c = $c->getParent();
array_unshift($categories, $c);
}
$this->path = '<a href="menu.php" class="button"><span class="icon book"></span>Menu</a>';
foreach( $categories as $cat )
{
$this->path .= '|<a href="menu.php?cat=' . $cat->categoryid . '" class="button">' . $cat->name . '</a>';
}
}
else
{
$this->path = '<a href="menu.php" class="button"><span class="icon book"></span>Menu</a>';
}
}
elseif( $type == 'report' )
{
switch($id)
{
case 0: $report_name = 'Item Frequency'; break;
case 1: $report_name = 'Orders per Hour'; break;
}
$this->path = '<a href="reporting.php" class="button"><span class="icon book"></span>Reports</a>';
if($id != null)
{
$this->path .= '|<a href="reporting.php?report='.$report_name.'" class="button"><span class="icon clock"></span>'.$report_name.'</a>';
}
}
}
示例4: pathinfo
kick(1, $data, 7);
}
if( $data['char'] == '' || $data['char'] == null || !is_array($data['char']) || count($data['char']) <= 0 )
{
kick(1, $data, 8);
}
//if it's all okay data:
//get the image name
$fn = pathinfo( $_FILES['image']['name'] );
$svFn = time() . "." . $fn['extension'];
//get the image destination
$cat = Category::getByID($data['cat'][0]);
$cats = array($cat);
while( $cat )
{
$cat = $cat->getParent();
if( $cat )
{
array_push($cats, $cat);
}
}
$cats = array_reverse($cats);
$dest = "";
foreach( $cats as $cat )
示例5: getParent
public function getParent()
{
return $this->fields["SubBoard"] == "yes" ? Board::getByID($this->fields["Parent"]) : Category::getByID($this->fields["Parent"]);
}
示例6: __construct
function __construct($user, $elementID, $data, $con)
{
parent::__construct($user, Category::getByID(intval($elementID)), $data, $con);
}
示例7: handlePostRequest
public static function handlePostRequest()
{
$data = static::getRequestData();
// create Content object
$Content = new CMS_BlogPost();
$Content->Title = $data['Title'];
$Content->save();
// create text ContentItem object
$ContentItem = new CMS_RichTextContent();
$ContentItem->ContentID = $Content->ID;
$ContentItem->Data = $data['Data'];
$ContentItem->save();
// create CategoryItem object foreach
if (is_array($data['Categories']) && count($data['Categories'])) {
foreach ($data['Categories'] as $cat) {
$Category = Category::getByID($cat);
$CategoryItem = new CategoryItem();
$CategoryItem->ContextClass = 'CMS_BlogPost';
$CategoryItem->ContextID = $Content->ID;
$CategoryItem->CategoryID = $Category->ID;
$CategoryItem->save();
}
}
// create TagItem object foreach. if Tag object doesn't exist, create as well
if (is_array($data['Tags']) && count($data['Tags'])) {
foreach ($data['Tags'] as $word) {
$Tag = Tag::getFromHandle($word, true);
// second boolean is telling method to make the Tag object for us if it doesn't exist
$TagItem = new TagItem();
$TagItem->ContextClass = 'CMS_BlogPost';
$TagItem->ContextID = $Content->ID;
$TagItem->TagID = $Tag->ID;
$TagItem->save();
}
}
return static::respondCRUD($Content, 'singular', 'created');
}
示例8: __get
public function __get($var)
{
if( $var == 'ingredients' )
{
return Ingredient::getByItem($this->itemid);
}
elseif( $var == 'recommendations' )
{
return Ingredient::getRecommendedByItem($this->itemid);
}
elseif( $var == 'characteristics' )
{
return Characteristic::getByItem($this->itemid);
}
elseif( $var == 'category' )
{
return Category::getByID($this->categoryid);
}
elseif( $var == 'price' )
{
return money_format('%i', $this->price);
}
else
{
return $this->$var;
}
}
示例9: AdminPage
<?php
require_once './config.php';
$page = new AdminPage();
$category = new Category(['Settings' => $page->settings]);
$id = 0;
// Set the current action.
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
switch ($action) {
case 'submit':
$ret = $category->update($_POST["id"], $_POST["status"], $_POST["description"], $_POST["disablepreview"], $_POST["minsize"]);
header("Location:" . WWW_TOP . "/category-list.php");
break;
case 'view':
default:
if (isset($_GET["id"])) {
$page->title = "Category Edit";
$id = $_GET["id"];
$cat = $category->getByID($id);
$page->smarty->assign('category', $cat);
}
break;
}
$page->smarty->assign('status_ids', array(Category::STATUS_ACTIVE, Category::STATUS_INACTIVE, Category::STATUS_DISABLED));
$page->smarty->assign('status_names', array('Yes', 'No', 'Disabled'));
$page->content = $page->smarty->fetch('category-edit.tpl');
$page->render();
示例10: isset
$cat = isset($_GET['cat']) ? $_GET['cat'] : -1;
$tmpl->code = -1;
if( $cat == -1 )
{
$tmpl->cats = Category::getTopLevel();
$tmp->categoryid = -1;
if( $tmpl->cats instanceof Category )
{
$tmpl->cats = array( $tmpl->cats );
}
}
else
{
$tmp = Category::getByID($cat);
$num = $tmp->number;
$tmpl->prev = Category::getByNumber(preg_replace('#\.[\d]+$#','',$num));
$tmpl->cats = Category::getByParent($cat);
if( $tmpl->cats instanceof Category )
{
$tmpl->items = Item::getByCategory($tmpl->cats->categoryid);
}
else
{
$tmpl->items = Item::getByCategory($cat);
}
if( $tmpl->items instanceof Item )
{
$tmpl->items = array( $tmpl->items );