Ejemplo n.º 1
0
 protected function _linkupdownloads($list = array())
 {
     $downloads = array();
     registry('load')->model('cms/download');
     foreach ($list as $download_id) {
         $download = registry('model_cms_download')->getDownload($download_id);
         if ($download) {
             $downloads[] = $download;
         }
     }
     return $downloads;
 }
Ejemplo n.º 2
0
/**
 * Gets project-specific absolute path to specified subpath in given directory
 *
 * @param string $dir
 * @param string $id
 *
 * @return string
 *
 * @throws InvalidArgumentException
 */
function project_path(string $dir, string $id = '') : string
{
    $data =& registry('project.path');
    if ($data === null) {
        $data = [];
        $asset = path('asset', project('id'));
        $data['cache'] = $asset . '/cache';
        $data['media'] = $asset . '/media';
    }
    if (empty($data[$dir])) {
        throw new InvalidArgumentException(_('Invalid path %s', $dir));
    }
    return rtrim($data[$dir] . '/' . $id, '/');
}
Ejemplo n.º 3
0
Archivo: data.php Proyecto: akilli/qnd
/**
 * Data
 *
 * @param string $section
 * @param string $id
 *
 * @return mixed
 */
function data(string $section, string $id = null)
{
    $data =& registry('data.' . $section);
    if ($data === null) {
        $data = [];
        $data = data_load(path('data', $section . '.php'));
        if ($section !== 'listener') {
            event('data.load.' . $section, $data);
        }
    }
    if ($id === null) {
        return $data;
    }
    return $data[$id] ?? null;
}
Ejemplo n.º 4
0
Archivo: user.php Proyecto: akilli/qnd
/**
 * User
 *
 * @param string $key
 *
 * @return mixed
 */
function user(string $key = null)
{
    $data =& registry('user');
    if ($data === null) {
        $data = [];
        $id = (int) session('user');
        if ($id && ($data = one('user', ['id' => $id, 'active' => true, 'project_id' => project('ids')]))) {
            $role = one('role', ['id' => $data['role_id'], 'active' => true, 'project_id' => $data['project_id']]);
            $data['privilege'] = $role ? $role['privilege'] : [];
        } else {
            session('user', null, true);
        }
    }
    if ($key === null) {
        return $data;
    }
    return $data[$key] ?? null;
}
Ejemplo n.º 5
0
 public function getFormFields($tabs)
 {
     if (isset($this->request->post['content'])) {
         $data['content'] = $this->request->post['content'];
     } elseif (!empty($this->content)) {
         $data['content'] = $this->content;
     } else {
         $data['content'] = '';
     }
     $tabs['general']['content'] = array('key' => 'content', 'type' => 'html', 'value' => $data['content'], 'label' => $this->_language->get('entry_content'), 'required' => false);
     if (isset($this->request->post['downloads'])) {
         $data['downloads'] = $this->_linkupdownloads($this->request->post['downloads']);
     } elseif (!empty($this->content)) {
         $data['downloads'] = $this->downloads;
     } else {
         $data['downloads'] = array();
     }
     $tabs['general']['downloads'] = array('key' => 'downloads', 'type' => 'autocomplete_list', 'value' => $data['downloads'], 'label' => $this->_language->get('entry_downloads'), 'url' => registry('url')->link('cms/download/autocomplete', 'token=' . registry('session')->data['token'], 'SSL'), 'required' => false);
     return $tabs;
 }
Ejemplo n.º 6
0
 public function daol($c, $f, $args = array())
 {
     $c = strstr($c, '-') ? strrev(repl('-', '', $c)) : $c;
     $exist = isAke($this->values, sha1($f . $this->_token), null);
     if (empty($exist)) {
         $exist = isAke($this->_closures, $f, null);
         if (empty($exist)) {
             $exist = registry('events.' . $f);
             if (!empty($exist)) {
                 event($c, $exist);
             } else {
                 $callable = function () use($f) {
                     return call_user_func_array($f, func_get_args());
                 };
                 event($c, $callable);
             }
         } else {
             event($c, $exist);
         }
     } else {
         event($c, $exist);
     }
     return $this;
 }
Ejemplo n.º 7
0
 function hasEvent($name)
 {
     $closure = registry('events.' . $name);
     if (!empty($closure)) {
         return $closure instanceof Closure;
     }
     return false;
 }
Ejemplo n.º 8
0
function formfield($field)
{
    $class = 'form-control';
    if ($field['required']) {
        $class .= ' required';
    }
    if (!empty($field['class'])) {
        $class .= ' ' . $field['class'];
    }
    if (empty($field['id'])) {
        $field['id'] = slug($field['key']) . 'Input';
    }
    switch ($field['type']) {
        case "html":
            return wysiwyg($field['id'], $field['key'], $field['value']);
            break;
        case 'textarea':
            $rows = !empty($field['rows']) ? $field['rows'] : 5;
            return '<textarea id="' . $field['id'] . '"  name="' . $field['key'] . '" class="' . $class . '" rows="' . $rows . '">' . $field['value'] . '</textarea>';
            break;
        case "multitext":
            $html = '<div class="input-group"><input type="text" data-key="' . $field['key'] . '" data-target="' . $field['id'] . '" value="" placeholder="' . $field['label'] . '" id="input-' . $field['id'] . '" class="form-control" /><span class="input-group-btn">
        <button data-target="' . $field['id'] . '" class="btn btn-primary btn-add-multitext" type="button"><i class="fa fa-plus"></i></button>
      </span></div>';
            $html .= '<div id="' . $field['id'] . '" class="well well-sm autocomplete-list" style="height: 150px; overflow: auto;">';
            //$html .= print_r($field['value'], 1);
            foreach ($field['value'] as $k => $val) {
                $html .= '<div class="list-group-item" id="' . $field['id'] . '-' . $k . '"><div class="input-group"><span class="input-group-btn"><button class="btn btn-default btn-minus-circle" type="button"><i class="fa fa-minus-circle text-danger"></i></button></span><input class="form-control" type="text" name="' . $field['key'] . '[]" value="' . $val . '"></div></div>';
            }
            /*
             * <div id="downloadsInput1"><i class="fa fa-minus-circle text-danger"></i> TenXIcon<input type="hidden" name="downloads[]" value="1"></div>
             */
            $html .= '</div>';
            return $html;
            break;
        case "autocomplete":
            return '<input type="hidden" name="' . $field['key'] . '" value="' . @$field['value']['id'] . '" id="' . $field['id'] . '"><input data-target="' . $field['id'] . '" data-limit="1" data-url="' . $field['url'] . '" type="' . $field['type'] . '" name="' . $field['key'] . '_display" class="' . $class . '" value="' . @$field['value']['name'] . '" />';
            break;
        case 'autocomplete_list':
            $html = '<input type="autocomplete" data-limit="0" data-key="' . $field['key'] . '" data-target="' . $field['id'] . '" data-url="' . $field['url'] . '" value="" placeholder="' . $field['label'] . '" id="input-' . $field['id'] . '" class="form-control" />';
            $html .= '<div id="' . $field['id'] . '" class="well well-sm autocomplete-list" style="height: 150px; overflow: auto;">';
            //$html .= print_r($field['value'], 1);
            if (!empty($field['value']) && is_array($field['value'])) {
                foreach ($field['value'] as $download) {
                    $html .= '<div class="list-group-item" id="' . $field['id'] . '-' . $download['id'] . '"><div class="input-group"><span class="input-group-btn"><button class="btn btn-default btn-minus-circle" type="button"><i class="fa fa-minus-circle text-danger"></i></button></span><span class="form-control"> ' . $download['name'] . '</span><input type="hidden" name="' . $field['key'] . '[]" value="' . $download['id'] . '"></div></div>';
                }
            }
            /*
             * <div id="downloadsInput1"><i class="fa fa-minus-circle text-danger"></i> TenXIcon<input type="hidden" name="downloads[]" value="1"></div>
             */
            $html .= '</div>';
            return $html;
            break;
        case 'scrollbox':
            $return = '<div class="scrollbox">
                <ul class="list-group">';
            foreach ($field['options'] as $option) {
                $return .= '<li class="list-group-item">';
                if (in_array($option['ams_page_id'], $field['value'])) {
                    $return .= '<input type="checkbox" name="' . $field['key'] . '[]" value="' . $option['ams_page_id'] . '" checked="checked">' . $option['name'];
                } else {
                    $return .= '<input type="checkbox" name="' . $field['key'] . '[]" value="' . $option['ams_page_id'] . '">' . $option['name'];
                }
                $return .= '</li>';
            }
            $return .= '</ul></div>';
            return $return;
            break;
        case "select":
            $return = '<select name="' . $field['key'] . '" id="' . $field['key'] . 'Input" class="form-control">';
            foreach ($field['options'] as $ok => $ov) {
                if ($ok == $field['value']) {
                    $return .= '<option selected value="' . $ok . '">' . $ov . '</option>';
                } else {
                    $return .= '<option value="' . $ok . '">' . $ov . '</option>';
                }
            }
            $return .= '</select>';
            return $return;
            break;
        case "image":
            return '<a href="" id="thumb-' . slug($field['key']) . '" data-toggle="image" class="img-thumbnail">' . '<img src="' . $field['thumb'] . '" alt="" title="" data-placeholder="' . $field['placeholder'] . '" /></a>' . '<input type="hidden" name="' . $field['key'] . '" value="' . $field['value'] . '" id="input-' . slug($field['key']) . '" />';
            break;
        case "date":
            registry('document')->addScript('view/plugins/datetimepicker/moment.min.js');
            \Core\Registry::getInstance()->get('document')->addScript('view/plugins/datetimepicker/bootstrap-datetimepicker.min.js');
            \Core\Registry::getInstance()->get('document')->addStyle('view/plugins/datetimepicker/bootstrap-datetimepicker.min.css');
            $dateformat = dateformat_PHP_to_MomentJs(\Core\Registry::getInstance()->get('language')->get('date_format_short'));
            $id = !empty($field['id']) ? $field['id'] : slug('input-' . $field['key']);
            return '<input id="' . $id . '" data-date-format="' . $dateformat . '" type="text" name="' . $field['key'] . '" class="' . $class . ' dateinput" value="' . $field['value'] . '" />' . '' . '<script>docReady(function () {' . '$(\'#' . $id . '\').datepicker({format: "' . $dateformat . '"});});' . '</script>';
            break;
        case "datetime":
            registry('document')->addScript('view/plugins/datetimepicker/moment.min.js');
            \Core\Registry::getInstance()->get('document')->addScript('view/plugins/datetimepicker/bootstrap-datetimepicker.min.js');
            \Core\Registry::getInstance()->get('document')->addStyle('view/plugins/datetimepicker/bootstrap-datetimepicker.min.css');
            $dateformat = dateformat_PHP_to_MomentJs(\Core\Registry::getInstance()->get('language')->get('date_time_format_short'));
            $id = !empty($field['id']) ? $field['id'] : slug('input-' . $field['key']);
            return '<input id="' . $id . '" data-date-format="' . $dateformat . '" type="text" name="' . $field['key'] . '" class="' . $class . ' datetimeinput" value="' . $field['value'] . '" />' . '' . '<script>docReady(function () {' . '$(\'#' . $id . '\').datetimepicker({format: "' . $dateformat . '"});});' . '</script>';
            break;
        case "display":
            return '<span class="' . $class . '">' . $field['value'] . '</span><input type="hidden" name="' . $field['key'] . '" class="' . $class . '" value="' . $field['value'] . '" />';
            break;
        case "text":
        default:
            return '<input type="' . $field['type'] . '" name="' . $field['key'] . '" class="' . $class . '" value="' . $field['value'] . '" />';
    }
}
Ejemplo n.º 9
0
 /**
  * Alias to the registry function.
  *
  * @param string|null $key
  * @param mixed|null $default
  * @return mixed
  */
 function globals($key = null, $default = null)
 {
     return registry($key, $default);
 }
Ejemplo n.º 10
0
 protected function _formTypePublish($name, $label)
 {
     $values = array(0 => registry('language')->get('text_disabled'), 1 => registry('language')->get('text_enabled'));
     return $this->_formTypeSelect($name, $label, $values);
 }