text:
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * @package PhpMyAdmin-Designer
 */

/**
 * init
 */

var _change = 0; // variable to track any change in designer layout.
var _staying = 0; //  variable to check if the user stayed after seeing the confirmation prompt.
var show_relation_lines = true;

AJAX.registerTeardown('pmd/move.js', function () {
    if ($.FullScreen.supported) {
        $(document).unbind($.FullScreen.prefix + 'fullscreenchange');
    }
});

AJAX.registerOnload('pmd/move.js', function () {
    $('#page_content').css({'margin-left': '3px'});
    $('#exitFullscreen').hide();
    if ($.FullScreen.supported) {
        $(document).fullScreenChange(function () {
            if (!$.FullScreen.isFullScreen()) {
                $('#page_content').removeClass('content_fullscreen')
                    .css({'width': 'auto', 'height': 'auto'});
                $('#enterFullscreen').show();
                $('#exitFullscreen').hide();
                Top_menu_reposition($('#key_Left_Right')[0]);
            }
        });
    } else {
        $('#enterFullscreen').hide();
    }
});

// Below is the function to bind onbeforeunload events with the content_frame as well as the top window.

/*
 FIXME: we can't register the beforeonload event because it will persist between pageloads

 AJAX.registerOnload('pmd/move.js', function(){
 $(window).bind('beforeunload', function() {        // onbeforeunload for the frame window.
 if (_change == 1 && _staying == 0) {
 return PMA_messages['strLeavingDesigner'];
 } else if (_change == 1 && _staying == 1) {
 _staying = 0;
 }
 });
 $(window).unload(function() {
 _change = 0;
 });
 window.top.onbeforeunload = function() {     // onbeforeunload for the browser main window.
 if (_change == 1 && _staying == 0) {
 _staying = 1;                                                   //  Helps if the user stays on the page  as there
 setTimeout('make_zero();', 100);                    //   is no other way of knowing whether the user stayed or not.
 return PMA_messages['strLeavingDesigner'];
 }
 };
 });*/

function make_zero() {   // Function called if the user stays after seeing the confirmation prompt.
    _staying = 0;
}

var dx, dy, dy2;
var cur_click;
// update in Main()
var sm_x = 2, sm_y = 2;
var sm_s = 0;
var sm_add = 10;
var s_left = 0;
var s_right = 0;
var ON_relation = 0;
var ON_grid = 0;
var ON_display_field = 0;
// relation_style: 0 - angular 1 - direct
var ON_angular_direct = 1;
var click_field = 0;
var link_relation = "";
var id_hint;
var canvas_width = 0;
var canvas_height = 0;
var osn_tab_width = 0;
var osn_tab_height = 0;
var height_field = 7;
var Glob_X, Glob_Y;
var timeoutID;
var layer_menu_cur_click = 0;
var step = 10;
var old_class;
var from_array = [];
var downer;

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

//window.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
//---CROSS
document.onmousedown = MouseDown;
document.onmouseup = MouseUp;
document.onmousemove = MouseMove;

var isIE = document.all && !window.opera;
var isNN = !document.all && document.getElementById;
var isN4 = document.layers;

if (isIE) {
    window.onscroll = General_scroll;
    document.onselectstart = function () {
        return false;
    };
}

//document.onmouseup = function(){General_scroll_end();}
function MouseDown(e) {
    var offsetx, offsety;
    if (cur_click != null) {
        offsetx = isIE ? event.clientX + document.body.scrollLeft : e.pageX;
        offsety = isIE ? event.clientY + document.body.scrollTop : e.pageY;
        dx = offsetx - parseInt(cur_click.style.left);
        dy = offsety - parseInt(cur_click.style.top);
        //alert(" dx = " + dx + " dy = " +dy);
        document.getElementById("canvas").style.display = 'none';
        /*
         var left = parseInt(cur_click.style.left);
         var top  = parseInt(cur_click.style.top);
         dx = e.pageX - left;
         dy = e.pageY - top;

         alert(" dx = " + dx + " dy = " +dy);
         */
        cur_click.style.zIndex = 2;
    }
    if (layer_menu_cur_click) {
        offsetx = e.pageX;
        dx = offsetx - parseInt(document.getElementById("layer_menu").style.width);
    }
}

function MouseMove(e) {
    //Glob_X = e.pageX;
    //Glob_Y = e.pageY;
    Glob_X = isIE ? event.clientX + document.body.scrollLeft : e.pageX;
    Glob_Y = isIE ? event.clientY + document.body.scrollTop : e.pageY;

    //mouseX = (bw.ns4||bw.ns6)? e.pageX: bw.ie&&bw.win&&!bw.ie4? (event.clientX-2)+document.body.scrollLeft : event.clientX+document.body.scrollLeft;
    //mouseY = (bw.ns4||bw.ns6)? e.pageY: bw.ie&&bw.win&&!bw.ie4? (event.clientY-2)+document.body.scrollTop : event.clientY+document.body.scrollTop;

    //window.status = "X = "+ Glob_X + " Y = "+ Glob_Y;

    if (cur_click != null) {
        _change = 1;
        var mGx = Glob_X - dx;
        var mGy = Glob_Y - dy;
        mGx = mGx > 0 ? mGx : 0;
        mGy = mGy > 0 ? mGy : 0;

        if (ON_grid) {
            mGx = mGx % step < step / 2 ? mGx - mGx % step : mGx - mGx % step + step;
            mGy = mGy % step < step / 2 ? mGy - mGy % step : mGy - mGy % step + step;
        }

        cur_click.style.left = mGx + 'px';
        cur_click.style.top = mGy + 'px';
    }

    if (ON_relation || ON_display_field) {
        document.getElementById('pmd_hint').style.left = (Glob_X + 20) + 'px';
        document.getElementById('pmd_hint').style.top = (Glob_Y + 20) + 'px';
    }

    if (layer_menu_cur_click) {
        document.getElementById("layer_menu").style.width = ((Glob_X - dx) >= 150 ? Glob_X - dx : 150) + 'px';
        //document.getElementById("layer_menu").style.height = Glob_Y - dy>=200?Glob_Y - dy:200;
        //document.getElementById("id_scroll_tab").style.height = Glob_Y - dy2;
    }
}

function MouseUp(e) {
    if (cur_click != null) {
        document.getElementById("canvas").style.display = 'inline-block';
        Re_load();
        cur_click.style.zIndex = 1;
        cur_click = null;
    }
    layer_menu_cur_click = 0;
    //window.releaseEvents(Event.MOUSEMOVE);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

//function ToInt(s)
//{
//    return s.substring(0,s.length-2)*1; //re = /(\d+)\w*/; newstr = str.replace(re, "$1");
//}

function Canvas_pos() {
    canvas_width = document.getElementById('canvas').width = osn_tab_width - 3;
    canvas_height = document.getElementById('canvas').height = osn_tab_height - 3;

    if (isIE) {
        document.getElementById('canvas').style.width = ((osn_tab_width - 3) ? (osn_tab_width - 3) : 0) + 'px';
        document.getElementById('canvas').style.height = ((osn_tab_height - 3) ? (osn_tab_height - 3) : 0) + 'px';
    }
}

function Osn_tab_pos() {
    osn_tab_width = parseInt(document.getElementById('osn_tab').style.width);
    osn_tab_height = parseInt(document.getElementById('osn_tab').style.height);
}

function Main() {
    //alert( document.getElementById('osn_tab').offsetTop);
    //---CROSS

    document.getElementById("layer_menu").style.top = -1000 + 'px'; //fast scroll
    sm_x += document.getElementById('osn_tab').offsetLeft;
    sm_y += document.getElementById('osn_tab').offsetTop;
    Osn_tab_pos();
    Canvas_pos();
    Small_tab_refresh();
    Re_load();
    id_hint = document.getElementById('pmd_hint');
    if (isIE) {
        General_scroll();
    }
}

//-------------------------------- new -----------------------------------------
function Rezize_osn_tab() {
    var max_X = 0;
    var max_Y = 0;
    for (var key in j_tabs) {
        var k_x = parseInt(document.getElementById(key).style.left) + document.getElementById(key).offsetWidth;
        var k_y = parseInt(document.getElementById(key).style.top) + document.getElementById(key).offsetHeight;
        max_X = max_X < k_x ? k_x : max_X;
        max_Y = max_Y < k_y ? k_y : max_Y;
    }

    osn_tab_width = max_X + 50;
    osn_tab_height = max_Y + 50;
    Canvas_pos();
    document.getElementById('osn_tab').style.width = osn_tab_width + 'px';
    document.getElementById('osn_tab').style.height = osn_tab_height + 'px';
}
//------------------------------------------------------------------------------

/**
 * refreshes display, must be called after state changes
 */
function Re_load() {
    Rezize_osn_tab();
    var n;
    var x1;
    var x2;
    var a = [];
    var K;
    var key;
    var key2;
    var key3;
    Clear();
    for (K in contr) {
        for (key in contr[K]) {
            // contr name
            for (key2 in contr[K][key]) {
                // table name
                for (key3 in contr[K][key][key2]) {
                    // field name
                    if (!document.getElementById("check_vis_" + key2).checked || !document.getElementById("check_vis_" + contr[K][key][key2][key3][0]).checked) {
                        // if hide
                        continue;
                    }
                    var x1_left = document.getElementById(key2).offsetLeft + 1;
                    var x1_right = x1_left + document.getElementById(key2).offsetWidth;
                    var x2_left = document.getElementById(contr[K][key][key2][key3][0]).offsetLeft;
                    var x2_right = x2_left + document.getElementById(contr[K][key][key2][key3][0]).offsetWidth;
                    a[0] = Math.abs(x1_left - x2_left);
                    a[1] = Math.abs(x1_left - x2_right);
                    a[2] = Math.abs(x1_right - x2_left);
                    a[3] = Math.abs(x1_right - x2_right);
                    n = s_left = s_right = 0;
                    for (var i = 1; i < 4; i++) {
                        if (a[n] > a[i]) {
                            n = i;
                        }
                    }
                    if (n == 1) {
                        x1 = x1_left - sm_s;
                        x2 = x2_right + sm_s;
                        if (x1 < x2) {
                            n = 0;
                        }
                    }
                    if (n == 2) {
                        x1 = x1_right + sm_s;
                        x2 = x2_left - sm_s;
                        if (x1 > x2) {
                            n = 0;
                        }
                    }
                    if (n == 3) {
                        x1 = x1_right + sm_s;
                        x2 = x2_right + sm_s;
                        s_right = 1;
                    }
                    if (n == 0) {
                        x1 = x1_left - sm_s;
                        x2 = x2_left - sm_s;
                        s_left = 1;
                    }
                    //alert(key2 + "." + key3);

                    var row_offset_top = 0;
                    //alert('id_tbody_' + key2);
                    //alert(document.getElementById('id_hide_tbody_' + key2));
                    var tab_hide_button = document.getElementById('id_hide_tbody_' + key2);

                    //alert(tab_hide_button.innerHTML);
                    if (tab_hide_button.innerHTML == 'v') {
                        row_offset_top = document.getElementById(key2 + "." + key3).offsetTop;
                    }

                    var y1 = document.getElementById(key2).offsetTop
                        + row_offset_top
                        + height_field;
                    //alert(1);

                    row_offset_top = 0;
                    var tab_hide_button = document.getElementById('id_hide_tbody_' + contr[K][key][key2][key3][0]);
                    if (tab_hide_button.innerHTML == 'v') {
                        row_offset_top = document.getElementById(contr[K][key][key2][key3][0]
                        + '.' + contr[K][key][key2][key3][1]).offsetTop;
                    }

                    var y2 =
                        document.getElementById(contr[K][key][key2][key3][0]).offsetTop
                        + row_offset_top
                        + height_field;

                    //alert(y1 + ' - ' + key2 + "." + key3);
                    Line0(x1 - sm_x, y1 - sm_y, x2 - sm_x, y2 - sm_y, getColorByTarget(contr[K][key][key2][key3][0] + '.' + contr[K][key][key2][key3][1]));
                }
            }
        }
    }
}

/**
 * draws a line from x1:y1 to x2:y2 with color
 */
function Line(x1, y1, x2, y2, color_line) {
    var canvas = document.getElementById("canvas");
    var ctx = canvas.getContext("2d");
    ctx.strokeStyle = color_line;
    ctx.lineWidth = 1;
    ctx.beginPath();
    ctx.moveTo(x1, y1);
    ctx.lineTo(x2, y2);
    ctx.stroke();
}

/**
 * draws a relation/constraint line, whether angular or not
 */
function Line0(x1, y1, x2, y2, color_line) {
    if (!show_relation_lines) {
        return;
    }
    Circle(x1, y1, 3, 3, color_line);
    Rect(x2 - 1, y2 - 2, 4, 4, color_line);

    if (ON_angular_direct) {
        Line2(x1, y1, x2, y2, color_line);
    } else {
        Line3(x1, y1, x2, y2, color_line);
    }
}

/**
 * draws a angualr relation/constraint line
 */
function Line2(x1, y1, x2, y2, color_line) {
    var x1_ = x1;
    var x2_ = x2;

    if (s_right) {
        x1_ += sm_add;
        x2_ += sm_add;
    } else if (s_left) {
        x1_ -= sm_add;
        x2_ -= sm_add;
    } else if (x1 < x2) {
        x1_ += sm_add;
        x2_ -= sm_add;
    } else {
        x1_ -= sm_add;
        x2_ += sm_add;
    }

    Line(x1, y1, x1_, y1, color_line);
    Line(x2, y2, x2_, y2, color_line);
    Line(x1_, y1, x2_, y2, color_line);
}

/**
 * draws a relation/constraint line
 */
function Line3(x1, y1, x2, y2, color_line) {
    var x1_ = x1;
    var x2_ = x2;

    if (s_right) {
        if (x1 < x2) {
            x1_ += x2 - x1 + sm_add;
            x2_ += sm_add;
        } else {
            x2_ += x1 - x2 + sm_add;
            x1_ += sm_add;
        }

        Line(x1, y1, x1_, y1, color_line);
        Line(x2, y2, x2_, y2, color_line);
        Line(x1_, y1, x2_, y2, color_line);
        return;
    }
    if (s_left) {
        if (x1 < x2) {
            x2_ -= x2 - x1 + sm_add;
            x1_ -= sm_add;
        } else {
            x1_ -= x1 - x2 + sm_add;
            x2_ -= sm_add;
        }

        Line(x1, y1, x1_, y1, color_line);
        Line(x2, y2, x2_, y2, color_line);
        Line(x1_, y1, x2_, y2, color_line);
        return;
    }

    var x_s = (x1 + x2) / 2;
    Line(x1, y1, x_s, y1, color_line);
    Line(x_s, y2, x2, y2, color_line);
    Line(x_s, y1, x_s, y2, color_line);
}

function Circle(x, y, r, w, color) {
    var ctx = document.getElementById('canvas').getContext('2d');
    ctx.beginPath();
    ctx.moveTo(x, y);
    ctx.lineWidth = w;
    ctx.strokeStyle = color;
    ctx.arc(x, y, r, 0, 2 * Math.PI, true);
    ctx.stroke();
}

function Clear() {
    var canvas = document.getElementById("canvas");
    var ctx = canvas.getContext("2d");
    ctx.clearRect(0, 0, canvas_width, canvas_height);
}

function Rect(x1, y1, w, h, color) {
    var ctx = document.getElementById('canvas').getContext('2d');
    ctx.fillStyle = color;
    ctx.fillRect(x1, y1, w, h);
}
//--------------------------- FULLSCREEN -------------------------------------
function Enter_fullscreen() {
    if (!$.FullScreen.isFullScreen()) {
        $('#enterFullscreen').hide();
        $('#exitFullscreen').show();
        $('#page_content')
            .addClass('content_fullscreen')
            .css({'width': screen.width - 5, 'height': screen.height - 5})
            .requestFullScreen();
        Top_menu_reposition($('#key_Left_Right')[0]);
    }
}

function Exit_fullscreen() {
    if ($.FullScreen.isFullScreen()) {
        $.FullScreen.cancelFullScreen();
    }
}
//------------------------------ SAVE ------------------------------------------
function Save(url) // (del?) no for pdf
{
    for (var key in j_tabs) {
        document.getElementById('t_x_' + key + '_').value = parseInt(document.getElementById(key).style.left);
        document.getElementById('t_y_' + key + '_').value = parseInt(document.getElementById(key).style.top);
        document.getElementById('t_v_' + key + '_').value = document.getElementById('id_tbody_' + key).style.display == 'none' ? 0 : 1;
        document.getElementById('t_h_' + key + '_').value = document.getElementById('check_vis_' + key).checked ? 1 : 0;
    }
    document.form1.action = url;
    $(document.form1).submit();
}

function Get_url_pos() {
    var poststr = '';
    for (var key in j_tabs) {
        poststr += '&t_x[' + key + ']=' + parseInt(document.getElementById(key).style.left);
        poststr += '&t_y[' + key + ']=' + parseInt(document.getElementById(key).style.top);
        poststr += '&t_v[' + key + ']=' + (document.getElementById('id_tbody_' + key).style.display == 'none' ? 0 : 1);
        poststr += '&t_h[' + key + ']=' + (document.getElementById('check_vis_' + key).checked ? 1 : 0);
    }
    return poststr;
}

function Save2() {
    _change = 0;
    var poststr = 'IS_AJAX=1&server=' + server + '&db=' + db + '&token=' + token + '&die_save_pos=1';
    poststr += Get_url_pos();
    makeRequest('pmd_save_pos.php', poststr);
}

function Grid() {
    if (!ON_grid) {
        ON_grid = 1;
        document.getElementById('grid_button').className = 'M_butt_Selected_down';
    } else {
        document.getElementById('grid_button').className = 'M_butt';
        ON_grid = 0;
    }
}

function Angular_direct() {
    if (ON_angular_direct) {
        ON_angular_direct = 0;
        document.getElementById('angular_direct_button').className = 'M_butt_Selected_down';
    } else {
        ON_angular_direct = 1;
        document.getElementById('angular_direct_button').className = 'M_butt';
    }
    Re_load();
}
//++++++++++++++++++++++++++++++ RELATION ++++++++++++++++++++++++++++++++++++++
function Start_relation() {
    if (ON_display_field) {
        return;
    }

    if (!ON_relation) {
        document.getElementById('foreign_relation').style.display = '';
        ON_relation = 1;
        document.getElementById('pmd_hint').innerHTML = PMA_messages['strSelectReferencedKey'];
        document.getElementById('pmd_hint').style.display = 'block';
        document.getElementById('rel_button').className = 'M_butt_Selected_down';
    } else {
        document.getElementById('pmd_hint').innerHTML = "";
        document.getElementById('pmd_hint').style.display = 'none';
        document.getElementById('rel_button').className = 'M_butt';
        click_field = 0;
        ON_relation = 0;
    }
}

function Click_field(T, f, PK) // table field
{
    if (ON_relation) {
        if (!click_field) {
            //.style.display=='none'        .style.display = 'none'
            if (!PK) {
                alert(PMA_messages['strPleaseSelectPrimaryOrUniqueKey']);
                return;// 0;
            }//PK
            if (j_tabs[db + '.' + T] != '1') {
                document.getElementById('foreign_relation').style.display = 'none';
            }
            click_field = 1;
            link_relation = "T1=" + T + "&F1=" + f;
            document.getElementById('pmd_hint').innerHTML = PMA_messages['strSelectForeignKey'];
        } else {
            Start_relation(); // hidden hint...
            if (j_tabs[db + '.' + T] != '1' || !PK) {
                document.getElementById('foreign_relation').style.display = 'none';
            }
            var left = Glob_X - (document.getElementById('layer_new_relation').offsetWidth >> 1);
            document.getElementById('layer_new_relation').style.left = left + 'px';
            var top = Glob_Y - document.getElementById('layer_new_relation').offsetHeight;
            document.getElementById('layer_new_relation').style.top = top + 'px';
            document.getElementById('layer_new_relation').style.display = 'block';
            link_relation += '&T2=' + T + '&F2=' + f;
        }
    }

    if (ON_display_field) {
        // if is display field
        if (display_field[T] == f) {
            //alert(T);
            //s = '';for(k in display_field)s += k + ' = ' + display_field[k] + ',';alert(s);
            old_class = 'tab_field';
            //display_field.splice(T, 1);
            delete display_field[T];
            //s = '';for(k in display_field)s += k + ' = ' + display_field[k] + ', ';alert(s);
            //n = 0;for(k in display_field)n++;alert(n);
        } else {
            old_class = 'tab_field_3';
            if (display_field[T]) {
                document.getElementById('id_tr_' + T + '.' + display_field[T]).className = 'tab_field';
                //display_field.splice(T, 1);
                delete display_field[T];
            }
            display_field[T] = f;
        }
        ON_display_field = 0;
        document.getElementById('pmd_hint').innerHTML = "";
        document.getElementById('pmd_hint').style.display = 'none';
        document.getElementById('display_field_button').className = 'M_butt';
        makeRequest('pmd_display_field.php', 'T=' + T + '&F=' + f + '&server=' + server + '&db=' + db + '&token=' + token);
    }
}

function New_relation() {
    document.getElementById('layer_new_relation').style.display = 'none';
    link_relation += '&server=' + server + '&db=' + db + '&token=' + token + '&die_save_pos=0';
    link_relation += '&on_delete=' + document.getElementById('on_delete').value + '&on_update=' + document.getElementById('on_update').value;
    link_relation += Get_url_pos();

    //alert(link_relation);
    makeRequest('pmd_relation_new.php', link_relation);
}

//-------------------------- create tables -------------------------------------

function Start_table_new() {
    PMA_commonParams.set('table', '');
    PMA_commonActions.refreshMain('tbl_create.php');
}

function Start_tab_upd(table) {
    PMA_commonParams.set('table', table);
    PMA_commonActions.refreshMain('tbl_structure.php');
}
//--------------------------- hide tables --------------------------------------

function Small_tab_all(id_this) // max/min all tables
{
    if (id_this.alt == "v") {
        for (var key in j_tabs) {
            if (document.getElementById('id_hide_tbody_' + key).innerHTML == "v") {
                Small_tab(key, 0);
            }
        }
        id_this.alt = ">";
        id_this.src = pmaThemeImage + "pmd/rightarrow1.png";
    } else {
        for (var key in j_tabs) {
            if (document.getElementById('id_hide_tbody_' + key).innerHTML != "v") {
                Small_tab(key, 0);
            }
        }
        id_this.alt = "v";
        id_this.src = pmaThemeImage + "pmd/downarrow1.png";
    }
    Re_load();
}

function Small_tab_invert() // invert max/min all tables
{
    for (var key in j_tabs) {
        Small_tab(key, 0);
    }
    Re_load();
}

function Relation_lines_invert() {
    show_relation_lines = !show_relation_lines;
    Re_load();
}

function Small_tab_refresh() {
    for (var key in j_tabs) {
        if (document.getElementById('id_hide_tbody_' + key).innerHTML != "v") {
            Small_tab(key, 0);
            Small_tab(key, 0);
        }
    }
}

function Small_tab(t, re_load) {
    var id = document.getElementById('id_tbody_' + t);
    var id_this = document.getElementById('id_hide_tbody_' + t);
    var id_t = document.getElementById(t);
    id_t.style.width = id_t.offsetWidth + 'px';
    if (id_this.innerHTML == "v") {
        //---CROSS
        id.style.display = 'none';
        id_this.innerHTML = '>';
    } else {
        id.style.display = '';
        id_this.innerHTML = 'v';
    }
    if (re_load) {
        Re_load();
    }
}
//------------------------------------------------------------------------------
function Select_tab(t) {
    var id_zag = document.getElementById('id_zag_' + t);
    if (id_zag.className != 'tab_zag_3') {
        document.getElementById('id_zag_' + t).className = 'tab_zag_2';
    } else {
        document.getElementById('id_zag_' + t).className = 'tab_zag';
    }
    //----------
    var id_t = document.getElementById(t);
    window.scrollTo(parseInt(id_t.style.left) - 300, parseInt(id_t.style.top) - 300);
    setTimeout(function () {
        document.getElementById('id_zag_' + t).className = 'tab_zag';
    }, 800);
}
//------------------------------------------------------------------------------

function Canvas_click(id) {
    var n = 0;
    var relation_name = 0;
    var selected = 0;
    var a = [];
    var Key0, Key1, Key2, Key3, Key, x1, x2;
    var K, key, key2, key3;
    var Local_X = $.FullScreen.isFullScreen() ? Glob_X : Glob_X - document.getElementById("canvas_outer").offsetLeft;
    var Local_Y = Glob_Y - document.getElementById("canvas_outer").offsetTop;
    Clear();
    for (K in contr) {
        for (key in contr[K]) {
            for (key2 in contr[K][key]) {
                for (key3 in contr[K][key][key2]) {
                    if (!document.getElementById("check_vis_" + key2).checked
                        || !document.getElementById("check_vis_" + contr[K][key][key2][key3][0]).checked) {
                        continue; // if hide
                    }
                    var x1_left = document.getElementById(key2).offsetLeft + 1;//document.getElementById(key2+"."+key3).offsetLeft;
                    var x1_right = x1_left + document.getElementById(key2).offsetWidth;
                    var x2_left = document.getElementById(contr[K][key][key2][key3][0]).offsetLeft;//+document.getElementById(contr[K][key2][key3][0]+"."+contr[K][key2][key3][1]).offsetLeft
                    var x2_right = x2_left + document.getElementById(contr[K][key][key2][key3][0]).offsetWidth;
                    a[0] = Math.abs(x1_left - x2_left);
                    a[1] = Math.abs(x1_left - x2_right);
                    a[2] = Math.abs(x1_right - x2_left);
                    a[3] = Math.abs(x1_right - x2_right);
                    n = s_left = s_right = 0;
                    for (var i = 1; i < 4; i++) {
                        if (a[n] > a[i]) {
                            n = i;
                        }
                    }
                    if (n == 1) {
                        x1 = x1_left - sm_s;
                        x2 = x2_right + sm_s;
                        if (x1 < x2) {
                            n = 0;
                        }
                    }
                    if (n == 2) {
                        x1 = x1_right + sm_s;
                        x2 = x2_left - sm_s;
                        if (x1 > x2) {
                            n = 0;
                        }
                    }
                    if (n == 3) {
                        x1 = x1_right + sm_s;
                        x2 = x2_right + sm_s;
                        s_right = 1;
                    }
                    if (n == 0) {
                        x1 = x1_left - sm_s;
                        x2 = x2_left - sm_s;
                        s_left = 1;
                    }

                    var y1 = document.getElementById(key2).offsetTop + document.getElementById(key2 + "." + key3).offsetTop + height_field;
                    var y2 = document.getElementById(contr[K][key][key2][key3][0]).offsetTop +
                        document.getElementById(contr[K][key][key2][key3][0] + "." + contr[K][key][key2][key3][1]).offsetTop + height_field;
                    if (!selected && Local_X > x1 - 10 && Local_X < x1 + 10 && Local_Y > y1 - 7 && Local_Y < y1 + 7) {
                        Line0(x1 - sm_x, y1 - sm_y, x2 - sm_x, y2 - sm_y, "rgba(255,0,0,1)");
                        selected = 1; // Rect(x1-sm_x,y1-sm_y,10,10,"rgba(0,255,0,1)");
                        relation_name = key; //
                        Key0 = contr[K][key][key2][key3][0];
                        Key1 = contr[K][key][key2][key3][1];
                        Key2 = key2;
                        Key3 = key3;
                        Key = K;
                    } else {
                        Line0(x1 - sm_x, y1 - sm_y, x2 - sm_x, y2 - sm_y, getColorByTarget(contr[K][key][key2][key3][0] + '.' + contr[K][key][key2][key3][1]));
                    }
                }
            }
        }
    }
    if (selected) {
        // select relations
        //alert(Key0+' - '+Key1+' - '+Key2+' - '+Key3);
        var left = Glob_X - (document.getElementById('layer_upd_relation').offsetWidth >> 1);
        document.getElementById('layer_upd_relation').style.left = left + 'px';
        var top = Glob_Y - document.getElementById('layer_upd_relation').offsetHeight - 10;
        document.getElementById('layer_upd_relation').style.top = top + 'px';
        document.getElementById('layer_upd_relation').style.display = 'block';
        link_relation = 'T1=' + Key0 + '&F1=' + Key1 + '&T2=' + Key2 + '&F2=' + Key3 + '&K=' + Key;
    }
}

function Upd_relation() {
    document.getElementById('layer_upd_relation').style.display = 'none';
    link_relation += '&server=' + server + '&db=' + db + '&token=' + token + '&die_save_pos=0';
    link_relation += Get_url_pos();
    makeRequest('pmd_relation_upd.php', link_relation);
}

function VisibleTab(id, t_n) {
    if (id.checked) {
        document.getElementById(t_n).style.display = 'block';
    } else {
        document.getElementById(t_n).style.display = 'none';
    }
    Re_load();
}

function Hide_tab_all(id_this) // max/min all tables
{
    if (id_this.alt == 'v') {
        id_this.alt = '>';
        id_this.src = pmaThemeImage + "pmd/rightarrow1.png";
    } else {
        id_this.alt = 'v';
        id_this.src = pmaThemeImage + "pmd/downarrow1.png";
    }
    var E = document.form1;
    for (var i = 0; i < E.elements.length; i++) {
        if (E.elements[i].type == "checkbox" && E.elements[i].id.substring(0, 10) == 'check_vis_') {
            if (id_this.alt == 'v') {
                E.elements[i].checked = true;
                document.getElementById(E.elements[i].value).style.display = '';
            } else {
                E.elements[i].checked = false;
                document.getElementById(E.elements[i].value).style.display = 'none';
            }
        }
    }
    Re_load();
}

function in_array_k(x, m) {
    var b = 0;
    for (var u in m) {
        if (x == u) {
            b = 1;
            break;
        }
    }
    return b;
}

function No_have_constr(id_this) {
    var a = [];
    var K, key, key2, key3;
    for (K in contr) {
        for (key in contr[K]) {
            // contr name
            for (key2 in contr[K][key]) {
                // table name
                for (key3 in contr[K][key][key2]) {
                    // field name
                    a[key2] = a[contr[K][key][key2][key3][0]] = 1; // exist constr
                }
            }
        }
    }

    if (id_this.alt == 'v') {
        id_this.alt = '>';
        id_this.src = pmaThemeImage + "pmd/rightarrow2.png";
    } else {
        id_this.alt = 'v';
        id_this.src = pmaThemeImage + "pmd/downarrow2.png";
    }
    var E = document.form1;
    for (var i = 0; i < E.elements.length; i++) {
        if (E.elements[i].type == "checkbox" && E.elements[i].id.substring(0, 10) == 'check_vis_') {
            if (!in_array_k(E.elements[i].value, a)) {
                if (id_this.alt == 'v') {
                    E.elements[i].checked = true;
                    document.getElementById(E.elements[i].value).style.display = '';
                } else {
                    E.elements[i].checked = false;
                    document.getElementById(E.elements[i].value).style.display = 'none';
                }
            }
        }
    }
}

function PDF_save() {
    // var WinPDF =
    // window.open("pmd_pdf.php?token="+token+"&db="+db,"wind1", "top=200,left=200,width=200,height=100,resizable=yes,scrollbars=yes,menubar=no");
    Save('pmd_pdf.php?server=' + server + '&token=' + token + '&db=' + db);
}

function General_scroll() {
    /*
     if (!document.getElementById('show_relation_olways').checked) {
     document.getElementById("canvas").style.display = 'none';
     clearTimeout(timeoutID);
     timeoutID = setTimeout(General_scroll_end, 500);
     }
     */
    //if (timeoutID)
    clearTimeout(timeoutID);
    timeoutID = setTimeout
    (
        function () {
            document.getElementById('top_menu').style.left = document.body.scrollLeft + 'px';
            document.getElementById('top_menu').style.top = document.body.scrollTop + 'px';
        }, 200
    );
}

/*
 function General_scroll_end()
 {
 document.getElementById('layer_menu').style.left = document.body.scrollLeft;
 document.getElementById('layer_menu').style.top  = document.body.scrollTop + document.getElementById('top_menu').offsetHeight;
 if (isIE) {
 document.getElementById('layer_menu').style.left = document.body.scrollLeft;
 document.getElementById('layer_menu').style.top  = document.body.scrollTop + document.getElementById('top_menu').offsetHeight;
 }
 document.getElementById("canvas").style.display = 'block';
 }
 */

function Show_left_menu(id_this) // max/min all tables
{
    if (id_this.alt == "v") {
        var pos = $("#top_menu").offset();
        var height = $("#top_menu").height();
        document.getElementById("layer_menu").style.top = '0px';
        document.getElementById("layer_menu").style.display = 'block';
        id_this.alt = ">";
        id_this.src = pmaThemeImage + "pmd/uparrow2_m.png";
        if (isIE) {
            General_scroll();
        }
    } else {
        document.getElementById("layer_menu").style.top = -1000 + 'px'; //fast scroll
        document.getElementById("layer_menu").style.display = 'none';
        id_this.alt = "v";
        id_this.src = pmaThemeImage + "pmd/downarrow2_m.png";
    }
}
//------------------------------------------------------------------------------
function Top_menu_right(id_this) {
    if (id_this.alt == ">") {
        moveTopMenuToRight(id_this);
        id_this.alt = "<";
        id_this.src = pmaThemeImage + "pmd/2leftarrow_m.png";
    } else {
        document.getElementById('top_menu').style.paddingLeft = 0;
        id_this.alt = ">";
        id_this.src = pmaThemeImage + "pmd/2rightarrow_m.png";
    }
}

function Top_menu_reposition(id_this) {
    if (id_this.alt == "<") {
        moveTopMenuToRight(id_this);
    }
}

function moveTopMenuToRight(id_this) {
    var top_menu_width = 10;
    $('#top_menu').children().each(function () {
        top_menu_width += $(this).outerWidth(true);
    });
    var offset = parseInt(document.getElementById('canvas_outer').offsetWidth - top_menu_width, 10);
    document.getElementById('top_menu').style.paddingLeft = offset + 'px';
}
//------------------------------------------------------------------------------
function Start_display_field() {
    if (ON_relation) {
        return;
    }
    if (!ON_display_field) {
        ON_display_field = 1;
        document.getElementById('pmd_hint').innerHTML = PMA_messages['strChangeDisplay'];
        document.getElementById('pmd_hint').style.display = 'block';
        document.getElementById('display_field_button').className = 'M_butt_Selected_down';//'#FFEE99';gray #AAAAAA

        if (isIE) { // correct for IE
            document.getElementById('display_field_button').className = 'M_butt_Selected_down_IE';
        }
    } else {
        document.getElementById('pmd_hint').innerHTML = "";
        document.getElementById('pmd_hint').style.display = 'none';
        document.getElementById('display_field_button').className = 'M_butt';
        ON_display_field = 0;
    }
}
//------------------------------------------------------------------------------
var TargetColors = [];
function getColorByTarget(target) {
    var color = '';  //"rgba(0,100,150,1)";

    for (var i in TargetColors) {
        if (TargetColors[i][0] == target) {
            color = TargetColors[i][1];
            break;
        }
    }

    if (color.length == 0) {
        var i = TargetColors.length + 1;
        var d = i % 6;
        var j = (i - d) / 6;
        j = j % 4;
        j++;
        var color_case = new Array(
            new Array(1, 0, 0),
            new Array(0, 1, 0),
            new Array(0, 0, 1),
            new Array(1, 1, 0),
            new Array(1, 0, 1),
            new Array(0, 1, 1)
        );
        var a = color_case[d][0];
        var b = color_case[d][1];
        var c = color_case[d][2];
        var e = (1 - (j - 1) / 6);

        var r = Math.round(a * 200 * e);
        var g = Math.round(b * 200 * e);
        var b = Math.round(c * 200 * e);
        var color = "rgba(" + r + "," + g + "," + b + ",1)";

        TargetColors.push(new Array(target, color));

    }

    return color;
}

function Click_option(id_this, column_name, table_name) {
    var left = Glob_X - (document.getElementById(id_this).offsetWidth >> 1);
    document.getElementById(id_this).style.left = left + 'px';
    // var top = Glob_Y - document.getElementById(id_this).offsetHeight - 10;
    document.getElementById(id_this).style.top = (screen.height / 4) + 'px';
    document.getElementById(id_this).style.display = 'block';
    document.getElementById('option_col_name').innerHTML = '<strong>' + PMA_messages['strAddOption'] + '"' + column_name + '"</strong>';
    col_name = column_name;
    tab_name = table_name;
}

function Close_option() {
    document.getElementById('pmd_optionse').style.display = 'none';
}

function Select_all(id_this, owner) {
    var parent = document.form1;
    downer = owner;
    var i;
    var k;
    var tab = [];
    for (i = 0; i < parent.elements.length; i++) {
        if (parent.elements[i].type == "checkbox" && parent.elements[i].id.substring(0, (9 + id_this.length)) == 'select_' + id_this + '._') {
            if (document.getElementById('select_all_' + id_this).checked == true) {
                parent.elements[i].checked = true;
                parent.elements[i].disabled = true;
                var temp = '`' + id_this.substring(owner.length + 1) + '`.*';
            }
            else {
                parent.elements[i].checked = false;
                parent.elements[i].disabled = false;
            }
        }
    }
    if (document.getElementById('select_all_' + id_this).checked == true) {
        select_field.push('`' + id_this.substring(owner.length + 1) + '`.*');
        tab = id_this.split(".");
        from_array.push(tab[1]);
    }
    else {
        for (i = 0; i < select_field.length; i++) {
            if (select_field[i] == ('`' + id_this.substring(owner.length + 1) + '`.*')) {
                select_field.splice(i, 1);
            }
        }
        for (k = 0; k < from_array.length; k++) {
            if (from_array[k] == id_this) {
                from_array.splice(k, 1);
                break;
            }
        }
    }
    Re_load();
}

function Table_onover(id_this, val, buil) {
    if (!val) {
        document.getElementById("id_zag_" + id_this).className = "tab_zag_2";
        if (buil) {
            document.getElementById("id_zag_" + id_this + "_2").className = "tab_zag_2";
        }
    }
    else {
        document.getElementById("id_zag_" + id_this).className = "tab_zag";
        if (buil) {
            document.getElementById("id_zag_" + id_this + "_2").className = "tab_zag";
        }
    }
}

/* This function stores selected column information in select_field[]
 * In case column is checked it add else it deletes
 *
 */
function store_column(id_this, owner, col) {
    var i;
    var k;
    if (document.getElementById('select_' + owner + '.' + id_this + '._' + col).checked == true) {
        select_field.push('`' + id_this + '`.`' + col + '`');
        from_array.push(id_this);
    }
    else {
        for (i = 0; i < select_field.length; i++) {
            if (select_field[i] == ('`' + id_this + '`.`' + col + '`')) {
                select_field.splice(i, 1);
                break;
            }
        }
        for (k = 0; k < from_array.length; k++) {
            if (from_array[k] == id_this) {
                from_array.splice(k, 1);
                break;
            }
        }
    }
}

/**
 * This function builds object and adds them to history_array
 * first it does a few checks on each object, then makes an object(where,rename,groupby,aggregate,orderby)
 * then a new history object is made and finally all these history objects are addded to history_array[]
 *
 **/

function add_object() {
    var rel = document.getElementById('rel_opt');
    var sum = 0;
    var init = history_array.length;
    if (rel.value != '--') {
        if (document.getElementById('Query').value == "") {
            document.getElementById('pmd_hint').innerHTML = "value/subQuery is empty";
            document.getElementById('pmd_hint').style.display = 'block';
            return;
        }
        var p = document.getElementById('Query');
        var where_obj = new where(rel.value, p.value);//make where object
        history_array.push(new history(col_name, where_obj, tab_name, h_tabs[downer + '.' + tab_name], "Where"));
        sum = sum + 1;
        rel.value = '--';
        p.value = "";
    }
    if (document.getElementById('new_name').value != "") {
        var rename_obj = new rename(document.getElementById('new_name').value);//make Rename object
        history_array.push(new history(col_name, rename_obj, tab_name, h_tabs[downer + '.' + tab_name], "Rename"));
        sum = sum + 1;
        document.getElementById('new_name').value = "";
    }
    if (document.getElementById('operator').value != '---') {
        var aggregate_obj = new aggregate(document.getElementById('operator').value);
        history_array.push(new history(col_name, aggregate_obj, tab_name, h_tabs[downer + '.' + tab_name], "Aggregate"));
        sum = sum + 1;
        document.getElementById('operator').value = '---';
        //make aggregate operator
    }
    if (document.getElementById('groupby').checked == true) {
        history_array.push(new history(col_name, 'GroupBy', tab_name, h_tabs[downer + '.' + tab_name], "GroupBy"));
        sum = sum + 1;
        document.getElementById('groupby').checked = false;
        //make groupby
    }
    if (document.getElementById('h_rel_opt').value != '--') {
        if (document.getElementById('having').value == "") {
            document.getElementById('pmd_hint').innerHTML = "value/subQuery is empty";
            document.getElementById('pmd_hint').style.display = 'block';
            return;
        }
        var p = document.getElementById('having');
        var where_obj = new having(document.getElementById('h_rel_opt').value, p.value, document.getElementById('h_operator').value);//make where object
        history_array.push(new history(col_name, where_obj, tab_name, h_tabs[downer + '.' + tab_name], "Having"));
        sum = sum + 1;
        document.getElementById('h_rel_opt').value = '--';
        document.getElementById('h_operator').value = '---';
        p.value = ""; //make having
    }
    if (document.getElementById('orderby').checked == true) {
        history_array.push(new history(col_name, 'OrderBy', tab_name, h_tabs[downer + '.' + tab_name], "OrderBy"));
        sum = sum + 1;
        document.getElementById('orderby').checked = false;
        //make orderby
    }
    PMA_ajaxShowMessage($.sprintf(PMA_messages['strObjectsCreated'], sum));
    //output sum new objects created
    var existingDiv = document.getElementById('ab');
    existingDiv.innerHTML = display(init, history_array.length);
    Close_option();
    panel(0);
}


text:
"""Family module for Wikimedia outreach wiki."""
from __future__ import unicode_literals

__version__ = '$Id: 8ad23b6dfa568979f3dc447ae38245027fd2cd68 $'

from pywikibot import family

# Outreach wiki custom family
class Family(family.WikimediaFamily):

    """Family class for Wikimedia outreach wiki."""

    def __init__(self):
        """Constructor."""
        super(Family, self).__init__()
        self.name = u'outreach'
        self.langs = {
            'outreach': 'outreach.wikimedia.org',
        }
        self.interwiki_forward = 'wikipedia'

redpajama_set_name: RedPajamaGithub


text:
package processors

import (
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/credentials"
	"github.com/dailyburn/ratchet/data"
	"github.com/dailyburn/ratchet/util"
)

// S3Writer sends data upstream to S3. By default, we will not compress data before sending it.
// Set the `Compress` flag to true to use gzip compression before storing in S3 (if this flag is
// set to true, ".gz" will automatically be appended to the key name specified).
//
// By default, we will separate each iteration of data sent to `ProcessData` with a new line
// when we piece back together to send to S3. Change the `LineSeparator` attribute to change
// this behavior.
type S3Writer struct {
	data          []string
	Compress      bool
	LineSeparator string
	config        *aws.Config
	bucket        string
	key           string
}

// NewS3Writer instaniates a new S3Writer
func NewS3Writer(awsID, awsSecret, awsRegion, bucket, key string) *S3Writer {
	w := S3Writer{bucket: bucket, key: key, LineSeparator: "\n", Compress: false}

	creds := credentials.NewStaticCredentials(awsID, awsSecret, "")
	// .WithLogLevel(aws.LogDebugWithRequestRetries | aws.LogDebugWithRequestErrors)
	w.config = aws.NewConfig().WithRegion(awsRegion).WithDisableSSL(true).WithCredentials(creds)

	return &w
}

// ProcessData enqueues all received data
func (w *S3Writer) ProcessData(d data.JSON, outputChan chan data.JSON, killChan chan error) {
	w.data = append(w.data, string(d))
}

// Finish writes all enqueued data to S3, defering to util.WriteS3Object
func (w *S3Writer) Finish(outputChan chan data.JSON, killChan chan error) {
	util.WriteS3Object(w.data, w.config, w.bucket, w.key, w.LineSeparator, w.Compress)
}

func (w *S3Writer) String() string {
	return "S3Writer"
}


text:
<?php

namespace Bruery\UserBundle\Controller;

use Bruery\UserBundle\BrueryUserEvents;
use FOS\UserBundle\Model\UserInterface;
use Sonata\UserBundle\Controller\RegistrationFOSUser1Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;

class RegistrationSonataUserController extends RegistrationFOSUser1Controller
{

    /**
     * @return RedirectResponse
     */
    public function registerAction()
    {
        $user = $this->getUser();

        if ($user instanceof UserInterface) {
            $this->get('session')->getFlashBag()->set('sonata_user_error', 'sonata_user_already_authenticated');

            return $this->redirect($this->generateUrl('sonata_user_profile_show'));
        }

        $form = $this->get('sonata.user.registration.form');
        $formHandler = $this->get('sonata.user.registration.form.handler');
        $confirmationEnabled = $this->container->getParameter('fos_user.registration.confirmation.enabled');

        $process = $formHandler->process($confirmationEnabled);
        if ($process) {
            $user = $form->getData();

            $authUser = false;
            if ($confirmationEnabled) {
                $this->get('session')->set('fos_user_send_confirmation_email/email', $user->getEmail());
                $url = $this->generateUrl('sonata_user_registration_check_email');
            } else {
                $authUser = true;
                $url = $this->generateUrl('sonata_user_profile_show');
            }

            $this->setFlash('fos_user_success', 'registration.flash.user_created');

            $response = new RedirectResponse($url);

            if ($authUser) {
                $this->authenticateUser($user, $response);
            }

            return $response;
        }

        $this->get('session')->set('sonata_user_redirect_url', $this->get('request')->headers->get('referer'));

        return $this->render('FOSUserBundle:Registration:register.html.'.$this->getEngine(), array(
            'form' => $form->createView(),
        ));
    }

    /**
     * Renders a view.
     *
     * @param string   $view       The view name
     * @param array    $parameters An array of parameters to pass to the view
     * @param Response $response   A response instance
     *
     * @return Response A Response instance
     */
    public function render($view, array $parameters = array(), Response $response = null)
    {
        $template = $this->get('bruery_core.template_loader')->getTemplates();
        switch ($view) {
            case 'FOSUserBundle:Registration:register.html.twig':
                return parent::render($template['bruery_user.template.registration.form'], $parameters, $response);
                break;

            case 'FOSUserBundle:Registration:checkEmail.html.twig':
                return parent::render($template['bruery_user.template.registration.check_email'], $parameters, $response);
                break;

            case 'FOSUserBundle:Registration:confirmed.html.twig':
                return parent::render($template['bruery_user.template.registration.confirmed'], $parameters, $response);
                break;

            default:
                return parent::render($view, $parameters, $response);
                break;
        }
    }
}


text:
GulpSamples
===========

Plugin
------

Creating your own plugin can be quite useful. However, the core guidelines should be honored. It is really important that plugins are small, focus on a single feature and integrate well with piping.

The provided sample uses a plugin just called `prefixer`. It is basically equivalent to the sample in the Gulp documentation.

How is the structure of the provided plugin?

1. We return a constructor function. In our case this function requires one argument. If the argument is missing, then we throw an error.
2. Throwing an error should always be done by throwing a new `PluginError` of the `gulp-util` module. That way Gulp knows that this is not an internal error, but one within the build system.
3. The constructor function will return a stream object. That object is already setup with a callback, that will be called for each stream. The callback may receive multiple arguments. In the example we use the file, encoding and a callback. The callback must be invoked in the end, to indicate that transforming the stream is completed.
4. Inside the callback we can access the stream object to push the stream. If we do not push the stream, then we basically exclude the file.
5. Either way we should usually decide between three options:
   1. No content
   2. Buffered content
   3. Contents from a file


text:
import React from 'react';
import { HTMLFieldProps, connectField, filterDOMProps } from 'uniforms';

import AutoField from './AutoField';

export type NestFieldProps = HTMLFieldProps<
  object,
  HTMLDivElement,
  { itemProps?: object }
>;

function Nest({
  children,
  fields,
  itemProps,
  label,
  ...props
}: NestFieldProps) {
  return (
    <div {...filterDOMProps(props)}>
      {label && <label>{label}</label>}
      {children ||
        fields.map(field => (
          <AutoField key={field} name={field} {...itemProps} />
        ))}
    </div>
  );
}

export default connectField<NestFieldProps>(Nest);


text:
package see.functions.service;

import com.google.common.base.Preconditions;
import see.functions.VarArgFunction;

import javax.annotation.Nonnull;
import java.util.List;

public class IsDefined implements VarArgFunction<Object, Boolean> {

    @Override
    public Boolean apply(@Nonnull List<Object> args) {
        Preconditions.checkArgument(args.size() == 1, "isDefined takes one argument");

        try {
            Object value = args.get(0);
            return value != null;
        } catch (Exception e) {
            return false;
        }
    }

    @Override
    public String toString() {
        return "isDefined";
    }
}


text:
<?xml version="1.0"?>

<config>
    <sections>
        <catalog>
            <groups>
                <search>
                    <fields>
                        <engine translate="label">
                            Search Engine
                            <frontend_type>select</frontend_type>
                            <backend_model>factfinder/system_config_backend_engine</backend_model>
                            <source_model>factfinder/system_config_source_engine</source_model>
                            <sort_order>19</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>0</show_in_store>
                            <comment><![CDATA[Please, configure FACT-Finder engine only in the FACT-Finder tab]]></comment>
                        </engine>
                    </fields>
                </search>
            </groups>
        </catalog>
        <factfinder translate="label" module="factfinder">
            FACT-Finder
            <tab>catalog</tab>
            <sort_order>420</sort_order>
            <frontend_type>text</frontend_type>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>
                <search translate="label">
                    FACT-Finder
                    <frontend_type>text</frontend_type>
                    <sort_order>10</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <enabled translate="label">
                            Enabled
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>10</sort_order>

                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </enabled>
                        <address translate="label">
                            Server URL
                            <frontend_type>text</frontend_type>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </address>
                        <port translate="label">
                            Server Port
                            <frontend_type>text</frontend_type>
                            <sort_order>30</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </port>
                        <protocol translate="label">
                            Protocol
                            <frontend_type>select</frontend_type>
                            <source_model>factfinder/system_config_source_protocol</source_model>
                            <sort_order>35</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </protocol>
                        <context translate="label comment">
                            Context Name
                            <comment>Name of the FACT-Finder application</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>40</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </context>
                        <auth_user translate="label comment">
                            User name
                            <comment>User name for authentication</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>50</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </auth_user>
                        <auth_password translate="label">
                            Password
                            <frontend_type>password</frontend_type>
                            <sort_order>60</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </auth_password>
                        <channel translate="label comment">
                            Primary Channel
                            <comment>FACT-Finder can provide multiple search indexes, each represented by a "channel". Enter the channel that will be filled with your Magento export. Leave empty to use the default channel.</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>70</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </channel>
                        <language translate="label comment">
                            Language
                            <comment>Some text strings come directly from FACT-Finder. Enter the language code here. Leave empty to use the language specified by the user's browser.</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>80</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </language>
                        <auth_type translate="label">
                            Authentication Type
                            <frontend_type>select</frontend_type>
                            <source_model>factfinder/system_config_source_authtype</source_model>
                            <sort_order>90</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </auth_type>
                        <auth_advancedPrefix translate="label comment">
                            Advanced Authentication Prefix
                            <frontend_type>text</frontend_type>
                            <comment>The advanced authentication post- and prefix are only used when the authentication type is "advanced".</comment>
                            <sort_order>100</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </auth_advancedPrefix>
                        <auth_advancedPostfix>
                            Advanced Authentication Postfix
                            <frontend_type>text</frontend_type>
                            <sort_order>110</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </auth_advancedPostfix>
                    </fields>
                </search>
                <fallback translate="label">
                    FACT-Finder Fallback Configuration
                    <frontend_type>text</frontend_type>
                    <sort_order>15</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <use_fallback translate="label comment">
                            Use Fallback
                            <comment>If activated and FACT-Finder cannot be contacted, Magento's built-in search will be used instead.</comment>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </use_fallback>
                    </fields>
                </fallback>
                <export translate="label">
                    FACT-Finder Export Configuration
                    <frontend_type>text</frontend_type>
                    <sort_order>20</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <remove_tags translate="label">
                            Remove html entities and tags
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </remove_tags>
                        <products_without_categories translate="label">
                            Export products without categories
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>25</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </products_without_categories>
                        <out_of_stock_products>
                            Export out of stock products
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>30</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </out_of_stock_products>
                        <attributes translate="label">
                            Attributes
                            <frontend_model>factfinder/adminhtml_form_field_attributes</frontend_model>
                            <backend_model>factfinder/system_config_backend_attributes</backend_model>
                            <sort_order>35</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </attributes>
                        <explicit_attributes translate="label">
                            Use explicit attribute types
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>40</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment><![CDATA[Use types from the above table to export attributes in type-specific columns rather than in separate ones]]></comment>
                        </explicit_attributes>
                        <trigger_data_import translate="label">
                            Trigger Data Import
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>50</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment><![CDATA[Start FACTFinder data import after each export]]></comment>
                        </trigger_data_import>
                        <import_delay_enabled translate="label comment">
                            Import Delay Enabled
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>60</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment><![CDATA[If enabled, imports will be triggered with a delay between each other. Recommended for FACT-Finder >= 7.1.]]></comment>
                        </import_delay_enabled>
                        <use_ftp translate="label comment">
                            Upload files to FTP host
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>70</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment><![CDATA[Upload exported data to FTP server]]></comment>
                        </use_ftp>
                        <ftp_host translate="label">
                            FTP Host
                            <frontend_type>text</frontend_type>
                            <sort_order>80</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <depends><use_ftp>1</use_ftp></depends>
                        </ftp_host>
                        <ftp_port translate="label">
                            FTP Port
                            <frontend_type>text</frontend_type>
                            <sort_order>90</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <depends><use_ftp>1</use_ftp></depends>
                        </ftp_port>
                        <ftp_user translate="label">
                            FTP User
                            <frontend_type>text</frontend_type>
                            <sort_order>100</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <depends><use_ftp>1</use_ftp></depends>
                        </ftp_user>
                        <ftp_password translate="label">
                            FTP Password
                            <frontend_type>password</frontend_type>
                            <sort_order>110</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <depends><use_ftp>1</use_ftp></depends>
                        </ftp_password>
                        <ftp_path translate="label">
                            FTP Path
                            <frontend_type>text</frontend_type>
                            <sort_order>120</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <depends><use_ftp>1</use_ftp></depends>
                        </ftp_path>
                        <ftp_ssl translate="label">
                            Use SSL
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>130</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <depends><use_ftp>1</use_ftp></depends>
                            <comment><![CDATA[Yes for FTPS and No for FTP]]></comment>
                        </ftp_ssl>
                        <export_url translate="label">
                            Trigger
                            <frontend_model>factfinder/adminhtml_exportlink</frontend_model>
                            <sort_order>140</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </export_url>
                        <disabled_validation translate="label comment">
                            Disable export feed validation
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>150</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment><![CDATA[This can be used in case of unpredicted problems with export data validation]]></comment>
                        </disabled_validation>
                        <export_cms_pages translate="label comment">
                            Export CMS pages
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>160</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </export_cms_pages>
                    </fields>
                </export>
                <config translate="label">
                    FACT-Finder Config Data
                    <frontend_type>text</frontend_type>
                    <sort_order>20</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <personalization translate="label">
                            Enable Personalization (>= 6.11)
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>5</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </personalization>
                        <redirectOnSingleResult>
                            Redirect to product details page for single results
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </redirectOnSingleResult>
                        <use_sortings>
                            Use sorting options
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>15</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment><![CDATA[If enabled, it requires FACT-Finder >= 7.1 and the configuration of the desired sorting options in the FACT-Finder Backend.]]></comment>
                        </use_sortings>
                        <use_resultsPerPage>
                            Use results per page options
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment><![CDATA[If enabled, it requires the configuration of default and alternative results per page options in the FACT-Finder backend.]]></comment>
                        </use_resultsPerPage>
                        <identifier translate="label">
                            Product Identifier
                            <frontend_type>select</frontend_type>
                            <source_model>factfinder/system_config_source_identifier</source_model>
                            <sort_order>35</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </identifier>
                        <internal_ip translate="label">
                            Internal IPs
                            <comment>Enter your internal IP addresses. Multiple IP addresses should be separated by semicolons.</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>55</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </internal_ip>
                        <debug translate="label">
                            Debug Log
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>60</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </debug>
                    </fields>
                </config>
                <cron translate="label">
                    FACT-Finder Cron Export Settings
                    <frontend_type>text</frontend_type>
                    <sort_order>25</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>0</show_in_website>
                    <show_in_store>0</show_in_store>
                    <fields>
                        <enabled translate="label">
                            Enable Cron Pre-Generation
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>0</show_in_store>
                        </enabled>
                        <time translate="label">
                            Start Time
                            <frontend_type>time</frontend_type>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>0</show_in_store>
                        </time>
                        <frequency translate="label">
                            Frequency
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_cron_frequency</source_model>
                            <backend_model>factfinder/system_config_backend_cron</backend_model>
                            <sort_order>30</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>0</show_in_store>
                        </frequency>
                    </fields>
                </cron>
                <modules translate="label">
                    FACT-Finder Features
                    <sort_order>50</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <tracking>
                            Enable FACT-Finder Tracking
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>5</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </tracking>
                        <suggest translate="label">
                            Enable FACT-Finder Suggest
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </suggest>
                        <asn translate="label">
                            Enable FACT-Finder After Search Navigation
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>15</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </asn>
                        <campaigns>
                            Enable FACT-Finder Campaigns
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>25</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </campaigns>
                        <recommendation translate="label">
                            Enable FACT-Finder Recommendation
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>30</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </recommendation>
                        <tagcloud translate="label">
                            Enable FACT-Finder Tag Cloud
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>35</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </tagcloud>
                    </fields>
                </modules>
            </groups>
        </factfinder>
    </sections>
</config>


text:
/**
* Author: Bob Chen
*/

package com.jcommerce.core.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.jcommerce.core.dao.GoodsDAO;
import com.jcommerce.core.model.Goods;

@Repository
@SuppressWarnings("unchecked")
public class GoodsDAOImpl extends DAOImpl implements GoodsDAO {
    public GoodsDAOImpl() {
        modelClass = Goods.class;
    }

    public List<Goods> getGoodsList() {
        return getList();
    }

    public Goods getGoods(Long id) {
        return (Goods)getById(id);
    }

    public void saveGoods(Goods obj) {
        save(obj);
    }

    public void removeGoods(Long id) {
        deleteById(id);
    }
}


text:
% Script ccc
% Clears all, closes all, clears screen.
%
% usage
%     ccc
%
% input
%
% output
%
% description:
%		% Clean slate work space in Matlab, clears all, closes all, clears screen.
%
% author
%     Martin Hjelm, martinhjelm@kth.se

  clear;
  clear -global;
  clear all;
  close all;
  clc;


text:
<!DOCTYPE html>

    <meta charset="UTF-8" />
    <meta name="robots" content="index, follow, all" />
    <title>Thelia\TaxEngine\TaxEngine | Thelia 2 API</title>

            <link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="../../css/bootstrap-theme.min.css">
        <link rel="stylesheet" type="text/css" href="../../css/sami.css">

        <meta name="MobileOptimized" content="width">
        <meta name="HandheldFriendly" content="true">
        <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">

                <form id="search-form" action="../../search.html" method="GET">

            <input name="search"
                   class="typeahead form-control"
                   type="search"
                   placeholder="Search">
        </form>

                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-elements">
                    Toggle navigation

                </button>
                Thelia 2 API

Classes

Namespaces

Interfaces

Traits

Index

Search

class

Thelia

TaxEngine

TaxEngine

TaxEngine

    class
    TaxEngine

Class TaxEngine

Methods

                    __construct(
    Request $request)

No description

                    addTaxTypeDirectory(
    string $namespace,
    string $path_to_tax_type_classes)

Add a directroy which contains tax types classes. The tax engine
will scan this directory, and add all the tax type classes.

                    addTaxType(
    unknown $fullyQualifiedclassName)

Add a tax type to the current list.

                    getTaxTypeList()

No description

    null|TaxEngine

                    getDeliveryCountry()

Find Tax Country Id
First look for a picked delivery address country
Then look at the current customer default address country
Else look at the default website country

Details

at line 38

    __construct(
    Request $request)

Parameters

    Request
                $request

at line 53

    addTaxTypeDirectory(
    string $namespace,
    string $path_to_tax_type_classes)

Add a directroy which contains tax types classes. The tax engine
will scan this directory, and add all the tax type classes.

Parameters

    string
                $namespace
                the namespace of the classes in the directory

    string
                $path_to_tax_type_classes
                the path to the directory

at line 64

    addTaxType(
    unknown $fullyQualifiedclassName)

Add a tax type to the current list.

Parameters

    unknown
                $fullyQualifiedclassName
                the fully qualified classname, su chas MyTaxes\Taxes\MyTaxType

at line 69

    getTaxTypeList()

at line 117

    null|TaxEngine
    getDeliveryCountry()

Find Tax Country Id
First look for a picked delivery address country
Then look at the current customer default address country
Else look at the default website country

Return Value

    null|TaxEngine

        Generated by Sami, the API Documentation Generator.


text:
/*
The pk-get tool fetches blobs, files, and directories.

Examples

Writes to stdout by default:

  pk-get <blobref>                 // dump raw blob
  pk-get -contents <file-blobref>  // dump file contents

Like curl, lets you set output file/directory with -o:

  pk-get -o <dir> <blobref>
    (if <dir> exists and is directory, <blobref> must be a directory;
     use -f to overwrite any files)

  pk-get -o <filename> <file-blobref>

Camget isn't very fleshed out. In general, using 'pk-mount' to just
mount a tree is an easier way to get files back.
*/
package main // import "perkeep.org/cmd/pk-get"


text:
const float Zero = 0.0f;

@implementation DSPHelpers

+(void)deinterleave:(float *)data left:(float**)left right:(float**)right length:(vDSP_Length)length
{
    float* leftChannel = (float *)malloc((length + 2) * sizeof(float));
    float* rightChannel = (float *)malloc((length + 2) * sizeof(float));

    vDSP_vsadd(data, 2, &Zero, leftChannel, 1, length);
    vDSP_vsadd(data + 1, 2, &Zero, rightChannel, 1, length - 1);

    *left = leftChannel;
    *right = rightChannel;
}

+(void)channelData:(float**)deinterleavedData fromInterleavedData:(float*)data channel:(AudioChannel)channel amplifySignal:(float)multiplicand length:(vDSP_Length)length
{
    float* extractedData = (float *)malloc((length + 2) * sizeof(float));
    int position = (channel == kLeftChannel) ? 0 : 1;

    vDSP_vsmul(data + position, 2, &multiplicand, extractedData, 1, length - position);

    *deinterleavedData = extractedData;
}

@end


text:
include(CheckCXXCompilerFlag)
include(TestUndefinedSymbolsAllowed)

get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)

find_program(GIT_EXE NAMES ${PRFERRED_GIT_NAMES} git)

# Need to change a lot of what we would normally do as it doesn't apply to Emscripten.
if (EMSCRIPTEN)
    find_program(NODE_EXE NAMES ${PREFERRED_NODE_NAMES} node)
    find_program(NPM_EXE NAMES ${PREFERRED_NPM_NAMES} npm)
else ()
  if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18 AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
    set(_FIND_PYTHON_DEVELOPMENT_TYPE Development.Module)
    set(FIND_PYTHON_DEVELOPMENT_MODULE TRUE)
  else()
    set(_FIND_PYTHON_DEVELOPMENT_TYPE Development)
  endif()

  test_undefined_symbols_allowed()

  find_package(Python ${PREFERRED_PYTHON_VERSION} COMPONENTS Interpreter ${_FIND_PYTHON_DEVELOPMENT_TYPE})

  find_program(BUILDCACHE_EXE buildcache)
  if(NOT BUILDCACHE_EXE)
    if(MSVC)
      find_program(CLCACHE_EXE clcache)
    else()
      find_program(CCACHE_EXE ccache)
    endif()
  endif()
  find_program(CLANG_FORMAT_EXE NAMES ${PREFERRED_CLANG_FORMAT_NAMES} clang-format)
  find_program(CLANG_TIDY_EXE NAMES ${PREFERRED_CLANG_TIDY_NAMES} clang-tidy)
  find_program(FIND_EXE NAMES ${PREFERRED_FIND_NAMES} find)
  find_program(GCOV_EXE NAMES ${PREFERRED_GCOV_NAMES} gcov)
  find_program(LLVM_COV_EXE NAMES ${PREFERRED_LLVM_COV_NAMES} llvm-cov HINTS ${LLVM_BIN_DIR} /Library/Developer/CommandLineTools/usr/bin/)
  find_program(LLVM_PROFDATA_EXE NAMES ${PREFERRED_LLVM_PROFDATA_NAMES} llvm-profdata HINTS ${LLVM_BIN_DIR} /Library/Developer/CommandLineTools/usr/bin/)
  find_program(VALGRIND_EXE NAMES ${PREFERRED_VALGRIND_NAMES} valgrind)
  find_program(INSTALL_NAME_TOOL_EXE NAMES ${PREFERRED_INSTALL_NAME_TOOL_NAMES} install_name_tool)

  if(Python_Interpreter_FOUND)
    if(NOT DEFINED TEST_COVERAGE_RESULT)
      set(TEST_COVERAGE_RESULT -1 CACHE INTERNAL "Result of testing for Python coverage.")
      message(STATUS "Performing Test HAVE_COVERAGE")
      get_filename_component(PYTHON_DIR ${Python_EXECUTABLE} DIRECTORY)
      execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/python_package_check.py exclude-until-coverage-plugin
        RESULT_VARIABLE TEST_COVERAGE_RESULT OUTPUT_QUIET ERROR_QUIET)
      if(TEST_COVERAGE_RESULT EQUAL 0)
        set(HAVE_COVERAGE TRUE)
        message(STATUS "Performing Test HAVE_COVERAGE - Success")
      else()
        set(HAVE_COVERAGE FALSE)
        message(STATUS "Performing Test HAVE_COVERAGE - Failed")
      endif()
    endif()
  endif()

  find_package(Doxygen)
  find_package(Sphinx)
  find_package(SWIG 3)

  set(_ORIGINAL_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})

  set(CMAKE_REQUIRED_FLAGS -fprofile-instr-generate)
  check_cxx_compiler_flag("-fprofile-instr-generate -fcoverage-mapping" LLVM_COVERAGE_COMPILER_FLAGS_OK)

  set(CMAKE_REQUIRED_FLAGS "-fprofile-arcs -ftest-coverage")
  check_cxx_compiler_flag("-fprofile-arcs -ftest-coverage" GCC_COVERAGE_COMPILER_FLAGS_OK)

  set(CMAKE_REQUIRED_FLAGS ${_ORIGINAL_CMAKE_REQUIRED_FLAGS})

  if(MSVC)
    mark_as_advanced(CLCACHE_EXE)
  else()
    mark_as_advanced(CCACHE_EXE)
  endif()

  mark_as_advanced(
    BUILDCACHE_EXE
    CLANG_TIDY_EXE
    CLANG_FORMAT_EXE
    FIND_EXE
    GCC_COVERAGE_COMPILER_FLAGS_OK
    GCOV_EXE
    GIT_EXE
    INSTALL_NAME_TOOL_EXE
    LLVM_COV_EXE
    LLVM_COVERAGE_COMPILER_FLAGS_OK
    LLVM_PROFDATA_EXE
    SWIG_EXECUTABLE
    VALGRIND_EXE
  )
endif()

# Find libxml2
set(HAVE_LIBXML2_CONFIG FALSE)
# We want to use config mode for finding libXml2.
# This is especially important on Windows with Visual Studio.
# To do this we need to have two find_package calls and explicitly state that
# we wish to use Config mode in the first call.  Finding LibXml2 in config mode
# is the preferred method so we will try this first quietly.
#
# This does change how we get information about include paths and such so we
# need to track how we found LibXml2.
find_package(LibXml2 CONFIG QUIET)
if(LibXml2_FOUND)
  if(TARGET z)
    set(HAVE_ZLIB_TARGET TRUE)
    get_target_property(ZLIB_TARGET_TYPE z TYPE)
  else()
    find_package(ZLIB CONFIG QUIET)
    if(ZLIB_FOUND)
      if(TARGET z)
        set(HAVE_ZLIB_TARGET TRUE)
        get_target_property(ZLIB_TARGET_TYPE z TYPE)
      endif()
    else()
      find_package(ZLIB REQUIRED)
    endif()
  endif()
  set(HAVE_LIBXML2_CONFIG TRUE)
  # Different versions of LibXml2 have different names for the library target.
  # We try and capture that here.
  if(TARGET xml2)
    set(LIBXML2_TARGET_NAME xml2)
  elseif(TARGET LibXml2)
    set(LIBXML2_TARGET_NAME LibXml2)
  else()
    message(FATAL_ERROR "FindLibXml2: Found configuration file for LibXml2 but could not determine a target name from it.")
  endif()
  get_target_property(LIBXML2_TARGET_TYPE ${LIBXML2_TARGET_NAME} TYPE)
  set(HAVE_LIBXML2_TARGET TRUE)
  # Clear out GUI variables created in module search mode.
  foreach(_XML2_VAR LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR LIBXML2_XMLLINT_EXECUTABLE)
    if(DEFINED ${_XML2_VAR} AND NOT ${${_XML2_VAR}})
      unset(${_XML2_VAR} CACHE)
    endif()
  endforeach()
else()
  find_package(LibXml2 REQUIRED)
  if(TARGET z)
    set(HAVE_ZLIB_TARGET TRUE)
  else()
    find_package(ZLIB REQUIRED)
  endif()
  if(LibXml2_FOUND)
    # Clear out GUI variable created in config search mode.
    unset(LibXml2_DIR CACHE)
  endif()
endif()

if(BUILDCACHE_EXE OR CLCACHE_EXE OR CCACHE_EXE)
  set(COMPILER_CACHE_AVAILABLE TRUE CACHE INTERNAL "Executable required to cache compilations.")
endif()

if(CLANG_FORMAT_EXE)
  set(CLANG_FORMAT_VERSION_MINIMUM 11)
  execute_process(COMMAND ${CLANG_FORMAT_EXE} -version
                  OUTPUT_VARIABLE CLANG_FORMAT_VERSION
                  ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
  string(REGEX REPLACE "^.*clang-format version ([.0-9]+).*$" "\\1" CLANG_FORMAT_VERSION "${CLANG_FORMAT_VERSION}")

  if(CLANG_FORMAT_VERSION VERSION_LESS CLANG_FORMAT_VERSION_MINIMUM)
    message(STATUS "ClangFormat ${CLANG_FORMAT_VERSION} was found, but version ${CLANG_FORMAT_VERSION_MINIMUM}+ is needed to use ClangFormat")
  else()
    set(CLANG_FORMAT_AVAILABLE TRUE CACHE INTERNAL "Executable required to use ClangFormat is available.")

    if(GIT_EXE)
      set(CLANG_FORMAT_TESTING_AVAILABLE TRUE CACHE INTERNAL "Executables required to run the ClangFormat test are available.")
    endif()
  endif()
endif()

if(IS_MULTI_CONFIG)
  set(CONFIG_DIR_SUFFIX "/$<CONFIG>")
endif()

if(CLANG_TIDY_EXE)
  set(CLANG_TIDY_AVAILABLE TRUE CACHE INTERNAL "Executable required to perform static analysis is available.")
endif()

if(FIND_EXE AND GCOV_EXE AND Python_Interpreter_FOUND AND GCC_COVERAGE_COMPILER_FLAGS_OK)
  set(COVERAGE_TESTING_AVAILABLE TRUE CACHE INTERNAL "Executables required to run the coverage testing are available.")
endif()

if(SWIG_EXECUTABLE)
  set(BINDINGS_AVAILABLE TRUE CACHE INTERNAL "Executable required to generate bindings is available.")
endif()

if(BINDINGS_AVAILABLE AND (Python_Development.Module_FOUND OR Python_Development_FOUND))
  set(PYTHON_BINDINGS_AVAILABLE TRUE CACHE INTERNAL "Requirements for creating Python bindings are available.")
endif()

if(VALGRIND_EXE AND Python_Interpreter_FOUND)
  set(VALGRIND_TESTING_AVAILABLE TRUE CACHE INTERNAL "Executable required to run valgrind testing is available.")
endif()

if(LLVM_PROFDATA_EXE AND LLVM_COV_EXE AND FIND_EXE AND LLVM_COVERAGE_COMPILER_FLAGS_OK)
  set(LLVM_COVERAGE_TESTING_AVAILABLE TRUE CACHE INTERNAL "Executables required to run the llvm coverage testing are available.")
endif()

if(INSTALL_NAME_TOOL_EXE)
  set(INSTALL_NAME_TOOL_AVAILABLE TRUE CACHE INTERNAL "Executable required for manipulating dynamic library paths is available.")
endif()

if(HAVE_COVERAGE)
  set(PYTHON_COVERAGE_TESTING_AVAILABLE TRUE CACHE INTERNAL "Module required to run Python coverage testing is available.")
endif()

if(WIN32 AND NOT EMSCRIPTEN)
  find_program(MAKENSIS_EXE NAMES ${PREFERRED_NSIS_NAMES} makensis
    HINTS "C:/Program\ Files/NSIS/" "C:/Program\ Files\ (x86)/NSIS/")
  mark_as_advanced(MAKENSIS_EXE)
  if(MAKENSIS_EXE)
    set(NSIS_FOUND TRUE)
  else()
    set(NSIS_FOUND FALSE)
  endif()
endif()

if(EMSCRIPTEN AND NODE_EXE AND NPM_EXE)
    set(JAVASCRIPT_BINDINGS_TESTING_AVAILABLE TRUE CACHE INTERNAL "Executables required to run the javascript bindings tests are available.")
endif()


text:
<?php

namespace Bolt\Filesystem;

use Bolt\Filesystem\Exception\FileNotFoundException;
use Bolt\Filesystem\Handler\FileInterface;
use Bolt\Filesystem\Handler\ImageInterface;

/**
 * This is designed to help migrate us to our new filesystem abstraction which
 * requires mount points. During this transition period we need to be able to
 * match paths without mount points to a filesystem.
 *
 * @author Carson Full <carsonfull@gmail.com>
 */
class Matcher
{
    /** @var FilesystemInterface */
    protected $filesystem;
    /** @var string[] */
    protected $filesystemsToCheck;

    /**
     * Constructor.
     *
     * @param FilesystemInterface $filesystem
     * @param string[]            $filesystemsToCheck
     */
    public function __construct(FilesystemInterface $filesystem, array $filesystemsToCheck)
    {
        $this->filesystem = $filesystem;
        $this->filesystemsToCheck = $filesystemsToCheck;
    }

    /**
     * Gets the file object for the path given. Paths with the mount point included are
     * preferred, but are not required for BC. If the mount point is not included a list
     * of filesystems are checked and chosen if the file exists in that filesystem.
     *
     * @param FileInterface|string $path
     *
     * @throws FileNotFoundException If file was not found.
     *
     * @return FileInterface
     */
    public function getFile($path)
    {
        if ($path instanceof FileInterface) {
            return $path;
        }

        if (!$this->filesystem instanceof AggregateFilesystemInterface || $this->containsMountPoint($path)) {
            $file = $this->filesystem->getFile($path);
            if (!$file->exists()) {
                throw new FileNotFoundException($path);
            }

            return $file;
        }

        // Trim "files/" from front of path for BC.
        if (strpos($path, 'files/') === 0) {
            $path = substr($path, 6);
        }

        foreach ($this->filesystemsToCheck as $mountPoint) {
            if (!$this->filesystem->hasFilesystem($mountPoint)) {
                continue;
            }

            $file = $this->filesystem->getFile("$mountPoint://$path");
            if ($file->exists()) {
                return $file;
            }
        }

        throw new FileNotFoundException($path);
    }

    /**
     * Same as {@see getFile} for images.
     *
     * @param ImageInterface|string $path
     *
     * @throws FileNotFoundException If file was not found.
     *
     * @return ImageInterface
     */
    public function getImage($path)
    {
        if ($path instanceof ImageInterface) {
            return $path;
        }

        $file = $this->getFile($path);

        return $this->filesystem->getImage($file->getFullPath());
    }

    /**
     * Change if a path contains a mount point.
     *
     * Ex: files://foo.jpg
     *
     * @param string $path
     *
     * @return bool
     */
    private function containsMountPoint($path)
    {
        return (bool) preg_match('#^.+\:\/\/.*#', $path);
    }
}