diff --git a/flickrstickr.info b/flickrstickr.info index 55f941b..f515938 100755 --- a/flickrstickr.info +++ b/flickrstickr.info @@ -1,4 +1,5 @@ ; $Id: flickrstickr.info,v 1.1 2008/07/10 07:37:40 wmostrey Exp $ -name = flickrstickr +name = Flickrstickr +core = 6.x description = Flickr intergration for TinyMCE -dependencies = image \ No newline at end of file +dependencies[] = image diff --git a/flickrstickr.module b/flickrstickr.module index 5a68e4e..7486f0f 100644 --- a/flickrstickr.module +++ b/flickrstickr.module @@ -56,27 +56,27 @@ function flickrstickr_isdrupal47() { /** * implements hook_menu */ -function flickrstickr_menu($may_cache) { +function flickrstickr_menu() { $items = array(); - if (!$may_cache) { - $items[] = array( - 'path' => 'flickrstickr/xml/user', - 'title' => t('xml proxy'), - 'callback' => 'flickrstickr_proxy_user', - 'access' => TRUE, - 'type' => MENU_CALLBACK, - 'weight' => 5, - ); - $items[] = array( - 'path' => 'flickrstickr/xml/images', - 'title' => t('xml proxy'), - 'callback' => 'flickrstickr_proxy_images', - 'access' => TRUE, - 'type' => MENU_CALLBACK, - 'weight' => 5, - ); - $items[] = array( 'path' => 'admin/settings/flickrstickr', 'title' => 'FlickrStickr', 'callback' => 'drupal_get_form', 'callback arguments' => array('flickrstickr_settings'), 'access' => user_access('administer site configuration'), ); - } + $items['flickrstickr/xml/user'] = array( + 'type' => MENU_CALLBACK, + 'page callback' => 'flickrstickr_proxy_user', + 'page arguments' => array(3), + 'access callback' => TRUE, + ); + $items['flickrstickr/xml/images'] = array( + 'type' => MENU_CALLBACK, + 'page callback' => 'flickrstickr_proxy_images', + 'page arguments' => array(3, 5, 4), + 'access callback' => TRUE, + ); + $items['admin/settings/flickrstickr'] = array( + 'title' => 'FlickrStickr', + 'description' => t('Configure Flickrstickr.'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('flickrstickr_settings'), + 'access arguments' => array('flickrstickr admin'), + ); return $items; } @@ -84,10 +84,10 @@ function flickrstickr_menu($may_cache) { * Public ajax proxy for user search * Bcause the javascript restriction */ -function flickrstickr_proxy_user() { +function flickrstickr_proxy_user($username) { header("Content-type: text/xml; charset=UTF-8"); $apikey = flickrstickr_getapikey(); - $content = flickrstrick_get_url("http://www.flickr.com/services/rest/?method=flickr.people.findByUsername&api_key=". $apikey ."&username=". urlencode(arg(3)), "r"); + $content = flickrstrick_get_url("http://www.flickr.com/services/rest/?method=flickr.people.findByUsername&api_key=".$apikey."&username=".urlencode($username), "r"); echo $content; } @@ -95,23 +95,23 @@ function flickrstickr_proxy_user() { * public ajax proxy for tag search * Because the javascript restriction */ -function flickrstickr_proxy_images() { +function flickrstickr_proxy_images($userid, $page, $tags = NULL) { global $user; $flickrstickr = flickrstickr_getuserparam(); header("Content-type: text/xml; charset=UTF-8"); $apikey = flickrstickr_getapikey(); - $userid = urlencode(arg(3)); - $page = urlencode(arg(5)); + $userid = urlencode($userid); + $page = urlencode($page); if ($userid == "!recent!") { - $query = "http://www.flickr.com/services/rest/?method=flickr.photos.getRecent&api_key=". $apikey ."&per_page=". $flickrstickr['imgno'] ."&page=". $page; + $query = "http://www.flickr.com/services/rest/?method=flickr.photos.getRecent&api_key=". $apikey ."&per_page=". $flickrstickr['imgno'] . "&page=" . $page; } else { - $query = "http://www.flickr.com/services/rest/?method=flickr.photos.search&api_key=". $apikey ."&per_page=". $flickrstickr['imgno'] ."&page=". $page; - if (arg(3) != "all") { + $query = "http://www.flickr.com/services/rest/?method=flickr.photos.search&api_key=". $apikey ."&per_page=". $flickrstickr['imgno'] . "&page=" . $page; + if ($user != "all") { $query .= "&user_id=". $userid; } - if (arg(4) != null) { - $query .= "&tags=". urlencode(arg(4)); + if ($tags != null) { + $query .= "&tags=". urlencode($tags); } } echo flickrstrick_get_url($query); @@ -120,12 +120,12 @@ function flickrstickr_proxy_images() { /** * implements hook_user */ -function flickrstickr_user($type, & $edit, & $user, $category= NULL) { - if (!user_access('flickrstickr access', $user)) { - return array(); - } - $flickrstickr = flickrstickr_getuserparam(); +function flickrstickr_user($type, &$edit, &$user, $category= NULL) { if ($type == 'form' && $category == 'account') { + if (!user_access('flickrstickr access', $user)) { + return array(); + } + $flickrstickr = flickrstickr_getuserparam(); $options_link = array( 'none' => 'None', 'flickr_img' => 'Flickr image page', @@ -176,10 +176,11 @@ function flickrstickr_user($type, & $edit, & $user, $category= NULL) { /** * imlements hook_form_alter */ -function flickrstickr_form_alter($form_id, & $form) { - if (preg_match('/_node_form$/', $form_id) && user_access('flickrstickr access')) { +function flickrstickr_form_alter(&$form, $form_state, $form_id) { + if (isset($form['type']) && isset($form['#node']) && user_access('flickrstickr access')) { $form['flickrstickr'] = array( '#type' => 'fieldset', + '#access' => user_access('flickrstickr access'), '#title' => t('Flickr image insert'), '#collapsible' => TRUE, '#collapsed' => TRUE, @@ -187,7 +188,7 @@ function flickrstickr_form_alter($form_id, & $form) { ); $form['flickrstickr']['images'] = array( '#type' => 'markup', - '#value' => _flickrstickr_htmlpart(), + '#value' => _flickrstickr_htmlpart($form['#node']->type), '#weight' => -1, ); } @@ -196,13 +197,13 @@ function flickrstickr_form_alter($form_id, & $form) { /** * Create the flickr images selector */ -function _flickrstickr_htmlpart() { +function _flickrstickr_htmlpart($nodetype) { global $user; global $base_url; $flickrstickr = flickrstickr_getuserparam(); $base_path = base_path(); - drupal_set_html_head(''); - drupal_set_html_head(''); + drupal_add_css(drupal_get_path('module', 'flickrstickr') . '/flickrstickr.css'); + drupal_add_js(drupal_get_path('module', 'flickrstickr') . '/flickrstickr.js'); // This line is needed because of floating image selector drupal_set_html_head(''); $ret = ''; @@ -254,7 +255,6 @@ function _flickrstickr_htmlpart() { $ret .= "function getBaseUrl(){\n". "return \"". $base_url ."\";}\n"; $ret .= "for (i=0;i<". $flickrstickr['imgno'] .";i++) {"."images[i]= new Object();}"; $ret .= 'function insertText(id){'; - $nodetype = arg(2); $cck = strpos($nodetype, 'content-'); if ($cck === FALSE) { $ret .= 'textarea = document.getElementById("edit-body");'; @@ -301,23 +301,6 @@ function flickrstickr_getapikey() { } /** - * implements hook_help - */ -function flickrstickr_help($section) { - switch ($section) { - case 'admin/modules#description': - $output = t("Enable flickr image inserter in your node forms."); - break; - } - return $output; -} - -/* -global $user; -$node = array('uid' => $user->uid, 'name' => $user->name, 'type' => 'image'); -*/ - -/** * implements hook_filter */ function flickrstickr_filter($op, $delta = 0, $format = -1, $text = '') {