예제 #1
0
    /**
     * read editors folder and load names into array
     * 
     * @param array $args
     * @return type 
     */
    public function getEditors($args)
    {
        $path = 'modules/Scribite/plugins';
        $plugins = FileUtil::getFiles($path, false, true, null, 'd');


        $editors = array();

        foreach ($plugins as $pluginName) {
            $className = 'ModulePlugin_Scribite_' . $pluginName . '_Plugin';
            $instance = PluginUtil::loadPlugin($className);
            $pluginstate = PluginUtil::getState($instance->getServiceId(), PluginUtil::getDefaultState());
            if ($pluginstate['state'] == PluginUtil::ENABLED) {
                if (isset($args['format']) && $args['format'] == 'formdropdownlist') {
                    $editors[] = array(
                        'text' => $instance->getMetaDisplayName(),
                        'value' => $pluginName
                    );
                } else {
                    $editors[$pluginName] = $instance->getMetaDisplayName();
                }
            }
        }

        return $editors;
    }
예제 #2
0
 /**
  * Whether or not the plugin is enabled.
  *
  * @return boolean
  */
 public function isEnabled()
 {
     if ($this instanceof \Zikula\Framework\Plugin\AlwaysOnInterface) {
         return true;
     }
     $plugin = \PluginUtil::getState($this->serviceId, \PluginUtil::getDefaultState());
     return $plugin['state'] === PluginUtil::ENABLED ? true : false;
 }
예제 #3
0
    /**
     * Whether or not the plugin is installed.
     *
     * @return boolean
     */
    public function isInstalled()
    {
        if ($this instanceof Zikula_Plugin_AlwaysOnInterface) {
            return true;
        }

        $plugin = PluginUtil::getState($this->serviceId, PluginUtil::getDefaultState());
        return ($plugin['state'] === PluginUtil::NOTINSTALLED) ? false : true;
    }
예제 #4
0
    /**
     * Lists all plugins.
     * @return string HTML output string
     */
    public function viewPlugins()
    {
        // Security check
        if (!SecurityUtil::checkPermission('Extensions::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        $state = FormUtil::getPassedValue('state', -1, 'GETPOST');
        $sort = FormUtil::getPassedValue('sort', null, 'GETPOST');
        $module = FormUtil::getPassedValue('bymodule', null, 'GETPOST');
        $systemplugins = FormUtil::getPassedValue('systemplugins', false, 'GETPOST')? true : null;

        $this->view->assign('state', $state);

        // generate an auth key to use in urls
        $csrfToken = SecurityUtil::generateCsrfToken($this->serviceManager, true);
        $plugins = array();
        $pluginClasses = ($systemplugins) ? PluginUtil::loadAllSystemPlugins() : PluginUtil::loadAllModulePlugins();

        foreach ($pluginClasses as $className) {
            $instance = PluginUtil::loadPlugin($className);
            $pluginstate = PluginUtil::getState($instance->getServiceId(), PluginUtil::getDefaultState());

            // Tweak UI if the plugin is AlwaysOn
            if ($instance instanceof Zikula_Plugin_AlwaysOnInterface) {
                $pluginstate['state'] = PluginUtil::ENABLED;
                $pluginstate['version'] = $instance->getMetaVersion();
            }

            // state filer
            if ($state >= 0 && $pluginstate['state'] != $state) {
                continue;
            }

            // module filter
            if (!empty($module) && $instance->getModuleName() != $module) {
                continue;
            }

            $actions = array();
            // Translate state
            switch ($pluginstate['state']) {
                case PluginUtil::NOTINSTALLED:
                    $status = $this->__('Not installed');
                    $statusimage = 'redled.png';

                    $actions[] = array('url' => ModUtil::url('Extensions', 'admin', 'initialisePlugin',
                                                    array('plugin' => $className,
                                                          'state'  => $state,
                                                          'bymodule' => $module,
                                                          'sort'   => $sort,
                                                          'systemplugins' => $systemplugins,
                                                          'csrftoken' => $csrfToken)
                                                ),
                                       'image' => 'folder_new.png',
                                       'title' => $this->__('Install'));
                    break;
                case PluginUtil::ENABLED:
                    $status = $this->__('Active');
                    $statusimage = 'greenled.png';
                    $pluginLink = array();
                    if (!$systemplugins) {
                        $pluginLink['_module'] = $instance->getModuleName();
                    }
                    $pluginLink['_plugin'] = $instance->getPluginName();
                    $pluginLink['_action'] = 'configure';

                    if ($instance instanceof Zikula_Plugin_ConfigurableInterface) {
                        $actions[] = array('url' => ModUtil::url('Extensions', 'adminplugin', 'dispatch', $pluginLink),
                                           'image' => 'configure.png',
                                           'title' => $this->__('Configure plugin'));
                    }

                    // Dont allow to disable/uninstall plugins that are AlwaysOn
                    if (!$instance instanceof Zikula_Plugin_AlwaysOnInterface) {
                        $actions[] = array('url' => ModUtil::url('Extensions', 'admin', 'deactivatePlugin',
                                                    array('plugin' => $className,
                                                          'state'  => $state,
                                                          'bymodule' => $module,
                                                          'sort'   => $sort,
                                                          'systemplugins' => $systemplugins,
                                                          'csrftoken' => $csrfToken)
                                                ),
                                       'image' => 'folder_red.png',
                                       'title' => $this->__('Deactivate'));

                        $actions[] = array('url' => ModUtil::url('Extensions', 'admin', 'removePlugin',
                                                    array('plugin' => $className,
                                                          'state'  => $state,
                                                          'bymodule' => $module,
                                                          'sort'   => $sort,
                                                          'systemplugins' => $systemplugins,
                                                          'csrftoken' => $csrfToken)
                                                ),
                                       'image' => '14_layer_deletelayer.png',
                                       'title' => $this->__('Remove plugin'));
                    }
                    break;
                case PluginUtil::DISABLED:
                    $status = $this->__('Inactive');
                    $statusimage = 'yellowled.png';

                    $actions[] = array('url' => ModUtil::url('Extensions', 'admin', 'activatePlugin',
                                                    array('plugin' => $className,
                                                          'state'  => $state,
                                                          'bymodule' => $module,
                                                          'sort'   => $sort,
                                                          'systemplugins' => $systemplugins,
                                                          'csrftoken' => $csrfToken)
                                                ),
                                       'image' => 'folder_green.png',
                                       'title' => $this->__('Activate'));

                    $actions[] = array('url' => ModUtil::url('Extensions', 'admin', 'removePlugin',
                                                    array('plugin' => $className,
                                                           'state' => $state,
                                                           'bymodule' => $module,
                                                           'sort'   => $sort,
                                                           'systemplugins' => $systemplugins,
                                                           'csrftoken' => $csrfToken)
                                                ),
                                       'image' => '14_layer_deletelayer.png',
                                       'title' => $this->__('Remove plugin'));

                    break;
            }

            // upgrade ?
            if ($pluginstate['state'] != PluginUtil::NOTINSTALLED
                && $pluginstate['version'] != $instance->getMetaVersion()) {

                $status = $this->__('New version');
                $statusimage = 'redled.png';

                $actions = array();
                $actions[] = array('url' => ModUtil::url('Extensions', 'admin', 'upgradePlugin',
                                                array('plugin' => $className,
                                                      'state'  => $state,
                                                      'bymodule' => $module,
                                                      'sort'   => $sort,
                                                      'systemplugins' => $systemplugins,
                                                      'csrftoken' => $csrfToken)
                                            ),
                                       'image' => 'folder_favorites.png',
                                       'title' => $this->__('Upgrade'));

                $actions[] = array('url' => ModUtil::url('Extensions', 'admin', 'removePlugin',
                                                array('plugin' => $className,
                                                       'state' => $state,
                                                       'bymodule' => $module,
                                                       'sort'   => $sort,
                                                       'systemplugins' => $systemplugins,
                                                       'csrftoken' => $csrfToken)
                                            ),
                                       'image' => '14_layer_deletelayer.png',
                                       'title' => $this->__('Remove plugin'));
            }

            $info =  array('instance'    => $instance,
                           'status'      => $status,
                           'statusimage' => $statusimage,
                           'actions'     => $actions,
                           'version'     => $pluginstate['state'] == PluginUtil::NOTINSTALLED ?
                                                 $instance->getMetaVersion() : $pluginstate['version']);

            // new version of plugin?
            if ($pluginstate['state'] != PluginUtil::NOTINSTALLED
                && $pluginstate['version'] != $instance->getMetaVersion()) {
                $info['newversion'] = $instance->getMetaVersion();
            }

            $plugins[] = $info;
        }

        // sort plugins array
        if (empty($sort) || $sort == 'module') {
            usort($plugins, array($this, 'viewPluginsSorter_byModule'));
        } elseif ($sort == 'name') {
            usort($plugins, array($this, 'viewPluginsSorter_byName'));
        }

        $this->view->assign('plugins', $plugins)
                   ->assign('module', $module)
                   ->assign('sort', $sort)
                   ->assign('state', $state)
                   ->assign('systemplugins', $systemplugins)
                   ->assign('_type', ($systemplugins) ? 'system' : 'module');

        // Return the output that has been generated by this function
        return $this->view->fetch('extensions_admin_viewPlugins.tpl');
    }