public function addContextMenu(array $menu)
    {
        foreach ($menu as &$item) {
            if (!\is_array($item) || !isset($item['title'])) {
                throw new InvalidArgumentException('Invalid structure. Example: [ [\'title\' => \'TEST\', \'href\' => \'http://www.google.com\', \'popup\' => \'true\', \'confirm\' => \'true\'] ,  [..] , ...]');
            }
        }
        unset($item);

        foreach ($menu as $menu_key => &$item) {
            if (!isset($item['js'])) {
                $item['js'] = '';
            }
            if (!isset($item['href'])) {
                $item['href'] = '';
            }
            if (!isset($item['popup'])) {
                $item['popup'] = false;
            }

            if (!isset($item['confirm'])) {
                $item['confirm'] = false;
            }

            foreach ($item as $item_key => $item_value) {
                $item[$item_key] = str_replace(["'", '"'], ["\'", ''], $item[$item_key]);
            }

            // Bool to int for javascript
            $item['confirm'] = (int)$item['confirm'];
            $item['popup'] = (int)$item['popup'];

            $this->context_menu_items[] = $item;

        }

        return $this;
    }
public function addContextMenu(array $menu)
    {
        foreach ($menu as &$item) {
            if (!\is_array($item) || !isset($item['title'])) {
                throw new InvalidArgumentException('Invalid structure. Example: [ [\'title\' => \'TEST\', \'href\' => \'http://www.google.com\', \'popup\' => \'true\', \'confirm\' => \'true\'] ,  [..] , ...]');
            }
        }
        unset($item);

        foreach ($menu as $menu_key => &$item) {
            if (!isset($item['js'])) {
                $item['js'] = '';
            }
            if (!isset($item['href'])) {
                $item['href'] = '';
            }
            if (!isset($item['popup'])) {
                $item['popup'] = false;
            }

            if (!isset($item['confirm'])) {
                $item['confirm'] = false;
            }

            foreach ($item as $item_key => $item_value) {
                $item[$item_key] = str_replace(["'", '"'], ["\'", ''], $item[$item_key]);
            }

            // Bool to int for javascript
            $item['confirm'] = (int)$item['confirm'];
            $item['popup'] = (int)$item['popup'];

            $this->context_menu_items[] = $item;

        }

        return $this;
    }
public function addContextMenu ( array $ menu ) { foreach ( $ menu as & $ item ) { if ( ! \ is_array ( $ item ) || ! isset ( $ item [ 'title' ] ) ) { throw new InvalidArgumentException ( 'Invalid structure. Example: [ [\'title\' => \'TEST\', \'href\' => \'http://www.google.com\', \'popup\' => \'true\', \'confirm\' => \'true\'] ,  [..] , ...]' ) ; } } unset ( $ item ) ; foreach ( $ menu as $ menu_key => & $ item ) { if ( ! isset ( $ item [ 'js' ] ) ) { $ item [ 'js' ] = '' ; } if ( ! isset ( $ item [ 'href' ] ) ) { $ item [ 'href' ] = '' ; } if ( ! isset ( $ item [ 'popup' ] ) ) { $ item [ 'popup' ] = false ; } if ( ! isset ( $ item [ 'confirm' ] ) ) { $ item [ 'confirm' ] = false ; } foreach ( $ item as $ item_key => $ item_value ) { $ item [ $ item_key ] = str_replace ( [ "'" , '"' ] , [ "\'" , '' ] , $ item [ $ item_key ] ) ; } // Bool to int for javascript $ item [ 'confirm' ] = ( int ) $ item [ 'confirm' ] ; $ item [ 'popup' ] = ( int ) $ item [ 'popup' ] ; $ this -> context_menu_items [ ] = $ item ; } return $ this ; }
context menu for table rows, with dynamic parameters
@param array $menu array( array('title' => 'TEST', 'confirm' => true // not obligate //, 'popup' => true // not obligate //, 'href' => 'http://www.google.com', 'js' => 'alert();') ,  array(..) , ...)
@return $this
@throws \InvalidArgumentException
context menu for table rows with dynamic parameters