Example #1
0
 function tearDown()
 {
     foreach (StudipFormat::getStudipMarkups() as $key => $value) {
         StudipFormat::removeStudipMarkup($key);
     }
     foreach ($this->old_rules as $key => $value) {
         StudipFormat::addStudipMarkup($key, @$value['start'], @$value['end'], @$value['callback']);
     }
 }
Example #2
0
 /**
  * Extracts urls and their according open graph infos from a given string
  * 
  * @param String $string Text to extract urls and open graph infos from
  * @return OpenGraphURLCollection containing the extracted urls
  */
 public static function extract($string)
 {
     $collection = new OpenGraphURLCollection();
     if (Config::get()->OPENGRAPH_ENABLE) {
         $regexp = StudipFormat::getStudipMarkups()['links']['start'];
         $matched = preg_match_all('/' . $regexp . '/ms', $string, $matches, PREG_SET_ORDER);
         foreach ($matches as $match) {
             $url = $match[2];
             if (!$url) {
                 continue;
             }
             if (!isLinkIntern($url)) {
                 $og_url = OpenGraphURL::fromURL($url);
                 if ($og_url && !$collection->find($og_url->id)) {
                     $og_url->store();
                     $collection[] = $og_url;
                 }
             }
         }
     }
     return $collection;
 }