/** * Suggests a short URL to use to view the team * * @param int $i_preference * @return string */ public function SuggestShortUrl($i_preference = 1) { # Base the short URL on the team name $s_url = strtolower(html_entity_decode($this->GetName())); # Remove punctuation $s_url = preg_replace('/[^a-z0-9 ]/i', '', $s_url); # Remove noise words $s_url = preg_replace(array('/\\bstoolball\\b/i', '/\\bclub\\b/i', '/\\bladies\\b/i', '/\\bmixed\\b/i', '/\\bsports\\b/i'), '', $s_url); # Apply preference if ($i_preference == 2) { # Append player type $s_url .= strtolower(html_entity_decode(PlayerType::Text($this->GetPlayerType()))); $s_url = preg_replace('/[^a-z0-9 ]/i', '', $s_url); } else { if ($i_preference > 2) { $s_url = ShortUrl::SuggestShortUrl($s_url, $i_preference, 2, 'team'); } } # Remove spaces $s_url = str_replace(' ', '-', trim($s_url)); return $this->GetShortUrlPrefix() . $s_url; }
/** * Suggests a short URL to use to view the club * * @param int $i_preference * @return string */ public function SuggestShortUrl($i_preference = 1) { $url = strtolower(html_entity_decode($this->GetName())); # Remove punctuation $url = preg_replace('/[^a-z ]/i', '', $url); # Remove noise words $url = trim(preg_replace(array('/\\bstoolball\\b/i', '/\\bclub\\b/i', '/\\bladies\\b/i', '/\\bmixed\\b/i', '/\\bsports\\b/i'), '', $url)); if ($this->GetTypeOfClub() == Club::SCHOOL) { $url = "school/{$url}"; $suffix_if_duplicate = 'school'; } else { $suffix_if_duplicate = 'club'; } # Apply preference if ($i_preference > 1) { $url = ShortUrl::SuggestShortUrl($url, $i_preference, 1, $suffix_if_duplicate); } # Remove spaces $url = str_replace(' ', '-', $url); return $url; }
/** * Suggests a short URL to use to view the player * * @param int $i_preference * @return string */ public function SuggestShortUrl($i_preference = 1) { $s_url = strtolower(html_entity_decode($this->GetName())); # Remove punctuation, add dashes $s_url = preg_replace('/[^a-z0-9- ]/i', '', $s_url); $s_url = str_replace(' ', '-', $s_url); $s_url = rtrim($s_url, "-"); # Add team as prefix if ($this->team->GetShortUrl()) { $s_url = $this->team->GetShortUrl() . "/" . $s_url; } # Apply preference if ($i_preference > 1) { $s_url = ShortUrl::SuggestShortUrl($s_url, $i_preference, 1, "-player", true); } return $s_url; }
/** * Suggests a short URL to use to view the competition * * @param int $i_preference * @return string */ public function SuggestShortUrl($i_preference = 1) { $s_url = strtolower(html_entity_decode($this->GetName())); # Remove punctuation $s_url = preg_replace('/[^a-z ]/i', '', $s_url); # Remove noise words $s_url = preg_replace(array('/\\bstoolball\\b/i', '/\\bleague\\b/i', '/\\bladies\\b/i', '/\\bmixed\\b/i', '/\\bdistrict\\b/i', '/\\bthe\\b/i', '/\\band\\b/i', '/\\bin\\b/i', '/\\bwith\\b/i', '/\\bassociation\\b/i', '/\\bdivision\\b/i', '/\\bcounty\\b/i', '/\\bfriendlies\\b/i'), '', $s_url); # Apply preference if ($i_preference == 2) { # Append player type $s_url .= strtolower(html_entity_decode(PlayerType::Text($this->GetPlayerType()))); $s_url = preg_replace('/[^a-z0-9 ]/i', '', $s_url); } else { if ($i_preference > 2) { $s_url = ShortUrl::SuggestShortUrl($s_url, $i_preference, 2); } } # Remove spaces $s_url = str_replace(' ', '', $s_url); return $s_url; }
/** * Suggests a short URL to use to view the ground * * @param int $i_preference * @return string */ public function SuggestShortUrl($i_preference = 1) { $s_url = strtolower(html_entity_decode($this->GetName())); # Remove punctuation $s_url = preg_replace('/[^a-z ]/i', '', $s_url); # Remove noise words $s_url = preg_replace(array('/\\bstoolball\\b/i', '/\\bclub\\b/i', '/\\bplaying\\b/i', '/\\fields\\b/i', '/\\bfield\\b/i', '/\\bground\\b/i', '/\\bthe\\b/i', '/\\band\\b/i'), '', $s_url); # Apply preference if ($i_preference == 2) { # Append locality $s_locality = preg_replace('/[^a-z0-9 ]/i', '', strtolower(html_entity_decode($this->GetAddress()->GetLocality()))); if ($s_locality and stristr($s_url, $s_locality) === false) { $s_url .= $s_locality; } } else { if ($i_preference == 3) { # Append town $s_town = preg_replace('/[^a-z0-9 ]/i', '', strtolower(html_entity_decode($this->GetAddress()->GetTown()))); if ($s_town and stristr($s_url, $s_town) === false) { $s_url .= $s_town; } } else { if ($i_preference > 3) { $s_url = ShortUrl::SuggestShortUrl($s_url, $i_preference, 3, 'ground'); } } } # Remove spaces $s_url = str_replace(' ', '', $s_url); return "ground/{$s_url}"; }