Пример #1
0
 function __construct(&$subject, $config = array())
 {
     parent::__construct($subject, $config);
     if (is_null(self::$isPro)) {
         self::$isPro = JLNodoublesHelper::allow($this->params->get('key')) ? true : false;
     }
     self::$noRedirect = $this->stopWords();
 }
Пример #2
0
    protected function getInput()
    {
        $db = JFactory::getDBO();
        $doc = JFactory::getDocument();
        $db->setQuery('SELECT element FROM #__extensions WHERE type="component" ORDER BY name');
        $components = $db->loadColumn();
        jimport('joomla.filesystem.folder');
        $folders = JFolder::folders(JPATH_ROOT . '/components', 'com_(.*)');
        if (!$this->value) {
            $this->value = array(0 => array('var_name' => array('task', 'format', 'no_html', 'tmpl'), 'var_value' => array('save, edit, add, delete, apply', 'nohtml', '1', 'component')), 'com_content' => array('checkbox' => 'on', 'var_name' => array(''), 'var_value' => array('')));
        }
        $this->components = JFolder::files(JPATH_ROOT . '/plugins/system/jlnodoubles/helpers');
        $plugin = JPluginHelper::getPlugin('system', 'jlnodoubles');
        $pluginParams = new JRegistry($plugin->params);
        $allow = JLNodoublesHelper::allow($pluginParams->get('key', '')) ? true : false;
        $all = JText::_('PLG_JLNODUBLES_ALL_COMPONENTS');
        array_unshift($components, $all);
        ?>
        <div id="sh_component_wrapper">
            <?php 
        var_dump($allow);
        foreach ($components as $component) {
            if (in_array($component, $folders) || $component == $all) {
                $componentName = $component;
                if ($component == $all) {
                    $component = 0;
                }
                $checked = isset($this->value[$component]["checkbox"]) ? ' checked="checked" ' : '';
                $unchecked_class = $checked || !$component ? '' : ' unchecked ';
                $disabled = !$allow && $componentName != 'com_content' && in_array($componentName . '.php', $this->components) ? ' disabled="disabled"' : '';
                ?>
                    <div class="sh_component_inner <?php 
                echo $unchecked_class;
                ?>
"
                         id="sh_component_<?php 
                echo $component;
                ?>
">
                        <div class="sh_component_name">
                            <?php 
                if ($component) {
                    ?>
                                <input type="checkbox"
                                       onclick="shnodoubles.com_checkbox(this, '<?php 
                    echo $component;
                    ?>
')"
                                       class="shnodoubles_com_checkbox"
                                       name="<?php 
                    echo $this->name . '[' . $component . '][checkbox]';
                    ?>
" <?php 
                    echo $checked;
                    ?>
                                        <?php 
                    echo $disabled;
                    ?>
                                    />
                            <?php 
                }
                ?>
                            <?php 
                echo $componentName;
                ?>
                            <input type="button" value="<?php 
                echo JText::_('PLG_JLNODUBLES_ADD_VAR');
                ?>
"
                                   onclick="shnodoubles.add_var(this, '<?php 
                echo $component;
                ?>
')"
                                   class="shnodoubles_add_var">
                        </div>
                        <?php 
                if (!isset($this->value[$component]) || !isset($this->value[$component]["var_name"])) {
                    $this->value[$component] = array('var_name' => array(''), 'var_value' => array(''));
                }
                for ($i = 0; $i < sizeof($this->value[$component]["var_name"]); $i++) {
                    ?>
                            <div class="sh_component_value">
                                <input name="<?php 
                    echo $this->name . '[' . $component . '][var_name][]';
                    ?>
'"
                                       placeholder="<?php 
                    echo JText::_('PLG_JLNODUBLES_VAR');
                    ?>
"
                                       value="<?php 
                    echo $this->value[$component]["var_name"][$i];
                    ?>
">
                                <input name="<?php 
                    echo $this->name . '[' . $component . '][var_value][]';
                    ?>
"
                                       placeholder="<?php 
                    echo JText::_('PLG_JLNODUBLES_COMPONENT_VAR_VALUE');
                    ?>
"
                                       class="sh_component_var_value"
                                       value="<?php 
                    echo $this->value[$component]["var_value"][$i];
                    ?>
">
                                <input type="button" value="<?php 
                    echo JText::_('PLG_JLNODUBLES_DEL');
                    ?>
"
                                       onclick="shnodoubles.remove_var(this)" class="shnodoubles_remove_var">
                            </div>
                        <?php 
                }
                ?>
                    </div>
                <?php 
            }
            ?>
            <?php 
        }
        ?>
        </div>
        <?php 
        $script = '
            var jlnodoubles = {
                "name": "' . $this->name . '",
                "lang": {
                    "VAR": "' . JText::_('PLG_JLNODUBLES_VAR') . '",
                    "VALUE": "' . JText::_('PLG_JLNODUBLES_COMPONENT_VAR_VALUE') . '",
                    "DEL": "' . JText::_('PLG_JLNODUBLES_DEL') . '"
                }
            };
        ';
        $doc->addScriptDeclaration($script);
        $doc->addScript(JUri::root() . 'plugins/system/jlnodoubles/assets/jlnodoubles.js');
        $doc->addStyleSheet(JUri::root() . 'plugins/system/jlnodoubles/assets/jlnodoubles.css');
    }