Add Code Button to Quick Reply Editor in vBulletin CKEditor

Katılım
12 Haziran 2011
Mesajlar
14.298
Makaleler
3
Çözümler
6
Yer
Nebuchadnezzar
Daha fazla  
Meslek
Judge Dredd
vBulletin comes with CKEditor anymore. So, you don't have to mess with a lot of code if want to add "Code" button near "Quote" button in quick reply editor.

Just open up /httpdocs/forum/vb/ckeditor.php

And then search for

Kod:
'Quote'

You will find something like this:

Kod:
	protected function setToolbar($toolbartype)
	{
		$toolbar = array();
		$iespell = (is_browser('ie') AND !is_browser('ie64bit') AND !is_browser('mac'));
		$justify = (vB::$vbulletin->stylevars['textdirection']['string'] == 'ltr' ? array('JustifyLeft', 'JustifyCenter', 'JustifyRight') : array('JustifyRight', 'JustifyCenter', 'JustifyLeft'));
		if ($this->editor_type == 'qr')
		{
			$toolbar[] = array('RemoveFormat');
			$toolbar[] = array('PasteText', '-', 'Bold', 'Italic', 'Underline');
			$toolbar[] = array('Font', 'FontSize', 'TextColor');
			$toolbar[] = array('Smiley');
			$toolbar[] = array('Link', 'Email', 'Unlink', 'Image', 'Video', '-', 'Quote');

Now add this code after 'Quote':

Kod:
, 'Code'

The result will be like this:

Kod:
	protected function setToolbar($toolbartype)
	{
		$toolbar = array();
		$iespell = (is_browser('ie') AND !is_browser('ie64bit') AND !is_browser('mac'));
		$justify = (vB::$vbulletin->stylevars['textdirection']['string'] == 'ltr' ? array('JustifyLeft', 'JustifyCenter', 'JustifyRight') : array('JustifyRight', 'JustifyCenter', 'JustifyLeft'));
		if ($this->editor_type == 'qr')
		{
			$toolbar[] = array('RemoveFormat');
			$toolbar[] = array('PasteText', '-', 'Bold', 'Italic', 'Underline');
			$toolbar[] = array('Font', 'FontSize', 'TextColor');
			$toolbar[] = array('Smiley');
			$toolbar[] = array('Link', 'Email', 'Unlink', 'Image', 'Video', '-', 'Quote', 'Code');

Do this for two places.

In the end, it will be like this:

Kod:
	/**
	 * Sets the toolbar options in the editor based on the editor type requested
	 *
	 * @var	int	Toolbar type 0 - Simple / 1 - Standard / 2 - WYSIWYG
	 */
	protected function setToolbar($toolbartype)
	{
		$toolbar = array();
		$iespell = (is_browser('ie') AND !is_browser('ie64bit') AND !is_browser('mac'));
		$justify = (vB::$vbulletin->stylevars['textdirection']['string'] == 'ltr' ? array('JustifyLeft', 'JustifyCenter', 'JustifyRight') : array('JustifyRight', 'JustifyCenter', 'JustifyLeft'));
		if ($this->editor_type == 'qr')
		{
			$toolbar[] = array('RemoveFormat');
			$toolbar[] = array('PasteText', '-', 'Bold', 'Italic', 'Underline');
			$toolbar[] = array('Font', 'FontSize', 'TextColor');
			$toolbar[] = array('Smiley');
			$toolbar[] = array('Link', 'Email', 'Unlink', 'Image', 'Video', '-', 'Quote', 'Code');
			if ($iespell)
			{
				$toolbar[] = array('iespell');
			}
			$this->config['toolbar'] = $toolbar;
		}
		else if ($this->editor_type == 'qr_small')
		{
			$toolbar[] = array('RemoveFormat');
			$toolbar[] = array('PasteText', '-', 'Bold', 'Italic', 'Underline');
			$toolbar[] = array('Font', 'FontSize', 'TextColor');
			$toolbar[] = array('Smiley');
			$toolbar[] = array('Link', 'Email', 'Unlink', 'Image', 'Video');
			if ($iespell)
			{
				$toolbar[] = array('iespell');
			}
			$this->config['toolbar'] = $toolbar;
		}
		else if ($this->editor_type == 'qe')
		{
			$toolbar[] = array('RemoveFormat');
			$toolbar[] = array('PasteText', '-', 'Bold', 'Italic', 'Underline');
			$toolbar[] = array('Font', 'FontSize', 'TextColor');
			$toolbar[] = array('Smiley');
			$toolbar[] = array('Link', 'Email', 'Unlink', 'Image', 'Video', '-', 'Quote', 'Code');
			if ($iespell)
			{
				$toolbar[] = array('iespell');
			}
			$this->config['toolbar'] = $toolbar;

Now you can enjoy adding code in quick reply mode
 
Merhaba;
ckeditor.php dosyam sizin gösterdiğinizden farklı. İlgili düzenlemeyi nereden yapabilirim?
Dosya içeriği aşağıdaki gibi. Vb versiyonu 4.2.2

Kod:
<?php/*======================================================================*\
|| #################################################################### ||
|| # vBulletin 4.2.1 - Licence Number XXXXXXXX
|| # ---------------------------------------------------------------- # ||
|| # Copyright ©2000-2013 vBulletin Solutions Inc. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/


// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);


// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'ckeditor');
define('CSRF_PROTECTION', true);
define('NOPMPOPUP', 1);
define('NOCOOKIES', 1);
define('NONOTICES', 1);
define('NOHEADER', 1);
define('NOSHUTDOWNFUNC', 1);
define('LOCATION_BYPASS', 1);
define('NOGLOBALPHRASE', 1);


// Immediately send back the 304 Not Modified header if this is cached, don't load global.php
if ((!empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) OR !empty($_SERVER['HTTP_IF_NONE_MATCH'])))
{
    $sapi_name = php_sapi_name();
    if ($sapi_name == 'cgi' OR $sapi_name == 'cgi-fcgi')
    {
        header('Status: 304 Not Modified');
    }
    else
    {
        header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
    }
    // remove the content-type and X-Powered headers to emulate a 304 Not Modified response as close as possible
    header('Content-Type:');
    header('X-Powered-By:');
    exit;
}


// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array('ckeditor');


// get special data templates from the datastore
$specialtemplates = array();


// pre-cache templates used by all actions  - build
$globaltemplates = array();


// pre-cache templates used by specific actions
$actiontemplates = array();


// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/class_xml.php');


// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################


header('Pragma:'); // VBIV-8269 
header('Cache-control: max-age=31536000, private');
header('Expires: ' . gmdate("D, d M Y H:i:s", TIMENOW + 31536000) . ' GMT');


// When were the CKEditor phrases last modified? Good Question.
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');


$xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml');
$xml->add_group('phrases');


foreach ($vbphrase AS $key => $phrase)
{
    $xml->add_tag('phrase', $phrase, array(
        'name'  => $key,
    ));
}


$xml->close_group('group');
$xml->print_xml();


/*======================================================================*\
|| ####################################################################
|| # Downloaded: 07:36, Thu Apr 18th 2013
|| # CVS: $RCSfile$ - $Revision: 30573 $
|| ####################################################################
\*======================================================================*/

Edit: yanlış dosyaya bakmışım.

İşe yaradı. Teşekkür ederim.
 
Son düzenleyen: Moderatör:
Bu siteyi kullanmak için çerezler gereklidir. Siteyi kullanmaya devam etmek için çerezleri kabul etmelisiniz. Daha Fazlasını Öğren.…