PDA

Orijinalini görmek için tıklayınız : BEKLİYOR Joomla 1.5 Plugiini Joomla 2.5 e uyarlama



aligultekin34
23-02-2012, 12:48
Slm arkadaşlar. Joomlada easy ping pluginini başlıktanda anlaşılacağı gibi uyarlamak istiyorum nasıl yaparım.
Xml dosyasını düzenlemeyi başardım :)
-php kaldı ?

Easy Ping - Joomla! Extensions Directory



<?php
/**
* @version $Id: easyping.php 10714 2009-11-20 10:10:14Z $
* @package Joomla
* @subpackage Content
* @copyright Copyright (C) 2005 - 2009 Viviendo Linux. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/


// Check to ensure this file is included in Joomla!
defined( '_JEXEC' ) or die( 'Restricted access' );


jimport( 'joomla.plugin.plugin' );
jimport( 'joomla.installer.installer' );


//$mainframe->registerEvent( 'onPrepareContent', 'plgContentEasyPing' );






/**
* Blog Ping Content Plugin
*
* @package Joomla
* @subpackage Content
* @since 2.5
*/
class plgSystemEasyPing extends JPlugin
{


/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @param object $subject The object to observe
* @param object $params The object that holds the plugin parameters
* @since 1.5
*/
function plgContentEasyPing( &$subject, $params )
{
parent::__construct( $subject, $params );
}


/**
*
* Method is called by the view
*
* @param object The article object. Note $article->text is also available
* @param object The article params
* @param int The 'page' number
*/
function onPrepareContent( &$article, &$params, $limitstart )
{
global $mainframe;
}


/**
*
* Method is called by the view and the results are imploded and displayed in a placeholder
*
* @param object The article object. Note $article->text is also available
* @param object The article params
* @param int The 'page' number
* @return string
*/
function onAfterDisplayTitle( &$article, &$params, $limitstart )
{
global $mainframe;


return '';
}


/**
*
* Method is called by the view and the results are imploded and displayed in a placeholder
*
* @param object The article object. Note $article->text is also available
* @param object The article params
* @param int The 'page' number
* @return string
*/
function onBeforeDisplayContent( &$article, &$params, $limitstart )
{
global $mainframe;


return '';
}


/**
*
* Method is called by the view and the results are imploded and displayed in a placeholder
*
* @param object The article object. Note $article->text is also available
* @param object The article params
* @param int The 'page' number
* @return string
*/
function onAfterDisplayContent( &$article, &$params, $limitstart )
{
global $mainframe;


return '';
}


/**
*
* Method is called right before content is saved into the database.
* Article object is passed by reference, so any changes will be saved!
* NOTE: Returning false will abort the save with an error.
* You can set the error by calling $article->setError($message)
*
* @param object A JTableContent object
* @param bool If the content is just about to be created
* @return bool If false, abort the save
*/
function onBeforeContentSave( &$article, $isNew )
{
global $mainframe;


// Check if fetch images is enabled. This is to convert remote (external) images into internal ones automatically to prevent
// broken images and to enable tools that auto-resize and auto-create thumb nails
if($this->params->get('fetchimages')==1) {
if(trim($this->params->get('imagespath'))!="") {
jimport('joomla.filesystem.path');
$safepath=JPATH_SITE.DS.JPath::clean($this->params->get('imagespath'));
jimport('joomla.filesystem.folder');
if(!is_dir($safepath)) {
$result = JFolder::create($safepath, 0777);
}
if(is_dir($safepath)) {
$result = JFolder::create($safepath.DS.$article->id, 0777);
$this->imagedir=JPath::clean($this->params->get('imagespath')).$article->id;
$this->basepath=$safepath.$article->id;
// echo "<xmp>"; print_r($article); echo "</xmp>"; exit;
$article=self::images2local(&$article);
// echo "<xmp>"; print_r($article); echo "</xmp>"; exit;
}
}
}




return true;
}


/**
* Article is passed by reference, but after the save, so no changes will be saved.
* Method is called right after the content is saved
*
*
* @param object A JTableContent object
* @param bool If the content is just about to be created
* @return void
*/
function onAfterContentSave( &$article, $isNew )
{
global $mainframe,$params;
if($this->params->get('enabled')==1) {
self::ping($article);
}
return true;
}






function pingServer($URL, $siteurl, $sitename) {


$parse = parse_url($URL);
if(!isset($parse['host'])) return false;
$host = $parse['host'];
$port = isset($parse['port'])?$parse['port']:80;
$uri = isset($parse['path'])?$parse['path']:'/';


$fp=fsockopen($host,$port,$errno,$errstr);
if(!$fp)
{ return array(-1,"Cannot open connection: $errstr ($errno)<br />\n"); }


$sitetitle = $sitename;
// $siteurl = rtrim($siteurl,"/").'/';


$data = "<?xml version=\"1.0\"?>\r\n".
" <methodCall>\r\n".
" <methodName>weblogUpdates.ping</methodName>\r\n".
" <params>\r\n".
" <param>\r\n".
" <value>$sitetitle</value>\r\n".
" </param>\r\n".
" <param>\r\n".
" <value>$siteurl</value>\r\n".
" </param>\r\n".
" </params>\r\n".
" </methodCall>";


$len = strlen($data);
$out = "POST $uri HTTP/1.0\r\n";
$out .= "User-Agent: Joomla! Ping/1.0\r\n";
$out .= "Host: $host\r\n";
$out .= "Content-Type: text/xml\r\n";
$out .= "Content-length: $len\r\n\r\n";
$out .= $data;


fwrite($fp, $out);
$response = '';
while(!feof($fp)) $response.=fgets($fp, 128);
fclose($fp);


$lines=explode("\r\n",$response);
$firstline=$lines[0];
if(!ereg("HTTP/1.[01] 200 OK",$firstline))
{ return array(-1,$firstline); }


while($lines[0]!='') array_shift($lines);
array_shift($lines);
$lines=strip_tags(implode(' ',$lines));


$n=preg_match(
'|<member>\s*<name>flerror</name>\s*<value>\s*<boolean>([^<]*)</boolean>\s*</value>\s*</member>|i',
$response, $matches);
if(0==$n)
{ return array(-1,$lines); }
$flerror=$matches[1];


$n=preg_match(
'|<member>\s*<name>message</name>\s*<value>\s*<string>([^<]*)</string>\s*</value>\s*</member>|i',
$response, $matches);
if(0==$n)
{ return array(-1,$lines); }
$message=$matches[1];


return array($flerror,$message);
}


function ping($row)
{
global $mosConfig_sitename,$mosConfig_live_site;
if($this->params->get('createsitemap')==1) {
$sitemapcreated=self::createSitemap();
} else $sitemapcreated=false;


if($this->params->get('othersitemap')!="") {
$othersitemap=$this->params->get('othersitemap');
} else $othersitemap=false;


$siteurl=JURI::root();
$config = &JFactory::getConfig();
$sitename=$config->getValue("MetaDesc");
// Obtains the standard services or set the default ones
$servicios=split(" ",$this->params->get('services','http://rpc.pingomatic.com/ http://blogsearch.google.com/ping/RPC2 http://rpc.technorati.com/rpc/ping'));
foreach($servicios as $s) if(trim($s)!="") $urllist[]=array($s,0);


// Check if there is yahoo service enabled and then check if there is a yahoo app id
if($this->params->get('yahoo')==1) {
$urllist[]=array("http://api.my.yahoo.com/rss/ping?u=::URL::",1);
if(trim($this->params->get('yahooappid'))!="") {
$urllist[]=array("http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=".$this->params->get('yahooappid')."&url=::URL::",1);
}
}


// Check if msn is enabled
if($this->params->get('msn')==1) {
$urllist[]=array("http://webmaster.live.com/webmaster/ping.aspx?siteMap=::URL::",1);
$urllist[]=array("http://www.bing.com/webmaster/ping.aspx?siteMap=::URL::",1);
}


// echo "<pre>"; print_r($urllist); die();
foreach ( $urllist as $url )
{
if($url[1]==0) {
if($sitemapcreated)
$response=self::pingServer($url[0],$siteurl."sitemap.xml",$sitename);
if(strlen($othersitemap)>0)
$response=self::pingServer($url[0],$siteurl.$othersitemap,$sitename);
else
$response=self::pingServer($url[0],$siteurl,$sitename);
} else {
if($sitemapcreated)
$newurl=str_replace("::URL::",$siteurl."sitemap.xml",$url[0]);
elseif(strlen($othersitemap)>0)
$newurl=str_replace("::URL::",$siteurl.$othersitemap,$url[0]);
else
$newurl=str_replace("::URL::",$siteurl,$url[0]);
$timeout=3; // 3 seconds of timeout in fopen
$oldtimeout = ini_set('default_socket_timeout', $timeout);
if(($fp=fopen($newurl,"r"))==true) {
ini_set('default_socket_timeout', $oldtimeout);
stream_set_timeout($fp, $timeout);
stream_set_blocking($fp, 0);
$msg=fread($fp,8192);
$response=array("MSG"=>$msg);
fclose($fp);
} else {
ini_set('default_socket_timeout', $oldtimeout);
$response=array("Error"=>"Cannot connect");
}
}
$r=implode("|",$response);
}
return;
}


function createSitemap() {
$registry =& JFactory::getConfig();
$sef = $registry->getValue('config.sef') & $registry->getValue('config.sef_rewrite');




// require_once(JPATH_SITE.DS.'components'.DS.'com_co ntent'.DS.'helpers'.DS.'route.php');
if (!class_exists('JSite')) {
JLoader::import('includes.application',JPATH_SITE) ;
}
if (!class_exists('ContentHelperRoute')) {
JLoader::import('components.com_content.helpers.ro ute',JPATH_SITE);
}




$savepath=substr(getcwd(),0,strrpos(getcwd(),"/"))."/sitemap.xml";
$siteurl=JURI::root();
$config = &JFactory::getConfig();
$sitename=$config->getValue("MetaDesc");
if(($fp=fopen($savepath,"w"))==true) {
// or die("Need write permission on sitemap file $savepath");
$db =& JFactory::getDBO();
$query = 'SELECT
a.id, a.title AS title, a.created AS created, a.metadesc, a.metakey, CONCAT(a.introtext, a.fulltext) AS text,
CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,
CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(":", b.id, b.alias) ELSE b.id END as secslug,
CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as catslug,
a.alias,a.modified,
b.alias AS sectionalias,
c.alias AS categoryalias,
a.sectionid,
a.catid,
a.title,
c.title as cattitle ' .
' FROM #__content a, #__sections b, #__categories c ' .
' WHERE a.sectionid=b.id AND a.catid=c.id '.
' ORDER BY a.created DESC,a.modified DESC LIMIT 1000';

$db->setQuery($query);
// $totalrows = $db->loadResult();
$total=$db->loadObjectList();
// I need to get the list of available languages of the site, to generate a link for each one
$langparams = JComponentHelper::getParams('com_languages');
list($langs,)=split("\-",$langparams->get("site"));
$langs=array("es","en"); //hardcoded es/en languages

//print_r($total);exit;
//http://www.sitemaps.org/protocol.php
// always, hourly, daily, weekly, monthly, yearly, never
$lastmod=date("Y-m-d\TH:i\Z");
$xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".
// "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n".
"<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n".
" <url>\n".
" <loc>$siteurl</loc>\n".
" <lastmod>$lastmod</lastmod>\n".
" <changefreq>daily</changefreq>\n".
" <priority>0.5</priority>\n".
" </url>\n";
foreach($total as $item) {
if(strtotime($item->created)>strtotime($item->modified)) $lastmod=$item->created; else $lastmod=$item->modified;
$lastmod=date("Y-m-d\TH:i\Z",strtotime($lastmod));
/*
Verify sh404sef configuration to know if it is working and if itt includes section, category or both
or check for jom_sef
*
* I just don't know how to get sef URL....
*/
// Add section and category link to sitemap if not added yet
if(!isset($this->sections[$item->sectionid])) {
foreach($langs as $lang) {
$loc=ContentHelperRoute::getSectionRoute( $item->secslug );
$loc.="&amp;lang=$lang";
$loc=$siteurl.JRoute::_($loc);
$loc = JURI::root().JRoute::_(ContentHelperRoute::getSect ionRoute($item->sectionid))."&amp;lang=$lang";
$loc=ereg_replace("&amp;Itemid=[0-9]+","",$loc);
// echo $loc;
$xml.=" <url>\n".
" <loc>$loc</loc>\n".
" <lastmod>$lastmod</lastmod>\n".
" <changefreq>daily</changefreq>\n".
" <priority>0.6</priority>\n".
" </url>\n";
$this->sections[$item->sectionid]=1;
}
}
if(!isset($this->categories[$item->catid])) {
foreach($langs as $lang) {
$loc=ContentHelperRoute::getCategoryRoute( $item->catslug, $item->secslug );
$loc.="&amp;lang=$lang";
$loc=$siteurl.JRoute::_($loc);
$loc = JURI::root().JRoute::_(ContentHelperRoute::getCate goryRoute($item->catid, $item->secctionid))."&amp;lang=$lang";
// echo($loc);
$xml.=" <url>\n".
" <loc>$loc</loc>\n".
" <lastmod>$lastmod</lastmod>\n".
" <changefreq>daily</changefreq>\n".
" <priority>0.6</priority>\n".
" </url>\n";
$this->categories[$item->catid]=1;
}
}
foreach($langs as $lang) {
$loc=ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->secslug );
// $loc=self::getSiteRoute($loc);
$loc.="&amp;lang=$lang";
$loc=$siteurl.JRoute::_($loc);
$loc = JURI::root().JRoute::_(ContentHelperRoute::getArti cleRoute($item->id))."&amp;lang=$lang";
// die($loc);
$xml.=" <url>\n".
" <loc>$loc</loc>\n".
" <lastmod>$lastmod</lastmod>\n".
" <changefreq>weekly</changefreq>\n".
" <priority>0.65</priority>\n".
" </url>\n";
}
}
$xml.="</urlset>";
fwrite($fp,$xml);
fclose($fp);
return true;
}
return false;
}




/**
* Function to get the SEF route
*
* @param string $url The non-SEF route
* @return string The SEF route
*/
function getSiteRoute($url)
{
static $router;


jimport('joomla.application.router');
require_once(JPATH_SITE.DS.'includes'.DS.'applicat ion.php');


// Only get the router once.
if (!is_object($router))
{
// Get and configure the site router.
$config = &JFactory::getConfig();
$router = &JRouter::getInstance('site');
$router->setMode($config->getValue('sef', 1));
}


// Build the route.
$uri = &$router->build($url);
$route = $uri->toString(array('path', 'query', 'fragment'));


// Strip out the base portion of the route.
$route = str_replace(JURI::base(true).'/', '', $route);


return $route;
}

function images2local(&$item) {
$campos=array("introtext","fulltext");
unset($metakey);
foreach($campos as $campo) {
$sSQL="";
$regex="/<img[^>]+>/i";
$newtxt=$item->$campo;
if(trim($newtxt)!="") {
$newtxt = preg_replace_callback($regex,(array($this,'reempla za')),$newtxt,-1,$cuantas);
$item->$campo=$newtxt;
}
}
return $item;
}


function reemplaza($txt) {
if(strstr("http",$txt[0])==false) {
$src=$txt[0];
$url=eregi_replace('<img.*src[^=]*=[^"]*"([^"]+)"[^>]*>',"\\1",$src);
$dirname=dirname(eregi_replace("^(http[s]{0,1}://)([^/]+)(.*)$","\\3",$url));
$basename=JPath::clean(basename($url));
$basenameext=strrchr($basename,"."); // Gets the extension
$basename=md5($basename).$basenameext; // Generates a new filename, with md5 hash, to avoid invalid filenames
$uri=eregi_replace("^(http[s]{0,1}://)([^/]+)(.*)$","$this->imagedir/$this->basename",$url);
if($url!=$uri) {
$newfname=$uri.urlencode($basename);
$newtag=eregi_replace('(<img.*src[^=]*=[^"]*")([^"]+)("[^>]*>)',"\\1$newfname\\3",$src);
$cp=@copy($url,"$this->basepath/$basename");
if($cp)
return $newtag;
else
return $url;
} else
return $txt[0];
}
}
}



(http://extensions.joomla.org/extensions/site-management/seo-a-metadata/8488)

gokhan
23-02-2012, 18:45
belki bu konuya bakmışsındır ama genede yazim dedim :)

http://forum.joomla.gen.tr/digerleri/836-modul-uyarlama.html#post6059

aligultekin34
23-02-2012, 19:37
He o konuyu biliyorumda bu sistem plugini olduğu için bunda öyle pek bakıpta göremiyoruz. Bu eklentinin ben sadecene ayar dosyasını hallettim. Plugin yöneticisinden ayarlarını kayıt edebiliyoruz. Ama işte bu Php kısmında ufak bir değişiklik varsa çalışmayabiliyor.

aligultekin34
25-02-2012, 15:06
Arkadaşlar biraz düzenledim ama php kısmına bi bakabilecekmisiniz ?

467

gokhan
25-02-2012, 20:57
sitenin resmi sayfasında destek bölümü var. bende gittim konu açtım :D

Easy Ping - Viviendo Linux .:: .:: Viviendo Linux Magazine - Mexico ::. (http://www.viviendolinux.com/en/foro/nuestras-contribuciones/easy-ping-dp1.html#axzz1nPJpwmvP)

gokhan
28-02-2012, 21:48
işini görürmü bilmem ama aynı işlevi görüyor sanırım :)

BlogPing - Joomla! Extensions Directory (http://extensions.joomla.org/extensions/authoring-a-content/blog/7702?qh=YTozOntpOjA7czo0OiJwaW5nIjtpOjE7czo1OiJwaW 5ncyI7aToyO3M6NzoicGluZ2luZyI7fQ%3D%3D+)

aligultekin34
01-03-2012, 23:53
Teşekkürler.Ben bunu düzenledim ufaktanda olsa ama kod parçacıklarında sorun varmıdır orasını bilemiyorum o yüzden. Bilen biri varsa php kısmında 1.5 tan sonra ne diğişimiştir onlar daha iyi bilir. Ben diğer kısmı düzenledim. Kurulumda sorunsuz kuruluyor ve aktif oluyor :)

mousazadeh.m
25-03-2013, 13:11
Hi everybody,
I have installed easy pluging 2.5 released on this topic in my joomla 2.5 successfully. but it doesn't work. would you please help me?
i'm not good in turkish language.

Ümit
25-03-2013, 22:00
Hi everybody,
I have installed easy pluging 2.5 released on this topic in my joomla 2.5 successfully. but it doesn't work. would you please help me?
i'm not good in turkish language.

Google search...

Migrating from Joomla 1.5 plugin (module,component) to Joomla 2.5 plugin

and

Joomla! &bull; View forum - Joomla! 2.5 - Ask Support Questions Here (http://forum.joomla.org/viewforum.php?f=614&sid=5ec0a2dad0a0f267befa9e8db6061541)