Implement front-end list view & model
authorLaury GvR <laury@gaslightmedia.com>
Thu, 13 Sep 2018 17:22:04 +0000 (13:22 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Thu, 13 Sep 2018 17:22:04 +0000 (13:22 -0400)
Added list shortcode, model & view, and basic styles for the list.

css/front.css [new file with mode: 0644]
models/front/staff/list.php [new file with mode: 0644]
setup/shortcodes.php
setup/validActions.php
views/front/staff/list.html [new file with mode: 0644]

diff --git a/css/front.css b/css/front.css
new file mode 100644 (file)
index 0000000..cf9ae57
--- /dev/null
@@ -0,0 +1,28 @@
+.glm-staff-block-wrapper {
+    float: left;
+    padding: 10px;
+    width: 33%;
+}
+.glm-staff-name {
+    font-weight: bold;
+}
+@media (min-width: 641px) and (max-width: 1024px) {
+    .glm-staff-block-wrapper {
+        float: left;
+        padding: 10px;
+        width: 50%;
+    }   
+}
+@media (max-width: 640px) {
+    .glm-staff-block-wrapper {
+        float: left;
+        padding: 10px;
+        width: 50%;
+    }   
+}
+.glm-staff-block {
+    /* border: 1px solid grey; */
+    /* box-shadow: 1px 1px 1px 1px grey; */
+    text-align: center;
+    width: 100%;
+}
\ No newline at end of file
diff --git a/models/front/staff/list.php b/models/front/staff/list.php
new file mode 100644 (file)
index 0000000..1db55bc
--- /dev/null
@@ -0,0 +1,148 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * Job Postings
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+// Load Contacts data abstract
+require_once GLM_MEMBERS_STAFF_PLUGIN_CLASS_PATH.'/data/dataStaff.php';
+
+class GlmMembersFront_staff_list extends GlmDatastaff
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    /**
+     * Contact Info
+     *
+     * @var $contactInfo
+     * @access public
+     */
+    public $contactInfo = false;
+    /**
+     * Member ID
+     *
+     * @var $memberID
+     * @access public
+     */
+    public $memberID = false;
+    /**
+     * Contact ID
+     *
+     * @var $contactID
+     * @access public
+     */
+    public $contactID = false;
+
+
+    /*
+     * Constructor
+     *
+     * This contructor performs the work for this model. This model returns
+     * an array containing the following.
+     *
+     * 'status'
+     *
+     * True if successfull and false if there was a fatal failure.
+     *
+     * 'view'
+     *
+     * A suggested view name that the contoller should use instead of the
+     * default view for this model or false to indicate that the default view
+     * should be used.
+     *
+     * 'data'
+     *
+     * Data that the model is returning for use in merging with the view to
+     * produce output.
+     *
+     * @wpdb object WordPress database object
+     *
+     * @return array Array containing status, suggested view, and any data
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        /*
+         * Run constructor for the Contacts data class
+         *
+         * Note, the third parameter is a flag that indicates to the Contacts
+         * data class that it should flag a group of fields as 'view_only'.
+         */
+        parent::__construct(false, false, true);
+
+
+    }
+
+    public function modelAction($actionData = false)
+    {
+        $success_load = false;
+        $success_message = "";
+        $option = false;
+        $view_file = 'list';
+        
+        if (isset($_REQUEST['option']) && trim($_REQUEST['option']) != '') {
+            $option = $_REQUEST['option'];
+        }
+
+        $staff_data = $this->getList();
+   
+        switch ($option) {
+
+            case "list":
+                $view_file = 'list';
+            
+                break;
+            
+            default:
+        
+                break;
+        }
+        $success_load = "Yes";
+        
+
+        
+        // Compile template data
+        $templateData = array(
+            'staffData'    => $staff_data,
+            'successLoad'  => $success_load
+        );
+
+        // Return status, any suggested view, and any data to controller
+        return array(
+                'status' => true,
+                'modelRedirect' => false,
+                'view' => 'front/staff/'.$view_file.'.html',
+                'data' => $templateData
+        );
+
+    }
+
+}
index 8344e1f..7721cd1 100644 (file)
  *       </tr>
  */
 
+
+$glmMembersEventsShortcodes = array(
+    'glm-members-staff-list' => array(
+        'plugin'     => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
+        'menu'       => 'staff',
+        'action'     => 'list',
+        'table'      => false,
+        'attributes' => array(
+        )
+    ),
+);
+
 $glmMembersStaffShortcodes = array(
 );
 
index ebf06b7..30a3f92 100644 (file)
@@ -65,6 +65,10 @@ $glmMembersStaffAddOnValidActions = array(
         ),
     ),
     'frontActions' => array(
+        'staff' => array(
+            'list'     => GLM_MEMBERS_STAFF_PLUGIN_SLUG,
+            //'detail'   => GLM_MEMBERS_STAFF_PLUGIN_SLUG,
+        )
     )
 );
 
diff --git a/views/front/staff/list.html b/views/front/staff/list.html
new file mode 100644 (file)
index 0000000..ce4776b
--- /dev/null
@@ -0,0 +1,40 @@
+<div class="glm-staff-container">
+    {if $staffData}
+            
+            {foreach $staffData as $staffKey => $staffVal}
+                <div class="glm-staff-block-wrapper">
+                    <div class="glm-staff-block">
+                        <div class="glm-staff-name">
+                            <span class="glm-staff-fname">
+                                {$staffVal.fname}
+                            </span>
+                            <span class="glm-staff-lname">
+                                {$staffVal.lname}
+                            </span>
+                        </div>
+                        
+                        <div class="glm-staff-location">
+                            <span class="glm-staff-extension">
+                                {$staffVal.extension}
+                            </span>
+                            <span class="glm-staff-building">
+                                {$staffVal.building}
+                            </span>
+                            <span class="glm-staff-department">
+                                {$staffVal.department}
+                            </span>
+                        </div>
+
+                        <span class="glm-staff-email">
+                            <a href="mailto:{$staffVal.email}">{$staffVal.email}</a>
+                        </span>
+                        
+                    </div>
+                </div>
+            {/foreach}
+        </div>
+    {else}
+        Sorry, no staff members found.
+    {/if}
+
+</div>
\ No newline at end of file