Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial work towards releasing for Symphony 2.2.

  • Loading branch information...
commit a59d3dacdd3e460217945987c86c477d79a96cfc 1 parent 8508a27
@psychoticmeow psychoticmeow authored
View
3  assets/publish.css
@@ -0,0 +1,3 @@
+div.field-bilink ol.duplicator div.content {
+ padding-top: 0;
+}
View
27 assets/publish.js
@@ -3,18 +3,21 @@
-----------------------------------------------------------------------------*/
jQuery(document).ready(function() {
- jQuery('.field-bilink ol.multiple').symphonyDuplicator({
- orderable: true,
- collapsible: false,
- minimum: 0,
- maximum: 10000000
- });
- jQuery('.field-bilink ol.single').symphonyDuplicator({
- orderable: false,
- collapsible: false,
- minimum: 0,
- maximum: 1
- });
+ jQuery('.field-bilink ol.multiple')
+ .symphonyDuplicator({
+ orderable: true,
+ collapsible: true,
+ minimum: 0,
+ maximum: 10000000
+ });
+
+ jQuery('.field-bilink ol.single')
+ .symphonyDuplicator({
+ orderable: false,
+ collapsible: true,
+ minimum: 0,
+ maximum: 1
+ });
});
/*---------------------------------------------------------------------------*/
View
7 extension.driver.php
@@ -8,8 +8,8 @@ class Extension_BiLinkField extends Extension {
public function about() {
return array(
'name' => 'Field: Bi Link',
- 'version' => '1.0.14',
- 'release-date' => '2009-09-03',
+ 'version' => '1.1.0',
+ 'release-date' => '2011-03-03',
'author' => array(
'name' => 'Rowan Lewis',
'website' => 'http://pixelcarnage.com/',
@@ -46,7 +46,7 @@ public function uninstall() {
}
public function update($previousVersion) {
- if (version_compare($previousVersion, '1.0.14', '<')) {
+ if (version_compare($previousVersion, '1.1.0', '<')) {
Symphony::Database()->query("
ALTER TABLE `tbl_fields_bilink`
ADD COLUMN `allow_editing` ENUM('yes','no') DEFAULT 'no';
@@ -64,6 +64,7 @@ public function update($previousVersion) {
public function addHeaders($page) {
if (!$this->addedHeaders) {
+ $page->addStylesheetToHead(URL . '/extensions/bilinkfield/assets/publish.css', 'screen', 123269781);
$page->addScriptToHead(URL . '/extensions/bilinkfield/assets/publish.js', 123269781);
$this->addedHeaders = true;
View
92 fields/field.bilink.php
@@ -216,7 +216,7 @@ public function displaySettingsPanel(&$wrapper, $errors = null) {
$group->appendChild($label);
// Column Mode --------------------------------------------------------
-
+
$label = Widget::Label(__('Column Mode'));
$label->appendChild(Widget::Select(
@@ -231,7 +231,10 @@ public function displaySettingsPanel(&$wrapper, $errors = null) {
$wrapper->appendChild($group);
// Allow Editing -----------------------------------------------------
-
+
+ $compact = new XMLElement('div');
+ $compact->setAttribute('class', 'compact');
+
$label = Widget::Label();
$input = Widget::Input(
"fields[{$order}][allow_editing]", 'yes', 'checkbox'
@@ -240,7 +243,7 @@ public function displaySettingsPanel(&$wrapper, $errors = null) {
if ($this->get('allow_editing') == 'yes') $input->setAttribute('checked', 'checked');
$label->setValue($input->generate() . ' ' . __('Allow editing of linked entries'));
- $wrapper->appendChild($label);
+ $compact->appendChild($label);
// Allow Multiple -----------------------------------------------------
@@ -252,9 +255,11 @@ public function displaySettingsPanel(&$wrapper, $errors = null) {
if ($this->get('allow_multiple') == 'yes') $input->setAttribute('checked', 'checked');
$label->setValue($input->generate() . ' ' . __('Allow selection of multiple options'));
- $wrapper->appendChild($label);
- $this->appendShowColumnCheckbox($wrapper);
- $this->appendRequiredCheckbox($wrapper);
+ $compact->appendChild($label);
+ $this->appendRequiredCheckbox($compact);
+ $this->appendShowColumnCheckbox($compact);
+
+ $wrapper->appendChild($compact);
}
public function commit() {
@@ -428,7 +433,7 @@ public function displayPublishPanel(&$wrapper, $data = null, $error = null, $pre
}
else {
- $label = new XMLElement('h3', $this->get('label'));
+ $label = new XMLElement('p', $this->get('label'));
$label->setAttribute('class', 'label');
$wrapper->appendChild($label);
@@ -584,77 +589,90 @@ public function checkPostFieldData($data, &$error = null, $entry_id = null) {
$field = $fieldManager->fetch($this->get('linked_field_id'));
$field_id = $this->get('id');
$status = self::__OK__;
-
+ $handled_entries = array();
+
self::$errors[$field_id] = array();
self::$entries[$field_id] = array();
-
+
// Create:
foreach ($data['entry'] as $index => $entry_data) {
- $existing_id = (integer)$data['entry_id'][$index];
-
- if ($existing_id <= 0) {
- if ($this->_engine->Author) {
- $author_id = $this->_engine->Author->get('id');
- }
-
- else {
- $author_id = '1';
+ $existing_id = null;
+
+ // Find existing entry:
+ if ((integer)$data['entry_id'][$index] > 0) {
+ $entries = $entryManager->fetch(
+ (integer)$data['entry_id'][$index],
+ $this->get('linked_section_id')
+ );
+
+ if (isset($entries[0])) {
+ $entry = $entries[0];
+ $existing_id = $entry->get('id');
}
-
+ }
+
+ // Skip duplicate entries:
+ if ($existing_id != null && in_array($existing_id, $handled_entries)) {
+ continue;
+ }
+
+ // Create a new entry:
+ if ($existing_id == null) {
$entry = $entryManager->create();
$entry->set('section_id', $this->get('linked_section_id'));
- $entry->set('author_id', $author_id);
+ $entry->set('author_id', (
+ isset(Symphony::Engine()->Author)
+ ? Symphony::Engine()->Author->get('id')
+ : 1
+ ));
$entry->set('creation_date', DateTimeObj::get('Y-m-d H:i:s'));
$entry->set('creation_date_gmt', DateTimeObj::getGMT('Y-m-d H:i:s'));
$entry->assignEntryId();
}
-
- else {
- $entry = @current($entryManager->fetch($existing_id, $this->get('linked_section_id')));
- }
-
+
// Append correct linked data:
$existing_data = $entry->getData($this->get('linked_field_id'));
$existing_entries = array();
-
+
if (isset($existing_data['linked_entry_id'])) {
if (!is_array($existing_data['linked_entry_id'])) {
$existing_entries[] = $existing_data['linked_entry_id'];
}
-
+
else foreach ($existing_data['linked_entry_id'] as $linked_entry_id) {
$existing_entries[] = $linked_entry_id;
}
}
-
+
if (!in_array($entry_id, $existing_entries)) {
$existing_entries[] = $entry_id;
}
-
+
$entry_data[$field->get('element_name')] = $existing_entries;
-
+
// Validate:
if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($entry_data, $errors)) {
self::$errors[$field_id][$index] = $errors;
$status = self::__INVALID_FIELDS__;
}
-
+
if (__ENTRY_OK__ != $entry->setDataFromPost($entry_data, $error)) {
$status = self::__INVALID_FIELDS__;
}
-
+
// Cleanup dud entry:
- if ($existing_id == 0 and $status != self::__OK__) {
+ if ($existing_id == null and $status != self::__OK__) {
$existing_id = $entry->get('id');
$entry->set('id', 0);
Symphony::Database()->delete('tbl_entries', " `id` = '$existing_id' ");
}
-
+
self::$entries[$field_id][$index] = $entry;
+ $handled_entries[] = $entry->get('id');
}
-
+
return $status;
}
@@ -680,9 +698,9 @@ public function processRawFieldData($data, &$status, $simulate = false, $entry_i
$new_data[] = $entry->get('id');
}
- $data = $new_data;
+ $data = array_unique($new_data);
}
-
+
if (empty($data)) {
return null;
}
View
14 readme.md
@@ -0,0 +1,14 @@
+# Field: Bi-Link
+
+__Version:__ 1.1.0
+__Author:__ Rowan Lewis <me@rowanlewis.com>
+__Build Date:__ 3 March 2011
+__Requirements:__ Symphony 2.2
+
+## Installation
+
+1. Upload the 'bilinkfield' folder in this archive to your Symphony 'extensions' folder.
+
+2. Enable it by selecting the "Field: Bi-Link", choose Enable from the with-selected menu, then click Apply.
+
+3. Go to each section you want to link and add the "Bi-Link" field.
View
22 readme.txt
@@ -1,22 +0,0 @@
-Field: Bi-Link
--------------------------------------------------------------------------------
-
-Version: 1.0.13
-Author: Rowan Lewis <rowan@pixelcarnage.com>
-Build Date: 7 July 2009
-Requirements: Symphony 2.0.2
-
-
-Installation
--------------------------------------------------------------------------------
-
-1. Upload the 'bilinkfield' folder in this archive to your Symphony
- 'extensions' folder.
-
-2. Enable it by selecting the "Field: Bi-Link", choose Enable from the
- with-selected menu, then click Apply.
-
-3. Go to each section you want to link and add the "Bi-Link" field.
-
-4. From one of the sections choose the section you want to link to from the
- select box, and save.
Please sign in to comment.
Something went wrong with that request. Please try again.