> ------------------------------------------------------------------------------ See main.inc.php for release information LMT_root : common classe for admin and public classes --------------------------------------------------------------------------- */ include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/common_plugin.class.inc.php'); include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/css.class.inc.php'); include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/ajax.class.inc.php'); global $ajax; class LMT_root extends common_plugin { 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 LMT_root($prefixeTable, $filelocation) { $this->plugin_name='LMT'; $this->plugin_name_files="lmt"; parent::common_plugin($prefixeTable, $filelocation); $this->section_name=$this->plugin_name_files; $this->set_tables_list(array('images', 'licence_author', 'licence_doc')); $this->css = new css(dirname($this->filelocation).'/'.$this->plugin_name_files.".css"); $this->css_icn = new css(dirname($this->filelocation).'/'.$this->plugin_name_files."_icn.css"); } public function init_events() { add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') ); } /* menu block management */ public function register_blocks() { } /* surchage of common_plugin->save_config function */ public function save_config() { if(parent::save_config()) { $this->css->make_CSS($this->generate_CSS()); $this->css_icn->make_CSS($this->generate_CSS2()); return(true); } return(false); } /* surchage of common_plugin->save_config function */ public function load_config() { parent::load_config(); if(!$this->css->css_file_exists()) { $this->css->make_CSS($this->generate_CSS()); } if(!$this->css_icn->css_file_exists()) { $this->css_icn->make_CSS($this->generate_CSS2()); } } /* intialize default values */ public function init_config() { //global $user; $this->my_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->my_config['lmt_warning_texts'][$key]=''; $this->my_config['lmt_redirect_url-by'][$key]='http://creativecommons.org/licenses/by/2.0/'.$lang; $this->my_config['lmt_redirect_url-by-nd'][$key]='http://creativecommons.org/licenses/by-nd/2.0/'.$lang; $this->my_config['lmt_redirect_url-by-nc'][$key]='http://creativecommons.org/licenses/by-nc/2.0/'.$lang; $this->my_config['lmt_redirect_url-by-nc-nd'][$key]='http://creativecommons.org/licenses/by-nc-nd/2.0/'.$lang; $this->my_config['lmt_redirect_url-by-nc-sa'][$key]='http://creativecommons.org/licenses/by-nc-sa/2.0/'.$lang; $this->my_config['lmt_redirect_url-by-sa'][$key]='http://creativecommons.org/licenses/by-sa/2.0/'.$lang; $this->my_config['lmt_redirect_url-cright'][$key]=''; $this->my_config['lmt_redirect_url-cleft'][$key]=''; } } /* generate the css code */ protected function generate_CSS() { $text = " .TableRow:hover { background-color:#".$this->my_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=mysql_fetch_array($result)) { $return=array( "defaut" => "n", "licence" => $row['licence_type'], "aut_text1" => $row['text1'], "aut_text2" => $row['text2'] ); } } if(($return["licence"]=="")&&($this->my_config["lmt_licence_visible"]=="y")) { $return=array( "defaut" => "y", "licence" => $this->my_config["lmt_licence_default"], "aut_text1" => "", "aut_text2" => "" ); $sql="SELECT * FROM ".$this->tables['licence_author']." WHERE id = '".$this->my_config["lmt_licence_default_author"]."'"; $result=pwg_query($sql); if($result) { while($row=mysql_fetch_array($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=mysql_fetch_assoc($result)) { array_push($returned, $row); } return($returned); } return(false); } protected function display_result($action_msg, $result) { global $page; if($result) { array_push($page['infos'], $action_msg); } else { array_push($page['errors'], $action_msg); } } /* --------------------------------------------------------------------------- ajax functions --------------------------------------------------------------------------- */ } //class ?>