Example #1
0
function backups_form($item)
{
    global $user;
    global $DB;
    global $website;
    global $layout;
    $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(329, 'Backups') . ' / ' . t(38, 'Create'));
    } else {
        $navibars->title(t(329, 'Backups') . ' / ' . t(170, 'Edit') . ' [' . $item->id . ']');
    }
    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/database_save.png"> ' . t(410, 'Begin backup') . '</a>'));
    } else {
        if ($item->status == 'completed') {
            $navibars->add_actions(array('<a href="#" onclick="navigate_restore_dialog();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/database_refresh.png"> ' . t(412, 'Restore') . '</a> '));
        }
        $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(58, 'Cancel') . '": function() {
									$(this).dialog("close");
								},
								"' . t(35, 'Delete') . '": function() {
									$(this).dialog("close");
									window.location.href = "?fid=backups&act=4&id=' . $item->id . '";
								}
							}
						});';
        $delete_html[] = '}';
        $delete_html[] = '</script>';
        $navibars->add_content(implode("\n", $delete_html));
    }
    $navibars->add_actions(array(!empty($item->id) ? '<a href="?fid=backups&act=2"><img height="16" align="absmiddle" width="16" src="img/icons/silk/add.png"> ' . t(38, 'Create') . '</a>' : '', '<a href="?fid=backups&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(67, 'Title') . '</label>', $naviforms->textfield('title', $item->title), ''));
    $navibars->add_tab_content_row(array('<label>' . t(168, 'Notes') . '</label>', $naviforms->textarea('notes', $item->notes)));
    $navibars->add_tab_content_row(array('<br />'));
    if (empty($item->status) && !empty($item->id)) {
        $item->status = 'prepare';
        if (!empty($item->id)) {
            $layout->add_script('
                $.get("?fid=backups&act=backup&id=' . $item->id . '");
            ');
        }
    }
    // show current backup status
    $navibars->add_tab_content_row(array('<label>' . t(68, 'Status') . '</label>', backup::status($item->status)));
    if (empty($item->status)) {
        $estimated_size = backup::estimated_size();
        $navibars->add_tab_content_row(array('<br />'));
        $navibars->add_tab_content_row(array('<label>' . t(420, 'Estimated size') . '</label>', core_bytes($estimated_size)));
    } else {
        if ($item->status != 'completed' && $item->status != 'error') {
            $navibars->add_tab_content_row(array('<label>&nbsp;</label>', '<button id="backup_refresh_status"><img src="' . NAVIGATE_URL . '/img/icons/silk/reload.png" align="absmiddle" /> ' . t(423, "Refresh") . '</button>'));
            $layout->add_script('
            $("#backup_refresh_status").bind("click", function(e)
            {
                e.stopPropagation();
                e.preventDefault();
                window.location.replace("?fid=backups&act=2&id=' . $item->id . '");
            });
        ');
        } else {
            if ($item->status == 'completed') {
                $navibars->add_tab_content_row(array('<br />'));
                $navibars->add_tab_content_row(array('<label>' . t(409, 'Size') . '</label>', core_bytes($item->size)));
                $navibars->add_tab_content_row(array('<label>' . t(421, 'Created on') . '</label>', core_ts2date($item->date_created, true)));
                $navibars->add_tab_content_row(array('<label>' . t(82, 'File') . '</label>', '<a href="?fid=backups&act=download&id=' . $item->id . '">' . $item->file . '</a>'));
            }
        }
    }
    return $navibars->generate();
}
Example #2
0
function files_item_properties($item)
{
    global $user;
    global $website;
    global $layout;
    global $user;
    $navibars = new navibars();
    $naviforms = new naviforms();
    $navibars->title(t(89, 'Files'));
    $layout->navigate_media_browser();
    // we can use media browser in this function
    //$navibars->add_actions(	array(	'<a href="?fid='.$_REQUEST['fid'].'&act=0&parent='.$item->parent.'"><img height="16" align="absmiddle" width="16" src="img/icons/silk/clipboard.png"> NaviM+</a>'));
    $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>', $user->permission("files.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>' : ''));
    $navibars->add_actions(array('<a href="?fid=' . $_REQUEST['fid'] . '&act=0&parent=' . $item->parent . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/folder_up.png"> ' . t(139, 'Back') . '</a>', 'search_form'));
    $delete_html = array();
    $delete_html[] = '<script language="javascript" type="text/javascript">';
    $delete_html[] = 'function navigate_delete_dialog()';
    $delete_html[] = '{';
    $delete_html[] = '$("<div id=\\"navigate-delete-dialog\\" class=\\"hidden\\">' . t(57, 'Do you really want to delete this item?') . '</div>").dialog(
					  {
							resizable: true,
							height: 150,
							width: 300,
							modal: true,
							title: "' . t(59, 'Confirmation') . '",
							buttons: 
							{
								"' . t(35, 'Delete') . '": function()
								{
									$.ajax(
									{
										async: false,
										url: "' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=' . $_REQUEST['fid'] . '&act=json&op=delete&id=' . $item->id . '",
										success: function(data)
										{
											if(data=="true" || data=="1")
												window.location.href = "?fid=' . $_REQUEST['fid'] . '&act=0&parent=' . $item->parent . '";
											else
												navigate_notification(data);
										}
									});
									$(this).dialog("close");		
                                    $("#navigate-delete-dialog").remove();
								},
								"' . t(58, 'Cancel') . '": function()
								{
									$(this).dialog("close");
									$("#navigate-delete-dialog").remove();
								}
							}
						});
					}';
    $delete_html[] = '</script>';
    $navibars->add_content(implode("\n", $delete_html));
    $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>' . $item->id . '</span>'));
    $navibars->add_tab_content_row(array('<label>' . t(144, 'Filename') . '</label>', $naviforms->textfield('name', $item->name)));
    $navibars->add_tab_content_row(array('<label>' . t(145, 'Size') . '</label>', '<span>' . core_bytes($item->size) . '</span>'));
    $navibars->add_tab_content_row(array('<label>' . t(160, 'Type') . '</label>', $naviforms->selectfield('type', array(0 => 'image', 1 => 'video', 2 => 'audio', 3 => 'document', 4 => 'flash', 5 => 'file'), array(0 => t(157, 'Image'), 1 => t(272, 'Video'), 2 => t(31, 'Audio'), 3 => t(539, 'Document'), 4 => 'Flash', 5 => t(82, 'File')), $item->type, false)));
    // retrieve a full list of mimetypes by extension
    $mimetypes = array_values(file::mimetypes());
    // remove duplicate entries
    $mimetypes = array_unique($mimetypes);
    sort($mimetypes);
    $mimetypes = array_filter($mimetypes);
    $navibars->add_tab_content_row(array('<label>MIME</label>', $naviforms->selectfield('mime', $mimetypes, $mimetypes, $item->mime, false)));
    $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 . ');
    ');
    $navibars->add_tab_content_row(array('<label>' . t(80, 'Permission') . '</label>', $naviforms->selectfield('permission', array(0 => 0, 1 => 1, 2 => 2), array(0 => t(69, 'Published'), 1 => t(70, 'Private'), 2 => t(81, 'Hidden')), $item->permission)));
    $navibars->add_tab_content_row(array('<label>' . t(65, 'Enabled') . '</label>', $naviforms->checkbox('enabled', $item->enabled)));
    /*										
    	$navibars->add_tab_content_row(array(	'<label>'.t(153, 'Embed link').'</label>',
    											'<a href="'.NAVIGATE_DOWNLOAD.'?wid='.$website->id.'&id='.$item->id.'&disposition=inline" target="_blank">'.NAVIGATE_DOWNLOAD.'?wid='.$website->id.'&id='.$item->id.'&disposition=inline</a>'));
    
    	$navibars->add_tab_content_row(array(	'<label>'.t(154, 'Download link').'</label>',
    											'<a href="'.NAVIGATE_DOWNLOAD.'?wid='.$website->id.'&id='.$item->id.'&disposition=attachment">'.NAVIGATE_DOWNLOAD.'?wid='.$website->id.'&id='.$item->id.'&disposition=attachment</a>'));
    */
    $website_root = $website->absolute_path(true) . '/object';
    if (empty($website_root)) {
        $website_root = NVWEB_OBJECT;
    }
    $navibars->add_tab_content_row(array('<label>' . t(153, 'Embed link') . '</label>', '<a href="' . $website_root . '?id=' . $item->id . '&disposition=inline" target="_blank">' . $website_root . '?id=' . $item->id . '&disposition=inline</a>'));
    $navibars->add_tab_content_row(array('<label>' . t(154, 'Download link') . '</label>', '<a href="' . $website_root . '?id=' . $item->id . '&disposition=attachment">' . $website_root . '?id=' . $item->id . '&disposition=attachment</a>'));
    if ($item->type == 'image') {
        $navibars->add_tab(t(157, "Image"));
        $navibars->add_tab_content_row(array('<label>' . t(155, 'Width') . ' / ' . t(156, 'Height') . '</label>', $naviforms->textfield('width', $item->width, '50px'), 'x', $naviforms->textfield('height', $item->height, '50px'), 'px'));
        $navibars->add_tab_content_row(array('<label>' . t(170, 'Edit') . '</label>', '
			<script language="javascript" type="text/javascript">
				function navigate_pixlr_edit()
				{
					pixlr.overlay.show({
						service: "editor",
						loc: "' . $user->language . '",
						image:"' . NAVIGATE_DOWNLOAD . '?id=' . $item->id . '&disposition=inline&sid=' . session_id() . '&seed=" + new Date().getTime(),
						title: "' . $item->name . '",
						target: "' . NAVIGATE_URL . '/navigate_upload.php?wid=' . $website->id . '&engine=pixlr&id=' . $item->id . '&session_id=' . session_id() . '&seed=" + + new Date().getTime(),
						exit: "' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=' . $_REQUEST['fid'] . '&act=pixlr_exit&id=' . $item->id . '&ts=" + + new Date().getTime(),
						credentials: true,
						method: "GET",
						referrer: "Navigate CMS",
						icon: "' . NAVIGATE_URL . '/img/navigate-isotype-16x16.png",
						locktitle: true,
						locktype: "png",
						redirect: "' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=' . $_REQUEST['fid'] . '&act=pixlr_exit&id=' . $item->id . '&ts=" + + new Date().getTime()
					});

					// add a close button
					var close_button = $(\'<a href="#"><span class="fa-stack"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-close fa-stack-1x fa-inverse"></i></span></a>\');
					close_button.css({
					    "position": "absolute",
					    "right": "-20px",
					    "top": "-20px",
					    "font-size": "20px",
					    "color": "#222"
					});
					close_button.on("click", function()
					{
				        pixlr.overlay.hide();
				        $("#image-preview").attr("src", $("#image-preview").attr("src") + "&refresh=" + new Date().getTime());
					});
					$("div:last").prepend(close_button);
				}
			</script>
			<a href="#" class="button" onclick="navigate_pixlr_edit();"><img src="' . NAVIGATE_URL . '/img/logos/pixlr.png" width="100px" height="42px" /></a>
		'));
        $navibars->add_tab_content_row(array('<label>' . t(274, 'Preview') . '</label>', '<div><img id="image-preview" src="' . $website_root . '?id=' . $item->id . '&disposition=inline&seed=' . core_time() . '" width="400px" /></div>'));
        $navibars->add_tab_content_row(array('<label>&nbsp;</label>' . '<button onclick="navigate_media_browser_focalpoint(' . $item->id . '); return false;"><img src="img/icons/silk/picture-measurement.png" align="absmiddle"> ' . t(540, 'Focal point') . '</button>'));
        $navibars->add_tab(t(334, 'Description'));
        $website_languages_selector = $website->languages();
        $website_languages_selector = array_merge(array('' => '(' . t(443, 'All') . ')'), $website_languages_selector);
        $navibars->add_tab_content_row(array('<label>' . t(63, 'Languages') . '</label>', $naviforms->buttonset('files_description_language_selector', $website_languages_selector, '', "navigate_tabform_language_selector(this);")));
        foreach ($website->languages_list as $lang) {
            $language_info = '<span class="navigate-form-row-language-info" title="' . language::name_by_code($lang) . '"><img src="img/icons/silk/comment.png" align="absmiddle" />' . $lang . '</span>';
            $navibars->add_tab_content_row(array('<label>' . t(67, 'Title') . ' ' . $language_info . '</label>', $naviforms->textfield('title-' . $lang, @$item->title[$lang])), '', 'lang="' . $lang . '"');
            $navibars->add_tab_content_row(array('<label>' . t(334, 'Description') . ' ' . $language_info . '</label>', $naviforms->textfield('description-' . $lang, @$item->description[$lang])), '', 'lang="' . $lang . '"');
        }
    } else {
        if ($item->type == 'video') {
            $navibars->add_tab(t(272, "Video"));
            /*
            $navibars->add_tab_content_row(array(	'<label>'.t(272, 'Video').'</label>',
            										'<div id="video_'.$item->id.'" style="display:block;width:640px;height:360px;float:left;" class="video">',
            										'<video controls="controls">',
            										'	<source src="'.NAVIGATE_DOWNLOAD.'?wid='.$website->id.'&id='.$item->id.'&disposition=inline" type="'.$item->mime.'" />',
            										'</video>',
            										'</div>'
                                                        ));	
            																				
            $layout->add_script('         
            	$("#video_'.$item->id.' video").mediaelementplayer(
            	{
            		pluginPath: "'.NAVIGATE_URL.'/lib/external/mediaelement/"
            	});
            ');				
            */
            $navibars->add_tab_content_row(array('<label>' . t(272, 'Video') . '</label>', '<div id="video_' . $item->id . '" style="display:block;width:640px;height:360px;float:left;" class="video">
													<a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a>
												</div>', '<script language="javascript" type="text/javascript" src="http://bitcast-b.bitgravity.com/player/6/functions.js"></script>'));
            $layout->add_script('         
			var flashvars = {};
			flashvars.AutoPlay = "false";
			flashvars.File = "' . urlencode(NAVIGATE_DOWNLOAD . '?wid=' . $website->id . '&id=' . $item->id . '&disposition=inline') . '";
			flashvars.Mode = "ondemand";
			var params = {};
			params.allowFullScreen = "true";
			params.allowScriptAccess = "always";
			var attributes = {};
			attributes.id = "bitgravity_player_6";
			swfobject.embedSWF(stablerelease, "video_' . $item->id . '", "640", "360", "9.0.115", "http://bitcast-b.bitgravity.com/player/expressInstall.swf", flashvars, params, attributes);	
		');
        } else {
            if ($item->type == 'audio') {
                $navibars->add_tab(t(31, "Audio"));
                $navibars->add_tab_content_row(array('<label>' . t(31, 'Audio') . '</label>', '<div id="audio_' . $item->id . '" style="display:block;float:left;" class="audio">', '<audio controls="controls">', '	<source src="' . NAVIGATE_DOWNLOAD . '?wid=' . $website->id . '&id=' . $item->id . '&disposition=inline" type="' . $item->mime . '" />', '</audio>', '</div>'));
                $layout->add_script('         
			$("#audio_' . $item->id . ' audio").mediaelementplayer(
			{
				pluginPath: "' . NAVIGATE_URL . '/lib/external/mediaelement/"
			});

			$("#audio_' . $item->id . '").addClass("ui-state-default");
		');
            }
        }
    }
    return $navibars->generate();
}