| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: |
|
| 11: |
|
| 12: | namespace Xmf\Module;
|
| 13: |
|
| 14: | use Xmf\Language;
|
| 15: |
|
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: |
|
| 29: | class Admin
|
| 30: | {
|
| 31: |
|
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: |
|
| 37: | protected static $ModuleAdmin = null;
|
| 38: | protected $lastInfoBoxTitle = null;
|
| 39: | protected static $paypal = '';
|
| 40: |
|
| 41: | |
| 42: | |
| 43: |
|
| 44: | protected function __construct()
|
| 45: | {
|
| 46: | }
|
| 47: |
|
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | |
| 53: | |
| 54: | |
| 55: | |
| 56: |
|
| 57: | public static function getInstance()
|
| 58: | {
|
| 59: |
|
| 60: | static $instance;
|
| 61: |
|
| 62: | if ($instance === null) {
|
| 63: | if (class_exists('\Xoops\Module\Admin', true)) {
|
| 64: | $instance = new \Xoops\Module\Admin;
|
| 65: | static::$ModuleAdmin = $instance;
|
| 66: | } else {
|
| 67: | include_once $GLOBALS['xoops']->path('Frameworks/moduleclasses/moduleadmin/moduleadmin.php');
|
| 68: | static::$ModuleAdmin = new \ModuleAdmin;
|
| 69: | Language::load('xmf');
|
| 70: | $instance = new static();
|
| 71: | }
|
| 72: | }
|
| 73: |
|
| 74: | return $instance;
|
| 75: | }
|
| 76: |
|
| 77: | |
| 78: | |
| 79: | |
| 80: | |
| 81: | |
| 82: | |
| 83: | |
| 84: | |
| 85: | |
| 86: | |
| 87: | |
| 88: | |
| 89: | |
| 90: | |
| 91: | |
| 92: |
|
| 93: | public function addConfigBoxLine($value = '', $type = 'default')
|
| 94: | {
|
| 95: | if ($type === 'module') {
|
| 96: | $mod = (is_array($value)) ? $value[0] : $value;
|
| 97: | if (xoops_isActiveModule($mod)) {
|
| 98: | return $this->addConfigAccept(sprintf(_AM_XMF_MODULE_INSTALLED, $mod));
|
| 99: | } else {
|
| 100: | $nomod = (is_array($value)) ? $value[1] : 'error';
|
| 101: | $line = sprintf(_AM_XMF_MODULE_NOT_INSTALLED, $mod);
|
| 102: | if ($nomod === 'warning') {
|
| 103: | return $this->addConfigWarning($line);
|
| 104: | } else {
|
| 105: | return $this->addConfigError($line);
|
| 106: | }
|
| 107: | }
|
| 108: | }
|
| 109: | return static::$ModuleAdmin->addConfigBoxLine($value, $type);
|
| 110: | }
|
| 111: |
|
| 112: | |
| 113: | |
| 114: | |
| 115: | |
| 116: | |
| 117: | |
| 118: | |
| 119: | |
| 120: |
|
| 121: | public function addInfoBox($title, $type = 'default', $extra = '')
|
| 122: | {
|
| 123: | $this->lastInfoBoxTitle = $title;
|
| 124: |
|
| 125: | return static::$ModuleAdmin->addInfoBox($title);
|
| 126: | }
|
| 127: |
|
| 128: | |
| 129: | |
| 130: | |
| 131: | |
| 132: | |
| 133: | |
| 134: | |
| 135: | |
| 136: |
|
| 137: | public function addInfoBoxLine($text = '', $type = 'default', $color = 'inherit')
|
| 138: | {
|
| 139: | return static::$ModuleAdmin->addInfoBoxLine(
|
| 140: | $this->lastInfoBoxTitle,
|
| 141: | $text,
|
| 142: | '',
|
| 143: | $color,
|
| 144: | $type
|
| 145: | );
|
| 146: | }
|
| 147: |
|
| 148: | |
| 149: | |
| 150: | |
| 151: | |
| 152: | |
| 153: | |
| 154: | |
| 155: | |
| 156: | |
| 157: |
|
| 158: | public function addItemButton($title, $link, $icon = 'add', $extra = '')
|
| 159: | {
|
| 160: | return static::$ModuleAdmin->addItemButton($title, $link, $icon, $extra);
|
| 161: | }
|
| 162: |
|
| 163: | |
| 164: | |
| 165: | |
| 166: | |
| 167: | |
| 168: | |
| 169: | |
| 170: |
|
| 171: | public function renderButton($position = null, $delimiter = " ")
|
| 172: | {
|
| 173: | if (null === $position) {
|
| 174: | $position = 'right';
|
| 175: | }
|
| 176: |
|
| 177: | return static::$ModuleAdmin->renderButton($position, $delimiter);
|
| 178: | }
|
| 179: |
|
| 180: | |
| 181: | |
| 182: | |
| 183: | |
| 184: | |
| 185: | |
| 186: | |
| 187: |
|
| 188: | public function displayButton($position = null, $delimiter = " ")
|
| 189: | {
|
| 190: | echo $this->renderButton($position, $delimiter);
|
| 191: | }
|
| 192: |
|
| 193: | |
| 194: | |
| 195: | |
| 196: | |
| 197: |
|
| 198: | public function renderInfoBox()
|
| 199: | {
|
| 200: | return static::$ModuleAdmin->renderInfoBox();
|
| 201: | }
|
| 202: |
|
| 203: | |
| 204: | |
| 205: | |
| 206: | |
| 207: |
|
| 208: | public function displayInfoBox()
|
| 209: | {
|
| 210: | echo $this->renderInfoBox();
|
| 211: | }
|
| 212: |
|
| 213: | |
| 214: | |
| 215: | |
| 216: | |
| 217: |
|
| 218: | public function renderIndex()
|
| 219: | {
|
| 220: | return static::$ModuleAdmin->renderIndex();
|
| 221: | }
|
| 222: |
|
| 223: | |
| 224: | |
| 225: | |
| 226: | |
| 227: |
|
| 228: | public function displayIndex()
|
| 229: | {
|
| 230: | echo $this->renderIndex();
|
| 231: | }
|
| 232: |
|
| 233: | |
| 234: | |
| 235: | |
| 236: | |
| 237: | |
| 238: | |
| 239: |
|
| 240: | public function renderNavigation($menu = '')
|
| 241: | {
|
| 242: | return static::$ModuleAdmin->addNavigation($menu);
|
| 243: | }
|
| 244: |
|
| 245: | |
| 246: | |
| 247: | |
| 248: | |
| 249: | |
| 250: | |
| 251: |
|
| 252: | public function displayNavigation($menu = '')
|
| 253: | {
|
| 254: | echo static::$ModuleAdmin->addNavigation($menu);
|
| 255: | }
|
| 256: |
|
| 257: | |
| 258: | |
| 259: | |
| 260: | |
| 261: | |
| 262: | |
| 263: |
|
| 264: | public function renderAbout($logo_xoops = true)
|
| 265: | {
|
| 266: | return static::$ModuleAdmin->renderAbout(static::$paypal, $logo_xoops);
|
| 267: | }
|
| 268: |
|
| 269: | |
| 270: | |
| 271: | |
| 272: | |
| 273: | |
| 274: | |
| 275: |
|
| 276: | public function displayAbout($logo_xoops = true)
|
| 277: | {
|
| 278: | echo $this->renderAbout($logo_xoops);
|
| 279: | }
|
| 280: |
|
| 281: | |
| 282: | |
| 283: | |
| 284: | |
| 285: | |
| 286: | |
| 287: |
|
| 288: | public function addConfigError($value = '')
|
| 289: | {
|
| 290: | $path = XOOPS_URL . '/Frameworks/moduleclasses/icons/16/';
|
| 291: | $line = "";
|
| 292: | $line .= "<span style='color : red; font-weight : bold;'>";
|
| 293: | $line .= "<img src='" . $path . "0.png' >";
|
| 294: | $line .= $value;
|
| 295: | $line .= "</span>";
|
| 296: | $value = $line;
|
| 297: | $type = 'default';
|
| 298: |
|
| 299: | return static::$ModuleAdmin->addConfigBoxLine($value, $type);
|
| 300: | }
|
| 301: |
|
| 302: | |
| 303: | |
| 304: | |
| 305: | |
| 306: | |
| 307: | |
| 308: |
|
| 309: | public function addConfigAccept($value = '')
|
| 310: | {
|
| 311: | $path = XOOPS_URL . '/Frameworks/moduleclasses/icons/16/';
|
| 312: | $line = "";
|
| 313: | $line .= "<span style='color : green;'>";
|
| 314: | $line .= "<img src='" . $path . "1.png' >";
|
| 315: | $line .= $value;
|
| 316: | $line .= "</span>";
|
| 317: | $value = $line;
|
| 318: | $type = 'default';
|
| 319: |
|
| 320: | return static::$ModuleAdmin->addConfigBoxLine($value, $type);
|
| 321: | }
|
| 322: |
|
| 323: | |
| 324: | |
| 325: | |
| 326: | |
| 327: | |
| 328: | |
| 329: |
|
| 330: | public function addConfigWarning($value = '')
|
| 331: | {
|
| 332: | $path = XOOPS_URL . '/Frameworks/moduleclasses/icons/16/';
|
| 333: | $line = "";
|
| 334: | $line .= "<span style='color : orange; font-weight : bold;'>";
|
| 335: | $line .= "<img src='" . $path . "warning.png' >";
|
| 336: | $line .= $value;
|
| 337: | $line .= "</span>";
|
| 338: | $value = $line;
|
| 339: | $type = 'default';
|
| 340: |
|
| 341: | return static::$ModuleAdmin->addConfigBoxLine($value, $type);
|
| 342: | }
|
| 343: |
|
| 344: |
|
| 345: | |
| 346: | |
| 347: | |
| 348: | |
| 349: | |
| 350: | |
| 351: | |
| 352: |
|
| 353: | public function addConfigModuleVersion($moddir, $minversion)
|
| 354: | {
|
| 355: | $return = false;
|
| 356: | $helper = Helper::getHelper($moddir);
|
| 357: | if (is_object($helper) && is_object($helper->getModule())) {
|
| 358: | $mod_modversion = $helper->getModule()->getVar('version');
|
| 359: | $mod_version_f = $mod_modversion;
|
| 360: | $min_version_f = $minversion;
|
| 361: | $value = sprintf(
|
| 362: | _AM_XMF_MODULE_VERSION,
|
| 363: | strtoupper($moddir),
|
| 364: | $min_version_f,
|
| 365: | $mod_version_f
|
| 366: | );
|
| 367: | if ($helper->getModule()->versionCompare($min_version_f, $mod_version_f, '<=')) {
|
| 368: | $this->addConfigAccept($value);
|
| 369: | $return = true;
|
| 370: | } else {
|
| 371: | $this->addConfigError($value);
|
| 372: | }
|
| 373: | } else {
|
| 374: | $value = sprintf(
|
| 375: | _AM_XMF_MODULE_NOTFOUND,
|
| 376: | strtoupper($moddir),
|
| 377: | $minversion
|
| 378: | );
|
| 379: | $this->addConfigError($value);
|
| 380: | }
|
| 381: |
|
| 382: | return $return;
|
| 383: | }
|
| 384: |
|
| 385: |
|
| 386: |
|
| 387: | |
| 388: | |
| 389: | |
| 390: | |
| 391: | |
| 392: | |
| 393: |
|
| 394: | protected static function isXng()
|
| 395: | {
|
| 396: | return class_exists('\Xoops', false);
|
| 397: | }
|
| 398: |
|
| 399: | |
| 400: | |
| 401: | |
| 402: | |
| 403: | |
| 404: | |
| 405: | |
| 406: | |
| 407: | |
| 408: | |
| 409: |
|
| 410: | public static function menuIconPath($image)
|
| 411: | {
|
| 412: | if (static::isXng()) {
|
| 413: | return($image);
|
| 414: | } else {
|
| 415: | $path = '../../Frameworks/moduleclasses/icons/32/';
|
| 416: |
|
| 417: | return($path . $image);
|
| 418: | }
|
| 419: | }
|
| 420: |
|
| 421: | |
| 422: | |
| 423: | |
| 424: | |
| 425: | |
| 426: | |
| 427: | |
| 428: | |
| 429: | |
| 430: | |
| 431: | |
| 432: | |
| 433: | |
| 434: | |
| 435: | |
| 436: |
|
| 437: | public static function iconUrl($name = '', $size = '32')
|
| 438: | {
|
| 439: | switch ($size) {
|
| 440: | case '16':
|
| 441: | $path = '16/';
|
| 442: | break;
|
| 443: | case '/':
|
| 444: | $path = '';
|
| 445: | break;
|
| 446: | case '32':
|
| 447: | default:
|
| 448: | $path = '32/';
|
| 449: | break;
|
| 450: | }
|
| 451: |
|
| 452: | if (static::isXng()) {
|
| 453: | $path = '/media/xoops/images/icons/' . $path;
|
| 454: | } else {
|
| 455: | $path = '/Frameworks/moduleclasses/icons/' . $path;
|
| 456: | }
|
| 457: |
|
| 458: | return(XOOPS_URL . $path . $name);
|
| 459: | }
|
| 460: |
|
| 461: | |
| 462: | |
| 463: | |
| 464: | |
| 465: | |
| 466: | |
| 467: | |
| 468: | |
| 469: |
|
| 470: | public static function setPaypal($paypal = '')
|
| 471: | {
|
| 472: | static::$paypal = $paypal;
|
| 473: | }
|
| 474: | }
|
| 475: | |