Update documentation in classes
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 17 Dec 2014 14:35:27 +0000 (09:35 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 17 Dec 2014 14:35:27 +0000 (09:35 -0500)
Update README.md file

README.md
controllers/admin.php
controllers/front.php
glm-employment.php
models/database.php
models/job.php

index d445eba..64ea532 100644 (file)
--- a/README.md
+++ b/README.md
@@ -3,35 +3,39 @@
 
 ##Models:
     job.php         = job posting
-    application.php = user submitted application form
+    database.php    = database
+
+    list-applications.php    = using copy of list table class extends to create
+        list of applications
+    class-glm-list-table.php = copy from wordpress core file to protect against
+        wordpress updates for this class
 
 
 ##Views:
     Admin
-        index.php
-        listJobs.php
-        editJob.php
-        listApplications.php
-        viewApplication.php
-        printApplication.php
+        applicationList.php
+        form_1.php
+        job_meta.php
+        view-application.php
 
     Front
-        index.php
-        listJobs.php
-        viewJob.php
-        applyOnline.php
+        formTemplate.php
+        jobDetail.php
+        jobList.php
+        jobSearch.php
+        thankYou.php
 
 
 ##Controllers:
-    pluginController.php
-        Used to setup the actions and hooks for the plugin to function in admin or the front.
-
-    adminController.php = for the admin side
+    admin.php = for the admin side
         activate-plugin.php
             should have an init function for creating the database tables
         upgrade-plugin.php
             should have functions for upgrading the database versions
 
-    frontController.php = for front end
+    front.php = for front end
 
+##Config:
+    config files for each form
+        setting{1-7}.php
 
index 5af6a65..119a20d 100644 (file)
@@ -9,8 +9,15 @@ defined('ABSPATH') or die();
  */
 class glm_employment_admin
 {
-
+    /**
+     * Plugin Directory Name
+     * @var type
+     */
     public $pluginDirName;
+    /**
+     * Wordpress Database object
+     * @var type
+     */
     public $wpdb;
 
     /**
@@ -24,6 +31,9 @@ class glm_employment_admin
         add_action('admin_menu', array($this, 'add_job_menus'));
     }
 
+    /**
+     * Add job menus
+     */
     public function add_job_menus()
     {
         add_submenu_page(
@@ -44,11 +54,20 @@ class glm_employment_admin
 //        );
     }
 
+    /**
+     * show job settings
+     */
     public function show_job_settings()
     {
         echo '<p>Job Settings</p>';
     }
 
+    /**
+     * Show the applications
+     *
+     * Will check the Get action and see if it needs to view the application
+     * or show the application list
+     */
     public function get_applications()
     {
         $action = filter_var($_GET['action'], FILTER_SANITIZE_STRING);
@@ -62,6 +81,9 @@ class glm_employment_admin
         }
     }
 
+    /**
+     * View the application for one id
+     */
     public function view_application()
     {
         wp_enqueue_script(
@@ -97,6 +119,9 @@ class glm_employment_admin
         echo '</div>';
     }
 
+    /**
+     * Show application list
+     */
     public function show_applications()
     {
         $path = plugin_dir_path(GLM_EMP_PLUGIN_PATH_FILE);
@@ -106,20 +131,13 @@ class glm_employment_admin
         include $this->pluginDirName . 'views/admin/applicationList.php';
     }
 
-    public function glm_jobs($atts)
-    {
-        extract(shortcode_atts(array('limit' => '10'), $atts));
-        global $wpdb;
-        $sql = "SELECT * FROM $wpdb->posts WHERE post_type = '"
-            . GLM_EMP_POST_TYPE . "'";
-        $jobs = $wpdb->get_results($sql, OBJECT);
-        ob_start();
-        include $this->pluginDirName . 'views/front/jobList.php';
-        $out = ob_get_contents();
-        ob_end_clean();
-        return $out;
-    }
-
+    /**
+     * Sets the plugin directory
+     *
+     * @param type $dir Directory name
+     *
+     * @return void
+     */
     public function setPluginDir($dir)
     {
         $this->pluginDirName = $dir;
index ec99176..cb4a766 100644 (file)
@@ -58,11 +58,22 @@ class glm_employment_front
         $this->settingDir   = $this->pluginDirName . self::FORM_SETTINGS_DIR;
     }
 
+    /**
+     * Set the form state
+     *
+     * $this->formSubmitted will be true if the form has the
+     * self::FORM_VAR set
+     */
     public function set_form_state()
     {
         $this->formSubmitted = isset($_POST[self::FORM_VAR]);
     }
 
+    /**
+     * Job display short code
+     *
+     * @param type $atts Attributes
+     */
     public function glm_jobs_shortcode($atts)
     {
         extract(shortcode_atts(array('limit' => '10'), $atts));
@@ -82,12 +93,23 @@ class glm_employment_front
         }
     }
 
+    /**
+     * Load the form setting from the config file
+     *
+     * @param type $form_part Form part to load
+     *
+     * @return type
+     */
+
     public function load_form_settings($form_part = '')
     {
         include $this->settingDir . "/settings{$form_part}.php";
         return $form;
     }
 
+    /**
+     * Show the application form
+     */
     public function show_apply_form()
     {
         $formPart = (isset($_REQUEST['form_part']))
@@ -150,6 +172,11 @@ class glm_employment_front
         }
     }
 
+    /**
+     * Store the application resume file into the directory and the database table
+     *
+     * @return boolean
+     */
     public function store_resume_file()
     {
         echo '<pre>'.print_r($form, true).'</pre>';
@@ -174,6 +201,13 @@ class glm_employment_front
             }
     }
 
+    /**
+     * Store the main application form data
+     *
+     * @param type $form Form array
+     *
+     * @return type
+     */
     public function store_application_data($form)
     {
         if ($this->appId = filter_var($_REQUEST['appId'], FILTER_VALIDATE_INT)) {
@@ -203,6 +237,14 @@ class glm_employment_front
         return $this->appId;
     }
 
+    /**
+     * Store the data for the form to the database per form part
+     *
+     * @param type $form      Form array
+     * @param type $form_part Part number
+     *
+     * @return boolean
+     */
     public function store_form_data($form, $form_part)
     {
         // check if there's one stored first
@@ -262,6 +304,13 @@ class glm_employment_front
         );
     }
 
+    /**
+     * Process the form by form part number
+     *
+     * @param type $part Form number
+     *
+     * @return string
+     */
     public function form_process($part)
     {
         $this->clean_post();
@@ -306,6 +355,9 @@ class glm_employment_front
         return $form;
     }
 
+    /**
+     * Clean the post array (trim each field)
+     */
     public function clean_post()
     {
         foreach ($_POST as $key => $val) {
@@ -313,6 +365,16 @@ class glm_employment_front
         }
     }
 
+    /**
+     * Display the job for given id
+     *
+     * @global type $wpdb Word Press Database Object
+     * @global type $wp   Wordpress global $wp variable
+     *
+     * @param type $job_id Job id to display
+     *
+     * @return type
+     */
     public function show_job($job_id)
     {
         global $wpdb, $wp;
@@ -336,6 +398,15 @@ class glm_employment_front
         return;
     }
 
+    /**
+     * List the jobs that are currently set to display
+     * based on start and end dates
+     *
+     * @global type $wpdb Word Press Database Object
+     * @global type $wp   Global WP object
+     *
+     * @return type
+     */
     public function list_jobs()
     {
         global $wpdb, $wp;
@@ -401,6 +472,9 @@ class glm_employment_front
         return;
     }
 
+    /**
+     * Front end job search form
+     */
     public function search_form()
     {
         $glm_jobscategory = (isset($_REQUEST['glm_jobscategory']))
@@ -454,11 +528,19 @@ class glm_employment_front
         include $this->frontViewDir . '/jobSearch.php';
     }
 
+    /**
+     * Sets the plugin directory
+     *
+     * @param type $dir Plugin directory
+     */
     public function setPluginDir($dir)
     {
         $this->pluginDirName = $dir;
     }
 
+    /**
+     * Create session for the online form
+     */
     public function startJobSession()
     {
         if (!session_id()) {
index 03ef072..dfb83d2 100644 (file)
@@ -9,7 +9,9 @@
  */
 
 defined('ABSPATH') or die();
-
+/**
+ * Defines for the plugin
+ */
 define('GLM_EMP_PLUGIN_PATH_FILE', __FILE__);
 define('GLM_EMP_VERSION', '0.0.1');
 define('GLM_EMP_VRS_OPTION_NAME', 'glm_jobs_db_version');
@@ -21,18 +23,25 @@ define('GLM_EMP_FORM_TABLE', 'glm_jobs_app_form');
 $wp_upload_dir = wp_upload_dir();
 define('GLM_EMP_UPLOAD_DIR', $wp_upload_dir['basedir'] . '/glm-emp/');
 define('GLM_EMP_UPLOAD_URL', $wp_upload_dir['baseurl'] . '/glm-emp/');
+/**
+ * Create the upload directory for the resume files if not already there
+ */
 if (!is_dir(GLM_EMP_UPLOAD_DIR)) {
     // create the upload directory
     $oldUmask = umask(0);
     mkdir(GLM_EMP_UPLOAD_DIR, 0770);
     umask($oldUmask);
 }
-
+/**
+ * Require the class files
+ */
 require_once 'controllers/admin.php';
 require_once 'controllers/front.php';
 require_once 'models/job.php';
-
 require_once 'models/database.php';
+/**
+ * The Database class
+ */
 $glm_member_db = new glm_employment_models_database($GLOBALS['wpdb']);
 
 /**
@@ -59,6 +68,9 @@ class glm_employment_setup
 
 $employmentApp = new glm_employment_setup();
 
+/**
+ * Load style sheet for displaying the view and print for the application forms
+ */
 function glm_load_style()
 {
     wp_enqueue_style('foundation',
index 31caccc..985c1cd 100644 (file)
@@ -33,6 +33,11 @@ class glm_employment_models_database
     public $applicationTable;
     public $appFormTable;
 
+    /**
+     * Clas constructor for the database
+     *
+     * @param type $wpdb Wordpress db object
+     */
     public function __construct($wpdb)
     {
         $this->wpdb = $wpdb;
@@ -46,6 +51,9 @@ class glm_employment_models_database
         $this->appFormTable     = $this->wpdb->prefix . GLM_EMP_FORM_TABLE;
     }
 
+    /**
+     * Install the database tables needed for jobs
+     */
     public function install()
     {
         $charset_collate = $this->wpdb->get_charset_collate();
@@ -77,6 +85,9 @@ class glm_employment_models_database
         update_option(GLM_EMP_VRS_OPTION_NAME, GLM_EMP_VERSION);
     }
 
+    /**
+     * DB Version update check to update the database tables
+     */
     public function glm_emp_update_db_check()
     {
         if (GLM_EMP_VERSION != get_option(GLM_EMP_VRS_OPTION_NAME)) {
index 643e11f..c3d9022 100644 (file)
@@ -1,16 +1,26 @@
 <?php
-
+/**
+ * Sets up the job post type and its taxonomies. Handles also the new fields in
+ * the metaboxes.
+ */
 class glm_employment_job
 {
 
     public $pluginDirName;
 
+    /**
+     * Contstructor for the job class
+     *
+     * Calls filters and actions to setup Job post type
+     *
+     * @param type $path Plugin Path
+     */
     public function __construct($path)
     {
         $this->pluginDirName = $path;
         add_action('init', array($this, 'addPostTypes'));
-        add_action('init', array($this, 'createJobTaxonomy'), 0);
-        
+        add_action('init', array($this, 'createJobTaxonomy'));
+
         add_filter('post_updated_messages', array($this, 'jobsUpdatedMessages'));
 
         add_filter('manage_edit-glm_jobs_columns',
@@ -20,12 +30,19 @@ class glm_employment_job
                     array($this, 'jobsCustomColumns'));
         add_action('admin_init', array($this, 'metaDates'));
         add_action('save_post', array($this, 'saveEmpMeta'));
-        add_filter('manage_edit-glm_jobs_sortable_columns', array($this, 'sortByDates'));
-        add_filter('restrict_manage_posts', array($this, 'jobFilterList'));
+        add_filter('manage_edit-glm_jobs_sortable_columns', array($this, 'sortingColumns'));
+        add_action('restrict_manage_posts', array($this, 'jobFilterList'));
         add_filter('parse_query', array($this, 'jobFilter'));
     }
 
-    public function sortByDates($columns)
+    /**
+     * Add sorting by columns
+     *
+     * @param type $columns Array of columns
+     *
+     * @return arrray
+     */
+    public function sortingColumns($columns)
     {
         $columns['glmjobs_col_date'] = 'glmjobs_col_date';
         $columns['glmjobs_col_cat']  = 'glmjobs_col_cat';
@@ -33,7 +50,14 @@ class glm_employment_job
         return $columns;
     }
 
-    public function jobFilter(&$query)
+    /**
+     * Filter for the parse_query action
+     *
+     * @param type $query WP_Query object
+     *
+     * @return Object $query
+     */
+    public function jobFilter($query)
     {
         $qv =& $query->query_vars;
 
@@ -52,6 +76,11 @@ class glm_employment_job
         return $query;
     }
 
+    /**
+     * Setup the two drop downs for the Taxonomies
+     *
+     * @global type $wp_query
+     */
     public function jobFilterList()
     {
         $screen = get_current_screen();
@@ -84,12 +113,19 @@ class glm_employment_job
         }
     }
 
+    /**
+     * Add meta box for dates
+     */
     public function metaDates()
     {
         add_meta_box('glm_employment_meta', 'Position Information',
                      array($this, 'editJobMeta'), GLM_EMP_POST_TYPE);
     }
 
+    /**
+     * Build the edit part of the date
+     * @global type $post
+     */
     public function editJobMeta()
     {
         global $post;
@@ -131,6 +167,13 @@ class glm_employment_job
         include $this->pluginDirName . 'views/admin/job_meta.php';
     }
 
+    /**
+     * Save the Employment meta data
+     *
+     * @global type $post Post Object
+     *
+     * @return mixed
+     */
     public function saveEmpMeta()
     {
         global $post;
@@ -214,6 +257,16 @@ class glm_employment_job
         register_post_type(GLM_EMP_POST_TYPE, $args);
     }
 
+    /**
+     * Update the message text for the job post type
+     *
+     * @global type $post    Post object
+     * @global type $post_ID Id of post
+     *
+     * @param type $messages Messages array
+     *
+     * @return type
+     */
     public function jobsUpdatedMessages($messages)
     {
         global $post, $post_ID;
@@ -237,6 +290,9 @@ class glm_employment_job
         return $messages;
     }
 
+    /**
+     * Create the taxanomies for the post type
+     */
     public function createJobTaxonomy()
     {
         $labels = array(
@@ -305,6 +361,13 @@ class glm_employment_job
         register_taxonomy_for_object_type(GLM_EMP_TAX_DEPARTMENTS, GLM_EMP_POST_TYPE);
     }
 
+    /**
+     * To set which fields appear in the post type admin list
+     *
+     * @param array $columns Columns for the admin list view
+     *
+     * @return array
+     */
     function jobsEditColumns($columns)
     {
         $columns = array(
@@ -317,6 +380,13 @@ class glm_employment_job
         return $columns;
     }
 
+    /**
+     * Setup the custom columns for the admin list view
+     *
+     * @global type $post Post
+     *
+     * @param type $column Column
+     */
     function jobsCustomColumns($column)
     {
         global $post;