コード例 #1
0
ファイル: themes.php プロジェクト: vinothtimes/dchqtest
function &JB_get_ListMarkupObject($arg = 'JBListMarkup')
{
    static $ListMarkup;
    if (is_numeric($arg)) {
        // $arg is a form_id
        switch ($arg) {
            case 1:
                $class_name = 'JBPostListMarkup';
                break;
            case 2:
                $class_name = 'JBResumeListMarkup';
                break;
            default:
                $class_name = 'JBListMarkup';
                break;
        }
    } else {
        $class_name = $arg;
    }
    JBPLUG_do_callback('set_ListMarkup_class_name', $class_name);
    // plugin authors can change the name of the class, and have their plugin subclass JBListMarkup and then set the $class_name to their sub class.
    if (isset($ListMarkup[$class_name])) {
        return $ListMarkup[$class_name];
    }
    if (file_exists(JB_THEME_PATH . "JBListMarkup.php")) {
        include_once JB_THEME_PATH . "JBListMarkup.php";
    } else {
        include_once JB_DEFAULT_THEME_PATH . "JBListMarkup.php";
    }
    switch ($class_name) {
        case 'JBPostListMarkup':
            $ListMarkup[$class_name] = JB_get_PostListMarkupObject();
            break;
        case 'JBResumeListMarkup':
            $ListMarkup[$class_name] = JB_get_ResumeListMarkupObject();
            break;
        case 'JBAppListMarkup':
            $ListMarkup[$class_name] = JB_get_AppListMarkupObject();
            break;
        case 'JBIframeListMarkup':
            $ListMarkup[$class_name] = JB_get_IframeListMarkupObject();
            break;
        case 'JBListMarkup':
            $ListMarkup[$class_name] = new JBListMarkup();
            break;
        case 'JBRequestListMarkup':
            $ListMarkup[$class_name] = new JBRequestListMarkup();
            break;
        case 'JBProductListMarkup':
            $ListMarkup[$class_name] = new JBProductListMarkup();
            break;
        case 'JBOrdersListMarkup':
            $ListMarkup[$class_name] = new JBOrdersListMarkup();
            break;
        case 'JBMembershipStatusMarkup':
            $ListMarkup[$class_name] = new JBMembershipStatusMarkup();
            break;
        case 'JBSubscriptionStatusMarkup':
            $ListMarkup[$class_name] = new JBSubscriptionStatusMarkup();
            break;
        case 'JBPaymentOptionListMarkup':
            $ListMarkup[$class_name] = new JBPaymentOptionListMarkup();
        default:
            JBPLUG_do_callback('get_ListMarkupObject', $ListMarkup, $class_name);
            if (!isset($ListMarkup[$class_name])) {
                $ListMarkup[$class_name] = new JBListMarkup();
            }
            break;
    }
    return $ListMarkup[$class_name];
}
コード例 #2
0
ファイル: resumes.inc.php プロジェクト: vinothtimes/phpdoc
function JB_list_resumes($list_mode, $show = '')
{
    global $resume_tag_to_field_id;
    global $tag_to_search;
    global $label;
    // languages array
    $LM =& JB_get_ResumeListMarkupObject();
    // load the ListMarkup Class
    $LM->set_list_mode($list_mode);
    $LM->set_show($show);
    if ($list_mode == 'ADMIN') {
        $admin = true;
    }
    ###########################################
    # initialize
    #
    if (!defined('JB_RESUMES_PER_PAGE')) {
        $resumes_per_page = 30;
    } else {
        $resumes_per_page = JB_RESUMES_PER_PAGE;
    }
    $order = jb_alpha_numeric($_REQUEST['order_by']);
    if ($_REQUEST['ord'] == 'asc') {
        $ord = 'ASC';
    } elseif ($_REQUEST['ord'] == 'desc') {
        $ord = 'DESC';
    } else {
        $ord = 'DESC';
        // sort descending by default
    }
    if ($order == '' || !JB_is_field_valid($order, 2)) {
        // by default, order by the post_date
        $order = " `resume_date` ";
    } else {
        $order = " `" . jb_escape_sql($order) . "` ";
    }
    $offset = (int) $_REQUEST['offset'];
    if ($offset < 0) {
        $offset = abs($offset);
    }
    if ($offset == '') {
        $offset = 0;
    }
    // build the search query string
    global $action;
    // process search result
    if ($_REQUEST['action'] == 'search') {
        $q_string = JB_generate_q_string(2);
        $where_sql = JB_generate_search_sql(2);
    }
    $cat = (int) $_REQUEST['cat'];
    if ($cat != '') {
        $cat = "&amp;cat={$cat}";
        $cat_sql = JB_search_category_tree_for_resumes();
    }
    if ($admin) {
        $where_status = " `status` != 'x' ";
    } else {
        $where_status = " `status`='ACT' ";
    }
    $approved = "";
    if ($show == 'WA') {
        // Admin is true, WA will show posts waiting to be approved
        $where_sql = " AND approved='N' ";
    } else {
        $approved = "t1.approved='Y' AND ";
    }
    #####################3
    # Set the LIMIT part of the sql query
    $limit_sql = "LIMIT " . jb_escape_sql($offset) . "," . jb_escape_sql($resumes_per_page) . " ";
    ##################################
    # How to get the resume count
    # If not searching by category, then
    if ($where_sql == '' && $cat_sql == '') {
        if ($admin) {
            // showing all resumes, active, not approved and suspended
            $resume_count = JB_get_resume_count('ALL');
        } else {
            // showing active & approved
            $resume_count = JB_get_resume_count('ACT');
        }
        if ($resume_count === null) {
            $calc_found_rows_sql = 'SQL_CALC_FOUND_ROWS';
        }
    } else {
        $calc_found_rows_sql = 'SQL_CALC_FOUND_ROWS';
    }
    if ($list_mode == 'SAVED') {
        $order = 'save_date';
        $calc_found_rows_sql = 'SQL_CALC_FOUND_ROWS';
        $sql = "SELECT {$calc_found_rows_sql} * FROM `saved_resumes` AS t1\n\t\tLEFT JOIN `resumes_table` as t2 on t2.resume_id=t1.resume_id\n\t\t WHERE t1.user_id='" . jb_escape_sql($_SESSION['JB_ID']) . "'   ORDER BY {$order} {$ord} {$limit_sql}";
    } elseif ($tag_to_search['smx_exists']) {
        // a skill matrix exists.. use the JOIN version of the query (Slower)
        // Using a LEFT JOIN because we want to have null values if no data for skill_matrix_data
        $sql = "Select {$calc_found_rows_sql} *, t1.user_id AS user_id FROM `resumes_table` AS t1 LEFT JOIN `skill_matrix_data` AS t2 ON t1.resume_id=t2.object_id WHERE {$approved}  {$where_status} {$where_sql} {$cat_sql} group by t1.resume_id ORDER BY {$order} {$ord} {$appr_order} {$limit_sql} ";
    } else {
        $sql = "Select {$calc_found_rows_sql}  * FROM `resumes_table`  as t1 WHERE   {$approved} {$where_status} {$where_sql} {$cat_sql}  ORDER BY  {$order} {$ord}  {$limit_sql} ";
    }
    $result = JB_mysql_query($sql) or die(mysql_error());
    ############
    # get the count if not initialized
    # Ask MySQL to get the number of rows from the last query
    if ($calc_found_rows_sql) {
        # Even though the last query had a LIMIT clause
        $row = mysql_fetch_row(jb_mysql_query("SELECT FOUND_ROWS()"));
        $resume_count = $row[0];
    }
    if ($resume_count > 0) {
        // estimate number of pages.
        $pages = ceil($resume_count / $resumes_per_page);
        if ($pages == 1) {
            // only one page - no need to show page navigation links
        } else {
            $pages = ceil($resume_count / $resumes_per_page);
            $cur_page = $offset / $resumes_per_page;
            $cur_page++;
            $LM->nav_pages_start();
            //echo "Page $cur_page of $pages - ";
            $label["navigation_page"] = str_replace("%CUR_PAGE%", $cur_page, $label["navigation_page"]);
            $label["navigation_page"] = str_replace("%PAGES%", $pages, $label["navigation_page"]);
            $LM->nav_pages_status();
            $nav = JB_nav_pages_struct($result, $q_string, $resume_count, $resumes_per_page);
            $LINKS = 10;
            JB_render_nav_pages($nav, $LINKS, $q_string, $show_emp, $cat);
            $LM->nav_pages_end();
        }
        // How many columns? (the hits column does not count here...)
        ob_start();
        // buffer the output, so that we can calculate the colspan.
        $colspan = JB_echo_list_head_data(2, $admin);
        // output the header columns
        $list_head_data = ob_get_contents();
        ob_end_clean();
        JBPLUG_do_callback('resume_list_set_colspan', $colspan);
        // set the colspan value
        $LM->set_colspan($colspan);
        if ($list_mode == 'EMPLOYER' || $list_mode == 'ADMIN' || $list_mode == 'SAVED') {
            $LM->open_form();
        }
        $LM->list_start();
        if ($list_mode == 'ADMIN') {
            // controls (approve button / disapprove button)
            $LM->admin_list_controls();
        } elseif ($list_mode == 'EMPLOYER') {
            $LM->employer_list_controls();
        } elseif ($list_mode == 'SAVED') {
            $LM->saved_list_controls();
        }
        #######################################
        # Open the list heading section
        $LM->list_head_open();
        if ($list_mode == 'ADMIN') {
            $LM->list_head_admin_action();
            JBPLUG_do_callback('resume_list_head_admin_action', $A = false);
        } elseif ($list_mode == 'EMPLOYER') {
            $LM->list_head_employer_action();
        } elseif ($list_mode == 'SAVED') {
            $LM->list_head_saved_action();
        }
        JBPLUG_do_callback('resume_list_head_user_action', $A = false);
        #######################################
        echo $list_head_data;
        #######################################
        # Close the list heading section
        $LM->list_head_close();
        $i = 0;
        JBPLUG_do_callback('resume_list_pre_fill', $i, $admin);
        //A plugin can list its own records before, and adjust the $i
        while (($row = mysql_fetch_array($result, MYSQL_ASSOC)) && $i < $resumes_per_page) {
            $LM->set_values($row);
            JBPLUG_do_callback('resume_list_set_data', $row, $i, $list_mode);
            // A plugin can modify the prams
            $i++;
            if ($admin) {
                // If Administrator, then can view private details.
                $row['anon'] = 'N';
            }
            $LM->list_item_open($admin);
            if ($list_mode == 'ADMIN') {
                $LM->list_data_admin_action();
                JBPLUG_do_callback('resume_list_data_admin_action', $LM);
            } elseif ($list_mode == 'SAVED') {
                $LM->list_data_saved_action();
            } elseif ($list_mode == 'EMPLOYER') {
                $LM->list_data_employer_action();
            }
            JBPLUG_do_callback('resume_list_data_user_action', $LM);
            JB_echo_resume_list_data($admin);
            $LM->list_item_close();
        }
        JBPLUG_do_callback('resume_list_back_fill', $i, $admin);
        // A plugin can list its own records after
        $LM->list_end();
        if ($list_mode == 'EMPLOYER' || $list_mode == 'ADMIN') {
            $LM->close_form();
        }
        $LM->nav_pages_start();
        JB_render_nav_pages($nav, $LINKS, $q_string, $show_emp, $cat);
        $LM->nav_pages_end();
    } else {
        $LM->no_resumes();
    }
}