Пример #1
0
function extensions_grid($list)
{
    global $layout;
    global $user;
    global $current_version;
    $navibars = new navibars();
    $navibars->title(t(327, 'Extensions'));
    $marketplace = isset($_REQUEST['marketplace']);
    if ($user->permission("extensions.install") == "true") {
        $navibars->add_actions(array('<a href="#" id="extension-upload-button"><img height="16" align="absmiddle" width="16" src="img/icons/silk/package_add.png"> ' . t(461, 'Install from file') . '</a>'));
    }
    if (!$marketplace) {
        $navibars->add_actions(array('search_form'));
    }
    $grid = new navigrid('extensions');
    $grid->set_header('
        <div class="navibrowse-path ui-corner-all">
            <input type="checkbox" id="extension-available-button" /><label for="extension-available-button"><img src="img/icons/silk/plugin.png" width="16px" height="16px" align="absbottom" /> ' . t(528, 'Available') . '</label>
            ' . ($user->permission("extensions.marketplace") == "true" ? '<input type="checkbox" id="extension-marketplace-button" /><label for="extension-marketplace-button"><img src="img/icons/silk/basket.png" width="16px" height="16px" align="absbottom" /> ' . t(527, 'Marketplace') . '</label>' : '') . '
        </div>
	');
    $layout->add_script('
        $("#extension-available-button").button().on("click", function()
        {
            window.location.replace("?fid=extensions");
        });
        $("#extension-marketplace-button").button();
        $("#extension-marketplace-button").button().on("click", function()
        {
            window.location.replace("?fid=extensions&marketplace");
        });

        $(".navibrowse-path input").removeAttr("checked");
        $("#extension-' . ($marketplace ? 'marketplace' : 'available') . '-button").attr("checked", "checked");
        $("#extension-marketplace-button,#extension-available-button").button("refresh");
    ');
    if (!$marketplace) {
        $grid->item_size(220, 220);
        $grid->thumbnail_size(205, 145);
        $extensions = array();
        for ($i = 0; $i < count($list); $i++) {
            $extensions[] = array('id' => $list[$i]['code'], 'name' => '<div class="navigrid-item-title">' . $list[$i]['title'] . '<br />v' . $list[$i]['version'] . '</div>', 'thumbnail' => NAVIGATE_URL . '/plugins/' . $list[$i]['code'] . '/thumbnail.png', 'description' => $list[$i]['description'], 'header' => '', 'footer' => '
                    <div class="buttonset navigrid-item-buttonset" style=" font-size: 0.6em; margin-top: 5px; visibility: hidden; "
                         extension="' . $list[$i]['code'] . '" extension-title="' . $list[$i]['title'] . '"
                         run="' . $list[$i]['run'] . '" enabled="' . $list[$i]['enabled'] . '"  favorite="' . $list[$i]['favorite'] . '">
                        <button class="navigrid-extensions-info" title="' . t(457, 'Information') . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/information.png"></button>' . (empty($list[$i]['options']) ? '' : '<button class="navigrid-extensions-settings" title="' . t(459, 'Settings') . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/cog.png"></button>') . (empty($list[$i]['update']) || $user->permission("extensions.update") == "false" ? '' : '<button class="navigrid-extensions-update" title="' . t(463, 'Update available') . ': ' . $list[$i]['update'] . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/asterisk_orange.png"></button>') . '<button ' . ($list[$i]['enabled'] === '0' ? 'style="display: none;"' : '') . ' class="navigrid-extensions-disable" title="' . t(460, 'Disable') . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/delete.png"></button>' . '<button ' . ($list[$i]['enabled'] === '1' ? 'style="display: none;"' : '') . ' class="navigrid-extensions-enable" title="' . t(462, 'Enable') . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"></button>' . ($user->permission("extensions.delete") == "true" ? '<button ' . ($list[$i]['enabled'] === '1' ? 'style="display: none;"' : '') . ' class="navigrid-extensions-remove" title="' . t(35, 'Delete') . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/cross.png"></button>' : '') . '
                    </div>
                ');
        }
        $grid->items($extensions);
        $navibars->add_content($grid->generate());
        $navibars->add_content('<div id="navigrid-extension-information" title="" style=" display: none; "></div>');
        $navibars->add_content('<div id="navigrid-extension-options" title="" style=" display: none; "></div>');
        $navibars->add_content('
            <div id="navigrid-extensions-remove-confirmation" title="' . t(59, 'Confirmation') . '" style=" display: none; ">
                ' . t(57, 'Do you really want to delete the item?') . '
            </div>');
        $navibars->add_content('
            <div id="navigrid-extensions-update" title="' . t(285, 'Update') . '" style=" display: none; ">
                <iframe src="about:blank"
                    class="ui-corner-all"
                    border="0" frameborder="0" allowtransparency="true">
                </iframe>
            </div>');
        $out = $navibars->generate();
        $layout->add_script('
            $(window).on("load", function()
            {
                $(".navigrid-item-buttonset").each(function(i, el)
                {
                    $(el).hide().css("visibility", "visible");
                    $(el).fadeIn();
                    $(".navigrid-extensions-disable").addClass("ui-corner-right");
                });
            });

            $.getScript("lib/packages/extensions/extensions.js?r=' . $current_version->revision . '", function()
            {
                navigate_extensions_refresh();
            });

            function navitable_quicksearch(value)
            {
                $(".navigrid-item").hide();

                if(value=="")
                    $(".navigrid-item").show();
                else
                {
                    $(".navigrid-item").each(function(i, el)
                    {
                        var item_text = $(el).text().toLowerCase();
                        if( item_text.indexOf(value.toLowerCase()) >= 0 )
                            $(el).fadeIn();
                    });
                }
            }
            $("#extension-upload-button").bind("click", function()
            {
                $("#extension-upload-button").parent().find("form").remove();
                $("#extension-upload-button").after(\'<form action="?fid=extensions&act=extension_upload" enctype="multipart/form-data" method="post"><input type="file" name="extension-upload" style=" display: none;" /></form>\');
                $("#extension-upload-button").next().find("input").bind("change", function()
                {
                    if($(this).val()!="")
                        $(this).parent().submit();
                });
                $("#extension-upload-button").next().find("input").trigger("click");

                return false;
            });

        ');
    } else {
        $html = '
            <div class="navibrowse-path ui-corner-all">
                <input type="checkbox" id="extension-available-button" /><label for="extension-available-button"><img src="img/icons/silk/rainbow.png" width="16px" height="16px" align="absbottom" /> ' . t(528, 'Available') . '</label>
                <input type="checkbox" id="extension-marketplace-button" /><label for="extension-marketplace-button"><img src="img/icons/silk/basket.png" width="16px" height="16px" align="absbottom" /> ' . t(527, 'Marketplace') . '</label>
            </div>
        ';
        $html .= '
            <iframe src="http://www.navigatecms.com/en/marketplace/extensions"
                    style="visibility: hidden; width: 1px; height: 1px;"
                    class="ui-corner-all"
                    border="0" frameborder="0" allowtransparency="true">
            </iframe>
        ';
        $navibars->add_content('<div id="navigate-content-safe" class="ui-corner-all">' . $html . '</div>');
        $layout->add_script('
            $(window).on("resize focus blur", function()
            {
                $("#navigate-content-safe iframe").css({"width": 1, "height": 1});

                $("#navigate-content-safe iframe").css({
                    padding: "0px 4px",
                    width: $(".navibrowse-path").width() + parseInt($(".navibrowse-path").css("padding-right")) * 2,
                    height: $("#navigate-content-safe").height() - $("#navigate-content-safe div:first").height() - 24,
                    visibility: "visible"
                });
            });

            $("#navigate-content-safe iframe").on("focus blur load", function(){ $(window).trigger("resize");});
        ');
        $out = $navibars->generate();
    }
    $layout->add_script('
        function navigatecms_marketplace_install_from_hash(hash)
        {
            window.location.replace("?fid=extensions&act=install_from_hash&hash="+hash);
        }

        if(typeof(window.postMessage) != "undefined")
        {
           if(typeof(window.addEventListener) != "undefined")
            {
                window.addEventListener("message", function(event) {
                    navigatecms_marketplace_install_from_hash(event.data);
                }, false);
            }
            else
            {
                window.attachEvent("onmessage", function(e) {
                    navigatecms_marketplace_install_from_hash(e.data);
                });
            }
        }
    ');
    return $out;
}
Пример #2
0
function themes_grid($list)
{
    global $layout;
    global $website;
    global $user;
    global $current_version;
    $navibars = new navibars();
    $navibars->title(t(367, 'Themes'));
    $marketplace = isset($_REQUEST['marketplace']);
    if ($user->permission("themes.install") == "true") {
        $navibars->add_actions(array('<a href="#" id="theme-upload-button"><img height="16" align="absmiddle" width="16" src="img/icons/silk/package_add.png"> ' . t(461, 'Install from file') . '</a>'));
    }
    $navibars->add_actions(array('<a href="?fid=themes&act=theme_sample_content_export" id="theme-sample-content-export-button"><img height="16" align="absmiddle" width="16" src="img/icons/silk/server_compressed.png"> ' . t(480, 'Export sample content') . '</a>'));
    $grid = new navigrid('themes');
    $grid->set_header('
        <div class="navibrowse-path ui-corner-all">
            <input type="checkbox" id="theme-available-button" /><label for="theme-available-button"><img src="img/icons/silk/rainbow.png" width="16px" height="16px" align="absbottom" /> ' . t(528, 'Available') . '</label>
            ' . ($user->permission("themes.marketplace") == "true" ? '<input type="checkbox" id="theme-marketplace-button" /><label for="theme-marketplace-button"><img src="img/icons/silk/basket.png" width="16px" height="16px" align="absbottom" /> ' . t(527, 'Marketplace') . '</label>' : '') . '
        </div>
	');
    $layout->add_script('
        $("#theme-available-button").button().on("click", function()
        {
            window.location.replace("?fid=themes");
        });
        $("#theme-marketplace-button").button();
        $("#theme-marketplace-button").button().on("click", function()
        {
            window.location.replace("?fid=themes&marketplace");
        });

        $(".navibrowse-path input").removeAttr("checked");
        $("#theme-' . ($marketplace ? 'marketplace' : 'available') . '-button").attr("checked", "checked");
        $("#theme-marketplace-button,#theme-available-button").button("refresh");
    ');
    if (!$marketplace) {
        $grid->item_size(220, 220);
        //$grid->thumbnail_size(138, 150); NV 1.x thumbnail size
        $grid->thumbnail_size(205, 145);
        $grid->highlight_on_click = false;
        $themes = array();
        // current website theme
        if (!empty($website->theme)) {
            $theme = new theme();
            $theme->load($website->theme, true);
            $update_ver = $_SESSION['themes_updates'][$theme->name];
            if (version_compare($update_ver, $theme->version, '<=')) {
                $update_ver = '';
            } else {
                $update_ver = $theme->version . ' &raquo; ' . $update_ver;
            }
            $themes[] = array('id' => $website->theme, 'name' => '<div class="navigrid-themes-title navigrid-themes-installed">' . $theme->title . '</div>', 'thumbnail' => NAVIGATE_URL . '/themes/' . $website->theme . '/thumbnail.png', 'header' => '
                ' . (file_exists(NAVIGATE_PATH . '/themes/' . $website->theme . '/' . $website->theme . '.info.html') ? '<a href="#" class="navigrid-themes-info" theme="' . $website->theme . '" theme-title="' . $theme->title . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/information.png"></a>' : '') . '
                ' . (empty($update_ver) ? '' : '
                    <a href="#" class="navigrid-themes-update" theme="' . $website->theme . '" title="' . t(285, "Update") . ' ' . $update_ver . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/asterisk_orange.png"></a>
                '), 'footer' => '
                    <a href="?fid=websites&act=edit&id=' . $website->id . '&tab=7" class="uibutton navigrid-themes-button navigrid-theme-configure"><img height="16" align="absmiddle" width="16" src="img/icons/silk/wrench_orange.png"> ' . t(200, 'Options') . '</a>
                ' . (!file_exists(NAVIGATE_PATH . '/themes/' . $website->theme . '/' . $website->theme . '_sample.zip') ? '' : '<a href="#" class="uibutton navigrid-themes-button navigrid-theme-install-demo"><img height="16" align="absmiddle" width="16" src="img/icons/silk/wand.png"> ' . t(484, 'Install demo') . '</a>'));
        }
        for ($t = 0; $t < count($list); $t++) {
            if ($website->theme == $list[$t]['code']) {
                continue;
            }
            $update_ver = $_SESSION['themes_updates'][$list[$t]['code']];
            if (version_compare($update_ver, $list[$t]['version'], '<=')) {
                $update_ver = '';
            } else {
                $update_ver = $list[$t]['version'] . ' &raquo; ' . $update_ver;
            }
            $themes[] = array('id' => $list[$t]['code'], 'name' => '<div class="navigrid-themes-title">' . $list[$t]['title'] . '</div>', 'thumbnail' => NAVIGATE_URL . '/themes/' . $list[$t]['code'] . '/thumbnail.png', 'header' => '
                    ' . ($user->permission("themes.delete") == "true" ? '<a href="#" class="navigrid-themes-remove" theme="' . $list[$t]['code'] . '" theme-title="' . $list[$t]['title'] . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/cancel.png"></a>' : '') . '
                    ' . (file_exists(NAVIGATE_PATH . '/themes/' . $list[$t]['code'] . '/' . $list[$t]['code'] . '.info.html') ? '<a href="#" class="navigrid-themes-info" theme="' . $list[$t]['code'] . '" theme-title="' . $list[$t]['title'] . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/information.png"></a>' : '') . '
                    ' . (empty($update_ver) ? '' : '
                    ' . ($user->permission("themes.update") == "true" ? '<a href="#" class="navigrid-themes-update" theme="' . $list[$t]['code'] . '" title="' . t(285, "Update") . ' ' . $update_ver . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/asterisk_orange.png"></a>' : '') . '
                '), 'footer' => '
                    ' . (file_exists(NAVIGATE_PATH . '/themes/' . $list[$t]['code'] . '/demo.html') ? '<a href="' . NAVIGATE_URL . '/themes/' . $list[$t]['code'] . '/demo.html' . '" class="uibutton navigrid-themes-button" target="_blank"><img height="16" align="absmiddle" width="16" src="img/icons/silk/monitor.png"> ' . t(274, 'Preview') . '</a>' : '') . '
                    <a href="#" class="uibutton navigrid-themes-button navigrid-themes-install" theme="' . $list[$t]['code'] . '" target="_blank" style=" margin-left: 5px; "><img height="16" align="absmiddle" width="16" src="img/icons/silk/world_go.png"> ' . t(365, 'Install') . '</a>
                ');
        }
        $grid->items($themes);
        $navibars->add_content($grid->generate());
        $navibars->add_content('
            <div id="navigrid-themes-install-confirmation" title="' . t(59, 'Confirmation') . '" style=" display: none; ">
                ' . t(371, 'Installing a new theme removes the settings of the old one.') . '<br />
                ' . t(372, 'The list of available block types may also change.') . '<br /><br />
                ' . t(373, 'Are you sure you want to continue?') . '
            </div>

            <div id="navigrid-themes-information" title="" style=" display: none; "></div>
        ');
        $navibars->add_content('
            <div id="navigrid-themes-install-demo-confirmation" title="' . t(59, 'Confirmation') . '" style=" display: none; ">
                ' . t(483, 'Do you really want to import the default website for the theme selected?') . '
            </div>');
        $navibars->add_content('
            <div id="navigrid-themes-remove-confirmation" title="' . t(59, 'Confirmation') . '" style=" display: none; ">
                ' . t(57, 'Do you really want to delete the item?') . '
            </div>');
        $navibars->add_content('
            <div id="navigrid-themes-update" title="' . t(285, 'Update') . '" style=" display: none; ">
                <iframe src="about:blank"
                    class="ui-corner-all"
                    border="0" frameborder="0" allowtransparency="true">
                </iframe>
            </div>');
    } else {
        $html = '
            <div class="navibrowse-path ui-corner-all">
                <input type="checkbox" id="theme-available-button" /><label for="theme-available-button"><img src="img/icons/silk/rainbow.png" width="16px" height="16px" align="absbottom" /> ' . t(528, 'Available') . '</label>
                <input type="checkbox" id="theme-marketplace-button" /><label for="theme-marketplace-button"><img src="img/icons/silk/basket.png" width="16px" height="16px" align="absbottom" /> ' . t(527, 'Marketplace') . '</label>
            </div>
        ';
        $html .= '
            <iframe src="http://www.navigatecms.com/en/marketplace/themes"
                    style="visibility: hidden; width: 1px; height: 1px;"
                    class="ui-corner-all"
                    border="0" frameborder="0" allowtransparency="true">
            </iframe>
        ';
        $navibars->add_content('<div id="navigate-content-safe" class="ui-corner-all">' . $html . '</div>');
        $layout->add_script('
            $(window).on("resize focus blur", function()
            {
                $("#navigate-content-safe iframe").css({"width": 1, "height": 1});

                $("#navigate-content-safe iframe").css({
                    padding: "0px 4px",
                    width: $(".navibrowse-path").width() + parseInt($(".navibrowse-path").css("padding-right")) * 2,
                    height: $("#navigate-content-safe").height() - $("#navigate-content-safe div:first").height() - 24,
                    visibility: "visible"
                });
            });

            $("#navigate-content-safe iframe").on("focus blur load", function(){ $(window).trigger("resize");});
        ');
    }
    $layout->add_script('
        function navigatecms_marketplace_install_from_hash(hash)
        {
            window.location.replace("?fid=themes&act=install_from_hash&hash="+hash);
        }

        if(typeof(window.postMessage) != "undefined")
        {
           if(typeof(window.addEventListener) != "undefined")
            {
                window.addEventListener("message", function(event) {
                    navigatecms_marketplace_install_from_hash(event.data);
                }, false);
            }
            else
            {
                window.attachEvent("onmessage", function(e) {
                    navigatecms_marketplace_install_from_hash(e.data);
                });
            }
        }
    ');
    $out = $navibars->generate();
    $layout->add_script('
		$.getScript("lib/packages/themes/themes.js?r=' . $current_version->revision . '", function()
		{
			navigate_themes_init();
		});
	');
    return $out;
}