--- /Users/theoldfather/Downloads/slideshowpro/slideshowpro.module 2008-01-24 14:29:43.000000000 -0500
+++ /Users/theoldfather/Desktop/slideshowpro.module 2009-02-20 16:22:00.000000000 -0500
@@ -257,16 +257,43 @@ function slideshowpro_get_image_path() {
}
/**
+ * returns permalink depending on installed modules
+ */
+function slideshowpro_get_permalink($node) {
+ $permalink['link'] = 'node/'.$node->nid;
+ $permalink['target'] = '_blank';
+
+ if(module_exists('link')){
+ if(isset($node->field_link[0]['url'])){
+ $permalink['link'] = link_cleanup_url($node->field_link[0]['url']);
+ }
+ if(isset($node->field_link[0]['attributes'])){
+ $attributes = unserialize($node->field_link[0]['attributes']);
+ if(isset($attributes['target'])){
+ $permalink['target'] = $attributes['target'];
+ }
+ else if(!isset($attributes['target']) && isset($node->field_link[0]['url'])){
+ $permalink['target'] = '_self';
+ }
+ }
+ }
+
+ return $permalink;
+}
+
+/**
* Format an image.
*/
-function theme_slideshowpro_xml_image(&$node, $size = 'preview') {
- $output = ''."\n";
+function theme_slideshowpro_xml_image(&$node, $size = 'preview') {
+ $permalink = slideshowpro_get_permalink($node);
+ $output = '
'."\n";
$variables = array(
'%src' => slideshowpro_get_image_path() . basename($node->images[$size]),
'%title' => check_plain($node->title),
'%caption' => variable_get('slideshowpro_title_as_caption', 0) ?
trim(check_plain($node->title)) : trim(check_plain(truncate_utf8($node->body, 100, TRUE, TRUE))),
- '%link' => url('node/'.$node->nid, NULL, NULL, TRUE),
+ '%link' => url($permalink['link'], NULL, NULL, TRUE),
+ '%target' => $permalink['target'],
'%thumb' => slideshowpro_get_image_path() . basename($node->images['thumbnail']));
return strtr($output, $variables);
}
@@ -300,56 +327,56 @@ function slideshowpro_path_to_ssp() {
* Return all slideshowpro macros as an array.
*/
function slideshowpro_get_macros($text) {
- $m = array();
- preg_match_all('/ \[ ( [^\[\]]+ )* \] /x', $text, $matches);
- $tag_match = (array) array_unique($matches[1]); // Don't process duplicates.
-
- foreach($tag_match as $macro) {
- $current_macro = '['. $macro .']';
- $param = array_map('trim', explode('|', $macro));
- $func_name = array_shift($param); // The first macro param is assumed to be the function name.
- if ($func_name == 'ssp') {
- $vars = array();
- foreach($param as $p) {
- $pos = strpos($p, '=');
- $varname = substr($p, 0, $pos);
- $varvalue = substr($p, $pos + 1);
- $vars[$varname] = $varvalue;
- }
- // the full unaltered filter string is the key for the array of filter attributes
- $m[$current_macro] = $vars;
- }
- }
+ $m = array();
+ preg_match_all('/ \[ ( [^\[\]]+ )* \] /x', $text, $matches);
+ $tag_match = (array) array_unique($matches[1]); // Don't process duplicates.
+
+ foreach($tag_match as $macro) {
+ $current_macro = '['. $macro .']';
+ $param = array_map('trim', explode('|', $macro));
+ $func_name = array_shift($param); // The first macro param is assumed to be the function name.
+ if ($func_name == 'ssp') {
+ $vars = array();
+ foreach($param as $p) {
+ $pos = strpos($p, '=');
+ $varname = substr($p, 0, $pos);
+ $varvalue = substr($p, $pos + 1);
+ $vars[$varname] = $varvalue;
+ }
+ // the full unaltered filter string is the key for the array of filter attributes
+ $m[$current_macro] = $vars;
+ }
+ }
- return $m;
+ return $m;
}
/**
* Implementation of hook_filter().
*/
function slideshowpro_filter($op, $delta = 0, $format = -1, $text = '') {
- switch ($op) {
- case 'list':
- return array(0 => t('Inline SSP slide shows'));
-
- case 'description':
- return t('Add SSP slide shows to your posts.');
-
- case 'process':
- foreach(slideshowpro_get_macros($text) as $unexpanded_macro => $macro) {
- $expanded_macro = slideshowpro_embed($macro);
- $text = str_replace($unexpanded_macro, $expanded_macro, $text);
- }
- return $text;
- default:
- return $text;
- }
+ switch ($op) {
+ case 'list':
+ return array(0 => t('Inline SSP slide shows'));
+
+ case 'description':
+ return t('Add SSP slide shows to your posts.');
+
+ case 'process':
+ foreach(slideshowpro_get_macros($text) as $unexpanded_macro => $macro) {
+ $expanded_macro = slideshowpro_embed($macro);
+ $text = str_replace($unexpanded_macro, $expanded_macro, $text);
+ }
+ return $text;
+ default:
+ return $text;
+ }
}
/**
* Implementation of hook_filter_tips().
*/
function slideshowpro_filter_tips($delta, $format, $long = false) {
- return t('SSP slideshows can be added to this post. Example: [ssp|path=path/to/your/ssp/feed|width=300|height=200].');
+ return t('SSP slideshows can be added to this post. Example: [ssp|path=path/to/your/ssp/feed|width=300|height=200].');
}
/**
@@ -358,46 +385,79 @@ function slideshowpro_filter_tips($delta
function slideshowpro_embed($args) {
static $id = 0;
$id++;
- // path to xml
- $flash_vars = 'xmlfilepath='. url($args['path'], NULL, NULL, TRUE);
- // check, wether parameters available
- $flash_vars .= '¶meters=';
- if (isset($args['params'])) {
- $params = explode(',', $args['params']);
- foreach ($params as $param) {
- if ($var = explode(':', $param)) {
- // if we use titles as captions, ignore showCaptionHeader
- $flash_vars .= $var[0] .':'. check_plain($var[1]) .',';
- }
- }
- }
- // hide caption header if we are using titles as captions
- if (variable_get('slideshowpro_title_as_caption', 0)) {
- $flash_vars .= 'showCaptionHeader:False,';
- }
- // width and height
- if (isset($args['width'])) {
- $width = ' width="'.$args['width'].'" ';
- }
- if (isset($args['height'])) {
- $height = ' height="'.$args['height'].'" ';
- }
+
+
+ // path to xml
+ $flash_vars = 'xmlfilepath='. url($args['path'], NULL, NULL, TRUE);
+ $vars['xmlfilepath']=url($args['path'], NULL, NULL, TRUE);
+
+
+ // check, wether parameters available
+ $flash_vars .= '¶meters=';
+ $vars['parameters']='';
+ if (isset($args['params'])) {
+ $params = explode(',', $args['params']);
+ foreach ($params as $param) {
+ if ($var = explode(':', $param)) {
+ // if we use titles as captions, ignore showCaptionHeader
+ $flash_vars .= $var[0] .':'. check_plain($var[1]) .',';
+ $vars['parameters'] .= $var[0] .':'. check_plain($var[1]) .',';
+ }
+ }
+ }
+ // hide caption header if we are using titles as captions
+ if (variable_get('slideshowpro_title_as_caption', 0)) {
+ $flash_vars .= 'showCaptionHeader:False,';
+ $vars['parameters'] .= 'showCaptionHeader:False,';
+ }
+ // width and height
+ if (isset($args['width'])) {
+ $width = ' width="'.$args['width'].'" ';
+ }
+ if (isset($args['height'])) {
+ $height = ' height="'.$args['height'].'" ';
+ }
+ if (isset($args['path-to-ssp'])) {
+ $path_to_ssp = $args['path-to-ssp'];
+ }
+ else{
+ $path_to_ssp = slideshowpro_path_to_ssp();
+ }
- return theme('slideshowpro_embed',
- '', $id);
+ if(module_exists('swfobject_api')){
+ $params = array(
+ 'width' => $args['width'],
+ 'height' => $args['height'],
+ 'version' => 8,
+ 'allowScriptAccess' => 'sameDomain',
+ 'quality' => 'high',
+ 'movie' => base_path() . $path_to_ssp,
+ 'wmode' => 'transparent',
+ 'express_redirect' => true,
+ 'no_flash' => t('')
+ );
+
+ return theme("swfobject_api", base_path() . $path_to_ssp, $params, $vars );
+
+ }
+ else{
+ return theme('slideshowpro_embed',
+ '', $id);
+ }
}
/**
* theme output
*/
function theme_slideshowpro_embed($output, $id) {
- return '