pwg_options = 'PiwigoPress_Admin'; add_option($this->pwg_options, serialize(array())); $this->gallery = unserialize(get_option($this->pwg_options)); $this->previous = $this->gallery; // Previous is not currently used $this->get_request(); $this->update(); update_option($this->pwg_options, serialize($this->gallery)); $piwigo = empty($this->gallery['piwigo']) ? '' : $this->gallery['piwigo']; $piwigo_url = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $piwigo ; if (!empty($this->gallery['external'])) $piwigo_url = $this->gallery['external']; if (substr($piwigo_url,-1)!='/') $piwigo_url .= '/'; $this->piwigo_url = $piwigo_url; } #add Piwigo button on editor-toolbar function add_button($context=''){ global $post_ID, $temp_ID; $_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID); $this->post_id = $_ID; $iframe_src = 'media-upload.php?post_id='.$_ID.'&type=piwigo&TB_iframe=true'; $title = __('Add Some Pictures From Piwigo'); $out = ''; $context.=$out; return $context; } function add_tab($tabs) { global $wpdb; /* Need for recent thumbnail access */ if($_REQUEST['type'] != 'piwigo') return $tabs; $response = pwg_get_contents( $this->piwigo_url . 'ws.php?method=pwg.categories.getList&format=php'); $this->gallery['categories'] = unserialize($response); $this->gallery['images']['stat'] = $this->gallery['categories']['stat']; if ($this->gallery['categories']['stat'] == 'ok') { $options = ''; $number = empty($this->gallery['number']) ? 10 : intval($this->gallery['number']); $options .= '&per_page=' . $number; if (!empty($this->gallery['category'])) $options .= '&cat_id=' . intval($this->gallery['category']); $from = empty($this->gallery['from']) ? '12' : intval($this->gallery['from']); $r = (array) $wpdb->get_results('SELECT date_sub( date( now( ) ) , INTERVAL ' . $from . ' MONTH ) as begin'); $from = $r[0]->begin; if (!empty($this->gallery['from'])) $options .= '&f_min_date_created=' . $from; $response = pwg_get_contents( $this->piwigo_url . 'ws.php?method=pwg.categories.getImages&format=php' . $options . '&recursive=true&order=random&f_with_thumbnail=true'); $this->gallery['images'] = unserialize($response); } $tab = (isset($_GET['tab'])) ? strip_tags(stripslashes($_GET['tab'])):'type'; // Default results if ( $this->gallery['categories']['stat'] != 'ok') $tab = 'select'; // No WS available if ( $this->gallery['images']['stat'] != 'ok') $tab = 'select'; // No WS available if ( $tab != 'select' and $this->gallery['images']['result']['images']['count'] == 0 ) $tab = 'criteria'; // No pictures available if ( $tab != 'select' and count($this->gallery['categories']['result']['categories']) == 0 ) $tab = 'select'; // No categories available $this->gallery['tab'] = $tab; if ( $this->gallery['images']['stat'] == 'ok' and $this->gallery['images']['result']['images']['count'] > 0 ) return array( 'result' => __('Select pictures'), 'criteria' => __('Your criteria'), 'select' => __('Select the Piwigo gallery'), ); if ( $this->gallery['categories']['stat'] == 'ok' and count($this->gallery['categories']['result']['categories']) > 0 ) return array( 'criteria' => __('Your criteria'), 'select' => __('Select the Piwigo gallery'), ); else return array( 'select' => __('Select the Piwigo gallery'), ); } function get_request() { $this->request = $this->gallery; foreach($_REQUEST as $key=>$value) { if(substr($key, 0, 12) == "PiwigoPress_") $this->request[substr($key, 12)] = trim($value); } } function update(){ $this->gallery['piwigo'] = strip_tags(stripslashes($this->request['piwigo'])); $this->gallery['external'] = strip_tags(stripslashes($this->request['external'])); } function head() { ?> /wp-content/plugins/piwigopress/css/style.css" type="text/css" rel="stylesheet"/> '; switch ($this->gallery['tab']) { case 'type': $html .= $this->add_Piwigo_Select(); break; case 'criteria': $html .= $this->add_Piwigo_Select(); break; case 'select': $html .= $this->add_Piwigo_Select(); break; } $html .= ''; echo $html; } function add_Piwigo_Select() { $piwigo = (empty($this->gallery['piwigo'])) ? 'piwigo' : $this->gallery['piwigo']; $external = (empty($this->gallery['external'])) ? '' : $this->gallery['external']; $iframe_src = 'media-upload.php?post_id='.$_ID.'&type=piwigo&TB_iframe=true'; $message = (isset($this->request['sub-url'])) ? __('Configuration saved'):''; return '

' . __('From my Piwigo gallery','pwg') . '

' . nl2br(__(<<
' . $message . '

'; } } } if (!is_object($PWG_Adm)) { $PWG_Adm = new PiwigoPress_Admin(); } /* function getAdminMenu() { add_submenu_page("plugins.php", "PiwigoPress", "PiwigoPress", "administrator", basename(__FILE__), array(&$PWG_Adm, "getAdminContent")); } */ ?>