> ------------------------------------------------------------------------------ See main.inc.php for release information LMT_root : common classe for admin and public classes --------------------------------------------------------------------------- */ include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'); include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php'); include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php'); class LMT_root extends CommonPlugin { protected $css; //the css object protected $css_icn; //the css object static public $licences=array('BY', 'BY-ND', 'BY-NC', 'BY-NC-ND', 'BY-NC-SA', 'BY-SA', 'CRIGHT', 'CLEFT', 'DEFAULT'); /** * constructor */ public function __construct($prefixeTable, $filelocation) { $this->setPluginName('LMT'); $this->setPluginNameFiles("lmt"); parent::__construct($prefixeTable, $filelocation); $this->section_name=$this->getPluginNameFiles(); $this->setTablesList(array('images', 'licence_author')); $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css"); $this->css_icn = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles()."_icn.css"); } /** * destructor */ public function __destruct() { unset($this->css); unset($this->css_icn); parent::__destruct(); } public function initEvents() { add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') ); } /** * menu block management */ public function register_blocks() { } /** * initialize default values for config var */ public function initConfig() { //global $user; $this->config=array( 'lmt_list_maxheight' => '650', 'lmt_list_maxitems' => '0', /* limit number of item displayed ; 0 : no limit */ 'lmt_licence_default' => 'BY', 'lmt_licence_default_author' => 0, 'lmt_licence_activated' => 'n', 'lmt_licence_visible' => 'n', /* y:always visible, n:only if needed */ 'lmt_licence_logo' => '80x15', /* 80x15, 88x31, text */ 'lmt_warning_visible' => 'y', /* y: display a text at the bottom of each page */ 'lmt_warning_texts' => array(), /* text displayed - multi lang */ 'lmt_redirect_activated' => 'y', /* y: the text is an url to a warning page */ 'lmt_redirect_open_target' => 'n', /* y: url are openned in a new page/tab */ 'lmt_redirect_url-by' => array(), 'lmt_redirect_url-by-nd' => array(), 'lmt_redirect_url-by-nc' => array(), 'lmt_redirect_url-by-nc-nd' => array(), 'lmt_redirect_url-by-nc-sa' => array(), 'lmt_redirect_url-by-sa' => array(), 'lmt_redirect_url-cright' => array(), 'lmt_redirect_url-cleft' => array(), ); $languages=get_languages(); foreach($languages as $key => $val) { $lang=substr($key,0,2)."/"; if($lang=="en/") { $lang=""; } $this->config['lmt_warning_texts'][$key]=''; $this->config['lmt_redirect_url-by'][$key]='http://creativecommons.org/licenses/by/2.0/'.$lang; $this->config['lmt_redirect_url-by-nd'][$key]='http://creativecommons.org/licenses/by-nd/2.0/'.$lang; $this->config['lmt_redirect_url-by-nc'][$key]='http://creativecommons.org/licenses/by-nc/2.0/'.$lang; $this->config['lmt_redirect_url-by-nc-nd'][$key]='http://creativecommons.org/licenses/by-nc-nd/2.0/'.$lang; $this->config['lmt_redirect_url-by-nc-sa'][$key]='http://creativecommons.org/licenses/by-nc-sa/2.0/'.$lang; $this->config['lmt_redirect_url-by-sa'][$key]='http://creativecommons.org/licenses/by-sa/2.0/'.$lang; $this->config['lmt_redirect_url-cright'][$key]=''; $this->config['lmt_redirect_url-cleft'][$key]=''; } } /** * returns the admin page link */ public function getAdminLink($mode='') { if($mode=='ajax') { return('plugins/'.basename(dirname($this->getFileLocation())).'/lmt_ajax.php'); } else { return(parent::getAdminLink()); } } /** * return the licence type for an image * * returned array * 'default' => 'y' => if no licence for the picture, return de default * licence * 'n' => if no licence for the picture, return empty values * 'licence' => the licence type * 'aut_text1' => author, text 1 * 'aut_text2' => author, text 2 * * @param Integer $image_id : the image id * @return Array */ public function getImageLicence($image_id) { $return=array( "default" => "", "licence" => "", "aut_text1" => "", "aut_text2" => "" ); $sql="SELECT lmti.licence_type, lmta.text1, lmta.text2 FROM ".$this->tables['images']." lmti LEFT OUTER JOIN ".$this->tables['licence_author']." lmta ON lmti.author_id = lmta.id WHERE lmti.image_id = '".$image_id."'"; $result=pwg_query($sql); if($result) { while($row=pwg_db_fetch_assoc($result)) { $return=array( "defaut" => "n", "licence" => $row['licence_type'], "aut_text1" => $row['text1'], "aut_text2" => $row['text2'] ); } } if(($return["licence"]=="")&&($this->config["lmt_licence_visible"]=="y")) { $return=array( "defaut" => "y", "licence" => $this->config["lmt_licence_default"], "aut_text1" => "", "aut_text2" => "" ); $sql="SELECT * FROM ".$this->tables['licence_author']." WHERE id = '".$this->config["lmt_licence_default_author"]."'"; $result=pwg_query($sql); if($result) { while($row=pwg_db_fetch_assoc($result)) { $return["aut_text1"]=$row['text1']; $return["aut_text2"]=$row['text2']; } } } return($return); } /** * returns an array of image id with the asked licence type * if $licence = "" => return all picture with a specific licences * * @param String $licence : licence to be filtered * @return Array */ public function getImagesLicences($licence) { $sql="".$this->tables['lmt']; $result=pwg_query($sql.$sql_where.$sql_order); if($result) { $returned=array(); while($row=pwg_db_fetch_assoc($result)) { array_push($returned, $row); } return($returned); } return(false); } protected function displayResult($action_msg, $result) { global $page; if($result) { array_push($page['infos'], $action_msg); } else { array_push($page['errors'], $action_msg); } } /** * build image url (for a given category) * * */ protected function makeImageDatas($tmp, $imageId) { $tmp2=array(); foreach($tmp['id'] as $key=>$val) { $tmp2[]=array( 'id' => $tmp['id'][$key], 'name' => $tmp['name'][$key], 'type' => $tmp['type'][$key], 'plinks' => $tmp['plinks'][$key], 'link'=> make_picture_url( array( 'image_id' => $imageId, 'category' => array ( 'id' => $tmp['id'][$key], 'name' => $tmp['name'][$key], 'permalink' => $tmp['plinks'][$key] ) ) ) ); } return($tmp2); } } //class class LMT_functions { static private $tables = Array(); static private $config = Array(); /** * initialise the class * * @param String $prefixeTable : the piwigo prefixe used on tables name * @param String $pluginNameFile : the plugin name used for tables name */ static public function init($prefixeTable) { GPCCore::loadConfig(LMT_root::$pluginNameFile, self::$config); $list=LMT_root::$pluginTables; for($i=0;$iset_filename('lmt_choose', dirname(__FILE__).'/templates/lmt_dialog_licence_choose.tpl'); $datas=Array( 'licencesList' => array() ); foreach(LMT_root::$licences as $licence) { if($licence!='DEFAULT') { $datas['licencesList'][]=array( 'value' => $licence, 'name' => l10n('lmt_lbl_cc_s-'.strtolower($licence)) ); } } $template->assign('datas', $datas); return($template->parse('lmt_choose', true)); } } //GMaps_functions ?>