Ejemplo n.º 1
0
         $addition_state .= h::{'div.uk-modal.cs-left'}(h::{"{$tag}.uk-modal-dialog-large"}($tag == 'pre' ? prepare_attr_value(file_get_contents($file)) : file_get_contents($file)), ['id' => "{$module_name}_api", 'title' => "{$module_name} » {$L->api}"]);
     }
     $addition_state .= h::icon('link', ['data-title' => $L->api_exists . h::br() . (file_exists($file) ? $L->click_to_view_details : ''), 'onClick' => "\$('#{$module_name}_api').cs().modal('show');", 'class' => file_exists($file) ? 'cs-pointer' : false]);
     unset($tag, $file);
 }
 /**
  * Information about module
  */
 if (file_exists($file = MODULES . "/{$module_name}/readme.txt") || file_exists($file = MODULES . "/{$module_name}/readme.html")) {
     if (substr($file, -3) == 'txt') {
         $tag = 'pre';
     } else {
         $tag = 'div';
     }
     $uniqid = uniqid('module_info_');
     $Page->replace($uniqid, $tag == 'pre' ? prepare_attr_value(file_get_contents($file)) : file_get_contents($file));
     $addition_state .= h::{'div.uk-modal.cs-left'}(h::{"{$tag}.uk-modal-dialog-large"}($uniqid), ['id' => "{$module_name}_readme", 'title' => "{$module_name} » {$L->information_about_module}"]) . h::{'icon.cs-pointer'}('exclamation', ['data-title' => $L->information_about_module . h::br() . $L->click_to_view_details, 'onClick' => "\$('#{$module_name}_readme').cs().modal('show');"]);
     unset($uniqid);
 }
 unset($tag, $file);
 /**
  * License
  */
 if (file_exists($file = MODULES . "/{$module_name}/license.txt") || file_exists($file = MODULES . "/{$module_name}/license.html")) {
     if (substr($file, -3) == 'txt') {
         $tag = 'pre';
     } else {
         $tag = 'div';
     }
     $addition_state .= h::{'div.uk-modal.cs-left'}(h::{"{$tag}.uk-modal-dialog-large"}(file_get_contents($file)), ['id' => "{$module_name}_license", 'title' => "{$module_name} » {$L->license}"]) . h::{'icon.cs-pointer'}('legal', ['data-title' => $L->license . h::br() . $L->click_to_view_details, 'onClick' => "\$('#{$module_name}_license').cs().modal('show');"]);
 }
Ejemplo n.º 2
0
            $uniqid = uniqid('module_info_');
            $Page->replace($uniqid, $tag == 'pre' ? prepare_attr_value(file_get_contents($file)) : file_get_contents($file));
            $addition_state .= h::{'div.uk-modal.cs-left'}(h::{"{$tag}.uk-modal-dialog-large"}($uniqid), ['id' => "{$plugin}_readme", 'title' => "{$plugin} -> {$L->information_about_plugin}"]) . h::{'icon.cs-pointer'}('exclamation', ['data-title' => $L->information_about_plugin . h::br() . $L->click_to_view_details, 'onClick' => "\$('#{$plugin}_readme').cs().modal('show');"]);
            unset($uniqid);
        }
        unset($tag, $file);
        /**
         * License
         */
        if (file_exists($file = PLUGINS . "/{$plugin}/license.txt") || file_exists($file = PLUGINS . "/{$plugin}/license.html")) {
            if (substr($file, -3) == 'txt') {
                $tag = 'pre';
            } else {
                $tag = 'div';
            }
            $addition_state .= h::{'div.uk-modal.cs-left'}(h::{"{$tag}.uk-modal-dialog-large"}($tag == 'pre' ? prepare_attr_value(file_get_contents($file)) : file_get_contents($file)), ['id' => "{$plugin}_license", 'title' => "{$plugin} -> {$L->license}"]) . h::{'icon.cs-pointer'}('legal', ['data-title' => $L->license . h::br() . $L->click_to_view_details, 'onClick' => "\$('#{$plugin}_license').cs().modal('show');"]);
        }
        unset($tag, $file);
        $state = in_array($plugin, $Config->components['plugins']);
        $action .= h::{'a.cs-button-compact'}(h::icon($state ? 'minus' : 'check'), ['href' => $a->action . ($state ? '/disable/' : '/enable/') . $plugin, 'data-title' => $state ? $L->disable : $L->enable]);
        $plugin_info = false;
        if (file_exists(PLUGINS . "/{$plugin}/meta.json")) {
            $plugin_meta = file_get_json(PLUGINS . "/{$plugin}/meta.json");
            $plugin_info = $L->plugin_info($plugin_meta['package'], $plugin_meta['version'], $plugin_meta['description'], $plugin_meta['author'], isset($plugin_meta['website']) ? $plugin_meta['website'] : $L->none, $plugin_meta['license'], isset($plugin_meta['provide']) ? implode(', ', (array) $plugin_meta['provide']) : $L->none, isset($plugin_meta['require']) ? implode(', ', (array) $plugin_meta['require']) : $L->none, isset($plugin_meta['conflict']) ? implode(', ', (array) $plugin_meta['conflict']) : $L->none, isset($plugin_meta['optional']) ? implode(', ', (array) $plugin_meta['optional']) : $L->none, isset($plugin_meta['multilingual']) && in_array('interface', $plugin_meta['multilingual']) ? $L->yes : $L->no, isset($plugin_meta['multilingual']) && in_array('content', $plugin_meta['multilingual']) ? $L->yes : $L->no, isset($plugin_meta['languages']) ? implode(', ', $plugin_meta['languages']) : $L->none);
        }
        unset($plugin_meta);
        $plugins_list[] = [h::span($L->{$plugin}, ['data-title' => $plugin_info]), h::icon($state ? 'check' : 'minus', ['data-title' => $state ? $L->enabled : $L->disabled]) . $addition_state, $action];
        unset($plugin_info);
    }
    unset($plugin, $state, $addition_state, $action);
}
Ejemplo n.º 3
0
/**
 * Prepare text to be used as value for html attribute value
 *
 * @param string|string[]	$text
 *
 * @return string|string[]
 */
function prepare_attr_value($text)
{
    if (is_array($text)) {
        foreach ($text as &$val) {
            $val = prepare_attr_value($val);
        }
        return $text;
    }
    return strtr($text, ['&' => '&amp;', '"' => '&quot;', '\'' => '&apos;', '<' => '&lt;', '>' => '&gt;']);
}
Ejemplo n.º 4
0
 /**
  * Rendering of input tag with automatic adding labels for type=radio if necessary and automatic correction if min and/or max attributes are specified
  * and value is out of this scope
  *
  * @static
  *
  * @param array|string	$in
  * @param array			$data
  *
  * @return string
  */
 static function input($in = [], $data = [])
 {
     if (isset($in['insert']) || isset($data['insert'])) {
         return static::__callStatic(__FUNCTION__, func_get_args());
     }
     if ($in === false) {
         return '';
     }
     if (!empty($data)) {
         $in = array_merge(['in' => $in], $data);
     }
     if (isset($in['type']) && $in['type'] == 'radio') {
         if (is_array_indexed($in) && is_array($in[0])) {
             return static::__callStatic(__FUNCTION__, [$in, $data]);
         }
         if (is_array($in)) {
             if (!isset($in['checked'])) {
                 $in['checked'] = $in['value'][0];
             }
             if (isset($in['add']) && !is_array($in['add'])) {
                 $add = $in['add'];
                 $in['add'] = [];
                 foreach ($in['in'] as $v) {
                     $in['add'][] = $add;
                 }
                 unset($add);
             }
             foreach ($in['value'] as $i => $v) {
                 if ($v == $in['checked']) {
                     if (!isset($in['add'][$i])) {
                         $in['add'][$i] = ' checked';
                     } else {
                         $in['add'][$i] .= ' checked';
                     }
                     break;
                 }
             }
             unset($in['checked'], $i, $v);
             $items = array_flip_3d($in);
             unset($in, $v, $i);
             $temp = '';
             foreach ($items as $item) {
                 if (!isset($item['id'])) {
                     $item['id'] = uniqid('input_');
                 }
                 $item['tag'] = __FUNCTION__;
                 if (isset($item['value'])) {
                     $item['value'] = prepare_attr_value($item['value']);
                 }
                 $temp .= static::label(static::u_wrap($item), ['for' => $item['id']]);
             }
             return static::span($temp);
         } else {
             if (!isset($in['id'])) {
                 $in['id'] = uniqid('input_');
             }
             $in['tag'] = __FUNCTION__;
             if (isset($in['value'])) {
                 $in['value'] = prepare_attr_value($in['value']);
             }
             return static::label(static::u_wrap($in), ['for' => $in['id']]);
         }
     } else {
         if (is_array_indexed($in)) {
             return static::__callStatic(__FUNCTION__, [$in, $data]);
         }
         if (isset($in['name']) && is_array($in['name']) || isset($in['id']) && is_array($in['id'])) {
             $items = array_flip_3d($in);
             $return = '';
             foreach ($items as $item) {
                 $return .= static::input($item);
             }
             return $return;
         } else {
             if (!isset($in['type'])) {
                 $in['type'] = 'text';
             } elseif ($in['type'] == 'checkbox' && !isset($in['id'])) {
                 $in['id'] = uniqid('input_');
             }
             if ($in['type'] == 'checkbox' && isset($in['value'], $in['checked']) && $in['value'] == $in['checked']) {
                 $in[] = 'checked';
             }
             unset($in['checked']);
             if (isset($in['min'], $in['value']) && $in['min'] !== false && $in['min'] > $in['value']) {
                 $in['value'] = $in['min'];
             }
             if (isset($in['max'], $in['value']) && $in['max'] !== false && $in['max'] < $in['value']) {
                 $in['value'] = $in['max'];
             }
             $in['tag'] = __FUNCTION__;
             return static::u_wrap($in);
         }
     }
 }