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;
 }
Example #2
0
     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;
Example #3
0
		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>';
				}
			}
		}
Example #4
0
		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 )
Example #5
0
 public function getParent()
 {
     return $this->fields["SubBoard"] == "yes" ? Board::getByID($this->fields["Parent"]) : Category::getByID($this->fields["Parent"]);
 }
Example #6
0
 function __construct($user, $elementID, $data, $con)
 {
     parent::__construct($user, Category::getByID(intval($elementID)), $data, $con);
 }
 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');
 }
Example #8
0
		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;
			}
		}
Example #9
0
<?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();
Example #10
0
	
	$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 );