$this->addUniqueKey(['fluidbook_id', 'link_id']);
}
- public static function getURLToTest($limit){
+ public static function getAllURLAudits()
+ {
+ $all = self::all();
+ $res = [];
+ foreach ($all as $l) {
+ /** @var $l FluidbookAuditLink */
+ if (!isset($res[$l->url])) {
+ $res[$l->url] = ['http_code' => $l->http_code, 'code_date' => $l->code_date, 'target_code' => $l->target_code, 'target_url' => $l->target_url, 'fluidbook_links' => []];
+ }
+ $res[$l->url]['fluidbook_links'][] = ['fluidbook_id' => $l->fluidbook_id, 'page' => $l->page, 'link_id' => $l->link_id];
+ }
+ return $res;
+ }
+
+ public static function getURLToTest($limit)
+ {
}
}
use App\Models\Base\ToolboxModel;
use Cubist\Backpack\Magic\Fields\Hidden;
+use Cubist\Backpack\Magic\Fields\Integer;
use Cubist\Backpack\Magic\Fields\SelectFromArray;
+use Cubist\Backpack\Magic\Fields\Textarea;
use Cubist\Backpack\Magic\Fields\URL;
use Cubist\Backpack\Magic\Traits\CustomDataSource;
use Cubist\Util\Files\Files;
$this->addField('server', SelectFromArray::class, __('Serveur'), ['type' => 'hidden', 'options' => LinkShortener::getAvaiableShorteners()]);
$this->addField('url', URL::class, __('URL'), ['column' => true]);
- $this->addField('shortlink', URL::class, __('Short URL'), ['type' => 'hidden_visible', 'column' => 'url', 'database_unique' => true]);
+ $this->addField('shortlink', URL::class, __('URL courte'), ['type' => 'hidden_visible', 'column' => 'url', 'database_unique' => true]);
+ $this->addField('http_code', Integer::class, __('Code HTTP'), ['type' => 'hidden_visible', 'column' => true]);
+ $this->addField('code_date', \Cubist\Backpack\Magic\Fields\Datetime::class, __('Code observé le'), ['type' => 'hidden_visible', 'column' => true]);
+ $this->addField('target_code', Integer::class, __('Code final'), ['type' => 'hidden_visible', 'column' => true]);
+ $this->addField('target_url', URL::class, __('URL finale'), ['type' => 'hidden_visible', 'column' => true]);
+ $this->addField('fluidbook_links', Textarea::class, __('Présence dans les fluidbooks'), ['type' => 'hidden_visible', 'column' => true]);
$this->addOwnerField(['column' => false, 'type' => Hidden::class]);
-
}
public function showPrimaryColumn()
*/
protected static function _getData()
{
+ $auditLinks = FluidbookAuditLink::getAllURLAudits();
+
$data = [];
foreach (LinkShortener::getAvaiableShorteners(true) as $id => $s) {
try {
'created_ok' => '1',
'owner' => $s['owner'],
];
+ if (isset($auditLinks[$i->url])) {
+ $d = array_merge($d, $auditLinks[$i->url]);
+ }
$data[$d['id']] = $d;
}
} catch (\Exception $e) {
return $data;
}
+ public static function shouldRefreshDatabase()
+ {
+ return true;
+ }
+
public static function getDataLastChangeFile()
{
return Files::mkdir(resource_path('shortlink')) . 'lastchange';
public function onSaving(): bool
{
-
$this->saveDataInWebflow();
$change = false;
*/
protected function compileHTMLFile($f, $relative, $dest, $isMainLocale, $locale, $texts, $images, $seo, $env = 'dev')
{
-
-
$urlmaps = $this->getURLMaps();
$urlmap = $urlmaps[$locale];
$origRelative = $relative;
}
}
-
// Replace URL
foreach ($urlmap as $k => $v) {
$html = str_replace(ltrim($k, '/'), ltrim($v, '/'), $html);
<meta content="' . $og_title . '" property="twitter:title" />
<meta content="' . $og_desc . '" property="twitter:description" />';
$html = preg_replace('/<title>[^<]*<\/title>/', '<title>' . e($currentPage['seo_title']) . '</title>' . $meta, $html);
-
}
}
}
Cache::put('webflow_' . $this->id . '_locales', $locales);
-
-
} catch (LockTimeoutException $e) {
} finally {