Plugin Directory

Changeset 1445352


Ignore:
Timestamp:
06/29/2016 01:57:45 AM (10 years ago)
Author:
AmitDeyUS
Message:

Added enhanced ADD DISTRIBUTOR form feature

Location:
marketpowerwp/trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • marketpowerwp/trunk/config/core_settings.json

    r1431993 r1445352  
    11[
    22  {
    3     "key": "default_multisoft_mpp_replication_path",
    4     "value": "/GetSiteReplicationInfo"
    5   },
    6   {
    7     "key": "default_multisoft_mpp_check_site_name_path",
    8     "value": "/CheckReplicatedSiteName"
    9   },
    10   {
    11     "key": "default_multisoft_mpp_replication_query_format",
    12     "value": "hashKey=%s&replicatedSiteName=%s"
    13   },
    14   {
    15     "key": "default_multisoft_mpp_check_site_name_query_format",
    16     "value": "hashKey=%s&siteName=%s"
     3    "key": "default_multisoft_mpp_web_path",
     4    "value": "/Modules/MLM/WebServices/MPPE/MPPEWebServices/WSMppeAPI.asmx"
    175  }
    186]
  • marketpowerwp/trunk/config/replication_settings.json

    r1431993 r1445352  
    11[
    22  {
    3     "key": "default_multisoft_mpp_web_path",
    4     "value": "/Modules/MLM/WebServices/MPPE/MPPEWebServices/WSMppeAPI.asmx"
     3    "key": "default_multisoft_mpp_replication_path",
     4    "value": "/GetSiteReplicationInfo"
     5  },
     6  {
     7    "key": "default_multisoft_mpp_check_site_name_path",
     8    "value": "/CheckReplicatedSiteName"
     9  },
     10  {
     11    "key": "default_multisoft_mpp_replication_query_format",
     12    "value": "hashKey=%s&replicatedSiteName=%s"
     13  },
     14  {
     15    "key": "default_multisoft_mpp_check_site_name_query_format",
     16    "value": "hashKey=%s&siteName=%s"
    517  }
    618]
  • marketpowerwp/trunk/js/leplugin.js

    r1431993 r1445352  
    2929    newDiv.dialog(options);
    3030};
     31LePlugin.utcDateToLocalDate = function (isoDate) {
     32    //01/15/2000
     33    var utcDate = new Date(isoDate);
     34    utcDate.setMinutes(utcDate.getMinutes() - utcDate.getTimezoneOffset());
     35    return utcDate;
     36};
     37LePlugin.utcTimeToLocalDate = function (utc_sec) {
     38    //01/15/2000
     39    var utcDate = new Date(utc_sec*1000);
     40    utcDate.setMinutes(utcDate.getMinutes() - utcDate.getTimezoneOffset());
     41    return utcDate;
     42};
     43LePlugin.Google = LePlugin.Google || {};
     44LePlugin.Google.Maps = LePlugin.Google.Maps || {};
     45LePlugin.Google.Maps.getFirstLocation = function (addressString, resultCallback) {
     46    var url = 'http://maps.googleapis.com/maps/api/geocode/json';
     47    var data = {
     48        address: addressString,
     49        sensor: false
     50    };
     51    jQuery.getJSON(url, data, function (response) {
     52        if (response && response.hasOwnProperty('results')
     53                && response.results.length > 0
     54                && response.results[0].hasOwnProperty('geometry')
     55                && response.results[0].geometry.hasOwnProperty('location')) {
     56            resultCallback(response.results[0].geometry.location);
     57        } else {
     58            resultCallback(false);
     59        }
     60    });
     61};
     62LePlugin.Google.Maps.getTimezoneFromLocation = function (lat, lng, resultCallback) {
     63    var url = 'https://maps.googleapis.com/maps/api/timezone/json'
     64    var data = {
     65        location: lat + ',' + lng,
     66        timestamp: ((new Date()).getTime()) / 1000
     67    };
     68    jQuery.getJSON(url, data, function (response) {
     69        if (response && response.hasOwnProperty('status')
     70                && response.status === 'OK') {
     71            resultCallback(response);
     72        } else {
     73            resultCallback(false);
     74        }
     75    });
     76};
     77
  • marketpowerwp/trunk/leplugin.php

    r1432001 r1445352  
    22
    33/**
    4  * Plugin Name: MarketPowerWP
    5  * Plugin URI: http://www.multisoft.com/
    6  * Description: Settings to invoke the MPP replication api
    7  * Version: 2.0
    8  * Author: dean.villar@gmail.com, dexterjohncampos@gmail.com
    9  * Author URI: http://www.multisoft.com/
    10  * License: Copyright www.multisoft.com 2014
     4 * Plugin Name: Multisoft MarketPowerPRO Tools
     5 * Description: Integration of Market Power Pro to wordpress
     6 * Version: 1.0
     7 * Author: Rodine Mark Paul L. Villar, Dexter John Campos
     8 * Author URI: mailto:dean.villar@gmail.com?subject= Multisoft MPP Tools
    119 */
    1210define('MPP_DEBUG', true);
     
    3028    if (file_exists($multisoft_config_file)) {
    3129        $multisoft_config_data = json_decode(
    32             file_get_contents($multisoft_config_file), true
     30            file_get_contents($multisoft_config_file),
     31            true
    3332        );
    3433        if ($multisoft_config_data) {
     
    6665);
    6766
     67if (is_admin()) {
     68    $multisoft_config_file = $multisoft_dirname . '/config/distributor_settings.json';
     69    $multisoft_config = null;
     70    if (file_exists($multisoft_config_file)) {
     71        $multisoft_config_data = json_decode(
     72            file_get_contents($multisoft_config_file),
     73            true
     74        );
     75
     76        if ($multisoft_config_data) {
     77            $multisoft_config = new LePlugin\Core\Config($multisoft_config_data);
     78        }
     79        unset($multisoft_config_data);
     80    }
     81    \Multisoft\MPP\Distributor\DistributorController::instance(
     82        $multisoft_dirname,
     83        $multisoft_pluginname,
     84        $multisoft_config
     85    );
     86}
     87
     88$multisoft_config_file = $multisoft_dirname . '/config/add_distributor_settings.json';
     89$multisoft_config = null;
     90if (file_exists($multisoft_config_file)) {
     91    $multisoft_config_data = json_decode(
     92        file_get_contents($multisoft_config_file),
     93        true
     94    );
     95    if ($multisoft_config_data) {
     96        $multisoft_config = new LePlugin\Core\Config($multisoft_config_data);
     97    }
     98    unset($multisoft_config_data);
     99}
     100$add = \Multisoft\MPP\Distributor\Add\AddController::instance(
     101    $multisoft_dirname,
     102    $multisoft_pluginname,
     103    $multisoft_config
     104);
    68105unset(
    69106    $multisoft_dirname,
  • marketpowerwp/trunk/readme.txt

    r1431998 r1445352  
    33Tags: marketpowerpro, multisoft
    44Requires at least: 3.4+
    5 Stable tag: 2.0
     5Stable tag: 1.1
    66License: Commercial
    77
  • marketpowerwp/trunk/src/LePlugin/Api/ApiController.php

    r1431993 r1445352  
    1212abstract class ApiController extends AbstractController {
    1313
    14     protected $api_version = "1.0"; //used as the main namespace
     14    const API_VERSION = "1.0"; //used as the main namespace
    1515
    1616    protected final function register_route($namespace, $route, $args = array(), $override = false) {
    1717        add_action('rest_api_init',
    1818                function ()use($namespace, $route, $args, $override) {
    19             register_rest_route($this->api_version . "/" . $namespace, $route, $args, $override);
     19            register_rest_route(self::API_VERSION . "/" . $namespace, $route, $args, $override);
    2020        });
    2121    }
  • marketpowerwp/trunk/src/LePlugin/Core/AbstractController.php

    r1431993 r1445352  
    1010 * This is where wordpress specific methods should be called only. If not possible, abstract in another class.
    1111 * @author Dexter John R. Campos <dexterjohncampos@gmail.com>, Rodine Mark Paul L. Villar <dean.villar@gmail.com>
    12  * @copyright Les Coders
     12  @copyright Les Coders
    1313 */
    1414abstract class AbstractController
     
    7878        //if menus
    7979        if (count($this->menus) > 0 || count($this->submenus) > 0) {
    80             $this->add_action("admin_menu", "admin_menu");
     80            $this->add_action("admin_menu", "admin_menu", 9);
    8181        }
    8282        if (count($this->admin_css) > 0 || count($this->admin_js) > 0) {
     
    261261    }
    262262
    263     protected final function add_capability($role, $cap, $grant = true)
    264     {
     263    protected final function add_role($role, $display_name, $capabilities = array()) {
     264        return add_role($role, $display_name, $capabilities);
     265    }
     266
     267    protected final function add_capability($role, $cap, $grant = true) {
    265268        $r = get_role($role);
    266269        if ($r === null) {
  • marketpowerwp/trunk/src/LePlugin/Core/Config.php

    r1431993 r1445352  
    55/**
    66 * @author Dexter John R. Campos <dexterjohncampos@gmail.com>
    7 @copyright Les Coders
     7 * @copyright Les Coders
    88 */
    9 class Config {
     9class Config
     10{
    1011
    1112    protected $config;
    1213
    13     public function __construct(array $config) {
    14         $this->config = $config;
     14    public function __construct(array $config)
     15    {
     16        if (is_array($config)) {
     17            $temp_config = array();
     18            foreach ($config as $config_item) {
     19                $config_item = (array)$config_item;
     20                $temp_config[$config_item['key']] = $config_item['value'];
     21            }
     22            $this->config = $temp_config;
     23        } else if (is_object($config)) {
     24            $this->config = $config;
     25        }
    1526    }
    1627
    17     public function __get($name) {
     28    public function __get($name)
     29    {
    1830        $value = false;
    1931        if (array_key_exists($name, $this->config)) {
  • marketpowerwp/trunk/src/LePlugin/Core/CoreApiController.php

    r1431993 r1445352  
    2424        $args = ["methods" => "GET", "callback" => [$this, "retrieveSetting"]];
    2525        $this->register_route("leplugin", "settings/(?P<name>[\w-]+)", $args);
     26        $this->add_filter('rest_authentication_errors', 'rest_is_logged', 10);
     27    }
     28
     29    public function rest_is_logged() {
     30        if (is_user_logged_in()) {
     31            return true;
     32        }
     33        return false;
    2634    }
    2735
  • marketpowerwp/trunk/src/LePlugin/Core/CoreController.php

    r1431993 r1445352  
    1616        wp_enqueue_style("leplugin-jquery-ui-css",
    1717                "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css");
     18        wp_enqueue_style("leplugin-font-awesome-css",
     19                "https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css");
    1820    }
    1921
  • marketpowerwp/trunk/src/LePlugin/Core/CronHelper.php

    r1431993 r1445352  
    77    private $pid;
    88    private $lockDir;
     9    private $lockFileName;
    910
    1011    const LOCK_SUFFIX = ".lock";
    1112
    12     public function __construct($lockDir) {
     13    public function __construct($lockDir, $lockFileName = "") {
    1314        $this->lockDir = $lockDir;
     15        $this->lockFileName = $lockFileName;
    1416    }
    1517
     
    4042    public function lock() {
    4143        global $argv;
    42         $lock_file = $this->lockDir . basename($argv[0]) . self::LOCK_SUFFIX;
    43 
     44        if ($this->lockFileName != "") {
     45            $lock_file = $this->lockDir . $this->lockFileName . self::LOCK_SUFFIX;
     46        } else {
     47            $lock_file = $this->lockDir . $argv[0] . self::LOCK_SUFFIX;
     48        }
    4449        if (file_exists($lock_file)) {
    4550            //return FALSE;
     
    6267    public function unlock() {
    6368        global $argv;
    64 
    65         $lock_file = $this->lockDir . $argv[0] . self::LOCK_SUFFIX;
     69        if ($this->lockFileName != "") {
     70            $lock_file = $this->lockDir . $this->lockFileName . self::LOCK_SUFFIX;
     71        } else {
     72            $lock_file = $this->lockDir . $argv[0] . self::LOCK_SUFFIX;
     73        }
    6674
    6775        if (file_exists($lock_file)) {
  • marketpowerwp/trunk/src/LePlugin/Core/GatewayInterface.php

    r1431993 r1445352  
    55/**
    66 * @author Dexter John R. Campos <dexterjohncampos@gmail.com>
    7 @copyright Les Coders
     7 * @copyright Les Coders
    88 * Just an interface for gateways.
    99 * Gateways are used by Controllers. Methods should be descriptive and specific.
  • marketpowerwp/trunk/src/LePlugin/Core/ListTable.php

    r1431993 r1445352  
    1010 */
    1111class ListTable extends WP_List_Table {
     12
     13    protected $notices = [];
    1214
    1315    public function __construct($args = array()) {
     
    3335    }
    3436
     37    protected function get_input_display_wrapper($item, $input, $display) {
     38        $displayStyle = 'style="display:none;"';
     39        $inputStyle = '';
     40        $inputWrapper = '<div ' . $inputStyle . ' class="input_wrapper">' . $input . '</div>';
     41        $displayWrapper = '<div ' . $displayStyle . ' class="display_wrapper">' . $display . '</div>';
     42        return $inputWrapper . $displayWrapper;
     43    }
     44
     45    protected function addNotice($message, $type = 'updated', $inline = true) {
     46        $this->notices[] = ["message" => $message, "type" => $type, "inline" => $inline];
     47    }
     48
     49    public function displayNotices() {
     50        foreach ($this->notices as $notice) {
     51            echo Utils::buildNotice($notice["message"], $notice["type"], $notice["inline"]);
     52        }
     53    }
     54
    3555}
  • marketpowerwp/trunk/src/LePlugin/Core/Utils.php

    r1431993 r1445352  
    22
    33namespace LePlugin\Core;
     4
     5use DateTime;
    46
    57/**
    68 * @author Dexter John R. Campos <dexterjohncampos@gmail.com>
    7 @copyright Les Coders
     9  @copyright Les Coders
    810 * Utility class that contains common methods that is unclassified as of the moment.
    911 */
     
    6870
    6971    public static function utc_date($format, $time = null) {
    70         $tz = date_default_timezone_get();
    71         date_default_timezone_set("UTC");
    72         $utc_time = null;
     72        return self::tz_date('UTC', $format, $time);
     73    }
     74
     75    public static function tz_date($tz, $format, $time = null) {
     76        $old_tz = date_default_timezone_get();
     77        date_default_timezone_set($tz);
     78        $tz_time = null;
    7379        if ($time === null) {
    74             $utc_time = date($format);
     80            $tz_time = date($format);
    7581        } else {
    76             $utc_time = date($format, $time);
    77         }
     82            $tz_time = date($format, $time);
     83        }
     84        date_default_timezone_set($old_tz);
     85        return $tz_time;
     86    }
     87
     88    public static function utc_strtotime($str, $time = null) {
     89        return self::tz_strtotime('UTC', $str, $time);
     90    }
     91
     92    public static function tz_strtotime($tz, $str, $time = null) {
     93        $old_tz = date_default_timezone_get();
    7894        date_default_timezone_set($tz);
    79         return $utc_time;
    80     }
    81 
    82     public static function utc_strtotime($str, $time = null) {
    83         $tz = date_default_timezone_get();
    84         date_default_timezone_set("UTC");
    85         $utc_time = null;
     95        $tz_time = null;
    8696        if ($time === null) {
    87             $utc_time = strtotime($str);
     97            $tz_time = strtotime($str);
    8898        } else {
    89             $utc_time = strtotime($str, $time);
    90         }
    91         date_default_timezone_set($tz);
    92         return $utc_time;
     99            $tz_time = strtotime($str, $time);
     100        }
     101        date_default_timezone_set($old_tz);
     102        return $tz_time;
    93103    }
    94104
     
    100110    }
    101111
     112    public static function buildNotice($message, $type = 'updated', $inline = true) {
     113
     114        $notice = '<div class="' . $type . ' notice is-dismissible ' . ($inline ? 'inline' : '') . '">'
     115                . '<p><strong>' . $message . '</strong></p>'
     116                . '</div>';
     117        return $notice;
     118    }
     119
     120    public static function buildTimezoneDropdown($name, $selected = '', array $otherAttrs = []) {
     121        $otherAttrsFlat = '';
     122        if (count($otherAttrs) > 0) {
     123            foreach ($otherAttrs as $key => $value) {
     124                $otherAttrsFlat .=' ' . $key . '="' . $value . '" ';
     125            }
     126        }
     127        $select = '<select name="' . $name . '" ' . $otherAttrsFlat . '>';
     128        $select .= '<option value="">-- Select Timezone --</option>';
     129        foreach (timezone_identifiers_list() as $zone) {
     130
     131            if ($selected !== '' && $selected !== null && $selected == $zone) {
     132                $selectedAttr = ' selected="selected" ';
     133            } else {
     134                $selectedAttr = '';
     135            }
     136            $select .= '<option ' . $selectedAttr . ' value="' . $zone . '">' . $zone . '</option>';
     137        }
     138        $select .='</select>';
     139        return $select;
     140    }
     141
     142    public static function buildUtcTimezoneDropdown($name, $selected = '', array $otherAttrs = []) {
     143        $otherAttrsFlat = '';
     144        if (count($otherAttrs) > 0) {
     145            foreach ($otherAttrs as $key => $value) {
     146                $otherAttrsFlat .=' ' . $key . '="' . $value . '" ';
     147            }
     148        }
     149        $offsets = [-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5,
     150            -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5,
     151            5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75,
     152            14];
     153        $select = '<select name="' . $name . '" ' . $otherAttrsFlat . '>';
     154        $select .= '<option value="">-- Select Timezone --</option>';
     155        foreach ($offsets as $offset) {
     156            if (0 <= $offset) {
     157                $offset_name = '+' . $offset;
     158            } else {
     159                $offset_name = '' . $offset;
     160            }
     161            $offset_name = 'UTC' . str_replace(['.25', '.5', '.75'], [':25', ':30', ':45'],
     162                            $offset_name);
     163
     164            if ($selected !== '' && $selected !== null && $selected == $offset) {
     165                $selectedAttr = ' selected="selected" ';
     166            } else {
     167                $selectedAttr = '';
     168            }
     169
     170            $select .= '<option ' . $selectedAttr . ' value="' . $offset . '">' . $offset_name . '</option>';
     171        }
     172
     173        $select .='</select>';
     174        return $select;
     175    }
     176
     177    public static function buildCountryDropDown($name, $selected = '', array $otherAttrs = []) {
     178        $otherAttrsFlat = '';
     179        if (count($otherAttrs) > 0) {
     180            foreach ($otherAttrs as $key => $value) {
     181                $otherAttrsFlat .=' ' . $key . '="' . $value . '" ';
     182            }
     183        }
     184        $select = '<select name="' . $name . '" ' . $otherAttrsFlat . '>';
     185        $select .= '<option value="">-- Select Country --</option>';
     186        foreach (self::$COUNTRY_ARRAY as $code => $country) {
     187            if ($selected == $code) {
     188                $selectedAttr = ' selected="selected" ';
     189            } else {
     190                $selectedAttr = '';
     191            }
     192            $select.='<option value="' . $code . '" ' . $selectedAttr . '>' . $country . '</option>';
     193        }
     194        $select .='</select>';
     195        return $select;
     196    }
     197
     198    static $COUNTRY_ARRAY = array("AF" => "Afghanistan",
     199        "AX" => "Åland Islands",
     200        "AL" => "Albania",
     201        "DZ" => "Algeria",
     202        "AS" => "American Samoa",
     203        "AD" => "Andorra",
     204        "AO" => "Angola",
     205        "AI" => "Anguilla",
     206        "AQ" => "Antarctica",
     207        "AG" => "Antigua and Barbuda",
     208        "AR" => "Argentina",
     209        "AM" => "Armenia",
     210        "AW" => "Aruba",
     211        "AU" => "Australia",
     212        "AT" => "Austria",
     213        "AZ" => "Azerbaijan",
     214        "BS" => "Bahamas",
     215        "BH" => "Bahrain",
     216        "BD" => "Bangladesh",
     217        "BB" => "Barbados",
     218        "BY" => "Belarus",
     219        "BE" => "Belgium",
     220        "BZ" => "Belize",
     221        "BJ" => "Benin",
     222        "BM" => "Bermuda",
     223        "BT" => "Bhutan",
     224        "BO" => "Bolivia",
     225        "BA" => "Bosnia and Herzegovina",
     226        "BW" => "Botswana",
     227        "BV" => "Bouvet Island",
     228        "BR" => "Brazil",
     229        "IO" => "British Indian Ocean Territory",
     230        "BN" => "Brunei Darussalam",
     231        "BG" => "Bulgaria",
     232        "BF" => "Burkina Faso",
     233        "BI" => "Burundi",
     234        "KH" => "Cambodia",
     235        "CM" => "Cameroon",
     236        "CA" => "Canada",
     237        "CV" => "Cape Verde",
     238        "KY" => "Cayman Islands",
     239        "CF" => "Central African Republic",
     240        "TD" => "Chad",
     241        "CL" => "Chile",
     242        "CN" => "China",
     243        "CX" => "Christmas Island",
     244        "CC" => "Cocos (Keeling) Islands",
     245        "CO" => "Colombia",
     246        "KM" => "Comoros",
     247        "CG" => "Congo",
     248        "CD" => "Congo, The Democratic Republic of The",
     249        "CK" => "Cook Islands",
     250        "CR" => "Costa Rica",
     251        "CI" => "Cote D'ivoire",
     252        "HR" => "Croatia",
     253        "CU" => "Cuba",
     254        "CY" => "Cyprus",
     255        "CZ" => "Czech Republic",
     256        "DK" => "Denmark",
     257        "DJ" => "Djibouti",
     258        "DM" => "Dominica",
     259        "DO" => "Dominican Republic",
     260        "EC" => "Ecuador",
     261        "EG" => "Egypt",
     262        "SV" => "El Salvador",
     263        "GQ" => "Equatorial Guinea",
     264        "ER" => "Eritrea",
     265        "EE" => "Estonia",
     266        "ET" => "Ethiopia",
     267        "FK" => "Falkland Islands (Malvinas)",
     268        "FO" => "Faroe Islands",
     269        "FJ" => "Fiji",
     270        "FI" => "Finland",
     271        "FR" => "France",
     272        "GF" => "French Guiana",
     273        "PF" => "French Polynesia",
     274        "TF" => "French Southern Territories",
     275        "GA" => "Gabon",
     276        "GM" => "Gambia",
     277        "GE" => "Georgia",
     278        "DE" => "Germany",
     279        "GH" => "Ghana",
     280        "GI" => "Gibraltar",
     281        "GR" => "Greece",
     282        "GL" => "Greenland",
     283        "GD" => "Grenada",
     284        "GP" => "Guadeloupe",
     285        "GU" => "Guam",
     286        "GT" => "Guatemala",
     287        "GG" => "Guernsey",
     288        "GN" => "Guinea",
     289        "GW" => "Guinea-bissau",
     290        "GY" => "Guyana",
     291        "HT" => "Haiti",
     292        "HM" => "Heard Island and Mcdonald Islands",
     293        "VA" => "Holy See (Vatican City State)",
     294        "HN" => "Honduras",
     295        "HK" => "Hong Kong",
     296        "HU" => "Hungary",
     297        "IS" => "Iceland",
     298        "IN" => "India",
     299        "ID" => "Indonesia",
     300        "IR" => "Iran, Islamic Republic of",
     301        "IQ" => "Iraq",
     302        "IE" => "Ireland",
     303        "IM" => "Isle of Man",
     304        "IL" => "Israel",
     305        "IT" => "Italy",
     306        "JM" => "Jamaica",
     307        "JP" => "Japan",
     308        "JE" => "Jersey",
     309        "JO" => "Jordan",
     310        "KZ" => "Kazakhstan",
     311        "KE" => "Kenya",
     312        "KI" => "Kiribati",
     313        "KP" => "Korea, Democratic People's Republic of",
     314        "KR" => "Korea, Republic of",
     315        "KW" => "Kuwait",
     316        "KG" => "Kyrgyzstan",
     317        "LA" => "Lao People's Democratic Republic",
     318        "LV" => "Latvia",
     319        "LB" => "Lebanon",
     320        "LS" => "Lesotho",
     321        "LR" => "Liberia",
     322        "LY" => "Libyan Arab Jamahiriya",
     323        "LI" => "Liechtenstein",
     324        "LT" => "Lithuania",
     325        "LU" => "Luxembourg",
     326        "MO" => "Macao",
     327        "MK" => "Macedonia, The Former Yugoslav Republic of",
     328        "MG" => "Madagascar",
     329        "MW" => "Malawi",
     330        "MY" => "Malaysia",
     331        "MV" => "Maldives",
     332        "ML" => "Mali",
     333        "MT" => "Malta",
     334        "MH" => "Marshall Islands",
     335        "MQ" => "Martinique",
     336        "MR" => "Mauritania",
     337        "MU" => "Mauritius",
     338        "YT" => "Mayotte",
     339        "MX" => "Mexico",
     340        "FM" => "Micronesia, Federated States of",
     341        "MD" => "Moldova, Republic of",
     342        "MC" => "Monaco",
     343        "MN" => "Mongolia",
     344        "ME" => "Montenegro",
     345        "MS" => "Montserrat",
     346        "MA" => "Morocco",
     347        "MZ" => "Mozambique",
     348        "MM" => "Myanmar",
     349        "NA" => "Namibia",
     350        "NR" => "Nauru",
     351        "NP" => "Nepal",
     352        "NL" => "Netherlands",
     353        "AN" => "Netherlands Antilles",
     354        "NC" => "New Caledonia",
     355        "NZ" => "New Zealand",
     356        "NI" => "Nicaragua",
     357        "NE" => "Niger",
     358        "NG" => "Nigeria",
     359        "NU" => "Niue",
     360        "NF" => "Norfolk Island",
     361        "MP" => "Northern Mariana Islands",
     362        "NO" => "Norway",
     363        "OM" => "Oman",
     364        "PK" => "Pakistan",
     365        "PW" => "Palau",
     366        "PS" => "Palestinian Territory, Occupied",
     367        "PA" => "Panama",
     368        "PG" => "Papua New Guinea",
     369        "PY" => "Paraguay",
     370        "PE" => "Peru",
     371        "PH" => "Philippines",
     372        "PN" => "Pitcairn",
     373        "PL" => "Poland",
     374        "PT" => "Portugal",
     375        "PR" => "Puerto Rico",
     376        "QA" => "Qatar",
     377        "RE" => "Reunion",
     378        "RO" => "Romania",
     379        "RU" => "Russian Federation",
     380        "RW" => "Rwanda",
     381        "SH" => "Saint Helena",
     382        "KN" => "Saint Kitts and Nevis",
     383        "LC" => "Saint Lucia",
     384        "PM" => "Saint Pierre and Miquelon",
     385        "VC" => "Saint Vincent and The Grenadines",
     386        "WS" => "Samoa",
     387        "SM" => "San Marino",
     388        "ST" => "Sao Tome and Principe",
     389        "SA" => "Saudi Arabia",
     390        "SN" => "Senegal",
     391        "RS" => "Serbia",
     392        "SC" => "Seychelles",
     393        "SL" => "Sierra Leone",
     394        "SG" => "Singapore",
     395        "SK" => "Slovakia",
     396        "SI" => "Slovenia",
     397        "SB" => "Solomon Islands",
     398        "SO" => "Somalia",
     399        "ZA" => "South Africa",
     400        "GS" => "South Georgia and The South Sandwich Islands",
     401        "ES" => "Spain",
     402        "LK" => "Sri Lanka",
     403        "SD" => "Sudan",
     404        "SR" => "Suriname",
     405        "SJ" => "Svalbard and Jan Mayen",
     406        "SZ" => "Swaziland",
     407        "SE" => "Sweden",
     408        "CH" => "Switzerland",
     409        "SY" => "Syrian Arab Republic",
     410        "TW" => "Taiwan, Province of China",
     411        "TJ" => "Tajikistan",
     412        "TZ" => "Tanzania, United Republic of",
     413        "TH" => "Thailand",
     414        "TL" => "Timor-leste",
     415        "TG" => "Togo",
     416        "TK" => "Tokelau",
     417        "TO" => "Tonga",
     418        "TT" => "Trinidad and Tobago",
     419        "TN" => "Tunisia",
     420        "TR" => "Turkey",
     421        "TM" => "Turkmenistan",
     422        "TC" => "Turks and Caicos Islands",
     423        "TV" => "Tuvalu",
     424        "UG" => "Uganda",
     425        "UA" => "Ukraine",
     426        "AE" => "United Arab Emirates",
     427        "GB" => "United Kingdom",
     428        "US" => "United States",
     429        "UM" => "United States Minor Outlying Islands",
     430        "UY" => "Uruguay",
     431        "UZ" => "Uzbekistan",
     432        "VU" => "Vanuatu",
     433        "VE" => "Venezuela",
     434        "VN" => "Viet Nam",
     435        "VG" => "Virgin Islands, British",
     436        "VI" => "Virgin Islands, U.S.",
     437        "WF" => "Wallis and Futuna",
     438        "EH" => "Western Sahara",
     439        "YE" => "Yemen",
     440        "ZM" => "Zambia",
     441        "ZW" => "Zimbabwe");
     442
    102443}
  • marketpowerwp/trunk/src/LePlugin/Core/View.php

    r1431993 r1445352  
    88namespace LePlugin\Core;
    99
    10 class View
    11 {
     10class View {
    1211
    1312    private $_args;
     
    1716    private $_notices = [];
    1817
    19     public function __get($name)
    20     {
     18    public function __get($name) {
    2119        if (isset($this->_args[$name])) {
    2220            return $this->_args[$name];
     
    2523    }
    2624
    27     public function __construct(AbstractController $context, $viewFile, $pluginFolder = "")
    28     {
     25    public function __construct(AbstractController $context, $viewFile, $pluginFolder = "") {
    2926        $query_args = $_GET;
    3027        $this->assign("query_args", $query_args);
     
    4037    }
    4138
    42     public function assign($name, $value)
    43     {
     39    public function assign($name, $value) {
    4440        $this->_args[$name] = $value;
    4541    }
    4642
    47     public function assignFromArray($array)
    48     {
     43    public function assignFromArray($array) {
    4944        if (!is_array($array)) {
    5045            return;
     
    5550    }
    5651
    57     public function display($displayBefore = true)
    58     {
     52    public function display($displayBefore = true) {
    5953        if (!file_exists($this->_filename)) {
    6054            throw new \Exception("There is no such view $this->_filename!");
     
    6963    }
    7064
    71     public function getHtml($displayBefore = true)
    72     {
     65    public function getHtml($displayBefore = true) {
    7366        ob_start();
    7467        $this->display();
     
    7770    }
    7871
    79     public function addNotice($message, $type = 'updated', $inline = true)
    80     {
     72    public function addNotice($message, $type = 'updated', $inline = true) {
    8173        $this->_notices[] = ["message" => $message, "type" => $type, "inline" => $inline];
    8274    }
    8375
    84     public function displayNotices()
    85     {
     76    public function displayNotices() {
    8677
    8778        foreach ($this->_notices as $notice) {
     
    9081    }
    9182
    92     private function buildNotice($message, $type = 'updated', $inline = true)
    93     {
     83    private function buildNotice($message, $type = 'updated', $inline = true) {
    9484
    9585        $notice = '<div class="' . $type . ' notice is-dismissible ' . ($inline ? 'inline' : '') . '">'
    96             . '<p><strong>' . $message . '</strong></p>'
    97             . '</div>';
     86                . '<p><strong>' . $message . '</strong></p>'
     87                . '</div>';
    9888        return $notice;
    9989    }
  • marketpowerwp/trunk/src/LePlugin/Core/WpdbRepository.php

    r1431993 r1445352  
    55/**
    66 * @author Dexter John R. Campos <dexterjohncampos@gmail.com>
    7 @copyright Les Coders
     7  @copyright Les Coders
    88 * An abstract class that uses wpdb for querying.
    99 * wpdb methods are protected and final to be used only inside of implementing class and to avoid overrides.
     
    6969    }
    7070
     71    public function countAll() {
     72        return $this->wp_get_var("SELECT count(1) FROM $this->table_name");
     73    }
     74
    7175}
  • marketpowerwp/trunk/src/LePlugin/Settings/Settings.php

    r1431993 r1445352  
    1515    }
    1616
    17     public function update($name, $value, $isPassword = false) {
     17    public static function update($name, $value, $isPassword = false) {
    1818        $gateway = new SettingsGateway();
    1919        return $gateway->update($name, $value, $isPassword);
  • marketpowerwp/trunk/src/Multisoft/MPP/Core/CoreController.php

    r1431993 r1445352  
    1414class CoreController extends AbstractController
    1515{
     16    const API_NAMESPACE = 'multisoft-mpp';
    1617    const MENU_SLUG = 'multisoft-mpp';
    1718    const CAP = 'manage-multisoft-mpp';
     
    2526        $this->enable_activation_hook();
    2627        $this->enable_deactivation_hook();
    27         $this->add_action('init', 'core_init', 1);
    28         $this->add_action('wp_login', 'core_session_destroy');
    29         $this->add_action('wp_logout', 'core_session_destroy');
    3028
    3129        $this->add_menu_page(
     
    3735        );
    3836
     37        $this->add_action('admin_menu', 'mpp_admin_menu');
     38        $this->add_action('admin_footer', 'mpp_admin_menu_footer');
     39
    3940        $this->setup_settings();
    4041    }
    4142
    42     public function core_init()
     43    public function mpp_admin_menu()
    4344    {
    44         if (!session_id()) {
    45             session_start();
     45
     46        global $submenu;
     47        foreach ($submenu[self::MENU_SLUG] as $index => $menu) {
     48            if ($menu[2] == self::MENU_SLUG) {
     49                $menu[0] = "<div id='mppro_link'>" . $menu[0] . "</div>";
     50                $menu[2] = "multisoft-mpp-settings";
     51                $submenu[self::MENU_SLUG][$index] = $menu;
     52                break;
     53            }
    4654        }
    4755    }
    4856
    49     public function core_session_destroy()
     57    public function mpp_admin_menu_footer()
    5058    {
    51         session_destroy();
     59        /* @var $settingsGateway SettingsGateway */
     60        $settingsGateway = SettingsGateway::getInstance();
     61        $url = $settingsGateway->get(
     62            CoreController::OPTION_WEB_ADDRESS,
     63            "http://www.marketpowerpro.com/"
     64        );
     65        ?>
     66        <script type="text/javascript">
     67            jQuery(document).ready(function ($) {
     68                var link = $('#mppro_link');
     69                $(link).parent().attr('href', '<?php echo $url;?>');
     70                $(link).parent().attr('target', '_blank');
     71            });
     72        </script>
     73        <?php
    5274    }
    5375
     
    98120        $settingsGateway = SettingsGateway::getInstance();
    99121
    100         $view = new View($this, 'mpp_deployment_general_settings_section.php');
     122        $view = new View($this, 'mpp/deployment_general_settings_section.php');
    101123
    102124        $base_web_address = $settingsGateway->get(self::OPTION_WEB_ADDRESS);
     
    114136        $settingsGateway = SettingsGateway::getInstance();
    115137
    116         $view = new View($this, 'mpp_deployment_advanced_settings_section.php');
     138        $view = new View($this, 'mpp/deployment_advanced_settings_section.php');
    117139
    118140        $web_path = $settingsGateway->get(self::OPTION_WEB_PATH);
  • marketpowerwp/trunk/src/Multisoft/MPP/Core/CoreGateway.php

    r1431993 r1445352  
    99
    1010use LePlugin\Core\GatewayInterface;
     11use Multisoft\MPP\Settings\SettingsGateway;
    1112
    1213class CoreGateway implements GatewayInterface
     
    7374        }
    7475    }
     76
     77    public function getResourceUrl($key)
     78    {
     79        /* @var $settingsGateway SettingsGateway */
     80        $settingsGateway = SettingsGateway::getInstance();
     81        $base_mpp_address = $settingsGateway->get(
     82            CoreController::OPTION_WEB_ADDRESS
     83        );
     84        $mpp_web_path = $settingsGateway->get(
     85            CoreController::OPTION_WEB_PATH
     86        );
     87        $keyValue = $settingsGateway->get(
     88            $key
     89        );
     90        return $base_mpp_address . $mpp_web_path . $keyValue;
     91    }
    7592}
  • marketpowerwp/trunk/src/Multisoft/MPP/Replication/ReplicationController.php

    r1431993 r1445352  
    164164    public function index()
    165165    {
    166         $view = new View($this, 'mpp_replication_shortcodes.php');
     166        $view = new View($this, 'mpp/replication/shortcodes.php');
    167167        $sample_content = "[mppe]Hello my name is MPPE_FIRSTNAME, " .
    168168            "I live in MPPE_ADDRESS1 MPPE_ADDRESS2 MPPE_CITY, MPPE_COUNTRYNAME MPPE_POSTALCODE[/mppe]!";
     
    210210        $mppe_info = $replicationGateway->get_replication_info(MPP_DEBUG);
    211211        if (is_wp_error($mppe_info)) {
    212             $error_view = new View($this, 'mpp_error_view.php');
     212            $error_view = new View($this, 'mpp/error_view.php');
    213213            $error_view->assign('code', $mppe_info->get_error_code());
    214214            $error_view->assign('message', $mppe_info->get_error_message());
     
    280280        /* @var $settingsGateway SettingsGateway */
    281281        $settingsGateway = SettingsGateway::getInstance();
    282         $replicationView = new View($this, 'mpp_replication_general_settings_section.php');
     282        $replicationView = new View($this, 'mpp/replication/general_settings_section.php');
    283283        $replicationView->assign('page_drop_down_args', array(
    284284            'depth' => 0,
     
    303303        /* @var $settingsGateway SettingsGateway */
    304304        $settingsGateway = SettingsGateway::getInstance();
    305         $replicationView = new View($this, 'mpp_replication_advanced_settings_section.php');
     305        $replicationView = new View($this, 'mpp/replication/advanced_settings_section.php');
    306306        $replicationView->assign('replication_path',
    307307            $settingsGateway->get(self::OPTION_REPLICATION_PATH, ''));
  • marketpowerwp/trunk/src/Multisoft/MPP/Settings/SettingsGateway.php

    r1431993 r1445352  
    8686    }
    8787
    88     public function update($name, $value, $isPassword = false)
     88    public function update($name, $value, $isPassword = false, $overwrite = true)
    8989    {
    90         if ($isPassword) {
    91             return update_option(self::PREFIX . $name, Utils::encrypt($value, $this->encryption_key));
     90        $opt = $this->get($name, false, $isPassword);
     91        if ($opt === false || $overwrite) {
     92            if ($isPassword) {
     93                return update_option(self::PREFIX . $name, Utils::encrypt($value, $this->encryption_key));
     94            }
     95            return update_option(self::PREFIX . $name, $value);
     96        } else {
     97            return true;
    9298        }
    93         return update_option(self::PREFIX . $name, $value);
    9499    }
    95100
Note: See TracChangeset for help on using the changeset viewer.