Items

What does items class do

Functions

Item::getUserClass

Definition

Name
_functionname_
Shorthand
_functionshorthand_
Syntax
_returntype_ = _functionname_( String format [, Mixed timestamp ] );

Description

_description_

Parameters

_var_
_type_ _summary_
Options
_value_
_description_
identifier
_type_ _summary_

Returns

_type_ _returnsummary_

Examples

Uses

PHP
  • _function_
Janitor
  • _function_

Item::getItem

Definition

Name
getItem
Syntax
Array|false = Item::getItem( Array $_options );

Description

getItem() fetches the data of a single Item from the "items" table in the database. It fetches the first Item that matches the criteria defined by the $_options parameter.

It is also possible to extend the fetched Item with more information from the database.

Parameters

$_options
Array Associative array containing search criteria and the option to extend the fetched Item.
Options
id
id of Item to fetch
sindex
sindex of Item to fetch
tags
Match Item by one or more tags. Separate multiple tags with semicolon. Tag(s) can be combined with an itemtype.
itemtype
Match Item by itemtype. Can only be used in combination with one or more tags.
extend
If set, Janitor's Items::extendItem() function is called on the Item. See documentation for extendItem().

Returns

Array Array of item properties or false if no Item is found.

Examples

Ex. 1a: Get Item with unique identifier
$IC = new Items(); $item = $IC->getItem(array("id" => 13));

Get a single Item based on the id 13. Return value:

Array ( [id] => 13 [sindex] => my-post [status] => 1 [itemtype] => post [user_id] => 2 [created_at] => 2018-06-06 18:51:55 [modified_at] => 2018-06-06 18:52:30 [published_at] => 2018-06-06 18:51:55 )
Ex. 1b: Get Item with unique identifier
$IC = new Items(); $item = $IC->getItem(array("sindex" => "my-post"));

Get a single Item based on the sindex "my-post". Return value:

Array ( [id] => 13 [sindex] => my-post [status] => 1 [itemtype] => post [user_id] => 2 [created_at] => 2018-06-06 18:51:55 [modified_at] => 2018-06-06 18:52:30 [published_at] => 2018-06-06 18:51:55 )
Ex. 2a: Get Item via filtering
$IC = new Items(); $item = $IC->getItem(array("tags" => "subject:cats;genre:thriller"));

Get a single Item based on the tags "subject:cats" and "genre:thriller". Return value:

Array ( [id] => 10 [sindex] => my-thriller-about-cats [status] => 1 [itemtype] => post [user_id] => 2 [created_at] => 2018-06-07 13:45:12 [modified_at] => 2018-06-07 13:52:30 [published_at] => 2018-06-07 13:45:12 )
Ex. 2b: Get Item via filtering
$IC = new Items(); $item = $IC->getItem(array("tags" => "subject:cats", "itemtype" => "gallery"));

Get a single Item based on the tag "subject:cats" and the itemtype "gallery". Return value:

Array ( [id] => 9 [sindex] => my-cats-gallery [status] => 1 [itemtype] => post [user_id] => 2 [created_at] => 2018-06-07 13:15:23 [modified_at] => 2018-06-07 13:32:35 [published_at] => 2018-06-07 13:15:23 )
Ex. 3: Get Item and extend it
$IC = new Items(); $item = $IC->getItem(array("id" => 13, "extend" => true));

Get a single Item based on the id 13 and extend it with its itemtype info (which is default for the extendItem() function). Return value:

Array ( [id] => 13 [sindex] => my-post [status] => 1 [itemtype] => post [user_id] => 2 [created_at] => 2018-06-06 18:51:55 [modified_at] => 2018-06-06 18:52:30 [published_at] => 2018-06-06 18:51:55 [item_id] => 13 [name] => My post [classname] => my_custom_CSS_class [description] => A short description of my post [html] => <p>The content of my post</p> )

Uses

Janitor
  • Query

Item::getIdFromSindex

Definition

Name
_functionname_
Shorthand
_functionshorthand_
Syntax
_returntype_ = _functionname_( String format [, Mixed timestamp ] );

Description

_description_

Parameters

_var_
_type_ _summary_
Options
_value_
_description_
identifier
_type_ _summary_

Returns

_type_ _returnsummary_

Examples

Uses

PHP
  • _function_
Janitor
  • _function_

Item::getSimpleType

Definition

Name
_functionname_
Shorthand
_functionshorthand_
Syntax
_returntype_ = _functionname_( String format [, Mixed timestamp ] );

Description

Get item data from items db

Parameters

_var_
_type_ _summary_
Options
_value_
_description_
identifier
_type_ _summary_

Returns

_type_ _returnsummary_

Examples

Uses

PHP
  • _function_
Janitor
  • _function_

Item::getRelatedItems

Definition

Name
_functionname_
Shorthand
_functionshorthand_
Syntax
_returntype_ = _functionname_( String format [, Mixed timestamp ] );

Description

_description_

Parameters

_var_
_type_ _summary_
Options
_value_
_description_
identifier
_type_ _summary_

Returns

_type_ _returnsummary_

Examples

Uses

PHP
  • _function_
Janitor
  • _function_

Item::extendItem

Definition

Name
extendItem
Syntax
Array = Item::extendItem( Array item [, Array $_options ] );

Description

Extend item after already having base information. Defined to be able to limit queries when getting information. Default only gets type data. Optional data.

Parameters

$item
Array Array of an item
$_options
Array Array of extra options
Options
tags
Extend your item with tags
prices
Extend your item with prices
ratings
Extend your item with ratings
comments
Extend your item with comments
everything
Extend your item with tags, prices, ratings, comments

Returns

Array returns array with the full item

Examples

$IC = new Item(); $item = $IC->getItem(array("sindex" => "my_name")); $item = $IC->extendItem($item);

Get an item and then extend it.

Uses

Janitor
  • _function_

Item::extendItems

Definition

Name
_functionname_
Shorthand
_functionshorthand_
Syntax
_returntype_ = _functionname_( String format [, Mixed timestamp ] );

Description

_description_

Parameters

_var_
_type_ _summary_
Options
_value_
_description_
identifier
_type_ _summary_

Returns

_type_ _returnsummary_

Examples

Uses

PHP
  • _function_
Janitor
  • _function_

Item::getItems

Definition

Name
getItems
Syntax
Array = Item::GetItems( Array $_options );

Description

Get all matching items, and put them into an array.

Parameters

$_options
Array Array of options
Options
itemtype
Returns post based on an itemtype
status
Returns items with a status of 1 or 0
tags
Returns all items with specific tag
sindex
Returns items with specific sindex
where
Add additional WHERE sql statement to query
order
Any Sql to order
limit
The amount of items to return
no_readstate
Returns items that current user has not marked at read
user_id
Returns items with given user_id
exclude
Excludes item id's seperated via semi-colons(;) from query
extend
Extend items with itemtype info before returning by using janitor function "Item::extendItem". Documentation for extendItem()

Returns

Array Array of items

Examples

$IC = new Item(); $items = $IC->getItems(array("itemtype" => "post", "status" => 1, "order" => "created_at DESC"));

Get all items with itemtype "post", status 1 (published), and order by created_at date.

$IC = new Item(); $items = $IC->getItems(array("tags" => "javascript", "limit" => 99));

Get all items with tag javascript, but don't get more than 99st.

$IC = new Item(); $items = $IC->getItems(["itemtype" => "people", "where" => "name = peter", "extend" => ["tags" => "true"]]);

Get all items with itemtype "people", where table row "name" has the value "peter" and extend those items with specific itemtype definitions (in this case for "people") and tags.

Uses

Janitor
  • _function_

Item::getNext

Definition

Name
getNext
Syntax
Array = Item::getNext( Number $item_id [, Array $_options ] );

Description

Can receive items array to use for finding next item(s) or receive query syntax to perform getItems request on it own

Parameters

$item_id
Number The id of the item
$_options
Array Array of options
Options
items
Array of item(s)
count
Max number of items

Returns

Array List of next items

Examples

$items = $IC->getItems(array("itemtype" => $itemtype, "status" => 1, "order" => "items.created_at DESC")); $next = $IC->getNext(1, array("items" => $items));

Return Next item array

Array ( [0] => Array ( [id] => 50 [sindex] => new_project [status] => 1 [itemtype] => project [user_id] => [created_at] => 2014-07-28 14:01:40 [modified_at] => 2014-07-28 14:27:01 [published_at] => 2014-07-28 14:01:40 ) )

Uses

Janitor
  • _function_

Item::getPrev

Definition

Name
getPrev
Syntax
Array = Item::getPrev( Number $item_id [, Array $_options ] );

Description

Can receive items array to use for finding previous item(s) or receive query syntax to perform getItems request on its own.

Parameters

$item_id
Number The item id
$_options
Array Array of options
Options
items
Array of item(s)
count
Max number of items

Returns

Array List of previous items

Examples

$items = $IC->getItems(array("itemtype" => $itemtype, "status" => 1, "order" => "items.created_at ASC")); $prev = $IC->getPrev(20, array("items" => $items));

Return previous item array

Array ( [0] => Array ( [id] => 51 [sindex] => this_is_the_new_headline [status] => 1 [itemtype] => project [user_id] => [created_at] => 2014-07-28 14:29:01 [modified_at] => 2014-07-28 14:31:52 [published_at] => 2014-07-28 14:29:01 ) )

Uses

Janitor
  • _function_

Item::paginate

Definition

Name
_functionname_
Shorthand
_functionshorthand_
Syntax
_returntype_ = _functionname_( String format [, Mixed timestamp ] );

Description

_description_

Parameters

_var_
_type_ _summary_
Options
_value_
_description_
identifier
_type_ _summary_

Returns

_type_ _returnsummary_

Examples

Uses

PHP
  • _function_
Janitor
  • _function_

Item::getMediae

Definition

Name
_functionname_
Shorthand
_functionshorthand_
Syntax
_returntype_ = _functionname_( String format [, Mixed timestamp ] );

Description

_description_

Parameters

_var_
_type_ _summary_
Options
_value_
_description_
identifier
_type_ _summary_

Returns

_type_ _returnsummary_

Examples

Uses

PHP
  • _function_
Janitor
  • _function_

Item::sliceMedia

Definition

Name
_functionname_
Shorthand
_functionshorthand_
Syntax
_returntype_ = _functionname_( String format [, Mixed timestamp ] );

Description

_description_

Parameters

_var_
_type_ _summary_
Options
_value_
_description_
identifier
_type_ _summary_

Returns

_type_ _returnsummary_

Examples

Uses

PHP
  • _function_
Janitor
  • _function_

Item::getOwners

Definition

Name
_functionname_
Shorthand
_functionshorthand_
Syntax
_returntype_ = _functionname_( String format [, Mixed timestamp ] );

Description

_description_

Parameters

_var_
_type_ _summary_
Options
_value_
_description_
identifier
_type_ _summary_

Returns

_type_ _returnsummary_

Examples

Uses

PHP
  • _function_
Janitor
  • _function_

Item::getTags

Definition

Name
getTags
Syntax
Array|false = Item::getTags( Array $_options );

Description

Get tag, optionally based on item_id, limited to context, or just check if specific tag exists

Parameters

$_options
Array Array of options
Options
$item_id
Get tag based on $item_id
$tag_id
Get tag based on it's id
context
The tag context.
value
The tag value.

Returns

Array|false Array of tags or false if nothing found.

Examples

$IC = new Item(); $item = $IC->getItem(array("sindex" => "item_name")); $tag = $IC->getTags(array("item" => $item[id]));

Get the tag based on item.

$IC = new Item(); $tag = $IC->getTags(array("context" => "hello"));

Get list of tags with the context of "hello".

$IC = new Item(); $tag = $IC->getTags(array("value" => "javascript"));

Get list of tags with the value of "javascript".

Uses

Janitor
  • Query

Item::getComments

Definition

Name
_functionname_
Shorthand
_functionshorthand_
Syntax
_returntype_ = _functionname_( String format [, Mixed timestamp ] );

Description

_description_

Parameters

_var_
_type_ _summary_
Options
_value_
_description_
identifier
_type_ _summary_

Returns

_type_ _returnsummary_

Examples

Uses

PHP
  • _function_
Janitor
  • _function_

Item::getPrices

Definition

Name
getPrices
Syntax
Array = Item::getPrices( Array $_options );

Description

Get the price of item.

Parameters

$_options
Array Array of options
Options
$item_id
Fetch the price from this item
$country
Get price based on country
currency
Get price based on currency

Returns

Array of prices

Examples

_blank for now

Get price in Euro from $item_id

Uses

Janitor
  • _function_

Item::getSubscriptionMethod

Definition

Name
_functionname_
Shorthand
_functionshorthand_
Syntax
_returntype_ = _functionname_( String format [, Mixed timestamp ] );

Description

_description_

Parameters

_var_
_type_ _summary_
Options
_value_
_description_
identifier
_type_ _summary_

Returns

_type_ _returnsummary_

Examples

Uses

PHP
  • _function_
Janitor
  • _function_