Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Initial commit

  • Loading branch information...
commit 969f89a8c10cb6b03a7f3952216fce90751a620f 0 parents
Masuga Design authored April 17, 2009
2  .gitignore
... ...
@@ -0,0 +1,2 @@
  1
+*.DS_Store
  2
+*.tmproj
42  README.textile
Source Rendered
... ...
@@ -0,0 +1,42 @@
  1
+h1. MD Weegee
  2
+
  3
+This works well if you have one weblog that is used as a "gallery". Unfortunately this _only_ works on a field whose Field Type is "File" – which is another 3rd-party extension by Mark Huot. In the MD Weegee settings, you enter one field id (the field id for the File field you have) – and MD Weegee will put a thumb from that field on the Edit page. This also only works with one weblog right now.
  4
+
  5
+If you can improve on the functionality of this add-on, please feel free to clone/fork it and make it happen, captain.
  6
+
  7
+h2. Info
  8
+
  9
+Developed by Ryan Masuga, http://masugadesign.com
  10
+
  11
+This extension allows you to easily see what entries are expired – or set to expire in the future. A brand new dropdown is inserted in the search area of the Edit page so you can also filter by entries that are expired. Very handy if you use EE’s built in entry expiration!
  12
+
  13
+Docs: "MD Weegee":http://www.masugadesign.com/the-lab/scripts/weegee/ <br />
  14
+EE Extension Info: http://expressionengine.com/docs/development/extensions.html
  15
+
  16
+Related EE Forum Thread: "Extension: Weegee - Add thumbnail image for entries on the EE CP Edit page":http://expressionengine.com/forums/viewthread/84513/
  17
+
  18
+h2. Installation
  19
+
  20
+# Put lang.weegee.php in your */system/language/english* folder
  21
+# Put ext.weegee.php in your */system/extensions* folder.
  22
+# Enable Weegee in Extensions (Admin > Utilities > Extensions Manager)
  23
+# In the settings, Eenter the field id number of the File field for which you want to show thumbnails
  24
+# Change the width of the thumbnails, if desired
  25
+
  26
+h2. Changelog
  27
+
  28
+*1.0.2 - (April 17, 2009)*
  29
+
  30
+* Changed name to MD Weegee
  31
+* Remove version info from language file
  32
+* Added LG Addon Updater checking
  33
+* Changed End of File to follow EE guidelines
  34
+* Updated how settings are stored
  35
+
  36
+1.0.1 – (January 12, 2009)
  37
+
  38
+* Removed outdated "Check for Update" method that was causing errors on the Control Panel homepage.
  39
+
  40
+1.0.0 – (July 8, 2008)
  41
+
  42
+* Initial release.
247  extensions/ext.md_weegee.php
... ...
@@ -0,0 +1,247 @@
  1
+<?php
  2
+/* ===========================================================================
  3
+ext.md_weegee.php ---------------------------
  4
+Show thumbs on the edit page list. Use it when using a weblog as gallery.
  5
+            
  6
+INFO ---------------------------
  7
+Developed by: Ryan Masuga, masugadesign.com
  8
+Created:   Jul 08 2008
  9
+Last Mod:  Apr 17 2009
  10
+
  11
+Related Thread: http://expressionengine.com/forums/viewthread/84513/
  12
+=============================================================================== */
  13
+if ( ! defined('EXT')) { exit('Invalid file request'); }
  14
+
  15
+if ( ! defined('MD_WG_version')){
  16
+	define("MD_WG_version",			"1.0.2");
  17
+	define("MD_WG_docs_url",		"http://masugadesign.com/the-lab/scripts/weegee/");
  18
+	define("MD_WG_addon_id",		"MD Weegee");
  19
+	define("MD_WG_extension_class",	"Md_weegee");
  20
+	define("MD_WG_cache_name",		"mdesign_cache");
  21
+}
  22
+
  23
+class Md_weegee
  24
+{
  25
+	var $settings		= array();
  26
+	var $name           = 'MD Weegee';
  27
+	var $version        = MD_WG_version;
  28
+	var $description    = 'Show image thumbnails on the edit page list.';
  29
+	var $settings_exist = 'y';
  30
+	var $docs_url       = MD_WG_docs_url;
  31
+
  32
+// --------------------------------
  33
+//  PHP 4 Constructor
  34
+// --------------------------------
  35
+	function Md_weegee($settings='')
  36
+	{
  37
+		$this->__construct($settings);
  38
+	}
  39
+
  40
+// --------------------------------
  41
+//  PHP 5 Constructor
  42
+// --------------------------------
  43
+	function __construct($settings='')
  44
+	{
  45
+		$this->settings = $settings;
  46
+	}
  47
+
  48
+	// --------------------------------
  49
+	//  Change Settings
  50
+	// --------------------------------  
  51
+ 	function settings()
  52
+	{
  53
+		$settings = array();
  54
+		$settings['field_id'] = '';
  55
+		$settings['thumb_width'] = '';
  56
+		$settings['check_for_updates'] = array('s', array('y' => "Yes", 'n' => "No"), 'y');
  57
+
  58
+		return $settings;
  59
+	} 
  60
+
  61
+
  62
+
  63
+
  64
+
  65
+	
  66
+	// --------------------------------
  67
+	//  Activate Extension
  68
+	// --------------------------------
  69
+	function activate_extension()
  70
+	{
  71
+		global $DB, $PREFS;
  72
+		
  73
+		$default_settings = serialize(
  74
+			array(
  75
+				
  76
+			  'field_id' => "",
  77
+			  'thumb_width' => "80",
  78
+				'check_for_updates'	=> 'y'
  79
+			)
  80
+		);
  81
+		
  82
+
  83
+	
  84
+		$hooks = array(
  85
+		  'edit_entries_additional_tableheader' => 'edit_entries_additional_tableheader',
  86
+		  'edit_entries_additional_celldata'    => 'edit_entries_additional_celldata',
  87
+			// allow to work with LG Addon Updater
  88
+		  'lg_addon_update_register_source'     => 'lg_addon_update_register_source',
  89
+		  'lg_addon_update_register_addon'      => 'lg_addon_update_register_addon'
  90
+		);
  91
+		
  92
+		foreach ($hooks as $hook => $method)
  93
+		{
  94
+			$sql[] = $DB->insert_string( 'exp_extensions', 
  95
+				array('extension_id' 	=> '',
  96
+					'class'			=> get_class($this),
  97
+					'method'		=> $method,
  98
+					'hook'			=> $hook,
  99
+					'settings'		=> $default_settings,
  100
+					'priority'		=> 10,
  101
+					'version'		=> $this->version,
  102
+					'enabled'		=> "y"
  103
+				)
  104
+			);
  105
+		}
  106
+
  107
+		// run all sql queries
  108
+		foreach ($sql as $query)
  109
+		{
  110
+			$DB->query($query);
  111
+		}
  112
+		return TRUE;
  113
+	}	
  114
+	
  115
+	// --------------------------------
  116
+	//  Disable Extension
  117
+	// -------------------------------- 
  118
+	function disable_extension()
  119
+	{
  120
+		global $DB;
  121
+		$DB->query("DELETE FROM exp_extensions WHERE class = '" . get_class($this) . "'");
  122
+	}
  123
+	
  124
+	// --------------------------------
  125
+	//  Update Extension
  126
+	// --------------------------------  
  127
+	function update_extension($current='')
  128
+	{
  129
+		global $DB;
  130
+		
  131
+		if ($current == '' OR $current == $this->version)
  132
+		{
  133
+			return FALSE;
  134
+		}
  135
+		
  136
+		$DB->query("UPDATE exp_extensions
  137
+		            SET version = '".$DB->escape_str($this->version)."'
  138
+		            WHERE class = '".get_class($this)."'");
  139
+	}
  140
+	// END
  141
+// ============================================================================
  142
+
  143
+
  144
+	// --------------------------------
  145
+	//  Add Image Table Heading
  146
+	// --------------------------------
  147
+	
  148
+	function edit_entries_additional_tableheader()
  149
+	{
  150
+		global $DSP, $LANG, $EXT;
  151
+		
  152
+		if (empty($this->settings['field_id'])) {
  153
+		  return;
  154
+		}
  155
+		
  156
+		$LANG->fetch_language_file('weegee');
  157
+		$extra = ($EXT->last_call !== FALSE) ? $EXT->last_call : '';
  158
+		return $extra.$DSP->table_qcell('tableHeadingAlt', $LANG->line('image'));
  159
+	}
  160
+	// END
  161
+
  162
+
  163
+	function lg_addon_update_register_source($sources)
  164
+	{
  165
+		global $EXT;
  166
+		if($EXT->last_call !== FALSE)
  167
+			$sources = $EXT->last_call;
  168
+		// must be in the following format:
  169
+		/*
  170
+		<versions>
  171
+			<addon id='LG Addon Updater' version='2.0.0' last_updated="1218852797" docs_url="http://site.com/" />
  172
+		</versions>
  173
+		*/
  174
+		if($this->settings['check_for_updates'] == 'y')
  175
+		{
  176
+			$sources[] = 'http://masugadesign.com/versions/';
  177
+		}
  178
+		return $sources;
  179
+	}
  180
+
  181
+	function lg_addon_update_register_addon($addons)
  182
+	{
  183
+		global $EXT;
  184
+		if($EXT->last_call !== FALSE)
  185
+			$addons = $EXT->last_call;
  186
+		if($this->settings['check_for_updates'] == 'y')
  187
+		{
  188
+			$addons[MD_LS_addon_id] = $this->version;
  189
+		}
  190
+		return $addons;
  191
+	}
  192
+
  193
+
  194
+	// ---------------------------------
  195
+	//  Add thumbnail for Entries
  196
+	// ---------------------------------
  197
+	
  198
+	function edit_entries_additional_celldata($row)
  199
+	{	
  200
+		global $DSP, $LANG, $EXT, $DB;
  201
+		
  202
+		global $img_i;
  203
+		 
  204
+		 if (empty($img_i))
  205
+		 {
  206
+		 	$img_i = 0;
  207
+		 }
  208
+		
  209
+		if (empty($this->settings['field_id'])) {
  210
+		  return;
  211
+		}
  212
+		
  213
+		$image="-";
  214
+		
  215
+		$uploadprefs = $DB->query('SELECT f.*, u.url as theurl FROM exp_weblog_fields f, exp_upload_prefs u WHERE f.field_id = '.$this->settings['field_id'].' AND f.field_list_items=u.id');
  216
+		
  217
+		$customfield = 'field_id_'.$this->settings['field_id'];
  218
+		
  219
+		$query = $DB->query("SELECT ".$customfield." FROM exp_weblog_data WHERE entry_id='".$row['entry_id']."'");
  220
+		
  221
+		$theimage = "";
  222
+		$thefileuploadpath = "";
  223
+
  224
+			foreach($uploadprefs->result as $uploadpref)
  225
+		{
  226
+		  $thefileuploadpath = $uploadpref['theurl'];
  227
+	  }
  228
+
  229
+			foreach($query->result as $file_field)
  230
+		{
  231
+		  $theimage = $file_field[$customfield];
  232
+	  }
  233
+	if ($theimage !="") {
  234
+		  $image = '<img src="'.$thefileuploadpath.$theimage.'" alt="" width="'.$this->settings['thumb_width'].'" valign="middle" />';
  235
+		} 
  236
+							
  237
+		$style = ($img_i % 2) ? 'tableCellOne' : 'tableCellTwo'; $img_i++;
  238
+		
  239
+		$extra = ($EXT->last_call !== FALSE) ? $EXT->last_call : '';
  240
+		
  241
+		return $extra.$DSP->table_qcell($style, $image);
  242
+	}
  243
+
  244
+/* END class */
  245
+}
  246
+/* End of file ext.md_weegee.php */
  247
+/* Location: ./system/extensions/ext.md_weegee.php */ 
25  language/english/lang.md_weegee.php
... ...
@@ -0,0 +1,25 @@
  1
+<?php
  2
+/*
  3
+extension:     ext.md_weegee.php
  4
+=================================================
  5
+ryan masuga, masugadesign.com
  6
+ryan@masugadesign.com | Copyright 2008-2009
  7
+================================================= */
  8
+
  9
+$L = array(
  10
+
  11
+'image' =>
  12
+"Image",
  13
+
  14
+'field_id' =>
  15
+"Field ID (only accepts one number right now)",
  16
+
  17
+'thumb_width' =>
  18
+"Width (in pixels) of the thumbnail",
  19
+
  20
+'check_for_updates' 	       => 'Check for updates? (requires LG Addon Updater)',
  21
+
  22
+// END
  23
+''=>''
  24
+);
  25
+?>

0 notes on commit 969f89a

Please sign in to comment.
Something went wrong with that request. Please try again.