id'); $stmt_source->close(); // b. Si el artículo guardado no tiene vínculos, buscamos una mejor fuente. if (empty($vinculos_a_sincronizar)) { // Priorizamos buscar en la versión en español, si existe. $id_fuente_es = null; foreach ($grupo_traduccion as $hermano) { if ($hermano['idioma_articulo'] === 'es') { $id_fuente_es = $hermano['id']; break; } } // Si encontramos una versión en español, la usamos como fuente. // Si no, usamos el primer "hermano" que encontremos en la lista. $id_fuente_fallback = $id_fuente_es ?? $grupo_traduccion_ids[0]; if ($id_fuente_fallback) { $stmt_fallback = $this->sql->prepare( "SELECT taxonomia_id FROM fa_taxonomia_vinculos WHERE contenido_id = ? AND contenido_tipo = 'articulo'" ); $stmt_fallback->bind_param('s', $id_fuente_fallback); $stmt_fallback->execute(); $vinculos_a_sincronizar = array_column($stmt_fallback->get_result()->fetch_all(MYSQLI_ASSOC), 'taxonomia_id'); $stmt_fallback->close(); } } // Si después de todo, no encontramos ningún vínculo en ningún artículo del grupo, no hacemos nada. if (empty($vinculos_a_sincronizar)) { return true; } // 3. SINCRONIZAR: Aplicar la lista de vínculos encontrada a TODOS los hermanos. $stmt_delete = $this->sql->prepare( "DELETE FROM fa_taxonomia_vinculos WHERE contenido_id = ? AND contenido_tipo = 'articulo'" ); $stmt_insert = $this->sql->prepare( "INSERT INTO fa_taxonomia_vinculos (taxonomia_id, contenido_id, contenido_tipo) VALUES (?, ?, 'articulo')" ); foreach ($grupo_traduccion_ids as $id_hermano) { $stmt_delete->bind_param('s', $id_hermano); $stmt_delete->execute(); foreach ($vinculos_a_sincronizar as $taxonomia_id) { $stmt_insert->bind_param('is', $taxonomia_id, $id_hermano); $stmt_insert->execute(); } } $stmt_delete->close(); $stmt_insert->close(); return true; } public function procesarVideosIncrustados(string $contenido): string { if (strpos($contenido, 'data-id') === false) { return $contenido; // Optimización: si no hay videos, no hacer nada. } $patron = '/
\s*
.*?<\/div>(.*?)<\/figure>/is'; return preg_replace_callback($patron, function ($matches) { $videoId = $matches[1]; $figcaptionHTML = trim($matches[2] ?? ''); // Capturamos el figcaption si existe // Instanciamos la clase de Videos para usar sus métodos $videos_cls = new Videos(); $video_propio = $videos_cls->vistaID($videoId); if ($video_propio) { // --- CASO 1: EL VIDEO ES NUESTRO --- // Usamos renglon() sin 'embed' para generar un enlace a nuestra página de video. // El método renglon() ya genera la
, por lo que reemplazamos toda la
. // Obtenemos el HTML del video $video_html = $videos_cls->renglon($video_propio, ['embed' => false]); $videos_cls->sql->close(); return '
' . $video_html . '
'; } else { // --- CASO 2: EL VIDEO ES DE UN TERCERO --- // Usamos renglon() con 'embed' => true. // Esto generará la estructura que tu JavaScript actual espera para cargar el reproductor. // Creamos un array de datos de video "falso" con solo el ID. $video_falso = ['id' => $videoId]; $opciones['embed'] = true; $opciones['link'] = 'https://youtu.be/' . $videoId; if (!empty($figcaptionHTML)) { if (preg_match('/
(.*?)<\/figcaption>/is', $figcaptionHTML, $caption_matches)) { $opciones['epigrafe'] = $caption_matches[1]; } } $video_html = $videos_cls->renglon($video_falso, $opciones); $videos_cls->sql->close(); return '
' . $video_html . '
'; } }, $contenido); } // Helper para Disclaimer Dinámico function getDisclaimer($target_lang, $traducido) { $row = $this->sql->query("SELECT idioma_articulo FROM fa_contenidos WHERE id = $traducido"); $source_lang = $row->fetch_row(); $source_lang = $source_lang[0]; // Diccionario para nombrar el idioma origen según el idioma destino // Formato: [destino][origen] $nombres_idiomas = [ 'es' => ['en' => 'inglés', 'pt' => 'portugués', 'it' => 'italiano', 'es' => 'español'], 'en' => ['es' => 'Spanish', 'pt' => 'Portuguese', 'it' => 'Italian', 'en' => 'English'], 'pt' => ['es' => 'espanhol', 'en' => 'inglês', 'it' => 'italiano', 'pt' => 'português'], 'it' => ['es' => 'spagnolo', 'en' => 'inglese', 'pt' => 'portoghese', 'it' => 'italiano'], ]; // Obtenemos el nombre del idioma origen (o un genérico si falla) $src_name = $nombres_idiomas[$target_lang][$source_lang] ?? _('otro idioma'); $target_lang = $nombres_idiomas[$target_lang][$target_lang] ?? _('otro idioma'); $disclaimer = sprintf(_('Este artículo fue escrito originalmente en %s y adaptado al %s con ayuda de IA, para facilitar su difusión global.'), $src_name, $target_lang) . ' ' . sprintf(_('Si notas algún error, por favor, %sescríbenos un mensaje%s, incluyendo el link de este artículo.'), '', ''); return '
' . $disclaimer . ''; } }
Fatal error: Uncaught Error: Class "Articulos" not found in /var/www/foroalfa/public_html/includes/vistas/articulos/articulo.php:12 Stack trace: #0 {main} thrown in /var/www/foroalfa/public_html/includes/vistas/articulos/articulo.php on line 12