Exemplo n.º 1
0
    /**
     * The admin page for our sources/activity system.
     **/
    function sourceMenu()
    {
        if (isset($_GET['page']) && isset($_POST['action']) && $_GET['page'] == basename(__FILE__)) {
            switch ($_POST['action']) {
                case 'add':
                    SourceAdmin::add($_REQUEST);
                    ?>
	            <div id="message" class="updated fade"><p><strong><?php 
                    echo __('Social Me Account saved.');
                    ?>
</strong></p></div>
	            <?php 
                    break;
                case 'gather':
                    SourceAdmin::gather($_REQUEST['id']);
                    break;
                case 'edit':
                    SourceAdmin::edit($_REQUEST);
                    ?>
                <div id="message" class="updated fade"><p><strong><?php 
                    echo __('Social Me Account modified.');
                    ?>
</strong></p></div>
	            <?php 
                    break;
                case 'delete':
                    SourceAdmin::burninate($_REQUEST['id']);
                    ?>
                <div id="message" class="updated fade"><p><strong><?php 
                    echo __('Social Me Account removed.');
                    ?>
</strong></p></div>
	            <?php 
                    break;
                case 'regen_widgets':
                    SourceAdmin::create_widget();
                    ?>
                <div id="message" class="updated fade"><p><strong><?php 
                    echo __('Social Me Widgets regenerated.');
                    ?>
</strong></p></div>
                <?php 
                    break;
                case 'hulk_smash':
                    SourceAdmin::hulk_smash();
                    ?>
                <div id="message" class="updated fade"><p><strong><?php 
                    echo __('Social Me database cleared.');
                    ?>
</strong></p></div>
	            <?php 
                    break;
                case 'install':
                    SourceAdmin::install();
                    ?>
                <div id="message" class="updated fade"><p><strong><?php 
                    echo __('Social Me Manager installed.');
                    ?>
</strong></p></div>
	            <?php 
                    break;
                case 'flush':
                    SourceAdmin::flush_streams($_REQUEST['flush_name']);
                    ?>
                <div id="message" class="updated fade"><p><strong><?php 
                    echo __('Social Me Account flushed.');
                    ?>
</strong></p></div>
	            <?php 
                    break;
                default:
                    break;
            }
        }
        ?>
			<div class="wrap">
				
				<div id="admin-options">
				
					<h2><?php 
        _e('Manage My "Social Me" Page');
        ?>
</h2>
                    <p>If you'd like to let your visitors know where else they may find you throughout the Web,
                    you can do it easily through your "Social Me" page. This is an exclusive feature of the WicketPixie theme for WordPress.
                    If you have accounts on other blogs, social networks, forums, Web sites, etc, add them here. For example,
                    you might add your Twitter, YouTube, and Flickr accounts here - making sure you use the corresponding RSS (or Atom) feeds for your profile,
                    so that WicketPixie can display your latest content from them on your Social Me page.<br /><br />
                    You can also include the list of these accounts in your sidebar - just be sure to enable the <a href="widgets.php">WicketPixie Social Me widget</a> first!</p>
                    <h3>Widget Regenerator</h3>
                    <p>If you are upgrading to 1.2+ from a version earlier than 1.2, you will need to click this button if you already have Social Mes added. You can also press this button if widgets seem to be broken.</p>
                    <form method="post" action="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
?page=sourcemanager.php&amp;regen_widgets=true">
                        <p class="submit">
                            <input type="submit" name="submit" value="Regenerate Widgets" />
                            <input type="hidden" name="action" value="regen_widgets" />
                        </p>
                    </form>
                    <h3>Social Me Listing</h3>
					<?php 
        if (SourceAdmin::check() != 'false' && SourceAdmin::count() != '') {
            ?>
					<form>
					<?php 
            wp_nonce_field('wicketpixie-settings');
            ?>
						<p style="margin-bottom:0;">Sort by: <select name="type" id="type">
							<?php 
            foreach (SourceAdmin::types() as $type) {
                ?>
								<option value="<?php 
                echo $type->type_id;
                ?>
"><?php 
                echo $type->name;
                ?>
</option>
							<?php 
            }
            ?>
						</select>	</p>
					</form>
					<table class="form-table" style="margin-bottom:20px;">
						<tr>
                            <th>Icon</th>
							<th>Title</th>
							<th style="text-align:center;">Feed</th>
							<th style="text-align:center;">Type</th>
							<th style="text-align:center;">Activity</th>
							<th style="text-align:center;" colspan="3">Actions</th>
						</tr>
						<?php 
            foreach (SourceAdmin::collect() as $source) {
                if ($source->lifestream == 0) {
                    $streamed = 'No';
                } else {
                    $streamed = 'Yes';
                }
                $isfeed = SourceAdmin::feed_check($source->title);
                ?>
		
						<tr>
							<td style="width:16px;"><img src="<?php 
                echo $source->favicon;
                ?>
" alt="Favicon" style="width: 16px; height: 16;" /></td>
                            <td><a href="<?php 
                echo $source->profile_url;
                ?>
"><?php 
                echo $source->title;
                ?>
</a></td>
                        <?php 
                if ($isfeed == 1) {
                    ?>
					   	<td style="text-align:center;"><a href="<?php 
                    echo $source->feed_url;
                    ?>
"><img src="<?php 
                    bloginfo('template_directory');
                    ?>
/images/icon-feed.gif" alt="View"/></a></td>
                        <?php 
                } elseif ($isfeed == 0) {
                    ?>
                        <td style="text-align:center;">N/A</td>
                        <?php 
                } else {
                    ?>
                        <td style="text-align:center;">?</td>
                        <?php 
                }
                ?>
					   	<td style="text-align:center;"><?php 
                echo SourceAdmin::type_name($source->type);
                ?>
</td>
					   	<td style="text-align:center;"><?php 
                echo $streamed;
                ?>
</td>
					   	<td>
							<form method="post" action="<?php 
                echo $_SERVER['PHP_SELF'];
                ?>
?page=sourcemanager.php&amp;gather=true&amp;id=<?php 
                echo $source->id;
                ?>
">
							<?php 
                wp_nonce_field('wicketpixie-settings');
                ?>
								<input type="submit" value="Edit" />
								<input type="hidden" name="action" value="gather" />
							</form>
							</td>
							<td>
							<form method="post" action="<?php 
                echo $_SERVER['PHP_SELF'];
                ?>
?page=sourcemanager.php&amp;delete=true&amp;id=<?php 
                echo $source->id;
                ?>
">
							<?php 
                wp_nonce_field('wicketpixie-settings');
                ?>
								<input type="submit" name="action" value="Delete" />
								<input type="hidden" name="action" value="delete" />
							</form>
							</td>
                            <?php 
                if ($isfeed == 1) {
                    ?>
							<td>
							<form method="post" action="<?php 
                    echo $_SERVER['PHP_SELF'];
                    ?>
?page=sourcemanager.php&amp;flush=true&amp;id=<?php 
                    echo $source->id;
                    ?>
">
							<?php 
                    wp_nonce_field('wicketpixie-settings');
                    ?>
								<input type="submit" value="Flush" />
								<input type="hidden" name="action" value="flush" />
								<input type="hidden" name="flush_name" value="<?php 
                    echo $source->title;
                    ?>
" />
							</form>
							</td>
                            <?php 
                }
                ?>
						</tr>
					<?php 
            }
            ?>
					</table>
					<?php 
        } else {
            ?>
						<p>You don't have any Social Mes, why not add some?</p>
					<?php 
        }
        ?>
					<?php 
        if (isset($_REQUEST['gather'])) {
            ?>
						<?php 
            $data = SourceAdmin::gather($_REQUEST['id']);
            ?>
						<form method="post" action="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?page=sourcemanager.php&amp;edit=true" class="form-table" style="margin-bottom:30px;">
						<?php 
            wp_nonce_field('wicketpixie-settings');
            ?>
							<h2>Editing "<?php 
            echo $data[0]->title;
            ?>
"</h2>
							<p><input type="text" name="title" id="title" value="<?php 
            echo $data[0]->title;
            ?>
" /></p>
							<p><input type="text" name="profile" id="profile" value="<?php 
            echo $data[0]->profile_url;
            ?>
" /></p>
							<p><input type="text" name="url" id="url" value="<?php 
            echo $data[0]->feed_url;
            ?>
" /></p>
							<p><input type="checkbox" name="lifestream" id="lifestream" value="1" <?php 
            if ($data[0]->lifestream == '1') {
                echo 'checked';
            }
            ?>
> Add to Activity?</p>
							<p><input type="checkbox" name="updates" id="updates" value="1" <?php 
            if ($data[0]->updates == '1') {
                echo 'checked';
            }
            ?>
> Use for Status Updates?</p>
							<p>Type:
								<select name="type" id="type">
									<?php 
            foreach (SourceAdmin::types() as $type) {
                ?>
										<option value="<?php 
                echo $type->type_id;
                ?>
" <?php 
                if ($type->type_id == $data[0]->type) {
                    echo 'selected';
                }
                ?>
><?php 
                echo $type->name;
                ?>
</option>
									<?php 
            }
            ?>
								</select>
							</p>
							<p class="submit">
								<input name="save" type="submit" value="Save Social Me" />
								<input type="hidden" name="action" value="edit" />
								<input type="hidden" name="id" value="<?php 
            echo $data[0]->id;
            ?>
">
							</p>
						</form>
					<?php 
        }
        ?>
					<?php 
        if (SourceAdmin::check() != 'false' && !isset($_REQUEST['gather'])) {
            ?>
						<form method="post" action="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?page=sourcemanager.php&amp;add=true" class="form-table" style="margin-bottom:30px;">
						<?php 
            wp_nonce_field('wicketpixie-settings');
            ?>
							<h2>Add a New Social Me</h2>
							<p><input type="text" name="title" id="title" onfocus="if(this.value=='Social Me Title')value=''" onblur="if(this.value=='')value='Social Me Title';" value="Social Me Title" /></p>
							<p><input type="text" name="profile" id="profile" onfocus="if(this.value=='Profile URL')value=''" onblur="if(this.value=='')value='Profile URL';" value="Profile URL" /></p>
							<p><input type="text" name="url" id="url" onfocus="if(this.value=='Profile Feed URL')value=''" onblur="if(this.value=='')value='Profile Feed URL';" value="Profile Feed URL" /></p>
							<p><input type="checkbox" name="lifestream" id="lifestream" value="1" checked="checked"> Add to Activity Stream?</p>
							<p><input type="checkbox" name="updates" id="updates" value="1"> Use for Status Updates?</p>
							<p>Type:
								<select name="type" id="type">
									<?php 
            foreach (SourceAdmin::types() as $type) {
                ?>
										<option value="<?php 
                echo $type->type_id;
                ?>
"><?php 
                echo $type->name;
                ?>
</option>
									<?php 
            }
            ?>
								</select>
							</p>
							<p class="submit">
								<input name="save" type="submit" value="Save Social Me" />    
								<input type="hidden" name="action" value="add" />
							</p>
						</form>
						<form name="hulk_smash" id="hulk_smash" method="post" action="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?page=sourcemanager.php&amp;hulk_smash=true">
						<?php 
            wp_nonce_field('wicketpixie-settings');
            ?>
							<h2>Delete the Social Mes Table</h2>
							<p>Please note, this is undoable and will result in the loss of all the data you have stored to date. Only do this if you are having problems with your social mes and you have exhausted every other option.</p>
							<p class="submit">
								<input name="save" type="submit" value="Delete Social Mes" />    
								<input type="hidden" name="action" value="hulk_smash" />
							</p>
						</form>
						<?php 
        } else {
            ?>
							<p>Table not installed. You should go ahead and run the installer.</p>
							<form name="install" id="install" method="post" action="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?page=sourcemanager.php&amp;install=true">
							<?php 
            wp_nonce_field('wicketpixie-settings');
            ?>
								<p class="submit">
									<input type="hidden" name="action" value="install" />
									<input type="submit" value="Install Social Me" />
								</p>
							</form>
						<?php 
        }
        ?>
				
					</div>

					<?php 
        include_once 'advert.php';
        ?>
				
<?php 
    }