当前位置: 首页>>代码示例>>PHP>>正文


PHP elgg_get_plugins函数代码示例

本文整理汇总了PHP中elgg_get_plugins函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_plugins函数的具体用法?PHP elgg_get_plugins怎么用?PHP elgg_get_plugins使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了elgg_get_plugins函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * {@inheritdoc}
  */
 protected function handle()
 {
     $plugins = elgg_get_plugins('inactive');
     if (empty($plugins)) {
         system_message('All plugins are active');
         return;
     }
     $ids = array_map(function (ElggPlugin $plugin) {
         return $plugin->getID();
     }, $plugins);
     $ids = array_values($ids);
     if ($this->option('all')) {
         $activate_ids = $ids;
     } else {
         $helper = $this->getHelper('question');
         $question = new ChoiceQuestion('Please select plugins you would like to activate (comma-separated list of indexes)', $ids);
         $question->setMultiselect(true);
         $activate_ids = $helper->ask($this->input, $this->output, $question);
     }
     if (empty($activate_ids)) {
         throw new \RuntimeException('You must select at least one plugin');
     }
     $plugins = [];
     foreach ($activate_ids as $plugin_id) {
         $plugins[] = elgg_get_plugin_from_id($plugin_id);
     }
     do {
         $additional_plugins_activated = false;
         foreach ($plugins as $key => $plugin) {
             if ($plugin->isActive()) {
                 unset($plugins[$key]);
                 continue;
             }
             if (!$plugin->activate()) {
                 // plugin could not be activated in this loop, maybe in the next loop
                 continue;
             }
             $ids = array('cannot_start' . $plugin->getID(), 'invalid_and_deactivated_' . $plugin->getID());
             foreach ($ids as $id) {
                 elgg_delete_admin_notice($id);
             }
             // mark that something has changed in this loop
             $additional_plugins_activated = true;
             unset($plugins[$key]);
             system_message("Plugin {$plugin->getFriendlyName()} has been activated");
         }
         if (!$additional_plugins_activated) {
             // no updates in this pass, break the loop
             break;
         }
     } while (count($plugins) > 0);
     if (count($plugins) > 0) {
         foreach ($plugins as $plugin) {
             $msg = $plugin->getError();
             $string = $msg ? 'admin:plugins:activate:no_with_msg' : 'admin:plugins:activate:no';
             register_error(elgg_echo($string, array($plugin->getFriendlyName())));
         }
     }
     elgg_flush_caches();
 }
开发者ID:hypejunction,项目名称:elgg-cli,代码行数:63,代码来源:PluginsActivateCommand.php

示例2: site_get_list_plugin

function site_get_list_plugin()
{
    $plugins = elgg_get_plugins($status = 'active', $site_guid = null);
    $return = array('messages' => false, 'thewire' => false, 'blog' => false, 'tidypics' => false, 'file' => false, 'bookmarks' => false, 'groups' => false);
    foreach ($plugins as $plugin) {
        $a = $plugin->title;
        if (array_key_exists($plugin->title, $return)) {
            $return[$plugin->title] = true;
        }
    }
    return $return;
}
开发者ID:rohit1290,项目名称:elgg_with_rest_api,代码行数:12,代码来源:site.php

示例3: transfer_plugins_export

/**
 * Exports plugins and their configuration
 */
function transfer_plugins_export()
{
    // metadata
    $info = array('elgg_version' => get_version(true), 'elgg_release' => get_version(false), 'transfer_plugins_format' => TRANSFER_PLUGINS_FORMAT);
    $info['plugins'] = array();
    $plugins = elgg_get_plugins('all');
    foreach ($plugins as $plugin) {
        if (is_object($plugin) && is_object($plugin->getManifest())) {
            $plugin_info = array('id' => $plugin->getID(), 'version' => $plugin->getManifest()->getVersion(), 'active' => (bool) $plugin->isActive(), 'settings' => $plugin->getAllSettings(), 'priority' => $plugin->getPriority());
        }
        $plugin_order[$plugin->getPriority() * 10] = $plugin->getID();
        $info['plugins'][] = $plugin_info;
    }
    $info['17_pluginorder'] = serialize($plugin_order);
    return serialize($info);
}
开发者ID:socialweb,项目名称:PiGo,代码行数:19,代码来源:start.php

示例4: testThemePluginsAreLast

 public function testThemePluginsAreLast()
 {
     $plugins = elgg_get_plugins('all');
     $plugins = array_reverse($plugins);
     /* @var ElggPlugin[] $plugins */
     $found_non_theme = false;
     foreach ($plugins as $i => $plugin) {
         $is_theme = in_array('theme', $plugin->getManifest()->getCategories());
         if ($found_non_theme) {
             $this->assertFalse($is_theme, 'All themes come last');
         } else {
             if ($i === 0) {
                 $this->assertTrue($is_theme, 'Last plugin is a theme');
             }
             if (!$is_theme) {
                 $found_non_theme = true;
             }
         }
     }
 }
开发者ID:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:20,代码来源:ElggTravisInstallTest.php

示例5: handle

 /**
  * {@inheritdoc}
  */
 protected function handle()
 {
     $plugins = elgg_get_plugins('active');
     if (empty($plugins)) {
         system_message('All plugins are inactive');
         return;
     }
     $ids = array_map(function (ElggPlugin $plugin) {
         return $plugin->getID();
     }, $plugins);
     $ids = array_values($ids);
     if ($this->option('all')) {
         $deactivate_ids = $ids;
     } else {
         $helper = $this->getHelper('question');
         $question = new ChoiceQuestion('Please select plugins you would like to deactivate (comma-separated list of indexes)', $ids);
         $question->setMultiselect(true);
         $deactivate_ids = $helper->ask($this->input, $this->output, $question);
     }
     if (empty($deactivate_ids)) {
         throw new RuntimeException('You must select at least one plugin');
     }
     $plugins = [];
     foreach ($deactivate_ids as $plugin_id) {
         $plugins[] = elgg_get_plugin_from_id($plugin_id);
     }
     foreach ($plugins as $plugin) {
         if (!$plugin->isActive()) {
             continue;
         }
         if (!$plugin->deactivate()) {
             $msg = $plugin->getError();
             $string = $msg ? 'admin:plugins:deactivate:no_with_msg' : 'admin:plugins:deactivate:no';
             register_error(elgg_echo($string, array($plugin->getFriendlyName(), $plugin->getError())));
         } else {
             system_message("Plugin {$plugin->getFriendlyName()} has been deactivated");
         }
     }
     elgg_flush_caches();
 }
开发者ID:hypejunction,项目名称:elgg-cli,代码行数:43,代码来源:PluginsDeactivateCommand.php

示例6: elgg_update_services_get_updates

function elgg_update_services_get_updates()
{
    $installed_plugins = elgg_get_plugins('all');
    $plugin_hash_list = array();
    foreach ($installed_plugins as $id => $plugin) {
        $manifest = $plugin->getManifest();
        $bundled = in_array('bundled', $manifest->getCategories()) ? true : false;
        if (!$bundled) {
            $id = $manifest->getID();
            if (empty($id)) {
                $id = $plugin->getID();
            }
            $version = $manifest->getVersion();
            $author = $manifest->getAuthor();
            $plugin_hash_list[] = md5($id . $version . $author);
        }
    }
    $url = "http://community.elgg.org/services/api/rest/json/?method=plugins.update.check&version=" . elgg_get_version(true);
    foreach ($plugin_hash_list as $plugin_hash) {
        $url .= "&plugins[]=" . $plugin_hash;
    }
    $update_check = elgg_update_services_file_get_conditional_contents($url);
    return json_decode($update_check, true);
}
开发者ID:iionly,项目名称:elgg_update_services,代码行数:24,代码来源:start.php

示例7: subsite_manager_boot_system_plugins_event_handler

function subsite_manager_boot_system_plugins_event_handler($event, $type, $object)
{
    global $CONFIG;
    global $SUBSITE_MANAGER_PLUGINS_BOOT;
    // needs to be set for links in html head
    $viewtype = get_input('view', 'default');
    $site_guid = elgg_get_site_entity()->getGUID();
    $lastcached = datalist_get("sc_lastcached_" . $viewtype . "_" . $site_guid);
    $CONFIG->lastcache = $lastcached;
    // skip non-subsites
    if (!subsite_manager_on_subsite()) {
        return true;
    }
    $site = elgg_get_site_entity();
    $to_activate = $site->getPrivateSetting('subsite_manager_plugins_activate');
    if ($to_activate) {
        $SUBSITE_MANAGER_PLUGINS_BOOT = true;
        $site->removePrivateSetting('subsite_manager_plugins_activate');
        $to_activate = unserialize($to_activate);
        set_time_limit(0);
        elgg_generate_plugin_entities();
        $old_ia = elgg_set_ignore_access(true);
        $plugins = elgg_get_plugins('any');
        foreach ($plugins as $plugin) {
            if (in_array($plugin->getID(), $to_activate)) {
                try {
                    $plugin->activate();
                } catch (Exception $e) {
                }
            }
        }
        elgg_set_ignore_access($old_ia);
        $SUBSITE_MANAGER_PLUGINS_BOOT = false;
        elgg_register_event_handler("ready", "system", "subsite_manager_ready_system_handler", 100);
    }
}
开发者ID:pleio,项目名称:subsite_manager,代码行数:36,代码来源:system.php

示例8: translation_editor_merge_translations

function translation_editor_merge_translations($language = "", $update = false)
{
    global $CONFIG;
    $result = false;
    if (empty($language)) {
        $language = get_current_language();
    }
    if (!empty($language)) {
        $translations = array();
        if ($core = translation_editor_read_translation($language, "core")) {
            $translations = $core;
        }
        if ($custom_keys = translation_editor_read_translation($language, "custom_keys")) {
            $translations += $custom_keys;
        }
        if ($plugins = elgg_get_plugins()) {
            foreach ($plugins as $plugin) {
                if ($plugin_translation = translation_editor_read_translation($language, $plugin->title)) {
                    $translations += $plugin_translation;
                }
            }
        }
        if (!empty($translations)) {
            if (translation_editor_write_translation($language, "translation_editor_merged_" . $CONFIG->site_guid, $translations)) {
                $result = true;
            }
        } else {
            if (translation_editor_delete_translation($language, "translation_editor_merged_" . $CONFIG->site_guid)) {
                $result = true;
            }
        }
    }
    if ($result) {
        elgg_trigger_event("language:merge", "translation_editor", $language);
    }
    // reset language cache on all sites
    if ($update) {
        $ts = time();
        datalist_set("te_last_update_" . $language, $ts);
        set_private_setting($CONFIG->site_guid, "te_last_update_" . $language, $ts);
    }
    return $result;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:43,代码来源:functions.php

示例9: activatePlugin

 /**
  * Activate the plugin as well as all plugins required by it
  *
  * @param string $id Plugin ID
  * @return boolean
  */
 public static function activatePlugin($id)
 {
     if (!$id) {
         return false;
     }
     $plugin = elgg_get_plugin_from_id($id);
     if (!$plugin) {
         $plugins = elgg_get_plugins('inactive');
         foreach ($plugins as $p) {
             /* @var $p ElggPlugin */
             $manifest = $p->getManifest();
             if (!$manifest) {
                 continue;
             }
             $provides = $manifest->getProvides();
             if (!empty($provides)) {
                 foreach ($provides as $provide) {
                     if ($provide['type'] == 'plugin' && $provide['name'] == $id) {
                         $plugin = $p;
                         break;
                     }
                 }
             }
         }
         if (!$plugin) {
             return false;
         }
     }
     if ($plugin->isActive()) {
         return true;
     }
     $result = true;
     $manifest = $plugin->getManifest();
     if (!$manifest) {
         return false;
     }
     $requires = $manifest->getRequires();
     if (!empty($requires)) {
         foreach ($requires as $require) {
             if ($require['type'] == 'plugin') {
                 $result = self::activatePlugin($require['name']);
                 if (!$result) {
                     break;
                 }
             }
         }
     }
     if (!$result) {
         return false;
     }
     return $plugin->activate();
 }
开发者ID:n8b,项目名称:VMN,代码行数:58,代码来源:Util.php

示例10: elgg_get_plugins_provides

/**
 * Returns an array of all provides from all active plugins.
 *
 * Array in the form array(
 * 	'provide_type' => array(
 * 		'provided_name' => array(
 * 			'version' => '1.8',
 * 			'provided_by' => 'provider_plugin_id'
 *  	)
 *  )
 * )
 *
 * @param string $type The type of provides to return
 * @param string $name A specific provided name to return. Requires $provide_type.
 *
 * @return array
 * @since 1.8.0
 * @access private
 */
function elgg_get_plugins_provides($type = null, $name = null)
{
    global $SUBSITE_MANAGER_PLUGINS_BOOT;
    static $provides = null;
    $active_plugins = elgg_get_plugins('active');
    if (!isset($provides) || !empty($SUBSITE_MANAGER_PLUGINS_BOOT)) {
        $provides = array();
        foreach ($active_plugins as $plugin) {
            $plugin_provides = array();
            $manifest = $plugin->getManifest();
            if ($manifest instanceof ElggPluginManifest) {
                $plugin_provides = $plugin->getManifest()->getProvides();
            }
            if ($plugin_provides) {
                foreach ($plugin_provides as $provided) {
                    $provides[$provided['type']][$provided['name']] = array('version' => $provided['version'], 'provided_by' => $plugin->getID());
                }
            }
        }
    }
    if ($type && $name) {
        if (isset($provides[$type][$name])) {
            return $provides[$type][$name];
        } else {
            return false;
        }
    } elseif ($type) {
        if (isset($provides[$type])) {
            return $provides[$type];
        } else {
            return false;
        }
    }
    return $provides;
}
开发者ID:pleio,项目名称:subsite_manager,代码行数:54,代码来源:plugins.php

示例11: getProvides

 /**
  * Returns an array of all provides from all active plugins.
  *
  * Array in the form array(
  * 	'provide_type' => array(
  * 		'provided_name' => array(
  * 			'version' => '1.8',
  * 			'provided_by' => 'provider_plugin_id'
  *  	)
  *  )
  * )
  *
  * @param string $type The type of provides to return
  * @param string $name A specific provided name to return. Requires $provide_type.
  *
  * @return array
  * @access private
  */
 function getProvides($type = null, $name = null)
 {
     global $ELGG_PLUGINS_PROVIDES_CACHE;
     if (!isset($ELGG_PLUGINS_PROVIDES_CACHE)) {
         $active_plugins = elgg_get_plugins('active');
         $provides = array();
         foreach ($active_plugins as $plugin) {
             $plugin_provides = array();
             $manifest = $plugin->getManifest();
             if ($manifest instanceof \ElggPluginManifest) {
                 $plugin_provides = $plugin->getManifest()->getProvides();
             }
             if ($plugin_provides) {
                 foreach ($plugin_provides as $provided) {
                     $provides[$provided['type']][$provided['name']] = array('version' => $provided['version'], 'provided_by' => $plugin->getID());
                 }
             }
         }
         $ELGG_PLUGINS_PROVIDES_CACHE = $provides;
     }
     if ($type && $name) {
         if (isset($ELGG_PLUGINS_PROVIDES_CACHE[$type][$name])) {
             return $ELGG_PLUGINS_PROVIDES_CACHE[$type][$name];
         } else {
             return false;
         }
     } elseif ($type) {
         if (isset($ELGG_PLUGINS_PROVIDES_CACHE[$type])) {
             return $ELGG_PLUGINS_PROVIDES_CACHE[$type];
         } else {
             return false;
         }
     }
     return $ELGG_PLUGINS_PROVIDES_CACHE;
 }
开发者ID:ibou77,项目名称:elgg,代码行数:53,代码来源:Plugins.php

示例12: _elgg_load_translations_for_language

/**
 * Load both core and plugin translations for a specific language
 *
 * This can be used to load translations on-demand in case we need
 * to translate something to a language not loaded by default for
 * the current user.
 *
 * @param $language Language code
 * @return bool
 *
 * @since 1.9.4
 * @throws PluginException
 * @access private
 */
function _elgg_load_translations_for_language($language)
{
    global $CONFIG;
    // Try to load translations from system cache
    if (!empty($CONFIG->system_cache_enabled)) {
        $data = elgg_load_system_cache("{$language}.lang");
        if ($data) {
            $added = add_translation($language, unserialize($data));
            if ($added) {
                // Translations were successfully loaded from system cache
                return true;
            }
        }
    }
    // Read translations from the core languages directory
    _elgg_register_translations_for_language(dirname(dirname(dirname(__FILE__))) . "/languages/", $language);
    // Get active plugins
    $plugins = elgg_get_plugins('active');
    if (!$plugins) {
        // Active plugins were not found, so no need to register plugin translations
        return true;
    }
    foreach ($plugins as $plugin) {
        $languages_path = "{$plugin->getPath()}languages/";
        if (!is_dir($languages_path)) {
            // This plugin doesn't have anything to translate
            continue;
        }
        $language_file = "{$languages_path}{$language}.php";
        if (!file_exists($language_file)) {
            // This plugin doesn't have translations for the requested language
            $name = $plugin->getFriendlyName();
            elgg_log("Plugin {$name} is missing translations for {$language} language", 'NOTICE');
            continue;
        }
        // Register translations from the plugin languages directory
        if (!_elgg_register_translations_for_language($languages_path, $language)) {
            $msg = elgg_echo('ElggPlugin:Exception:CannotRegisterLanguages', array($plugin->getID(), $plugin->guid, $languages_path));
            throw new PluginException($msg);
        }
    }
    return true;
}
开发者ID:gzachos,项目名称:elgg_ellak,代码行数:57,代码来源:languages.php

示例13: get_input

<?php

/**
 * Disable all specified installed plugins.
 *
 * Specified plugins in the mod/ directory are disabled and the views cache and simplecache
 * are reset.
 *
 * @package Elgg.Core
 * @subpackage Administration.Plugins
 */
$guids = get_input('guids');
if (empty($guids)) {
    $plugins = elgg_get_plugins('active');
} else {
    $plugins = elgg_get_entities(['type' => 'object', 'subtype' => 'plugin', 'guids' => explode(',', $guids), 'limit' => false]);
}
if (empty($plugins)) {
    forward(REFERER);
}
foreach ($plugins as $plugin) {
    if (!$plugin->isActive()) {
        continue;
    }
    if (!$plugin->deactivate()) {
        $msg = $plugin->getError();
        $string = $msg ? 'admin:plugins:deactivate:no_with_msg' : 'admin:plugins:deactivate:no';
        register_error(elgg_echo($string, array($plugin->getFriendlyName(), $plugin->getError())));
    }
}
// don't regenerate the simplecache because the plugin won't be
开发者ID:thehereward,项目名称:Elgg,代码行数:31,代码来源:deactivate_all.php

示例14: enablePlugins

 /**
  * Enable a set of default plugins
  *
  * @return void
  */
 protected function enablePlugins()
 {
     elgg_generate_plugin_entities();
     $plugins = elgg_get_plugins('any');
     foreach ($plugins as $plugin) {
         if ($plugin->getManifest()) {
             if ($plugin->getManifest()->getActivateOnInstall()) {
                 $plugin->activate();
             }
         }
     }
 }
开发者ID:nogsus,项目名称:Elgg,代码行数:17,代码来源:ElggInstaller.php

示例15: checkDependencies

 /**
  * Returns if the Elgg system meets the plugin's dependency
  * requirements.  This includes both requires and conflicts.
  *
  * Full reports can be requested.  The results are returned
  * as an array of arrays in the form array(
  * 	'type' => requires|conflicts,
  * 	'dep' => array( dependency array ),
  * 	'status' => bool if depedency is met,
  * 	'comment' => optional comment to display to the user.
  * )
  *
  * @param bool $full_report Return a full report.
  * @return bool|array
  */
 public function checkDependencies($full_report = false)
 {
     // Note: $conflicts and $requires are not unused. They're called dynamically
     $requires = $this->getManifest()->getRequires();
     $conflicts = $this->getManifest()->getConflicts();
     $enabled_plugins = elgg_get_plugins('active');
     $this_id = $this->getID();
     $report = array();
     // first, check if any active plugin conflicts with us.
     foreach ($enabled_plugins as $plugin) {
         $temp_conflicts = array();
         $temp_manifest = $plugin->getManifest();
         if ($temp_manifest instanceof ElggPluginManifest) {
             $temp_conflicts = $plugin->getManifest()->getConflicts();
         }
         foreach ($temp_conflicts as $conflict) {
             if ($conflict['type'] == 'plugin' && $conflict['name'] == $this_id) {
                 $result = $this->checkDepPlugin($conflict, $enabled_plugins, false);
                 // rewrite the conflict to show the originating plugin
                 $conflict['name'] = $plugin->getManifest()->getName();
                 if (!$full_report && !$result['status']) {
                     $this->errorMsg = "Conflicts with plugin \"{$plugin->getManifest()->getName()}\".";
                     return $result['status'];
                 } else {
                     $report[] = array('type' => 'conflicted', 'dep' => $conflict, 'status' => $result['status'], 'value' => $this->getManifest()->getVersion());
                 }
             }
         }
     }
     $check_types = array('requires', 'conflicts');
     if ($full_report) {
         // Note: $suggests is not unused. It's called dynamically
         $suggests = $this->getManifest()->getSuggests();
         $check_types[] = 'suggests';
     }
     foreach ($check_types as $dep_type) {
         $inverse = $dep_type == 'conflicts' ? true : false;
         foreach (${$dep_type} as $dep) {
             switch ($dep['type']) {
                 case 'elgg_version':
                     $result = $this->checkDepElgg($dep, get_version(), $inverse);
                     break;
                 case 'elgg_release':
                     $result = $this->checkDepElgg($dep, get_version(true), $inverse);
                     break;
                 case 'plugin':
                     $result = $this->checkDepPlugin($dep, $enabled_plugins, $inverse);
                     break;
                 case 'priority':
                     $result = $this->checkDepPriority($dep, $enabled_plugins, $inverse);
                     break;
                 case 'php_extension':
                     $result = $this->checkDepPhpExtension($dep, $inverse);
                     break;
                 case 'php_ini':
                     $result = $this->checkDepPhpIni($dep, $inverse);
                     break;
             }
             // unless we're doing a full report, break as soon as we fail.
             if (!$full_report && !$result['status']) {
                 $this->errorMsg = "Missing dependencies.";
                 return $result['status'];
             } else {
                 // build report element and comment
                 $report[] = array('type' => $dep_type, 'dep' => $dep, 'status' => $result['status'], 'value' => $result['value']);
             }
         }
     }
     if ($full_report) {
         // add provides to full report
         $provides = $this->getManifest()->getProvides();
         foreach ($provides as $provide) {
             $report[] = array('type' => 'provides', 'dep' => $provide, 'status' => true, 'value' => '');
         }
         return $report;
     }
     return true;
 }
开发者ID:elainenaomi,项目名称:labxp2014,代码行数:93,代码来源:ElggPluginPackage.php


注:本文中的elgg_get_plugins函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。