/*
Plugin Name: WP Calameo
Description: Embed Calameo publications & miniCalameo inside a post
Version: 1.1.0
Author: Calameo
*/
/* Copyright 2009 Calameo (email : contact@calameo.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
function calameo_parse( $content )
{
// Parse for full Calaméo viewers
$content = preg_replace_callback("/\[calameo ([^]]*)\]/i", "calameo_render", $content);
return $content;
}
function calameo_render( $tags )
{
// Parsing attributes
if ( !preg_match_all('/([^= ]+)=([\S]*)/i', $tags[1], $matches) ) return '';
$attributes = array();
$count = count($matches[1]);
for ( $i = 0 ; $i < $count ; $i++ )
{
$attributes[$matches[1][$i]] = $matches[2][$i];
}
// Get code from URL
if ( !empty($attributes['url']) )
{
if ( preg_match('~calameo\.com/(read|books)/([0-9a-z]+)~i', $attributes['url'], $regs) )
{
$attributes['code'] = $regs[2];
}
}
// Checking attributes
if ( empty($attributes['code']) ) return '';
if ( empty($attributes['mode']) ) $attributes['mode'] = 'book';
if ( empty($attributes['page']) ) $attributes['page'] = 1;
if ( empty($attributes['wmode']) ) $attributes['wmode'] = '';
if ( empty($attributes['title']) ) $attributes['title'] = 'View this publication on Calaméo';
// Language
$language = preg_match('/$([a-z]+)/i', get_bloginfo('language'));
$languages = array(
'en'=>'en',
'fr'=>'fr',
'es'=>'es',
'de'=>'de',
'it'=>'it',
'pt'=>'pt',
'ru'=>'ru',
'ja'=>'jp',
'zh'=>'cn',
'kr'=>'kr'
);
if ( empty($attributes['lang']) )
{
$attributes['lang'] = ( !empty($language) && !empty($languages[$language]) ) ? $languages[$language] : 'en';
}
// Prepare viewer and link URLs
$book_url = 'http://calameo.com/books/' . $attributes['code'] . ( !empty($attributes['authid']) ? '?authid=' . $attributes['authid'] : '' );
$home_url = 'http://calameo.com';
$publish_url = 'http://calameo.com/upload';
$browse_url = 'http://calameo.com/browse/weekly/?o=7&w=DESC';
// Preparing Flashvars
$flashvars = 'bkcode=' . $attributes['code'];
$flashvars .= '&langid=' . $attributes['lang'];
$flashvars .= '&page=' . $attributes['page'];
switch ( $attributes['mode'] )
{
case 'mini':
if ( empty($attributes['width']) )$attributes['width'] = '240';
if ( empty($attributes['height']) ) $attributes['height'] = '150';
if ( empty($attributes['clickto']) ) $attributes['clickto'] = 'public';
if ( empty($attributes['clicktarget']) ) $attributes['clicktarget'] = '_self';
if ( empty($attributes['clicktourl']) ) $attributes['clicktourl'] = '';
if ( empty($attributes['autoflip']) ) $attributes['autoflip'] = '0';
if ( empty($attributes['showarrows']) ) $attributes['showarrows'] = '1';
$viewer_url = 'http://v.calameo.com/2.0/cmini.swf';
$flashvars .= '&clickTo=' . urlencode($attributes['clickto']);
$flashvars .= '&clickTarget=' . urlencode($attributes['clicktarget']);
$flashvars .= '&clickToUrl=' . urlencode($attributes['clicktourl']);
$flashvars .= '&autoFlip=' . max(0, intval($attributes['autoflip']));
$flashvars .= '&showArrows=' . ( !empty($attributes['showarrows']) ? '1' : '0' );
$flashvars .= '&mode=embed';
break;
case 'book':
default:
if ( empty($attributes['width']) )$attributes['width'] = '';
if ( empty($attributes['height']) ) $attributes['height'] = '400';
if ( !empty($attributes['view']) ) $flashvars .= '&viewModeAtStart=' . $attributes['view'];
if ( !empty($attributes['authid']) ) $flashvars .= '&authid=' . $attributes['authid'];
$viewer_url = 'http://v.calameo.com/2.0/cviewer.swf';
break;
}
// Sizes and units
$attributes['widthUnit'] = ( strpos($attributes['width'], '%') ) ? '' : 'px';
$attributes['heightUnit'] = ( strpos($attributes['height'], '%') ) ? '' : 'px';
// Generate HTML embed code
$html = '
';
if ( empty($attributes['hidelinks']) ) $html .= '
Immissione in ruolo da procedura concorsuale STEM A041, le nomine in ruoloavranno decorrenza giuridica ed economica 01.09.2022. AVVISO DI CONVOCAZIONE ...
Su Albo on line pubblicati gli elenchi degli alunni ammessi ai percorsi formativi nell'ambito del progetto 10.1.1A-FSEPON-SI-2021-92 AZIONE 10.1.1A “Insieme si ...