static function generate($depth = False) { # Get current Filter string $filter = RawUrlDecode(Get_Query_Var('filter')); if (!empty($filter)) { $str_filter = $filter; } elseif (Is_Singular()) { $str_filter = StrToLower(Get_The_Title()); } else { $str_filter = ''; } # Explode Filter string $arr_current_filter = empty($str_filter) ? array() : PReg_Split('/(?<!^)(?!$)/u', $str_filter); Array_UnShift($arr_current_filter, ''); $arr_filter = array(); # This will be the function result $filter_part = ''; # Check if we are inside a taxonomy archive $taxonomy_term = Is_Tax() ? Get_Queried_Object() : Null; foreach ($arr_current_filter as $filter_letter) { $filter_part .= $filter_letter; $arr_available_filters = self::getFilters($filter_part, $taxonomy_term); if (Count($arr_available_filters) <= 1) { break; } $active_filter_part = MB_SubStr(Implode($arr_current_filter), 0, MB_StrLen($filter_part) + 1); $arr_filter_line = array(); foreach ($arr_available_filters as $available_filter) { $arr_filter_line[$available_filter] = (object) array('filter' => MB_StrToUpper(MB_SubStr($available_filter, 0, 1)) . MB_SubStr($available_filter, 1), 'link' => Post_Type::getArchiveLink($available_filter, $taxonomy_term), 'active' => $active_filter_part == $available_filter, 'disabled' => False); } $arr_filter[] = $arr_filter_line; # Check filter depth limit if ($depth && Count($arr_filter) >= $depth) { break; } } # Run a filter $arr_filter = Apply_Filters('glossary_prefix_filter_links', $arr_filter, $depth); return $arr_filter; }
<?php #------------------------------------------------------------------------------- $Contracts = DB_Select('Contracts', '*', array('Where' => "`TypeID` != 'Public' AND `ProfileID` = 0")); #------------------------------------------------------------------------------- switch (ValueOf($Contracts)) { case 'error': return ERROR | @Trigger_Error(500); case 'exception': echo "Договоры не найдены\n"; break; case 'array': #--------------------------------------------------------------------------- foreach ($Contracts as $Contract) { #------------------------------------------------------------------------- $Profile = DB_Select('Profiles', 'ID', array('UNIQ', 'Where' => SPrintF("`TemplateID` = '%s' AND `Name` LIKE '%%%s%%'", $Contract['TypeID'], MB_SubStr($Contract['CustomerName'], 0, 10)))); if (!Is_Array($Profile)) { #----------------------------------------------------------------------- echo SPrintF("%s - %s\n", $Contract['ID'], $Contract['CustomerName']); #----------------------------------------------------------------------- continue; } #------------------------------------------------------------------------- $IsUpdate = DB_Update('Contracts', array('ProfileID' => $Profile['ID']), array('ID' => $Contract['ID'])); if (Is_Error($IsUpdate)) { return ERROR | @Trigger_Error(500); } } break; default: return ERROR | @Trigger_Error(101);