Kaynağa Gözat

WIP on adding form

Andy Baugh 7 yıl önce
ebeveyn
işleme
e88538c3e0
2 değiştirilmiş dosya ile 59 ekleme ve 8 silme
  1. 5 6
      lib/tCMS/Config.inc
  2. 54 2
      templates/default/admin/settings.inc

+ 5 - 6
lib/tCMS/Config.inc

@@ -10,11 +10,10 @@
         ];
         private $conf_model = [
             'users' => [
-                'name'        => [ 'display' => true, 'masks' => 'parent', 'label' => 'Username', 'placeholder' => 'AzureDiamond', 'form_field' => 'input', 'field_type' => 'text' ],
-                'password'    => [ 'display' => true, 'masks' => 'auth_hash', 'label' => 'Password', 'placeholder' => 'hunter2', 'form_field' => 'input', 'field_type' => 'password' ],
-                'display_name' => [ 'display' => true, 'label' => 'Display Name', 'placeholder' => "Your Name", 'default' => 'Anonymous', 'form_field' => 'input', 'field_type' => 'text' ],
+                'name'         => [ 'masks' => 'parent', 'label' => 'Username', 'placeholder' => 'AzureDiamond', 'form_field' => 'input', 'field_type' => 'text' ],
+                'password'     => [ 'masks' => 'auth_hash', 'label' => 'Password', 'placeholder' => 'hunter2', 'form_field' => 'input', 'field_type' => 'password' ],
+                'display_name' => [ 'label' => 'Display Name', 'placeholder' => "Your Name", 'default' => 'Anonymous', 'form_field' => 'input', 'field_type' => 'text' ],
                 'avatar'       => [
-                    'display'      => true,
                     'label'        => 'User Avatar',
                     'default'      => "R0lGODlhGAAYAMIAAAAAAIYGBp2dndHR0QAAAAAAAAAAAAAAACH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEKAAQALAAAAAAYABgAAANySBQc+jDGMOpwMj96OdYShYmg9okAAazsWqIDIMz0nGaiJbercIeXls1H+00utWTRhOS1Gp+JjLibcSpRyFTp8YR2TpGPBBETz4DAjlzeKmnsCNi5isuTboFdSy2y9g95XBcldDxZJYmKIIiLG4SOOBEJADs=",
                     'form_field'   => 'input',
@@ -23,8 +22,8 @@
                 ],
              ],
             'main'  => [
-                'theme' => [ 'display' => true, 'label' => 'tCMS Theme', 'default' => 'default', 'form_field' => 'select', 'select_opts' => [ 'default' ] ],
-                'home'  => [ 'display' => true, 'label' => 'Default Home', 'default' => 'blog', 'form_field' => 'select', 'select_opts' => [ 'blog', 'microblog', 'fileshare' ] ],
+                'home'  => [ 'label' => 'Default Home', 'default' => 'blog', 'form_field' => 'select', 'select_opts' => [ 'blog', 'microblog', 'fileshare' ] ],
+                'theme' => [ 'label' => 'tCMS Theme', 'default' => 'default', 'form_field' => 'select', 'select_opts' => [ 'default' ] ],
             ],
         ];
 

+ 54 - 2
templates/default/admin/settings.inc

@@ -2,14 +2,66 @@
  General settings:
 </p>
 <hr />
-INSERT FORM HERE
+<form id="mainConfig" method="post" action="index.php">
+    <?php
+        $conf  = $conf_obj->get('main');
+        $model = $conf_obj->get_config_model('main');
+        $line = '<input type="hidden" name="conf_change_type" value="main"></input>';
+
+        # For now there's no use to the 'form_field' setting, as main only uses select, user only inputs
+        foreach ( $model as $key => $item ) {
+            $line .= '<label for="' . $key . '">' . $item['label'] . '</label>';
+            $line .= '<select name="' . $key '" id="' . $key . '">';
+            foreach ( $item['select_opts'] as $option ) {
+                $line .= '<option value="' . $option . '">' . $option . '</option>';
+            }
+            $line .= '</select>';
+            echo "$line\n";
+        }
+    ?>
+    <input type="submit" value="Commit Changes"></input>
+</form>
 <hr />
 
 <p class="title">
  User management:
 </p>
 <hr />
-INSERT USER TABLE W/USER DROPDOWN FORM HERE
+<form id="userConfig" method="post" action="index.php">
+    <?php
+        $conf  = $conf_obj->get('user');
+        $model = $conf_obj->get_config_model('user');
+        $line = '<input type="hidden" name="conf_change_type" value="user"></input>';
+        foreach ( $conf as $user => $data ) {
+            foreach ( $model as $key => $item ) {
+                $line .= '<label for="' . $key . '">' . $item['label'] . '</label>';
+                $val = "";
+                if( array_key_exists( $key, $data ) ) {
+
+                } else if( array_key_exists( 'masks', $conf ) ) {
+                    if( $conf['masks'] == 'parent' ) $val = 
+                }
+                $line .= '<input name="' . $key . '" id="' . $key . '" type="' . $item['field_type'] . '" placeholder="' . $item['placeholder'] . '" value="' . $val . '"></input><br />';
+                echo "$line\n";
+            }
+        }
+    ?>
+    <input type="submit" value="Commit Changes"></input>
+</form>
+<p class="title">
+ Add User:
+</p>
+<form id="addUser" method="post" action="index.php">
+    <input type="hidden" name="conf_change_type" value="user"></input>
+    <?php
+        foreach ( $model as $key => $item ) {
+            $line .= '<label for="' . $key . '">' . $item['label'] . '</label>';
+            $line .= '<input name="' . $key . '" id="' . $key . '" type="' . $item['field_type'] . '" placeholder="' . $item['placeholder'] . '" value=""></input><br />';
+            echo "$line\n";
+        }
+    ?>
+    <input type="submit" value="Commit Changes"></input>
+</form>
 <hr />
 
 <p class="title">