/** * clearly return url property for use * @param [type] $_type type of url you need * @param [type] $_arg an argument for pass into some condition * @return [type] the url value */ public function url($_type = null, $_arg = null) { $tmp_result = null; $myprefix = Protocol . "://"; $mypostfix = '/'; $mytld = router::get_root_domain('tld'); switch ($_type) { // sub domain like 'account' case 'sub': return router::get_sub_domain($_arg); break; case 'path': $myUrl = router::get_url($_arg); if ($_arg == '_') { // filter url to delete disallow characters $myUrl = router::urlfilterer($myUrl); // dont use $ in id $myUrl = str_replace('$', 'dollar', $myUrl); } return $myUrl; break; case 'breadcrumb': $myurl = router::get_url(-1); $breadcrumb = array(); foreach ($myurl as $value) { $tmp_pos = strpos($value, '='); array_push($breadcrumb, $tmp_pos ? substr($value, 0, $tmp_pos) : $value); } return $breadcrumb; break; case 'param': return \lib\utility::get(null, $_arg); break; // domain tld like 'com' // domain tld like 'com' case 'tld': return $mytld; break; // domain name like 'ermile' // domain name like 'ermile' case 'domain': return router::get_root_domain('domain'); break; // domain name except subdomain like 'ermile.com' // domain name except subdomain like 'ermile.com' case 'raw': return router::get_root_domain('domain') . '.' . $mytld; break; // like raw plus http[s]:// domain name except subdomain like 'http://ermile.com/' // like raw plus http[s]:// domain name except subdomain like 'http://ermile.com/' case 'root': return $myprefix . router::get_root_domain() . $mypostfix; break; // use main protocol and give it from config file if not exist use root url // return http or https // use main protocol and give it from config file if not exist use root url // return http or https case 'MainProtocol': if (defined('MainProtocol') && constant('MainProtocol') && is_string(constant('MainProtocol'))) { return constant('MainProtocol'); } else { return 'http'; } break; // use main site and give it from config file if not exist use root url // like raw plus http[s]:// domain name except subdomain like 'http://ermile.com/' // use main site and give it from config file if not exist use root url // like raw plus http[s]:// domain name except subdomain like 'http://ermile.com/' case 'MainSite': if (defined('MainSite') && constant('MainSite') && is_string(constant('MainSite'))) { return constant('MainSite'); } else { return router::get_root_domain() . $mypostfix; } break; // base url for user in base tag with http[s] // base url for user in base tag with http[s] case 'base': return router::$base; break; // full url except get parameter with http[s] // full url except get parameter with http[s] case 'full': return $myprefix . router::get_domain() . '/' . router::get_url(); break; // return module info // return module info case 'module': if ($_arg === 'prefix') { $mymodule = substr(router::get_url(0), 0, -1); } elseif ($_arg == 'array') { $mymodule = router::get_url(-1); } elseif ($_arg == 'cp') { $mymodule = router::get_url(0); switch ($mymodule) { case 'tags': case 'cats': $mymodule = 'terms'; break; case 'pages': $mymodule = 'posts'; break; } } else { $mymodule = router::get_url(0); } return $mymodule; break; case 'child': $mychild = router::get_url(1); if (strrpos($mychild, '=') !== false) { $mychild = substr($mychild, 0, strrpos($mychild, '=')); } if (!$_arg) { return $mychild; } if ($mychild == 'add') { return T_('add new'); } if ($mychild == 'edit') { return T_('edit'); } if ($mychild == 'delete') { return T_('delete'); } break; // login service and main service with full address // login service and main service with full address case 'LoginService': case 'account': return $myprefix . AccountService . MainTld . '/' . MyAccount; break; case 'MainService': $_arg = is_array($_arg) ? $_arg : array('com', 'dev'); if (in_array($mytld, $_arg)) { return $myprefix . constant('MainService') . '.' . $mytld; } else { return $myprefix . constant('MainService') . MainTld; } break; default: return null; break; } }