CBlogPost :: PreparePath: Bitrix method

      
<?php 
//  CBlogPost :: PreparePath()
//  /dist/bitrix/modules/blog/general/blog_post.php:554

    
public static function PreparePath($blogUrl$postID 0$siteID False$is404 True$userID 0$groupID 0)
    {
        
$blogUrl Trim($blogUrl);
        
$postID IntVal($postID);
        
$groupID IntVal($groupID);
        
$userID IntVal($userID);

        if (!
$siteID)
        {
            
$siteID SITE_ID;
        }

        
$dbPath CBlogSitePath::GetList(array(), array("SITE_ID"=>$siteID));
        while (
$arPath $dbPath->Fetch())
        {
            if (
strlen($arPath["TYPE"]) > 0)
            {
                
$arPaths[$arPath["TYPE"]] = $arPath["PATH"];
            }
            else
            {
                
$arPaths["OLD"] = $arPath["PATH"];
            }
        }

        if(
$postID 0)
        {
            if(
$groupID 0)
            {
                if(
strlen($arPaths["H"])>0)
                {
                    
$result str_replace("#blog#"$blogUrl$arPaths["H"]);
                    
$result str_replace("#post_id#"$postID$result);
                    
$result str_replace("#user_id#"$userID$result);
                    
$result str_replace("#group_id#"$groupID$result);
                }
                elseif(
strlen($arPaths["G"])>0)
                {
                    
$result str_replace("#blog#"$blogUrl$arPaths["G"]);
                    
$result str_replace("#user_id#"$userID$result);
                    
$result str_replace("#group_id#"$groupID$result);
                }
            }
            elseif(
strlen($arPaths["P"])>0)
            {
                
$result str_replace("#blog#"$blogUrl$arPaths["P"]);
                
$result str_replace("#post_id#"$postID$result);
                
$result str_replace("#user_id#"$userID$result);
            }
            elseif(
strlen($arPaths["B"])>0)
            {
                
$result str_replace("#blog#"$blogUrl$arPaths["B"]);
                
$result str_replace("#user_id#"$userID$result);
            }
            else
            {
                if(
$is404)
                    
$result htmlspecialcharsbx($arPaths["OLD"])."/".htmlspecialcharsbx($blogUrl)."/".$postID.".php";
                else
                    
$result htmlspecialcharsbx($arPaths["OLD"])."/post.php?blog=".$blogUrl."&post_id=".$postID;
            }
        }
        else
        {
            if(
strlen($arPaths["B"])>0)
            {
                
$result str_replace("#blog#"$blogUrl$arPaths["B"]);
                
$result str_replace("#user_id#"$userID$result);
            }
            else
            {
                if(
$is404)
                    
$result htmlspecialcharsbx($arPaths["OLD"])."/".htmlspecialcharsbx($blogUrl)."/";
                else
                    
$result htmlspecialcharsbx($arPaths["OLD"])."/post.php?blog=".$blogUrl;
            }
        }

        return 
$result;
    }