Beispiel #1
0
 /**
  * Register the JavaScript for the dashboard.
  *
  * @since    1.0.0
  */
 public function enqueueScripts()
 {
     /**
      * This function is provided for demonstration purposes only.
      *
      * An instance of this class should be passed to the run() function
      * defined in PluginName_Loader as all of the hooks are defined
      * in that particular class.
      *
      * The PluginName_Loader will then create the relationship
      * between the defined hooks and the functions defined in this
      * class.
      */
     wp_enqueue_script($this->plugin->getName(), plugin_dir_url(dirname(__FILE__)) . 'dist/scripts/plugin-name-admin.js', array('jquery'), $this->plugin->getVersion(), false);
 }
 /**
  * Return all injectable types
  *
  * @param $only_primary    return only primary types (false by default)
  *
  * @return an array which contains array(itemtype => itemtype name)
  **/
 static function getItemtypes($only_primary = false)
 {
     global $INJECTABLE_TYPES;
     getTypesToInject();
     $plugin = new Plugin();
     $values = array();
     foreach ($INJECTABLE_TYPES as $type => $from) {
         $injectionclass = new $type();
         if (class_exists($type) && (!$only_primary || $only_primary && $injectionclass->isPrimaryType())) {
             $instance = new $type();
             //If user has no right to create an object of this type, do not display type in the list
             if (!$instance->canCreate()) {
                 continue;
             }
             $typename = get_parent_class($type);
             $name = '';
             if ($from != 'datainjection') {
                 $plugin->getFromDBbyDir($from);
                 $name = $plugin->getName() . ': ';
             }
             $name .= call_user_func(array($type, 'getTypeName'));
             $values[$typename] = $name;
         }
     }
     asort($values);
     return $values;
 }
Beispiel #3
0
 public function testPlugin()
 {
     $pl = new Plugin(123, 'A Plugin', true);
     $this->assertEquals(123, $pl->getID());
     $this->assertEquals('A Plugin', $pl->getName());
     $this->assertEquals(true, $pl->isActive());
 }
 /**
  * @param array $remote - Array containing $host,$port,$auth data
  * @param str $cmd - remote command to execute
  * @param Plugin $plugin - plugin to receive results
  * @param str $callback - method from plugin to callback with results
  * @param mixed $data - data passed to callback function
  */
 public function __construct($remote, $cmd, $plugin, $callback, $data)
 {
     $this->server = $remote;
     $this->cmd = $cmd;
     $this->sock = false;
     $this->plugin = $plugin->getName();
     $this->callback = $callback;
     $this->data = $data;
 }
 private function getMissingDependencies(Plugin $plugin, array $plugins_collection)
 {
     $missing_dependencies = array();
     foreach ($plugins_collection as $candidate_plugin) {
         if (in_array($plugin->getName(), $candidate_plugin->getDependencies())) {
             $missing_dependencies[] = $candidate_plugin->getName();
         }
     }
     return $missing_dependencies;
 }
Beispiel #6
0
 public function actionIndex()
 {
     // список всех плагинов
     $plugins = Yii::app()->getPlugins();
     // все плагины регистрируем в бд
     // TODO если в базе нашлись плагины, которых уже нет, то помечаем их как удаленные
     // список плагинов, зарегистрированных в системе
     $pluginsDb = Plugin::model()->findAll();
     $finded = array();
     foreach ($plugins as $code => $config) {
         if (is_int($code)) {
             $code = $config;
             $config = array();
         }
         if (!isset($config['class'])) {
             $config['class'] = $code;
         }
         foreach ($pluginsDb as $plugin) {
             if ($plugin->code == $code) {
                 if ($plugin->class_name != $config['class']) {
                     $plugin->class_name = $config['class'];
                     $plugin->save();
                 }
                 $finded[] = $code;
                 continue 2;
             }
         }
         // плагина ещё нет в базе
         $newPlugin = new Plugin();
         $newPlugin->code = $code;
         $newPlugin->status = Plugin::STATUS_NEW;
         $newPlugin->class_name = $config['class'];
         //-------------------
         $newPlugin->name = $newPlugin->getName();
         // нигде не используется, исключительно для легкого чтения таблицы
         //-------------------
         $finded[] = $code;
         $newPlugin->save();
     }
     foreach ($pluginsDb as $plugin) {
         if (!in_array($plugin->code, $finded)) {
             // пропавшие плагины просто удаляем из базы
             try {
                 $plugin->deactivate($plugin);
             } catch (Exception $e) {
             }
             $plugin->delete();
             Yii::app()->compilePluginsConfig();
         }
     }
     $plugins = Plugin::model()->notDeleted()->findAll(array('order' => 'name'));
     $this->render('/index', array('plugins' => $plugins));
 }
Beispiel #7
0
                if (is_dir(ADMIN . '/plugins/' . $file)) {
                    $xmlFile = ADMIN . '/plugins/' . $file . '/info.xml';
                    if (!file_exists($xmlFile)) {
                        continue;
                    }
                    $exists = false;
                    foreach (getPlugins() as $plugin) {
                        if ($plugin->getInfoPath() == $xmlFile) {
                            $exists = true;
                        }
                    }
                    if ($exists) {
                        continue;
                    }
                    if (file_exists($xmlFile)) {
                        $ainfo = Plugin::getAuthorInfo($xmlFile);
                        $manager->addItem("Not installed plugins", array(Plugin::getName($xmlFile), Plugin::getDescription($xmlFile), $ainfo['name'], '<a href="' . $ainfo['website'] . '">' . $ainfo['website'] . '</a>', "override_actions" => array("<a href='" . orongoURL("orongo-admin/plugin-install.php?xml_path=" . urlencode(str_replace(ADMIN . '/plugins', "", $xmlFile))) . "'>" . l("Install") . "</a>")), "", "");
                    }
                } else {
                    continue;
                }
            }
        }
        $manage->addObject($manager);
        $manage->render();
        break;
    default:
        header("Location: " . orongoURL("orongo-admin/index.php?msg=1"));
        exit;
        break;
}
Beispiel #8
0
 /**
  * Gets player balance
  *
  * @param Plugin $api Economy plugin (from moneyPlugin)
  * @param str|IPlayer $player Player to lookup
  *
  * @return int
  */
 public static function getMoney($api, $player)
 {
     if (!$api) {
         return false;
     }
     switch ($api->getName()) {
         case "GoldStd":
             return $api->getMoney($player);
             break;
         case "PocketMoney":
         case "MassiveEconomy":
             if ($player instanceof IPlayer) {
                 $player = $player->getName();
             }
             return $api->getMoney($player);
         case "EconomyAPI":
             if ($player instanceof IPlayer) {
                 $player = $player->getName();
             }
             return $api->mymoney($player);
         default:
             return false;
             break;
     }
 }
Beispiel #9
0
 /**
  * Constructor
  *
  * @param Plugin $plugin The plugin the installer is associated with
  */
 public function __construct($plugin)
 {
     $this->plugin = $plugin;
     $this->_plugin = $plugin->getName();
 }
 /**
  * @return String plugin name
  */
 public final function getName()
 {
     return Plugin::getName($this->getInfoPath());
 }
Beispiel #11
0
 public function getMetrics()
 {
     return array('metrics' => array('compile_time' => number_format($this->t2 - $this->t1, 3), 'execution_time' => number_format($this->t3 - $this->t2, 3), 'total_time' => number_format($this->t3 - $this->t1, 3), 'memory_usage' => number_format(memory_get_peak_usage(true) / 1024 / 1024, 1)), 'plugin' => array('Id' => $this->plugin->getId(), 'Name' => $this->plugin->getName(), 'Identifier' => $this->plugin->getIdentifier(), 'Event' => $this->plugin->getEvent(), 'Entity' => $this->plugin->getEntity()), 'output' => $this->output);
 }
Beispiel #12
0
 /**
  * Add a response command that is generated by a plugin
  *
  * @param Plugin        $xPlugin            The plugin object
  * @param array         $aAttributes        The attributes for this response command
  * @param mixed         $mData              The data to be sent with this command
  *
  * @return \Jaxon\Plugin\Response
  */
 public function addPluginCommand($xPlugin, $aAttributes, $mData)
 {
     $aAttributes['plg'] = $xPlugin->getName();
     return $this->addCommand($aAttributes, $mData);
 }