| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// Disallow direct access. |
| 7 |
defined('ABSPATH') or die("Access denied"); |
| 8 |
|
| 9 |
/** |
| 10 |
* |
| 11 |
*/ |
| 12 |
class CJTExtensionsPluginsListView extends CJTView { |
| 13 |
|
| 14 |
/** |
| 15 |
* put your comment there... |
| 16 |
* |
| 17 |
* @var mixed |
| 18 |
*/ |
| 19 |
protected $extensions; |
| 20 |
|
| 21 |
/** |
| 22 |
* put your comment there... |
| 23 |
* |
| 24 |
* @var mixed |
| 25 |
*/ |
| 26 |
protected $listTypeName; |
| 27 |
|
| 28 |
/** |
| 29 |
* put your comment there... |
| 30 |
* |
| 31 |
* @var mixed |
| 32 |
*/ |
| 33 |
protected $securityToken; |
| 34 |
|
| 35 |
/** |
| 36 |
* put your comment there... |
| 37 |
* |
| 38 |
* @param mixed $info |
| 39 |
* @return CJTInstallerNoticeView |
| 40 |
*/ |
| 41 |
public function __construct($info) { |
| 42 |
// CJTView class! |
| 43 |
parent::__construct($info); |
| 44 |
// Enqueue Styles & Scripts. |
| 45 |
add_action('admin_print_styles', array(__CLASS__, 'enqueueStyles')); |
| 46 |
add_action('admin_print_scripts', array(__CLASS__, 'enqueueScripts')); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* put your comment there... |
| 51 |
* |
| 52 |
* @param mixed $parent |
| 53 |
*/ |
| 54 |
public function activateExtensionsMenuItem($parent) { |
| 55 |
// Hack Wordpress menu to select CSS & Javascript root menu item |
| 56 |
// and the Extensions child menu item! |
| 57 |
// We just hack get_admin_page_parent() function! |
| 58 |
$GLOBALS['typenow'] = CJTPlugin::PLUGIN_REQUEST_ID; |
| 59 |
$GLOBALS['pagenow'] = CJTPlugin::PLUGIN_REQUEST_ID; |
| 60 |
$GLOBALS['plugin_page'] = $GLOBALS['submenu'][CJTPlugin::PLUGIN_REQUEST_ID][CJTExtensionsAccessPoint::MENU_POSITION_INDEX][2]; |
| 61 |
// We use this filter as (ACTION) not change in the return value! |
| 62 |
return $parent; |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* put your comment there... |
| 67 |
* |
| 68 |
* @param mixed $links |
| 69 |
*/ |
| 70 |
public function addExtensionActions($links, $file) { |
| 71 |
$pluginsFilesMap =& $this->extensions->getFiles2ClassesMap(); |
| 72 |
$extensions =& $this->extensions->getExtensions(); |
| 73 |
// If its a CJT extension! |
| 74 |
if (isset($pluginsFilesMap[$file])) { |
| 75 |
// Get extension data! |
| 76 |
$class = $pluginsFilesMap[$file]; |
| 77 |
$extension = $extensions[$class]; |
| 78 |
// We only work with extensions that required license key! |
| 79 |
if ($extension['definition']['primary']['requiredLicense']) { |
| 80 |
// Load license |
| 81 |
$definition = new SimpleXMLElement($extension['definition']['raw']); |
| 82 |
$component['name'] = (string) $definition->license->name; |
| 83 |
$component['pluginBase'] = $file; |
| 84 |
// Get action Markup! |
| 85 |
$links['license-key'] = $this->getTemplate('default_setup_action', array('component' => $component)); |
| 86 |
} |
| 87 |
} |
| 88 |
return $links; |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* put your comment there... |
| 93 |
* |
| 94 |
* @param mixed $tpl |
| 95 |
*/ |
| 96 |
public function display($tpl = null) { |
| 97 |
// Get model object! |
| 98 |
$model = $this->getModel('extensions'); |
| 99 |
// Some time we work as aspecific extensions page or geneal Wordpress plugins page! |
| 100 |
$this->securityToken = cssJSToolbox::getSecurityToken(); |
| 101 |
$this->listTypeName = $model->getListTypeName(); |
| 102 |
$this->extensions = CJTPlugin::getInstance()->extensions(); |
| 103 |
if ($this->listTypeName == 'extensions') { |
| 104 |
// Select Extensions menu item instead of Wordpress Plugins item! |
| 105 |
add_filter('parent_file', array(&$this, 'activateExtensionsMenuItem')); |
| 106 |
} |
| 107 |
// Output internal HTML used by JS! |
| 108 |
add_action('admin_footer', array(&$this, 'outputCommonMarkups')); |
| 109 |
// Add SETUP Link inside the Plugins (only CJT extensions) row! |
| 110 |
add_filter('plugin_action_links', array(&$this, 'addExtensionActions'), 10 , 2); |
| 111 |
|
| 112 |
} |
| 113 |
|
| 114 |
/** |
| 115 |
* put your comment there... |
| 116 |
* |
| 117 |
*/ |
| 118 |
public static function enqueueScripts() { |
| 119 |
$listTypeName = CJTModel::getInstance('extensions')->getListTypeName(); |
| 120 |
// Use related scripts. |
| 121 |
self::useScripts(__CLASS__, |
| 122 |
'jquery', |
| 123 |
'thickbox', |
| 124 |
'framework:js:{CJT-}utilities', |
| 125 |
'framework:js:ajax:{CJT-}cjt-server', |
| 126 |
'views:extensions:plugins-list:public:js:{CJTExtensionsPluginsListView-}default', |
| 127 |
"views:extensions:plugins-list:public:js:{CJTExtensionsPluginsListView-}{$listTypeName}" |
| 128 |
); |
| 129 |
} |
| 130 |
|
| 131 |
/** |
| 132 |
* put your comment there... |
| 133 |
* |
| 134 |
*/ |
| 135 |
public static function enqueueStyles() { |
| 136 |
$listTypeName = CJTModel::getInstance('extensions')->getListTypeName(); |
| 137 |
// Use related scripts. |
| 138 |
self::useStyles(__CLASS__, |
| 139 |
'thickbox', |
| 140 |
"views:extensions:plugins-list:public:css:{CJTExtensionsPluginsListView-}{$listTypeName}" |
| 141 |
); |
| 142 |
} |
| 143 |
|
| 144 |
/** |
| 145 |
* put your comment there... |
| 146 |
* |
| 147 |
*/ |
| 148 |
public function outputCommonMarkups() { |
| 149 |
echo $this->getTemplate('default'); |
| 150 |
} |
| 151 |
} // End class. |