> ------------------------------------------------------------------------------ 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 protected $licences=array('BY', 'BY-ND', 'BY-NC', 'BY-NC-ND', 'BY-NC-SA', 'BY-SA', 'CRIGHT', 'CLEFT', 'DEFAULT'); 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"); } public function __destruct() { unset($this->css); unset($this->css_icn); unset($this->licences); parent::__destruct(); } public function initEvents() { add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') ); } /* menu block management */ public function register_blocks() { } /* surchage of CommonPlugin->saveConfig function */ public function saveConfig() { if(parent::saveConfig()) { $this->css->makeCSS($this->generate_CSS()); $this->css_icn->makeCSS($this->generate_CSS2()); return(true); } return(false); } /* surchage of CommonPlugin->saveConfig function */ public function loadConfig() { parent::loadConfig(); if(!$this->css->fileExists()) { $this->css->makeCSS($this->generate_CSS()); } if(!$this->css_icn->fileExists()) { $this->css_icn->makeCSS($this->generate_CSS2()); } } /* intialize default values */ public function initConfig() { //global $user; $this->config=array( 'lmt_mouseovercolor' => '303030', /**/ '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]=''; } } /* generate the css code */ protected function generate_CSS() { $text = " .TableRow:hover { background-color:#".$this->config['lmt_mouseovercolor']."; } .formtable { text-align:justify; display:block; margin-top:0px; margin-bottom:0px; width:100%; } .formtable tr { vertical-align:top; } .littlefont { font-size:90%; } table.littlefont th { text-align:center; padding:3px;padding-left:9px;padding-right:9px; } table.littlefont td { text-align:left; padding:0px;padding-left:3px;padding-right:3px; } .lmt_page { text-align:justify; margin:8px; } .lmt { text-align:justify; } #list { width:100%; overflow-y:scroll; min-height:250px; max-height:650px; } #ullist li { width:300px; display:block; float:left; text-align:left; } #ullist label { float:left; } #ullist li table { margin:0px; text-align:left; width:300px; font-size:80%; } #ullist li tr { vertical-align:top; } .content ul.thumbnails span.extendwrap1 { margin:0px; cursor:pointer; } .is_on, .is_off { z-index:20; width:12px; height:12px; display:block; cursor:pointer; } .is_on { background:url(./img/cb_on.png); } .is_off { background:url(./img/cb_off.png); } .icnhelp { weight:bold; text-decoration:none; cursor:help; } .hinthlp { position:absolute; max-width:400px; border:1px solid #000000; background:#ffffa0; color:#000000; top:0px; left:-450px; padding:2px; text-align:justify; } "; return($text); } /* generate the css code */ protected function generate_CSS2() { $text = " .logo80x15 { position:relative; top:4px; margin-right:4px; border:0px none; } .logo88x31 { position:relative; margin-right:4px; border:0px none; } #theImage img.logo80x15, #theImage img.logo88x31 { border:0px none; padding:0px; } .licencetag { display:block; padding-top:10px; font-size:80%; } "; return($text); } /* ------------------------------------------------------------------------- return the licence type for an image $default = 'y' => if no licence for the picture, return de default licence 'n' => if no licence for the picture, return empty values ------------------------------------------------------------------------- */ public function get_image_licence($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 licence type if $licence = "" => return all picture with a specific licences ------------------------------------------------------------------------- */ public function get_images_licences($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); } } /* --------------------------------------------------------------------------- ajax functions --------------------------------------------------------------------------- */ } //class ?>