Easy-Design.Net forum




Documentations et Dossiers [Extras] Youtube dans votre PHPBoost V3

Patrice Membre non connecté

EDN Intéressé(e)

Rang

Avatar

Inscrit le : 10/03/2012 à 14h27

Messages: 50

Le 03/04/2015 à 22h06

Reprise du message précédent

Swan:
Bonjour,

Bon courant Pâques ( pendant les vacances) je vous le ferais le tuto ^^

Merci Sonic ^^


Merci Swan !!!!! Merci beaucoup ! :ok :)

Site web    
m-ickael Membre non connecté

EDN Maitre-Sage

Rang

Avatar

Inscrit le : 23/02/2010 à 09h15

Messages: 2296

Le 03/04/2015 à 22h57
Merci par avance.
Patrice Membre non connecté

EDN Intéressé(e)

Rang

Avatar

Inscrit le : 10/03/2012 à 14h27

Messages: 50

Le 27/06/2015 à 00h17
Coucou Swan !

C'est le lourdingue qui revient à la charge sur ce post :D

Je ne pense pas que tu aies eu le temps de t'en occuper, mais j'espère que les vacances d'été seront propices à rédaction de ce tuto ;)

@++
patrice
Site web    
Swan Membre non connecté

Administrateur

Rang

Avatar

Inscrit le : 01/08/2009 à 22h53

Messages: 8431

Le 27/06/2015 à 11h48
Bonjour,

C'est vrai ! Ouille oui .. En post'it sur mon bureau virtuel.



swan_signature

Site web    
Swan Membre non connecté

Administrateur

Rang

Avatar

Inscrit le : 01/08/2009 à 22h53

Messages: 8431

Le 08/07/2015 à 17h29
Bonjour,

Et voilà comme promis de longue date, je vous ai fait le tuto : Youtube dans votre PHPBoost V3

J'ai retenté la procédure en locale sur la 3.0.11 et c'est fonctionnel ! Amusez vous bien ;)

Swan :study


swan_signature

Site web    
Patrice Membre non connecté

EDN Intéressé(e)

Rang

Avatar

Inscrit le : 10/03/2012 à 14h27

Messages: 50

Le 08/07/2015 à 18h00
Merci infiniment Swan !
Je teste ça dès ce soir normalement. Je suis impressionné par la longueur du tuto :oO
Site web    
Swan Membre non connecté

Administrateur

Rang

Avatar

Inscrit le : 01/08/2009 à 22h53

Messages: 8431

Le 08/07/2015 à 18h50
Mais non il est pas long :D
Il est très simple à appliquer si on suit bien le tuto :)


swan_signature

Site web    
Patrice Membre non connecté

EDN Intéressé(e)

Rang

Avatar

Inscrit le : 10/03/2012 à 14h27

Messages: 50

Le 08/07/2015 à 18h57
Par contre, j'ai jamais dit qu'il était difficile :rolleyes
Ce sera même un plaisir de le tester, et les membres de mon association vont adorer l'utilité de cette fonction !
Site web    
Patrice Membre non connecté

EDN Intéressé(e)

Rang

Avatar

Inscrit le : 10/03/2012 à 14h27

Messages: 50

Le 08/07/2015 à 22h48
Aïe, aïe, aïe...

une fois le cache généré j'ai ce message et je ne comprends pas ce qui ne va pas....

"Parse error: syntax error, unexpected T_STRING in /home/adalaero/www/kernel/framework/content/parser/content_second_parser.class.php on line 283"

Site web    
Swan Membre non connecté

Administrateur

Rang

Avatar

Inscrit le : 01/08/2009 à 22h53

Messages: 8431

Le 09/07/2015 à 00h54
Re,

Patrice est ce que tu peux me poser le fichier "content_second_parser.class.php", tel que tu l'as modifié , s'il te plait ?


swan_signature

Site web    
Patrice Membre non connecté

EDN Intéressé(e)

Rang

Avatar

Inscrit le : 10/03/2012 à 14h27

Messages: 50

Le 09/07/2015 à 01h03
oui, le voilà:

Code PHP :
 
<?php
/*##################################################
 *                        content_second_parser.class.php
 *                            -------------------
 *   begin                : August 10, 2008
 *   copyright            : (C) 2008 Benoit Sautel
 *   email                : [[email protected]][email protected][/mail]
 *
 *
 ###################################################
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *  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.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 ###################################################*/
 
import('content/parser/parser');
 
/**
 * @package content
 * @subpackage parser
 * @desc This class ensures the real time processing of the content. The major part of the processing is saved in the database to minimize as much as possible the treatment
 * when the content is displayed. However, some tags cannot be cached, because we cannot have return to the original code. It's for instance the case of the code tag
 * which replaces the code by a lot of html code which formats the code.
 * This kind of tag is treated in real time by this class.
 * The content you put in that parser must come from a ContentParser class (BBCodeParser or TinyMCEParser) (it can have been saved in a database between the first parsing and the real time parsing).
 * @author Benoît Sautel <[email protected]>
 */
class ContentSecondParser extends Parser
{
######## Public #######
/**
* @desc Builds a ContentSecondParser object
*/
function ContentSecondParser()
{
parent::Parser();
}
 
/**
 * @desc Parses the content of the parser. The result will be ready to be displayed.
 */
function parse()
{
global $LANG;
 
//Balise code
if (strpos($this->content, '[[CODE') !== false)
{
$this->content = preg_replace_callback('`[[CODE(?:=([A-Za-z0-9#+-]+))?(?:,(0|1)(?:,(0|1))?)?]](.+)
`sU', array(&$this, '_callback_highlight_code'), $this->content); } //Media if (strpos($this->content, '[[MEDIA]]') !== false) { $this->_process_media_insertion(); } //Balise latex. if (strpos($this->content, '') !== false)
{
require_once(PATH_TO_ROOT . '/kernel/framework/content/math/mathpublisher.php');
$this->content = preg_replace_callback('`[[MATH]](.+)`sU', array(&$this, '_math_code'), $this->content); } import('util/url'); $this->content = Url::html_convert_root_relative2absolute($this->content, $this->path_to_root, $this->page_path); } /** * @desc Transforms a PHPBoost HTML content to make it exportable and usable every where in the web. * @param string $html Content to transform * @return string The exportable content */ function export_html_text($html_content) { import('util/url'); //Balise vidéo $html_content = preg_replace('`
s*`isU', ' ', $html_content); return Url::html_convert_root_relative2absolute($html_content); } ## Private ## /** * @static * @desc Highlights a content in a supported language using the appropriate syntax highlighter. * The highlighted languages are numerous: actionscript, asm, asp, bash, c, cpp, csharp, css, d, delphi, fortran, html, * java, javascript, latex, lua, matlab, mysql, pascal, perl, php, python, rails, ruby, sql, text, vb, xml, * PHPBoost templates and PHPBoost BBCode. * @param string $contents Content to highlight * @param string $language Language name * @param bool $line_number Indicate whether or not the line number must be added to the code. * @param bool $inline_code Indicate if the code is multi line. */ function _highlight_code($contents, $language, $line_number, $inline_code) { $contents = htmlspecialchars_decode($contents); //BBCode PHPBoost if (strtolower($language) == 'bbcode') { import('content/parser/bbcode_highlighter'); $bbcode_highlighter = new BBCodeHighlighter(); $bbcode_highlighter->set_content($contents, PARSER_DO_NOT_STRIP_SLASHES); $bbcode_highlighter->parse($inline_code); $contents = $bbcode_highlighter->get_content(DO_NOT_ADD_SLASHES); } //Templates PHPBoost elseif (strtolower($language) == 'tpl' || strtolower($language) == 'template') { import('content/parser/template_highlighter'); require_once(PATH_TO_ROOT . '/kernel/framework/content/geshi/geshi.php'); $template_highlighter = new TemplateHighlighter(); $template_highlighter->set_content($contents, PARSER_DO_NOT_STRIP_SLASHES); $template_highlighter->parse($line_number ? GESHI_NORMAL_LINE_NUMBERS : GESHI_NO_LINE_NUMBERS, $inline_code); $contents = $template_highlighter->get_content(DO_NOT_ADD_SLASHES); } elseif ($language != '') { require_once(PATH_TO_ROOT . '/kernel/framework/content/geshi/geshi.php'); $Geshi = new GeSHi($contents, $language); if ($line_number) //Affichage des numéros de lignes. $Geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); //No container if we are in an inline tag if ($inline_code) $Geshi->set_header_type(GESHI_HEADER_NONE); $contents = '
' . $Geshi->parse_code() . '
'; } else { $highlight = highlight_string($contents, true); $font_replace = str_replace(array(''), array(''), $highlight); $contents = preg_replace('`color="(.*?)"`', 'style="color:$1"', $font_replace); } return $contents; } /** * @static * @desc Handler which highlights a string matched by the preg_replace_callback function. * @param string[] $matches The matched contents: 0 => the whole string, 1 => the language, 2 => number count?, * 3 => multi line?, 4 => the code to highlight. * @return string the colored content */ function _callback_highlight_code($matches) { global $LANG; $line_number = !empty($matches[2]); $inline_code = !empty($matches[3]); $contents = $this->_highlight_code($matches[4], $matches[1], $line_number, $inline_code); if (!$inline_code && !empty($matches[1])) { $contents = '' . sprintf($LANG['code_langage'], strtoupper($matches[1])) . '
' . $contents .'
'; } else if (!$inline_code && empty($matches[1])) { $contents = '' . $LANG['code_tag'] . '
' . $contents . '
'; } return $contents; } /** * @static * @desc Parses the latex code and replaces it by an image containing the mathematic formula. * @param string[] $matches 0 => the whole tag, 1 => the latex code to parse. * @return string The code of the image containing the formula. */ function _math_code($matches) { $matches[1] = str_replace('
', '', $matches[1]); $matches = mathfilter(html_entity_decode($matches[1], ENT_COMPAT, 'ISO-8859-1'), 12); return $matches; } /** * Processes the media insertion it replaces the [[MEDIA]]tag[[/MEDIA]] by the Javascript API correspondig calls. */ function _process_media_insertion() { //Swf $this->content=preg_replace_callback('`[[MEDIA]]insertSwfPlayer('([^']+)', ([0-9]+), ([0-9]+));[[/MEDIA]]`isU',array('ContentSecondParser','_process_swf_tag'),$this->content); //Movie $this->content=preg_replace_callback('`[[MEDIA]]insertMoviePlayer('([^']+)', ([0-9]+), ([0-9]+));[[/MEDIA]]`isU',array('ContentSecondParser','_process_movie_tag'),$this->content); //Sound $this->content=preg_replace_callback('`[[MEDIA]]insertSoundPlayer('([^']+)');[[/MEDIA]]`isU',array('ContentSecondParser','_process_sound_tag'),$this->content); //Youtube $this->content = preg_replace_callback('`[[MEDIA]]insertYoutubePlayer('([^']+)', ([0-9]+), ([0-9]+));[[/MEDIA]]`isU', array('ContentSecondParser', '_process_youtube_tag'), $this->content); } /** * Inserts the javascript calls for the swf tag. * @param $matches The matched elements * @return The movie insertion code containing javascrpt calls */ function _process_swf_tag($matches) { return "" . "" . "" . "" . "" . "" . "" . "" . "" . ""; } /** * Inserts the javascript calls for the movie tag. * @param $matches The matched elements * @return The movie insertion code containing javascrpt calls */ function _process_movie_tag($matches) { $id = 'movie_' . get_uid(); return '
' . ''; } /** * Inserts the javascript calls for the sound tag. * @param $matches The matched elements * @return The movie insertion code containing javascrpt calls */ function _process_sound_tag($matches) { //Balise son return ' '; } function _process_youtube_tag($matches) { //Balise youtube $matches[1] = str_replace(array('/watch?v=', '/embed/'), '/v/', $matches[1]); return "" . "" . "" . "" . "" . "" . "" . "" . "" . ""; } } ?>[[/CODE]]
Site web    
Swan Membre non connecté

Administrateur

Rang

Avatar

Inscrit le : 01/08/2009 à 22h53

Messages: 8431

Le 09/07/2015 à 01h14
Je te zieute cela demain à tête reposée, j'ai plus les yeux là ;)


swan_signature

Site web    
Patrice Membre non connecté

EDN Intéressé(e)

Rang

Avatar

Inscrit le : 10/03/2012 à 14h27

Messages: 50

Le 09/07/2015 à 01h17
pas de soucis, je t'en remercie d'avance. J'espère que ça fonctionnera :)

bonne nuit !
Site web    
janus57 Membre non connecté

EDN Erudit(e)

Rang

Avatar

Inscrit le : 14/01/2013 à 21h59

Messages: 1018

Le 09/07/2015 à 01h24
Bonjour,

essaye ceci :
Code PHP :
 
<?php
/*##################################################
 *                        content_second_parser.class.php
 *                            -------------------
 *   begin                : August 10, 2008
 *   copyright            : (C) 2008 Benoit Sautel
 *   email                : [[email protected]][email protected][/mail]
 *
 *
 ###################################################
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *  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.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 ###################################################*/
 
import('content/parser/parser');
 
/**
 * @package content
 * @subpackage parser
 * @desc This class ensures the real time processing of the content. The major part of the processing is saved in the database to minimize as much as possible the treatment
 * when the content is displayed. However, some tags cannot be cached, because we cannot have return to the original code. It's for instance the case of the code tag
 * which replaces the code by a lot of html code which formats the code.
 * This kind of tag is treated in real time by this class.
 * The content you put in that parser must come from a ContentParser class (BBCodeParser or TinyMCEParser) (it can have been saved in a database between the first parsing and the real time parsing).
 * @author Benoît Sautel <[email protected]>
 */
class ContentSecondParser extends Parser
{
######## Public #######
/**
* @desc Builds a ContentSecondParser object
*/
function ContentSecondParser()
{
parent::Parser();
}
 
/**
 * @desc Parses the content of the parser. The result will be ready to be displayed.
 */
function parse()
{
global $LANG;
 
//Balise code
if (strpos($this->content, '[[CODE') !== false)
{
$this->content = preg_replace_callback('`[[CODE(?:=([A-Za-z0-9#+-]+))?(?:,(0|1)(?:,(0|1))?)?]](.+)
`sU', array(&$this, '_callback_highlight_code'), $this->content); } //Media if (strpos($this->content, '[[MEDIA]]') !== false) { $this->_process_media_insertion(); } //Balise latex. if (strpos($this->content, '') !== false)
{
require_once(PATH_TO_ROOT . '/kernel/framework/content/math/mathpublisher.php');
$this->content = preg_replace_callback('`[[MATH]](.+)`sU', array(&$this, '_math_code'), $this->content); } import('util/url'); $this->content = Url::html_convert_root_relative2absolute($this->content, $this->path_to_root, $this->page_path); } /** * @desc Transforms a PHPBoost HTML content to make it exportable and usable every where in the web. * @param string $html Content to transform * @return string The exportable content */ function export_html_text($html_content) { import('util/url'); //Balise vidéo $html_content = preg_replace('`
s*`isU', ' ', $html_content); return Url::html_convert_root_relative2absolute($html_content); } ## Private ## /** * @static * @desc Highlights a content in a supported language using the appropriate syntax highlighter. * The highlighted languages are numerous: actionscript, asm, asp, bash, c, cpp, csharp, css, d, delphi, fortran, html, * java, javascript, latex, lua, matlab, mysql, pascal, perl, php, python, rails, ruby, sql, text, vb, xml, * PHPBoost templates and PHPBoost BBCode. * @param string $contents Content to highlight * @param string $language Language name * @param bool $line_number Indicate whether or not the line number must be added to the code. * @param bool $inline_code Indicate if the code is multi line. */ function _highlight_code($contents, $language, $line_number, $inline_code) { $contents = htmlspecialchars_decode($contents); //BBCode PHPBoost if (strtolower($language) == 'bbcode') { import('content/parser/bbcode_highlighter'); $bbcode_highlighter = new BBCodeHighlighter(); $bbcode_highlighter->set_content($contents, PARSER_DO_NOT_STRIP_SLASHES); $bbcode_highlighter->parse($inline_code); $contents = $bbcode_highlighter->get_content(DO_NOT_ADD_SLASHES); } //Templates PHPBoost elseif (strtolower($language) == 'tpl' || strtolower($language) == 'template') { import('content/parser/template_highlighter'); require_once(PATH_TO_ROOT . '/kernel/framework/content/geshi/geshi.php'); $template_highlighter = new TemplateHighlighter(); $template_highlighter->set_content($contents, PARSER_DO_NOT_STRIP_SLASHES); $template_highlighter->parse($line_number ? GESHI_NORMAL_LINE_NUMBERS : GESHI_NO_LINE_NUMBERS, $inline_code); $contents = $template_highlighter->get_content(DO_NOT_ADD_SLASHES); } elseif ($language != '') { require_once(PATH_TO_ROOT . '/kernel/framework/content/geshi/geshi.php'); $Geshi = new GeSHi($contents, $language); if ($line_number) //Affichage des numéros de lignes. $Geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); //No container if we are in an inline tag if ($inline_code) $Geshi->set_header_type(GESHI_HEADER_NONE); $contents = '
' . $Geshi->parse_code() . '
'; } else { $highlight = highlight_string($contents, true); $font_replace = str_replace(array(''), array(''), $highlight); $contents = preg_replace('`color="(.*?)"`', 'style="color:$1"', $font_replace); } return $contents; } /** * @static * @desc Handler which highlights a string matched by the preg_replace_callback function. * @param string[] $matches The matched contents: 0 => the whole string, 1 => the language, 2 => number count?, * 3 => multi line?, 4 => the code to highlight. * @return string the colored content */ function _callback_highlight_code($matches) { global $LANG; $line_number = !empty($matches[2]); $inline_code = !empty($matches[3]); $contents = $this->_highlight_code($matches[4], $matches[1], $line_number, $inline_code); if (!$inline_code && !empty($matches[1])) { $contents = '' . sprintf($LANG['code_langage'], strtoupper($matches[1])) . '
' . $contents .'
'; } else if (!$inline_code && empty($matches[1])) { $contents = '' . $LANG['code_tag'] . '
' . $contents . '
'; } return $contents; } /** * @static * @desc Parses the latex code and replaces it by an image containing the mathematic formula. * @param string[] $matches 0 => the whole tag, 1 => the latex code to parse. * @return string The code of the image containing the formula. */ function _math_code($matches) { $matches[1] = str_replace('
', '', $matches[1]); $matches = mathfilter(html_entity_decode($matches[1], ENT_COMPAT, 'ISO-8859-1'), 12); return $matches; } /** * Processes the media insertion it replaces the [[MEDIA]]tag[[/MEDIA]] by the Javascript API correspondig calls. */ function _process_media_insertion() { //Swf $this->content=preg_replace_callback('`[[MEDIA]]insertSwfPlayer('([^']+)', ([0-9]+), ([0-9]+));[[/MEDIA]]`isU',array('ContentSecondParser','_process_swf_tag'),$this->content); //Movie $this->content=preg_replace_callback('`[[MEDIA]]insertMoviePlayer('([^']+)', ([0-9]+), ([0-9]+));[[/MEDIA]]`isU',array('ContentSecondParser','_process_movie_tag'),$this->content); //Sound $this->content=preg_replace_callback('`[[MEDIA]]insertSoundPlayer('([^']+)');[[/MEDIA]]`isU',array('ContentSecondParser','_process_sound_tag'),$this->content); //Youtube $this->content = preg_replace_callback('`[[MEDIA]]insertYoutubePlayer('([^']+)', ([0-9]+), ([0-9]+));[[/MEDIA]]`isU', array('ContentSecondParser', '_process_youtube_tag'), $this->content); } /** * Inserts the javascript calls for the swf tag. * @param $matches The matched elements * @return The movie insertion code containing javascrpt calls */ function _process_swf_tag($matches) { return "" . "" . "" . "" . "" . "" . "" . "" . "" . ""; } /** * Inserts the javascript calls for the movie tag. * @param $matches The matched elements * @return The movie insertion code containing javascrpt calls */ function _process_movie_tag($matches) { $id = 'movie_' . get_uid(); return '
' . ''; } /** * Inserts the javascript calls for the sound tag. * @param $matches The matched elements * @return The movie insertion code containing javascrpt calls */ function _process_sound_tag($matches) { //Balise son return ' '; } function _process_youtube_tag($matches) { //Balise youtube $matches[1] = str_replace(array('/watch?v=', '/embed/'), '/v/', $matches[1]); return ' '; } } ?> [[/CODE]]

Cordialement, janus57
   
Patrice Membre non connecté

EDN Intéressé(e)

Rang

Avatar

Inscrit le : 10/03/2012 à 14h27

Messages: 50

Le 09/07/2015 à 01h27
salut Janus,

Nikel ça fonctionne !! :D :D :D
Site web    
Swan Membre non connecté

Administrateur

Rang

Avatar

Inscrit le : 01/08/2009 à 22h53

Messages: 8431

Le 09/07/2015 à 11h47
Bonjour,

Merci Janus, hé oui, problème de crochets ... Surement dû à une correction que j'avais pas appliqué sur ce fichier, vu que EDN est en 3.0.10 et pas 11 ...

Tuto corrigé.


swan_signature

Site web    
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie