ezsystems / eztags

GNU General Public License v2.0
40 stars 40 forks source link

Added tags re-ordering support #77

Closed thiagocamposviana closed 10 years ago

thiagocamposviana commented 10 years ago

Last time I checked eZTagsObject::fetchList( ) receives one array of object ids, but the array returned will not follow the objects id order we have passed, this is why I fetch one by one.

emodric commented 10 years ago

I don't get it, you can still use something like this, right?

https://gist.github.com/emodric/51d11c8f92ff0a1fc648

eddie@abyss: ~ $ php sort_test.php
array(4) {
  [0] =>
  class Test#4 (1) {
    public $id =>
    int(2)
  }
  [1] =>
  class Test#2 (1) {
    public $id =>
    int(4)
  }
  [2] =>
  class Test#5 (1) {
    public $id =>
    int(7)
  }
  [3] =>
  class Test#3 (1) {
    public $id =>
    int(13)
  }
}
thiagocamposviana commented 10 years ago

Let me try something

thiagocamposviana commented 10 years ago

Fixed, now looks like this:

function tags()
{
    if ( !is_array( $this->IDArray ) || empty( $this->IDArray ) )
        return array();

    $eztags = array();
    foreach( eZTagsObject::fetchList( array( 'id' => array( $this->IDArray ) ) ) as $item)
    {
        $eztags[array_search($item->attribute('id'), $this->IDArray)] = $item;
    }
    ksort($eztags);
    if(count($eztags) > 0)
        return $eztags;

    return null;
}

thiagocamposviana commented 10 years ago

I have fixed the code, for the js file I completely replaced \t (tabs) with 4 white spaces ( ), and also removed trailing spaces.

emodric commented 10 years ago

Hi @thiagocamposviana

I have just two more comments and then I'm merging this :)

emodric commented 10 years ago

OK, this is now good :) Give me some more time to test this again, and I'll merge it sometime tomorrow!

Great work @thiagocamposviana :+1:

emodric commented 10 years ago

Okay, I think this is ready for merging. Is there anything you wish to add @thiagocamposviana?

Also, I'm gonna try to port this to multilanguage branch. Can I ping you if I'm stuck?

emodric commented 10 years ago

I forgot to mention, can you please create a mysql upgrade script in update/database/mysql/1.4/eztags-dbupdate-1.3-to-1.4.sql?

Something like this:

ALTER TABLE `eztags_attribute_link`
ADD COLUMN `priority` int(11) NOT NULL default 0 AFTER `object_id`;
thiagocamposviana commented 10 years ago

Ok, created the upgrade sql query.

thiagocamposviana commented 10 years ago

Happy to help if needed on getting this onto the multilanguage branch!

emodric commented 10 years ago

Thanks @thiagocamposviana, merging it now!