Index: includes/linodef_buttonsapi.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/linodef/modules/linodef_buttonsapi/includes/Attic/linodef_buttonsapi.inc,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 linodef_buttonsapi.inc
--- includes/linodef_buttonsapi.inc	21 Jan 2009 17:19:40 -0000	1.1.2.5
+++ includes/linodef_buttonsapi.inc	30 Apr 2009 23:14:12 -0000
@@ -12,6 +12,99 @@
  */
 
 /**
+ * Get data for button: Show elements by view name.
+ *
+ * @param string $viewname
+ *      The name of the view.
+ * @param string $options
+ *      Linodef tag options separated by comma.
+ * @return
+ *      array
+ *          - data: the node/field/vocab data
+ *              - tag: the tag to be inserted
+ *              - desc: the description for the editor button
+ *          - name: the label/name of the node/field/vocab
+ *          - element type
+ *          - element
+ *      string
+ *          if view not found a message is returned which should appear in editor text field (depends on Linodef submodule for editor)
+ *
+ * @see linodef_buttonsapi_rawdata()
+ */
+function _linodef_buttonsapi_getelementssbyviewname($viewname, $display_id = NULL, $args = NULL, $options) {
+  $view_result = _linodef_buttonsapi_get_view_result($viewname, $display_id, $args);
+  if (is_array($view_result) {
+    if (property_exists($view_result[0], nid)) {
+      // Check for CCK fields -> if the FIRST view field object type is a valid field, the embed the FIRST field, otherwise the nodes.
+      // To check use node_data_%field, where %field is the field_name.
+      foreach ($view_result as $item) {
+        // Use field value or node title and heed options-> similar to the other functions.
+      }
+    }
+    elseif (property_exists($view_result[0], tid)) {
+      foreach ($view_result as $item) {
+        // Use term name and heed options-> similar to the other functions.
+        // Retrieve additional information with term_data_%custom.
+      }
+    }
+    return $output;
+  }
+  else {
+    return $view_result;
+  }
+}
+
+/**
+ * Helper function for _linodef_buttonsapi_getelementssbyviewname().
+ * Investigate the result of a view.
+ *
+ * @param string $viewname
+ *      The name of the view to retrieve the data from.
+ * @param string $display_id
+ *      The display id. On the edit page for the view in question, you'll find
+ *      a list of displays at the left side of the control area. "Defaults"
+ *      will be at the top of that list. Hover your cursor over the name of the
+ *      display you want to use. An URL will appear in the status bar of your
+ *      browser. This is usually at the bottom of the window, in the chrome.
+ *      Everything after #views-tab- is the display ID, e.g. page_1.
+ * @param array $args
+ *      Array of arguments.
+ * @return
+ *      array
+ *          An array containing an object for each view item. For details see http://drupal.org/node/342132 and http://views.doc.logrus.com/classview.html.
+ *      string
+ *          If the view is not found a message is returned which should appear in editor text field (depends on Linodef submodule for editor)
+ *
+ * @see linodef_buttonsapi_rawdata()
+ */
+function _linodef_buttonsapi_get_view_result($viewname, $display_id = NULL, $args = NULL) {
+  if (module_exists('views')) {
+    $view = views_get_view($viewname);
+    if (is_object($view)) {
+      if (is_array($args)) {
+        $view->set_arguments($args);
+      }
+      if (is_string($display_id)) {
+        $view->set_display($display_id);
+      }
+      else {
+        // Heed pager setting.
+        $view->init_display();
+      }
+      $view->pre_execute();
+      $view->execute();
+      return $view->result;
+    }
+    else {
+      return linodef_message(array('error' => array('view' => $viewname, 'type' => 'not found')), TRUE);
+    }
+  }
+  else {
+    return linodef_message(array('warning' => array('activate module' => 'Views'), 'explanation' => array('option to use in tag id' => array('%option' => 'viewid', '%id' => $viewname))), TRUE);
+  }
+}
+
+/**
  * Get data for button: Show fields by field name.
  *
  * @param string $fieldname
@@ -29,7 +122,7 @@
  *      string
  *          if node/field (value) not found a message is returned which should appear in editor text field (depends on Linodef submodule for editor)
  *
- * @see linodef_editorbuttons_switch()
+ * @see linodef_buttonsapi_rawdata()
  */
 function _linodef_buttonsapi_getfieldsbyfieldname($fieldname, $option_string) {
     // Heed content permissions settings if module is enabled.
@@ -122,7 +215,7 @@
  *      string
  *          if content type not found a message is returned which should appear in editor text field (depends on Linodef submodule for editor)
  *
- * @see linodef_editorbuttons_switch()
+ * @see linodef_buttonsapi_rawdata()
  */
 function _linodef_buttonsapi_getnodesbycontenttype($contenttype, $option_string) {
     if ($ctype_obj = node_get_types('type', $contenttype)) {
@@ -178,7 +271,7 @@
  *      string
  *          if vid not found a message is returned which should appear in editor text field (depends on Linodef submodule for editor)
  *
- * @see linodef_editorbuttons_switch()
+ * @see linodef_buttonsapi_rawdata()
  */
 function _linodef_buttonsapi_gettermsbyvid($vid, $option_string) {
   if (module_exists('taxonomy')) {
Index: linodef_buttonsapi.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/linodef/modules/linodef_buttonsapi/Attic/linodef_buttonsapi.module,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 linodef_buttonsapi.module
--- linodef_buttonsapi.module	30 Nov 2008 13:00:31 -0000	1.1.2.2
+++ linodef_buttonsapi.module	30 Apr 2009 11:05:21 -0000
@@ -9,7 +9,7 @@
  * 2) Buttons
  *  a. Provide a popup window.
  *  b. Provide autocomplete button.
- * 4) Admin settings.
+ * 3) Admin settings.
  *
  * @package Linodef
  * @author Roi Danton
@@ -86,15 +86,25 @@
     $options = linodef_buttonsapi_validate_tagoptions($option_string_path);
     $option_string = $options ? ','. implode(',', $options) : '';
 
-    if (substr($drupal_element, 0, 6) == "field_") {
+    // Retrieve element list using views.
+    if (substr($drupal_element, 0, 5) == "view_") {
+        //$output = _linodef_buttonsapi_getelementssbyviewname($drupal_element, $option_string);
+    }
+    // Backwards compatbility for Linodef versions <RC3.
+    // Fields by name.
+    elseif (substr($drupal_element, 0, 6) == "field_") {
         $output = _linodef_buttonsapi_getfieldsbyfieldname($drupal_element, $option_string);
     }
+    // Taxonomy terms by vid.
     elseif (preg_match("@([0-9]+)@", $drupal_element)) {
+
         // Remove tag options that are not needed for terms: translation.
         if ($options['translation']) { unset($options['translation']); }
-        $option_string = preg_replace("@,translation=([a-zA-Z]{2})@", "", $option_string);
+        $option_string = preg_replace("@,translation=([a-zA-Z]+)@", "", $option_string);
+        
         $output = _linodef_buttonsapi_gettermsbyvid($drupal_element, $option_string);
     }
+    //Nodes by content type.
     else {
         $output = _linodef_buttonsapi_getnodesbycontenttype($drupal_element, $option_string);
     }
@@ -128,6 +138,7 @@
             $options_path = explode(',', $option_string);
         }
         // If modified by linodef_buttonsapi_tagoptions_to_path().
+        // DOESNT WORK WITH NEW TAGOPTIONS LAYOUT, NEEDS TO BE MODIFIED!
         elseif (strpos($option_string, '_') !== FALSE) {
             $options_path = explode('_', $option_string);
         }
@@ -165,8 +176,9 @@
  */
 function linodef_buttonsapi_tagoptions_to_path($options) {
     $output = implode('_', $options);
-    // Make option layout compatible with path: translation.
+    // Make options with values compatible with paths.
     $output = str_replace('=', '-', $output);
+    // todo: remove/modify strings between ""
     return $output;
 }
 
@@ -331,7 +343,7 @@
 }
 
 /**
- * 4) Admin settings.
+ * 3) Admin settings.
  *
  * Implementation of hook_form_[form_id]_alter().
  *

