本文整理汇总了PHP中Util::starts_with方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::starts_with方法的具体用法?PHP Util::starts_with怎么用?PHP Util::starts_with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Util
的用法示例。
在下文中一共展示了Util::starts_with方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: thumb
public function thumb($type, $source_href, $width, $height)
{
$source_path = $this->context->to_path($source_href);
if (!file_exists($source_path) || Util::starts_with($source_path, $this->setup->get('CACHE_PUB_PATH'))) {
return null;
}
$capture_path = $source_path;
if ($type === 'img') {
$capture_path = $source_path;
} else {
if ($type === 'mov') {
if ($this->setup->get('HAS_CMD_AVCONV')) {
$capture_path = $this->capture(Thumb::$AVCONV_CMDV, $source_path);
} else {
if ($this->setup->get('HAS_CMD_FFMPEG')) {
$capture_path = $this->capture(Thumb::$FFMPEG_CMDV, $source_path);
}
}
} else {
if ($type === 'doc') {
if ($this->setup->get('HAS_CMD_CONVERT')) {
$capture_path = $this->capture(Thumb::$CONVERT_CMDV, $source_path);
} else {
if ($this->setup->get('HAS_CMD_GM')) {
$capture_path = $this->capture(Thumb::$GM_CONVERT_CMDV, $source_path);
}
}
}
}
}
return $this->thumb_href($capture_path, $width, $height);
}
示例2: _perform
function _perform()
{
$method_return = false;
if (Util::starts_with($this->actual_search_term, HELPME)) {
$method_return = $this->get_help();
return $method_return;
}
if (Util::starts_with($this->actual_search_term, LIVE_SCORES)) {
$method_return = $this->get_scores();
} else {
if (in_array(trim($this->actual_search_term), $this->results)) {
$method_return = $this->get_matches();
} else {
if (in_array(trim($this->actual_search_term), $this->fixtures)) {
$method_return = $this->get_matches(true);
} else {
if (in_array(trim($this->actual_search_term), $this->scores)) {
$last_score = false;
if (in_array(trim($this->actual_search_term), $this->last_scores)) {
$last_score = true;
}
$method_return = $this->get_scores($last_score);
} else {
$this->unknown_search_term;
$error_msg = "Cricket/IPL Unknown Search type.<br>";
$error_msg .= "Type cricket help or ipl help for more info.<br>";
$this->error_messages[$this->error_count] = $error_msg;
$this->error_count++;
$method_return = false;
}
}
}
}
return $method_return;
}
示例3: thumb
public function thumb($type, $source_url, $width, $height)
{
$source_path = $this->app->to_path($source_url);
if (!file_exists($source_path) || Util::starts_with($source_path, CACHE_PATH)) {
return null;
}
$capture_path = $source_path;
if ($type === "img") {
$capture_path = $source_path;
} else {
if ($type === "mov") {
if (HAS_CMD_AVCONV) {
$capture_path = $this->capture(Thumb::$AVCONV_CMDV, $source_path);
} else {
if (HAS_CMD_FFMPEG) {
$capture_path = $this->capture(Thumb::$FFMPEG_CMDV, $source_path);
}
}
} else {
if ($type === "doc" && HAS_CMD_CONVERT) {
$capture_path = $this->capture(Thumb::$CONVERT_CMDV, $source_path);
}
}
}
return $this->thumb_href($capture_path, $width, $height);
}
示例4: _perform
function _perform()
{
$results_found = false;
if (Util::starts_with($this->actual_search_term, HELPME)) {
$results_found = $this->get_help();
return true;
}
$tagalus_api_url = HASH_API_URL . 'definition/' . $this->actual_search_term . "/show.xml";
$results_found = false;
if ($data = Util::load_page($tagalus_api_url)) {
preg_match("/(.*?)We're sorry, but something went wrong(.*?)/is", $data, $matcher);
if ($matcher) {
$this->output[$this->get_type()][0] = "nothing found for the hashtag " . $this->actual_search_term . " visit " . TAG_URL . $this->actual_search_term . " to add a definition";
return true;
}
$xml = simplexml_load_string($data);
$defintions = $xml->xpath('//definition/the-definition');
//Util::print_array($defintions[0]);
$hash = $defintions[0];
if ($hash) {
$this->output[$this->get_type()][] = "#" . $this->actual_search_term . " means " . $hash;
$results_found = true;
} else {
$this->no_results_found_error("nothing found for the hashtag " . $this->actual_search_term . " visit " . TAG_URL . $this->actual_search_term . " to add a definition");
}
}
if (!$results_found) {
$this->no_results_found_error("nothing found for the hashtag " . $this->actual_search_term . " visit " . TAG_URL . $this->actual_search_term . " to add a definition");
return false;
}
return true;
}
示例5: get_parent
public function get_parent(&$cache)
{
$parent_path = Util::normalize_path(dirname($this->path), false);
if ($parent_path !== $this->path && Util::starts_with($parent_path, $this->context->get_setup()->get('ROOT_PATH'))) {
return Item::get($this->context, $parent_path, $cache);
}
return null;
}
示例6: get_parent
public function get_parent(&$cache)
{
$parent_path = Util::normalize_path(dirname($this->path), false);
if ($parent_path !== $this->path && Util::starts_with($parent_path, ROOT_PATH)) {
return Item::get($this->app, $parent_path, $cache);
}
return null;
}
示例7: _perform
function _perform()
{
if (Util::starts_with($this->actual_search_term, HELPME)) {
$method_return = $this->get_help();
return $method_return;
}
$results_found = false;
//echo WEATHER_URL.$this->actual_search_term;
if ($data = Util::load_page(WEATHER_URL . urlencode($this->actual_search_term))) {
$xml = simplexml_load_string($data);
$error = $xml->xpath('//problem_cause');
if (!$error) {
$results_found = true;
if ($this->lookup_today) {
$weather = $xml->xpath('//current_conditions');
if ($weather) {
$temp_data = $xml->xpath('//forecast_information/city');
$attrs = $temp_data[0]->attributes();
$city = $attrs["data"];
$temp_data = $xml->xpath('//current_conditions/condition');
$attrs = $temp_data[0]->attributes();
$condition = $attrs["data"];
$temp_data = $xml->xpath('//current_conditions/temp_f');
$attrs = $temp_data[0]->attributes();
$fari = $attrs["data"];
$temp_data = $xml->xpath('//current_conditions/temp_c');
$attrs = $temp_data[0]->attributes();
$celcius = $attrs["data"];
$temp_data = $xml->xpath('//current_conditions/wind_condition');
$attrs = $temp_data[0]->attributes();
$wind = $attrs["data"];
$this->output['weather'][0] = "#weather {$city} Condition: {$condition}, Temp: " . $fari . "°F/" . $celcius . "°C, {$wind}";
} else {
$this->output['weather'][0] = "I am being coded to get better weather updates, meantime lookup today's weather, \"@twitlookup cityname/zipcode\"";
}
}
} else {
$this->no_results_found_error('no results found for this weather lookup');
}
}
if (!$results_found) {
$this->no_results_found_error("could not find the weather for " . $this->actual_search_term);
return false;
}
return true;
}
示例8: _perform
function _perform()
{
$results_found = false;
if (Util::starts_with($this->actual_search_term, HELPME)) {
//echo "Help me dear";
$this->output = $this->get_help();
//Util::print_array($this->output);
return true;
}
$results_found = false;
if ($data = Util::load_page(ACRO_API_URL . $this->actual_search_term)) {
$xml = simplexml_load_string($data);
$defintions = $xml->xpath('//found');
$attrs = $defintions[0]->attributes();
$counter = $attrs["n"][0];
if ($counter && $counter > 0) {
$defintions = $xml->xpath('//found/acro/expan');
$counter = 0;
$message = "";
if (count($defintions) > 0) {
$message = $this->actual_search_term . " means ";
}
foreach ($defintions as $def) {
$also = "";
if (($counter > 0 || count($defintions) > 1) && $counter < count($defintions)) {
$also = ",";
}
$message .= $def . $also;
$counter++;
}
$this->output[$this->get_type()][] = $message;
$results_found = true;
} else {
$this->no_results_found_error("nothing found for the acronym " . $this->actual_search_term);
}
}
if (!$results_found) {
$this->no_results_found_error("nothing found for the acronym " . $this->actual_search_term);
return false;
}
return true;
}
示例9: get_lookup_object
function get_lookup_object($lookupword, $lookuptype)
{
$lookupword = strtolower($lookupword);
if (Util::starts_with($lookupword, "dict")) {
return new DictionaryLookup($lookupword, $lookuptype);
} else {
if (Util::starts_with($lookupword, "weather")) {
return new WeatherLookup($lookupword, $lookuptype);
} else {
if (Util::starts_with($lookupword, "acro")) {
return new AcronymLookup($lookupword, $lookuptype);
} else {
if (Util::starts_with($lookupword, "hash")) {
return new HashLookup($lookupword, $lookuptype);
} else {
if (Util::starts_with($lookupword, "movie")) {
return new MovieLookup($lookupword, $lookuptype);
} else {
if (Util::starts_with($lookupword, "ipl") || Util::starts_with($lookupword, "cricket")) {
return new CricketLookup($lookupword, $lookuptype);
} else {
if (Util::starts_with($lookupword, "help")) {
return new Help($lookupword, $lookuptype);
} else {
if (Util::starts_with($lookupword, "credit")) {
return new Credits($lookupword, $lookuptype);
} else {
return new DefaultLookup($lookupword, $lookuptype);
}
}
}
}
}
}
}
}
}
示例10: _perform
function _perform()
{
$results_found = false;
if (Util::starts_with($this->actual_search_term, HELPME)) {
$this->output = $this->get_help();
return true;
}
$results_found = false;
if ($this->actual_search_term) {
$search_url = MOVIE_API_URL . urlencode($this->actual_search_term);
echo "SEARCH URL {$search_url}<br><br>";
$data = Util::load_page($search_url);
$this->get_titles($data);
die;
//echo $imdb_content;
//parse for product name
$name = Util::get_match('/<title>(.*)<\\/title>/isU', $imdb_content);
$director = strip_tags(Util::get_match('/<h5[^>]*>Director:<\\/h5>(.*)<\\/div>/isU', $imdb_content));
$plot = Util::get_match('/<h5[^>]*>Plot:<\\/h5>(.*)<\\/div>/isU', $imdb_content);
$release_date = Util::get_match('/<h5[^>]*>Release Date:<\\/h5>(.*)<\\/div>/isU', $imdb_content);
$mpaa = Util::get_match('/<a href="\\/mpaa">MPAA<\\/a>:<\\/h5>(.*)<\\/div>/isU', $imdb_content);
$run_time = Util::get_match('/Runtime:<\\/h5>(.*)<\\/div>/isU', $imdb_content);
//build content
$content .= '<h2>Film</h2><p>' . $name . '</p>';
$content .= '<h2>Director</h2><p>' . $director . '</p>';
$content .= '<h2>Plot</h2><p>' . substr($plot, 0, strpos($plot, '<a')) . '</p>';
$content .= '<h2>Release Date</h2><p>' . substr($release_date, 0, strpos($release_date, '<a')) . '</p>';
$content .= '<h2>MPAA</h2><p>' . $mpaa . '</p>';
$content .= '<h2>Run Time</h2><p>' . $run_time . '</p>';
$content .= '<h2>Full Details</h2><p><a href="' . $url . '" rel="nofollow">' . $url . '</a></p>';
echo $content;
die;
$xml = simplexml_load_string($data);
$defintions = $xml->xpath('//found');
$attrs = $defintions[0]->attributes();
$counter = $attrs["n"][0];
if ($counter && $counter > 0) {
$defintions = $xml->xpath('//found/acro/expan');
$counter = 0;
$message = "";
if (count($defintions) > 0) {
$message = $this->actual_search_term . " means ";
}
foreach ($defintions as $def) {
$also = "";
if (($counter > 0 || count($defintions) > 1) && $counter < count($defintions)) {
$also = ",";
}
$message .= $def . $also;
$counter++;
}
$this->output[$this->get_type()][] = $message;
$results_found = true;
} else {
$this->no_results_found_error("nothing found for the movie " . $this->actual_search_term);
}
}
if (!$results_found) {
$this->no_results_found_error("nothing found for the movie " . $this->actual_search_term);
return false;
}
return true;
}
示例11: _perform
function _perform()
{
if (Util::starts_with($this->actual_search_term, HELPME)) {
$this->output = "usage @twitlookup dict word for looking up defintions visit http://twitlookup.com#dict for more help";
return true;
}
$search_url = LOOKUP_URL . urlencode($this->actual_search_term);
$method_return = false;
if ($data = Util::load_page($search_url)) {
$xml = simplexml_load_string($data);
$result = $xml->xpath('//text');
$data = $result[0];
//$result = iconv("UTF-8","UTF-8",$result[0]);
$defcount = 0;
preg_match("/(.*?)does not yet have an entry(.*?)/is", $data, $matcher);
if ($matcher) {
$error_msg = "We could not find any definition for the word you are looking for.<br>";
$error_msg .= "Please try again in some time, type help for more info.<br>";
$this->error_messages[$this->error_count] = $error_msg;
$this->error_count++;
$this->no_results = true;
return false;
}
preg_match("/<h2>(.*?)<span class=\"mw-headline\">(.*?)<\\/span><\\/h2>/is", $data, $matcher);
if ($matcher) {
$this->output['language'] = $matcher[2];
}
$parts_of_speech = array("Noun", "Verb", "Pronoun", "Adjective", "Adverb", "Preposition", "Conjuntion", "Interjection");
$one_matcher_found = false;
foreach ($parts_of_speech as $pos) {
$match_str = "/<span class=\"mw-headline\">{$pos}<\\/span><\\/h[0-9]>(.*?)<ol>(.*?)<\\/ol>(.*?)/is";
preg_match_all($match_str, $data, $matcher);
//echo "$match_str<br>";
if ($matcher) {
$one_matcher_found = true;
$definitions = $matcher[2];
for ($j = 0; $j < count($definitions); $j++) {
$result = "<ol>" . $definitions[$j] . "</ol>";
$xml = simplexml_load_string($result);
$result = $xml->xpath('//ol/li');
for ($i = 0; $i < count($result); $i++) {
preg_match("/(.*?)<dl>(.*?)<\\/dl>(.*?)/is", $result[$i]->asXml(), $matcher1);
if ($matcher1) {
$definition = strip_tags($matcher1[1]);
} else {
$definition = strip_tags($result[$i]->asXml());
}
$this->output['type'][$pos]['def'][$defcount] = $definition;
//$this->output['type'][$j]['name']['def'] = $definition;
$defcount++;
}
}
}
if ($one_matcher_found) {
$method_return = true;
} else {
$error_msg = "We could not find any definition for the word you are looking for.<br>";
$error_msg .= "Please try again in some time, type help for more info.<br>";
$this->error_messages[$this->error_count] = $error_msg;
$this->error_count++;
$this->no_results = true;
}
}
if ($this->caller_type == "twitter") {
$this->format_output_for_twitter();
}
} else {
$error_msg = "Unknown error occurred, while trying to get the definition.<br>";
$error_msg .= "Please try again in some time.<br>";
$this->error_messages[$this->error_count] = $error_msg;
$this->error_count++;
$this->search_error = false;
}
return $method_return;
}
示例12: is_info_request
public function is_info_request()
{
return Util::starts_with($this->setup->get('REQUEST_HREF') . '/', $this->setup->get('PUBLIC_HREF'));
}
示例13: test_start_with
public function test_start_with()
{
$this->assertTrue(Util::starts_with('start a string', 'start a'));
$this->assertFalse(Util::starts_with('start a string', 'string'));
}