Exemplo n.º 1
0
 public function getAll($onlyUnprocessed = false)
 {
     if ($onlyUnprocessed) {
         return ExternalLinks::with('link')->where('valid', 1)->where('processed', 0)->get();
     }
     return ExternalLinks::with('link')->where('valid', 1)->orderBy('processed', 'DESC')->get();
 }
Exemplo n.º 2
0
 public function replaceReferenceOnParent($link, $parent)
 {
     $parent_item = Links::find($parent);
     $parent_item->update(['content' => str_replace($link->url, '/' . $link->slug, $parent_item->content), 'indexed_link' => 1]);
     $external_link = ExternalLinks::find($link->id);
     if ($external_link) {
         $external_link->update(['processed' => 1]);
     }
 }
Exemplo n.º 3
0
 public function attachExternalLinks($link, $urls, $blacklist)
 {
     $existing_el = array_pluck($link->externals->toArray(), 'id');
     foreach ($urls as $url) {
         if (!in_array($url, $existing_el)) {
             $parsed_url = parse_url($url);
             if ($this->checkIfContainsBlackListItem($url, $blacklist) || isset($parsed_url['path']) && strlen($parsed_url['path']) < 2 || !filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED) || !filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED) || strpos($url, 'ailto:') || strpos($url, 'keywords/') || strpos($url, 'entities/')) {
                 $external_links_object = ExternalLinks::make($link->id, $url, 0, 1);
             } else {
                 $external_links_object = ExternalLinks::make($link->id, $url);
             }
             $this->external_links->save($external_links_object);
         }
     }
 }