Fork me on GitHub




« 1 2 (3) 4 5 »


Re: Publisher 1.08
Admin Frxoops
Inscrit: 16/03/2009 16:40
De Tende (06)
Messages: 3528
Oui on en est à la 1.8.0 mais ON2AT a pris la 1.0.8.

De toute façon je rencontre des bogues avec la dernière version.

Posté le : 11/02/2023 14:46

Open in new window

Xoopseuse Mai 2012 | Responsable équipe internationale | Recherche avancée en bas de page !
Partager Twitter Partagez cette article sur GG+
Re: Publisher 1.08
Team FrXoops
Inscrit: 14/05/2004 22:32
Messages: 2554
Il faut éviter le 1.8, elle ne semble pas encore stable.

Posté le : 11/02/2023 14:47

Ne pas perdre patience, même si cela semble impossible, c'est déjà de la patience.
Origami
Conseil des Sages
Sur gitHub
Partager Twitter Partagez cette article sur GG+
Re: Publisher 1.08
Team FrXoops
Inscrit: 14/05/2004 22:32
Messages: 2554
Bon a priori c'est la fonction html2text($document) qui bug.
Je n'ai pas le temps de chercher pourquoi mais je l'ai remplacée par la même fonction de la vrsion 1.02, et la ça fonctionne.
Donc dans le fichier class/Metagen.php, il faut remplacer la fonction html2text par cette versions:
public function html2text($document)
    {
        // PHP Manual:: function preg_replace
        // $document should contain an HTML document.
        // This will remove HTML tags, javascript sections
        // and white space. It will also convert some
        // common HTML entities to their text equivalent.
        // Credits : newbb2
        $search = array(
            "'<script[^>]*?>.*?</script>'si", // Strip out javascript<?php
            
"'<img.*?/>'si"// Strip out img tags
            
"'<[/!]*?[^<>]*?>'si"// Strip out HTML tags<?php
            
"'([rn])[s]+'"// Strip out white space
            
"'&(quot|#34);'i"// Replace HTML entities
            
"'&(amp|#38);'i",
            
"'&(lt|#60);'i",
            
"'&(gt|#62);'i",
            
"'&(nbsp|#160);'i",
            
"'&(iexcl|#161);'i",
            
"'&(cent|#162);'i",
            
"'&(pound|#163);'i",
            
"'&(copy|#169);'i",
            
//"'&#(d+);'e"
        
);
        
// evaluate as php
        
$replace = array(
            
"",
            
"",
            
"",
            
"\1",
            
""",
            "
&",
            "
<",
            "
>",
            " ",
            chr(161),
            chr(162),
            chr(163),
            chr(169),
            //"
chr(\1)"
        );
        
$text = preg_replace($search$replace$document);

        return 
$text;
    }
}

Posté le : 11/02/2023 15:45

Ne pas perdre patience, même si cela semble impossible, c'est déjà de la patience.
Origami
Conseil des Sages
Sur gitHub
Partager Twitter Partagez cette article sur GG+
Re: Publisher 1.08
Semi pro
Inscrit: 26/07/2011 14:05
De Fleurus (W-B) (Belgique)
Messages: 792
Bonjour, chez moi cela ne fonctionne pas j’ai toujours ce soucis d’apostrophe...

Posté le : 12/02/2023 11:44

Je suis souvent copié mais "copié = Synonyme de célébrité" Alors continuez mes fans.
Site Radioamateur Belge
Partager Twitter Partagez cette article sur GG+
Re: Publisher 1.08
Team FrXoops
Inscrit: 14/05/2004 22:32
Messages: 2554
Peux-tu envoyer ce fichier ?

Posté le : 12/02/2023 14:32

Ne pas perdre patience, même si cela semble impossible, c'est déjà de la patience.
Origami
Conseil des Sages
Sur gitHub
Partager Twitter Partagez cette article sur GG+
Re: Publisher 1.08
Semi pro
Inscrit: 26/07/2011 14:05
De Fleurus (W-B) (Belgique)
Messages: 792
Citation :
JJDai a écrit :
Peux-tu envoyer ce fichier ?

Bonjour JJDai, comment je fait pour vous l'envoyer?

Posté le : 12/02/2023 15:17

Je suis souvent copié mais "copié = Synonyme de célébrité" Alors continuez mes fans.
Site Radioamateur Belge
Partager Twitter Partagez cette article sur GG+
Re: Publisher 1.08
Team FrXoops
Inscrit: 14/05/2004 22:32
Messages: 2554
bin attacher un fichier ci-dessous

Posté le : 12/02/2023 16:15

Ne pas perdre patience, même si cela semble impossible, c'est déjà de la patience.
Origami
Conseil des Sages
Sur gitHub
Partager Twitter Partagez cette article sur GG+
Re: Publisher 1.08
Semi pro
Inscrit: 26/07/2011 14:05
De Fleurus (W-B) (Belgique)
Messages: 792
Citation :
JJDai a écrit :
bin attacher un fichier ci-dessous


<?php

declare(strict_types=1);

namespace XoopsModules\Cb;

/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

/**
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
* @since 1.0
* @author trabis <lusopoemas@gmail.com>
* @author The SmartFactory <www.smartfactory.ca>
*/

require_once \dirname(__DIR__) . '/include/common.php';

/**
* Class Metagen
*/
class Metagen
{
/**
* @var Helper
*/
public $helper;
/**
* @var \MyTextSanitizer
*/
public $myts;
/**
* @var string
*/
public $title;
/**
* @var string
*/
public $originalTitle;
/**
* @var string
*/
public $keywords;
/**
* @var string
*/
public $categoryPath;
/**
* @var string
*/
public $description;
/**
* @var int
*/
public $minChar = 4;

/**
* @param string $title
* @param string $keywords
* @param string $description
* @param string $categoryPath
*/
public function __construct($title, $keywords = '', $description = '', $categoryPath = '')
{
/** @var Helper $this->helper */
$this->helper = Helper::getInstance();
$this->myts = \MyTextSanitizer::getInstance();
$this->setCategoryPath($categoryPath);
$this->setTitle($title);
$this->setDescription($description);
if ('' == $keywords) {
$keywords = $this->createMetaKeywords();
}
$this->setKeywords($keywords);
}

/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $this->html2text($title);
$this->originalTitle = $this->title;
$titleTag = [];
$titleTag['module'] = $this->helper->getModule()->getVar('name');
if (isset($this->title) && ('' != $this->title) && (\mb_strtoupper($this->title) != \mb_strtoupper($titleTag['module']))) {
$titleTag['title'] = $this->title;
}
if (isset($this->categoryPath) && ('' != $this->categoryPath)) {
$titleTag['category'] = $this->categoryPath;
}
$ret = $titleTag['title'] ?? '';
if (isset($titleTag['category']) && '' != $titleTag['category']) {
if ('' != $ret) {
$ret .= ' - ';
}
$ret .= $titleTag['category'];
}
if (isset($titleTag['module']) && '' != $titleTag['module']) {
if ('' != $ret) {
$ret .= ' - ';
}
$ret .= $titleTag['module'];
}
$this->title = $ret;
}

/**
* @param string $keywords
*/
public function setKeywords($keywords)
{
$this->keywords = $keywords;
}

/**
* @param string $categoryPath
*/
public function setCategoryPath($categoryPath)
{
$categoryPath = $this->html2text($categoryPath);
$this->categoryPath = $categoryPath;
}

/**
* @param string $description
*/
public function setDescription($description)
{
$description = $this->html2text($description);
$description = $this->purifyText($description);
$this->description = $description;
}

/**
* Does nothing
*/
public function createTitleTag()
{
}

/**
* @param int $maxWords
*
* @return string
*/
public function createMetaDescription($maxWords = 30)
{
$description = $this->purifyText($this->description);
$description = $this->html2text($description);
$words = \explode(' ', $description);
$ret = '';
$i = 1;
$wordCount = \count($words);
foreach ($words as $word) {
$ret .= $word;
if ($i < $wordCount) {
$ret .= ' ';
}
++$i;
}

return $ret;
}

/**
* @param string $text
* @param int $minChar
*
* @return array
*/
public function findMetaKeywords($text, $minChar)
{
$keywords = [];
$text = $this->purifyText($text);
$text = $this->html2text($text);
$originalKeywords = \explode(' ', $text);
foreach ($originalKeywords as $originalKeyword) {
$secondRoundKeywords = \explode("'", $originalKeyword);
foreach ($secondRoundKeywords as $secondRoundKeyword) {
if (\mb_strlen($secondRoundKeyword) >= $minChar) {
if (!\in_array($secondRoundKeyword, $keywords, true)) {
$keywords[] = \trim($secondRoundKeyword);
}
}
}
}

return $keywords;
}

/**
* @return string
*/
public function createMetaKeywords()
{
$keywords = $this->findMetaKeywords($this->originalTitle . ' ' . $this->description, $this->minChar);
$moduleKeywords = $this->helper->getConfig('seo_meta_keywords');
if ('' != $moduleKeywords) {
$moduleKeywords = \explode(',', $moduleKeywords);
$keywords = \array_merge($keywords, \array_map('\trim', $moduleKeywords));
}
$ret = \implode(',', $keywords);

return $ret;
}

/**
* Does nothing
*/
public function autoBuildMetaKeywords()
{
}

/**
* Build Metatags
*/
public function buildAutoMetaTags()
{
$this->keywords = $this->createMetaKeywords();
$this->description = $this->createMetaDescription();
//$this->title = $this->createTitleTag();
}

/**
* Creates meta tags
*/
public function createMetaTags()
{
global $xoopsTpl, $xoTheme;
if ('' != $this->keywords) {
$xoTheme->addMeta('meta', 'keywords', $this->keywords);
}
if ('' != $this->description) {
$xoTheme->addMeta('meta', 'description', $this->description);
}
if ('' != $this->title) {
$xoopsTpl->assign('xoops_pagetitle', $this->title);
}
}

/**
* Return true if the string is length > 0
*
* @credit psylove
* @param mixed $var
* @return bool
*/
public static function emptyString($var)
{
return ('' !== $var);
}

/**
* Create a title for the short_url field of an article
*
* @credit psylove
*
* @param string|array $title title of the article
* @param bool $withExt do we add an html extension or not
*
* @return string short url for article
*/
public static function generateSeoTitle($title = '', $withExt = true)
{
// Transformation de la chaine en minuscule
// Codage de la chaine afin d'éviter les erreurs 500 en cas de caractères imprévus
$title = \rawurlencode(\mb_strtolower($title));
// Transformation des ponctuations

$pattern = [
'/%09/', // Tab
'/%20/', // Space
'/%21/', // !
'/%22/', // "
'/%23/', // #
'/%25/', // %
'/%26/', // &
'/%27/', // '
'/%28/', // (
'/%29/', // )
'/%2C/', // ,
'/%2F/', // /
'/%3A/', // :
'/%3B/', // ;
'/%3C/', // <
'/%3D/', // =
'/%3E/', // >
'/%3F/', // ?
'/%40/', // @
'/%5B/', // [
'/%5C/', // \
'/%5D/', // ]
'/%5E/', // ^
'/%7B/', // {
'/%7C/', // |
'/%7D/', // }
'/%7E/', // ~
'/\./', // .
];
$repPat = ['-', '-', '-', '-', '-', '-100', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-at-', '-', '-', '-', '-', '-', '-', '-', '-', '-'];
$title = \preg_replace($pattern, $repPat, $title);
// Transformation des caractères accentués
$pattern = [
'/%B0/', // °
'/%E8/', // è
'/%E9/', // é
'/%EA/', // ê
'/%EB/', // ë
'/%E7/', // ç
'/%E0/', // à
'/%E2/', // â
'/%E4/', // ä
'/%EE/', // î
'/%EF/', // ï
'/%F9/', // ù
'/%FC/', // ü
'/%FB/', // û
'/%F4/', // ô
'/%F6/', // ö
];
$repPat = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'];
$title = \preg_replace($pattern, $repPat, $title);
$tableau = \explode('-', $title); // Transforms the string in table //Transforme la chaine de caractères en tableau
$tableau = \array_filter($tableau, [__CLASS__, 'emptyString']); // Remove empty strings of the table //Supprime les chaines vides du tableau
$title = \implode('-', $tableau); // Transforms a character string in table separated by a hyphen //Transforme un tableau en chaine de caractères séparé par un tiret
if ($title && !(\is_array($title))) {
if ($withExt) {
$title .= '.html';
}

return $title;
}

return '';
}

/**
* @param $text
* @param bool $keyword
*
* @return mixed
*/
public function purifyText($text, $keyword = false)
{
// $text = str_replace(['&nbsp;', ' '], ['<br>', ' '], $text); //for php 5.4
$text = \str_replace('&nbsp;', ' ', $text);
$text = \str_replace('<br>', ' ', $text);
$text = \strip_tags($text);
$text = \html_entity_decode($text);
$text = $this->myts->undoHtmlSpecialChars($text);

$text = \str_replace(')', ' ', $text);
$text = \str_replace('(', ' ', $text);
$text = \str_replace(':', ' ', $text);
$text = \str_replace('&euro', ' euro ', $text);
$text = \str_replace('&hellip', '...', $text);
$text = \str_replace('&rsquo', ' ', $text);
$text = \str_replace('!', ' ', $text);
$text = \str_replace('?', ' ', $text);
$text = \str_replace('"', ' ', $text);
$text = \str_replace('-', ' ', $text);
$text = \str_replace('\n', ' ', $text);

// $text = str_replace([')','(',':','&euro','&hellip','&rsquo','!','?','"','-','\n'], [' ' , ' ', ' ', ' euro ', '...', ' ', ' ', ' ', ' ', ' ', ' '], $text); //for PHP 5.4

if ($keyword) {
$text = \str_replace('.', ' ', $text);
$text = \str_replace(',', ' ', $text);
$text = \str_replace('\'', ' ', $text);
// $text = str_replace(['.', ' '], [',', ' '], ['\'', ' '], $text); //for PHP 5.4
}
$text = \str_replace(';', ' ', $text);

return $text;
}

/**
* @param string $document
*
* @return mixed
*/
public function html2text($document)
{
if (empty($document)) {
return '';
}
// PHP Manual:: function preg_replace
// $document should contain an HTML document.
// This will remove HTML tags, javascript sections
// and white space. It will also convert some
// common HTML entities to their text equivalent.
// Credits : newbb2
$search = [
"'<script[^>]*?>.*?</script>'si", // Strip out javascript
"'<img.*?>'si", // Strip out img tags
"'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags
"'([\r\n])[\s]+'", // Strip out white space
"'&(quot|#34);'i", // Replace HTML entities
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
]; // evaluate as php

$replace = [
'',
'',
'',
'\\1',
'"',
'&',
'<',
'>',
' ',
\chr(161),
\chr(162),
\chr(163),
\chr(169),
];

$text = \preg_replace($search, $replace, $document);

\preg_replace_callback(
'/&#(\d+);/',
static function ($matches) {
return \chr($matches[1]);
},
$document
);

return $text;
}
}


Voila mon code

Posté le : 12/02/2023 17:14

Je suis souvent copié mais "copié = Synonyme de célébrité" Alors continuez mes fans.
Site Radioamateur Belge
Partager Twitter Partagez cette article sur GG+
Re: Publisher 1.08
Team FrXoops
Inscrit: 14/05/2004 22:32
Messages: 2554
Pas le code, le fichier STP

Posté le : 12/02/2023 19:36

Ne pas perdre patience, même si cela semble impossible, c'est déjà de la patience.
Origami
Conseil des Sages
Sur gitHub
Partager Twitter Partagez cette article sur GG+
Re: Publisher 1.08
Semi pro
Inscrit: 26/07/2011 14:05
De Fleurus (W-B) (Belgique)
Messages: 792
Comment on fait pour attacher le fichier car je ne trouve pas comment faire désoler

Posté le : 13/02/2023 09:17

Je suis souvent copié mais "copié = Synonyme de célébrité" Alors continuez mes fans.
Site Radioamateur Belge
Partager Twitter Partagez cette article sur GG+

 Haut   Précédent   Suivant
« 1 2 (3) 4 5 »



Vous pouvez voir les sujets.
Vous ne pouvez pas débuter de nouveaux sujets.
Vous ne pouvez pas répondre aux contributions.
Vous ne pouvez pas éditer vos contributions.
Vous ne pouvez pas effacez vos contributions.
Vous ne pouvez pas ajouter de nouveaux sondages.
Vous ne pouvez pas voter en sondage.
Vous ne pouvez pas attacher des fichiers à vos contributions.
Vous ne pouvez pas poster sans approbation.

Propulsé avec XOOPS | Graphisme adapté par Tatane, Grosdunord, Montuy337513

44 Personne(s) en ligne (30 Personne(s) connectée(s) sur Forum) | Utilisateur(s): 0 | Invité(s): 44 | Plus ...