Piero V.

Flatpress: Next/Prev Page link and PrettyURLs

Italiano

(See below for English)

Come ho già detto in qualche post fa, sto facendo un plugin per implementare i tag su flatpress.

Dopo alcuni giorni di lavoro, pensando di averlo finito, mi accorgo di un bug: dalla seconda pagina non funziona più il filtro dei tag (e me ne sono accorto per puro caso!!)

La colpa è di Pretty URLs, che gestisce gli url delle pagine ricreandoli dall’inizio.

Le soluzioni sono quattro:

  1. Fare un plugin che non supporta PrettyURLs
  2. Fare un plugin che usi delle estensioni PECL
  3. Fare un plugin solo per PHP 4 (e io uso PHP5 😊 )
  4. Fare una classe sostitutiva a pretty urls

L’unica che mi pare accettabile è la quarta, ed ecco il codice (testato, sembra funzionare):

## Replacement Class for PrettyURLs Plugin
if(class_exists('Plugin_PrettyURLs')) {
	class class_name {
		function class_name(&$original) { # Constructor
			$this->original=&$original;
			$this->baseurl=&$original->baseurl;
		}
		function permalink($str, $id) {
			return $this->original->permalink($str, $id);
		}
		function commentlink($str, $id) {
			return $this->original->commentlink($str, $id);
		}
		function feedlink($str, $type) {
			return $this->original->feedlink($str, $type);
		}
		function commentsfeedlink($str, $type, $id) {
			return $this->original->commentsfeedlink($str, $type, $id);
		}
		function staticlink($str, $id) {
			return $this->original->staticlink($str, $id);
		}
		function categorylink($str, $catid) {
			return $this->original->categorylink($str, $catid);
		}
		function yearlink($str, $y) {
			return $this->original->yearlink($str, $y);
		}
		function monthlink($str, $y, $m) {
			return $this->original->monthlink($str, $y, $m);
		}
		function daylink($str, $y, $m, $d) {
			return $this->original->daylink($str, $y, $m, $d);
		}
		function nextprevlink($nextprev, $v) {
			if(!empty($fp_params['myparam'])) {
				## My code here
			} else
				return $this->original->nextprevlink($nextprev, $v);
		}
	}
}

Si fa il backup di $plugin_prettyurls, quindi si dà a $plugin_prettyurls questa classe: … [Leggi il resto]

Plugin Autoreadmore (v1.5) [Flatpress]

Italiano

Questo è un plugin per flatpress che serve per fare in modo che automaticamente, quando un testo è lungo, venga tagliato e aggiunto un Leggi il resto nell’anteprima.

È una modifica del plugin readmore originale di flatpress di NoWhereMan fatta da me per l’integrazione con flatpress usando la funzione cutHtmlText di Abidibo.

L’unica modifica dalla [iurl:post:entry100619-133625 title=”Autoreadmore v1.1”]versione 1.1 è che il testo viene tagliato dopo, così non taglia es BBCode.

Lingue: en-us, it-it.

Licenza: GNU GPL v2.

Download: [iurl:relative:fp-content/attachs/autoreadmore_v1.5.tar.gz title=”Tarball della versione 1.5”]Autoreadmore V1.5.

English

This flatpress plugin automatically chop a long entry and adds “Readmore” to the preview.

It’s a modification of the original Read More plugin by NoWhereMan using cutHtmlText by Abidibo.

The only change from [iurl:post:entry100619-133625 title=”Autoreadmore v1.1 (IT only)”]version 1.1 is that entry is cut after other plugins (such as BBCode).

Languages: en-us, it-it.

License: GNU GPL v2.

Download: [iurl:relative:fp-content/attachs/autoreadmore_v1.5.tar.gz title=”Tarball of version 1.5”]Autoreadmore V1.5.

Flatpress: far vedere post non (apparentemente) collegati

Italiano

Scrivendo un plugin per i tag mi sono chiesto: “Come si potrebbe far vedere tutti i post con uno stesso tag?”

Andando avanti a pensare mi sono detto: “una specie di categoria”: ed ecco qui la risposta: quando ce n’è il bisogno, si fa creare una falsa categoria durante il filtro init.

Le categorie sono gestite dalla classe FPDB che le carica solo una volta e flatpress ne crea solo un’istanza.

Ecco il codice di base:

class plugin_tag_walker {
	var $valid=true;
	function current_key() {
		return current($this->array);
	}
	function next() {
		$n=next($this->array);
		if($n==false)
			$this->valid=false;
		return $n;
	}
}

class plugin_tag_fpdb {
	function length() {
		return $this->len;
	}
	function walker($p1=null) {
		$a=new plugin_tag_walker();
		$a->array=$this->array;
		return $a;
	}
}

function prova_cat() {
	global $fpdb, $fp_params;
	if(isset($_GET['tag'])) {       ### Solo se c'è il parametro GET tag
		$fp_params['cat']=-50;  ### L'id della categoria
		$p=new plugin_tag_fpdb();
		$p->array=array(
			'100715151839', ### Quali sono i post
			'100715163207',
			'100808220001'
		);
		$p->len=count($p->array);
		if($fp_params['count']>$p->len)
			$fp_params['count']=$p->len;
		$fpdb->_indexer[$fp_params['cat']]=&$p;
	}
	return true;
}

add_filter('init', 'prova_cat');

Praticamente la funzione prova_cat assegna alla categoria -50 un oggetto che ne restituisce un altro che una volta chiamato dal codice di flatpress restituisce i post. … [Leggi il resto]

Bi-lingual articles for FlatPress in this blog

Available languages Italian and English.

Italiano

Lavorando per i plugin di flatpress si può vedere quanto esso sia scritto bene.

Ma non intendo codice leggibile che apri il file e ti è subito chiaro come funziona, ma intendo proprio che il funzionamento è ben concepibito.

Io lo uso per il mio blog e così voglio poter “restituire” qualcosa cercando di proporre idee, scrivere plugin etc.

Ho deciso così che quando scriverò qualcosa su flatpress (per il quale alla prima occasione creerò una nuova categoria apposita), cercherò di farlo sia in italiano che in inglese (seppure il secondo magari qualche dettaglio non riuscirò a metterlo).

Questa è la mia decisione perché la documentazione è importante, e di solito la traduzione delle documentazioni in italiano è poca, e in inglese è internazionale e averne tanta non fa mai male.

English

Working for flatpress plugins, you can see that it’s well coded.

The reason it’s not that opening a file you understand how it works, I mean that it’s well conceived by the logical functioning.

I use it for my blog so I want to contribute trying to propose ideas or to write plugin etc.

So I have decided that when I write about flatpress, I’ll do it both in Italian and English, or I’ll try because documentation is importand and usually there isn’t so much italian documentation, instead English is an international language and having a lot of documentation is not bad.

Plugin Favicon (v2.0) [Flatpress]

Available languages: Italian (on top), English (see under Italian section)

Italiano

Ho abbondantemente modificato il plugin Favicon di flatpress mettendogli anche codice del plugin BBCode per fare in modo che l’utente può scegliere la favicon direttamente dal pannello di amministrazione (Plugins -> Favicon).

In più aggiunge anche l’icona per iPhone e iPod Touch, anche quella selezionabile dallo stesso pannello.

Basta scaricare il tarball che metto sotto e decomprimelo in fp-plugins.

Lingue: en-us, it-it

Licenza: GNU GPL v2

Download: favicon_v2.0.tar.gz

English

I’ve modified flatpress Favicon plugin (copying code from BBCode plugin too 😊 ) to add the possibility of selecting favicon from the admin panel (Plugins -> Favicon).

It also adds an icon for iPod Touch/iPhone selectable from the same page.

You just have to download the tarball and decompress in fp-plugins directory.

Languages: en-us, it-it

License: GNU GPL v2

Download: favicon_v2.0.tar.gz