Integration hookslar nedir nasil yapilir

Started by CaptainJack, February 14, 2024, 04:37:41 PM

Previous topic - Next topic

CaptainJack

Manuel modifikasyon yaparken kancalari nasil calistircaz nerede calistircaz?


CaptainJack

Cok karisik nasil yapicaz anlamadim. Bi örnek olsaydi keske

Bugo

Öğrenmek için diğer projeleri örnek olarak kullanabilirsiniz. Örneğin, bir zamanlar Suki, digger ve diğer birçok geliştiricinin modlarından öğrendim.

CaptainJack


webtiryaki

Quote from: CaptainJack on February 17, 2024, 01:46:32 AMyok örnek yok nasıl yapıcam
tamamda buna sen karar vermen Lazım ne yazacağını bilememki ben

<?php

declare(strict_types=1);


if (
file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
    require_once(
dirname(__FILE__) . '/SSI.php');

elseif (!
defined('SMF'))
    exit(
'<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');

global 
$context;

$hookCall = !empty($context['uninstalling']) ? 'remove_integration_function' 'add_integration_function';

// Everybody likes hooks
$hooks = [
    
'integrate_pre_include' => '$sourcedir/xxx.php',
    
'integrate_member_context' => 'xxxx',
    
'integrate_general_mod_settings' => 'xxx',
    
'integrate_prepare_display_context' => 'xxx',
    
'integrate_load_custom_profile_fields' => 'xxx',
];

foreach (
$hooks as $hook => $function)
    
$hookCall($hook$function);


CaptainJack


webtiryaki

Quote from: CaptainJack on February 18, 2024, 11:03:46 AMAbi bi yardim edin ya

<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<id>Kira_:TgWaShare</id>
<name>Tg and Wa share post</name>
<version>1.0b</version>
<type>modification</type>

<install for="2.1.*">
<require-file name="TgWaShare.php" destination="$sourcedir" />
<require-dir name="languages" destination="$themedir" />
<require-file name="icons/Telegram.png" destination="$themedir/images/icons" />
<require-file name="icons/Whatsapp.png" destination="$themedir/images/icons" />
<hook hook="integrate_post_quickbuttons" function="post_quickbuttons" file="$sourcedir/TgWaShare.php" />
</install>

<uninstall for="2.1.*">
<hook hook="integrate_post_quickbuttons" function="post_quickbuttons" file="$sourcedir/TgWaShare.php" reverse="true" />
<remove-file name="$sourcedir/TgWaShare.php" />
<remove-file name="$languagedir/TgWaShare.english.php" />
<remove-file name="$languagedir/TgWaShare.russian.php" />
<remove-file name="$themedir/images/icons/Telegram.png" />
<remove-file name="$themedir/images/icons/Whatsapp.png" />
</uninstall>
</package-info>

<?php
if (!defined('SMF'))
    die(
'Hacking attempt...');

function 
post_quickbuttons(&$list_items)
{
global $settings,$txt;
loadLanguage('TgWaShare');

$url=preg_replace('%(index.php\?)(.*)(msg=)%i''$1$3'$list_items['more']['report']['href']);

$tg_button['tg_button']=array(
        
'label' => '<img style="width: 20px; margin-bottom: -5px;" src="'$settings['images_url'] . '/icons/Telegram.png">'.$txt['TgWaShare'],
        
'href'  => 'https://t.me/share/url?url='.rawurlencode($url),
'show'  => true
    
);

$wa_button['wa_button']=array(
        
'label' => '<img style="width: 20px; margin-bottom: -5px;" src="'$settings['images_url'] . '/icons/Whatsapp.png">'.$txt['TgWaShare'],
        
'href'  => 'https://api.whatsapp.com/send?text='.rawurlencode($url),
'show'  => true
    
);

$list_items['more']=array_merge($wa_button,$list_items['more']);
$list_items['more']=array_merge($tg_button,$list_items['more']);
}
?>

CaptainJack


CaptainJack

Quote from: webtiryaki on February 18, 2024, 11:32:55 AM
Quote from: CaptainJack on February 18, 2024, 11:03:46 AMAbi bi yardim edin ya

<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<id>Kira_:TgWaShare</id>
<name>Tg and Wa share post</name>
<version>1.0b</version>
<type>modification</type>

<install for="2.1.*">
<require-file name="TgWaShare.php" destination="$sourcedir" />
<require-dir name="languages" destination="$themedir" />
<require-file name="icons/Telegram.png" destination="$themedir/images/icons" />
<require-file name="icons/Whatsapp.png" destination="$themedir/images/icons" />
<hook hook="integrate_post_quickbuttons" function="post_quickbuttons" file="$sourcedir/TgWaShare.php" />
</install>

<uninstall for="2.1.*">
<hook hook="integrate_post_quickbuttons" function="post_quickbuttons" file="$sourcedir/TgWaShare.php" reverse="true" />
<remove-file name="$sourcedir/TgWaShare.php" />
<remove-file name="$languagedir/TgWaShare.english.php" />
<remove-file name="$languagedir/TgWaShare.russian.php" />
<remove-file name="$themedir/images/icons/Telegram.png" />
<remove-file name="$themedir/images/icons/Whatsapp.png" />
</uninstall>
</package-info>

<?php
if (!defined('SMF'))
    die(
'Hacking attempt...');

function 
post_quickbuttons(&$list_items)
{
global $settings,$txt;
loadLanguage('TgWaShare');

$url=preg_replace('%(index.php\?)(.*)(msg=)%i''$1$3'$list_items['more']['report']['href']);

$tg_button['tg_button']=array(
        
'label' => '<img style="width: 20px; margin-bottom: -5px;" src="'$settings['images_url'] . '/icons/Telegram.png">'.$txt['TgWaShare'],
        
'href'  => 'https://t.me/share/url?url='.rawurlencode($url),
'show'  => true
    
);

$wa_button['wa_button']=array(
        
'label' => '<img style="width: 20px; margin-bottom: -5px;" src="'$settings['images_url'] . '/icons/Whatsapp.png">'.$txt['TgWaShare'],
        
'href'  => 'https://api.whatsapp.com/send?text='.rawurlencode($url),
'show'  => true
    
);

$list_items['more']=array_merge($wa_button,$list_items['more']);
$list_items['more']=array_merge($tg_button,$list_items['more']);
}
?>
bu kodlari nereye yazicam

CaptainJack

Bi yardim edin allah rizasi icin kafayi yicem. En basindan bi anlatin

Bugo

Okumak istemiyorsanız bunu size nasıl açıklayabilirim? Bunu resimlerde deneyeceğim. Her modun, manuel kurulum prosedürünü görüntüleyen bir ayrıştırma düğmesi vardır.




Kanca eklemek için forumun kök dizininde bir dosya oluşturun ve oraya aşağıdaki kodu ekleyin:
hooks.php:

<?php


if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
    require_once(
dirname(__FILE__) . '/SSI.php');

elseif (!
defined('SMF'))
    exit(
'<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');

global 
$context;

$hookCall = !empty($context['uninstalling']) ? 'remove_integration_function' 'add_integration_function';

$hooks = [
    
'integrate_post_quickbuttons' => '$sourcedir/TgWaShare.php|post_quickbuttons',
];

foreach (
$hooks as $hook => $function)
    
$hookCall($hook$function);

echo 
'Ok';


Ardından tarayıcınızda aşağıdaki adresi açın: https://<forumunuz>/hooks.php

Bundan sonra hooks.php kaldırılabilir.

CaptainJack

Quote from: Bugo on February 20, 2024, 10:36:08 AMOkumak istemiyorsanız bunu size nasıl açıklayabilirim? Bunu resimlerde deneyeceğim. Her modun, manuel kurulum prosedürünü görüntüleyen bir ayrıştırma düğmesi vardır.

[nofollow]
[nofollow]

Kanca eklemek için forumun kök dizininde bir dosya oluşturun ve oraya aşağıdaki kodu ekleyin:
hooks.php:

<?php


if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
    require_once(
dirname(__FILE__) . '/SSI.php');

elseif (!
defined('SMF'))
    exit(
'<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');

global 
$context;

$hookCall = !empty($context['uninstalling']) ? 'remove_integration_function' 'add_integration_function';

$hooks = [
    
'integrate_post_quickbuttons' => '$sourcedir/TgWaShare.php|post_quickbuttons',
];

foreach (
$hooks as $hook => $function)
    
$hookCall($hook$function);

echo 
'Ok';


Ardından tarayıcınızda aşağıdaki adresi açın: https://<forumunuz>/hooks.php

Bundan sonra hooks.php kaldırılabilir.

oldu çok teşekkür ederim.

CaptainJack

Quote from: Bugo on February 20, 2024, 10:36:08 AMOkumak istemiyorsanız bunu size nasıl açıklayabilirim? Bunu resimlerde deneyeceğim. Her modun, manuel kurulum prosedürünü görüntüleyen bir ayrıştırma düğmesi vardır.

[nofollow]
[nofollow]

Kanca eklemek için forumun kök dizininde bir dosya oluşturun ve oraya aşağıdaki kodu ekleyin:
hooks.php:

<?php


if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
    require_once(
dirname(__FILE__) . '/SSI.php');

elseif (!
defined('SMF'))
    exit(
'<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');

global 
$context;

$hookCall = !empty($context['uninstalling']) ? 'remove_integration_function' 'add_integration_function';

$hooks = [
    
'integrate_post_quickbuttons' => '$sourcedir/TgWaShare.php|post_quickbuttons',
];

foreach (
$hooks as $hook => $function)
    
$hookCall($hook$function);

echo 
'Ok';


Ardından tarayıcınızda aşağıdaki adresi açın: https://<forumunuz>/hooks.php

Bundan sonra hooks.php kaldırılabilir.

bu kodları diğer modlarda da çalıştırabilir miyiz?

CaptainJack



Bugo

Bazı değişikliklerin zaten hazır bir install.php veya hooks.php dosyası vardır, bunları forumun kök klasörüne taşımanız ve tarayıcınız üzerinden çalıştırmanız yeterlidir. Ancak, değişikliklerinizin neden normal şekilde, Paket Yöneticisi aracılığıyla yüklenmediğini anlamak daha iyidir.

Advertisement: