示例#1
0
 public static function buildJSONTree($lang = 'en-US')
 {
     $u = Qdmvc_Helper::getCurrentUser();
     $debug_mode = isset($_GET['debugmode']) ? $_GET['debugmode'] : 0;
     $re = array();
     foreach (static::getIndex() as $key => $config) {
         if (!$u->hasPermission(null, null, $key)) {
             continue;
         }
         //quocdunginfo, performance
         $tmp = array();
         $active = isset($config['Active']) ? $config['Active'] : true;
         $p_id = isset($config['ParentId']) ? $config['ParentId'] : -1;
         if (!$active) {
             continue;
         }
         $text = isset($config['Caption']) && isset($config['Caption'][$lang]) ? $config['Caption'][$lang] : $key;
         $tmp['title'] = $debug_mode == 1 ? $key : $text;
         $tmp['key'] = $key;
         $tmp['parentid'] = $p_id;
         if (!Qdmvc_Helper::isNullOrEmpty($config['PageType']) && $config['PageType'] == 'Folder') {
             $tmp['title'] = '[' . $tmp['title'] . ']';
             $tmp['value'] = '';
             $tmp['folder'] = true;
         } else {
             $tmp['value'] = Qdmvc_Helper::getCompactPageListLink($key);
         }
         array_push($re, $tmp);
     }
     return json_encode($re);
 }
示例#2
0
 protected static function getFieldsConfig($f_name, $meta_name, $lang = 'en-US')
 {
     //check in Layout first
     $tmp_config = static::initFields();
     if (!Qdmvc_Helper::isNullOrEmpty($tmp_config[$f_name][$meta_name])) {
         return $tmp_config[$f_name][$meta_name];
     }
     //check in Model
     $c = static::getModel();
     $tmp = $c::getSingleFieldConfig($f_name, $meta_name, $lang);
     if (Qdmvc_Helper::isNullOrEmpty($tmp) && $meta_name == 'SourceExpr') {
         $tmp = $f_name;
     }
     return $tmp;
 }
示例#3
0
 public static function getLanguage()
 {
     if (static::$language == null) {
         //check user personalization first
         $username = Qdmvc_Helper::getCurrentUserName();
         if ($username != null) {
             $tmp = new QdUserPersonalization();
             $tmp->SETRANGE('username', $username);
             $tmp->SETRANGE('active', true);
             $tmp = $tmp->GETLIST();
             if (!Qdmvc_Helper::isNullOrEmpty($tmp)) {
                 if ($tmp[0]->language != '') {
                     static::$language = $tmp[0]->language;
                     return static::$language;
                 }
             }
         }
         //check in general setup
         $tmp = QdSetup::GET();
         static::$language = $tmp->df_language;
     }
     return static::$language;
 }
示例#4
0
 protected function assign()
 {
     //assign value
     $c = static::$model;
     foreach ($c::getFieldsConfig() as $key => $value) {
         if ($c::ISFLOWFIELD($key) || $c::ISSYSTEMFIELD($key)) {
             continue;
         }
         //check allow submit field
         if (!Qdmvc_Helper::isNullOrEmpty(static::allowSubmitFields())) {
             if (!in_array($key, static::allowSubmitFields())) {
                 continue;
             }
         }
         //Boolean
         if (in_array($c::getDataType($key), array('Boolean'))) {
             $this->obj->{$key} = 0;
             if (isset($_POST['data'][$key])) {
                 if ($_POST['data'][$key] === 'true' || $_POST['data'][$key] === '1' || $_POST['data'][$key] === 1 || $_POST['data'][$key] === true) {
                     $this->obj->{$key} = 1;
                 }
             }
             continue;
         }
         if ($c::getDataType($key) == 'Date') {
             if (isset($_POST['data'][$key])) {
                 $tmp = DateTime::createFromFormat(get_option('date_format', 'j/m/Y'), $_POST['data'][$key]);
                 //DateTime::createFromFormat('d/M/Y', "01/01/2015");//$_POST['data'][$key]);
                 if ($tmp == false) {
                     $this->obj->{$key} = null;
                 } else {
                     $this->obj->{$key} = $tmp;
                 }
             }
             continue;
         }
         if (isset($_POST['data'][$key])) {
             $this->obj->{$key} = $_POST['data'][$key];
             $this->obj->{$key} = str_replace('\\"', '"', $this->obj->{$key});
             //quocdunginfo, need to find other approach
             $this->obj->{$key} = str_replace("\\'", "'", $this->obj->{$key});
             //quocdunginfo, need to find other approach
         }
     }
 }
    private function render_serverFunctions()
    {
        if (count($this->serverFunctions()) <= 0) {
            return;
        }
        ?>
        <!-- Single button -->
        <div class="btn-group">
            <button type="button" class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown"
                    aria-expanded="false">
                <?php 
        echo Qdmvc_Message::getMsg('btn_function');
        ?>
 <span class="caret"></span>
            </button>
            <ul class="dropdown-menu" role="menu">
                <?php 
        foreach ($this->serverFunctions() as $item => $config) {
            $fn_label = isset($config['label'][$this->data['language']]) ? $config['label'][$this->data['language']] : '@' . $item;
            $fn_confirm = !Qdmvc_Helper::isNullOrEmpty($config['confirm']) && $config['confirm'] == true;
            ?>
                    <li><a id="<?php 
            echo $item;
            ?>
"><?php 
            echo $fn_label;
            ?>
</a></li>
                <?php 
            if (!Qdmvc_Helper::isNullOrEmpty($config['fn_name'])) {
                ?>
                    <script>
                        (function ($) {
                            $(document).ready(function () {
                                $('#<?php 
                echo $item;
                ?>
').click(function () {
                                    <?php 
                if ($fn_confirm) {
                    echo sprintf('if(confirm("%s"))', Qdmvc_Message::getMsg('msg_confirm'));
                }
                ?>
                                    MYAPP.callFn('<?php 
                echo $config['fn_name'];
                ?>
');
                                });
                            });
                        })(jQuery);
                    </script>
                <?php 
            }
        }
        ?>
            </ul>
        </div>
    <?php 
    }
示例#6
0
 public static function getSourceExpr($f_name)
 {
     $re = static::getFieldsConfig($f_name, 'SourceExpr');
     if (Qdmvc_Helper::isNullOrEmpty($re)) {
         $re = $f_name;
     }
     return $re;
 }
示例#7
0
 private function checkMandatory()
 {
     $cf = static::getFieldsConfig();
     $re = true;
     foreach ($cf as $key => $config) {
         if (Qdmvc_Helper::isNullOrEmpty($this->{$key})) {
             if (static::ISMANDATORY($key)) {
                 $this->pushValidateError($key, sprintf(Qdmvc_Message::getMsg('msg_field_mandatory'), $this->id, static::getFieldCaption($key, Qdmvc_Config::getLanguage())), 'error');
                 $re = false;
             }
         }
     }
     return $re;
 }