GithubHelp home page GithubHelp logo

stefangabos / zebra_mptt Goto Github PK

View Code? Open in Web Editor NEW
80.0 12.0 29.0 208 KB

A PHP library providing an implementation of the modified preorder tree traversal (MPTT) algorithm

Home Page: https://stefangabos.github.io/Zebra_Mptt/Zebra_Mptt/Zebra_Mptt.html

License: Other

PHP 100.00%
mptt php php-mptt algorithms tree-traversal

zebra_mptt's Introduction

Hi there ๐Ÿ‘‹

I am Stefan Gabos, a web developer working from Bucharest, Romania. I'm half Hungarian, stubborn, articulate, and slightly afraid of women.

I started coding when I was around 14 (that's way back in 1994), and I am extremely passionate about it. I started coding in BASIC and then went on with Assembler and Turbo Pascal. In 1997 I started developing commercial applications using Microsoft Access. Since 2001 I'm developing exclusively for the web using PHP, MySQL, HTML, CSS and JavaScript.

I am an incurable workaholic and a perfectionist. I work with PHP, MySQL, HTML and CSS and JavaScript and have been using these things since back when GeoCities was the most visited website on the Internet and the <blink> tag was cool. I am among the 6 people in the world who were never afraid of Internet Explorer 6.

I develop rock-solid PHP libraries and super-lightweight, highly optimized, bad-ass jQuery plugins and open-source them because I am a web developer even when I'm not at work.

When working, I listen to massive amounts of music โ€“ alternative rock, in general. When I am not working (it sometimes happens), I enjoy playing the guitar, sleeping, cooking, watching Formula One or a good movie.

zebra_mptt's People

Contributors

cranesandcaff avatar dominikfiala avatar erlingormar avatar jamesshaver avatar stefangabos 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

zebra_mptt's Issues

Bug when moving nodes

So I found the following bug: When you move a node on a tree where the parent column isn't named "parent", you will get an error. I also found the solution: It ddoesn't work because of this line: (Line 1089)

$target_parent = $target == 0 ? 0 : $this->lookup[$target]['parent'];

As you can see, it uses "parent" as key in an array, which won't work if your column is for example named parent_index, because than the key in that array would also be called parent_index. If you change that line to the following, it works:

$target_parent = $target == 0 ? 0 : $this->lookup[$target][$this->properties['parent_column']];

get_previous_siblings return incorrect information

the line 949 of Zebra_Mptt.php has an error at the time of returning the siblings , the previous and next functions are identical, I change it to the following line and it works

// get previous node
$siblings = array_slice($siblings, $node_position - 1, 1);

Composer install problems - require mysql

There isn't a mysql composer package which is causing the composer install to not work. I think if you removed the requirement composer would be able to install the package.

Problem 1
- Installation request for stefangabos/zebra_mptt 2.2.5 -> satisfiable by stefangabos/zebra_mptt[2.2.5].
- stefangabos/zebra_mptt 2.2.5 requires mysql >=4.1.22 -> no matching package found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Adding to the top level

Hello,

if i am adding node to top level (without parent), calculation of left and right values is bad. But not for first time. It hapends if you add root, some nodes under root and then you add another node without parent. In this case the values are bad. I suggest add something like this after line 188

`if ($boundary === 0) {

INSERT INTO tree (lft, rgt, title) SELECT IFNULL(MAX(rgt), 0) + 1, IFNULL(MAX(rgt), 0) + 2, title FROM tree
}`

Problem with "before" / "after" options

There is an issue with MOVE function.

I have a very simple category list - no children, just something like this:

[1] TV
[2] Apple
[3] Samsung
[4] Sony
[5] LG
[6] Huawei

When I'm trying to do: move(5,3, 'before') or move(5,2, 'after) I receive error:

**Warning**:  array_keys() expects parameter 1 to be array, boolean given in **zebra_mptt/zebra_mptt.php** on line **1095**
**Warning**:  array_search() expects parameter 2 to be array, null given in **zebra_mptt/zebra_mptt.php** on line **1096**

I'm using PHP 7.2.

When I do simple move(6,3) without before / after - everything is fine. Only before / after commands are making this warning, and the script doesn't work properly.

Is Zebra_Mptt still maintained?

function move error

follow the example, the result in database is error.

$orange = $mptt->move($orange, $red, 'after');

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.