Jump to content
Дизайн и модификация IPS Community IPBSkinsBETA
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Qartvela™

Добавить условие в: (TNG34) Quoted Images as Links

Recommended Posts

Здравствуйте

 

Нужно исключить темы из этого мода, по "ID" идентификатору темы:

 

<if test="$topic['tid'] != X">
//Some data
</if>

 

 

<?xml version="1.0" encoding="utf-8"?>
<hookexport>
 <hookdata>
   <config>
     <hook_name>(tng34) Цитата изображений ссылкой</hook_name>
     <hook_desc>Отображение цитируемых изображений в лайтбокс ссылки на исходное изображение</hook_desc>
     <hook_author>techngaming.com</hook_author>
     <hook_email>admin@techngaming.com</hook_email>
     <hook_website>http://www.techngaming.com/</hook_website>
     <hook_update_check/>
     <hook_requirements><![CDATA[a:4:{s:20:"hook_ipb_version_min";i:0;s:20:"hook_ipb_version_max";i:0;s:20:"hook_php_version_min";s:1:"0";s:20:"hook_php_version_max";s:1:"0";}]]></hook_requirements>
     <hook_version_human>1.3.0</hook_version_human>
     <hook_version_long>1300</hook_version_long>
     <hook_extra_data/>
     <hook_key>tng33_QuotedImages</hook_key>
   </config>
 </hookdata>
 <hookfiles>
   <file>
     <hook_file_real>tng33_QuotedImages.php</hook_file_real>
     <hook_type>libraryHooks</hook_type>
     <hook_classname>tng33_QuotedImages</hook_classname>
     <hook_data><![CDATA[a:8:{s:12:"dataLocation";s:0:"";s:14:"libApplication";s:4:"core";s:15:"classToOverload";s:18:"class_localization";s:9:"skinGroup";N;s:12:"skinFunction";N;s:4:"type";N;s:2:"id";N;s:8:"position";N;}]]></hook_data>
     <hooks_source><![CDATA[<?php
	class tng33_QuotedImages extends class_localization
	{
		function tng_QuotedImages($data='')
		{
			// Check we have stuff to work on
			if((strpos($data, 'blockquote')==false) || (strpos($data, 'bbc_img')==false)) {
				return $data;
			}

			// Define IPS Tags
			$ipstags = array("<#IMG_DIR#>","<#EMO_DIR#>","<% CHARSET %>","http://ipbskins.ru/forum/public/style_images/ipbskins","{style_images_url}");
			$safetags = array("#tng##IMG_DIR##tng#","#tng##EMO_DIR##tng#","#tng#% CHARSET %#tng#","#tng#style_image_url#tng#","#tng#style_images_url#tng#");

			// Make IPS Tags safe
			$data = str_replace($ipstags, $safetags, $data);

			// Keep HTML Parser happy
			$html = array('<!DOCTYPE html>'."\n".'<html><head><meta http-equiv="Content-Type" content="text/html; charset='.IPS_DOC_CHAR_SET.'"></head><body>','</body></html>');

			// Setup the DOM (Suppress errors with @)
			$dom = new DOMdocument();
			@$dom->loadHTML($html[0].$data.$html[1]);
			$xpath = new DOMXpath($dom);

			// This is where the magic happens
			foreach ($xpath->query('//blockquote//img[@class="bbc_img"]') as $entry) {
				$href = $entry->getAttribute('src');
				$title = $entry->getAttribute('alt');
				$replace = $dom->createElement('a', substr($href,0,40).'...');
				$entry->parentNode->replaceChild($replace, $entry);
				$replace->setAttribute('href', $href);
				$replace->setAttribute('title', $title);
				$replace->setAttribute('rel', 'lightbox');
				$replace->setAttribute('class', 'bbc_url');
				$replace->parentNode->removeAttribute('rel');
			}

			// Grab the post back and remove the HTML tags
			$data = str_replace($html, '', $dom->saveHTML());

			// Restore IPS Tags and return the content
			return str_replace($safetags, $ipstags, $data);
		}
	} ]]></hooks_source>
   </file>
   <file>
     <hook_file_real>tng33_QuotedImages1.php</hook_file_real>
     <hook_type>skinHooks</hook_type>
     <hook_classname>tng33_QuotedImages1</hook_classname>
     <hook_data><![CDATA[a:8:{s:12:"dataLocation";s:0:"";s:14:"libApplication";s:0:"";s:15:"classToOverload";s:10:"skin_topic";s:9:"skinGroup";N;s:12:"skinFunction";N;s:4:"type";N;s:2:"id";N;s:8:"position";N;}]]></hook_data>
     <hooks_source><![CDATA[
	class tng33_QuotedImages1 extends skin_topic(~id~)
	{
		function post($post, $displayData, $topic, $forum=array())
		{
			$post['post']['post'] = $this->registry->class_localization->tng_QuotedImages($post['post']['post']);
			return parent::post($post, $displayData, $topic, $forum=array());
		}

		function quickEditPost($post)
		{
			$post['post'] = $this->registry->class_localization->tng_QuotedImages($post['post']);
			return parent::quickEditPost($post);
		}
	} ]]></hooks_source>
   </file>
   <file>
     <hook_file_real>tng33_QuotedImages2.php</hook_file_real>
     <hook_type>skinHooks</hook_type>
     <hook_classname>tng33_QuotedImages2</hook_classname>
     <hook_data><![CDATA[a:8:{s:12:"dataLocation";s:0:"";s:14:"libApplication";s:0:"";s:15:"classToOverload";s:9:"skin_post";s:9:"skinGroup";N;s:12:"skinFunction";N;s:4:"type";N;s:2:"id";N;s:8:"position";N;}]]></hook_data>
     <hooks_source><![CDATA[
	class tng33_QuotedImages2 extends skin_post(~id~)
	{
		function topicSummary($posts=array())
		{
			foreach($posts as $p => $post)
			{
				$posts[$p]['post'] = $this->registry->class_localization->tng_QuotedImages($posts[$p]['post']);
			}	
			return parent::topicSummary($posts);
		}

		function preview($data="")
		{
			$data = $this->registry->class_localization->tng_QuotedImages($data);
			return parent::preview($data);
		}
	} ]]></hooks_source>
   </file>
   <file>
     <hook_file_real>tng33_quoteimages3.php</hook_file_real>
     <hook_type>skinHooks</hook_type>
     <hook_classname>tng33_QuotedImages3</hook_classname>
     <hook_data><![CDATA[a:8:{s:12:"dataLocation";s:0:"";s:14:"libApplication";s:0:"";s:15:"classToOverload";s:20:"skin_global_comments";s:9:"skinGroup";N;s:12:"skinFunction";N;s:4:"type";N;s:2:"id";N;s:8:"position";N;}]]></hook_data>
     <hooks_source><![CDATA[
	class tng33_QuotedImages3 extends skin_global_comments(~id~)
	{
		function comment($r, $parent, $settings)
		{
			$r['comment']['comment_text'] = $this->registry->class_localization->tng_QuotedImages($r['comment']['comment_text']);
			return parent::comment($r, $parent, $settings);
		}

		function commentHidden($r, $parent, $settings)
		{
			$r['comment']['comment_text'] = $this->registry->class_localization->tng_QuotedImages($r['comment']['comment_text']);
			return parent::commentHidden($r, $parent, $settings);
		}
	} ]]></hooks_source>
   </file>
 </hookfiles>
 <hookextras_settings/>
 <hookextras_language/>
 <hookextras_modules/>
 <hookextras_help/>
 <hookextras_templates/>
 <hookextras_css/>
 <hookextras_tasks/>
 <hookextras_database_create/>
 <hookextras_database_alter/>
 <hookextras_database_update/>
 <hookextras_database_insert/>
</hookexport>

 

 

Как реализовать?

 

Спасибо за ранее

 

(TNG34)QuotedImagesasLinks.zip

Share this post


Link to post
Share on other sites

Можно попробовать

$this->request['t']

Будет работать при просмотре темы

 

Выше

// Check we have stuff to work on

добавить

if (in_array($this->request['t'], array(1,2,3,4,5)))
{
   return $data;
}

  • Upvote 1

Share this post


Link to post
Share on other sites

Можно попробовать

Работает! Большое вам спасибо!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...