/** * Container list tag handler * * @param array $tag_params * @param array $children */ public function tag_ContainerList($tag_params, $children) { global $language; $manager = GalleryContainerManager::getInstance(); $conditions = array(); $order_by = array('name_' . $language); $order_asc = true; // grab parameters if (isset($tag_params['exclude'])) { $conditions['text_id'] = array('operator' => 'NOT IN', 'value' => fix_chars(explode(',', $tag_params['exclude']))); } $items = $manager->getItems($manager->getFieldNames(), $conditions, $order_by, $order_asc); $template = $this->loadTemplate($tag_params, 'containers_list_item.xml'); $template->registerTagHandler('_image', $this, 'tag_Image'); $template->registerTagHandler('_image_list', $this, 'tag_ImageList'); $template->registerTagHandler('_group', $this, 'tag_Group'); $template->registerTagHandler('_group_list', $this, 'tag_GroupList'); $selected = isset($tag_params['selected']) ? fix_id($tag_params['selected']) : -1; if (count($items) > 0) { foreach ($items as $item) { $params = array('id' => $item->id, 'text_id' => $item->text_id, 'name' => $item->name, 'description' => $item->description, 'image' => $this->getContainerImage($item), 'selected' => $selected, 'item_change' => url_MakeHyperlink($this->getLanguageConstant('change'), window_Open('gallery_containers_change', 400, $this->getLanguageConstant('title_containers_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'containers_change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('gallery_containers_delete', 400, $this->getLanguageConstant('title_containers_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'containers_delete'), array('id', $item->id)))), 'item_groups' => url_MakeHyperlink($this->getLanguageConstant('container_groups'), window_Open('gallery_containers_groups', 400, $this->getLanguageConstant('title_containers_groups'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'containers_groups'), array('id', $item->id))))); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } } }
/** * Return URL for checkout form * @return string */ public function get_url() { return url_Make('direct-checkout', 'paypal'); }
/** * 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(); } } }
/** * Handle rendering list of submissions. * * @param array $tag_params * @param array $children */ public function tag_SubmissionList($tag_params, $children) { $field_manager = ContactForm_FormFieldManager::getInstance(); $submission_manager = ContactForm_SubmissionManager::getInstance(); $submission_field_manager = ContactForm_SubmissionFieldManager::getInstance(); $fields = array(); $conditions = array(); // get parameters $conditions['form'] = -1; if (isset($tag_params['form'])) { $conditions['form'] = fix_id($tag_params['form']); } // load template $template = $this->loadTemplate($tag_params, 'submissions_list_item.xml'); $template->registerTagHandler('cms:fields', $this, 'tag_SubmissionFields'); // get submissions $items = $submission_manager->getItems($submission_manager->getFieldNames(), $conditions); // load field definitions if ($conditions['form'] != -1) { $field_definitions = $field_manager->getItems($field_manager->getFieldNames(), array('form' => $conditions['form'])); if (count($field_definitions) > 0) { foreach ($field_definitions as $field) { $fields[$field->id] = $field; } } } // parse template if (count($items) > 0) { foreach ($items as $item) { // get submitted fields $submitted_data = $submission_field_manager->getItems($submission_field_manager->getFieldNames(), array('submission' => $item->id)); $field_data = array(); if (count($submitted_data) > 0) { foreach ($submitted_data as $record) { $field_data[] = array('submission' => $record->submission, 'field' => $record->field, 'value' => $record->value, 'label' => $fields[$record->field]->label, 'placeholder' => $fields[$record->field]->placeholder, 'type' => $fields[$record->field]->type); } } // prepare timestamps $timestamp = strtotime($item->timestamp); $date = date($this->getLanguageConstant('format_date_short'), $timestamp); $time = date($this->getLanguageConstant('format_time_short'), $timestamp); $params = array('id' => $item->id, 'form' => $item->form, 'timestamp' => $item->timestamp, 'time' => $time, 'date' => $date, 'address' => $item->address, 'fields' => $field_data, 'item_details' => url_MakeHyperlink($this->getLanguageConstant('details'), window_Open('contact_form_submission_details' . $item->id, 400, $this->getLanguageConstant('title_submission_details'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'submission_details'), array('id', $item->id))))); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } } }
/** * Tag handler for tip list * * @param array $tag_params * @param array $children */ public function tag_TipList($tag_params, $children) { $manager = TipManager::getInstance(); $conditions = array(); $limit = null; $order_by = array('id'); $order_asc = true; if (isset($tag_params['only_visible']) && $tag_params['only_visible'] == 1) { $conditions['visible'] = 1; } if (isset($tag_params['order_by'])) { $order_by = explode(',', fix_chars($tag_params['order_by'])); } if (isset($tag_params['order_asc'])) { $order_asc = $tag_params['order_asc'] == '1' || $tag_params['order_asc'] == 'yes'; } if (isset($tag_params['limit'])) { $limit = fix_id($tag_params['limit']); } $template = $this->loadTemplate($tag_params, 'list_item.xml'); $template->setMappedModule($this->name); // get items $items = $manager->getItems($manager->getFieldNames(), $conditions, $order_by, $order_asc, $limit); if (count($items) > 0) { foreach ($items as $item) { $params = array('id' => $item->id, 'content' => $item->content, 'visible' => $item->visible, 'item_change' => url_MakeHyperlink($this->getLanguageConstant('change'), window_Open('tips_change', 400, $this->getLanguageConstant('title_tips_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'tips_change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('tips_delete', 400, $this->getLanguageConstant('title_tips_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'tips_delete'), array('id', $item->id))))); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } } }
/** * Handle drawing list of delivery method prices * * @param array $tag_params * @param array $children */ public function tag_DeliveryPricesList($tag_params, $children) { $manager = ShopDeliveryMethodPricesManager::getInstance(); $conditions = array(); $relations = array(); // prepare filtering conditions if (isset($tag_params['method'])) { $conditions['method'] = fix_id($tag_params['method']); } if (isset($_REQUEST['method'])) { $conditions['method'] = fix_id($_REQUEST['method']); } // get relations with shop item if (isset($tag_params['item'])) { $relations_manager = ShopDeliveryItemRelationsManager::getInstance(); $item_id = fix_id($tag_params['item']); $raw_relations = $relations_manager->getItems(array('price'), array('item' => $item_id)); if (count($raw_relations) > 0) { foreach ($raw_relations as $relation) { $relations[] = $relation->price; } } } // get template $template = $this->_parent->loadTemplate($tag_params, 'delivery_method_prices_list_item.xml'); // get items from database $items = $manager->getItems($manager->getFieldNames(), $conditions); if (count($items) > 0) { foreach ($items as $item) { $params = array('id' => $item->id, 'value' => $item->value, 'method' => isset($conditions['method']) ? $conditions['method'] : 0, 'selected' => in_array($item->id, $relations) ? 1 : 0, 'item_change' => url_MakeHyperlink($this->_parent->getLanguageConstant('change'), window_Open('shop_delivery_price_change', 370, $this->_parent->getLanguageConstant('title_delivery_method_price_change'), true, true, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'delivery_methods'), array('sub_action', 'change_price'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->_parent->getLanguageConstant('delete'), window_Open('shop_delivery_price_delete', 400, $this->_parent->getLanguageConstant('title_delivery_method_price_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'delivery_methods'), array('sub_action', 'delete_price'), array('id', $item->id))))); $template->setLocalParams($params); $template->restoreXML(); $template->parse(); } } }
/** * Tag handler for all questions. * * @param array $tag_params * @param array $children */ public function tag_QuestionList($tag_params, $children) { $manager = QuestionManager::getInstance(); $conditions = array(); // get items from database $items = $manager->getItems($manager->getFieldNames(), $conditions); // load template $template = $this->loadTemplate($tag_params, 'list_item.xml'); if (count($items) > 0) { foreach ($items as $item) { $params = array('id' => $item->id, 'question' => $item->question, 'answer' => $item->answer, 'item_change' => url_MakeHyperlink($this->getLanguageConstant('change'), window_Open('faq_change', 730, $this->getLanguageConstant('title_question_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('faq_delete', 400, $this->getLanguageConstant('title_question_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'delete'), array('id', $item->id))))); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } } }
function window_OpenHyperlink($text, $id, $width, $title, $can_close, $can_minimize, $module, $action) { $url = url_Make('transfer_control', _BACKEND_SECTION_, array('backend_action', $action), array('module', $module)); return url_MakeHyperlink($text, window_Open($id, $width, $title, $can_close, $can_minimize, $url), $text); }
/** * Show list of transactions * * @param array $tag_params * @param array $children */ public function tag_TransactionList($tag_params, $children) { $manager = ShopTransactionsManager::getInstance(); $conditions = array(); // load template $template = $this->_parent->loadTemplate($tag_params, 'transaction_list_item.xml'); // get items from database $items = $manager->getItems($manager->getFieldNames(), $conditions); if (count($items) > 0) { foreach ($items as $item) { $title = $this->_parent->getLanguageConstant('title_transaction_details'); $title .= ' ' . $item->uid; $window = 'shop_transation_details_' . $item->id; $params = array('buyer' => $item->buyer, 'address' => $item->address, 'uid' => $item->uid, 'type' => $item->type, 'type_value' => '', 'status' => $item->status, 'status_value' => '', 'currency' => $item->currency, 'currency_value' => '', 'handling' => $item->handling, 'shipping' => $item->shipping, 'total' => $item->total, 'delivery_method' => $item->delivery_method, 'remark' => $item->remark, 'timestamp' => $item->timestamp, 'item_details' => url_MakeHyperlink($this->_parent->getLanguageConstant('details'), window_Open($window, 800, $title, true, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'transactions'), array('sub_action', 'details'), array('id', $item->id))))); $template->setLocalParams($params); $template->restoreXML(); $template->parse(); } } }
/** * Tag handler for feedback list. * * @param array $tag_params * @param array $children */ public function tag_FeedbackList($tag_params, $children) { $manager = FeedbackManager::getInstance(); $user_manager = UserManager::getInstance(); $conditions = array(); // load template $template = $this->loadTemplate($tag_params, 'list_item.xml'); // get items from the database $items = $manager->getItems($manager->getFieldNames(), $conditions); // parse template if (count($items) > 0) { foreach ($items as $item) { $timestamp = strtotime($item->timestamp); $date = date($this->getLanguageConstant('format_date_short'), $timestamp); $time = date($this->getLanguageConstant('format_time_short'), $timestamp); $user = $user_manager->getSingleItem(array('fullname'), array('id' => $item->user)); $user_name = $item->user; if (is_object($user)) { $user_name = $user->fullname; } $params = array('id' => $item->id, 'user' => $item->user, 'user_name' => $user_name, 'timestamp' => $item->timestamp, 'time' => $time, 'date' => $date, 'message' => $item->message, 'url' => $item->url, 'status' => $item->status, 'item_change' => url_MakeHyperlink($this->getLanguageConstant('change'), window_Open('feedback_change', 430, $this->getLanguageConstant('title_feedback_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'feedback_change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('feedback_delete', 400, $this->getLanguageConstant('title_feedback_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'feedback_delete'), array('id', $item->id))))); $template->setLocalParams($params); $template->restoreXML(); $template->parse(); } } }
/** * Show message for canceled checkout operation * * @param array $tag_params * @param array $children */ public function tag_CanceledMessage($tag_params, $children) { // show message $template = $this->loadTemplate($tag_params, 'checkout_message.xml'); $params = array('message' => $this->getLanguageConstant('message_checkout_canceled'), 'button_text' => $this->getLanguageConstant('button_take_me_back'), 'button_action' => url_Make('', 'home'), 'redirect' => false); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); }
/** * Perform logout procedure */ private function logout_commit() { // change session type to default Session::change_type(); // kill session variables unset($_SESSION['uid']); unset($_SESSION['logged']); unset($_SESSION['level']); unset($_SESSION['username']); unset($_SESSION['fullname']); // get message $message = $this->parent->getLanguageConstant('message_logout_ok'); // get url $url = url_SetRefresh(url_Make('', $this->parent->name), 2); // load template and show the message $template = new TemplateHandler('session_message.xml', $this->parent->path . 'templates/'); $template->setMappedModule($this->parent->name); $params = array('message' => $message, 'redirect_url' => $url); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); }
private function showSettings() { $template = new TemplateHandler('settings.xml', $this->path . 'templates/'); $template->setMappedModule($this->name); $params = array('form_action' => backend_UrlMake($this->name, 'settings_save'), 'cancel_action' => window_Close('tranzila'), 'confirm_url' => url_Make('checkout_completed', 'shop', array('method', 'tranzila')), 'cancel_url' => url_Make('checkout_canceled', 'shop', array('method', 'tranzila'))); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); }
/** * Tag handler for admin lists * * @param array $tag_params * @param array $children */ public function tag_AdminList($tag_params, $children) { $manager = ChatAdminManager::getInstance(); $user_manager = ChatUserManager::getInstance(); $room_manager = ChatRoomManager::getInstance(); $conditions = array(); // if room was specified, print only admins for that room if (isset($tag_params['room']) && !empty($tag_params['room'])) { $room = escape_chars($tag_params['room']); if (is_numeric($room)) { $room_id = $room; } else { $room_id = $room_manger->getItemValue('id', array('text_id' => $room)); } $conditions['room'] = $room_id; } $items = $manager->getItems($manager->getFieldNames(), $conditions, array('user', 'room')); if (isset($tag_params['template'])) { if (isset($tag_params['local']) && $tag_params['local'] == 1) { $template = new TemplateHandler($tag_params['template'], $this->path . 'templates/'); } else { $template = new TemplateHandler($tag_params['template']); } } else { $template = new TemplateHandler('admins_list_item.xml', $this->path . 'templates/'); } if (count($items) > 0) { foreach ($items as $item) { $user = $user_manager->getSingleItem(array('display_name'), array('id' => $item->user)); $room = $room_manager->getSingleItem(array('name'), array('id' => $item->room)); $params = array('id' => $item->id, 'user' => $item->user, 'room' => $item->room, 'display_name' => $user->display_name, 'room_name' => $room->name, 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('chat_admins_delete', 400, $this->getLanguageConstant('title_chat_admins_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'admins_delete'), array('id', $item->id))))); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } } }
/** * Handle drawing item list * * @param array $tag_params * @param array $chilren */ public function tag_ItemList($tag_params, $children) { global $language; $manager = ShopItemManager::getInstance(); $conditions = array(); $page_switch = null; $order_by = array('id'); $order_asc = true; $limit = null; // create conditions if (isset($tag_params['category'])) { if (is_numeric($tag_params['category'])) { $category_id = fix_id($tag_params['category']); } else { // specified id is actually text_id, get real one $category_manager = ShopCategoryManager::getInstance(); $category = $category_manager->getSingleItem(array('id'), array('text_id' => fix_chars($tag_params['category']))); if (!is_object($category)) { return; } $category_id = $category->id; } $membership_manager = ShopItemMembershipManager::getInstance(); $membership_items = $membership_manager->getItems(array('item'), array('category' => $category_id)); $item_ids = array(); if (count($membership_items) > 0) { foreach ($membership_items as $membership) { $item_ids[] = $membership->item; } } if (count($item_ids) > 0) { $conditions['id'] = $item_ids; } else { $conditions['id'] = -1; } // make sure nothing is returned if category is empty } if (isset($tag_params['related'])) { $relation_manager = ShopRelatedItemsManager::getInstance(); $item_id = fix_id($tag_params['related']); $related_items = $relation_manager->getItems(array('related'), array('item' => $item_id)); $related_item_ids = array(); if (count($related_items) > 0) { foreach ($related_items as $relationship) { $related_item_ids[] = $relationship->related; } } if (count($related_item_ids) > 0) { $conditions['id'] = $related_item_ids; } else { $conditions['id'] = -1; } } if (!(isset($tag_params['show_deleted']) && $tag_params['show_deleted'] == 1)) { // force hiding deleted items $conditions['deleted'] = 0; } if (isset($tag_params['filter']) && !empty($tag_params['filter'])) { // filter items with name matching $conditions['name_' . $language] = array('operator' => 'LIKE', 'value' => '%' . fix_chars($tag_params['filter']) . '%'); } if (isset($tag_params['paginate'])) { $per_page = is_numeric($tag_params['paginate']) ? $tag_params['paginate'] : 10; $param = isset($tag_params['page_param']) ? fix_chars($tag_params['page_param']) : null; $item_count = $manager->getItemValue('COUNT(id)', $conditions); $page_switch = new PageSwitch($param); $page_switch->setCurrentAsBaseURL(); $page_switch->setItemsPerPage($per_page); $page_switch->setTotalItems($item_count); // get filter params $limit = $page_switch->getFilterParams(); } if (isset($tag_params['order_by'])) { $order_by = array(fix_chars($tag_params['order_by'])); } // get items $items = $manager->getItems($manager->getFieldNames(), $conditions, $order_by, $order_asc, $limit); // create template $template = $this->_parent->loadTemplate($tag_params, 'item_list_item.xml'); $template->registerTagHandler('_color_list', $this, 'tag_ColorList'); if (count($items) > 0) { $gallery = null; if (class_exists('gallery')) { $gallery = gallery::getInstance(); } $manufacturer_manager = ShopManufacturerManager::getInstance(); foreach ($items as $item) { if (!is_null($gallery)) { // get manufacturer logo $manufacturer_logo_url = ''; if ($item->manufacturer != 0) { $manufacturer = $manufacturer_manager->getSingleItem($manufacturer_manager->getFieldNames(), array('id' => $item->manufacturer)); if (is_object($manufacturer)) { $manufacturer_logo_url = $gallery->getImageURL($manufacturer->logo); } } // get urls for image and thumbnail $image_url = $gallery->getGroupThumbnailURL($item->gallery, true); $thumbnail_url = $gallery->getGroupThumbnailURL($item->gallery); } else { // default values if gallery is not enabled $image_url = ''; $thumbnail_url = ''; $manufacturer_logo_url = ''; } $rating = 0; $params = array('id' => $item->id, 'uid' => $item->uid, 'name' => $item->name, 'description' => $item->description, 'gallery' => $item->gallery, 'size_definition' => $item->size_definition, 'colors' => $item->colors, 'image' => $image_url, 'thumbnail' => $thumbnail_url, 'manufacturer_logo_url' => $manufacturer_logo_url, 'author' => $item->author, 'views' => $item->views, 'price' => $item->price, 'tax' => $item->tax, 'currency' => $this->_parent->settings['default_currency'], 'weight' => $item->weight, 'votes_up' => $item->votes_up, 'votes_down' => $item->votes_down, 'rating' => $rating, 'priority' => $item->priority, 'timestamp' => $item->timestamp, 'visible' => $item->visible, 'deleted' => $item->deleted, 'item_change' => url_MakeHyperlink($this->_parent->getLanguageConstant('change'), window_Open('shop_item_change', 505, $this->_parent->getLanguageConstant('title_item_change'), true, true, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'items'), array('sub_action', 'change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->_parent->getLanguageConstant('delete'), window_Open('shop_item_delete', 400, $this->_parent->getLanguageConstant('title_item_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'items'), array('sub_action', 'delete'), array('id', $item->id))))); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } } // draw page switch if needed if (!is_null($page_switch)) { $params = array(); $children = array(); // pick up parameters from original array foreach ($tag_params as $key => $value) { if (substr($key, 0, 12) == 'page_switch_') { $params[substr($key, 12)] = $value; } } $page_switch->tag_PageSwitch($params, $children); } }
/** * 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); }
/** * Returns absolute image URL * @return string */ private function getImageURL() { $result = url_Make('print_image', $this->name); return $result; }
/** * Handle displaying list of stored currencies * * @param array $tag_params * @param array $children */ public function tag_CurrencyList($tag_params, $children) { $manager = ShopCurrenciesManager::getInstance(); $conditions = array(); $items = $manager->getItems($manager->getFieldNames(), $conditions); // create template $template = $this->_parent->loadTemplate($tag_params, 'currency_list_item.xml'); $template->setMappedModule($this->name); $selected = isset($tag_params['selected']) ? fix_id($tag_params['selected']) : -1; // parse template if (count($items) > 0) { foreach ($items as $item) { $params = $this->getCurrencyForCode($item->currency); $params['selected'] = $selected; // add delete link to params $params['item_delete'] = url_MakeHyperlink($this->_parent->getLanguageConstant('delete'), window_Open('shop_currencies_delete', 270, $this->_parent->getLanguageConstant('title_currencies_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'currencies'), array('sub_action', 'delete'), array('id', $item->id)))); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } } }
/** * Tag handler for affiliate list. * * @param array $tag_params * @param array $children */ public function tag_AffiliateList($tag_params, $children) { $manager = AffiliatesManager::getInstance(); $conditions = array(); // get items from database $items = $manager->getItems($manager->getFieldNames(), $conditions); // load template $template = $this->loadTemplate($tag_params, 'list_item.xml'); // parse template if (count($items) > 0) { foreach ($items as $item) { if ($item->clicks > 0) { $rate = round(100 * $item->conversions / $item->clicks, 2); } else { $rate = 0; } $params = array('id' => $item->id, 'uid' => $item->uid, 'name' => $item->name, 'clicks' => $item->clicks, 'conversions' => $item->conversions, 'rate' => $rate, 'item_change' => url_MakeHyperlink($this->getLanguageConstant('change'), window_Open('affiliates_change', 370, $this->getLanguageConstant('title_affiliates_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'affiliate_change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('affiliates_delete', 400, $this->getLanguageConstant('title_affiliates_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'affiliate_delete'), array('id', $item->id))))); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } } }
/** * 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(); } } }
/** * Tag handler for feed list * * @param array $params * @param array $children */ public function tag_FeedList($params, $children) { $manager = NewsFeedManager::getInstance(); $group_manager = NewsGroupManager::getInstance(); $items = $manager->getItems($manager->getFieldNames(), array()); // create template parser $template = new TemplateHandler('feed_list_item.xml', $this->path . 'templates/'); if (count($items) > 0) { foreach ($items as $item) { $group = $group_manager->getSingleItem(array('title'), array('id' => $item->group)); $params = array('id' => $item->id, 'group' => $item->group, 'news_count' => $item->news_count, 'title' => $item->title, 'group_title' => $group->title, 'description' => $item->description, 'active' => $item->active, 'active_char' => $item->active ? CHAR_CHECKED : CHAR_UNCHECKED, 'item_change' => url_MakeHyperlink($this->getLanguageConstant('change'), window_Open('news_feeds_change', 390, $this->getLanguageConstant('title_news_feed_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'feed_change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('news_feeds_delete', 390, $this->getLanguageConstant('title_news_feed_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'feed_delete'), array('id', $item->id))))); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } } }
/** * Display comment input form * * @param array $tag_params */ private function showInputForm($tag_params) { $module = isset($tag_params['module']) ? fix_chars($tag_params['module']) : null; $section = isset($tag_params['section']) ? fix_chars($tag_params['section']) : null; if (is_null($module) || is_null($section)) { return; } if (isset($tag_params['template'])) { if (isset($tag_params['local']) && $tag_params['local'] == 1) { $template = new TemplateHandler($tag_params['template'], $this->path . 'templates/'); } else { $template = new TemplateHandler($tag_params['template']); } } else { $template = new TemplateHandler('comment_input_form.xml', $this->path . 'templates/'); } $template->setMappedModule($this->name); $params = array('module' => $module, 'section' => $section, 'size_limit' => $this->settings['size_limit'], 'form_action' => url_Make('save_data', $this->name)); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); }
/** * Tag handler for printing code lists * * @param array $params * @param array $children */ public function tag_CodeList($params, $children) { $manager = CodeManager::getInstance(); $conditions = array(); $items = $manager->getItems($manager->getFieldNames(), $conditions, array('id')); $template = new TemplateHandler('list_item.xml', $this->path . 'templates/'); $template->setMappedModule($this->name); if (count($items) > 0) { foreach ($items as $item) { $params = array('id' => $item->id, 'code' => $item->code, 'url' => $item->url, 'item_change' => url_MakeHyperlink($this->getLanguageConstant('change'), window_Open('codes_change', 400, $this->getLanguageConstant('title_codes_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'codes_change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('codes_delete', 400, $this->getLanguageConstant('title_codes_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'codes_delete'), array('id', $item->id)))), 'item_open' => url_MakeHyperlink($this->getLanguageConstant('open'), $item->url, '', '', '_blank')); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } } }
/** * Tag handler for interval list. * * @param array $tag_params * @param array $children */ public function tag_IntervalList($tag_params, $children) { $manager = IntervalManager::getInstance(); $conditions = array(); // get intervals $intervals = $manager->getItems($manager->getFieldNames(), $conditions); // load template $template = $this->loadTemplate($tag_params, 'list_item.xml'); $template->registerTagHandler('cms:days', $this, 'tag_Days'); $template->registerTagHandler('cms:times', $this, 'tag_Times'); // parse template if (count($intervals) > 0) { foreach ($intervals as $interval) { $params = array('id' => $interval->id, 'days' => $interval->days, 'enabled' => $interval->enabled, 'item_change' => url_MakeHyperlink($this->getLanguageConstant('change'), window_Open('delivery_intervals_change', 500, $this->getLanguageConstant('title_interval_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'intervals_change'), array('id', $interval->id)))), 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('delivery_intervals_delete', 400, $this->getLanguageConstant('title_interval_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'intervals_delete'), array('id', $interval->id))))); $template->setLocalParams($params); $template->restoreXML(); $template->parse(); } } }
/** * Handle drawing user list * * @param array $tag_params * @param array $children */ public function tag_UserList($tag_params, $children) { $admin_manager = UserManager::getInstance(); // make sure lower levels can't edit others if ($_SESSION['level'] < 5) { $conditions = array('id' => $_SESSION['uid']); } else { $conditions = array(); } // create template if (isset($tag_params['template'])) { if (isset($tag_params['local']) && $tag_params['local'] == 1) { $template = new TemplateHandler($tag_params['template'], $this->parent->path . 'templates/'); } else { $template = new TemplateHandler($tag_params['template']); } } else { $template = new TemplateHandler('users_list_item.xml', $this->parent->path . 'templates/'); } $template->setMappedModule($this->parent->name); // get users from database $users = $admin_manager->getItems($admin_manager->getFieldNames(), $conditions); // draw users if (count($users) > 0) { foreach ($users as $user) { $params = array('id' => $user->id, 'fullname' => $user->fullname, 'username' => $user->username, 'level' => $user->level, 'verified' => $user->verified, 'verified_char' => $user->verified ? CHAR_CHECKED : CHAR_UNCHECKED, 'agreed' => $user->agreed, 'agreed_char' => $user->agreed ? CHAR_CHECKED : CHAR_UNCHECKED, 'selected' => isset($tag_params['selected']) && $tag_params['selected'] == $user->id, 'item_change' => url_MakeHyperlink($this->parent->getLanguageConstant('change'), window_Open('system_users_change', 370, $this->parent->getLanguageConstant('title_users_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->parent->name), array('backend_action', 'users_change'), array('id', $user->id)))), 'item_delete' => url_MakeHyperlink($this->parent->getLanguageConstant('delete'), window_Open('system_users_delete', 400, $this->parent->getLanguageConstant('title_users_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->parent->name), array('backend_action', 'users_delete'), array('id', $user->id))))); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } } }
/** * Handle JSON request for list of downloads. */ private function json_DownloadsList() { $result = array('error' => false, 'error_message' => '', 'items' => array()); if ($this->checkLicense()) { // valid license or local API requested data $manager = DownloadsManager::getInstance(); $conditions = array(); $items = $manager->getItems($manager->getFieldNames(), $conditions); if (count($items) > 0) { foreach ($items as $item) { $result['items'][] = array('id' => $item->id, 'name' => $item->name, 'description' => $item->description, 'count' => $item->count, 'filename' => $item->filename, 'size' => $item->size, 'visible' => $item->visible, 'timestamp' => $item->timestamp, 'download_url' => url_Make('get', $this->name, array('id', $item->id))); } } } else { // invalid license $result['error'] = true; $result['error_message'] = $this->getLanguageConstant('message_license_error'); } print json_encode($result); }
/** * Handle item size values tag * * @param array $tag_params * @param array $childen */ public function tag_ValueList($tag_params, $children) { $manager = ShopItemSizeValuesManager::getInstance(); $conditions = array(); // create conditions if (isset($tag_params['definition'])) { $conditions['definition'] = fix_id($tag_params['definition']); } // get items from database $items = $manager->getItems($manager->getFieldNames(), $conditions); // create template $template = $this->_parent->loadTemplate($tag_params, 'values_list_item.xml'); $template->setMappedModule($this->name); // parse template if (count($items) > 0) { foreach ($items as $item) { $params = array('id' => $item->id, 'value' => $item->value, 'item_change' => url_MakeHyperlink($this->_parent->getLanguageConstant('change'), window_Open('shop_item_size_values_change', 370, $this->_parent->getLanguageConstant('title_size_value_change'), true, true, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'sizes'), array('sub_action', 'value_change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->_parent->getLanguageConstant('delete'), window_Open('shop_item_size_values_delete', 400, $this->_parent->getLanguageConstant('title_size_value_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'sizes'), array('sub_action', 'value_delete'), array('id', $item->id))))); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } } }
/** * Generate JSON object list for specified parameters */ private function json_ArticleList() { global $language; $manager = ArticleManager::getInstance(); $group_manager = ArticleGroupManager::getInstance(); $admin_manager = UserManager::getInstance(); $conditions = array(); $order_by = array('id'); $order_asc = true; // give the ability to limit number of articles to display if (isset($_REQUEST['limit'])) { $limit = fix_id($_REQUEST['limit']); } else { $limit = null; } // get parameters if (isset($_REQUEST['id'])) { $conditions['id'] = fix_id($_REQUEST['id']); } if (isset($_REQUEST['text_id'])) { $conditions['text_id'] = explode(',', $_REQUEST['text_id']); } if (isset($_REQUEST['order_by'])) { $order_by = explode(',', fix_chars($_REQUEST['order_by'])); } if (isset($_REQUEST['random']) && $_REQUEST['random'] == 1) { $order_by = array('RAND()'); } if (isset($_REQUEST['order_asc'])) { $order_asc = $_REQUEST['order_asc'] == 1 ? true : false; } if (isset($_REQUEST['only_visible']) && $_REQUEST['only_visible'] == 1) { $conditions['visible'] = 1; } if (isset($_REQUEST['group'])) { $group_id_list = array(); $group_names = explode(',', $_REQUEST['group']); if (count($group_names) > 0 && is_numeric($group_names[0])) { // specified group is a number, treat it as group id $group_id_list = $group_names; } else { // get id's from specitifed text_id $groups = $group_manager->getItems($group_manager->getFieldNames(), array('text_id' => $group_names)); if (count($groups) > 0) { foreach ($groups as $group) { $group_id_list[] = $group->id; } } } if (count($group_id_list) > 0) { $conditions['group'] = $group_id_list; } else { $conditions['group'] = -1; } } $all_languages = isset($_REQUEST['all_languages']) && $_REQUEST['all_languages'] == 1; $rating_image_type = isset($_REQUEST['rating_image_type']) ? $_REQUEST['rating_image_type'] : ImageType::Stars; // get items from manager $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) { $timestamp = strtotime($item->timestamp); $date = date($this->getLanguageConstant('format_date_short'), $timestamp); $time = date($this->getLanguageConstant('format_time_short'), $timestamp); $rating_image_url = url_Make('get_rating_image', $this->name, array('type', $rating_image_type), array('id', $item->id)); $result['items'][] = array('id' => $item->id, 'text_id' => $item->text_id, 'timestamp' => $item->timestamp, 'date' => $date, 'time' => $time, 'title' => $all_languages ? $item->title : $item->title[$language], 'author' => $admin_manager->getItemValue('fullname', array('id' => $item->author)), 'visible' => $item->visible, 'views' => $item->views, 'votes_up' => $item->votes_up, 'votes_down' => $item->votes_down, 'rating' => $this->getArticleRating($item, 10), 'rating_image' => $rating_image_url); } } else { // no articles were found for specified cirteria $result['error'] = true; $result['error_message'] = $this->getLanguageConstant('message_json_articles_not_found'); } print json_encode($result); }
/** * 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(); } } }
/** * Handle tag list tag drawing * * @param array $tag_params * @param array $children */ public function tag_WarehouseList($tag_params, $children) { $manager = ShopWarehouseManager::getInstance(); $conditions = array(); $template = $this->_parent->loadTemplate($tag_params, 'warehouse_list_item.xml'); $items = $manager->getItems($manager->getFieldNames(), $conditions); if (count($items) > 0) { foreach ($items as $item) { $params = array('name' => $item->name, 'street' => $item->street, 'street2' => $item->street2, 'city' => $item->city, 'zip' => $item->zip, 'country' => $item->country, 'state' => $item->state, 'item_change' => url_MakeHyperlink($this->_parent->getLanguageConstant('change'), window_Open('shop_warehouse_change', 300, $this->_parent->getLanguageConstant('title_warehouse_change'), true, true, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'warehouses'), array('sub_action', 'change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->_parent->getLanguageConstant('delete'), window_Open('shop_warehouse_delete', 400, $this->_parent->getLanguageConstant('title_warehouse_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'warehouses'), array('sub_action', 'delete'), array('id', $item->id))))); $template->setLocalParams($params); $template->restoreXML(); $template->parse(); } } }