unclecheese / dataobjectmanager Goto Github PK
View Code? Open in Web Editor NEWDataObjectManager module for Silverstripe CMS
DataObjectManager module for Silverstripe CMS
i tried to fix this but after looking in the 3 classes i didnt find the bug... :(
After you use anything that calles the ajax method, you cant uncheck any boxes.
The SimpleTreeDropdownField only shows pages in the main language not the current viewed language.
The live drop down widget does not respect the current locale, instead using the default one
I needed to use a FilteredDropdownSet, but the label in the dependent dropdown box came from a method (e.g., getFullName()) instead of a single database field. This required a small modification to the FilteredDropdownSet. I think that this might be useful for others too.
The change is too small for me to bother forking the project and sending a pull request, so here's the patch:
code/dropdown_fields/FilteredDropdownSet.php | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/code/dropdown_fields/FilteredDropdownSet.php b/code/dropdown_fields/FilteredDropdownSet.php
index 09da7dd..64267e6 100755
--- a/code/dropdown_fields/FilteredDropdownSet.php
+++ b/code/dropdown_fields/FilteredDropdownSet.php
@@ -52,7 +52,9 @@ class FilteredDropdownSet extends FieldGroup {
$results = DataObject::get($this->sourceClass, $filter);
if($results) {
foreach($results as $r) {
$ret[$r->{$this->returnKey}] = $r->{$this->returnLabel};
$ret[$r->{$this->returnKey}] =
($r->hasMethod($this->returnLabel) ?
$r->{$this->returnLabel}(): $r->{$this->returnLabel});
}
}
return Convert::array2json($ret);
When viewing items in a ManyManyFileDataObjectManager the module will often fail to load items from the database.
DOM can produce invalid SQL during ajax calls which crashes the module and returns an error.
... ORDER BY ""
I've tracked this down to the following lines of PHP in ManyManyFileDataObjectManager.php. This error occurs when the [sort] querystring parameter is given, but empty (lines 96, 97)
} elseif (isset($_REQUEST['ctf'][$this->Name()]['sort'])) {
$this->sourceSort = "\"" . $_REQUEST['ctf'][$this->Name()]['sort'] . "\" " . $this->sort_dir;
}
I find this code a little odd, considering that the next line has the same condition, yet checkes for empty() on the querystring result.
I'm not certain if this condition should be removed, or an additional condition should be added to the elsif (perhaps checking to see if the requested sort column name contains whitespace characters?).
There is no spinner for when the request is being made to search for what a user has typed, this makes for a bad UI experience
When using a dropdown filter on a DOM instance ($dom->setFilter()) if you choose to set a default value this value is used for EVERY subsequent query.
ie: if I set to filter my object by Colour = Blue as default and then change the filter in the CMS to red, the subsequent query that is generated is Colour = Blue AND Colour = Red.
There needs to be some separation of the default filter and subsequent ones.
It would be great if release versions of the codebase were tagged so we can have some confidence we're not upgrading to broken code and can manage compatibility with older SS installs.
when the top is used it actually returns the [object Window] and the popup doesn't open in the correct location.
There is nothing being done with the $config array for the buttons passed to the constructor. It's missing $this->set_default_buttons($config);
function __construct($name, $title = null, $config = array(), $rows = 15, $cols = 55, $value = "", $form = null)
{
parent::__construct($name, $title, $rows, $cols, $value, $form);
$this->set_default_buttons($config);
}
allowscriptaccess is currently always being set to "true" (on line #251).
Quote from Adobe.com:
The AllowScriptAccess parameter can have one of three possible values: "always," "sameDomain," or "never:"
Thus, "true" is invalid. I suggest changing this to "sameDomain" by default. I don't have Git installed, otherwise I'd do it myself and not bother you with it. Sorry ;)
Hi,
I am using 2,4 version. The problem is that DOM pop up opens in the same page. Not in a separate page.
$f = parent::getCMSFields();
$manager = new ImageDataObjectManager(
$this, // Controller
'Images', // Source name
'ImageResource', // Source class
'Attachment', // File name on DataObject
array(
'Title' => 'Title',
'Caption' => 'Caption'
),
'getCMSFields_forPopup'
);
$f->addFieldToTab("Root.Content.Gallery",$manager);
return $f;
When getting selected IDs on ManyManyDOM a fatal error is thrown.
see: 1051f2d#commitcomment-855046
When one does this:
SELECT Field AS RenamedField FROM Table WHERE .... LIMIT x;
The alias (RenamedField in this case) can't be used to filter in the WHERE clause (as I understand it), and this would throw an error saying that the field 'RenamedField' doesn't exist, which is exactly what is happening in ManyManyDOM
Hi ya,
This is completely the wrong place to ask a question but I'm pretty desperate (3 days trying to work out my issue)
Silverstripe\Security:
- default_login_dest: '/home'
in my mysite.yml but it does nothing. What am I doing wrong?
I'm happy to pay for your time as I've been trying to work this out for 3 days grrrrr
Thank you for all your hard work and have a great Friday
I've been tracing a memory leak for some time and have finally tracked it down to the onBeforeWrite method of the SortableDataObject decorate. The symptom I saw was not being able to save a single Image due to memory constraints, and the memory jumping from 29M to > 128M when saving the Image.
The culprit is here
public function onBeforeWrite()
{
if(!$this->owner->ID) {
if($peers = DataObject::get($this->owner->class))
$this->owner->SortOrder = $peers->Count()+1;
}
}
}
The line
if($peers = DataObject::get($this->owner->class))
is loading all of the DataObjects of a particular class, e.g. Image, into memory, counting them, and setting the SortOrder to be one more than the maximum.
As a site gets bigger this will result in more memory being used when saving an object of a given class, eventually resulting in a memory leak preventing objects being saved.
In short, the number of objects of a given DataObject class are effectively limited by the amount of RAM allocated to the PHP process.
DataObjects can have the SortableDataObject decorator applied in a few different ways, e.g.
Within the class:
static $extensions = array('SortableDataObject');
or, in config.php:
SortableDataObject::add_sortable_class('ClassName');
When the first method above is used, DOM doesn't seem to know the DataObject is sortable.
When use the ManyManyDataObjectManager and add a join clause it can occur an ambigous mysql error.
To prevent this error, change Line 63 in code/ManyManyDataObjectManager.php
From:
$this->sourceJoin .= " LEFT JOIN "$manyManyTable" ON ("$source"."ID" = "{$sourceField}ID" AND "$manyManyTable"."{$this->manyManyParentClass}ID" = '$parentID')";
To:
$this->sourceJoin .= " LEFT JOIN "$manyManyTable" ON ("$source"."ID" = "$manyManyTable"."{$sourceField}ID" AND "$manyManyTable"."{$this->manyManyParentClass}ID" = '$parentID')";
Variable $Attachment.Title doesn't work on current Master (when uploading files with todays version)… but it does in Master from a month ago -.-
(Tested on clean install of SS 2.4.8 and SS 2.4.9, included Uploadify)
The DataObjectManager class will show edit & delete links for objects based on a global permission, ignoring whether any items would return false for canEdit() or canDelete(). For example, let's say that someone added fine-grained permissions to files in the assets folders. These permissions would simply be ignored.
NOTE: The underlying ComplexTableField has the same problem.
If you want to display a field of the related object "MyHasOneRelatedObject.Title", it does not work.
Solution:
HasManyDataObjectManager (~ line 76)
if(! $SNG->hasField($k) && ! $SNG->hasMethod('get' . $k))
must be changed in
if($SNG->hasField($k) && ! $SNG->hasMethod('get' . $k))
The quick search function on a DataObjectManager cannot search within fields on the dataobject's parent class (if, of course, it is subclassed).
Given a pair of dataobject classes arranged as such, attempting to search by the single summary field will cause a SQL error and will not filter the grid.
(Summarised code)
class Category extends DataObject {
static $db = array('FullName' => 'Varchar(512)');
static $summary_fields = array('FullName');
}
class ProductCategory extends Category {
static $belongs_many_many = array('Products' => 'ProductPage');
}
class ProductPage extends Page {
static $many_many = array('ProductCategories' => 'ProductCategory');
}
A DataObjectManager managing a product's categories will successfully load all categories, but searching using the quicksearch will cause the following SQL exception:
Unknown column 'ProductCategory.FullName' in 'where clause'
I have tracked this issue down to lines 237 - 240 of DataObjectManager.php
foreach(parent::Headings() as $field) {
if($SNG->hasDatabaseField($field->Name))
$search[] = "UPPER({$this->sourceClass}.$field->Name) LIKE '%".Convert::raw2sql(strtoupper($this->search))."%'";
}
It seems as though it is treating all summary fields as though they are direct members of the managed class type, without considering that they may in fact be inherited fields. I've confirmed that replacing the SQL string line to remove the table selector fixes the error, but I haven't tested it well; Ideally the code would find the correct table name to prevent any potential "ambiguous column" errors.
$search[] = "UPPER($field->Name) LIKE '%".Convert::raw2sql(strtoupper($this->search))."%'";
It should be possible to disable the CSV export option in the interface.
Using: SS 2.4.7
When using nested popup, it calls TableListField Class in the popup below the nested one.
This is causing errors since these classes are not included in the popup.
Maybe not elegant but it works if this is added to the of DataObjectManager_popup.ss:
<script type="text/javascript" src="{$BaseHref}assets/_combinedfiles/base.js"></script> <script type="text/javascript" src="{$BaseHref}sapphire/javascript/TableListField.js"></script>Regards,
Remy Vaartjes
I have a DataObject that I specify a custom folder for uploads (based on the DataObject's Title), I've noticed that when I upload files using uploadify it uses the correct folder however when it passes over to the DOM it seems to recreate the the custom folder under assets/assets/customFolder and place a copy of the file in there.
The DOM module seems to be looking for and setting 'sort_dir' parameters in URL strings, etc.
This is causing the sort dir to be ignored by the getQuery function in TableListField
Not sure why sort_dir is being used, but either DOM needs to extend getQuery and override this or start using 'dir'
Hi Aaron,
I noticed the nested popup is not centering properly in Firefox and Chrome.
It seems line 40 of dataobject_manager.js simply misses 'var'
Current:
top =
Suggestion:
var top =
Regards,
Remy Vaartjes
Write a readme
BPower BTW, UncleCheese, you're missing a readme: https://github.com/unclecheese/DataObjectManager
UncleCheese BTW, it's missing any semblance of coherent, well-architected code.
UncleCheese put in a ticket
BPower haha
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.