/** * */ function onAction() { global $application; $request = $application->getInstance('Request'); $mode = $request->getValueByKey('mode'); if (!$mode && modApiFunc('Session', 'is_Set', 'SupportMode')) { modApiFunc('Session', 'un_Set', 'SupportMode'); } else { $_mode = explode("|", $mode); $mode = modApiFunc('Session', 'is_Set', 'SupportMode') ? modApiFunc('Session', 'get', 'SupportMode') : ASC_S_DISABLE; foreach ($_mode as $flag) { if (Validator::isValidInt($flag)) { $mode |= $flag; } elseif (defined($flag)) { $mode |= constant($flag); } } if ($mode == ASC_S_DISABLE) { if (modApiFunc('Session', 'is_Set', 'SupportMode')) { modApiFunc('Session', 'un_Set', 'SupportMode'); } } else { modApiFunc('Session', 'set', 'SupportMode', $mode); } } }
function initSource() { $type = modApiFunc('Request', 'getValueByKey', 'type'); if ($type == "robot") { $id = modApiFunc('Request', 'getValueByKey', 'id'); //$date = modApiFunc('Request','getValueByKey','date'); $this->__source->setParams('id', $id); //$this->__source->setParams('date', $date); } else { parent::initSource(); $seance_id = modApiFunc('Request', 'getValueByKey', 'sid'); if (Validator::isValidInt($seance_id) == true) { $this->__source->setParams('seance_ids', array($seance_id)); } } }
function outputReportRows() { $x = 0; $y = 1; $field_list = $this->__report_settings->getColumnList(); foreach ($this->__report_settings->getReportData() as $row_data) { $x = 0; foreach ($field_list as $field) { $value = isset($row_data[$field]) ? $row_data[$field] : ''; if (Validator::isValidInt($value) or Validator::isValidFloat($value)) { $this->__excel->writeNumber($y, $x, $value); } else { $this->__excel->writeLabel($y, $x, $value); } $x++; } $y++; } }
function check() { $this->errors = array(); if (empty($this->id)) { $this->errors[] = GC_E_FIELD_ID; } if (empty($this->code)) { $this->errors[] = GC_E_FIELD_CODE; } if (empty($this->to)) { $this->errors[] = GC_E_FIELD_TO; } if (empty($this->from)) { $this->errors[] = GC_E_FIELD_FROM; } if (Validator::isValidFloat($this->amount) == false || $this->amount < 0.01) { $this->errors[] = GC_E_FIELD_AMOUNT; } if (!preg_match('/^[0-9\\.]+$/', $this->amount)) { $this->errors[] = GC_E_FIELD_AMOUNT_SEPARATOR; } $this->amount = floor($this->amount * 100) / 100; if (Validator::isValidFloat($this->remainder) == false || $this->remainder < 0) { $this->errors[] = GC_E_FIELD_REMAINDER; } $this->remainder = floor($this->remainder * 100) / 100; if ($this->remainder > $this->amount) { $this->errors[] = GC_E_AMOUNT_LESS_REMAINDER; } if (Validator::isValidInt($this->date_created) == false) { $this->errors[] = GC_E_FIELD_DATE_CREATED; } if ($this->sendtype != GC_SENDTYPE_EMAIL && $this->sendtype != GC_SENDTYPE_POST) { $this->errors[] = GC_E_FIELD_SENDTYPE; } if ($this->status != GC_STATUS_ACTIVE && $this->status != GC_STATUS_BLOCKED && $this->status != GC_STATUS_PENDING) { $this->errors[] = GC_E_FIELD_STATUS; } if ($this->sendtype == GC_SENDTYPE_EMAIL && !Validator::isValidEmail($this->email)) { $this->errors[] = GC_E_FIELD_EMAIL; } if ($this->sendtype == GC_SENDTYPE_POST) { if (empty($this->fname)) { $this->errors[] = GC_E_FIELD_FNAME; } if (empty($this->lname)) { $this->errors[] = GC_E_FIELD_LNAME; } if (empty($this->address)) { $this->errors[] = GC_E_FIELD_ADDRESS; } if (empty($this->city)) { $this->errors[] = GC_E_FIELD_CITY; } if (empty($this->zip)) { $this->errors[] = GC_E_FIELD_ZIP; } if (empty($this->country_id)) { $this->errors[] = GC_E_FIELD_COUNTRYID; } if (empty($this->state_id)) { $this->errors[] = GC_E_FIELD_STATEID; } } return empty($this->errors); }
/** * @ describe the function ProductList->getTag. */ function getTag($tag) { global $application; $value = null; $CatID = modApiFunc('CProductListFilter', 'getCurrentCategoryId'); switch ($tag) { case 'CurrentCategoryPath': $value = str_replace("/", " >> ", $this->_cats_paths[modApiFunc('CProductListFilter', 'getCurrentCategoryId')]); break; case 'Local_CategoriesBrowser_GoTo': $cb_obj = new CategoriesBrowser(); $this->cb_params['category_path_prefix'] = getMsg('CTL', 'PRFX_TARGET_CATEGORY'); $this->cb_params['buttons'] = array('go' => array('label' => 'BTN_GO', 'callback' => 'OnGoButtonClick(%CID%);', 'default_state' => 'disabled', 'enable_condition' => 'category_selected'), 'cancel' => array('label' => 'BTN_CANCEL', 'callback' => 'hideBlock(\'categories_browser_goto\');', 'default_state' => 'enabled')); $value = $cb_obj->output($this->cb_params); break; case 'Local_CategoriesBrowser_MoveTo': $cb_obj = new CategoriesBrowser(); $this->cb_params['category_path_prefix'] = getMsg('CTL', 'PRFX_TARGET_CATEGORY'); $this->cb_params['buttons'] = array('move' => array('label' => 'BTN_MOVE_PRD', 'callback' => 'OnMoveButtonClick(%CID%);', 'default_state' => 'disabled', 'enable_condition' => 'category_selected'), 'cancel' => array('label' => 'BTN_CANCEL', 'callback' => 'hideBlock(\'categories_browser_moveto\');', 'default_state' => 'enabled')); $value = $cb_obj->output($this->cb_params); break; case 'Local_CategoriesBrowser_CopyTo': $cb_obj = new CategoriesBrowser(); $this->cb_params['category_path_prefix'] = getMsg('CTL', 'PRFX_TARGET_CATEGORY'); $this->cb_params['buttons'] = array('move' => array('label' => 'BTN_COPY_PRD', 'callback' => 'OnCopyButtonClick(%CID%);', 'default_state' => 'disabled', 'enable_condition' => 'category_selected'), 'cancel' => array('label' => 'BTN_CANCEL', 'callback' => 'hideBlock(\'categories_browser_copyto\');', 'default_state' => 'enabled')); $value = $cb_obj->output($this->cb_params); break; case 'ProductListSubcategories': $value = $this->getSubcategoriesList(); break; case 'Breadcrumb': $value = modApiFunc("Breadcrumb", "output", true, "ProductList"); break; case 'Items': $value = $this->getProductList(); break; case 'CategoryName': $categoryInfo = new CCategoryInfo($CatID); $value = $categoryInfo->getCategoryTagValue('name'); break; case 'PaginatorLine': $obj =& $application->getInstance($tag); $value = $obj->output($this->paginator_name, "ProductList"); break; # override the PaginatorRows tag behavior # override the PaginatorRows tag behavior case 'PaginatorRows': $obj =& $application->getInstance($tag); $value = $obj->output($this->paginator_name, 'ProductList'); break; case 'Add_Product_Link': $request = new Request(); // $request->setView ( 'SelectProductType' ); $request->setView('Catalog_AddProduct'); $request->setKey('category_id', $CatID); $value = $request->getURL(); break; case 'Move_Products_Link': $request = new Request(); $request->setView('MoveProducts'); $request->setAction('SetEditableProducts'); $value = $request->getURL(); break; case 'Copy_Products_Link': $request = new Request(); $request->setView('CopyProducts'); $request->setAction('SetEditableProducts'); $value = $request->getURL(); break; case 'Edit_Product_Link': $request = new Request(); $request->setView('Catalog_EditProduct'); $request->setAction('SetCurrentProduct'); $request->setKey('prod_id', ''); $value = $request->getURL(); break; case 'Delete_Products_Link': $request = new Request(); $request->setView('DeleteProducts'); $request->setAction('SetEditableProducts'); $value = $request->getURL(); break; case 'SortProdHref': $request = new Request(); $request->setView('SortProducts'); $value = $request->getURL(); break; case 'ProductsInCatTotal': $value = $this->ProdNumInCat; break; case 'AlertMessage': $MessageResources =& $application->getInstance('MessageResources'); $err_mes = new ActionMessage(array('PRDLST_006')); $value = $MessageResources->getMessage($err_mes); break; case 'SortAlertMessage': if ($this->ProdNumInCat == 0) { $MessageResources =& $application->getInstance('MessageResources'); $err_mes = new ActionMessage(array('PRDLST_007')); $value = $MessageResources->getMessage($err_mes); } elseif ($this->ProdNumInCat == 1) { $MessageResources =& $application->getInstance('MessageResources'); $err_mes = new ActionMessage(array('PRDLST_008')); $value = $MessageResources->getMessage($err_mes); } else { $value = ''; } break; case 'ProductsNumber': $value = $this->_Cat_Info->getCategoryTagValue('productsnumber_non_recursively'); break; case 'ProductsNumberRecursively': $value = $this->_Cat_Info->getCategoryTagValue('productsnumberrecursively') - $this->_Cat_Info->getCategoryTagValue('productsnumber'); break; case 'SubcategoriesNumber': $value = $this->_Cat_Info->getCategoryTagValue('subcategoriesnumber'); break; case 'From': $value = $this->From; break; case 'To': $value = $this->To; break; case 'CategoryStatistics': $value = $this->outputCategoryStatistics(); break; case 'CurrensySign': $value = modApiFunc("Localization", "getCurrencySign"); break; case 'ProductOfflineStatusReason': $prod_status_id = $this->_Current_Product->getProductTagValue('Available', PRODUCTINFO_NOT_LOCALIZED_DATA); $value = $prod_status_id == PRODUCT_STATUS_ONLINE ? getMsg('SYS', "PRODUCT_PARENT_STATUS_ONLINE") : ""; break; case 'ProductOfflineStatusColor': // Offline. // Online, , Offline - . $prod_status_id = $this->_Current_Product->getProductTagValue('Available', PRODUCTINFO_NOT_LOCALIZED_DATA); $value = $prod_status_id == PRODUCT_STATUS_ONLINE ? "rgb(175, 175, 175)" : "#FF0000"; break; case 'ProductCatsCount': $value = count($this->_Current_Product->getCategoriesIDs()); break; case 'ProductCatsList': $_ps = array(); $_cts = $this->_Current_Product->getCategoriesIDs(); foreach ($_cts as $cid) { $_ps[] = $this->_cats_paths[$cid]; } asort($_ps); $_ps = array_map("addslashes", array_map("_ml_htmlentities", $_ps)); $value = implode("<br>", $_ps); break; case 'ProductQuantityInStock': if ($this->_Current_Product->whichStockControlMethod() == PRODUCT_OPTIONS_INVENTORY_TRACKING) { $value = ""; $inv_qty = modApiFunc('Product_Options', 'getQuantityInStockByInventoryTable', 'product', $this->_Current_Product->getProductTagValue('ID')); if (Validator::isValidInt($inv_qty) == true) { $value = $inv_qty . ' ' . modApiFunc('Localization', 'getUnitTypeValue', 'item'); } } else { $value = $this->_Current_Product->getProductTagValue('QuantityInStock', PRODUCTINFO_NOT_LOCALIZED_DATA); if (Validator::isValidInt($value) == true) { $value = $this->_Current_Product->getProductTagValue('QuantityInStock', PRODUCTINFO_LOCALIZED_DATA); } } break; case 'HeaderData': if (empty($this->psf_filter)) { $value = modApiFunc('TmplFiller', 'fill', "catalog/prod_list/", "list-header-category-data.tpl.html", array()); } else { $value = modApiFunc('TmplFiller', 'fill', "catalog/prod_list/", "list-header-searchform-data.tpl.html", array()); } break; case 'SearchFilterData': $value = $this->getSearchFilterDataText(); break; case 'FooterData': if (empty($this->psf_filter)) { $value = modApiFunc('TmplFiller', 'fill', "catalog/prod_list/", "list-footer-category-data.tpl.html", array()); } else { $value = modApiFunc('TmplFiller', 'fill', "catalog/prod_list/", "list-footer-searchform-data.tpl.html", array()); } break; case 'IfSearchFormActive': $value = empty($this->psf_filter) ? '' : 'Y'; break; case 'ProductThumbnail': $value = modApiFunc('TmplFiller', 'fill', 'catalog/prod_list/', 'list_item_image.tpl.html', array()); break; case 'Local_NoImageSrc': $value = $application->getAppIni('URL_IMAGES_DIR') . 'noimage.png'; break; case 'Local_SelectCategoriesProducts': $categorylist = modApiFunc("Catalog", "getSubcategoriesFullListWithParent", 1, false); foreach ($categorylist as $val => $data) { $catvalid = $data["id"]; if ($data['level'] == 2) { $value = '<option value="' . $catvalid . '" ' . ($CatID == $catvalid ? 'selected' : '') . '> ' . $data["name"] . '</option>'; } else { $value = '<option value="' . $catvalid . '" ' . ($CatID == $catvalid ? 'selected' : '') . '>' . $data["name"] . '</option>'; } } break; default: if (_ml_strpos($tag, 'Local_SortBy') === 0) { $tag = _ml_substr($tag, _ml_strlen('Local_SortBy')); $value = $this->getSortLink($tag); break; } if (_ml_strpos($tag, 'Product') === 0) { $tag = _ml_substr($tag, _ml_strlen('Product')); } if (is_object($this->_Current_Product) && $this->_Current_Product->isTagExists($tag)) { $value = $this->_Current_Product->getProductTagValue($tag); } break; } return $value; }
function formatTimeDuration($seconds) { if (Validator::isValidInt($seconds) == false) { return $seconds; } if ($seconds < 60) { return $this->__formatSecondsDuration($seconds); } elseif ($seconds < 3600) { return $this->__formatMinutesDuration($seconds); } else { return $this->__formatHoursDuration($seconds); } }
function __isValidParamValue($group_name, $param_name, $value) { loadCoreFile('validator.php'); $param_info = $this->getParamBaseInfo($group_name, $param_name); $result = false; switch ($param_info['PARAM_TYPE']) { case PARAM_TYPE_FLOAT: $result = Validator::isValidFloat($value); break; case PARAM_TYPE_INT: $result = Validator::isValidInt($value); break; case PARAM_TYPE_LIST: $result = in_array($value, $this->getParamValueList($param_info['GROUP_NAME'], $param_info['PARAM_NAME'])); break; case PARAM_TYPE_STRING: $result = true; break; } if ($result == true) { $validator_class = $param_info['PARAM_VALIDATOR']['CLASS']; $validator_method = $param_info['PARAM_VALIDATOR']['METHOD']; if (!class_exists($validator_class)) { loadClass($validator_class); if (!class_exists($validator_class) or !method_exists($validator_class, $validator_method)) { _fatal(__CLASS__ . '::' . __FUNCTION__ . ":<br>Method <i>{$validator_method}</i> or class <i>{$validator_class}</i> does not exist!"); } } return call_user_func(array($validator_class, $validator_method), $value); } else { return false; } }