本文整理汇总了PHP中gallery::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP gallery::getInstance方法的具体用法?PHP gallery::getInstance怎么用?PHP gallery::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gallery
的用法示例。
在下文中一共展示了gallery::getInstance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tag_ItemList
/**
* Display list of items associated with page and of specified type
*
* @param array $tag_params
* @param array $children
*/
public function tag_ItemList($tag_params, $children, $type)
{
$manager = UserPageItemsManager::getInstance();
$page_id = isset($tag_params['page']) ? fix_id($tag_params['page']) : null;
// create query conditions
$conditions = array();
if (!is_null($page_id)) {
$conditions['page'] = $page_id;
}
$conditions['type'] = $type;
// get items from database
$items = $manager->getItems(array('id', 'item'), $conditions);
if ($type == user_page::VIDEO) {
// create template
$template = $this->loadTemplate($tag_params, 'page_items_video.xml');
// connect tag handlers
if (class_exists('youtube')) {
$module = youtube::getInstance();
$template->registerTagHandler('_video', $module, 'tag_Video');
}
} else {
// create template
$template = $this->loadTemplate($tag_params, 'page_items_gallery.xml');
// connect tag handlers
if (class_exists('gallery')) {
$module = gallery::getInstance();
$template->registerTagHandler('_gallery', $module, 'tag_Group');
}
}
// parse items
if (count($items) > 0) {
foreach ($items as $item) {
$params = array('item' => $item->item, 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('user_pages_items_delete', 400, $this->getLanguageConstant('title_delete_page'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'page_items_delete'), array('id', $item->id)))));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
}
示例2: import_from_file
/**
* Import items from uploaded file.
*/
private function import_from_file()
{
global $db, $site_path;
$gallery = gallery::getInstance();
$gallery_manager = GalleryManager::getInstance();
$languages = Language::getLanguages(false);
$item_manager = ShopItemManager::getInstance();
$category_manager = ShopCategoryManager::getInstance();
$property_manager = \Modules\Shop\Property\Manager::getInstance();
$membership_manager = \ShopItemMembershipManager::getInstance();
// load categories
$categories = array();
$raw_categories = $category_manager->getItems($category_manager->getFieldNames(), array());
if (count($raw_categories) > 0) {
foreach ($raw_categories as $category) {
$categories[$category->id] = $category->title[self::DEFAULT_LANGUAGE];
}
}
// load existing items
$existing_items = array();
$items = $item_manager->getItems(array('id', 'uid'), array());
foreach ($items as $item) {
$existing_items[$item->uid] = $item->id;
}
// load existing images
$existing_images = array();
$images = $gallery_manager->getItems(array('group', 'text_id', 'id'), array());
if (count($images) > 0) {
foreach ($images as $image) {
// make sure we have storage array
if (!array_key_exists($image->group, $existing_images)) {
$existing_images[$image->group] = array();
}
// add image to the list
$existing_images[$image->group][$image->id] = $image->text_id;
}
}
$image_list = scandir(_BASEPATH . '/' . $site_path . 'import/');
// load csv file
$csv_data = $this->load_csv_file($_FILES['import']['tmp_name']);
array_shift($csv_data);
// remove header
$number_to_import = isset($_REQUEST['number_to_import']) && !empty($_REQUEST['number_to_import']) ? fix_id($_REQUEST['number_to_import']) : count($csv_data);
$counter = 0;
foreach ($csv_data as $row) {
// make sure we are within our limits
if (++$counter > $number_to_import) {
break;
}
// get item name and description
$item_name = array_fill(0, count($languages), '');
$item_name = array_combine($languages, $item_name);
$item_description = $item_name;
$item_name['he'] = $db->escape_string($row[self::COL_NAME_HE]);
$item_name['ru'] = $db->escape_string($row[self::COL_NAME_RU]);
$item_description['he'] = $db->escape_string($row[self::COL_DESCRIPTION_HE]);
$item_description['ru'] = $db->escape_string($row[self::COL_DESCRIPTION_RU]);
// unpack price values
$prices = explode(',', $row[self::COL_PRICE]);
$price_names = explode(',', $row[self::COL_SIZE_LABELS]);
// generate uid and check if item exists in database
$uid = hash('sha256', 'item_' . $row[self::COL_ID]);
if (array_key_exists($uid, $existing_items)) {
$data = array('name' => $item_name, 'description' => $item_description, 'price' => count($prices) > 0 ? floatval($prices[0]) : 0);
$item_id = $existing_items[$uid];
$item_manager->updateData($data, array('id' => $item_id));
$gallery_id = $item_manager->getItemValue('gallery', array('id' => $item_id));
} else {
// prepare data
$data = array('name' => $item_name, 'description' => $item_description, 'price' => count($prices) > 0 ? floatval($prices[0]) : 0, 'colors' => '', 'tax' => 0, 'weight' => 0, 'manufacturer' => 0, 'uid' => $uid);
// store author of the uploaded item
$data['author'] = $_SESSION['uid'];
// create item gallery
$gallery_id = $gallery->createGallery($item_name);
$data['gallery'] = $gallery_id;
// add item to the database
$item_manager->insertData($data);
$item_id = $item_manager->getInsertedID();
}
// remove existing prices
$property_manager->deleteData(array('item' => $item_id, 'text_id' => array('operator' => 'LIKE', 'value' => 'price_%')));
// create price properties
if (count($prices) > 1) {
// generate default name
$price_name = array_fill(0, count($languages), '');
$price_name = array_combine($languages, $price_name);
for ($i = 1; $i < count($prices); $i++) {
// set and reset specified name
if (isset($price_names[$i])) {
$price_name[self::DEFAULT_LANGUAGE] = $price_names[$i];
} else {
$price_name[self::DEFAULT_LANGUAGE] = '';
}
// prepare data for insertion
$price_data = array('item' => $item_id, 'name' => $price_name, 'text_id' => 'price_' . $this->size_names[$i - 1], 'type' => 'decimal', 'value' => serialize(floatval($prices[$i])));
// insert new price property
$property_manager->insertData($price_data);
//.........这里部分代码省略.........
示例3: tag_ManufacturerList
/**
* Handle drawing list of manufacturers tag
*
* @param array $tag_params
* @param array $children
*/
public function tag_ManufacturerList($tag_params, $children)
{
$manager = ShopManufacturerManager::getInstance();
$conditions = array();
$selected = -1;
if (class_exists('gallery')) {
$use_images = true;
$gallery = gallery::getInstance();
$gallery_manager = GalleryManager::getInstance();
} else {
$use_images = false;
}
if (isset($tag_params['selected'])) {
$selected = fix_id($tag_params['selected']);
}
$items = $manager->getItems($manager->getFieldNames(), $conditions);
$template = $this->_parent->loadTemplate($tag_params, 'manufacturer_list_item.xml');
if (count($items) > 0) {
foreach ($items as $item) {
// get image
$image = '';
if ($use_images && !empty($item->logo)) {
$image_item = $gallery_manager->getSingleItem($gallery_manager->getFieldNames(), array('id' => $item->logo));
if (is_object($image_item)) {
$image = $gallery->getImageURL($image_item);
}
}
// prepare parameters
$params = array('id' => $item->id, 'name' => $item->name, 'web_site' => $item->web_site, 'logo' => $image, 'selected' => $selected == $item->id ? 1 : 0, 'item_change' => url_MakeHyperlink($this->_parent->getLanguageConstant('change'), window_Open('shop_manufacturer_change', 360, $this->_parent->getLanguageConstant('title_manufacturer_change'), true, true, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'manufacturers'), array('sub_action', 'change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->_parent->getLanguageConstant('delete'), window_Open('shop_manufacturer_delete', 400, $this->_parent->getLanguageConstant('title_manufacturer_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'manufacturers'), array('sub_action', 'delete'), array('id', $item->id)))));
// parse template
$template->setLocalParams($params);
$template->restoreXML();
$template->parse();
}
}
}
示例4: json_GetItem
/**
* Handle request for JSON object
*/
public function json_GetItem()
{
$uid = isset($_REQUEST['uid']) ? fix_chars($_REQUEST['uid']) : null;
$manager = ShopItemManager::getInstance();
// prepare result
$result = array('error' => false, 'error_message' => '', 'item' => array());
if (!is_null($uid)) {
// create conditions
$conditions = array('uid' => $uid, 'deleted' => 0, 'visible' => 1);
$item = $manager->getSingleItem($manager->getFieldNames(), $conditions);
if (is_object($item)) {
// get item image url
$thumbnail_url = null;
if (class_exists('gallery')) {
$gallery = gallery::getInstance();
$thumbnail_url = $gallery->getGroupThumbnailURL($item->gallery);
}
$rating = 0;
$result['item'] = array('id' => $item->id, 'uid' => $item->uid, 'name' => $item->name, 'description' => $item->description, 'gallery' => $item->gallery, 'views' => $item->views, 'price' => $item->price, 'tax' => $item->tax, 'weight' => $item->weight, 'votes_up' => $item->votes_up, 'votes_down' => $item->votes_down, 'rating' => $rating, 'priority' => $item->priority, 'timestamp' => $item->timestamp, 'thumbnail' => $thumbnail_url);
} else {
// there was a problem with reading item from database
$result['error'] = true;
$result['error_message'] = $this->_parent->getLanguageConstant('message_error_getting_item');
}
} else {
// invalid ID was specified
$result['error'] = true;
$result['error_message'] = $this->_parent->getLanguageConstant('message_error_invalid_id');
}
// create JSON object and print it
define('_OMIT_STATS', 1);
print json_encode($result);
}
示例5: tag_CategoryList
/**
* Tag handler for category list
*
* @param array $tag_params
* @param array $children
*/
public function tag_CategoryList($tag_params, $children)
{
global $language;
$manager = ShopCategoryManager::getInstance();
$conditions = array();
$order_by = array();
$order_asc = true;
$item_category_ids = array();
$item_id = isset($tag_params['item_id']) ? fix_id($tag_params['item_id']) : null;
// create conditions
if (isset($tag_params['parent_id'])) {
// set parent from tag parameter
$conditions['parent'] = fix_id($tag_params['parent_id']);
} else {
if (isset($tag_params['parent'])) {
// get parent id from specified text id
$text_id = fix_chars($tag_params['parent']);
$parent = $manager->getSingleItem(array('id'), array('text_id' => $text_id));
if (is_object($parent)) {
$conditions['parent'] = $parent->id;
} else {
$conditions['parent'] = -1;
}
} else {
if (!isset($tag_params['show_all'])) {
$conditions['parent'] = 0;
}
}
}
if (isset($tag_params['level'])) {
$level = fix_id($tag_params['level']);
} else {
$level = 0;
}
if (isset($tag_params['exclude'])) {
$list = fix_id(explode(',', $tag_params['exclude']));
$conditions['id'] = array('operator' => 'NOT IN', 'value' => $list);
}
if (!is_null($item_id)) {
$membership_manager = ShopItemMembershipManager::getInstance();
$membership_items = $membership_manager->getItems(array('category'), array('item' => $item_id));
if (count($membership_items) > 0) {
foreach ($membership_items as $membership) {
$item_category_ids[] = $membership->category;
}
}
}
// get order list
if (isset($tag_params['order_by'])) {
$order_by = fix_chars(split(',', $tag_params['order_by']));
} else {
$order_by = array('title_' . $language);
}
if (isset($tag_params['order_ascending'])) {
$order_asc = $tag_params['order_asc'] == '1' or $tag_params['order_asc'] == 'yes';
} else {
// get items from database
$items = $manager->getItems($manager->getFieldNames(), $conditions, $order_by, $order_asc);
}
// create template handler
$template = $this->_parent->loadTemplate($tag_params, 'category_list_item.xml');
$template->registerTagHandler('_children', $this, 'tag_CategoryList');
// initialize index
$index = 0;
// parse template
if (count($items) > 0) {
foreach ($items as $item) {
$image_url = '';
$thumbnail_url = '';
if (class_exists('gallery')) {
$gallery = gallery::getInstance();
$gallery_manager = GalleryManager::getInstance();
$image = $gallery_manager->getSingleItem(array('filename'), array('id' => $item->image));
if (!is_null($image)) {
$image_url = $gallery->getImageURL($image);
$thumbnail_url = $gallery->getThumbnailURL($image);
}
}
$params = array('id' => $item->id, 'index' => $index++, 'item_id' => $item_id, 'parent' => $item->parent, 'image_id' => $item->image, 'image' => $image_url, 'thumbnail' => $thumbnail_url, 'text_id' => $item->text_id, 'title' => $item->title, 'description' => $item->description, 'level' => $level, 'in_category' => in_array($item->id, $item_category_ids) ? 1 : 0, 'selected' => isset($tag_params['selected']) ? fix_id($tag_params['selected']) : 0, 'item_change' => url_MakeHyperlink($this->_parent->getLanguageConstant('change'), window_Open('shop_category_change', 400, $this->_parent->getLanguageConstant('title_category_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'categories'), array('sub_action', 'change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->_parent->getLanguageConstant('delete'), window_Open('shop_category_delete', 270, $this->_parent->getLanguageConstant('title_category_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'categories'), array('sub_action', 'delete'), array('id', $item->id)))), 'item_add' => url_MakeHyperlink($this->_parent->getLanguageConstant('add'), window_Open('shop_category_add', 400, $this->_parent->getLanguageConstant('title_category_add'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'categories'), array('sub_action', 'add'), array('parent', $item->id)))));
$template->restoreXML();
$template->setLocalParams($params);
$template->parse();
}
}
}
示例6: json_LinkList
/**
* Create JSON object containing links with specified characteristics
*/
private function json_LinkList()
{
define('_OMIT_STATS', 1);
$groups = array();
$conditions = array();
$limit = isset($tag_params['limit']) ? fix_id($tag_params['limit']) : null;
$order_by = isset($tag_params['order_by']) ? explode(',', fix_chars($tag_params['order_by'])) : array('id');
$order_asc = isset($tag_params['order_asc']) && $tag_params['order_asc'] == 'yes' ? true : false;
$grouped = isset($_REQUEST['grouped']) && $_REQUEST['grouped'] == 'yes' ? true : false;
$manager = LinksManager::getInstance();
$group_manager = LinkGroupsManager::getInstance();
$membership_manager = LinkMembershipManager::getInstance();
if (isset($_REQUEST['group'])) {
$group_list = explode(',', fix_chars($_REQUEST['group']));
$list = $group_manager->getItems(array('id'), array('name' => $group_list));
if (count($list) > 0) {
foreach ($list as $list_item) {
$groups[] = $list_item->id;
}
}
}
if (isset($_REQUEST['group_id'])) {
$groups = array_merge($groups, fix_id(explode(',', $_REQUEST['group_id'])));
}
if (isset($_REQUEST['sponsored'])) {
$sponsored = $_REQUEST['sponsored'] == 'yes' ? 1 : 0;
$conditions['sponsored'] = $sponsored;
}
// fetch ids for specified groups
if (!empty($groups)) {
$list = $membership_manager->getItems(array('link'), array('group' => $groups));
$id_list = array();
if (count($list) > 0) {
foreach ($list as $list_item) {
$id_list[] = $list_item->link;
}
} else {
// in case no members of specified group were found, ensure no items are retrieved
$id_list = '-1';
}
$conditions['id'] = $id_list;
}
// save some CPU time by getting this early
if (class_exists('gallery')) {
$use_images = true;
$gallery = gallery::getInstance();
$gallery_manager = GalleryManager::getInstance();
} else {
$use_images = false;
}
$items = $manager->getItems($manager->getFieldNames(), $conditions, $order_by, $order_asc, $limit);
$result = array('error' => false, 'error_message' => '', 'items' => array());
if (count($items) > 0) {
foreach ($items as $item) {
$result['items'][] = array('id' => $item->id, 'text' => $item->text, 'url' => $item->url, 'redirect_url' => url_Make('redirect', $this->name, array('id', $item->id)), 'external' => $item->external, 'sponsored' => $item->sponsored, 'display_limit' => $item->display_limit, 'sponsored_clicks' => $item->sponsored_clicks, 'total_clicks' => $item->total_clicks, 'image' => null);
}
} else {
}
print json_encode($result);
}
示例7: json_AddItemToCart
/**
* Add item to shopping cart using JSON request
*/
private function json_AddItemToCart()
{
$uid = fix_chars($_REQUEST['uid']);
$properties = isset($_REQUEST['properties']) ? fix_chars($_REQUEST['properties']) : array();
$cart = isset($_SESSION['shopping_cart']) ? $_SESSION['shopping_cart'] : array();
$variation_id = $this->generateVariationId($uid, $properties);
// try to get item from database
$manager = ShopItemManager::getInstance();
$item = $manager->getSingleItem($manager->getFieldNames(), array('uid' => $uid));
// default result is false
$result = null;
if (is_object($item)) {
if (array_key_exists($uid, $cart)) {
// update existing item count
$cart[$uid]['quantity']++;
} else {
// add new item to shopping cart
$cart[$uid] = array('uid' => $uid, 'quantity' => 1, 'variations' => array());
}
if (!array_key_exists($variation_id, $cart[$uid]['variations'])) {
$cart[$uid]['variations'][$variation_id] = $properties;
$cart[$uid]['variations'][$variation_id]['count'] = 0;
}
// increase count in case it already exists
$cart[$uid]['variations'][$variation_id]['count'] += 1;
// get item image url
$thumbnail_url = null;
if (class_exists('gallery')) {
$gallery = gallery::getInstance();
$thumbnail_url = $gallery->getGroupThumbnailURL($item->gallery);
}
// prepare result
$result = array('name' => $item->name, 'weight' => $item->weight, 'price' => $item->price, 'tax' => $item->tax, 'image' => $thumbnail_url, 'count' => $cart[$uid]['variations'][$variation_id]['count'], 'variation_id' => $variation_id);
// update shopping cart
$_SESSION['shopping_cart'] = $cart;
}
Events::trigger('shop', 'shopping-cart-changed');
print json_encode($result);
}