Changeset 1445352
- Timestamp:
- 06/29/2016 01:57:45 AM (10 years ago)
- Location:
- marketpowerwp/trunk
- Files:
-
- 21 edited
-
config/core_settings.json (modified) (1 diff)
-
config/replication_settings.json (modified) (1 diff)
-
js/leplugin.js (modified) (1 diff)
-
leplugin.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
-
src/LePlugin/Api/ApiController.php (modified) (1 diff)
-
src/LePlugin/Core/AbstractController.php (modified) (3 diffs)
-
src/LePlugin/Core/Config.php (modified) (1 diff)
-
src/LePlugin/Core/CoreApiController.php (modified) (1 diff)
-
src/LePlugin/Core/CoreController.php (modified) (1 diff)
-
src/LePlugin/Core/CronHelper.php (modified) (3 diffs)
-
src/LePlugin/Core/GatewayInterface.php (modified) (1 diff)
-
src/LePlugin/Core/ListTable.php (modified) (2 diffs)
-
src/LePlugin/Core/Utils.php (modified) (3 diffs)
-
src/LePlugin/Core/View.php (modified) (8 diffs)
-
src/LePlugin/Core/WpdbRepository.php (modified) (2 diffs)
-
src/LePlugin/Settings/Settings.php (modified) (1 diff)
-
src/Multisoft/MPP/Core/CoreController.php (modified) (5 diffs)
-
src/Multisoft/MPP/Core/CoreGateway.php (modified) (2 diffs)
-
src/Multisoft/MPP/Replication/ReplicationController.php (modified) (4 diffs)
-
src/Multisoft/MPP/Settings/SettingsGateway.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
marketpowerwp/trunk/config/core_settings.json
r1431993 r1445352 1 1 [ 2 2 { 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" 17 5 } 18 6 ] -
marketpowerwp/trunk/config/replication_settings.json
r1431993 r1445352 1 1 [ 2 2 { 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" 5 17 } 6 18 ] -
marketpowerwp/trunk/js/leplugin.js
r1431993 r1445352 29 29 newDiv.dialog(options); 30 30 }; 31 LePlugin.utcDateToLocalDate = function (isoDate) { 32 //01/15/2000 33 var utcDate = new Date(isoDate); 34 utcDate.setMinutes(utcDate.getMinutes() - utcDate.getTimezoneOffset()); 35 return utcDate; 36 }; 37 LePlugin.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 }; 43 LePlugin.Google = LePlugin.Google || {}; 44 LePlugin.Google.Maps = LePlugin.Google.Maps || {}; 45 LePlugin.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 }; 62 LePlugin.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 2 2 3 3 /** 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 11 9 */ 12 10 define('MPP_DEBUG', true); … … 30 28 if (file_exists($multisoft_config_file)) { 31 29 $multisoft_config_data = json_decode( 32 file_get_contents($multisoft_config_file), true 30 file_get_contents($multisoft_config_file), 31 true 33 32 ); 34 33 if ($multisoft_config_data) { … … 66 65 ); 67 66 67 if (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; 90 if (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 ); 68 105 unset( 69 106 $multisoft_dirname, -
marketpowerwp/trunk/readme.txt
r1431998 r1445352 3 3 Tags: marketpowerpro, multisoft 4 4 Requires at least: 3.4+ 5 Stable tag: 2.05 Stable tag: 1.1 6 6 License: Commercial 7 7 -
marketpowerwp/trunk/src/LePlugin/Api/ApiController.php
r1431993 r1445352 12 12 abstract class ApiController extends AbstractController { 13 13 14 protected $api_version= "1.0"; //used as the main namespace14 const API_VERSION = "1.0"; //used as the main namespace 15 15 16 16 protected final function register_route($namespace, $route, $args = array(), $override = false) { 17 17 add_action('rest_api_init', 18 18 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); 20 20 }); 21 21 } -
marketpowerwp/trunk/src/LePlugin/Core/AbstractController.php
r1431993 r1445352 10 10 * This is where wordpress specific methods should be called only. If not possible, abstract in another class. 11 11 * @author Dexter John R. Campos <dexterjohncampos@gmail.com>, Rodine Mark Paul L. Villar <dean.villar@gmail.com> 12 *@copyright Les Coders12 @copyright Les Coders 13 13 */ 14 14 abstract class AbstractController … … 78 78 //if menus 79 79 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); 81 81 } 82 82 if (count($this->admin_css) > 0 || count($this->admin_js) > 0) { … … 261 261 } 262 262 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) { 265 268 $r = get_role($role); 266 269 if ($r === null) { -
marketpowerwp/trunk/src/LePlugin/Core/Config.php
r1431993 r1445352 5 5 /** 6 6 * @author Dexter John R. Campos <dexterjohncampos@gmail.com> 7 @copyright Les Coders7 * @copyright Les Coders 8 8 */ 9 class Config { 9 class Config 10 { 10 11 11 12 protected $config; 12 13 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 } 15 26 } 16 27 17 public function __get($name) { 28 public function __get($name) 29 { 18 30 $value = false; 19 31 if (array_key_exists($name, $this->config)) { -
marketpowerwp/trunk/src/LePlugin/Core/CoreApiController.php
r1431993 r1445352 24 24 $args = ["methods" => "GET", "callback" => [$this, "retrieveSetting"]]; 25 25 $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; 26 34 } 27 35 -
marketpowerwp/trunk/src/LePlugin/Core/CoreController.php
r1431993 r1445352 16 16 wp_enqueue_style("leplugin-jquery-ui-css", 17 17 "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"); 18 20 } 19 21 -
marketpowerwp/trunk/src/LePlugin/Core/CronHelper.php
r1431993 r1445352 7 7 private $pid; 8 8 private $lockDir; 9 private $lockFileName; 9 10 10 11 const LOCK_SUFFIX = ".lock"; 11 12 12 public function __construct($lockDir ) {13 public function __construct($lockDir, $lockFileName = "") { 13 14 $this->lockDir = $lockDir; 15 $this->lockFileName = $lockFileName; 14 16 } 15 17 … … 40 42 public function lock() { 41 43 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 } 44 49 if (file_exists($lock_file)) { 45 50 //return FALSE; … … 62 67 public function unlock() { 63 68 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 } 66 74 67 75 if (file_exists($lock_file)) { -
marketpowerwp/trunk/src/LePlugin/Core/GatewayInterface.php
r1431993 r1445352 5 5 /** 6 6 * @author Dexter John R. Campos <dexterjohncampos@gmail.com> 7 @copyright Les Coders7 * @copyright Les Coders 8 8 * Just an interface for gateways. 9 9 * Gateways are used by Controllers. Methods should be descriptive and specific. -
marketpowerwp/trunk/src/LePlugin/Core/ListTable.php
r1431993 r1445352 10 10 */ 11 11 class ListTable extends WP_List_Table { 12 13 protected $notices = []; 12 14 13 15 public function __construct($args = array()) { … … 33 35 } 34 36 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 35 55 } -
marketpowerwp/trunk/src/LePlugin/Core/Utils.php
r1431993 r1445352 2 2 3 3 namespace LePlugin\Core; 4 5 use DateTime; 4 6 5 7 /** 6 8 * @author Dexter John R. Campos <dexterjohncampos@gmail.com> 7 @copyright Les Coders9 @copyright Les Coders 8 10 * Utility class that contains common methods that is unclassified as of the moment. 9 11 */ … … 68 70 69 71 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; 73 79 if ($time === null) { 74 $ utc_time = date($format);80 $tz_time = date($format); 75 81 } 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(); 78 94 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; 86 96 if ($time === null) { 87 $ utc_time = strtotime($str);97 $tz_time = strtotime($str); 88 98 } 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; 93 103 } 94 104 … … 100 110 } 101 111 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 102 443 } -
marketpowerwp/trunk/src/LePlugin/Core/View.php
r1431993 r1445352 8 8 namespace LePlugin\Core; 9 9 10 class View 11 { 10 class View { 12 11 13 12 private $_args; … … 17 16 private $_notices = []; 18 17 19 public function __get($name) 20 { 18 public function __get($name) { 21 19 if (isset($this->_args[$name])) { 22 20 return $this->_args[$name]; … … 25 23 } 26 24 27 public function __construct(AbstractController $context, $viewFile, $pluginFolder = "") 28 { 25 public function __construct(AbstractController $context, $viewFile, $pluginFolder = "") { 29 26 $query_args = $_GET; 30 27 $this->assign("query_args", $query_args); … … 40 37 } 41 38 42 public function assign($name, $value) 43 { 39 public function assign($name, $value) { 44 40 $this->_args[$name] = $value; 45 41 } 46 42 47 public function assignFromArray($array) 48 { 43 public function assignFromArray($array) { 49 44 if (!is_array($array)) { 50 45 return; … … 55 50 } 56 51 57 public function display($displayBefore = true) 58 { 52 public function display($displayBefore = true) { 59 53 if (!file_exists($this->_filename)) { 60 54 throw new \Exception("There is no such view $this->_filename!"); … … 69 63 } 70 64 71 public function getHtml($displayBefore = true) 72 { 65 public function getHtml($displayBefore = true) { 73 66 ob_start(); 74 67 $this->display(); … … 77 70 } 78 71 79 public function addNotice($message, $type = 'updated', $inline = true) 80 { 72 public function addNotice($message, $type = 'updated', $inline = true) { 81 73 $this->_notices[] = ["message" => $message, "type" => $type, "inline" => $inline]; 82 74 } 83 75 84 public function displayNotices() 85 { 76 public function displayNotices() { 86 77 87 78 foreach ($this->_notices as $notice) { … … 90 81 } 91 82 92 private function buildNotice($message, $type = 'updated', $inline = true) 93 { 83 private function buildNotice($message, $type = 'updated', $inline = true) { 94 84 95 85 $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>'; 98 88 return $notice; 99 89 } -
marketpowerwp/trunk/src/LePlugin/Core/WpdbRepository.php
r1431993 r1445352 5 5 /** 6 6 * @author Dexter John R. Campos <dexterjohncampos@gmail.com> 7 @copyright Les Coders7 @copyright Les Coders 8 8 * An abstract class that uses wpdb for querying. 9 9 * wpdb methods are protected and final to be used only inside of implementing class and to avoid overrides. … … 69 69 } 70 70 71 public function countAll() { 72 return $this->wp_get_var("SELECT count(1) FROM $this->table_name"); 73 } 74 71 75 } -
marketpowerwp/trunk/src/LePlugin/Settings/Settings.php
r1431993 r1445352 15 15 } 16 16 17 public function update($name, $value, $isPassword = false) {17 public static function update($name, $value, $isPassword = false) { 18 18 $gateway = new SettingsGateway(); 19 19 return $gateway->update($name, $value, $isPassword); -
marketpowerwp/trunk/src/Multisoft/MPP/Core/CoreController.php
r1431993 r1445352 14 14 class CoreController extends AbstractController 15 15 { 16 const API_NAMESPACE = 'multisoft-mpp'; 16 17 const MENU_SLUG = 'multisoft-mpp'; 17 18 const CAP = 'manage-multisoft-mpp'; … … 25 26 $this->enable_activation_hook(); 26 27 $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');30 28 31 29 $this->add_menu_page( … … 37 35 ); 38 36 37 $this->add_action('admin_menu', 'mpp_admin_menu'); 38 $this->add_action('admin_footer', 'mpp_admin_menu_footer'); 39 39 40 $this->setup_settings(); 40 41 } 41 42 42 public function core_init()43 public function mpp_admin_menu() 43 44 { 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 } 46 54 } 47 55 } 48 56 49 public function core_session_destroy()57 public function mpp_admin_menu_footer() 50 58 { 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 52 74 } 53 75 … … 98 120 $settingsGateway = SettingsGateway::getInstance(); 99 121 100 $view = new View($this, 'mpp _deployment_general_settings_section.php');122 $view = new View($this, 'mpp/deployment_general_settings_section.php'); 101 123 102 124 $base_web_address = $settingsGateway->get(self::OPTION_WEB_ADDRESS); … … 114 136 $settingsGateway = SettingsGateway::getInstance(); 115 137 116 $view = new View($this, 'mpp _deployment_advanced_settings_section.php');138 $view = new View($this, 'mpp/deployment_advanced_settings_section.php'); 117 139 118 140 $web_path = $settingsGateway->get(self::OPTION_WEB_PATH); -
marketpowerwp/trunk/src/Multisoft/MPP/Core/CoreGateway.php
r1431993 r1445352 9 9 10 10 use LePlugin\Core\GatewayInterface; 11 use Multisoft\MPP\Settings\SettingsGateway; 11 12 12 13 class CoreGateway implements GatewayInterface … … 73 74 } 74 75 } 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 } 75 92 } -
marketpowerwp/trunk/src/Multisoft/MPP/Replication/ReplicationController.php
r1431993 r1445352 164 164 public function index() 165 165 { 166 $view = new View($this, 'mpp _replication_shortcodes.php');166 $view = new View($this, 'mpp/replication/shortcodes.php'); 167 167 $sample_content = "[mppe]Hello my name is MPPE_FIRSTNAME, " . 168 168 "I live in MPPE_ADDRESS1 MPPE_ADDRESS2 MPPE_CITY, MPPE_COUNTRYNAME MPPE_POSTALCODE[/mppe]!"; … … 210 210 $mppe_info = $replicationGateway->get_replication_info(MPP_DEBUG); 211 211 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'); 213 213 $error_view->assign('code', $mppe_info->get_error_code()); 214 214 $error_view->assign('message', $mppe_info->get_error_message()); … … 280 280 /* @var $settingsGateway SettingsGateway */ 281 281 $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'); 283 283 $replicationView->assign('page_drop_down_args', array( 284 284 'depth' => 0, … … 303 303 /* @var $settingsGateway SettingsGateway */ 304 304 $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'); 306 306 $replicationView->assign('replication_path', 307 307 $settingsGateway->get(self::OPTION_REPLICATION_PATH, '')); -
marketpowerwp/trunk/src/Multisoft/MPP/Settings/SettingsGateway.php
r1431993 r1445352 86 86 } 87 87 88 public function update($name, $value, $isPassword = false )88 public function update($name, $value, $isPassword = false, $overwrite = true) 89 89 { 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; 92 98 } 93 return update_option(self::PREFIX . $name, $value);94 99 } 95 100
Note: See TracChangeset
for help on using the changeset viewer.