So ich hab jetzt die Möglichkeit gefunden bbcodes mittels insert Befehl in die bbcodes Tabelle vom Forum zu schreiben.
Der Eintrag in der Migrationsdatei sieht dabei wie folgt aus:
Code: Alles auswählen
public function update_data()
{
return array(
array('custom', array(array($this, 'import_bbcode'))),
);
}
public function import_bbcode()
{
$sqlary = array(
"INSERT INTO " . $this->table_prefix . 'bbcodes' . " (`bbcode_id`, `bbcode_tag`, `bbcode_helpline`, `display_on_posting`, `bbcode_match`, `bbcode_tpl`, `first_pass_match`, `first_pass_replace`, `second_pass_match`, `second_pass_replace`) VALUES (01, 'youtube', '', 1, '[youtube]https://{IDENTIFIER2}.youtube.com/watch?v={IDENTIFIER}[/youtube]', '<div class=\"videoCConsentContainer\" data-source=\"{IDENTIFIER}\">\n <div class=\"ccMessageContainer embed-responsive embed-responsive-16by9\">\n <div class=\"msgMedienContent\">\n <p>Video: https://{IDENTIFIER2}.youtube.com/watch?v={IDENTIFIER}<br><br>{L_COOKIE_INFO}</p>\n <a class=\"btn btn-primary\" onclick=\"return klaro.show();\">Cookie-Consent-Einstellungen anpassen</a>\n </div>\n </div>\n <div class=\"videoLayer embed-responsive embed-responsive-16by9 vimvid\"></div>\n</div>', '/(?!)/', '', '/(?!)/', '');",
);
foreach ($sqlary as $sql)
{
$this->db->sql_query($sql);
}
}
Der eigentliche einfügen Befehl sieht dann so aus:
Code: Alles auswählen
"INSERT INTO " . $this->table_prefix . 'bbcodes' . " (`bbcode_id`, `bbcode_tag`, `bbcode_helpline`, `display_on_posting`, `bbcode_match`, `bbcode_tpl`, `first_pass_match`, `first_pass_replace`, `second_pass_match`, `second_pass_replace`) VALUES (01, 'youtube', '', 1, '[youtube]https://{IDENTIFIER2}.youtube.com/watch?v={IDENTIFIER}[/youtube]', '<div class=\"videoCConsentContainer\" data-source=\"{IDENTIFIER}\">\n <div class=\"ccMessageContainer embed-responsive embed-responsive-16by9\">\n <div class=\"msgMedienContent\">\n <p>Video: https://{IDENTIFIER2}.youtube.com/watch?v={IDENTIFIER}<br><br>{L_COOKIE_INFO}</p>\n <a class=\"btn btn-primary\" onclick=\"return klaro.show();\">Cookie-Consent-Einstellungen anpassen</a>\n </div>\n </div>\n <div class=\"videoLayer embed-responsive embed-responsive-16by9 vimvid\"></div>\n</div>', '/(?!)/', '', '/(?!)/', '');",
Bis hier hin ist das kein Problem. Gut ich kann die ID jetzt mit dem Befehl nicht automatisch ermitteln lassen und um nur eine stelle der letzten ID erhöhen. Aber wenn ich die ID auf 1000 setze sollte es kein Problem geben mit dem erstellen. Ich wage zu bezweifeln das man diese ID mit automatischer Zählweise der bbcodes erreicht.
Mein Problem ist aber das Entfernen des bbcods bei Arbeitsdaten Löschung der Extension, die ich schreibe.
Im Moment sieht das so aus:
Code: Alles auswählen
public function revert_schema()
{
return array(
array('custom', array(array($this, 'remove_bbcode'))),
);
}
public function remove_bbcode()
{
$sqlary = array(
"DELETE FROM " . $this->table_prefix . 'bbcodes' . " WHERE `phpbb_bbcodes`.`bbcode_id` = 1 ;",
);
foreach ($sqlary as $sql)
{
$this->db->sql_query($sql);
}
}
Der lädt zwar aber der bbcode ist immer noch in der Tabelle enthalten. Das Problem ist sollte die extension deinstalliert werden und später nochmal installiert werden würde die Installationsroutine den Die doppelte id bemängeln.
@edit
Habe es jetzt so gelöst:
Code: Alles auswählen
public function update_data()
{
return array(
array('custom', array(array($this, 'import_bbcode'))),
);
}
public function import_bbcode()
{
$sqlary = array(
"INSERT INTO " . $this->table_prefix . 'bbcodes' . " (`bbcode_id`, `bbcode_tag`, `bbcode_helpline`, `display_on_posting`, `bbcode_match`, `bbcode_tpl`, `first_pass_match`, `first_pass_replace`, `second_pass_match`, `second_pass_replace`) VALUES (1001, 'youtube', '', 0, '[youtube]https://{IDENTIFIER2}.youtube.com/watch?v={IDENTIFIER}[/youtube]', '<div class=\"videoCConsentContainer\" data-source=\"{IDENTIFIER}\">\n <div class=\"ccMessageContainer embed-responsive embed-responsive-16by9\">\n <div class=\"msgMedienContent\">\n <p>Video: https://{IDENTIFIER2}.youtube.com/watch?v={IDENTIFIER}<br><br>{L_COOKIE_INFO}</p>\n <a class=\"btn btn-primary\" onclick=\"return klaro.show();\">Cookie-Consent-Einstellungen anpassen</a>\n </div>\n </div>\n <div class=\"videoLayer embed-responsive embed-responsive-16by9 vimvid\"></div>\n</div>', '/(?!)/', '', '/(?!)/', '');",
);
foreach ($sqlary as $sql)
{
$this->db->sql_query($sql);
}
}
public function revert_schema()
{
$sqlary = array(
"DELETE FROM " . $this->table_prefix . 'bbcodes' . " WHERE `bbcode_id` = 1001;",
);
foreach ($sqlary as $sql)
{
$this->db->sql_query($sql);
}
}
}
Das generiert im Oberen Teil die bbcodes und im unteren Teil löscht es diese bei deinstallierung wieder. Das einzige was ich nicht hinbekomme ist das der id wert sich automatisch um eins erhöht wenn in der bbcode tabelle schon welche vorhanden sind. Daher habe ich für meine Extension jetzt als id bei 1001 angefangen. Ich denke da sollte sich auch nicht die advanced bbcode box mit quer kommen. In meinen Tests funktioniert beides egal welche reienfolge man installiert. aber wenn man nach meiner Extension die bbcode box installiert mus man meoine nochmal neu installieren da die alle bbcodes löscht bei erstinstallation.