Example #1
0
 protected function getData()
 {
     $searchTerm = Str::lower($this->getSearchTerm());
     $searchWords = [];
     if (strlen($searchTerm)) {
         $searchWords = explode(' ', $searchTerm);
     }
     $pluginManager = PluginManager::instance();
     $plugins = $pluginManager->getPlugins();
     $this->prepareComponentList();
     $items = [];
     foreach ($plugins as $plugin) {
         $components = $this->getPluginComponents($plugin);
         if (!is_array($components)) {
             continue;
         }
         $pluginDetails = $plugin->pluginDetails();
         $pluginName = isset($pluginDetails['name']) ? $pluginDetails['name'] : Lang::get('system::lang.plugin.unnamed');
         $pluginIcon = isset($pluginDetails['icon']) ? $pluginDetails['icon'] : 'icon-puzzle-piece';
         $pluginDescription = isset($pluginDetails['description']) ? $pluginDetails['description'] : null;
         $pluginClass = get_class($plugin);
         $pluginItems = [];
         foreach ($components as $componentInfo) {
             $className = $componentInfo->className;
             $alias = $componentInfo->alias;
             $component = App::make($className);
             if ($component->isHidden) {
                 continue;
             }
             $componentDetails = $component->componentDetails();
             $component->alias = '--alias--';
             $item = (object) ['title' => ComponentHelpers::getComponentName($component), 'description' => ComponentHelpers::getComponentDescription($component), 'plugin' => $pluginName, 'propertyConfig' => ComponentHelpers::getComponentsPropertyConfig($component), 'propertyValues' => ComponentHelpers::getComponentPropertyValues($component, $alias), 'className' => get_class($component), 'pluginIcon' => $pluginIcon, 'alias' => $alias, 'name' => $componentInfo->duplicateAlias ? $componentInfo->className : $componentInfo->alias];
             if ($searchWords && !$this->itemMatchesSearch($searchWords, $item)) {
                 continue;
             }
             if (!array_key_exists($pluginClass, $items)) {
                 $group = (object) ['title' => $pluginName, 'description' => $pluginDescription, 'pluginClass' => $pluginClass, 'icon' => $pluginIcon, 'items' => []];
                 $items[$pluginClass] = $group;
             }
             $pluginItems[] = $item;
         }
         usort($pluginItems, function ($a, $b) {
             return strcmp($a->title, $b->title);
         });
         if (isset($items[$pluginClass])) {
             $items[$pluginClass]->items = $pluginItems;
         }
     }
     uasort($items, function ($a, $b) {
         return strcmp($a->title, $b->title);
     });
     return $items;
 }
Example #2
0
 /**
  * Returns the snippet property list as array, in format compatible with Inspector.
  */
 public function getProperties()
 {
     if (!$this->componentClass) {
         return self::parseIniProperties($this->properties);
     } else {
         return ComponentHelpers::getComponentsPropertyConfig($this->getComponent(), false, true);
     }
 }
Example #3
0
 protected function getComponentPropertyValues($component)
 {
     return ComponentHelpers::getComponentPropertyValues($component);
 }