Ejemplo n.º 1
0
function run()
{
    $out = '';
    switch (@$_REQUEST['act']) {
        case 'grid_note_background':
            grid_notes::background($_REQUEST['object'], $_REQUEST['id'], $_REQUEST['background']);
            core_terminate();
            break;
        case 'grid_notes_comments':
            $comments = grid_notes::comments($_REQUEST['object'], $_REQUEST['id'], false);
            echo json_encode($comments);
            core_terminate();
            break;
        case 'grid_notes_add_comment':
            echo grid_notes::add_comment($_REQUEST['object'], $_REQUEST['id'], $_REQUEST['comment'], $_REQUEST['background']);
            core_terminate();
            break;
        case 'grid_note_remove':
            echo grid_notes::remove($_REQUEST['id']);
            core_terminate();
            break;
        default:
    }
    return $out;
}
Ejemplo n.º 2
0
function items_form($item)
{
    global $user;
    global $DB;
    global $website;
    global $layout;
    global $theme;
    global $events;
    global $current_version;
    $navibars = new navibars();
    $naviforms = new naviforms();
    $layout->navigate_media_browser();
    // we can use media browser in this function
    $extra_actions = array();
    if (empty($item->id)) {
        $navibars->title(t(22, 'Items') . ' / ' . t(38, 'Create'));
    } else {
        $navibars->title(t(22, 'Items') . ' / ' . t(170, 'Edit') . ' [' . $item->id . ']');
    }
    $navibars->add_actions(array('<a href="#" onclick="javascript: navigate_media_browser();" title="Ctrl+M">
				<img height="16" align="absmiddle" width="16" src="img/icons/silk/images.png"> ' . t(36, 'Media') . '
			</a>'));
    if (empty($item->id)) {
        $navibars->add_actions(array($user->permission('items.create') == 'true' ? '<a href="#" onclick="navigate_items_tabform_submit(1);" title="Ctrl+S">
					<img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '
				</a>' : ""));
    } else {
        $navibars->add_actions(array($user->permission('items.edit') == 'true' || $item->author == $user->id ? '<a href="#" onclick="navigate_items_tabform_submit(1);" title="Ctrl+S">
					<img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '
				</a>' : "", $user->permission("items.delete") == 'true' ? '<a href="#" onclick="navigate_delete_dialog();">
					<img height="16" align="absmiddle" width="16" src="img/icons/silk/cancel.png"> ' . t(35, 'Delete') . '
				</a>' : ""));
        $extra_actions[] = '<a href="#" onclick="navigate_items_preview();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/monitor.png"> ' . t(274, 'Preview') . '</a>';
        if ($user->permission("items.create") != 'false') {
            $extra_actions[] = '<a href="?fid=items&act=duplicate&id=' . $item->id . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/page_copy.png"> ' . t(477, 'Duplicate') . '</a>';
        }
        $layout->add_script('
            function navigate_delete_dialog()
            {
                navigate_confirmation_dialog(
                    function() { window.location.href = "?fid=items&act=delete&id=' . $item->id . '"; }, 
                    null, null, "' . t(35, 'Delete') . '"
                );
            }
        ');
    }
    if (!empty($item->id)) {
        $notes = grid_notes::comments('item', $item->id);
        $navibars->add_actions(array('<a href="#" onclick="javascript: navigate_display_notes_dialog();">
					<span class="navigate_grid_notes_span" style=" width: 20px; line-height: 16px; ">' . count($notes) . '</span>
					<img src="img/skins/badge.png" width="20px" height="18px" style="margin-top: -2px;" class="grid_note_edit" align="absmiddle" /> ' . t(168, 'Notes') . '
				</a>'));
    }
    if (!empty($item->id)) {
        // we attach an event to "items" which will be fired by navibars to put an extra button
        $events->add_actions('items', array('item' => &$item, 'navibars' => &$navibars), $extra_actions);
    }
    if (!empty($item->id)) {
        $layout->navigate_notes_dialog('item', $item->id);
    }
    $navibars->add_actions(array(!empty($item->id) ? '<a href="?fid=items&act=edit"><img height="16" align="absmiddle" width="16" src="img/icons/silk/add.png"> ' . t(38, 'Create') . '</a>' : '', '<a href="?fid=items&act=list"><img height="16" align="absmiddle" width="16" src="img/icons/silk/application_view_list.png"> ' . t(39, 'List') . '</a>', 'search_form'));
    // languages
    $ws_languages = $website->languages();
    $navibars->form('', 'fid=items&act=edit&id=' . $item->id);
    $layout->add_script("\r\n        \$(document).on('keydown.ctrl_s', function (evt) { navigate_items_tabform_submit(1); return false; } );\r\n        \$(document).on('keydown.ctrl_m', function (evt) { navigate_media_browser(); return false; } );\r\n    ");
    $layout->add_script('
		var template_sections = [];	
	');
    $navibars->add_tab(t(43, "Main"));
    // tab #0
    $navibars->add_tab_content($naviforms->hidden('form-sent', 'true'));
    $navibars->add_tab_content($naviforms->hidden('id', $item->id));
    $navibars->add_tab_content_row(array('<label>ID</label>', '<span>' . (!empty($item->id) ? $item->id : t(52, '(new)')) . '</span>'));
    if (empty($item->id)) {
        $item->date_to_display = core_time();
    }
    $navibars->add_tab_content_row(array('<label>' . t(551, 'Date to display') . '</label>', $naviforms->datefield('date_to_display', $item->date_to_display, true)));
    $navibars->add_tab_content_row(array('<label>' . t(85, 'Date published') . '</label>', $naviforms->datefield('date_published', $item->date_published, true)));
    $navibars->add_tab_content_row(array('<label>' . t(90, 'Date unpublished') . '</label>', $naviforms->datefield('date_unpublish', $item->date_unpublish, true)));
    $navibars->add_tab_content_row(array('<label>' . t(364, 'Access') . '</label>', $naviforms->selectfield('access', array(0 => 0, 1 => 2, 2 => 1, 3 => 3), array(0 => t(254, 'Everybody'), 1 => t(362, 'Not signed in'), 2 => t(361, 'Web users only'), 3 => t(512, 'Selected web user groups')), $item->access, 'navigate_webuser_groups_visibility($(this).val());', false, array(1 => t(363, 'Users who have not yet signed in')))));
    $webuser_groups = webuser_group::all_in_array();
    $navibars->add_tab_content_row(array('<label>' . t(506, "Groups") . '</label>', $naviforms->multiselect('groups', array_keys($webuser_groups), array_values($webuser_groups), $item->groups)), 'webuser-groups-field');
    $layout->add_script('
        function navigate_webuser_groups_visibility(access_value)
        {
            if(access_value==3)
                $("#webuser-groups-field").show();
            else
                $("#webuser-groups-field").hide();
        }

        navigate_webuser_groups_visibility(' . $item->access . ');
    ');
    $permission_options = array(0 => t(69, 'Published'), 1 => t(70, 'Private'), 2 => t(81, 'Hidden'));
    if ($user->permission("items.publish") == 'false') {
        if (!isset($item->permission)) {
            $item->permission = 1;
        }
        $navibars->add_tab_content_row(array('<label>' . t(68, 'Status') . '</label>', $permission_options[$item->permission], $naviforms->hidden("permission", $item->permission)));
    } else {
        $navibars->add_tab_content_row(array('<label>' . t(68, 'Status') . '</label>', $naviforms->selectfield('permission', array_keys($permission_options), array_values($permission_options), $item->permission, '', false, array(0 => t(360, 'Visible to everybody'), 1 => t(359, 'Visible only to Navigate CMS users'), 2 => t(358, 'Hidden to everybody'))), '<span id="status_info" class="ui-icon ui-icon-alert"
                       data-message="' . t(618, 'Change the status to Published to see the item on the future publication date currently assigned', false, true) . '"
					   style="display: none; float: none; vertical-align: middle; "></span>'));
    }
    if (empty($item->id)) {
        $item->author = $user->id;
    }
    $author_webuser = $DB->query_single('username', 'nv_users', ' id = ' . $item->author);
    $navibars->add_tab_content($naviforms->hidden('item-author', $item->author));
    $navibars->add_tab_content_row(array('<label>' . t(266, 'Author') . '</label>', $naviforms->textfield('item-author-text', $author_webuser)));
    // script#1
    if ($item->date_modified > 0) {
        $navibars->add_tab_content_row(array('<label>' . t(227, 'Date modified') . '</label>', core_ts2date($item->date_modified, true)));
    }
    if ($item->date_created > 0) {
        $navibars->add_tab_content_row(array('<label>' . t(226, 'Date created') . '</label>', core_ts2date($item->date_created, true)));
    }
    $navibars->add_tab_content_row(array('<label>' . t(280, 'Page views') . '</label>', $item->views), "div_page_views");
    $navibars->add_tab(t(87, "Association"));
    // tab #1
    $navibars->add_tab_content_row(array('<label>' . t(87, "Association") . '</label>', $naviforms->buttonset('association', array('free' => t(100, 'Free'), 'category' => t(78, 'Category')), empty($item->id) ? 'category' : $item->association, "navigate_change_association(this);")));
    $hierarchy = structure::hierarchy(0);
    $categories_list = structure::hierarchyList($hierarchy, $item->category);
    if (empty($categories_list)) {
        $categories_list = '<ul><li value="0">' . t(428, '(no category)') . '</li></ul>';
    }
    $navibars->add_tab_content_row(array('<label>' . t(78, 'Category') . '</label>', $naviforms->dropdown_tree('category', $categories_list, $item->category, 'navigate_item_category_change')), 'div_category_tree');
    $layout->add_script('
        function navigate_item_category_change(id)
        {
            $.ajax(
            {
                url: NAVIGATE_APP + "?fid=" + navigate_query_parameter("fid") + "&act=96&id=" + id,
                dataType: "json",
                data: {},
                success: function(data, textStatus, xhr)
                {
                    item_category_path = data;
                }
            });
        }
    ');
    $navibars->add_tab_content_row(array('<label>' . t(162, 'Embedding') . '</label>', $naviforms->buttonset('embedding', array('1' => t(163, 'Embedded'), '0' => t(164, 'Own path')), empty($item->id) ? '1' : intval($item->embedding), "navigate_change_association();"), '<span id="embedding_info" class="ui-icon ui-icon-info"
			        data-message-title-1="' . t(163, 'Embedded', false, true) . '"
					data-message-content-1="' . t(165, 'Full content is shown on category page. Ex. "Who we are?"', false, true) . '"
					data-message-title-2="' . t(164, 'Own path', false, true) . '"
					data-message-content-2="' . t(166, 'The content is accessed through its own url. Ex. "News"', false, true) . '" 
					style="float: left; margin-left: -4px;">
			</span>'), 'div_category_embedded');
    $navibars->add_tab_content_row(array('<label>' . t(22, 'Elements') . '</label>', '<button style="float: left;">' . t(171, 'Order') . '</button>', '<span id="order_info" class="ui-icon ui-icon-info"
 				   data-message="' . t(425, 'Order elements of a category (unless the template forces other sorting)', false, true) . '"
				   style="float: left; margin-left: 2px;">				   
			</span>', '<div id="items_order_window" style="display: none;"></div>'), 'div_category_order');
    $layout->add_script('
	    $("#div_category_order button").button(
	    {
	        icons:
	        {
                primary: "ui-icon-arrowthick-2-n-s"
            }
	    }).on("click", function(e)
	    {
	        e.stopPropagation();
	        e.preventDefault();
	        navigate_status(navigate_t(6, "Loading") + "...", "loader");

	        $("#items_order_window").load("?fid=items&act=items_order&category=" + $("#category").val() + "&_bogus=" + new Date().getTime(), function()
	        {
	            navigate_status(navigate_t(42, "Ready"), "ready");
                $("#items_order_window").dialog({
                    modal: true,
                    title: "' . t(171, 'Order') . '",
                    width: 600,
                    height: 500,
                    buttons:
                    {
                        "' . t(58, 'Cancel') . '": function()
                        {
                            $(this).dialog("destroy");
                        },
                        "' . t(190, 'Ok') . '": function()
                        {
                            var dialog = this;
                            // save
                            $.post(
                                "?fid=items&act=items_order&category=" + $("#category").val() + "&_bogus=" + new Date().getTime(),
                                {
                                    "items-order": $("#items-order").val()
                                },
                                function(response)
                                {
                                    if(response=="true")
                                    {
                                        $(dialog).dialog("destroy");
                                    }
                                    else
                                    {
                                        $("<div>"+response+"</div>").dialog({
                                            modal: true,
                                            title: "' . t(56, "Unexpected error") . '"
                                        });
                                    }
                                }
                            );
                        }
                    }
                });
            });
	    });
	');
    $templates = template::elements('element');
    $template_select = $naviforms->select_from_object_array('template', $templates, 'id', 'title', $item->template);
    $navibars->add_tab_content_row(array('<label>' . t(79, 'Template') . '</label>', $template_select, '<span id="template_info" class="ui-icon ui-icon-alert"
 				   data-message="' . t(619, "Template changed, please Save now to see the changes in the next tabs", false, true) . '"
				   style="display: none; float: none; vertical-align: middle; "></span>'), 'div_template_select');
    $layout->add_script('
		var last_check = [];
		var active_languages = ["' . implode('", "', array_keys($ws_languages)) . '"];
		$("#div_template_select").hide();
	');
    // script#3
    if (!empty($item->id)) {
        $navibars->add_tab(t(9, "Content"));
        // tab #2
        $navibars->add_tab_content_row(array('<label>' . t(63, 'Languages') . '</label>', $naviforms->buttonset('language_selector', $ws_languages, $website->languages_list[0], "navigate_items_select_language(this);")));
        $template = $item->load_template();
        $translate_extensions = extension::list_installed('translate', false);
        foreach ($website->languages_list as $lang) {
            $navibars->add_tab_content('<div class="language_fields" id="language_fields_' . $lang . '" style=" display: none; ">');
            $navibars->add_tab_content_row(array('<label>' . t(67, 'Title') . '</label>', $naviforms->textfield('title-' . $lang, @$item->dictionary[$lang]['title'])));
            $open_live_site = '';
            if (!empty($item->paths[$lang])) {
                $open_live_site = ' <a target="_blank" href="' . $website->absolute_path(true) . $item->paths[$lang] . '"><img src="img/icons/silk/world_go.png" align="absmiddle" /></a>';
            }
            $navibars->add_tab_content_row(array('<label>' . t(75, 'Path') . $open_live_site . '</label>', $naviforms->textfield('path-' . $lang, @$item->paths[$lang], NULL, 'navigate_items_path_check(this, event);'), '<span>&nbsp;</span>'), 'div_path_' . $lang);
            if (!isset($template->sections)) {
                $template->sections[] = array(0 => array('id' => 'main', 'name' => '#main#', 'editor' => 'tinymce', 'width' => '960px'));
            }
            if (!is_array($template->sections)) {
                $template->sections = array();
            }
            // compatibility fix: auto-correct template sections with missing ID (only "code" provided)
            for ($s = 0; $s < count($template->sections); $s++) {
                if (!isset($template->sections[$s]['id'])) {
                    $template->sections[$s]['id'] = $template->sections[$s]['code'];
                }
            }
            foreach ($template->sections as $section) {
                if (is_object($section)) {
                    $section = (array) $section;
                }
                // ignore empty sections
                if (empty($section)) {
                    continue;
                }
                if ($section['editor'] == 'tinymce') {
                    $translate_menu = '';
                    if (!empty($translate_extensions)) {
                        $translate_extensions_titles = array();
                        $translate_extensions_actions = array();
                        foreach ($translate_extensions as $te) {
                            if ($te['enabled'] == '0') {
                                continue;
                            }
                            $translate_extensions_titles[] = $te['title'];
                            $translate_extensions_actions[] = 'javascript: navigate_tinymce_translate_' . $te['code'] . '(\'section-' . $section['id'] . '-' . $lang . '\', \'' . $lang . '\');';
                        }
                        if (!empty($translate_extensions_actions)) {
                            $translate_menu = $naviforms->splitbutton('translate_' . $lang, '<img src="img/icons/silk/comment.png" align="absmiddle"> ' . t(188, 'Translate'), $translate_extensions_actions, $translate_extensions_titles);
                        }
                    }
                    $navibars->add_tab_content_row(array('<label>' . template::section_name($section['name']) . '<span class="editor_selector" for="section-' . $section['id'] . '-' . $lang . '">' . '<i class="fa fa-border fa-fw fa-lg fa-file-text-o active" data-action="tinymce" title="' . t(614, "Edit with TinyMCE") . '"></i> ' . '<i class="fa fa-border fa-fw fa-lg fa-code" data-action="html" title="' . t(615, "Edit as source code") . '"></i> ' . '<i class="fa fa-border fa-fw fa-lg fa-eraser" data-action="clear" title="' . t(208, "Remove all content") . '"></i>' . '</span>' . '</label>', $naviforms->editorfield('section-' . $section['id'] . '-' . $lang, @$item->dictionary[$lang]['section-' . $section['id']], $section['width'] + 48 . 'px', $lang), '<div style="clear:both; margin-top:5px; float:left; margin-bottom: 10px;">', '<label>&nbsp;</label>', $translate_menu, '<button onclick="navigate_items_copy_from_dialog(\'section-' . $section['id'] . '-' . $lang . '\'); return false;"><img src="img/icons/silk/page_white_copy.png" align="absmiddle"> ' . t(189, 'Copy from') . '...</button> ', '<button onclick="navigate_items_copy_from_history_dialog(\'section-' . $section['id'] . '-' . $lang . '\', \'' . $section['id'] . '\', \'' . $lang . '\', \'' . $section['editor'] . '\'); return false;"><img src="img/icons/silk/time_green.png" align="absmiddle"> ' . t(40, 'History') . '</button> ', !empty($theme->content_samples) ? '<button onclick="navigate_items_copy_from_theme_samples(\'section-' . $section['id'] . '-' . $lang . '\', \'' . $section['id'] . '\', \'' . $lang . '\', \'' . $section['editor'] . '\'); return false;"><img src="img/icons/silk/rainbow.png" align="absmiddle"> ' . t(553, 'Fragments') . ' | ' . $theme->title . '</button> ' : '', '</div>', '<br />'), '', 'lang="' . $lang . '"');
                } else {
                    if ($section['editor'] == 'html') {
                        $navibars->add_tab_content_row(array('<label>' . template::section_name($section['name']) . '</label>', $naviforms->scriptarea('section-' . $section['id'] . '-' . $lang, @$item->dictionary[$lang]['section-' . $section['id']], 'html', ' width: ' . $section['width'] . 'px'), '<div style="clear:both; margin-top:5px; float:left; margin-bottom: 10px;">', '<label>&nbsp;</label>', '<button onclick="navigate_items_copy_from_history_dialog(\'section-' . $section['id'] . '-' . $lang . '\', \'' . $section['id'] . '\', \'' . $lang . '\', \'' . $section['editor'] . '\'); return false;"><img src="img/icons/silk/time_green.png" align="absmiddle"> ' . t(40, 'History') . '</button> ', !empty($theme->content_samples) ? '<button onclick="navigate_items_copy_from_theme_samples(\'section-' . $section['id'] . '-' . $lang . '\', \'' . $section['id'] . '\', \'' . $lang . '\', \'' . $section['editor'] . '\'); return false;"><img src="img/icons/silk/rainbow.png" align="absmiddle"> ' . t(553, 'Fragments') . ' | ' . $theme->title . '</button> ' : '', '</div>', '<br />'), '', 'lang="' . $lang . '"');
                    } else {
                        $translate_menu = '';
                        if (!empty($translate_extensions)) {
                            $translate_extensions_titles = array();
                            $translate_extensions_actions = array();
                            foreach ($translate_extensions as $te) {
                                if ($te['enabled'] == '0') {
                                    continue;
                                }
                                $translate_extensions_titles[] = $te['title'];
                                $translate_extensions_actions[] = 'javascript: navigate_textarea_translate_' . $te['code'] . '(\'section-' . $section['id'] . '-' . $lang . '\', \'' . $lang . '\');';
                            }
                            if (!empty($translate_extensions_actions)) {
                                $translate_menu = $naviforms->splitbutton('translate_' . $lang, '<img src="img/icons/silk/comment.png" align="absmiddle"> ' . t(188, 'Translate'), $translate_extensions_actions, $translate_extensions_titles);
                            }
                        }
                        $navibars->add_tab_content_row(array('<label>' . template::section_name($section['name']) . '</label>', $naviforms->textarea('section-' . $section['id'] . '-' . $lang, @$item->dictionary[$lang]['section-' . $section['id']], 8, 48, ' width: ' . $section['width'] . 'px'), '<div style="clear:both; margin-top:5px; margin-bottom: 10px; ">', '<label>&nbsp;</label>', $translate_menu, '<button onclick="navigate_items_copy_from_history_dialog(\'section-' . $section['id'] . '-' . $lang . '\', \'' . $section['id'] . '\', \'' . $lang . '\', \'' . $section['editor'] . '\'); return false;"><img src="img/icons/silk/time_green.png" align="absmiddle"> ' . t(40, 'History') . '</button> ', !empty($theme->content_samples) ? '<button onclick="navigate_items_copy_from_theme_samples(\'section-' . $section['id'] . '-' . $lang . '\', \'' . $section['id'] . '\', \'' . $lang . '\', \'' . $section['editor'] . '\'); return false;"><img src="img/icons/silk/rainbow.png" align="absmiddle"> ' . t(553, 'Fragments') . ' | ' . $theme->title . '</button> ' : '', '</div>'), '', 'lang="' . $lang . '"');
                    }
                }
            }
            if ($template->tags == 1 || $template->tags == 'true') {
                $tags_copy_select = '';
                $tags_copy_select_pre = '';
                $tags_copy_select_after = '';
                // allow copying tags between languages?
                if (count($website->languages_list) > 1) {
                    $tags_copy_select = $naviforms->selectfield('', array_keys($ws_languages), array_values($ws_languages), '', '', false, '', ' width: auto; position: absolute; margin-top: 1px; ', false);
                    $tags_copy_select = '
						<div style=" position: relative; margin-left: 600px; margin-top: -57px; width: 200px; height: 68px; ">
							<a href="#" class="uibutton" title="' . t(189, "Copy from") . '…"
							   onclick=" navigate_items_tags_copy_from_language($(this).next().val(), \'' . $lang . '\'); return false; ">
								<img src="img/icons/silk/page_white_copy.png" width="16" height="16" align="absmiddle" style=" cursor: pointer; " />
							</a>&nbsp;' . $tags_copy_select . '
						</div>
					';
                }
                $tags_top_list = '
					<div style=" position: relative; margin-left: 600px; margin-top: -93px; width: 200px; height: 92px; ">
						<a href="#" class="uibutton" onclick=" navigate_items_tags_ranking(\'' . $lang . '\', this); return false; ">
							<img src="img/icons/silk/award_star_gold_3.png" width="16" height="16" align="absmiddle" style=" cursor: pointer; " />
							' . t(613, "Most used") . '
						</a>
					</div>
				';
                $navibars->add_tab_content_row(array('<label>' . t(265, 'Tags') . '</label>', $naviforms->textfield('tags-' . $lang, @$item->dictionary[$lang]['tags']), $tags_top_list, $tags_copy_select));
            }
            $layout->add_script('			                
                $("#tags-' . $lang . '").tagit({
                    removeConfirmation: true,
                    allowSpaces: true,
                    singleField: true,
                    singleFieldDelimiter: ",",
                    placeholderText: "+",
                    autocomplete: 
                    {
                        delay: 0, 
                        minLength: 1,
                        source: "?fid=items&act=json_tags_search&lang=' . $lang . '"
                    },
                    afterTagAdded: function(event, ui)
                    {
                        var tags = $(this).tagit("assignedTags");
                        if(tags.length > 0)
                            tags = tags.join(",");
                        else
                            tags = "";
                            
                        $("#tags-' . $lang . '")
                            .val(tags)
                            .trigger("change");
                    },
                    afterTagRemoved: function(event, ui)
                    {                    
                        var tags = $(this).tagit("assignedTags");
                        if(tags.length > 0)
                            tags = tags.join(",");
                        else
                            tags = "";
                            
                        $("#tags-' . $lang . '")
                            .val(tags)
                            .trigger("change");
                    }
                });
                
                $("#tags-' . $lang . '").next().sortable({
                    items: ">li:not(.tagit-new)",
                    update: function(ui, event)
                    {
                        var tags = [];
                        
                        $("#tags-' . $lang . '").next().find("span.tagit-label").each(function()
                        {
                            if($(this).text() != "")
                                tags.push($(this).text());
                        });
                        if(tags.length > 0) tags = tags.join(",");
                        else                tags = "";
                                                    
                        $("#tags-' . $lang . '").val(tags);
                        $("#tags-' . $lang . '").trigger("change");                                                
                    }
                });                
			');
            // script#4
            $navibars->add_tab_content('</div>');
        }
        // translate content_samples titles
        if (is_array($theme->content_samples)) {
            for ($i = 0; $i < count($theme->content_samples); $i++) {
                $theme->content_samples[$i]->title = $theme->t($theme->content_samples[$i]->title);
            }
        }
        $layout->add_script('
			var template_sections = ' . json_encode($template->sections) . ';
		    var theme_content_samples = ' . json_encode($theme->content_samples) . ';
		    var website_theme = "' . $website->theme . '";
		');
        $category = new structure();
        $category->paths = array();
        if (!empty($item->category)) {
            $category->load($item->category);
        }
        $layout->add_script('
			var item_category_path = ' . json_encode($category->paths) . ';
			var item_id = "' . $item->id . '";
		');
        // script#5
        // select the first language of the website as the default origin when copying content
        $default_language = array_keys($ws_languages);
        $default_language = $default_language[0];
        $layout->add_content('
			<div id="navigate_items_copy_from" style=" display: none; ">
				<div class="navigate-form-row">
					<label>' . t(191, 'Source') . '</label>
					' . $naviforms->buttonset('navigate_items_copy_from_type', array('language' => t(46, 'Language'), 'item' => t(180, 'Item')), '0', "navigate_items_copy_from_change_origin(this);") . '
				</div>
				<div class="navigate-form-row" style=" display: none; ">
					<label>' . t(46, 'Language') . '</label>
					' . $naviforms->selectfield('navigate_items_copy_from_language_selector', array_keys($ws_languages), array_values($ws_languages), $default_language) . '
				</div>
				<div class="navigate-form-row" style=" display: none; ">
					<label>' . t(79, 'Template') . '</label>
					' . $naviforms->select_from_object_array('navigate_items_copy_from_template', $templates, 'id', 'title', '', '') . '
				</div>			
				<div class="navigate-form-row" style=" display: none; ">		
					<label>' . t(67, 'Title') . '</label>			
					' . $naviforms->textfield('navigate_items_copy_from_title') . '
					' . $naviforms->hidden('navigate_items_copy_from_item_id', '') . '
				</div>
				<div class="navigate-form-row" style=" display: none; ">
					<label>' . t(239, 'Section') . '</label>
					' . $naviforms->select_from_object_array('navigate_items_copy_from_section', array(), 'id', 'name', '') . '
				</div>			
			</div>
			
			<div id="navigate_items_copy_from_history" style=" display: none; ">
				<div class="navigate-form-row">
					<label>' . t(196, 'Date & time') . '</label>
					<select id="navigate_items_copy_from_history_options" 
							name="navigate_items_copy_from_history_options" 
							onchange="navigate_items_copy_from_history_preview(this.value, $(this).attr(\'type\'));">
					</select>
					<a href="#" onclick="navigate_items_copy_from_history_remove();"><img src="img/icons/silk/cancel.png" align="absmiddle"></a>
				</div>			
				<div class="navigate-form-row">
					<!--<div id="navigate_items_copy_from_history_text"
						 name="navigate_items_copy_from_history_text"
						 style="border: 1px solid #CCCCCC; float: left; height: auto; min-height: 20px; overflow: auto; width: 97%; padding: 3px; background: #f7f7f7;">
					</div>
					-->
					<textarea style="display: none;" id="navigate_items_copy_from_history_stylesheets">' . $website->content_stylesheets('link_tag') . '</textarea>
					<iframe id="navigate_items_copy_from_history_text"
						 name="navigate_items_copy_from_history_text"
						 src="about:blank"
						 style="border: 1px solid #CCCCCC; float: left; height: 300px; min-height: 20px; overflow: auto; width: 97%; padding: 3px; ">
					</iframe>
					<div id="navigate_items_copy_from_history_text_raw" style=" display: none; "></div>
				</div>			
			</div>

			<div id="navigate_items_copy_from_theme_samples" style=" display: none; ">
				<div class="navigate-form-row">
					<label>' . t(79, 'Template') . '</label>
					<select id="navigate_items_copy_from_theme_samples_options"
							name="navigate_items_copy_from_theme_samples_options"
							onchange="navigate_items_copy_from_theme_samples_preview(this.value, $(this).attr(\'type\'), $(this).find(\'option:selected\').attr(\'source\'));">
					</select>
				</div>
				<div class="navigate-form-row">
					<div id="navigate_items_copy_from_theme_samples_text"
						 name="navigate_items_copy_from_theme_samples_text"
						 style="border: 1px solid #CCCCCC; float: left; height: auto; min-height: 20px; overflow: auto; width: 97%; padding: 3px; background: #f7f7f7;">
					</div>
					<div id="navigate_items_copy_from_theme_samples_text_raw" style=" display: none; "></div>
				</div>
			</div>
		');
        // script will be bound to onload event at the end of this php function (after getScript is done)
        $onload_language = $_REQUEST['tab_language'];
        if (empty($onload_language)) {
            $onload_language = $website->languages_list[0];
        }
        $layout->add_script('
			function navigate_items_onload()
			{
				navigate_items_select_language("' . $onload_language . '");
				navigate_change_association("' . (empty($item->id) ? 'category' : $item->association) . '");
				setTimeout(function()
				{
					$(navigate_codemirror_instances).each(function() { this.refresh(); } );
				}, 500);
			};
		');
        /* IMAGE GALLERIES */
        if ($template->gallery === 'true' || $template->gallery > 0) {
            $navibars->add_tab(t(210, "Gallery"));
            // tab #3
            $access = array(0 => '', 1 => '<img src="img/icons/silk/lock.png" align="absmiddle" title="' . t(361, 'Web users only') . '" />', 2 => '<img src="img/icons/silk/user_gray.png" align="absmiddle" title="' . t(363, 'Users who have not yet signed up or signed in') . '" />', 3 => '<img src="img/icons/silk/group_key.png" align="absmiddle" title="' . t(512, "Selected web user groups") . '" />');
            $permissions = array(0 => '', 1 => '<img src="img/icons/silk/world_dawn.png" align="absmiddle" title="' . t(70, 'Private') . '" />', 2 => '<img src="img/icons/silk/world_night.png" align="absmiddle" title="' . t(81, 'Hidden') . '" />');
            if (!is_array($item->galleries[0])) {
                $item->galleries[0] = array();
            }
            $gallery_elements_order = implode('#', array_keys($item->galleries[0]));
            $navibars->add_tab_content($naviforms->hidden('items-gallery-elements-order', $gallery_elements_order));
            $gallery = '<ul id="items-gallery-elements" class="items-gallery">';
            $ids = array_keys($item->galleries[0]);
            //$default_img = 'data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='; // transparent pixel
            $default_img = 'img/icons/ricebowl/mimetypes/image.png';
            for ($g = 0; $g < count($ids); $g++) {
                $f = new file();
                $f->load($ids[$g]);
                $gallery .= '
				    <li>
                        <div id="items-gallery-item-' . $ids[$g] . '-droppable" class="navigate-droppable ui-corner-all" data-file-id="' . $f->id . '">
                            <div class="file-access-icons">' . $access[$f->access] . $permissions[$f->permission] . '</div>
                            <img title="' . $ids[$g] . '" src="' . $default_img . '" data-src="' . NAVIGATE_DOWNLOAD . '?wid=' . $website->id . '&id=' . $ids[$g] . '&amp;disposition=inline&amp;width=75&amp;height=75" width="75" height="75" />
                        </div>
                        <div class="navigate-droppable-cancel" style="display: block;"><img src="img/icons/silk/cancel.png" /></div>
                    </li>
                ';
            }
            // empty element
            $gallery .= '
                <li class="gallery-item-empty-droppable">
                    <div id="items-gallery-item-empty-droppable" class="navigate-droppable ui-corner-all">
                        <img src="img/icons/misc/dropbox.png" vspace="18" />
                    </div>
                </li>
            ';
            $gallery .= '</ul>';
            // now the image captions
            foreach ($item->galleries[0] as $image_id => $image_dictionary) {
                if (!is_array($image_dictionary)) {
                    $image_dictionary = array();
                }
                foreach ($website->languages_list as $lang) {
                    $gallery .= $naviforms->hidden('items-gallery-item-' . $image_id . '-dictionary-' . $lang, $image_dictionary[$lang]);
                }
            }
            $navibars->add_tab_content_row(array('<label>' . t(210, 'Gallery') . '</label>', '<div>' . $gallery . '</div>'));
            $layout->add_content('
				<ul id="contextmenu-gallery-items" style="display: none" class="ui-corner-all">
	                <li id="contextmenu-gallery-items-properties"><a href="#"><span class="ui-icon ui-icon-contact"></span>' . t(213, "Image caption") . '</a></li>
	                <li id="contextmenu-gallery-items-permissions"><a href="#"><span class="ui-icon ui-icon-key"></span>' . t(17, "Permissions") . '</a></li>
	                <li id="contextmenu-gallery-items-focalpoint"><a href="#"><span class="ui-icon ui-icon-image"></span>' . t(540, "Focal point") . '</a></li>
	                <li id="contextmenu-gallery-items-description"><a href="#"><span class="ui-icon ui-icon-comment"></span>' . t(334, 'Description') . '</a></li>
	                <li><!--divider--></li>
	                <li id="contextmenu-gallery-items-remove"><a href="#"><span class="ui-icon ui-icon-minus"></span>' . t(627, 'Remove') . '</a></li>
	                <li id="contextmenu-gallery-items-move-beginning"><a href="#"><span class="ui-icon ui-icon-arrowthickstop-1-n"></span>' . t(628, 'Move to the beginning') . '</a></li>
	                <li id="contextmenu-gallery-items-move-end"><a href="#"><span class="ui-icon ui-icon-arrowthickstop-1-s"></span>' . t(629, 'Move to the end') . '</a></li>
	            </ul>
			');
            // script#6
            $layout->add_script('
				$(window).on("load", function()
				{
					new LazyLoad({
					    threshold: 200,
					    container: $("#items-gallery-elements-order").parent()[0],
					    elements_selector: "#items-gallery-elements img",
					    throttle: 40,
					    data_src: "src",
					    show_while_loading: true
					});
				});
			');
            $captions_form = '
				<div id="navigate_items_gallery_captions_form" style=" display: none; ">
					<div class="navigate-form-row">
						<label>' . t(157, 'Image') . '</label>
						' . $naviforms->dropbox('navigate_items_gallery_captions_form_image', '', 'image', true) . '
					</div>
			';
            $caption_langs = array_values($website->languages_list);
            foreach ($caption_langs as $caption_language) {
                $captions_form .= '
					<div class="navigate-form-row">
						<label>' . language::name_by_code($caption_language) . '</label>
						' . $naviforms->textfield('navigate_items_gallery_captions_form_image_' . $caption_language, '') . '
					</div>
				';
            }
            $captions_form .= '
				</div>
			';
            $layout->add_content($captions_form);
        }
        // Properties TAB (only if needed)
        $properties_html = '';
        if ($item->association == 'free' && !empty($item->template) && $item->template != '0') {
            // we already know the properties to show: template is set on item
            $properties_html = navigate_property_layout_form('item', $item->template, 'item', $item->id);
        } else {
            if ($item->association == 'category' && $item->embedding == 0 && !empty($item->template)) {
                // we already know the properties to show: template is set on item
                $properties_html = navigate_property_layout_form('item', $item->template, 'item', $item->id);
            } else {
                if ($item->association == 'category' && $item->category > 0) {
                    // we have to get the template set in the category of the item
                    $template_id = $DB->query_single('template', 'nv_structure', ' id = ' . protect($item->category) . ' AND website = ' . $website->id);
                    $properties_html = navigate_property_layout_form('item', $template_id, 'item', $item->id);
                }
            }
        }
        if (!empty($properties_html)) {
            $navibars->add_tab(t(77, "Properties"));
            // tab #4
            $navibars->add_tab_content($properties_html);
        }
        if ($template->comments > 0 || $template->comments == 'true' || $template->comments === true || is_object($template->comments)) {
            $navibars->add_tab(t(250, "Comments"));
            // tab #5
            $navibars->add_tab_content_row(array('<label>' . t(252, 'Comments enabled to') . '</label>', $naviforms->selectfield('item-comments_enabled_to', array(0 => 0, 1 => 1, 2 => 2), array(0 => t(253, 'Nobody'), 1 => t(24, 'Registered users'), 2 => t(254, 'Everyone')), $item->comments_enabled_to)));
            $moderator_id = '';
            if (!empty($item->comments_moderator)) {
                $moderator_username = $DB->query_single('username', 'nv_users', ' id = ' . $item->comments_moderator);
                if (!empty($moderator_username)) {
                    $moderator_username = array($moderator_username);
                    $moderator_id = array($item->comments_moderator);
                }
            }
            $navibars->add_tab_content_row(array('<label>' . t(255, 'Moderator') . '</label>', $naviforms->selectfield('item-comments_moderator', $moderator_id, $moderator_username, $item->comments_moderator, null, false, null, null, false), '<span style="display: none;" id="item-comments_moderator-helper">' . t(535, "Find user by name") . '</span>', '<div class="subcomment"><img align="absmiddle" src="' . NAVIGATE_URL . '/img/icons/silk/information.png" /> ' . t(256, 'Leave blank to accept all comments') . '</div>'));
            // script#7
            // comments list
            // removed filter: AND nvwu.website = nvc.website ... reason: the webuser could be from another website if sharing webusers is enabled
            // TODO: retrieve comments by AJAX call to avoid memory issues. right now we just retrieve the first 500 comments
            $DB->query('SELECT nvc.*, nvwu.username, nvwu.avatar
						  FROM nv_comments nvc
						 LEFT OUTER JOIN nv_webusers nvwu 
						 			  ON nvwu.id = nvc.user
						 WHERE nvc.website = ' . protect($website->id) . '
						   AND nvc.item = ' . protect($item->id) . '
						ORDER BY nvc.date_created ASC
						LIMIT 500');
            $comments = $DB->result();
            $comments_total = count($comments);
            for ($c = 0; $c < $comments_total; $c++) {
                if ($comments[$c]->status == 2) {
                    $comment_status = 'hidden';
                } else {
                    if ($comments[$c]->status == 1) {
                        $comment_status = 'private';
                    } else {
                        if ($comments[$c]->status == -1) {
                            $comment_status = 'new';
                        } else {
                            $comment_status = 'public';
                        }
                    }
                }
                $navibars->add_tab_content_row(array('<span class="items-comment-label">' . core_ts2date($comments[$c]->date_created, true) . '<br />' . '<strong>' . (empty($comments[$c]->username) ? $comments[$c]->name : $comments[$c]->username) . '</strong>' . '<br />' . $comments[$c]->ip . '</span>', '<div id="items-comment-' . $comments[$c]->id . '" class="items-comment-message items-comment-status-' . $comment_status . '">' . nl2br($comments[$c]->message) . '</div>', empty($comments[$c]->avatar) ? '' : '<img style=" margin-left: 5px; " src="' . NAVIGATE_DOWNLOAD . '?wid=' . $website->id . '&id=' . $comments[$c]->avatar . '&amp;disposition=inline&amp;width=46&amp;height=46" />'));
            }
            $navibars->add_tab_content('
				<div id="items-comments-toolbar">
					<img id="items-comments-toolbar-publish" src="' . NAVIGATE_URL . '/img/icons/silk/accept.png" title="' . t(258, 'Publish') . '" />
					<img id="items-comments-toolbar-unpublish" src="' . NAVIGATE_URL . '/img/icons/silk/delete.png" title="' . t(259, 'Unpublish') . '" />
					<img id="items-comments-toolbar-delete" src="' . NAVIGATE_URL . '/img/icons/silk/decline.png" title="' . t(35, 'Delete') . '" />				
				</div>
			');
            // script#8
            // comments moderation
        }
        if ($item->votes > 0) {
            $navibars->add_tab(t(352, "Votes"));
            // tab #6
            $score = $item->score / $item->votes;
            $navibars->add_tab_content_panel('<img src="img/icons/silk/chart_pie.png" align="absmiddle" /> ' . t(337, 'Summary'), array('<div class="navigate-panels-summary ui-corner-all"><h2>' . $item->votes . '</h2><br />' . t(352, 'Votes') . '</div>', '<div class="navigate-panels-summary ui-corner-all""><h2>' . $score . '</h2><br />' . t(353, 'Score') . '</div>', '<div style=" float: left; margin-left: 8px; "><a href="#" class="uibutton" id="items_votes_webuser">' . t(15, 'Users') . '</a></div>', '<div style=" float: right; margin-right: 8px; "><a href="#" class="uibutton" id="items_votes_reset">' . t(354, 'Reset') . '</a></div>', '<div id="items_votes_webuser_window" style=" display: none; width: 600px; height: 350px; "></div>'), 'navigate-panel-web-summary', '385px', '200px');
            $layout->add_script('
				$("#items_votes_reset").on("click", function()
				{
				    navigate_confirmation_dialog(
				        function()
                        {                         
                            $.post("?fid=items&act=votes_reset&id=' . $item->id . '", function(data)
                            {
                                $("#navigate-panel-web-summary").addClass("ui-state-disabled");
                                navigate_notification("' . t(355, 'Votes reset') . '");
                            });
                        },
                        "' . t(497, "Do you really want to erase this data?") . '",
                        null,
				        "' . t(354, 'Reset') . '"
                    );					    
				});
				
				$("#items_votes_webuser").on("click", function()
				{
					$( "#items_votes_webuser_window" ).dialog(
					{
						title: "' . t(357, 'User votes') . '",
						width: 700,
						height: 400,
						modal: true,
						open: function()
						{
							$( "#items_votes_webuser_window" ).html("<table id=\\"items_votes_webuser_grid\\"></table>");
							$( "#items_votes_webuser_window" ).append("<div id=\\"items_votes_webuser_grid_pager\\"></div>");
							
							jQuery("#items_votes_webuser_grid").jqGrid(
							{
							  url: "?fid=' . $_REQUEST['fid'] . '&act=votes_by_webuser&id=' . $item->id . '",
							  editurl: "?fid=' . $_REQUEST['fid'] . '&act=votes_by_webuser&id=' . $item->id . '",
							  datatype: "json",
							  mtype: "GET",
							  pager: "#items_votes_webuser_grid_pager",	
							  colNames:["ID", "' . t(86, 'Date') . '", "' . t(1, 'Username') . '"],
							  colModel:[
								{name:"id", index:"id", width: 75, align: "left", sortable:true, editable:false, hidden: true},
								{name:"date",index:"date", width: 180, align: "center", sortable:true, editable:false},
								{name:"username", index:"username", align: "left", width: 380, sortable:true, editable:false}
								
							  ],
							  scroll: 1,
							  loadonce: false,
							  autowidth: true,
							  forceFit: true,
							  rowNum: 12,
							  rowList: [12],	
							  viewrecords: true,
							  multiselect: true,		  
							  sortname: "date",
							  sortorder: "desc"
							});	
							
							$("#items_votes_webuser_grid").jqGrid(	
							    "navGrid", 
								"#items_votes_webuser_grid_pager", 
								{
								    add: false,
									edit: false,
									del: true,
									search: false
                                }
                            );
						}
					});
				});				
			');
            $navibars->add_tab_content_panel('<img src="img/icons/silk/chart_line.png" align="absmiddle" /> ' . t(353, 'Score'), array('<div id="navigate-panel-web-score-graph" style=" margin: 8px; height: 150px; width: 360px; "></div>'), 'navigate-panel-web-score', '385px', '200px');
            $votes_by_score = webuser_vote::object_votes_by_score('item', $item->id);
            $gdata = array();
            $colors = array('#0a2f42', '#62bbe8', '#1d8ec7', '#44aee4', '#bbe1f5');
            foreach ($votes_by_score as $vscore) {
                $gdata[] = (object) array('label' => $vscore->value, 'data' => (int) $vscore->votes, 'color' => $colors[$vscore->value % count($colors)]);
            }
            $navibars->add_tab_content('
                <div class="hidden" id="navigate-panel-web-data-score">' . json_encode($gdata) . '</div>
            ');
            $navibars->add_tab_content_panel('<img src="img/icons/silk/chart_line.png" align="absmiddle" /> ' . t(352, 'Votes') . ' (' . t(356, 'last 90 days') . ')', array('<div id="navigate-panel-web-votes-graph" style=" margin: 8px; height: 150px; width: 360px; "></div>'), 'navigate-panel-web-votes', '385px', '200px');
            $votes_by_date = webuser_vote::object_votes_by_date('item', $item->id, 90);
            $navibars->add_tab_content('
                <div class="hidden" id="navigate-panel-web-data-votes_by_date">' . json_encode($votes_by_date) . '</div>
            ');
            // script#9
        }
        $nvweb_preview = NAVIGATE_PARENT . NAVIGATE_FOLDER . '/web/nvweb.php?preview=true&wid=' . $website->id . '&route=';
        $layout->add_script('
			function navigate_items_preview()
			{
				// navigate_items_disable_spellcheck(); not needed in tinymce 4?
				navigate_periodic_event_delegate(); // force saving current data in history
				var url = "' . $nvweb_preview . '";
				var active_language = $("input[name=\'language_selector[]\']:checked").val();

				if($("#template").parent().css("display")=="block")
					url = url + "node/' . $item->id . '&lang=" + active_language + "&template=" + $("#template").val();
			    else // category URL
			        url = url + item_category_path[active_language].slice(1);

				setTimeout(function() { window.open(url); }, 1000);
			}
		');
        $events->trigger('items', 'edit', array('item' => &$item, 'navibars' => &$navibars, 'naviforms' => &$naviforms));
    }
    $layout->add_script('
		$.getScript("lib/packages/items/items.js?r=' . $current_version->revision . '", function()
		{
			if(typeof navigate_items_onload == "function")
				navigate_items_onload();
		});
	');
    return $navibars->generate();
}
Ejemplo n.º 3
0
function block_group_form($item)
{
    global $DB;
    global $website;
    global $layout;
    global $theme;
    global $current_version;
    $navibars = new navibars();
    $naviforms = new naviforms();
    if (empty($item->id)) {
        $navibars->title(t(23, 'Blocks') . ' / ' . t(506, 'Groups') . ' / ' . t(38, 'Create'));
    } else {
        $navibars->title(t(23, 'Blocks') . ' / ' . t(506, 'Groups') . ' / ' . t(170, 'Edit') . ' [' . $item->id . ']');
    }
    if (empty($item->id)) {
        $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(0);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>'));
    } else {
        $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(0);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>', '<a href="#" onclick="navigate_delete_dialog();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/cancel.png"> ' . t(35, 'Delete') . '</a>'));
        $layout->add_script('
            function navigate_delete_dialog()
            {
                navigate_confirmation_dialog(
                    function() { window.location.href = "?fid=blocks&act=block_group_delete&id=' . $item->id . '"; }, 
                    null, null, "' . t(35, 'Delete') . '"
                );
            }
        ');
    }
    $navibars->add_actions(array('<a href="?fid=' . $_REQUEST['fid'] . '&act=0"><img height="16" align="absmiddle" width="16" src="img/icons/silk/brick.png"> ' . t(23, 'Blocks') . '</a>', '<a href="?fid=' . $_REQUEST['fid'] . '&act=block_types_list"><img height="16" align="absmiddle" width="16" src="img/icons/silk/brick_edit.png"> ' . t(167, 'Types') . '</a>'));
    if (!empty($item->id)) {
        $notes = grid_notes::comments('block_group', $item->id);
        $navibars->add_actions(array('<a href="#" onclick="javascript: navigate_display_notes_dialog();"><span class="navigate_grid_notes_span" style=" width: 20px; line-height: 16px; ">' . count($notes) . '</span><img src="img/skins/badge.png" width="20px" height="18px" style="margin-top: -2px;" class="grid_note_edit" align="absmiddle" /> ' . t(168, 'Notes') . '</a>'));
    }
    $navibars->add_actions(array(!empty($item->id) ? '<a href="?fid=' . $_REQUEST['fid'] . '&act=block_group_edit"><img height="16" align="absmiddle" width="16" src="img/icons/silk/add.png"> ' . t(38, 'Create') . '</a>' : '', '<a href="?fid=' . $_REQUEST['fid'] . '&act=block_groups_list"><img height="16" align="absmiddle" width="16" src="img/icons/silk/application_view_list.png"> ' . t(39, 'List') . '</a>'));
    $navibars->form();
    if (!empty($item->id)) {
        $navibars->add_tab(t(23, "Blocks"));
        $allowed_types = array();
        if (!empty($item->code)) {
            for ($bg = 0; $bg < count($theme->block_groups); $bg++) {
                if ($theme->block_groups[$bg]->id == $item->code) {
                    if (isset($theme->block_groups[$bg]->allowed_types)) {
                        $allowed_types = $theme->block_groups[$bg]->allowed_types;
                    }
                    break;
                }
            }
        }
        $blocks_selected = array();
        if (!is_array($item->blocks)) {
            $item->blocks = array();
        }
        $navibars->add_tab_content($naviforms->hidden('blocks_group_selection', json_encode($item->blocks)));
        $navibars->add_tab_content($naviforms->hidden('blocks-order', ""));
        $block_types = block::types();
        $lang = $website->languages_published[0];
        $extensions_blocks = extension::blocks();
        for ($p = 0; $p < count($item->blocks); $p++) {
            unset($block);
            switch ($item->blocks[$p]['type']) {
                case "block":
                    $block = new block();
                    $block->load($item->blocks[$p]['id']);
                    if (empty($block) || empty($block->type)) {
                        continue;
                    }
                    $blocks_selected[] = '
                        <div class="block_group_block ui-state-default" data-block-id="' . $block->id . '" data-block-type="block" data-block-uid="' . $item->blocks[$p]['uid'] . '">
                            <div class="actions">
                                <a href="?fid=blocks&act=edit&id=' . $block->id . '"><img src="' . NAVIGATE_URL . '/img/icons/silk/pencil.png" /></a>
                                <a href="#" onclick="navigate_blocks_selection_remove(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/cancel.png" /></a>
                            </div>
                            <div class="title">' . $block->dictionary[$lang]['title'] . '</div>
                            <div class="subcomment"><span style="float: right;">ID ' . $block->id . '</span><img src="img/icons/silk/brick.png" /> ' . $theme->t($block->type) . '</div>
                        </div>
                    ';
                    break;
                case "block_type":
                    for ($bt = 0; $bt < count($block_types); $bt++) {
                        if ($block_types[$bt]['id'] == $item->blocks[$p]['id']) {
                            $block = $block_types[$bt];
                            break;
                        }
                    }
                    $blocks_selected[] = '
                        <div class="block_group_block ui-state-default" data-block-id="' . $block['code'] . '" data-block-type="block_type" data-block-uid="' . $item->blocks[$p]['uid'] . '">
                            <div class="actions">
                                <a href="#" data-block-group="' . $block['block_group'] . '" data-block-type-code="' . $block['code'] . '" data-block-type-title="(span)" onclick="navigate_blocks_block_type_title(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/text_horizontalrule.png" /><span class="hidden">' . $item->blocks[$p]['title'] . '</span></a>
                                <a href="#" onclick="navigate_blocks_selection_remove(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/cancel.png" /></a>
                            </div>
                            <div class="title" title="' . $block['description'] . '">' . $block['title'] . '</div>
                            <div class="subcomment">
                                <span style="float: right;">ID ' . $block['code'] . '</span>
                                <img src="img/icons/silk/brick_link.png" /> ' . $block['count'] . ' ' . ($block['count'] == 1 ? t(437, "Block") : t(23, "Blocks")) . '
                            </div>
                        </div>
                    ';
                    break;
                case "block_group_block":
                    if (is_array($theme->block_groups)) {
                        foreach ($theme->block_groups as $key => $bg) {
                            for ($i = 0; $i < count($bg->blocks); $i++) {
                                if ($bg->blocks[$i]->id == $item->blocks[$p]['id']) {
                                    $block = array('code' => $bg->blocks[$i]->id, 'type' => $bg->blocks[$i]->id, 'title' => $theme->t($bg->blocks[$i]->title), 'description' => $theme->t($bg->blocks[$i]->description), 'properties' => $bg->blocks[$i]->properties, 'block_group' => $bg->id);
                                    break;
                                }
                            }
                        }
                    }
                    $blocks_selected[] = '
                        <div class="block_group_block ui-state-default" data-block-id="' . $block['code'] . '" data-block-type="block_group_block"  data-block-uid="' . $item->blocks[$p]['uid'] . '">
                            <div class="actions">
                                ' . (empty($block['properties']) ? '' : '<a href="#" data-block-group="' . $block['block_group'] . '" data-block-group-block="' . $block['code'] . '" data-block-group-action="settings" onclick="navigate_blocks_group_block_settings(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/cog.png" /></a>') . '
                                <a href="#" onclick="navigate_blocks_selection_remove(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/cancel.png" /></a>
                            </div>
                            <div class="title" title="' . $block['description'] . '">' . $block['title'] . '</div>
                            <div class="subcomment"><span style="float: right;">ID ' . $block['type'] . '</span><img src="img/icons/silk/bricks.png" /> ' . $theme->t($block['type']) . '</div>
                        </div>
                    ';
                    break;
                case "extension":
                    $block = $item->blocks[$p];
                    for ($be = 0; $be < count($extensions_blocks); $be++) {
                        if ($block['id'] == $extensions_blocks[$be]->id) {
                            $extension = new extension();
                            $extension->load($block['extension']);
                            $blocks_selected[] = '
                                <div class="block_group_block ui-state-default" data-block-id="' . $block['id'] . '" data-block-type="extension" data-block-extension="' . $block['extension'] . '"  data-block-uid="' . $item->blocks[$p]['uid'] . '">
                                    <div class="actions">
                                        ' . (empty($extensions_blocks[$be]->properties) ? '' : '<a href="#" data-block-group="' . $item->code . '" data-block-id="' . $block['id'] . '" data-block-extension="' . $block['extension'] . '" data-block-group-action="settings" onclick="navigate_block_group_extension_block_settings(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/cog.png" /></a>') . '
                                        <a href="#" onclick="navigate_blocks_selection_remove(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/cancel.png" /></a>
                                    </div>
                                    <div class="title">' . $extension->t($extensions_blocks[$be]->title) . '</div>
                                    <div class="subcomment"><span style="float: right;">ID ' . $block['id'] . '</span><img src="img/icons/silk/plugin.png" /> ' . $extension->title . '</div>
                                </div>
                            ';
                            break;
                        }
                    }
                    break;
            }
        }
        $blocks_selected = implode("\n", $blocks_selected);
        $navibars->add_tab_content('<div id="block_group_selected_blocks" style="width: 49%; float: left; margin-right: 2%;">
                <div class="ui-accordion ui-widget ui-helper-reset">
                    <h3 class="ui-accordion-header ui-state-default ui-accordion-icons ui-accordion-header-active ui-state-active ui-corner-top">
                        <img src="img/icons/silk/bricks.png" style="vertical-align: middle;" /> ' . t(405, 'Selection') . '
                    </h3>
                    <div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active">' . $blocks_selected . '</div>
                </div>
                <div class="subcomment">
                    <img src="img/icons/silk/information.png" align="absmiddle" /> ' . t(72, "Drag any row to assign priorities") . '
                </div>
             </div>');
        // **** ADD specific BLOCKS ****
        $sql = '
             SELECT b.type, b.id, d.text as title
               FROM nv_blocks b
          LEFT JOIN nv_webdictionary d
                     ON b.id = d.node_id
                    AND d.node_type = "block"
                    AND d.subtype = "title"
                    AND d.lang = "' . $website->languages_list[0] . '"
                    AND d.website = ' . $website->id . '
              WHERE b.website = ' . $website->id . '
           ORDER BY b.id DESC';
        $DB->query($sql);
        $block_elements = $DB->result();
        $block_group_blocks = array();
        for ($bg = 0; $bg < count($theme->block_groups); $bg++) {
            if ($theme->block_groups[$bg]->id == $item->code) {
                $block_group_blocks = $theme->block_groups[$bg]->blocks;
            }
        }
        // blocks available in the accordion
        $navibars->add_tab_content('<div id="blocks_available_wrapper" style="float: left; width: 49%; ">
                <div id="blocks_available_accordion">
                    <h3><i class="fa fa-fw fa-cube"></i> ' . t(437, 'Block') . '</h3>
                    <div>
                    ' . implode("\n", array_map(function ($b) use($allowed_types) {
            global $theme;
            $classes = 'block_group_block ui-state-default';
            if (!empty($allowed_types) && !in_array($b->type, $allowed_types)) {
                $classes .= ' ui-state-disabled hidden';
            }
            $html = '<div class="' . $classes . '" data-block-id="' . $b->id . '" data-block-type="block">' . '<div class="actions">
                                                <a href="?fid=blocks&act=edit&id=' . $b->id . '"><img src="' . NAVIGATE_URL . '/img/icons/silk/pencil.png" /></a>
                                                <a href="#" onclick="navigate_blocks_selection_remove(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/cancel.png" /></a>
                                            </div>' . '<div class="title">' . $b->title . '</div>' . '<div class="subcomment"><span style="float: right;">ID ' . $b->id . '</span><img src="img/icons/silk/brick.png" /> ' . $theme->t($b->type) . '</div>' . '</div>';
            return $html;
        }, $block_elements)) . '
                        <div class="navigate-block_group-accordion-info-link hidden"><i class="fa fa-eye-slash"></i>&nbsp;&nbsp;<a href="#">' . t(646, "Show all unselectable blocks") . '</a></div>
                    </div>
                    <h3><i class="fa fa-fw fa-cubes"></i> ' . t(543, 'Block type') . '</h3>
                    <div>
                    ' . implode("\n", array_map(function ($b) use($allowed_types) {
            $classes = 'block_group_block ui-state-default';
            if (!empty($allowed_types) && !in_array($b['id'], $allowed_types)) {
                $classes .= ' ui-state-disabled';
            }
            $html = '<div class="' . $classes . '" data-block-id="' . $b['id'] . '" data-block-type="block_type">' . '<div class="actions">
                                        <a href="#" data-block-group="' . $b['block_group'] . '" data-block-type-code="' . $b['code'] . '" data-block-type-title="(span)" onclick="navigate_blocks_block_type_title(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/text_horizontalrule.png" /><span class="hidden">' . $b['block_type_title'] . '</span></a>
                                        <a href="#" onclick="navigate_blocks_selection_remove(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/cancel.png" /></a>
                                    </div>' . '<div class="title">' . $b['title'] . '</div>' . '<div class="subcomment">
                                        <span style="float: right;">' . $b['count'] . ' ' . ($b['count'] == 1 ? t(437, "Block") : t(23, "Blocks")) . '</span>
                                        <img src="img/icons/silk/brick_link.png" /> ID ' . $b['id'] . '</div>' . '</div>';
            return $html;
        }, $block_types)) . '
                    </div>
                    <h3><i class="fa fa-fw fa-plus-square-o"></i> ' . t(556, 'Block from group') . ' [' . $theme->t($item->code) . ']</h3>
                    <div>                    
                        ' . implode("\n", array_map(function ($b) use($item) {
            global $theme;
            $html = '<div class="block_group_block ui-state-default" data-block-id="' . $b->id . '" data-block-type="block_group_block" title="' . $theme->t(@$b->description) . '">' . '<div class="actions">
                                                    ' . (empty($b->properties) ? '' : '<a href="#" data-block-group="' . $item->code . '" data-block-group-block="' . $b->id . '" data-block-group-action="settings" onclick="navigate_blocks_group_block_settings(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/cog.png" /></a>') . '
                                                    <a href="#" onclick="navigate_blocks_selection_remove(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/cancel.png" /></a>
                                                </div>' . '<div class="title">' . $theme->t($b->title) . '</div>' . '<div class="subcomment">
                                                    <span style="float: right;">ID ' . $b->id . '</span>
                                                    <img src="img/icons/silk/bricks.png" />' . '</div>' . '</div>';
            return $html;
        }, $block_group_blocks)) . '
                    </div>
                    <h3><i class="fa fa-fw fa-puzzle-piece"></i> ' . t(327, 'Extensions') . '</h3>
                    <div>
                        ' . implode("\n", array_map(function ($b) use($allowed_types, $item) {
            $classes = 'block_group_block ui-state-default';
            $extension = new extension();
            $extension->load($b->_extension);
            $html = '<div class="' . $classes . '" data-block-id="' . $b->id . '" data-block-type="extension" data-block-extension="' . $b->_extension . '">' . '<div class="actions">
                                            ' . (empty($b->properties) ? '' : '<a href="#" data-block-group="' . $item->code . '" data-block-group-block="' . $b->id . '" data-block-group-action="settings" onclick="navigate_block_group_extension_block_settings(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/cog.png" /></a>') . '
                                            <a href="#" onclick="navigate_blocks_selection_remove(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/cancel.png" /></a>
                                        </div>' . '<div class="title">' . $extension->t($b->title) . '</div>' . '<div class="subcomment"><span style="float: right;">ID ' . $b->id . '</span><img src="img/icons/silk/plugin.png" /> ' . $extension->title . '</div>' . '</div>';
            return $html;
        }, $extensions_blocks)) . '
                    </div>
                </div>
                <div class="subcomment">
                    <img src="img/icons/silk/information.png" align="absmiddle" /> ' . t(638, "Disabled blocks are not compatible with the current block group type") . '
                </div>
            </div>');
        $block_group_block_types_form = "";
        foreach ($website->languages_list as $lang) {
            $block_group_block_types_form .= ' 
                <div data-lang="' . $lang . '" class="navigate-form-row">
                    <label style="width: 48px; "><span title="' . language::name_by_code($lang) . '" class="navigate-form-row-language-info"><img align="absmiddle" src="img/icons/silk/comment.png">' . $lang . '</span></label>
                    <input type="text" style=" width: 340px;" name="block_type_title_value[' . $lang . ']" value="">
                </div>
            ';
        }
        $navibars->add_tab_content('
            <div id="navigate-block-groups-block-type-title" class="hidden">
                ' . $block_group_block_types_form . '
                <div class="subcomment" style="margin-left: 0;"><img src="img/icons/silk/information.png" /> ' . t(641, "It will only be shown if the template supports it") . '</div>
            </div>
        ');
        $layout->add_script('                       
            function navigate_blocks_block_type_title(el)
            {
                var title = $(el).find("span").text();
                
                try 
                {
                   title = jQuery.parseJSON(title);
                } 
                catch(e) 
                {
                    // not json; do nothing                    
                }                    
                
                $("#navigate-block-groups-block-type-title").find("input[type=text]").each(function()
                {                     
                    if(typeof(title)=="object")
                        $(this).val(title[$(this).parent().data("lang")]);
                    else
                        $(this).val(title);
                });
                
                $("#navigate-block-groups-block-type-title").removeClass("hidden");
                $("#navigate-block-groups-block-type-title").dialog({
                    title: navigate_t(67, "Title"),
                    modal: true,
                    width: 428,
                    buttons: [
                        {
                            text: navigate_t(190, "Ok"),
                            icons: {
                                primary: "ui-icon-check"
                            },
                            click: function()
                            {
                                var new_value = {};
                                
                                $("#navigate-block-groups-block-type-title")
                                    .find(\'input[type="text"]\').each(
                                        function()
                                        {
                                            new_value[$(this).parent().data("lang")] = $(this).val(); 
                                        }
                                    );
                                
                                $(el).find("span").text(JSON.stringify(new_value));
                                                            
                                blocks_selection_update();
                                
                                $( this ).dialog( "close" );
                            }
                        },
                        {
                            text: navigate_t(58, "Cancel"),
                            icons: {
                                primary: "ui-icon-close"
                            },
                            click: function()
                            {
                                $( this ).dialog( "close" );
                            }
                        }
                    ]
                });
            }
        ');
    }
    $navibars->add_tab(t(457, "Information"));
    $navibars->add_tab_content($naviforms->hidden('form-sent', 'true'));
    $navibars->add_tab_content($naviforms->hidden('id', $item->id));
    $navibars->add_tab_content_row(array('<label>ID</label>', '<span>' . (!empty($item->id) ? $item->id : t(52, '(new)')) . '</span>'));
    $navibars->add_tab_content_row(array('<label>' . t(67, 'Title') . '</label>', $naviforms->textfield('title', $item->title)));
    $blgroups = array();
    for ($blg = 0; $blg < count($theme->block_groups); $blg++) {
        $blgroups[$theme->block_groups[$blg]->id] = '';
        if (!empty($theme->block_groups[$blg]->description)) {
            $blgroups[$theme->block_groups[$blg]->id] = $theme->t($theme->block_groups[$blg]->description);
        }
    }
    if (!in_array($item->code, $blgroups)) {
        $blgroups[$item->code] = $item->code;
    }
    $navibars->add_tab_content_row(array('<label>' . t(237, 'Code') . '</label>', $naviforms->selectfield('code', array_keys($blgroups), array_keys($blgroups), $item->code, NULL, NULL, array_values($blgroups), "", true, true)));
    // DEPRECATED field, will be removed. Please use the Notes feature
    if (!empty($item->notes)) {
        $navibars->add_tab_content_row(array('<label>' . t(168, 'Notes') . '</label>', $naviforms->textarea('notes', $item->notes)));
    }
    if (!empty($item->id)) {
        $layout->navigate_notes_dialog('block_group', $item->id);
    }
    $layout->add_script('
        $.getScript("lib/packages/blocks/blocks.js?r=' . $current_version->revision . '", 
            function()
            {
                block_groups_onload();
            });
    ');
    return $navibars->generate();
}
Ejemplo n.º 4
0
function webusers_form($item)
{
    global $user;
    global $DB;
    global $website;
    global $theme;
    global $layout;
    global $events;
    $navibars = new navibars();
    $naviforms = new naviforms();
    $layout->navigate_media_browser();
    // we can use media browser in this function
    if (empty($item->id)) {
        $navibars->title(t(24, 'Web users') . ' / ' . t(38, 'Create'));
    } else {
        $navibars->title(t(24, 'Web users') . ' / ' . t(170, 'Edit') . ' [' . $item->id . ']');
    }
    $navibars->add_actions(array('<a href="#" onclick="javascript: navigate_media_browser();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/images.png"> ' . t(36, 'Media') . '</a>'));
    $navibars->add_actions(array('<a href="?fid=' . $_REQUEST['fid'] . '&act=webuser_groups_list"><img height="16" align="absmiddle" width="16" src="img/icons/silk/group.png"> ' . t(506, 'Groups') . '</a>'));
    if (!empty($item->id)) {
        $notes = grid_notes::comments('webuser', $item->id);
        $navibars->add_actions(array('<a href="#" onclick="javascript: navigate_display_notes_dialog();"><span class="navigate_grid_notes_span" style=" width: 20px; line-height: 16px; ">' . count($notes) . '</span><img src="img/skins/badge.png" width="20px" height="18px" style="margin-top: -2px;" class="grid_note_edit" align="absmiddle" /> ' . t(168, 'Notes') . '</a>'));
    }
    if (empty($item->id)) {
        $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(1);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>'));
    } else {
        $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(1);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>', '<a href="#" onclick="navigate_delete_dialog();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/cancel.png"> ' . t(35, 'Delete') . '</a>'));
        $delete_html = array();
        $delete_html[] = '<div id="navigate-delete-dialog" class="hidden">' . t(57, 'Do you really want to delete this item?') . '</div>';
        $delete_html[] = '<script language="javascript" type="text/javascript">';
        $delete_html[] = 'function navigate_delete_dialog()';
        $delete_html[] = '{';
        $delete_html[] = '$("#navigate-delete-dialog").removeClass("hidden");';
        $delete_html[] = '$("#navigate-delete-dialog").dialog({
							resizable: true,
							height: 150,
							width: 300,
							modal: true,
							title: "' . t(59, 'Confirmation') . '",
							buttons: {
								"' . t(35, 'Delete') . '": function() {
									$(this).dialog("close");
									window.location.href = "?fid=' . $_REQUEST['fid'] . '&act=remove&id=' . $item->id . '";
								},
								"' . t(58, 'Cancel') . '": function() {
									$(this).dialog("close");
								}
							}
						});';
        $delete_html[] = '}';
        $delete_html[] = '</script>';
        $navibars->add_content(implode("\n", $delete_html));
    }
    $navibars->add_actions(array(!empty($item->id) ? '<a href="?fid=webusers&act=2"><img height="16" align="absmiddle" width="16" src="img/icons/silk/add.png"> ' . t(38, 'Create') . '</a>' : '', '<a href="?fid=webusers&act=0"><img height="16" align="absmiddle" width="16" src="img/icons/silk/application_view_list.png"> ' . t(39, 'List') . '</a>', 'search_form'));
    $navibars->form();
    $navibars->add_tab(t(43, "Main"));
    $navibars->add_tab_content($naviforms->hidden('form-sent', 'true'));
    $navibars->add_tab_content($naviforms->hidden('id', $item->id));
    $navibars->add_tab_content_row(array('<label>ID</label>', '<span>' . (!empty($item->id) ? $item->id : t(52, '(new)')) . '</span>'));
    $navibars->add_tab_content_row(array('<label>' . t(246, 'Avatar') . '</label>', $naviforms->dropbox('webuser-avatar', $item->avatar, "image")));
    $navibars->add_tab_content_row(array('<label>' . t(1, 'User') . '</label>', $naviforms->textfield('webuser-username', $item->username, false, false, 'autocomplete="off"')));
    $navibars->add_tab_content_row(array('<label>' . t(2, 'Password') . '</label>', '<input type="password" name="webuser-password" autocomplete="off" value="" size="32" />', '<span class="navigate-form-row-info">' . t(48, "Leave blank to keep the current value") . '</span>'));
    // force removing the browser saved password
    $layout->add_script('
		setTimeout(function() {
			$("input[name=webuser-password]").val("");
		}, 10);
	');
    $navibars->add_tab_content_row(array('<label>' . t(44, 'E-Mail') . '</label>', $naviforms->textfield('webuser-email', $item->email), $item->email_verification_date > 0 ? '<span class="navigate-form-row-info" title="' . core_ts2date($item->email_verification_date, true) . '"><img src="img/icons/silk/tick.png" align="absmiddle" /> ' . t(37, "E-Mail confirmed") . '</span>' : ''));
    if (!empty($item->joindate)) {
        $navibars->add_tab_content_row(array('<label>' . t(247, 'Date joined') . '</label>', core_ts2date($item->joindate, true)));
    }
    if (!empty($item->lastseen)) {
        $navibars->add_tab_content_row(array('<label>' . t(563, 'Last seen') . '</label>', core_ts2date($item->lastseen, true)));
    }
    $navibars->add_tab_content_row(array('<label>' . t(249, 'Newsletter') . '</label>', $naviforms->checkbox('webuser-newsletter', $item->newsletter)));
    $webuser_access = array('0' => t(321, "Allowed"), '1' => t(47, "Blocked"), '2' => t(622, "Date range"));
    $navibars->add_tab_content_row(array('<label>' . t(364, 'Access') . '</label>', $naviforms->selectfield('webuser-access', array_keys($webuser_access), array_values($webuser_access), $item->access, 'navigate_webusers_change_access();')));
    if (empty($item->access_begin)) {
        $item->access_begin = '';
    }
    $navibars->add_tab_content_row(array('<label>&nbsp;&nbsp;<img src="img/icons/silk/date_go.png" /> ' . t(623, 'Begin') . '</label>', $naviforms->datefield('webuser-access-begin', $item->access_begin, true, ' width:200px; ')));
    if (empty($item->access_end)) {
        $item->access_end = '';
    }
    $navibars->add_tab_content_row(array('<label>&nbsp;&nbsp;<img src="img/icons/silk/date_delete.png" /> ' . t(624, 'End') . '</label>', $naviforms->datefield('webuser-access-end', $item->access_end, true, ' width:200px; ')));
    $layout->add_script('
		function navigate_webusers_change_access()
		{
			$("#webuser-access-begin").parent().hide();
			$("#webuser-access-end").parent().hide();
			
			if($("#webuser-access").val() == "2")
			{
				$("#webuser-access-begin").parent().show();
				$("#webuser-access-end").parent().show();
			}
		}
		navigate_webusers_change_access();
	');
    // private_comment is deprecated in NV 2.0
    if (!empty($item->private_comment)) {
        $navibars->add_tab_content_row(array('<label>' . t(538, 'Private comment') . '</label>', $naviforms->textarea('webuser-private_comment', $item->private_comment)));
    }
    $navibars->add_tab(t(506, "Groups"));
    $webuser_groups = webuser_group::all_in_array();
    $navibars->add_tab_content_row(array('<label>' . t(506, "Groups") . '</label>', $naviforms->multiselect('webuser-groups', array_keys($webuser_groups), array_values($webuser_groups), $item->groups)));
    $navibars->add_tab(t(308, "Personal"));
    $navibars->add_tab_content_row(array('<label>' . t(159, 'Name') . '</label>', $naviforms->textfield('webuser-fullname', $item->fullname)));
    $navibars->add_tab_content_row(array('<label>' . t(160, 'Type') . ' / ' . t(304, 'Gender') . '</label>', $naviforms->buttonset('webuser-gender', array('male' => '<img src="img/icons/silk/male.png" align="absbottom" /> ' . t(305, 'Male'), 'female' => '<img src="img/icons/silk/female.png" align="absbottom" /> ' . t(306, 'Female'), 'company' => '<img src="img/icons/silk/building.png" align="absbottom" /> ' . t(592, 'Company'), '' => '<img src="img/icons/silk/help.png" align="absbottom" /> ' . t(307, 'Unspecified')), $item->gender)));
    $navibars->add_tab_content_row(array('<label>' . t(248, 'Birthdate') . '</label>', $naviforms->datefield('webuser-birthdate', $item->birthdate, false)));
    $countries = property::countries();
    $country_names = array_values($countries);
    $country_codes = array_keys($countries);
    // include "country not defined" item
    array_unshift($country_codes, '');
    array_unshift($country_names, '(' . t(307, "Unspecified") . ')');
    $navibars->add_tab_content_row(array('<label>' . t(224, 'Country') . '</label>', $naviforms->selectfield("webuser-country", $country_codes, $country_names, strtoupper($item->country))));
    $timezones = property::timezones();
    if (empty($item->timezone)) {
        $item->timezone = date_default_timezone_get();
    }
    $navibars->add_tab_content_row(array('<label>' . t(97, 'Timezone') . '</label>', $naviforms->selectfield("webuser-timezone", array_keys($timezones), array_values($timezones), $item->timezone)));
    $layout->add_script('
		var webuser_country = "' . $item->country . '";
		$("#webuser-country").bind("change blur", function()
		{
			if($(this).val() != webuser_country)
			{
				webuser_country = $(this).val();
				$.getJSON("?fid=' . $_REQUEST['fid'] . '", { country: $(this).val(), act: 90 }, function(data) 
				{
					$("#webuser-timezone").find("option").remove();
					
					$.each(data, function(value, text) 
					{
						$("<option />", {
							value: value,
							html: text
						}).appendTo("#webuser-timezone");
					});				
				});				
			}
		});
	');
    // Language selector
    $data = language::language_names(false);
    $select = $naviforms->selectfield('webuser-language', array_keys($data), array_values($data), $item->language);
    $navibars->add_tab_content_row(array('<label>' . t(46, 'Language') . '</label>', $select));
    $navibars->add_tab(t(233, "Address"));
    $navibars->add_tab_content_row(array('<label>' . t(233, 'Address') . '</label>', $naviforms->textfield('webuser-address', $item->address)));
    $navibars->add_tab_content_row(array('<label>' . t(319, 'Location') . '</label>', $naviforms->textfield('webuser-location', $item->location)));
    $navibars->add_tab_content_row(array('<label>' . t(318, 'Zip code') . '</label>', $naviforms->textfield('webuser-zipcode', $item->zipcode)));
    $navibars->add_tab_content_row(array('<label>' . t(320, 'Phone') . '</label>', $naviforms->textfield('webuser-phone', $item->phone)));
    $navibars->add_tab(t(309, "Social"));
    $navibars->add_tab_content_row(array('<label>' . t(177, 'Website') . '</label>', $naviforms->textfield('webuser-social_website', $item->social_website)));
    if (!empty($theme->webusers['properties'])) {
        $properties_html = navigate_property_layout_form('webuser', $theme->name, 'webuser', $item->id);
        if (!empty($properties_html)) {
            $navibars->add_tab(t(77, "Properties"));
            $navibars->add_tab_content($properties_html);
        }
    }
    if (!empty($item->id)) {
        $layout->navigate_notes_dialog('webuser', $item->id);
    }
    $events->trigger('webuser', 'edit', array('webuser' => &$item, 'navibars' => &$navibars, 'naviforms' => &$naviforms));
    return $navibars->generate();
}
Ejemplo n.º 5
0
function dashboard_panel_public_wall($params)
{
    global $DB;
    global $website;
    global $layout;
    $stats =& $params['statistics'];
    $navibars =& $params['navibars'];
    $layout->navigate_notes_dialog('website', $website->id);
    $public_wall_notes = grid_notes::comments('website', $website->id);
    $elements_html = '
        <div class="navigate-panel-model-row hidden">
            <div class="navigate-panel-recent-comments-username ui-corner-all items-comment-status-public hide">
                <span data-field="date"></span> 
                <span data-field="username"><strong>' . $public_wall_notes[$e]['username'] . '</strong></span>
            </div>
            <div data-field="note" class="navigate-panel-recent-comments-element"></div>
        </div>
    ';
    for ($e = 0; $e < 4; $e++) {
        if (!isset($public_wall_notes[$e])) {
            break;
        }
        $tmp = array('<div class="navigate-panel-public-wall-note" id="website-note-' . $public_wall_notes[$e]['id'] . '">', '<div class="navigate-panel-recent-comments-username ui-corner-all items-comment-status-public">' . '<span data-field="date">' . $public_wall_notes[$e]['date'] . '</span> ' . '<span data-field="username"><strong>' . $public_wall_notes[$e]['username'] . '</strong></span>' . '</div>', '<div data-field="note" class="navigate-panel-recent-comments-element">' . $public_wall_notes[$e]['note'] . '</div>', '</div>');
        $elements_html .= implode("\n", $tmp);
    }
    $navibars->add_tab_content_panel('<img src="img/icons/silk/note.png" align="absmiddle" /> ' . t(637, 'Website notes') . '<div style="float: right; cursor: pointer;" onclick="navigate_display_notes_dialog(navigate_dashboard_website_notes_update);">
            <img src="img/icons/silk/add.png" width="18px" height="18px" class="grid_note_edit" align="absmiddle" />
         </div>' . '<div style="float: right;" onclick="navigate_display_notes_dialog(navigate_dashboard_website_notes_update);">
            <span class="navigate_grid_notes_span">' . count($public_wall_notes) . '</span><img src="img/skins/badge.png" ng-notes="' . count($public_wall_notes) . '" width="18px" height="18px" class="grid_note_edit" align="absmiddle" />
        </div>', $elements_html, 'navigate-panel-public-wall', '100%', '314px');
}