Permalink
Browse files

Added Select Box Link Support

  • Loading branch information...
root
root committed Dec 21, 2009
1 parent b608880 commit bda2c22eac809b7dcecf52d742ef94550cbead21
Showing with 42 additions and 26 deletions.
  1. +24 −14 assets/ee.ajaxify.js
  2. +11 −3 content/content.ajaxentries.php
  3. +2 −2 content/content.ajaxfields.php
  4. +5 −7 content/content.export.php
View
@@ -1,13 +1,12 @@
(function($) {
$(document).ready(function() {
$("#linked-section, #linked-entry").parent().hide();
$("#linked-entry").parent().hide();
});
/*---- Section Box Change ----*/
$("#context").live('change', function() {
var self = $(this);
var sectionID = $('option:selected', self).val();
var linked = $('#linked-section');
var sectionID = $('option:selected', $(this)).val(),
linked = $('#linked-section');
linked.attr("disabled",false)
.empty();
@@ -17,33 +16,44 @@
$("#linked-entry").parent().slideUp("fast");
$.get("../ajaxfields/", {section: sectionID}, function(data) {
var options = "";
$(data).find('field').each(function() {
linked.prepend($("<option value='" + $(this).attr('id') + "'>" + $(this).text() + "</option>"));
options += "<option value='" + $(this).attr('id') + "'>" + $(this).text() + "</option>";
});
linked.prepend($("<option value='' selected='selected'></option>"));
if(options == "") {
options = "<option value='' selected='selected'>No Available Links</option>";
} else {
options = "<option value='' selected='selected'>Where..</option>" + options;
}
linked.prepend(options);
}, "xml");
});
});
/*---- Bilink Field Change ----*/
/*---- Linked Field Change ----*/
$("#linked-section").live('change', function() {
var self = $(this);
var bilinkID = $('option:selected', $("#linked-section")).val();
var sectionID = $('option:selected', $('#context')).val();
var entries = $("#linked-entry");
var linkedID = $('option:selected', $("#linked-section")).val(),
sectionID = $('option:selected', $('#context')).val(),
entries = $("#linked-entry");
entries.attr("disabled",false)
.empty();
entries.parent().slideDown("fast", function () {
$.get("../ajaxentries/", {section: sectionID, field: bilinkID}, function(data) {
$.get("../ajaxentries/", {section: sectionID, field: linkedID}, function(data) {
var options = "";
$(data).find('entry').each(function() {
entries.prepend($("<option value='" + $(this).attr('id') + "'>" + $(this).text() + "</option>"));
options += "<option value='" + $(this).attr('id') + "'>" + $(this).text() + "</option>";
});
if(options == "") {
options = "<option value='' selected='selected'>No Entries</option>";
} else {
options = "<option value='' selected='selected'>is..</option>" + options;
}
entries.prepend(options);
}, "xml");
});
@@ -30,8 +30,16 @@ public function view() {
*/
foreach($fields as $field) {
if($field->get("id") == $this->fieldID) {
$linked_section_id = $field->get("linked_section_id");
$linked_field_id = $field->get("linked_field_id");
if($field->get('type') == "bilink") {
$linked_section_id = $field->get("linked_section_id");
$linked_field_id = $field->get("linked_field_id");
} else if($field->get('type') == "selectbox_link") {
$linked_section_id = Symphony::Database()->fetchVar("parent_section_id",0,"SELECT parent_section_id
FROM `tbl_sections_association`
WHERE `child_section_field_id` = {$field->get("id")}
LIMIT 1");
$linked_field_id = $field->get("related_field_id");
}
}
}
@@ -59,4 +67,4 @@ public function validate() {
return (is_numeric($this->target) && is_numeric($this->fieldID));
}
}
?>
?>
@@ -19,7 +19,7 @@ public function view() {
$options = array();
foreach($section->fetchFields() as $field) {
if($field->get('type') == "bilink") {
if(in_array($field->get('type'),array("bilink","selectbox_link"))) {
$el = new XMLElement("field", $field->get('label'));
@@ -32,4 +32,4 @@ public function view() {
}
}
?>
?>
View
@@ -65,7 +65,7 @@ public function __viewIndex() {
/*
** Check if the bilink is installed
*/
if($this->checkExtension("bilinkfield") == EXTENSION_ENABLED) {
if($this->checkExtension("bilinkfield") !== EXTENSION_ENABLED) {
$this->__viewIndexSectionLinks($group);
$this->__viewIndexLinkedEntries($group);
}
@@ -225,7 +225,7 @@ public function export($post) {
/* Data
** -----------
** Get the field scheme, then loop through our data applying the field's prepareTableValue for
** for output. If the field contains a 'linked_enty_id', use resolveLinks to implode the linked values
** for output. If the field contains a relationship, use resolveLinks to implode the linked values
*/
foreach($section->fetchFields() as $field) {
@@ -237,10 +237,9 @@ public function export($post) {
foreach($entries as $k => $v) {
foreach($v['fields'] as $name => $entry) {
$f_id = $fields->fetchFieldIDFromElementName($name, $section->get('id'));
if(isset($entry)) {
if(array_key_exists("linked_entry_id", $entry)) {
$data[$k][] = $this->resolveLinks($entry['linked_entry_id']);
if(array_key_exists("linked_entry_id", $entry) or array_key_exists("relation_id",$entry)) {
$data[$k][] = $this->resolveLinks(current($entry));
} else {
$value = $fields_value[$f_id]->prepareTableValue($entry);
@@ -260,7 +259,6 @@ public function export($post) {
}
}
$output .= $this->_driver->str_putcsv($data);
/* We got our CSV, so lets output it, but we'll exit, because we don't want any Symphony output */
@@ -271,4 +269,4 @@ public function export($post) {
exit;
}
}
?>
?>

0 comments on commit bda2c22

Please sign in to comment.