本文整理汇总了PHP中SJB_System::getSystemsettings方法的典型用法代码示例。如果您正苦于以下问题:PHP SJB_System::getSystemsettings方法的具体用法?PHP SJB_System::getSystemsettings怎么用?PHP SJB_System::getSystemsettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SJB_System
的用法示例。
在下文中一共展示了SJB_System::getSystemsettings方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$tp = SJB_System::getTemplateProcessor();
$bannersObj = new SJB_Banners();
$action = SJB_Request::getVar('action');
if (isset($action)) {
$groupID = SJB_Request::getVar('groupID');
switch ($action) {
case 'add':
if ($groupID == '') {
SJB_FlashMessages::getInstance()->addWarning('EMPTY_VALUE', array('fieldCaption' => 'Group ID'));
break;
}
$result = $bannersObj->addBannerGroup($groupID);
if ($result === false) {
SJB_FlashMessages::getInstance()->addWarning('ERROR_ADD_BANNER_GROUP');
break;
}
$site_url = SJB_System::getSystemsettings('SITE_URL') . "/manage-banner-groups/";
header("Location: {$site_url}");
break;
}
}
$tp->display("add_banner_group.tpl");
}
示例2: execute
public function execute()
{
$templateProcessor = SJB_System::getTemplateProcessor();
$errors = array();
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$gateway_id = isset($_REQUEST['gateway']) ? $_REQUEST['gateway'] : null;
$formSubmitted = SJB_Request::getVar('submit');
$gateway_sid = SJB_PaymentGatewayManager::getSIDByID($gateway_id);
if ($_SERVER['REQUEST_METHOD'] == 'GET' && !empty($action)) {
if ($action == 'deactivate') {
SJB_PaymentGatewayManager::deactivateByID($gateway_id);
} elseif ($action == 'activate') {
SJB_PaymentGatewayManager::activateByID($gateway_id);
}
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$gateway = SJB_PaymentGatewayManager::createObjectByID($gateway_id, $_REQUEST);
$gateway->dontSaveProperty('id');
$gateway->dontSaveProperty('caption');
$gateway->setSID($gateway_sid);
if ($gateway->isValid()) {
if (SJB_PaymentGatewayManager::saveGateway($gateway) !== false) {
$templateProcessor->assign('gatewaySaved', true);
if ($formSubmitted == 'save_gateway') {
$siteUrl = SJB_System::getSystemsettings('SITE_URL') . '/system/payment/gateways/?gatewaySaved=1';
SJB_HelperFunctions::redirect($siteUrl);
}
} else {
$errors['SETTINGS_SAVED_WITH_PROBLEMS'] = 1;
}
} else {
$errors = $gateway->getErrors();
}
}
$gateway = SJB_PaymentGatewayManager::getObjectByID($gateway_id);
$gateway_form = new SJB_Form($gateway);
$gateway_form->registerTags($templateProcessor);
$gateway_form->makeDisabled('id');
$gateway_form->makeDisabled('caption');
$countryCode = $gateway->getPropertyValue('country');
if (empty($countryCode)) {
$countryValue = SJB_CountriesManager::getCountrySIDByCountryCode('US');
$gateway->setPropertyValue('country', $countryValue);
}
if (empty($gateway)) {
$errors['GATEWAY_NOT_FOUND'] = 1;
$templateProcessor->assign('errors', $errors);
$templateProcessor->display('configure_gateway.tpl');
return;
}
$gateway_info = SJB_PaymentGatewayManager::getInfoBySID($gateway_sid);
$form_fields = $gateway_form->getFormFieldsInfo();
$templateProcessor->assign('gateway', $gateway_info);
$templateProcessor->assign('form_fields', $form_fields);
$templateProcessor->assign('errors', $errors);
$templateProcessor->display('configure_gateway.tpl');
}
示例3: execute
public function execute()
{
$templateProcessor = SJB_System::getTemplateProcessor();
$listingSid = isset($_REQUEST['listing_id']) ? $_REQUEST['listing_id'] : null;
$listing = SJB_ListingManager::getObjectBySID($listingSid);
if (!is_null($listing) && !$listing->isActive()) {
$listingInfo = SJB_ListingManager::getListingInfoBySID($listingSid);
$productInfo = !empty($listingInfo['product_info']) ? unserialize($listingInfo['product_info']) : array();
if (isset($listingInfo['complete']) && $listingInfo['complete'] == 1 && $listingInfo['checkouted'] == 1) {
$subTotalPrice = 0;
// проверить истек ли листинг, если истек , прайс прировнять к renewal_price
if (SJB_ListingManager::getIfListingHasExpiredBySID($listing->getID()) && isset($productInfo['renewal_price'])) {
$subTotalPrice = $productInfo['renewal_price'];
}
$userSid = $listing->getUserSID();
$productSid = $productInfo['product_sid'];
$listingTitle = $listing->getProperty('Title')->getValue();
$listingTypeSid = $listing->getListingTypeSID();
$listingTypeId = SJB_ListingTypeManager::getListingTypeIDBySID($listingTypeSid);
$newProductName = "Reactivation of \"{$listingTitle}\" {$listingTypeId}";
$newProductInfo = SJB_ShoppingCart::createInfoForCustomProduct($userSid, $productSid, $listingSid, $subTotalPrice, $newProductName, 'activateListing');
if ($subTotalPrice <= 0) {
if (SJB_ListingManager::activateListingBySID($listing->getSID())) {
SJB_Notifications::sendUserListingActivatedLetter($listing, $listing->getUserSID());
}
} else {
SJB_ShoppingCart::createCustomProduct($newProductInfo, $userSid);
$shoppingUrl = SJB_System::getSystemSettings('SITE_URL') . '/shopping-cart/';
SJB_HelperFunctions::redirect($shoppingUrl);
}
$templateProcessor->assign('listingTypeID', SJB_ListingTypeManager::getListingTypeIDBySID($listingTypeSid));
} elseif ($listingInfo['checkouted'] == 0) {
$productsInfoFromShopppingCart = SJB_ShoppingCart::getProductsInfoFromCartByProductSID($productInfo['product_sid'], $listing->getUserSID());
if (empty($productsInfoFromShopppingCart)) {
$productInfoToShopCart = SJB_ProductsManager::getProductInfoBySID($productInfo['product_sid']);
$productInfo['number_of_listings'] = 1;
$productObj = new SJB_Product($productInfoToShopCart, $productInfoToShopCart['product_type']);
$productObj->setNumberOfListings($productInfoToShopCart['number_of_listings']);
$productInfoToShopCart['price'] = $productObj->getPrice();
SJB_ShoppingCart::addToShoppingCart($productInfoToShopCart, $listing->getUserSID());
}
SJB_HelperFunctions::redirect(SJB_System::getSystemsettings('SITE_URL') . '/shopping-cart/');
} else {
$errors['LISTING_IS_NOT_COMPLETE'] = 1;
}
} elseif (is_null($listingSid)) {
$errors['INVALID_LISTING_ID'] = 1;
} elseif (!is_null($listing) && $listing->isActive()) {
$errors['LISTING_ALREADY_ACTIVE'] = 1;
} else {
$errors['WRONG_LISTING_ID_SPECIFIED'] = 1;
}
$templateProcessor->assign("errors", isset($errors) ? $errors : null);
$templateProcessor->display("pay_for_listing.tpl");
}
示例4: getSiteUrl
/**
* Get site URL
*
* @return string
*/
public static function getSiteUrl()
{
$siteUrl = SJB_System::getSystemSettings('USER_SITE_URL');
if (!empty($siteUrl)) {
return $siteUrl;
}
$siteUrl = SJB_System::getSystemsettings('SITE_URL');
$siteUrl = str_replace('/admin/', '', $siteUrl);
$siteUrl = str_replace('/admin', '', $siteUrl);
return $siteUrl;
}
示例5: execute
public function execute()
{
$bannersObj = new SJB_Banners();
$errors = array();
$tp = SJB_System::getTemplateProcessor();
if (isset($_REQUEST['action'])) {
$action_name = $_REQUEST['action'];
$params = $_REQUEST;
switch ($action_name) {
case 'delete_banner_group':
$result = $bannersObj->deleteBannerGroup($params['groupSID']);
if ($result === false) {
$errors[] = 'ERROR_DELETING_BANNER_GROUP';
}
break;
}
$site_url = SJB_System::getSystemsettings('SITE_URL') . '/manage-banner-groups/';
header("Location: {$site_url}");
}
$bannerGroups = $bannersObj->getAllBannerGroups();
$tp->assign('errors', $errors);
$tp->assign('bannerGroups', $bannerGroups);
$tp->display('manage_banner_groups.tpl');
}
示例6: execute
public function execute()
{
$tp = SJB_System::getTemplateProcessor();
$bannersObj = new SJB_Banners();
$errors = array();
$groupSID = SJB_Request::getVar('groupSID', false);
$form_submitted = SJB_Request::getVar('submit');
if (isset($_REQUEST['action'])) {
$action_name = $_REQUEST['action'];
$params = $_REQUEST;
switch ($action_name) {
case 'edit':
if ($params['groupID'] == '') {
$errors[] = 'GROUP_ID_MISMATCHED';
}
if ($groupSID === false) {
$errors[] = 'BANNER_GROUP_SID_NOT_DEFINED';
}
if ($errors) {
break;
}
$result = $bannersObj->updateBannerGroup($params['groupSID'], $params['groupID'], $params['number_banners_display_at_once']);
if ($result === false) {
$errors[] = 'ERROR_UPDATE_BANNER_GROUP';
break;
}
if ($form_submitted == 'save_banner') {
$site_url = SJB_System::getSystemsettings('SITE_URL') . '/manage-banner-groups/';
SJB_HelperFunctions::redirect($site_url);
}
break;
case 'delete_banner':
if (!isset($params['bannerId'])) {
$banners_sids = SJB_Request::getVar('banners', false);
if (count($banners_sids) > 0) {
$keys = array_keys($banners_sids);
$groupSID = $bannersObj->getBannerGroupSIDByBannerSID($keys[0]);
foreach ($banners_sids as $b_sid => $keys) {
$deleteBanner = $bannersObj->deleteBanner($b_sid);
if ($deleteBanner === false) {
$errors[] = $bannersObj->bannersError;
}
}
}
} else {
$groupSID = $bannersObj->getBannerGroupSIDByBannerSID($params['bannerId']);
$deleteBanner = $bannersObj->deleteBanner($params['bannerId']);
if ($deleteBanner === false) {
$errors[] = $bannersObj->bannersError;
break;
}
}
$site_url = SJB_System::getSystemsettings('SITE_URL') . '/edit-banner-group/?groupSID=' . $groupSID;
SJB_HelperFunctions::redirect($site_url);
break;
case 'activate':
$banners_sids = SJB_Request::getVar('banners', false);
if ($banners_sids) {
$keys = array_keys($banners_sids);
$groupSID = $bannersObj->getBannerGroupSIDByBannerSID($keys[0]);
foreach ($banners_sids as $b_sid => $keys) {
$deleteBanner = $bannersObj->updateActiveStatus($b_sid, true);
if ($deleteBanner === false) {
$errors[] = 'Can\'t activate banner. ID: ' . $b_sid;
}
}
}
break;
case 'deactivate':
$banners_sids = SJB_Request::getVar('banners', false);
if ($banners_sids) {
$keys = array_keys($banners_sids);
$groupSID = $bannersObj->getBannerGroupSIDByBannerSID($keys[0]);
foreach ($banners_sids as $b_sid => $keys) {
$deleteBanner = $bannersObj->updateActiveStatus($b_sid, false);
if ($deleteBanner === false) {
$errors[] = 'Can\'t deactivate banner. ID: ' . $b_sid;
}
}
}
break;
case 'approve':
$banners_sids = SJB_Request::getVar('banners', false);
if ($banners_sids) {
$keys = array_keys($banners_sids);
$groupSID = $bannersObj->getBannerGroupSIDByBannerSID($keys[0]);
foreach ($banners_sids as $b_sid => $keys) {
$bannerInfo = $bannersObj->getBannerProperties($b_sid);
$contractSID = !empty($bannerInfo['contract_sid']) ? $bannerInfo['contract_sid'] : false;
$approveBanner = $bannersObj->updateStatus($b_sid, 'approved');
if ($approveBanner === false) {
$errors[] = 'Can\'t approved banner. ID: ' . $b_sid;
} else {
$bannersObj->updateActiveStatus($b_sid, true);
if ($contractSID) {
SJB_ContractManager::updateExpirationPeriod($contractSID);
}
}
}
}
//.........这里部分代码省略.........
示例7: execute
//.........这里部分代码省略.........
if ($params['link'] == '' && $params['bannerType'] != 'code') {
$errors[] = 'Banner link mismatched!';
}
if ($params['bannerType'] == 'code' && $params['code'] == '') {
$errors[] = 'Banner code is empty.';
}
if ($params['bannerType'] == 'file' && $_FILES['image']['name'] == '' && empty($params['imagePath'])) {
$errors[] = 'No image attached!';
}
if ($_FILES['image']['name'] && $_FILES['image']['error']) {
$errors[SJB_UploadFileManager::getErrorId($_FILES['image']['error'])] = 1;
}
if ($errors) {
break;
}
// if image changed - save it
if ($_FILES['image']['name'] != '' && $_FILES['image']['tmp_name'] != '') {
$hashName = md5(time() * $_FILES['image']['size'] . "_" . $_FILES['image']['name']);
$ext = preg_match("|\\.(\\w{3})\\b|", $_FILES['image']['name'], $arr);
$bannerFilePath = $filesDir . "banners/" . $hashName . "." . $arr[1];
// move file from temporary folder, and fill banner info to DB
$copy = copy($_FILES['image']['tmp_name'], $bannerFilePath);
if (!$copy) {
$errors = 'Cannot copy file from TMP dir to Banners Dir';
break;
}
if ($_FILES['image']['type'] != 'application/x-shockwave-flash') {
// array of bannerInfo
// [0] - width
// [1] - height
// [2] - ??
// [3] - width & height in next view: width="104" height="150"
// [bits] - bit size of image
// [channels]
// [mime] - type, (image/jpeg, image/gif, image/png )
$bannerInfo = getimagesize($bannerFilePath);
if ($params['width'] != '' && $params['height'] != '') {
$sx = $params['width'];
$sy = $params['height'];
} else {
$sx = $bannerInfo[0];
$sy = $bannerInfo[1];
}
$type = $bannerInfo['mime'];
} else {
if ($params['width'] == '' || $params['height'] == '') {
$errors[] = 'SIZE_PARAMETER_MISMATCHED';
break;
}
$sx = $params['width'];
$sy = $params['height'];
$type = $_FILES['image']['type'];
}
$bannerFilePath = "/" . str_replace("../", "/", str_replace(SJB_BASE_DIR, '', $bannerFilePath));
// now delete old banner image
$bannersObj->deleteBannerImage($bannerId);
} else {
// if image not changed - leave it as is
$bannerOldInfo = $bannersObj->getBannerProperties($params['bannerId']);
$sx = $bannerOldInfo['width'];
$sy = $bannerOldInfo['height'];
if ($params['width'] != '' && $params['height'] != '') {
if ($params['width'] != $sx || $params['height'] != $sy) {
$sx = $params['width'];
$sy = $params['height'];
}
}
$type = $bannerOldInfo['type'];
$bannerFilePath = $bannerOldInfo['image_path'];
}
$title = $params['title'];
$link = $params['link'];
$active = $params['active'];
$group = $params['groupSID'];
// check 'link' for correct. If it hasn't 'http://' or 'https://' - add them
$expr = preg_match("/^(https?:\\/\\/)/", $link);
if ($expr != true && $params['bannerType'] != 'code') {
$link = "http://" . $link;
}
if ($params['bannerType'] == 'code') {
$bannersObj->deleteBannerImage($bannerId);
}
$result = $bannersObj->updateBanner($params['bannerId'], $title, $link, $bannerFilePath, $sx, $sy, $type, $active, $group, $params);
if ($form_submitted == 'save_banner') {
$site_url = SJB_System::getSystemsettings('SITE_URL') . "/edit-banner-group/?groupSID={$group}";
} else {
$site_url = SJB_System::getSystemsettings('SITE_URL') . "/edit-banner/?bannerId=" . $bannerId;
}
SJB_HelperFunctions::redirect($site_url);
break;
}
}
$banner_fields = $bannersObj->getBannersMeta();
$tp->assign("banner_fields", $banner_fields);
$tp->assign("banner", $banner);
$tp->assign('errors', $errors);
$tp->assign('bannersPath', SJB_Banners::getSiteUrl());
$tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
$tp->display("edit_banner.tpl");
}
示例8: execute
//.........这里部分代码省略.........
$params['sy'] = $sy;
$params['banner_group_sid'] = $group;
$productInfo['banner_info'] = $params;
break;
}
if (!$errors) {
$numberOfListings = SJB_Request::getVar('number_of_listings');
$extraInfo = SJB_ProductsManager::getProductExtraInfoBySID($productSID);
if (!empty($extraInfo['pricing_type']) && $extraInfo['pricing_type'] == 'volume_based' && $numberOfListings) {
$productInfo['number_of_listings'] = $numberOfListings;
$productObj = new SJB_Product($productInfo, $productInfo['product_type']);
$number_of_listings = !empty($productInfo['number_of_listings']) ? $productInfo['number_of_listings'] : 1;
$productObj->setNumberOfListings($number_of_listings);
$productInfo['price'] = $productObj->getPrice();
}
if (SJB_UserManager::isUserLoggedIn()) {
SJB_ShoppingCart::addToShoppingCart($productInfo, $current_user->getSID());
} else {
if (isset($_SESSION['products'])) {
foreach ($_SESSION['products'] as $addedProduct) {
$addedProductInfo = unserialize($addedProduct['product_info']);
if ($addedProductInfo['user_group_sid'] != $productInfo['user_group_sid']) {
$errors[] = 'You are trying to add products of different User Groups in your Shopping Cart. You сan add only products belonging to one User Group. If you want to add this product in the Shopping Cart please go back to the Shopping Cart and remove products of other User Groups.';
break;
}
}
}
if (!$errors) {
$id = time();
$_SESSION['products'][$id]['product_info'] = serialize($productInfo);
$_SESSION['products'][$id]['sid'] = $id;
$_SESSION['products'][$id]['user_sid'] = 0;
}
}
if (!$errors) {
SJB_HelperFunctions::redirect(SJB_System::getSystemsettings('SITE_URL') . '/shopping-cart/');
}
}
}
}
if (!empty($productInfo['expiration_period']) && !is_numeric($productInfo['expiration_period'])) {
$productInfo['period'] = ucwords($productInfo['expiration_period']);
} elseif (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based' && !empty($productInfo['volume_based_pricing'])) {
$volumeBasedPricing = $productInfo['volume_based_pricing'];
$price = array();
$firstPrice = 0;
if (!empty($volumeBasedPricing['listings_range_from'])) {
for ($i = 1; $i <= count($volumeBasedPricing['listings_range_from']); $i++) {
if ($volumeBasedPricing['listings_range_from'][$i] == $volumeBasedPricing['listings_range_to'][$i]) {
$price[$i]['range']['from'] = $volumeBasedPricing['listings_range_from'][$i];
} else {
$price[$i]['range']['from'] = $volumeBasedPricing['listings_range_from'][$i];
$price[$i]['range']['to'] = $volumeBasedPricing['listings_range_to'][$i];
}
$price[$i]['price'] = $volumeBasedPricing['price_per_unit'][$i];
if ($i > 1 && $firstPrice > $volumeBasedPricing['price_per_unit'][$i]) {
$price[$i]['savings'] = round(100 - 100 / $firstPrice * $volumeBasedPricing['price_per_unit'][$i]);
} else {
$firstPrice = $volumeBasedPricing['price_per_unit'][$i];
}
}
}
$productInfo['volume_based_pricing'] = $price;
$minListings = min($volumeBasedPricing['listings_range_from']);
$maxListings = max($volumeBasedPricing['listings_range_to']);
$countListings = array();
for ($i = $minListings; $i <= $maxListings; $i++) {
$countListings[] = $i;
}
$productInfo['count_listings'] = $countListings;
} elseif (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'fixed') {
$productInfo['fixed_period'] = 1;
}
if ($productInfo['product_type'] == 'banners') {
$params = $_REQUEST;
$bannersObj = new SJB_Banners();
$banner_fields = $bannersObj->getBannersMeta();
foreach ($banner_fields as $key => $banner_field) {
$banner_fields[$banner_field['id']] = $banner_field;
if (!empty($params[$banner_field['id']])) {
$banner_fields[$banner_field['id']]['value'] = $params[$banner_field['id']];
}
unset($banner_fields[$key]);
}
if (!empty($params['errors'])) {
$tp->assign("errors", $params['errors']);
}
$tp->assign("banner_fields", $banner_fields);
}
$userGroupID = SJB_UserGroupDBManager::getUserGroupIDBySID($productInfo['user_group_sid']);
$tp->assign('productInfo', $productInfo);
$tp->assign('userGroupID', $userGroupID);
$tp->assign('productSID', $productSID);
$tp->assign('mayChooseProduct', true);
}
$tp->assign('errors', $errors);
break;
}
$tp->display($template);
}
示例9: proceedToCheckout
/**
* @param int $currentUserID
* @param int $productSID
* @return bool|int|mixed
*/
public function proceedToCheckout($currentUserID, $productSID)
{
$errors = array();
$productInfo = SJB_ProductsManager::getProductInfoBySID($productSID);
if (SJB_UserManager::isUserLoggedIn()) {
$numberOfListings = SJB_ListingDBManager::getNumberOfCheckoutedListingsByProductSID($productSID, $currentUserID);
$extraInfo = SJB_ProductsManager::getProductExtraInfoBySID($productSID);
$shoppingCartProducts = SJB_ShoppingCart::getProductsInfoFromCartByProductSID($productSID, $currentUserID);
if (!empty($shoppingCartProducts)) {
if ($productInfo['product_type'] == 'mixed_product' || isset($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'fixed') {
if ($numberOfListings / (count($shoppingCartProducts) * $productInfo['number_of_listings']) > 1) {
SJB_ShoppingCart::addToShoppingCart($productInfo, $currentUserID);
}
}
if (isset($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based') {
if ($numberOfListings / (count($shoppingCartProducts) * end($productInfo['volume_based_pricing']['listings_range_to'])) > 1) {
$productInfo['number_of_listings'] = 1;
$productObj = new SJB_Product($productInfo, $productInfo['product_type']);
$productObj->setNumberOfListings($productInfo['number_of_listings']);
$productInfo['price'] = $productObj->getPrice();
SJB_ShoppingCart::addToShoppingCart($productInfo, $currentUserID);
} else {
foreach ($shoppingCartProducts as $shoppingCartProduct) {
$unserializedProductInfoFromShopCart = unserialize($shoppingCartProduct['product_info']);
if ($unserializedProductInfoFromShopCart['number_of_listings'] < end($unserializedProductInfoFromShopCart['volume_based_pricing']['listings_range_to'])) {
$unserializedProductInfoFromShopCart['number_of_listings'] += 1;
SJB_ShoppingCart::updateItemBySID($shoppingCartProduct['sid'], $unserializedProductInfoFromShopCart);
break;
}
}
}
}
} else {
if (!empty($extraInfo['pricing_type']) && $extraInfo['pricing_type'] == 'volume_based') {
$productInfo['number_of_listings'] = 1;
$productObj = new SJB_Product($productInfo, $productInfo['product_type']);
$productObj->setNumberOfListings($productInfo['number_of_listings']);
$productInfo['price'] = $productObj->getPrice();
}
SJB_ShoppingCart::addToShoppingCart($productInfo, $currentUserID);
}
} else {
$products = SJB_Session::getValue('products');
if (isset($products)) {
foreach ($products as $addedProduct) {
$addedProductInfo = unserialize($addedProduct['product_info']);
if ($addedProductInfo['user_group_sid'] != $productInfo['user_group_sid']) {
$errors[] = 'You are trying to add products of different User Groups in your Shopping Cart. You сan add only products belonging to one User Group. If you want to add this product in the Shopping Cart please go back to the Shopping Cart and remove products of other User Groups.';
break;
}
}
}
if (!$errors) {
$id = time();
$products[$id]['product_info'] = serialize($productInfo);
$products[$id]['sid'] = $id;
$products[$id]['user_sid'] = 0;
SJB_Session::setValue('products', $products);
}
}
if (!$errors) {
SJB_HelperFunctions::redirect(SJB_System::getSystemsettings('SITE_URL') . '/shopping-cart/');
}
}
示例10: execute
public function execute()
{
$tp = SJB_System::getTemplateProcessor();
$bannersObj = new SJB_Banners();
$filesDir = SJB_System::getSystemSettings('FILES_DIR');
// set null values, to initialize
$errors = array();
$groupSID = SJB_Request::getVar('groupSID', false);
$params = $_REQUEST;
if (isset($_REQUEST['action'])) {
$action_name = $_REQUEST['action'];
switch ($action_name) {
case 'add':
// ERRORS
if ($params['title'] == '') {
$errors[] = 'Banner Title is empty.';
}
if ($params['link'] == '' && $params['bannerType'] != 'code') {
$errors[] = 'Banner link mismatched!';
}
if ($params['bannerType'] == 'code' && $params['code'] == '') {
$errors[] = 'Banner code is empty.';
}
if ($_FILES['image']['name'] == '' && $params['bannerType'] == 'file') {
$errors[] = 'No image attached!';
}
if ($_FILES['image']['name'] && $_FILES['image']['error']) {
$errors[SJB_UploadFileManager::getErrorId($_FILES['image']['error'])] = 1;
}
if ($errors) {
break;
}
// ok. All input fields presented
$title = $params['title'];
$link = $params['link'];
// check 'link' for correct. If it hasn't 'http://' or 'https://' and bannerType != code - add them
$expr = preg_match("/^(https?:\\/\\/)/", $link);
if ($expr != true && $params['bannerType'] != 'code') {
$link = 'http://' . $link;
}
if ($params['bannerType'] == 'file') {
// make filename
preg_match("|\\.(\\w{3})\\b|u", $_FILES['image']['name'], $arr);
$fileName = preg_replace("|\\.(\\w{3})\\b|u", '', $_FILES['image']['name']);
$hashName = md5(time() * $_FILES['image']['size']) . '_' . $fileName;
$bannerFilePath = $filesDir . 'banners/' . $hashName . '.' . $arr[1];
// move file from temporary folder, and fill banner info to DB
$copy = copy($_FILES['image']['tmp_name'], $bannerFilePath);
if (!$copy) {
$errors[] = 'Cannot copy file from TMP dir to Banners Dir';
break;
}
if ($_FILES['image']['type'] != 'application/x-shockwave-flash') {
// array of bannerInfo
// [0] - width
// [1] - height
// [2] - ??
// [3] - width & height in next view: width="104" height="150"
// [bits] - bit size of image
// [channels]
// [mime] - type, (image/jpeg, image/gif, image/png )
$bannerInfo = getimagesize($bannerFilePath);
if ($params['width'] != '' && $params['height'] != '') {
$sx = $params['width'];
$sy = $params['height'];
} else {
$sx = $bannerInfo[0];
$sy = $bannerInfo[1];
}
$type = $bannerInfo['mime'];
} else {
if ($params['width'] == '' || $params['height'] == '') {
$errors[] = 'SIZE_PARAMETER_MISMATCHED';
break;
}
$sx = $params['width'];
$sy = $params['height'];
$type = $_FILES['image']['type'];
}
$active = $params['active'];
$group = $params['groupSID'];
$bannerFilePath = '/' . str_replace('../', '/', str_replace(SJB_BASE_DIR, '', $bannerFilePath));
} else {
$sx = $params['width'];
$sy = $params['height'];
$type = '';
$active = $params['active'];
$group = $params['groupSID'];
$bannerFilePath = '';
}
$bannersObj->addBanner($title, $link, $bannerFilePath, $sx, $sy, $type, $active, $group, $params);
$site_url = SJB_System::getSystemsettings('SITE_URL') . "/edit-banner-group/?groupSID={$groupSID}";
header("Location: {$site_url}");
break;
}
}
$banner_fields = $bannersObj->getBannersMeta();
$bannerGroup = $bannersObj->getBannerGroupBySID($groupSID);
$tp->assign('params', $params);
$tp->assign('errors', $errors);
//.........这里部分代码省略.........