コード例 #1
0
ファイル: xajax.php プロジェクト: apexad/editsee
function openPopup($popup)
{
    $objResponse = new xajaxResponse();
    $objResponse->includeCSS(str_replace('index.php', '', $_SERVER['SCRIPT_NAME']) . 'includes/layout/overlay.css');
    switch ($popup) {
        case 'undelete':
            $popup_title = 'Restore Posts';
            $popup_contents = <<<UNDELETE
\t<form id="editsee_undelte">
\t<table>
\t<tr><td><!-- Content Type:</td><td> <select id="content_type" onchange="xajax_undeleteList((this.options[this.selectedIndex]).value)">
\t\t<option value=""></option>
\t\t<option value="post">Posts</option>
\t\t<option value="page">Pages</option>
\t\t<option value="links">Links</option>
\t\t<option value="comments">Comments</options>
\t\t</select>--><input type="button" value="Load Posts" onclick="xajax_undeleteList('post'); return false;" /></td></tr>
\t\t<tr><td colspan="2" id="undelete_items"></td></tr>
\t\t<tr><td colspan="2" class="submit">
UNDELETE;
            break;
        case 'password':
            $popup_title = 'Change Password';
            $popup_contents = <<<PASSWORD
\t<form id="editsee_password">
\t<table>
\t<tr><td>Existing Password:</td><td><input type="password" id="existing_password" /></td></tr>
\t<tr><td>New Password:</td><td><input type="password" id="new_password" /></td></tr>
\t<tr><td>Re-Type New Password:</td><td><input type="password" id="retype_password" /></td></tr>
\t<tr><td colspan="2" class="submit">
\t<input type="submit" value="change password" onclick="xajax_changePassword(
\t\t\t\t\t\t\t\t\t\t\t\t\tdocument.getElementById('existing_password').value
\t\t\t\t\t\t\t\t\t\t\t\t\t,document.getElementById('new_password').value
\t\t\t\t\t\t\t\t\t\t\t\t\t,document.getElementById('retype_password').value
\t\t\t\t\t\t\t\t\t\t\t\t); return false;" />
PASSWORD;
            break;
        case 'new_link':
            $popup_title = 'New Link';
            $popup_contents = <<<NEWLINK
\t<form id="editsee_newlink">
\t<table>
\t<tr><td>Link URL:</td><td><input type="text" id="link_url" /></td></tr>
\t<tr><td>Link Title:</td><td><input type="text" id="link_title" /></td></tr>
\t<tr><td>No-Follow <span title="no follow tells search engine to ignore this link">(?)</span>:</td><td><input type="checkbox" id="link_nofollow" class="checkbox" value="nofollow" /></td></tr>
\t<tr><td>Link Target</td><td><select id="link_target">
\t\t\t\t\t\t\t\t\t<option value="_self">Same Window</option>
\t\t\t\t\t\t\t\t\t<option value="_blank">New Window</option>
\t\t\t\t\t\t\t\t</select></td></tr>
\t<tr><td colspan="2" class="submit">
\t<input type="submit" value="add link" onclick="xajax_newLink(
\t\t\t\t\t\t\t\t\t\t\t\t\tdocument.getElementById('link_url').value
\t\t\t\t\t\t\t\t\t\t\t\t\t,document.getElementById('link_title').value
\t\t\t\t\t\t\t\t\t\t\t\t\t,document.getElementById('link_nofollow').checked
\t\t\t\t\t\t\t\t\t\t\t\t\t,(document.getElementById('link_target').options[document.getElementById('link_target').selectedIndex]).value
\t\t\t\t\t\t\t\t\t\t\t\t); return false;" />
NEWLINK;
            break;
        case 'theme_selector':
            $_SESSION['temp_theme'] = '';
            $_SESSION['popup_close_redirect'] = 'yes';
            $project7 = new editsee_App();
            $themes = '';
            $theme_url = $project7->get_config('es_main_url') . 'theme/';
            $handler = opendir('./theme');
            while (false !== ($file = readdir($handler))) {
                if (substr($file, 0, 1) != '.') {
                    $themes .= '<option value="' . $file . '"';
                    if ($file == $project7->get_config('es_theme')) {
                        $themes .= ' selected="selected"';
                        $theme_image = $theme_url . $project7->get_config('es_theme') . '/screenshot.png';
                    }
                    $themes .= '>' . ucfirst($file) . '</option>';
                }
            }
            $popup_title = 'Change Theme';
            $popup_contents = <<<THEMESELECT
\t\t\t<form id="editsee_theme_selector">
\t\t\t<table>
\t\t\t<tr><td>Theme:</td><td><select id="site_theme" onchange="document.getElementById('theme_screenshot').src='{$theme_url}'+(this.options[this.selectedIndex]).value+'/screenshot.png'">\t
\t\t\t{$themes}</select></td></tr>
\t\t\t<tr><td colspan="2"><img id="theme_screenshot" src="{$theme_image}"></div></td></tr>
\t\t\t<tr><td colspan="2" class="submit"><input type="submit" value="Preview Theme" onclick="xajax_previewTheme((document.getElementById('site_theme').options[document.getElementById('site_theme').selectedIndex]).value); return false;" /></td></tr>
\t\t\t<tr><td colspan="2" class="submit"><input type="submit" value="change theme" onclick="xajax_setTheme((document.getElementById('site_theme').options[document.getElementById('site_theme').selectedIndex]).value); return false;" />
THEMESELECT;
            break;
        case 'site_settings':
            $project7 = new editsee_App();
            $title = $project7->get_config('es_title');
            $main_url = $project7->get_config('es_main_url');
            $description = $project7->get_config('es_description');
            $posts_per_page = $project7->get_config('es_posts_per_page');
            $email_comments = $project7->get_config('es_email_comments') == '1' ? ' checked="checked"' : '';
            $show_post_author = $project7->get_config('es_show_post_author') == '1' ? ' checked="checked"' : '';
            $popup_title = 'Site Settings';
            $popup_contents = <<<SITESETTINGS
\t\t<form id="editsee_sitesettings">
\t\t<table>
\t\t<tr><td>Site Title:</td><td><input type="text" id="site_title" value="{$title}" /></td></tr>
\t\t<tr><td>Site URL:</td><td><input type="text" id="main_url" value="{$main_url}" /></td></tr>
\t\t<tr><td>Site Description:</td><td><textarea id="site_desc" rows="5">{$description}</textarea></td>
\t\t<tr><td>E-mail Comments:</td><td><input type="checkbox" id="email_comments" class="checkbox" value="yes" {$email_comments}></td></tr>
\t\t<tr><td>Show Post Author:</td><td><input type="checkbox" id="show_post_author" class="checkbox" value="yes" {$show_post_author}></td></tr>
\t\t<tr><td>Post Per Page:</td><td><input type="text" id="posts_per_page" value="{$posts_per_page}" /></td></tr>
\t\t<tr><td>Custom Homepage:</td><td>
\t\t\t\t\t\t\t<select id="homepage">
\t\t\t\t\t\t\t<option value="!posts!">-- posts --</option>
SITESETTINGS;
            $query = $project7->db->_query("select title,urltag from " . $project7->db->get_table_prefix() . "post \r\n\t\t\t\t\t\t\t\t\t\t\t\t\twhere type='page' and deleted='0'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\torder by title desc");
            while ($row = $query->_fetch_assoc()) {
                $popup_contents .= '<option value="' . $row['urltag'] . '"';
                if ($project7->get_config('es_homepage') == $row['urltag']) {
                    $popup_contents .= ' selected="selected"';
                }
                $popup_contents .= '>' . $row['title'] . '</option>' . "\n";
            }
            $post_page = $project7->get_config('es_postpage');
            $popup_contents .= '
							</select></td></tr>
		<tr><td>Posts Page:</td><td><input type="text" id="postpage" value="' . $post_page . '" /></td></tr>';
            $popup_contents .= <<<SITESETTINGS
\t\t<tr><td colspan="2" class="submit">
\t\t<input type="submit" value="save settings" onclick="xajax_siteSettings(
\t\t\t\t\t\t\t\t\t\t\t\t\tdocument.getElementById('site_title').value
\t\t\t\t\t\t\t\t\t\t\t\t\t,document.getElementById('main_url').value
\t\t\t\t\t\t\t\t\t\t\t\t\t,document.getElementById('site_desc').value
\t\t\t\t\t\t\t\t\t\t\t\t\t,document.getElementById('posts_per_page').value
\t\t\t\t\t\t\t\t\t\t\t\t\t,document.getElementById('homepage').value
\t\t\t\t\t\t\t\t\t\t\t\t\t,document.getElementById('postpage').value
\t\t\t\t\t\t\t\t\t\t\t\t\t,document.getElementById('email_comments').checked
\t\t\t\t\t\t\t\t\t\t\t\t\t,document.getElementById('show_post_author').checked
\t\t\t\t\t\t\t\t\t\t\t\t\t); return false;" />
SITESETTINGS;
            break;
        case 'profile_settings':
            $project7 = new editsee_App();
            $username = $_SESSION['username'];
            $query = $project7->db->_query("select email from " . $project7->db->get_table_prefix() . "user where user_id='" . $_SESSION['user_id'] . "'");
            $email = $query->_result(0);
            $popup_title = 'Profile Settings';
            $popup_contents = <<<PROFILESETTINGS
\t<form id="editsee_profile_settings">
\t<table>
\t<tr><td>Username:</td><td><input type="text" id="username" value="{$username}" /></td></tr>
\t<tr><td>E-mail Address</td><td><input type="text" id="email" value="{$email}" /></td></tr>
\t<tr><td colspan="2" class="submit">
\t<input type="submit" value="save profile" onclick="xajax_profileSettings(
\t\t\t\t\t\t\t\t\t\t\t\t\tdocument.getElementById('username').value
\t\t\t\t\t\t\t\t\t\t\t\t\t,document.getElementById('email').value
\t\t\t\t\t\t\t\t\t\t\t\t); return false;" />
PROFILESETTINGS;
            break;
        case 'forgot_password':
            $project7 = new editsee_App();
            $popup_title = 'Forgot Password';
            $popup_contents = <<<FORGOTPASSWORD
\t<form id="editsee_forgot_password">
\t<table>
\t<tr><td>Username/E-mail Address:</td><td><input type="text" id="information" /></td></tr>
\t<tr><td colspan="2" class="submit">
\t<input type="submit" value="reset password" onclick="xajax_forgotPassword(
\t\t\t\t\t\t\t\t\t\t\t\t\tdocument.getElementById('information').value
\t\t\t\t\t\t\t\t\t\t\t\t); return false;" />
FORGOTPASSWORD;
            break;
        case 'new_category':
            $popup_title = 'New Category';
            $popup_contents = <<<NEWCAT
\t\t<form id="editsee_new_category">
\t\t<table>
\t\t<tr><td>Category:</td><td><input type="text" id="category" /></td></tr>
\t\t<tr><td colspan="2" class="submit">
\t\t<input type="submit" value="add category" onclick="xajax_newCategory(document.getElementById('category').value); return false;" />\t\t
NEWCAT;
            break;
        case 'custom_footer':
            $project7 = new editsee_App();
            $query = $project7->db->_query("select data from " . $project7->db->get_table_prefix() . "custom where section='footer' and label='Custom Footer'");
            if ($query->_num_rows() == 1) {
                $custom_footer = stripslashes($query->_result(0));
            }
            $popup_title = 'Custom Footer';
            $popup_contents = <<<CUSTOMFOOTER
\t<form id="custom_footer">
\t<table>
\t<tr><td>
\t\t\t<input type="hidden" id="custom_section" value="footer" />
\t\t\t<input type="hidden" id="custom_label" value="Custom Footer" />
\t\t\t<textarea id="custom_footer_code" style="width:300px !important;" rows="20">{$custom_footer}</textarea>
\t</tr</td>
\t<tr><td colspan="2" class="submit"><input type="submit" value="save footer" onclick="xajax_customSection(document.getElementById('custom_section').value
\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t,document.getElementById('custom_label').value
\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t,document.getElementById('custom_footer_code').value); return false;" />
CUSTOMFOOTER;
            break;
        case 'manage_users':
            $project7 = new editsee_App();
            $user_list = $project7->get_users('<tr>', '<td>data</td>', '</tr>');
            $popup_title = 'Manage Users';
            $popup_contents = <<<MANUSERS
\t\t<form id="editsee_manage_users">
\t\t<h2>Exiting Users</h2>
\t\t<table id="user_list">
\t\t<tr><td>Username</td><td>Email</td><td>Role</td><td>&nbsp;</td></tr>
\t\t{$user_list}
\t\t</table>
\t\t<h2>Add New User</h2>
\t\t<table>
\t\t<tr><td>Username:</td><td><input type="text" id="name" /></td></tr>
\t\t<tr><td>Password:</td><td><input type="password" id="password" /></td></tr>
\t\t<tr><td>Email:</td><td><input type="text" id="email" /></td></tr>
\t\t<tr><td>Role:</td><td><select id="role"><option value="poster">Poster</option><option value="author">Author</option><option value="admin">Admin</option></select></td></tr>
MANUSERS;
            $popup_contents .= '
			<tr><td colspan="2"><img src="' . $project7->get_config('es_main_url') . 'includes/layout/images/user_add.png" ';
            $popup_contents .= <<<MANUSERS
\t\tonclick="xajax_newUser(document.getElementById('name').value,(document.getElementById('role').options[document.getElementById('role').selectedIndex]).value,document.getElementById('password').value,document.getElementById('email').value); return false;" alt="Add User" title="Add User"/></td>
\t\t</tr>
\t\t<tr><td colspan="2" class="submit">\t
MANUSERS;
            break;
        default:
            $popup_title = ucwords(str_replace('_', ' ', $popup));
            $popup_contents .= '<p>This popup does not exist, yet!</p><table><tr><td class="submit">';
    }
    $popup_contents .= '<input type="submit" value="cancel" onclick="xajax_closePopup(); return false;" /></td></tr>
		</table>
		</form>';
    $popup_contents = '<div>' . $popup_title . '<button onclick="xajax_closePopup(); return false;" class="red">Close</button></div>' . $popup_contents;
    $objResponse->insert("page", "div", "popup");
    $objResponse->assign("popup", 'innerHTML', $popup_contents);
    return $objResponse;
}