/** * Perform plugin operation * * @param int $plugin_id The plugin id * @param string $action The action to perform */ public function action_plugin_ui($plugin_id, $action) { $confirm_url = rawurlencode(URL::get('admin', array('page' => 'plugins', 'configure' => $this->plugin_id(), 'configaction' => 'Confirm')) . '#plugin_options'); $picasa = new Picasa(); $auth_url = $picasa->get_auth_url() . $confirm_url; $deauth_url = URL::get('admin', array('page' => 'plugins', 'configure' => $this->plugin_id(), 'configaction' => 'De-Authorize')) . '#plugin_options'; if ($plugin_id == $this->plugin_id) { switch ($action) { case _t('Authorize'): if ($this->is_auth()) { echo "<p>" . _t("This installation has already been authorized to access your Picasa account.") . "</p>"; echo "<p><a href='" . $deauth_url . "' title='" . _t("De-Authorize") . "'>" . _t("De-Authorize access to your Picasa account") . "</p>"; } else { echo "<p>" . _t("You have not authorized access to your Picasa account") . "</p>"; echo "<p><a href='" . $auth_url . "' target='_blank'>" . _t("Authorize") . "</a> " . _t("your Habari installation to access your Picasa account") . "</p>"; } break; case 'Confirm': if (!isset($_GET['token'])) { echo "<p>" . _t("Your account has not been authorized access to this installation.") . "<p>"; echo "<p><a href='" . $auth_url . "' target='_blank'>" . _t("Authorize") . "</a> " . _t("your Habari installation to access your Picasa account.") . "</p>"; } else { $token = $_GET['token']; $picasa->exchange_token($token); echo "<p>" . _t("Your authorization was successful.") . "</p>"; echo "<p><a href='" . $deauth_url . "' title='" . _t("De-Authorize") . "'>" . _t("De-Authorize access to your Picasa account") . "</p>"; } break; case _t('De-Authorize'): Options::delete('picasa_token_' . User::identify()->id, $token); echo "<p>" . _t("De-Authorization successful. This installation will no longer be able to access your Picasa account.") . "</p>"; echo "<p><a href='" . $auth_url . "' title='" . _t("Authorize") . "' target='_blank'>" . _t("Authorize") . "</a> " . _t("your Habari installation to access your Picasa account") . "</p>"; break; case _t('Configure'): $ui = new FormUI(strtolower(get_class($this))); $ui->append('select', 'picasa_size', 'option:picasasilo__picasa_size', _t('Default size for images in Posts:')); //I did not _t() the following as it should be replaced. Picasa supports all sizes up to original size. $ui->picasa_size->options = array('s75' => 'Square (75x75)', 's100' => 'Thumbnail (100px)', 's240' => 'Small (240px)', 's500' => 'Medium (500px)', 's1024' => 'Large (1024px)', '' => 'Original Size'); $ui->append('submit', 'save', _t('Save')); $ui->set_option('success_message', _t('Options saved')); $ui->out(); break; } } }