Exemplo n.º 1
0
 /**
  * render
  * Fungsi ini untuk me-render layout
  * @param array $layout
  * @param array $sections
  * @param array $model
  * @param boolean $return
  * @return mixed me-return sebuah layout
  */
 public static function render($layout, $sections = null, $model = null, $return = false)
 {
     $formpath = @$sections['editor'] ? '//layouts/forms_editor/' : "//layouts/forms/";
     if (count($sections) > 0) {
         foreach ($sections as $k => $section) {
             switch (@$section['type']) {
                 case "menu":
                     if (@$section['file'] == "") {
                         continue;
                     }
                     $options = ['title' => @$section['title'], 'icon' => @$section['icon'], 'sections' => $sections, 'options' => @$section['menuOptions'], 'inlineJS' => @$section['inlineJS']];
                     $mt = MenuTree::load($section['file'], $options);
                     if ($mt != null) {
                         $sections[$k]['content'] = $mt->render(false);
                     }
                     break;
                 case "form":
                     if (@$section['class'] == "") {
                         continue;
                     }
                     $fb = FormBuilder::load(@$section['class']);
                     if ($fb != null) {
                         $sections[$k]['content'] = $fb->render($model, ['renderInAjax' => true]);
                     }
                     break;
             }
         }
     }
     return Yii::app()->controller->renderPartial($formpath . $layout, $sections, $return);
 }
Exemplo n.º 2
0
            // open list tag
            while ($categ = $result->fetch_object()) {
                // open list item
                $html .= '<li><a href="/web_php_cms/posts.php?categ_id=' . $categ->category_id . '">' . $categ->category_name . '</a>';
                // search if current item has children to append
                $html .= $this->getMenuTree($categ->category_id);
                // close LI
                $html .= '</li>';
            }
            $html .= '</ul>';
            // close list tag
        }
        return $html;
    }
}
$menu = new MenuTree();
echo $menu->getMenuTree();
exit;
//GET POST FIELD VALUES
$username_value = "admin";
$password_value = "test";
$sql = "SELECT user_id\n\t\t\t  FROM user\n\t\t\t WHERE username = ? \n\t\t\t   AND `password` = ?\n\t\t\t   AND active = 1 ";
$result = $db->select_prep($sql, array($username_value, $password_value));
print_r($result);
exit;
//CLEAN SPEACIAL CHARS BASED ON THE CURRENT DB's Charset
$username_clean = $db->escape($username_value);
$password_clean = $db->escape($password_value);
$sql = "SELECT user_id\n\t\t\t  FROM user\n\t\t\t WHERE username = '******' \n\t\t\t   AND `password` = '{$password_clean}'\n\t\t\t   AND active = 1 ";
$result = $db->select($sql);
print_r($result);
Exemplo n.º 3
0
<!DOCTYPE HTML>
<html lang="en-US" ng-app="main">
<?php 
include "_head.php";
?>
<body ng-controller="MainController">
<nav class="navbar navbar-fixed-top navbar-main" role="navigation">
    <div class="container-full">
        <div class="navbar-collapse collapse">
            <?php 
try {
    $menu = $this->mainMenu;
} catch (CdbException $e) {
    $menu = [];
}
MenuTree::formatMenuItems($menu);
$this->widget('zii.widgets.CMenu', array('encodeLabel' => false, 'id' => 'mainmenu', 'activateParents' => true, 'htmlOptions' => array('class' => 'nav navbar-nav'), 'submenuHtmlOptions' => array('class' => 'dropdown-menu', 'role' => 'nav'), 'itemCssClass' => 'dropdown-submenu', 'itemTemplate' => '{menu}', 'items' => $menu));
?>
        </div>
        <!-- ./navbar-collapse -->
    </div>
    <!-- /.container-full -->
</nav>
<?php 
//if (Setting::$mode == "running" && !Yii::app()->user->isGuest) {
//    include("_widget.php");
//}
?>
<div id="content" ng-cloak
     class="<?php 
echo Setting::$mode == "running" && Yii::app()->user->isGuest ? 'no-widget' : '';
Exemplo n.º 4
0
 public function actionSave($class, $timestamp)
 {
     FormField::$inEditor = true;
     $class = FormBuilder::classPath($class);
     $session = Yii::app()->session['FormBuilder_' . $class];
     $file = file(Yii::getPathOfAlias($class) . ".php", FILE_IGNORE_NEW_LINES);
     $changed = false;
     if ($timestamp != @$session['timestamp']) {
         $changed = true;
     }
     if (!$changed) {
         foreach ($file as $k => $f) {
             if (trim($file[$k]) != trim(@$session['file'][$k])) {
                 $changed = true;
             }
         }
     }
     if (!$changed) {
         $postdata = file_get_contents("php://input");
         $post = CJSON::decode($postdata);
         $session = Yii::app()->session['FormBuilder_' . $class];
         $fb = FormBuilder::load($class);
         if (isset($post['fields'])) {
             if (is_subclass_of($fb->model, 'FormField')) {
                 Yii::app()->cache->delete('toolbarData');
                 Yii::app()->cache->delete('toolbarHtml');
             }
             //save posted fields
             if (!$fb->setFields($post['fields'])) {
                 echo "FAILED: PERMISSION DENIED";
             }
         } else {
             if (isset($post['form'])) {
                 if (is_array($post['form']['layout']['data'])) {
                     ## save menutree to menutree file
                     foreach ($post['form']['layout']['data'] as $d) {
                         if (@$d['type'] == "menu" && !!@$d['file']) {
                             $menuOptions = MenuTree::getOptions($d['file']);
                             $menuOptions['layout'] = $d;
                             MenuTree::writeOptions($d['file'], $menuOptions);
                         }
                     }
                 }
                 //save posted form
                 if (!$fb->setForm($post['form'])) {
                     echo "FAILED: PERMISSION DENIED";
                 }
             }
         }
     } else {
         echo "FAILED";
     }
 }
Exemplo n.º 5
0
<?php

require_once '../includes/helpers.php';
require_once '../includes/MenuTree.php';
?>

<?php 
include '../includes/header.php';
?>

    <div class="row">
      <div id="categories_container" class="col-md-4 col-lg-4" 
        style="background-color: #fff; height: 400px;">
         <!-- sidebar post category list -->
        <?php 
$menuObject = new MenuTree();
echo $menuObject->getMenuTree(0);
?>
      </div>
      <div class="col-md-8 col-lg-8">
        <!-- posts loop -->
      </div>
    </div>

<?php 
include '../includes/footer.php';
?>

<script>
  
  $(document).ready(function () 
Exemplo n.º 6
0
 public function actionGetList($path)
 {
     $list = (include Yii::getPathOfAlias($path) . ".php");
     MenuTree::fillMenuItems($list);
     echo json_encode($list);
 }
Exemplo n.º 7
0
 public function actionTree()
 {
     $user = Users::model()->findByPk(user()->getId());
     $menu = new MenuTree($user->security_roles_id);
     $data = $menu->get_menu();
     //        $data = "[{text: 'Penjualan',
     //                  expanded: false,
     //                  children:[{
     //                  text: 'Faktur Penjualan',
     //                  id: 'jun.NotaGrid',
     //                  leaf: true
     //                  },
     //                  {
     //                  text: 'Sales dan Pelanggan',
     //                  expanded: false,
     //                  children:[{
     //                    text: 'Managemen Pelanggan',
     //                    id: 'jun.CustomersGrid',
     //                    leaf: true
     //                    }]
     //                  }]
     //                  },
     //                  {text: 'Pembelian',
     //                  expanded: false,
     //                  children:[{
     //                    text: 'Pembelian Kredit',
     //                    id: 'jun.NotaGrid',
     //                    leaf: true
     //                    },
     //                    {
     //                    text: 'Pembelian Tunai',
     //                    id: 'jun.NotaGrid',
     //                    leaf: true
     //                    },
     //                    {
     //                    text: 'Supplier',
     //                    expanded: false,
     //                    children:[{
     //                        text: 'Managemen Supplier',
     //                        id: 'jun.SuppliersGrid',
     //                        leaf: true
     //                        }]
     //                    }]
     //                  },
     //                  {text: 'Item',
     //                  expanded: false,
     //                  children:[{
     //                    text: 'Item',
     //                    id: 'jun.StockMasterGrid',
     //                    leaf: true
     //                    },
     //                    {
     //                    text: 'Satuan Item',
     //                    id: 'jun.ItemUnitsGrid',
     //                    leaf: true
     //                    },
     //                    {
     //                    text: 'Kategori Stok',
     //                    id: 'jun.StockCategoryGrid',
     //                    leaf: true
     //                    }]
     //                  },
     //                  {text: 'Kas/Bank',
     //                    expanded: false,
     //                    children:[{
     //                        text: 'Kas Keluar',
     //                        id: 'jun.NotaGrid',
     //                        leaf: true
     //                        },{
     //                        text: 'Kas Masuk',
     //                        id: 'jun.NotaGrid',
     //                        leaf: true
     //                        },{
     //                        text: 'Transfer Antar Bank',
     //                        id: 'jun.TranferBankWin',
     //                        leaf: true
     //                        },{
     //                        text: 'Penyesuain Bank',
     //                        id: 'jun.NotaGrid',
     //                        leaf: true
     //                        },{
     //                         text: 'Bank Statement',
     //                            id: 'jun.BankTransGrid',
     //                           leaf: true
     //                        },
     //                        {
     //                        text: 'Managemen',
     //                        expanded: false,
     //                        children:[{
     //                            text: 'Akun Bank',
     //                            id: 'jun.BankAccountsGrid',
     //                            leaf: true
     //                            }]
     //                        }]},
     //                  {
     //                    text:'Akuntansi',
     //                    expanded: false,
     //                    children:[{
     //                    text: 'Input Jurnal',
     //                    id: 'jun.TblUserGrid',
     //                    leaf: true
     //                    },{
     //                    text: 'GL Inquiry',
     //                    id: 'jun.GlTransGrid',
     //                    leaf: true
     //                    },{
     //                        text: 'Managemen',
     //                        expanded: false,
     //                        children:[{
     //                            text: 'Quick Entries',
     //                            id: 'jun.NotaGrid',
     //                            leaf: true
     //                            },{
     //                            text: 'Akun Rekening',
     //                            id: 'jun.ChartMasterGrid',
     //                            leaf: true
     //                            },{
     //                            text: 'Grup Akun Rekening',
     //                            id: 'jun.ChartTypesGrid',
     //                            leaf: true
     //                            },{
     //                            text: 'Kelas Akun Rekening',
     //                            id: 'jun.ChartClassGrid',
     //                            leaf: true
     //                            }]
     //                        }
     //                    ]},
     //                    {
     //                                text: 'Setting',
     //                                expanded: false,
     //                                children:[{
     //                                    text: 'Forms Setup',
     //                                    id: 'jun.SysTypesGrid',
     //                                    leaf: true
     //                                },{
     //                                    text: 'Profile',
     //                                    id: 'jun.KlasfikasiDetailManfaatGrid',
     //                                    leaf: true
     //                                },{
     //                                    text: 'Ubah Password',
     //                                    id: 'jun.KlasfikasiDetailManfaatGrid',
     //                                    leaf: true
     //                                },{
     //                                    text: 'Users',
     //                                    id: 'jun.UsersGrid',
     //                                    leaf: true
     //                                }]
     //
     //                            }]";
     Yii::app()->end($data);
 }
Exemplo n.º 8
0
 public static function fillMenuItems(&$list)
 {
     if (!is_array($list)) {
         $list = [];
     }
     $markCollapsed = 'collapsed';
     foreach ($list as $k => $v) {
         if (isset($v['url']) && is_string($v['url'])) {
             if ($v['url'] != '#' && substr($v['url'], 0, 4) != 'http') {
                 $list[$k]['formattedUrl'] = str_replace(["\n", "\r"], "", str_replace('?', '&', $v['url']));
                 $list[$k]['formattedUrl'] = Yii::app()->createUrl($list[$k]['url']);
                 if (isset(Yii::app()->request) && Yii::app()->request->requestUri == $list[$k]['formattedUrl']) {
                     $v['active'] = true;
                 }
             }
         }
         if (!isset($v['items'])) {
             $list[$k]['items'] = [];
         } else {
             $list[$k]['state'] = MenuTree::fillMenuItems($list[$k]['items']);
             $markCollapsed = $list[$k]['state'];
         }
         if (isset($v['active']) && $v['active']) {
             $markCollapsed = '';
         }
     }
     return $markCollapsed;
 }