Gets markup for a module
@param  object $module The module object
@param  array  $args   Module args
@return string
505616
public function getModuleMarkup($module, $args)
    {
        $templatePath = $module->template();

        // Get template for legacy modules
        if (!$templatePath) {
            $templatePath = \Modularity\Helper\Wp::getTemplate($module->post_type, 'module', false);
        }

        if (!$templatePath) {
            return false;
        }

        $moduleMarkup = '';
        if (preg_match('/.blade.php$/i', $templatePath)) {
            $moduleMarkup = $this->loadBladeTemplate($templatePath, $module, $args);
        } else {
            $moduleMarkup = $this->loadTemplate($templatePath, $module, $args);
        }

        if (empty($moduleMarkup)) {
            return;
        }

        $classes = array(
            'modularity-' . $module->post_type,
            'modularity-' . $module->post_type . '-' . $module->ID
        );

        //Hide module if preview
        if (is_preview() && $module->hidden) {
            $classes[] = 'modularity-preview-hidden';
        }

        //Add selected scope class
        if (isset($module->data['meta']) && isset($module->data['meta']['module_css_scope']) && is_array($module->data['meta']['module_css_scope'])) {
            if (!empty($module->data['meta']['module_css_scope'][0])) {
                $classes[] = $module->data['meta']['module_css_scope'][0];
            }
        }

        $beforeModule = '';
        $moduleEdit = '';
        if (!(isset($args['edit_module']) && $args['edit_module'] === false) && current_user_can('edit_module', $module->ID)) {
            $moduleEdit = '<div class="modularity-edit-module"><a href="' . admin_url('post.php?post=' . $module->ID . '&action=edit&is_thickbox=true&is_inline=true') . '">' . __('Edit module', 'modularity') . ': ' . $module->data['post_type_name'] .  '</a></div>';
        }

        if (isset($module->columnWidth) && !empty($module->columnWidth)) {
            $beforeWidget = $module->columnWidth;

            $classes[] = $beforeWidget;

            $beforeModule = apply_filters('Modularity/Display/BeforeModule', '<div class="' . implode(' ', $classes) . '">', $args, $module->post_type, $module->ID);
        } elseif (isset($args['before_widget'])) {
            $beforeWidget = str_replace('%1$s', $module->post_type . '-' . $module->ID, $args['before_widget']);
            $beforeWidget = str_replace('%2$s', implode(' ', $classes), $beforeWidget);
            $beforeModule = apply_filters('Modularity/Display/BeforeModule', $beforeWidget, $args, $module->post_type, $module->ID);
        }

        $moduleMarkup = $beforeModule . $moduleEdit . $moduleMarkup;
        return $moduleMarkup;
    }
1139244
public static function _describeArg($arg)
    {
        if (is_array($arg)) {
            return sprintf('array[%d]', count($arg));
        }
        if (is_object($arg)) {
            return sprintf('object[%s]', get_class($arg));
        }

        return Text::toString($arg);
    }
612847
public function markdown(string $markdown, array $args = []): string
    {
        if (!$markdown) {
            return $markdown;
        } elseif (!$this->canMarkdown()) {
            return $markdown;
        } elseif (!$this->WPCom_Markdown) {
            return $markdown;
        }
        $default_args = ['unslash' => false];
        $args += $default_args; // Merge defaults.

        return (string) $this->WPCom_Markdown->transform($markdown, $args);
    }
750535
public function addModule($module)
    {
        if ($module instanceof ModuleInterface) {
            if (in_array($module, $this->modules)) {
                throw new \InvalidArgumentException(
                    'This occurrence of '.get_class($module).' is already registered.'
                );
            }
            if ($module->getContainer() !== $this) {
                throw new \InvalidArgumentException(
                    'This occurrence of '.get_class($module).' is already registered in another module container.'
                );
            }

            $module->attachEvents();
            $this->modules[] = $module;

            return $this;
        }

        /** @var string $className */
        $className = $module;

        if (!is_subclass_of($className, $this->getModuleBaseClassName(), true)
            || !is_subclass_of($className, ModuleInterface::class)) {
            throw new \InvalidArgumentException(
                'Passed module class name needs to be a class extending '.$this->getModuleBaseClassName()
                .' and/or '.ModuleInterface::class
            );
        }

        if (isset($this->modules[$className])) {
            throw new \InvalidArgumentException(
                'Module '.$className.' is already registered.'
            );
        }

        if (!($this instanceof ModuleContainerInterface)) {
            throw new \RuntimeException(
                'Current module container uses the ModuleContainerTrait, but doesn\'t implement '
                .ModuleContainerInterface::class.', please implement it.'
            );
        }

        /** @var ModuleInterface $module */
        $module = new $className($this);
        $module->attachEvents();
        $this->modules[$className] = $module;

        return $this;
    }
1294449
public function renderModule($module, $params = array(), $settings = array())
    {
        $style = null;

        if (is_object($module)) {
            $object = clone $module;
        } else {
            $object = new \stdClass();
        }
        if (!isset($object->published)) {
            $object->published = 1;
        }
        if (!is_object($module)) {
            $object->module = $module;
        }
        if (!isset($object->position)) {
            $object->position = '';
        }
        if (!isset($object->content)) {
            $object->content = '';
        }
        if (!isset($object->menuid)) {
            $object->menuid = '0';
        }
        if (!is_object($module)) {
            $object->name = preg_replace('/^mod_/', '', $module);
        }
        if (!isset($object->style)) {
            $object->style = null;
        }
        if (!isset($object->title)) {
            $object->title = '';
        }
        if (!isset($object->showtitle)) {
            $object->showtitle = '0';
        }

        if (isset($settings['title'])) {
            $object->title = $settings['title'];
            $object->showtitle = '1';
        }

        if (isset($settings['style'])) {
            $style = $object->style = $settings['style'];
        }

        if (isset($object->params)) {
            $params = array_merge(
                json_decode($object->params, true),
                $params
            );
        }

        $params = array_merge(array(
            'layout' => 'default',
            'moduleclass_sfx' => '',
            'cache' => 0,
            'cache_time' => 900,
            'cachemode' => 'itemid',
            'module_tag' => 'div',
            'bootstrap_size' => 0,
            'header_tag' => 'h2',
            'header_class' => '',
            'style' => '0'
        ), $params);

        $object->params = json_encode($params);

        $this->renderModuleObject($object, array(
            'style' => $style
        ));

        return $object->content;
    }
1017016
public function url($uri = '', $module = null)
    {
        if ($module != null) {
            $appNames = Container::get('config')->get('app_name');
            if (is_array($appNames)) {
                foreach ($appNames as &$appName) {
                    $appName = str_replace('./', '', $appName);
                }

                $appNames = array_flip($appNames);
                $baseUrl = $appNames[$module];
                $baseUrl = '//' . $baseUrl . '/';
            }
        } else {
            $baseUrl = Container::get('request')->getBaseUrl();
        }

        $uri = is_array($uri) ? implode('/', $uri) : trim($uri, '/');
        $prefix = $baseUrl . 'index.php?_i=';

        switch (strtolower(Container::get('config')->get('url_mode'))) {
            case 'path_info':
                return $uri == '' ? rtrim($baseUrl, '/') : $baseUrl . $uri;
            case 'query_string':
                return $uri == '' ? rtrim($baseUrl, '/') : $prefix . $uri;
            default:
                throw new ConfigException('`url_mode` Config ERROR');
        }
    }
664127
public function changelogFor(Module $module)
    {
        $path = $module->getPath().'/CHANGELOG.md';
        if (! $this->finder->isFile($path)) {
            return [];
        }

        $parser = new \Changelog\Parser(file_get_contents($path));

        return $parser->getReleases();
    }
1254847
protected function getFromMethod($args)
    {
        if (!$method = $this->getKeyMethod($args)) {
            return '';
        }

        array_shift($args);

        return call_user_func([$this, $method], ...$args);
    }
698663
public function getCommand( $args )
    {
        $class = strtoupper( substr( $args[ 1 ], 0, 1 ) ) . substr( $args[ 1 ], 1 );
        $class .= 'Command';

        /** @var Command $command */
        $command = NULL;

        if ( class_exists( $class ) )
        {
            $command = new $class();
        }

        if ( NULL === $command && !empty( $this->namespaces ) )
        {
            foreach ( $this->namespaces as $ns )
            {
                $name = $ns . $class;

                if ( class_exists( $name ) )
                {
                    $command = new $name();
                    $command->init( $args );

                    break;
                }
            }
        }

        if ( NULL !== $command )
        {
            $command->configure();
        }

        return $command;
    }
484897
static function AjaxUrl(ModuleBase $module, array $args = array())
    {
        $allArgs = array('module'=> ClassFinder::ModuleType($module)) + $args;
        $guard = new UserGuard();
        $user = $guard->GetUser();
        if (!$user)
        {
            throw new \Exception('Security breach on ajax url: no backend user logged in');
        }
        $allArgs['__backendUser'] = $user->GetID();
        return 'ajax.php?' . http_build_query($allArgs);
    }
103367
function getModulePath(module) {
    if (!module || !module.id) return ""

    var parts = module.id.split("/")

    return parts.slice(0, parts.length-1).join("/")
}
74397
public function module(Module $module)
    {
        $vars = $this->model::generate_page($module, 'setting');
        
        return $this->makeResponse('module', $vars);
    }
1320949
protected function getExtendsClassName(string $module): string
    {
        $shortName = (new \ReflectionClass($module))->getShortName();
        $extendClassName = "Package{$shortName}";

        return $extendClassName;
    }
4240
public function getModuleName()
    {
        $module = $this->argument('module') ?: app('modules')->getUsedNow();

        $module = app('modules')->findOrFail($module);

        return $module->getStudlyName();
    }
349480
public function loadModule($module)
    {
        $trgtModule = $module;
        if (is_array($module) && !empty($module)) {
            $trgtModule = $module[count($module)-1];
        }

        if (!in_array($trgtModule, $this->getActiveModules())) {
            $moduleLoadFile = $_SERVER['DOCUMENT_ROOT'] . '/../config/melis.module.load.php';
            if (file_exists($moduleLoadFile)) {
                $modules = include $_SERVER['DOCUMENT_ROOT'] . '/../config/melis.module.load.php';

                $moduleCount = count($modules);
                $insertAtIdx = $moduleCount - 1;
                array_splice($modules, $insertAtIdx, 0, $module);

                // create the module.load file
                $this->createModuleLoader('config/', $modules, [], []);
            }
        }

        return $this->isModuleLoaded($trgtModule);
    }
338213
public function getModuleName()
    {
        $module = $this->argument('module') ?: $this->laravel['modules']->getUsedNow();

        $module = $this->laravel['modules']->findOrFail($module);

        return $module->getStudlyName();
    }
591563
static public function getModuleCommands($module)
    {
        $prefix = $module instanceof Application ? '' : $module->getUniqueId().'/';

        $controllers = [];
        foreach (array_keys($module->controllerMap) as $id) {
            $controllers[] = $prefix.$id;
        }

        foreach ($module->getModules() as $id => $child) {
            if (($child = $module->getModule($id)) === null) {
                continue;
            }
            foreach (static::getModuleCommands($child) as $command) {
                $controllers[] = $command;
            }
        }

        $controllerPath = $module->getControllerPath();
        if (is_dir($controllerPath)) {
            $files = scandir($controllerPath);
            foreach ($files as $file) {
                if (!empty($file) && substr_compare($file, 'Controller.php', -14, 14) === 0) {
                    $controllerClass = $module->controllerNamespace.'\\'.substr(basename($file), 0, -4);
                    if (static::validateControllerClass($controllerClass)) {
                        $controllers[] = $prefix.Inflector::camel2id(substr(basename($file), 0, -14));
                        //$controllers[] = $controllerClass;
                    }
                }
            }
        }

        return $controllers;
    }