예제 #1
0
 public function __construct($name, $conf)
 {
     parent::__construct($conf);
     $this->name = $name;
     $this->required = isset($conf['required']) ? $conf['required'] : 0;
     $this->size = isset($conf['size']) ? $conf['size'] : false;
 }
예제 #2
0
    public function SmilesWidget($element_id, $smiles_per_row = 4)
    {
        parent::__construct();
        $vb = new ViewBuilder("form/smilesWidget.html");
        // Genera l'HTML delle righe degli smiles qui
        $smiles_table = "";
        $c = 0;
        foreach (Smiles::GetList() as $smile => $image) {
            if ($c == 0) {
                $smiles_table .= "<tr>";
            }
            $smiles_table .= sprintf('<td onclick="javascript:Text.AppendTo(\'%s\', \'%s\');" data-hide="smiles-list-%s">
					<img src="/images/smiles/%s" alt="%s" />
				</td>', $element_id, $smile, $this->widget_id, $image, $smile);
            // Dividi gli smiles in righe
            $c = ($c + 1) % $smiles_per_row;
            if ($c == 0) {
                $smiles_table .= "</tr>";
            }
        }
        $vb->addValue("widget_id", $this->widget_id);
        $vb->addValue("smiles_table", $smiles_table);
        $vb->addValue("element_id", $element_id);
        $this->html = $vb->render();
    }
 public function __construct($name, $conf)
 {
     parent::__construct($conf);
     $this->name = $name;
     $this->required = isset($conf['required']) ? $conf['required'] : 0;
     $this->wysiwyg = isset($conf['wysiwyg']) ? $conf['wysiwyg'] : 0;
 }
 public function __construct($name, $conf)
 {
     parent::__construct($conf);
     $this->name = $name;
     $this->required = isset($conf['required']) ? $conf['required'] : 0;
     $this->options = $conf['options'];
 }
예제 #5
0
 public function __construct($name, $conf)
 {
     parent::__construct($conf);
     $this->name = $name;
     $this->required = isset($conf['required']) ? $conf['required'] : 0;
     $this->options = isset($conf['options']) ? $conf['options'] : array('0' => '-- Select --', 'val1' => 'option1', 'val2' => 'option2');
 }
예제 #6
0
 function run($path)
 {
     $sql = 'SELECT * FROM {{forms}} WHERE path=\'' . $path . '\'';
     $form = DB::getRow($sql);
     $sql = 'SELECT * FROM {{forms_fields}} WHERE forms=' . $form['id'] . ' ORDER BY num';
     $fields = DB::getAll($sql);
     foreach ($fields as $item) {
         $item['required'] = $item['required'] == 1 ? 'required' : '';
         switch ($item['type']) {
             case 'string':
                 $text .= FormWidget::getString($item);
                 break;
             case 'text':
                 $text .= FormWidget::getText($item);
                 break;
             case 'select':
                 $text .= FormWidget::getSelect($item);
                 break;
             case 'radio':
                 $text .= FormWidget::getRadio($item);
                 break;
             case 'hidden':
                 $text .= FormWidget::getString($item);
                 break;
             case '':
                 break;
         }
     }
     return str_replace('{content}', $text, View::getWidget('form', $form));
 }
예제 #7
0
 public function BbButtonWidget($element_id, $features = "code|quote|g|c|s")
 {
     parent::__construct();
     $vb = new ViewBuilder("form/bbButtonWidget.html");
     $features = explode("|", $features);
     foreach ($features as $feature) {
         $vb->addValue($feature, true);
     }
     $vb->addValue("widget_id", $this->widget_id);
     $vb->addValue("element_id", $element_id);
     $this->html = $vb->render();
 }
예제 #8
0
 public function __construct($name, $conf)
 {
     parent::__construct($conf);
     $this->name = $name;
     $this->required = isset($conf['required']) ? $conf['required'] : 0;
     $this->multiple = isset($conf['multiple']) ? $conf['multiple'] : 0;
     if (isset($conf['dimension']) && preg_match('/^\\d+x\\d$/', $conf['dimension'])) {
         $tokens = explode('x', $conf['dimension']);
         $this->dimension = array($tokens[0], $tokens[1]);
     } else {
         $this->dimension = 0;
     }
     $this->watermark = isset($conf['watermark']) ? $conf['watermark'] : 0;
 }
예제 #9
0
 public function __construct($name, $conf)
 {
     parent::__construct($conf);
     $this->name = $name;
     $this->required = isset($conf['required']) ? $conf['required'] : 0;
     $this->max_file_number = isset($conf['max_file_number']) ? $conf['max_file_number'] : 0;
     $this->max_file_size = isset($conf['max_file_size']) ? $conf['max_file_size'] : 2;
     // default to 2 MB
     $this->extensions = isset($conf['extensions']) ? $conf['extensions'] : 'jpg,png,gif';
     $this->extensions_quoted = explode(',', $this->extensions);
     $this->upload_dir = isset($conf['upload_dir']) ? $conf['upload_dir'] : 'files';
     $quoted = array();
     foreach ($this->extensions_quoted as $ext) {
         $quoted[] = "'{$ext}'";
     }
     $this->extensions_quoted = implode(',', $quoted);
 }
예제 #10
0
    public static function getFieldsByTree($id, $option = '')
    {
        $gal = 0;
        $data = array();
        $return = array();
        $sql = 'SELECT * FROM {{data}} WHERE tree=' . $id . ' AND field=0 ORDER BY num';
        $additional = DB::getAll($sql);
        foreach ($additional as $item) {
            if ($item['type'] == 'editor' || $item['type'] == 'text') {
                if ($_SESSION['user']['panel']['edit'] == 'on') {
                    $item['value'] = $item['value_text'];
                    $item['field'] = 'value_text';
                    $data[$item['path']] = View::getRenderEmpty('../' . ONESSA_DIR . '/views/onessa/field', $item);
                } else {
                    $data[$item['path']] = $item['value_text'];
                }
            } elseif ($item['type'] == 'string') {
                if ($_SESSION['user']['panel']['edit'] == 'on') {
                    $item['value'] = $item['value_string'];
                    $item['field'] = 'value_string';
                    $data[$item['path']] = View::getRenderEmpty('../' . ONESSA_DIR . '/views/onessa/field', $item);
                } else {
                    $data[$item['path']] = $item['value_string'];
                }
            } elseif ($item['type'] == 'integer') {
                $data[$item['path']] = $item['value_int'];
            } elseif ($item['type'] == 'radio') {
                //$data[$item['path']]=$item['value_int'];
                $data[$item['path']] = $item['value_int'] == 1 ? 'Да' : 'Нет';
            } elseif ($item['type'] == 'float') {
                $data[$item['path']] = $item['value_float'];
            } elseif ($item['type'] == 'select') {
                $data[$item['path']] = $item['value_text'];
            } elseif ($item['type'] == 'gallery') {
                $galname = $item['path'];
                if ($option == 'gal') {
                    $gal++;
                    $galname = 'gal' . $gal;
                }
                if (class_exists(GalleryWidget)) {
                    $data[$galname] = GalleryWidget::run($item);
                    if ($option == 'wide' || $option == 'gal') {
                        $data['files_' . $galname] = GalleryWidget::$files;
                    }
                } else {
                    $sql = '
						SELECT id FROM {{data}}
						WHERE tree=' . $item['tree'] . ' AND path=\'' . $item['path'] . '\' AND type=\'gallery\'
					';
                    $dataId = DB::getOne($sql);
                    if ($dataId) {
                        $sql = '
							SELECT id2 FROM {{relations}}
							WHERE modul1=\'data\' AND modul2=\'files\' AND id1=' . $dataId . '
						';
                        $fileId = DB::getAll($sql, 'id2');
                        if (count($fileId) > 0) {
                            $sql = '
								SELECT * FROM {{files}}
								WHERE id IN (' . implode(',', $fileId) . ')
								ORDER BY num
							';
                            $temp = DB::getAll($sql);
                            foreach ($temp as $item) {
                                $item['file'] = Funcs::getFileInfo($item['path']);
                                $data['files_' . $galname][$item['mime']][] = $item;
                            }
                        }
                    }
                }
            } elseif ($item['type'] != 'multival' && $item['type'] != 'multiselect' && $item['type'] != 'treeselectval' && $item['type'] != 'treeselect' && $item['type'] != 'select' && $item['type'] != 'fstring' && $item['type'] != 'fnumber' && $item['type'] != 'fcheckbox' && $item['type'] != 'fgroup') {
                $data[$item['type']] = FormWidget::run($item['type']);
            }
        }
        if ($option != 'wide') {
            foreach ($data as $key => $item) {
                if (is_numeric($key)) {
                    $return['additional'] .= $item;
                } else {
                    $return[$key] = $item;
                }
            }
            return $return;
        } else {
            return $data;
        }
    }
 public function __construct($name, $conf)
 {
     parent::__construct($conf);
     $this->name = $name;
 }