function mypageorder()
{
    global $wpdb;
    $parentID = 0;
    if (isset($_POST['btnSubPages'])) {
        $parentID = $_POST['pages'];
    } elseif (isset($_POST['hdnParentID'])) {
        $parentID = $_POST['hdnParentID'];
    }
    if (isset($_POST['btnReturnParent'])) {
        $parentsParent = $wpdb->get_row($wpdb->prepare("SELECT post_parent FROM {$wpdb->posts} WHERE ID = %d ", $_POST['hdnParentID']), ARRAY_N);
        $parentID = $parentsParent[0];
    }
    $success = "";
    if (isset($_POST['btnOrderPages'])) {
        $success = mypageorder_updateOrder();
    }
    $subPageStr = mypageorder_getSubPages($parentID);
    ?>

<div class='wrap'>
<form name="frmMyPageOrder" method="post" action="">
	<h2><?php 
    _e('My Page Order', 'mypageorder');
    ?>
</h2>
	<?php 
    echo $success;
    ?>
	
	<p><?php 
    _e('Choose a page from the drop down to order its subpages or order the pages on this level by dragging and dropping them into the desired order.', 'mypageorder');
    ?>
</p>
	
	<?php 
    if ($subPageStr != "") {
        ?>
	
	<h3><?php 
        _e('Order Subpages', 'mypageorder');
        ?>
</h3>
	<select id="pages" name="pages">
		<?php 
        echo $subPageStr;
        ?>
	</select>
	&nbsp;<input type="submit" name="btnSubPages" class="button" id="btnSubPages" value="<?php 
        _e('Order Subpages', 'mypageorder');
        ?>
" />
	<?php 
    }
    ?>

	<h3><?php 
    _e('Order Pages', 'mypageorder');
    ?>
</h3>
	
	<ul id="myPageOrderList">
	<?php 
    $results = mypageorder_pageQuery($parentID);
    foreach ($results as $row) {
        echo "<li id='id_{$row->ID}' class='lineitem'>" . __($row->post_title) . "</li>";
    }
    ?>
	</ul>

	<input type="submit" name="btnOrderPages" id="btnOrderPages" class="button-primary" value="<?php 
    _e('Click to Order Pages', 'mypageorder');
    ?>
" onclick="javascript:orderPages(); return true;" />
	<?php 
    echo mypageorder_getParentLink($parentID);
    ?>
	&nbsp;&nbsp;<strong id="updateText"></strong>
	<br /><br />
	<p>
	<a href="http://geekyweekly.com/mypageorder"><?php 
    _e('Plugin Homepage', 'mypageorder');
    ?>
</a>&nbsp;|&nbsp;<a href="http://geekyweekly.com/gifts-and-donations"><?php 
    _e('Donate', 'mypageorder');
    ?>
</a>&nbsp;|&nbsp;<a href="http://wordpress.org/tags/my-page-order?forum_id=10"><?php 
    _e('Support Forum', 'mypageorder');
    ?>
</a>
	</p>
	<input type="hidden" id="hdnMyPageOrder" name="hdnMyPageOrder" />
	<input type="hidden" id="hdnParentID" name="hdnParentID" value="<?php 
    echo $parentID;
    ?>
" />
</form>
</div>

<style type="text/css">
	#myPageOrderList {
		width: 90%; 
		border:1px solid #B2B2B2; 
		margin:10px 10px 10px 0px;
		padding:5px 10px 5px 10px;
		list-style:none;
		background-color:#fff;
		-moz-border-radius:3px;
		-webkit-border-radius:3px;
	}

	li.lineitem {
		border:1px solid #B2B2B2;
		-moz-border-radius:3px;
		-webkit-border-radius:3px;
		background-color:#F1F1F1;
		color:#000;
		cursor:move;
		font-size:13px;
		margin-top:5px;
		margin-bottom:5px;
		padding: 2px 5px 2px 5px;
		height:1.5em;
		line-height:1.5em;
	}
	
	.sortable-placeholder{ 
		border:1px dashed #B2B2B2;
		margin-top:5px;
		margin-bottom:5px; 
		padding: 2px 5px 2px 5px;
		height:1.5em;
		line-height:1.5em;	
	}
</style>

<script type="text/javascript">
// <![CDATA[

	function mypageorderaddloadevent(){
		jQuery("#myPageOrderList").sortable({ 
			placeholder: "sortable-placeholder", 
			revert: false,
			tolerance: "pointer" 
		});
	};

	addLoadEvent(mypageorderaddloadevent);
	
	function orderPages() {
		jQuery("#updateText").html("<?php 
    _e('Updating Page Order...', 'mypageorder');
    ?>
");
		jQuery("#hdnMyPageOrder").val(jQuery("#myPageOrderList").sortable("toArray"));
	}

// ]]>
</script>
<?php 
}
Beispiel #2
0
function mypageorder()
{
    global $wpdb;
    $mode = "";
    $mode = $_GET['mode'];
    $parentID = 0;
    if (isset($_GET['parentID'])) {
        $parentID = $_GET['parentID'];
    }
    if (isset($_GET['hideNote'])) {
        update_option('mypageorder_hideNote', '1');
    }
    $success = "";
    if ($mode == "act_OrderPages") {
        $success = mypageorder_updateOrder();
    }
    $subPageStr = mypageorder_getSubPages($parentID);
    ?>

<div class='wrap'>
	<h2><?php 
    _e('My Page Order', 'mypageorder');
    ?>
</h2>
	<?php 
    echo $success;
    if (get_option("mypageorder_hideNote") != "1") {
        ?>
		<div class="updated">
			<strong><p><?php 
        _e('If you like my plugin please consider donating. Every little bit helps me provide support and continue development.', 'mypageorder');
        ?>
 <a href="http://geekyweekly.com/gifts-and-donations"><?php 
        _e('Donate', 'mypageorder');
        ?>
</a>&nbsp;&nbsp;<small><a href="<?php 
        echo mypageorder_getTarget() . "?page=mypageorder&hideNote=true";
        ?>
"><?php 
        _e('No thanks, hide this', 'mypageorder');
        ?>
</a></small></p></strong>
		</div>
	<?php 
    }
    ?>
	
	<p><?php 
    _e('Choose a page from the drop down to order its subpages or order the pages on this level by dragging and dropping them into the desired order.', 'mypageorder');
    ?>
</p>
	<?php 
    echo mypageorder_getParentLink($parentID);
    if ($subPageStr != "") {
        ?>
	
	<h3><?php 
        _e('Order Subpages', 'mypageorder');
        ?>
</h3>
	<select id="pages" name="pages">
		<?php 
        echo $subPageStr;
        ?>
	</select>
	&nbsp;<input type="button" name="edit" Value="<?php 
        _e('Order Subpages', 'mypageorder');
        ?>
" onClick="javascript:goEdit();">
<?php 
    }
    ?>

	<h3><?php 
    _e('Order Pages', 'mypageorder');
    ?>
</h3>
	
	<ul id="order" style="width: 90%; margin:10px 10px 10px 0px; padding:10px; border:1px solid #B2B2B2; list-style:none;">
	<?php 
    $results = mypageorder_pageQuery($parentID);
    foreach ($results as $row) {
        echo "<li id='{$row->ID}' class='lineitem'>{$row->post_title}</li>";
    }
    ?>
	</ul>
	
	<input type="button" id="orderButton" Value="<?php 
    _e('Click to Order Pages', 'mypageorder');
    ?>
" onclick="javascript:orderPages();">&nbsp;&nbsp;<strong id="updateText"></strong>

	<p>
	<a href="http://geekyweekly.com/mypageorder"><?php 
    _e('Plugin Homepage', 'mypageorder');
    ?>
</a>
	&nbsp;|&nbsp;
	<a href="http://geekyweekly.com/gifts-and-donations"><?php 
    _e('Donate', 'mypageorder');
    ?>
</a>
	&nbsp;|&nbsp;
	<a href="http://wordpress.org/tags/my-page-order?forum_id=10"><?php 
    _e('Support Forum', 'mypageorder');
    ?>
</a>
	</p>
</div>

<style>
	li.lineitem {
		margin: 3px 0px;
		padding: 2px 5px 2px 5px;
		background-color: #F1F1F1;
		border:1px solid #B2B2B2;
		cursor: move;

	}
</style>

<script type="text/javascript">
// <![CDATA[

	function mypageorderaddloadevent(){
		jQuery("#order").sortable({ 
			placeholder: "ui-selected", 
			revert: false,
			tolerance: "pointer" 
		});
	};

	addLoadEvent(mypageorderaddloadevent);
	
	function orderPages() {
		jQuery("#orderButton").css("display", "none");
		jQuery("#updateText").html("<?php 
    _e('Updating Page Order...', 'mypageorder');
    ?>
");

		idList = jQuery("#order").sortable("toArray");
		location.href = '<?php 
    echo mypageorder_getTarget();
    ?>
?page=mypageorder&mode=act_OrderPages&parentID=<?php 
    echo $parentID;
    ?>
&idString='+idList;
	}

	function goEdit () {
		if(jQuery("#pages").val() != "")
			location.href="<?php 
    echo mypageorder_getTarget();
    ?>
?page=mypageorder&mode=dsp_OrderPages&parentID="+jQuery("#pages").val();
	}
// ]]>
</script>
<?php 
}