Coder Social home page Coder Social logo

dataobjectmanager's People

Contributors

alexhayes avatar camspiers avatar dhensby avatar dospuntocero avatar drzax avatar hdrlab avatar jamesbolitho avatar jmwohl avatar jonasaleknavicius avatar jonom avatar juanitou avatar kalakotra avatar mattclegg avatar powtac avatar simonexmachina avatar steffen-maass avatar streamflyer avatar tractorcow avatar undefinedoffset avatar willmorgan avatar zauberfisch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dataobjectmanager's Issues

Fatal Error on ManyMany DOM

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

Problem with filtering subclassed DataObjects

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))."%'";

Issues with setUploadFolder and Uploadify

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.

DOM isn't always aware that a DataObject is sortable

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.

Default Filter

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.

Memory Issue with Sortable DataObject Decorator

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.

Sorting DOM entries

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'

SS Framework help. I know this is the wrong place to ask. Sorry

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)

  1. I'm trying to override the Security templates. In SS3 we just used Secuirty_login.ss etc. But in SS4 this does not work.
  2. I need to redirect users based on their permission group. How would I do this, currently Administrators goto /admin but other users it just reloads the login page. I need the users to be redirected to the homepage. I've tried using
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

Bug in of ListField HasManyDataObjectManager

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))

Create Readme

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

Bugfix: Nested Popup not centering in FF and Chrome

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 = $.fn.DataObjectManager.getPageScroll()[1] + ($.fn.DataObjectManager.getPageHeight() / 10);

Suggestion:
var top = $.fn.DataObjectManager.getPageScroll()[1] + ($.fn.DataObjectManager.getPageHeight() / 10);

Regards,
Remy Vaartjes

ManyManyDataObjectManager Join ambiguous error

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')";

Tag releases.

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.

DataObjectManager pop up does not open in a separate window.

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;

SimpleTinyMCEField button config array

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);
}

Bugfix: Nested Popup uses missing cms javascript classes

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

Variable $Attachment.Title doesn't work…

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)

FLV.php's "Player"-method: allowscriptaccess

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 ;)

SimpleTreeDropdownField

The SimpleTreeDropdownField only shows pages in the main language not the current viewed language.

DataObjectManager class doesn't respect permissions of individual objects

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.

Patch: Update FilteredDropdownSet so that returnLabel can also be a method instead of a field.

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);
    
    --
    1.7.7.GIT

SQL Error Produced by ManyManyFileDataObjectManager

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?).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.