Exemplo n.º 1
0
<div id="<?php 
echo esc_attr($this->page);
?>
" class="<?php 
echo esc_attr($this->page);
?>
 awpcp-admin-page awpcp-page wrap">
	<div class="page-content">
		<h2 class="awpcp-page-header"><?php 
echo $this->title();
// title() is allowed to output html
?>
</h2>

        <?php 
$sidebar = $this->show_sidebar() ? awpcp_admin_sidebar() : '';
?>
        <?php 
echo $sidebar;
?>

		<div class="awpcp-main-content <?php 
echo empty($sidebar) ? 'without-sidebar' : 'with-sidebar';
?>
">
            <div class="awpcp-inner-content">
            <?php 
echo $content;
?>
            </div>
        </div>
    function awpcp_extra_fields_admin_head($show_settings = false)
    {
        global $awpcp;
        $output = '';
        $output .= "<div class=\"wrap\"><div id=\"icon-edit-pages\" class=\"icon32\"><br></div>";
        $output .= "<h2>";
        $output .= awpcp_admin_page_title(__('Extra Fields', 'awpcp-extra-fields'));
        $output .= "</h2>";
        $output .= "<div id=\"dashboard-widgets-wrap\">";
        // TODO: move this to a template when Extra Fields becomes a plugin
        if ($show_settings) {
            ob_start();
            ?>
        <div class="metabox-holder" style="float: left; width: 77%;">
        <div class="postbox">
            <h3 class="hndle"><span><?php 
            _e('Extra Field Settings', 'awpcp-extra-fields');
            ?>
</span></h3>
            <div class="inside">
            <form action="<?php 
            echo admin_url('options.php');
            ?>
" method="post">
            	<table class="form-table">
            	<?php 
            do_settings_fields('general-settings', 'extra-fields-settings');
            ?>
            	</table>
				<?php 
            settings_fields($awpcp->settings->setting_name);
            ?>
				<input type="hidden" name="group" value="<?php 
            echo 'general-settings';
            ?>
" />

				<p class="submit">
					<input type="submit" value="<?php 
            _e('Save Changes', 'awpcp-extra-fields');
            ?>
" class="button-primary" id="submit" name="submit">
				</p>
            </form>
            </div>
        </div>
        </div>
<?php 
            $output .= ob_get_contents();
            ob_end_clean();
        }
        $sidebar = awpcp_admin_sidebar();
        $output .= $sidebar;
        if (empty($sidebar)) {
            $output .= '<div class="postbox" style="padding:5px">';
        } else {
            $output .= '<div class="postbox" style="padding:5px; width:76%; float:left">';
        }
        $output .= '<div class="inside">';
        return $output;
    }
Exemplo n.º 3
0
	<div class="page-content">
        <?php 
if (version_compare(get_bloginfo('version'), '4.2.4', '<=')) {
    ?>
        <h2 class="awpcp-page-header"><?php 
    echo $page_title;
    ?>
</h2>
        <?php 
} else {
    ?>
        <h1 class="awpcp-page-header"><?php 
    echo $page_title;
    ?>
</h1>
        <?php 
}
?>

        <?php 
$show_sidebar = isset($show_sidebar) ? $show_sidebar : true;
?>
		<?php 
echo $sidebar = $show_sidebar ? awpcp_admin_sidebar() : '';
?>

		<div class="awpcp-main-content <?php 
echo empty($sidebar) ? 'without-sidebar' : 'with-sidebar';
?>
">
Exemplo n.º 4
0
function awpcp_opsconfig_categories()
{
    global $wpdb, $message, $awpcp_imagesurl, $clearform, $hascaticonsmodule;
    $cpagename_awpcp = get_awpcp_option('main-page-name');
    $awpcppagename = sanitize_title($cpagename_awpcp);
    $action = '';
    $output = '';
    $tbl_ad_categories = $wpdb->prefix . "awpcp_categories";
    $offset = isset($_REQUEST['offset']) ? clean_field($_REQUEST['offset']) : ($offset = 0);
    $results = isset($_REQUEST['results']) && !empty($_REQUEST['results']) ? clean_field($_REQUEST['results']) : ($results = 10);
    if (isset($_REQUEST['results']) && !empty($_REQUEST['results'])) {
        $results = max(intval($_REQUEST['results']), 5);
        update_user_option(get_current_user_id(), 'awpcp-admin-categories-results', $results);
    } else {
        $results = intval(get_user_option('awpcp-admin-categories-results', get_current_user_id()));
    }
    if (empty($results)) {
        $results = 10;
    }
    $cat_ID = '';
    $category_name = '';
    $aeaction = '';
    $category_parent_id = '';
    $promptmovetocat = '';
    $aeaction = '';
    ///////////////////
    // Check for existence of a category ID and action
    if (isset($_REQUEST['editcat']) && !empty($_REQUEST['editcat'])) {
        $cat_ID = $_REQUEST['editcat'];
        $action = "edit";
    } elseif (isset($_REQUEST['delcat']) && !empty($_REQUEST['delcat'])) {
        $cat_ID = $_REQUEST['delcat'];
        $action = "delcat";
    } elseif (isset($_REQUEST['managecaticon']) && !empty($_REQUEST['managecaticon'])) {
        $cat_ID = $_REQUEST['managecaticon'];
        $action = "managecaticon";
    } elseif (isset($_REQUEST['cat_ID']) && !empty($_REQUEST['cat_ID'])) {
        $cat_ID = $_REQUEST['cat_ID'];
    }
    if (!isset($action) || empty($action)) {
        if (isset($_REQUEST['action']) && !empty($_REQUEST['action'])) {
            $action = $_REQUEST['action'];
        }
    }
    if ($action == 'edit') {
        $aeaction = 'edit';
    }
    if ($action == 'editcat') {
        $aeaction = 'edit';
    }
    if ($action == 'delcat') {
        $aeaction = 'delete';
    }
    if ($action == 'managecaticon') {
        $return = apply_filters('awpcp-custom-manage-categories-action', '', $cat_ID);
        if ($return) {
            return;
        }
    }
    if ($action == 'setcategoryicon') {
        global $awpcp_plugin_path;
        if ($hascaticonsmodule == 1) {
            if (is_installed_category_icon_module()) {
                if (isset($_REQUEST['cat_ID']) && !empty($_REQUEST['cat_ID'])) {
                    $thecategory_id = $_REQUEST['cat_ID'];
                }
                if (isset($_REQUEST['category_icon']) && !empty($_REQUEST['category_icon'])) {
                    $theiconfile = $_REQUEST['category_icon'];
                } elseif (isset($_REQUEST['clear_icon'])) {
                    $theiconfile = null;
                } else {
                    $theiconfile = '';
                }
                if (isset($_REQUEST['offset']) && !empty($_REQUEST['offset'])) {
                    $offset = $_REQUEST['offset'];
                }
                $message = set_category_icon($thecategory_id, $theiconfile, $offset, $results);
                if (isset($message) && !empty($message)) {
                    $clearform = 1;
                }
            }
        }
    }
    if (isset($clearform) && $clearform == 1) {
        $action = $aeaction = null;
    }
    try {
        $category = awpcp_categories_collection()->get($cat_ID);
        $category_name = $category->name;
        $category_order = $category->order;
        $cat_parent_ID = $category->parent;
    } catch (AWPCP_Exception $e) {
        $category_name = null;
        $category_order = null;
        $cat_parent_ID = null;
    }
    $add_label = __('Add A New Category', 'AWPCP');
    $add_url = awpcp_get_admin_categories_url();
    $addnewlink = '<a class="" title="%1$s" href="%2$s"" accesskey="s">%1$s</a>';
    $addnewlink = sprintf($addnewlink, $add_label, $add_url);
    if ($aeaction == 'edit') {
        $aeword1 = __("You are currently editing the category shown below", "AWPCP");
        $aeword2 = __("Save Category Changes", "AWPCP");
        $aeword3 = __("Parent Category", "AWPCP");
        $aeword4 = __("Category List Order", "AWPCP");
    } elseif ($aeaction == 'delete') {
        if ($cat_ID != 1) {
            $aeword1 = __("If you're sure that you want to delete this category please press the delete button", "AWPCP");
            $aeword2 = __("Delete Category", "AWPCP");
            $aeword3 = __("Parent Category", "AWPCP");
            $aeword4 = '';
            if (ads_exist_cat($cat_ID)) {
                if (category_is_child($cat_ID)) {
                    $movetocat = get_cat_parent_ID($cat_ID);
                } else {
                    $movetocat = 1;
                }
                try {
                    $move_to_category = awpcp_categories_collection()->get($movetocat);
                    $movetoname = $move_to_category->name;
                } catch (AWPCP_Exception $e) {
                    $movetoname = __('Untitled', 'AWPCP');
                }
                $promptmovetocat = "<p>";
                $promptmovetocat .= __("The category contains ads. If you do not select a category to move them to the ads will be moved to:", "AWPCP");
                $promptmovetocat .= "<b>{$movetoname}</b></p>";
                try {
                    $move_to_category = awpcp_categories_collection()->get(1);
                    $defaultcatname = $move_to_category->name;
                } catch (AWPCP_Exception $e) {
                    $defaultcatname = __('Untitled', 'AWPCP');
                }
                if (category_has_children($cat_ID)) {
                    $promptmovetocat .= "<p>";
                    $promptmovetocat .= __("The category also has children. If you do not specify a move-to category the children will be adopted by", "AWPCP");
                    $promptmovetocat .= "<b>{$defaultcatname}</b><p><b>";
                    $promptmovetocat .= __("Note", "AWPCP");
                    $promptmovetocat .= ":</b>";
                    $promptmovetocat .= __("The move-to category specified applies to both ads and categories", "AWPCP");
                    $promptmovetocat .= "</p>";
                }
                $promptmovetocat .= "<p align=\"center\"><select name=\"movetocat\"><option value=\"0\">";
                $promptmovetocat .= __("Please select a Move-To category", "AWPCP");
                $promptmovetocat .= "</option>";
                $categories = get_categorynameid($cat_ID, $cat_parent_ID, $exclude = $cat_ID);
                $promptmovetocat .= "{$categories}</select>";
            }
            $thecategoryparentname = get_adparentcatname($cat_parent_ID);
        } else {
            $aeword1 = __('Sorry but you cannot delete %s. It is the default category and the default category cannot be deleted.', 'AWPCP');
            $aeword1 = sprintf($aeword1, '<strong>' . $category_name . '</strong>');
            $aeword2 = '';
            $aeword3 = '';
            $aeword4 = '';
        }
    } else {
        if (empty($aeaction)) {
            $aeaction = "newcategory";
        }
        $aeword1 = __('Add a New Category', 'AWPCP');
        $aeword2 = __("Add New Category", "AWPCP");
        $aeword3 = __("List Category Under", "AWPCP");
        $aeword4 = __("Category List Order", "AWPCP");
        $addnewlink = '';
    }
    if ($aeaction == 'delete') {
        $orderinput = '';
        if ($cat_ID == 1) {
            $categorynameinput = '';
            $selectinput = '';
        } else {
            $categorynameinput = "<span style=\"background:transparent url({$awpcp_imagesurl}/delete_ico.png) left center no-repeat;padding-left:20px;\">";
            $categorynameinput .= __("Category to Delete", "AWPCP");
            $categorynameinput .= ": {$category_name}</span>";
            $selectinput = "<p style=\"background:#D54E21;padding:3px;color:#ffffff;\">{$thecategoryparentname}</p>";
            $submitbuttoncode = "<input type=\"submit\" class=\"button-primary button\" name=\"createeditadcategory\" value=\"{$aeword2}\" />";
        }
    } elseif ($aeaction == 'edit') {
        $section_icon_style = "background:transparent url({$awpcp_imagesurl}/edit_ico.png) left center no-repeat;padding-left:20px;";
        $categorynameinput = __("Category to Edit", "AWPCP");
        $categorynameinput .= ": {$category_name} ";
        $categorynamefield = "<input name=\"category_name\" id=\"cat_name\" type=\"text\" class=\"inputbox\" value=\"{$category_name}\" size=\"40\" style=\"width: 90%\"/>";
        $selectinput = "<select name=\"category_parent_id\"><option value=\"0\">";
        $selectinput .= __("Make This a Top Level Category", "AWPCP");
        $selectinput .= "</option>";
        $orderinput = "<input name=\"category_order\" id=\"category_order\" type=\"text\" class=\"inputbox\" value=\"{$category_order}\" size=\"3\"/>";
        $categories = get_categorynameid($cat_ID, $cat_parent_ID, $exclude = '');
        $selectinput .= "{$categories}\n\t\t\t\t\t\t</select>";
        $submitbuttoncode = "<input type=\"submit\" class=\"button-primary button\" name=\"createeditadcategory\" value=\"{$aeword2}\" />";
    } else {
        $section_icon_style = "background:transparent url({$awpcp_imagesurl}/post_ico.png) left center no-repeat;padding-left:20px;";
        $categorynameinput = __('Enter the category name', 'AWPCP');
        $categorynamefield = "<input name=\"category_name\" id=\"cat_name\" type=\"text\" class=\"inputbox\" value=\"{$category_name}\" size=\"40\" style=\"width: 90%\"/>";
        $selectinput = "<select name=\"category_parent_id\"><option value=\"0\">";
        $selectinput .= __("Make This a Top Level Category", "AWPCP");
        $selectinput .= "</option>";
        $orderinput = "<input name=\"category_order\" id=\"category_order\" type=\"text\" class=\"inputbox\" value=\"{$category_order}\" size=\"3\"/>";
        $categories = get_categorynameid($cat_ID, $cat_parent_ID, $exclude = '');
        $selectinput .= "{$categories}\n\t\t\t\t\t</select>";
        $submitbuttoncode = "<input type=\"submit\" class=\"button-primary button\" name=\"createeditadcategory\" value=\"{$aeword2}\" />";
    }
    // Start the page display
    $output .= "<div class=\"wrap\"><h2>";
    $output .= awpcp_admin_page_title(__('Manage Categories', 'AWPCP'));
    $output .= "</h2>";
    if (isset($message) && !empty($message)) {
        $output .= $message;
    }
    $sidebar = awpcp_admin_sidebar();
    $output .= $sidebar;
    if (empty($sidebar)) {
        $output .= "<div style=\"padding:10px;\">";
    } else {
        $output .= "<div style=\"padding:10px; width: 75%\">";
    }
    $output .= "<b>";
    $output .= __("Icon Meanings", "AWPCP");
    $output .= ":</b> &nbsp;&nbsp;&nbsp;<img src=\"{$awpcp_imagesurl}/edit_ico.png\" alt=\"";
    $output .= __("Edit Category", "AWPCP");
    $output .= "\" border=\"0\"/>";
    $output .= __("Edit Category", "AWPCP");
    $output .= " &nbsp;&nbsp;&nbsp;<img src=\"{$awpcp_imagesurl}/delete_ico.png\" alt=\"";
    $output .= __("Delete Category", "AWPCP");
    $output .= "\" border=\"0\"/>";
    $output .= __("Delete Category", "AWPCP");
    if ($hascaticonsmodule == 1 && is_installed_category_icon_module()) {
        $label = __("Manage Category Icon", "AWPCP");
        $output .= " &nbsp;&nbsp;&nbsp;<img src=\"{$awpcp_imagesurl}/icon_manage_ico.png\" alt=\"";
        $output .= $label;
        $output .= "\" border=\"0\"/>";
        $output .= $label;
    }
    $output .= "\n\t\t\t </div>";
    if (empty($sidebar)) {
        $output .= "<div class=\"postbox\" style=\"padding:10px;\"><p>";
    } else {
        $output .= "<div class=\"postbox\" style=\"width:75%;float:left;padding:10px;\">";
    }
    $output .= "<form method=\"post\" id=\"awpcp_launch\">\n\t\t\t <input type=\"hidden\" name=\"category_id\" value=\"{$cat_ID}\" />\n\t\t\t  <input type=\"hidden\" name=\"aeaction\" value=\"{$aeaction}\" />\n\t\t\t  <input type=\"hidden\" name=\"offset\" value=\"{$offset}\" />\n\t\t\t  <input type=\"hidden\" name=\"results\" value=\"{$results}\" />\n\n\t\t\t<span style=\"line-height: 1.3em; {$section_icon_style}\"> {$aeword1}</span>\n\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"margin: 15px 0 12px\">\n\t\t\t\t<tr>\n\t\t\t\t\t<th style=\"text-align: left; padding-bottom: 4px; width: 40%\">{$categorynameinput}</th>\n\t\t\t\t\t<th style=\"text-align: left; padding-bottom: 4px; width: 25%\">{$aeword3}</th>\n\t\t\t\t\t<th style=\"text-align: left; padding-bottom: 4px; width: 20%\">{$aeword4}</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>{$categorynamefield}</td>\n\t\t\t\t\t<td>{$selectinput}</td>\n\t\t\t\t\t<td>{$orderinput}</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\n\t\t\t{$promptmovetocat}\n\n\t\t\t<div style=\"margin-top:5px;\">{$submitbuttoncode} {$addnewlink}</div>\n\t\t\t </form>\n\t\t\t </div>";
    if (empty($sidebar)) {
        $output .= "<div style=\"margin:0;padding:0px 0px 10px 0;\"><p>";
    } else {
        $output .= "<div style=\"margin:0;padding:0px 0px 10px 0;float:left;width:75%\">";
    }
    ///////////////////////////
    // Show the paginated categories list for management
    //////////////////////////
    $where = "category_name <> ''";
    $pager1 = create_pager(AWPCP_TABLE_CATEGORIES, $where, $offset, $results, $tpname = '');
    $pager2 = create_pager(AWPCP_TABLE_CATEGORIES, $where, $offset, $results, $tpname = '');
    $output .= "{$pager1} <form name=\"mycats\" id=\"mycats\" method=\"post\">\n\t\t <p><input type=\"submit\" name=\"deletemultiplecategories\" class=\"button\" value=\"";
    $output .= __("Delete Selected Categories", "AWPCP");
    $output .= "\" />\n\t\t <input type=\"submit\" name=\"movemultiplecategories\" class=\"button\" value=\"";
    $output .= __("Move Selected Categories", "AWPCP");
    $output .= "\" />\n\t\t <select name=\"moveadstocategory\"><option value=\"0\">";
    $output .= __("Select Move-To category", "AWPCP");
    $output .= "</option>";
    $movetocategories = get_categorynameid($cat_id = 0, $cat_parent_id = 0, $exclude);
    $output .= "{$movetocategories}</select></p>\n\t\t<p>";
    $output .= __('Delete categories should do this with existing Ads', 'AWPCP');
    $output .= ": <label><input type=\"radio\" name=\"movedeleteads\" value=\"1\" checked='checked' > " . __('Move Ads to new category', 'AWPCP') . "</label>";
    $output .= " <label><input type=\"radio\" name=\"movedeleteads\" value=\"2\" > " . __('Delete Ads too', 'AWPCP') . "</label></p>";
    $children = awpcp_get_categories_hierarchy();
    $categories = AWPCP_Category::query(array('orderby' => 'category_order, category_name', 'order' => 'ASC'));
    $count = 0;
    $items = awpcp_admin_categories_render_category_items($categories, $children, $offset, $results, $count);
    $opentable = '<table class="listcatsh"><tr>';
    $opentable .= '<td style="width:10%; text-align: center;">' . __('Category ID', 'AWPCP') . '</td>';
    $opentable .= "<td style=\"width:30%;padding:5px;\"><label><input type=\"checkbox\" onclick=\"CheckAll()\" />&nbsp;";
    $opentable .= __("Category Name (Total Ads)", "AWPCP");
    $opentable .= "</label></td><td style=\"width:35%;padding:5px;\">";
    $opentable .= __("Parent", "AWPCP");
    $opentable .= "</td><td style=\"width:5%;padding:5px;\">";
    $opentable .= __("Order", "AWPCP");
    $opentable .= "</td><td style=\"width:20%;padding:5px;;\">";
    $opentable .= __("Action", "AWPCP");
    $opentable .= "</td></tr>";
    $closetable = '<tr>';
    $closetable .= '<td>' . __('Category ID', 'AWPCP') . '</td>';
    $closetable .= '<td style="padding:5px;">';
    $closetable .= __("Category Name (Total Ads)", "AWPCP");
    $closetable .= "</td><td style=\"padding:5px;\">";
    $closetable .= __("Parent", "AWPCP");
    $closetable .= "</td><td style=\"padding:5px;\">";
    $closetable .= __("Order", "AWPCP");
    $closetable .= "</td><td style=\"padding:5px;\">";
    $closetable .= __("Action", "AWPCP");
    $closetable .= "</td></tr></table>";
    $theitems = smart_table2($items, intval($results / $results), $opentable, $closetable, false);
    $showcategories = "{$theitems}";
    $output .= "\n\t\t<style>\n\t\ttable.listcatsh { width: 100%; padding: 0px; border: none; border: 1px solid #dddddd;}\n\t\ttable.listcatsh td { font-size: 12px; border: none; background-color: #F4F4F4;\n\t\tvertical-align: middle; font-weight: bold; }\n\t\ttable.listcatsh tr.special td { border-bottom: 1px solid #ff0000;  }\n\t\ttable.listcatsc { width: 100%; padding: 0px; border: none; border: 1px solid #dddddd;}\n\t\ttable.listcatsc td { width:33%;border: none;\n\t\tvertical-align: middle; padding: 5px; font-weight: normal; }\n\t\ttable.listcatsc tr.special td { border-bottom: 1px solid #ff0000;  }\n\t\t</style>\n\t\t{$showcategories}\n\t\t</form>{$pager2}</div>";
    echo $output;
}