Example #1
0
 static function loadModules($position = "top", $type = "yii")
 {
     global $Yii_datamodule;
     if (!isset($Yii_datamodule)) {
         $Yii_datamodule = array();
     }
     if (isset($Yii_datamodule[$position])) {
         return implode("", $Yii_datamodule[$position]);
     }
     $Yii_datamodule[$position] = array();
     $menuID = Request::getVar('menuID', 1);
     $obj_module = YiiModule::getInstance();
     $items = $obj_module->loadItems(null, " a.position = '{$position}' AND a.status  >0 AND b.status >0");
     if (count($items)) {
         foreach ($items as $item) {
             $str_module = $obj_module->loadModule($item);
             if ($str_module != "") {
                 $type = ucfirst($type);
                 $fn = "modYii_{$type}";
                 if (function_exists($fn)) {
                     ob_start();
                     $fn($str_module, $item);
                     $str_module = ob_get_contents();
                     ob_end_clean();
                     $Yii_datamodule[$position][] = $str_module;
                 } else {
                     $Yii_datamodule[$position][] = $str_module;
                 }
             }
         }
     }
     return implode("", $Yii_datamodule[$position]);
 }
Example #2
0
 function getListEdit()
 {
     $moduleID = Request::getInt('id', "");
     $list = array();
     $obj_menu = YiiMenu::getInstance();
     $obj_module = YiiModule::getInstance();
     $items = $obj_menu->loadMenus();
     $items_xref = $obj_module->loadXrefMenu($moduleID);
     $str_html = '<select id="selection-menu" class="inputbox" multiple="multiple" size="15" name="selection-menu[]">';
     foreach ($items as $item) {
         $str_html .= '<optgroup label="' . $item['title'] . '">';
         $_items = $item["_items"];
         foreach ($_items as $_item) {
             $str = str_repeat("&nbsp; &nbsp; ", $_item['level'] - 1);
             if (in_array($_item['id'], $items_xref)) {
                 $str_html .= '<option value="' . $_item['id'] . '" selected ="">' . $str . $_item['title'] . '</option>';
             } else {
                 $str_html .= '<option value="' . $_item['id'] . '">' . $str . $_item['title'] . '</option>';
             }
         }
         $str_html .= '</optgroup>';
     }
     $str_html .= "</select>";
     $list['selection-menu'] = $str_html;
     return $list;
 }
Example #3
0
 function getListEdit($mainItem)
 {
     $moduleID = Request::getInt('cid', "");
     $lists = array();
     $obj_menu = YiiMenu::getInstance();
     $obj_module = YiiModule::getInstance();
     $items = $obj_menu->loadMenus();
     $items_xref = $obj_module->loadXrefMenu($moduleID);
     $attr = "";
     $meu_seletec = "selected";
     if ($mainItem->menu == "none") {
         $attr = 'disabled="disabled"';
     } else {
         if ($mainItem->menu == "all") {
             $attr = 'disabled="disabled"';
         }
     }
     $str_html = '<select id="selection-menu" class="inputbox" multiple="multiple" ' . $attr . ' size="15" name="selection-menu[]" style="min-width: 180px;">';
     foreach ($items as $item) {
         $str_html .= '<optgroup label="' . $item['title'] . '">';
         $_items = $item["_items"];
         foreach ($_items as $_item) {
             $str = str_repeat("&nbsp; &nbsp; ", $_item['level'] - 1);
             if ($mainItem->menu == "all") {
                 $str_html .= '<option value="' . $_item['id'] . '" selected ="">' . $str . $_item['title'] . '</option>';
             } else {
                 if ($mainItem->menu == "none") {
                     $str_html .= '<option value="' . $_item['id'] . '">' . $str . $_item['title'] . '</option>';
                 } else {
                     if (in_array($_item['id'], $items_xref)) {
                         $str_html .= '<option value="' . $_item['id'] . '" selected ="">' . $str . $_item['title'] . '</option>';
                     } else {
                         $str_html .= '<option value="' . $_item['id'] . '">' . $str . $_item['title'] . '</option>';
                     }
                 }
             }
         }
         $str_html .= '</optgroup>';
     }
     $str_html .= "</select>";
     $lists['selection-menu'] = $str_html;
     //                position
     $tbl_MP = YiiTables::getInstance(TBL_MODULE_POSITION);
     $items = $tbl_MP->loads("temp, position", null, " temp DESC");
     $str_html = '<div style="position: relative;">';
     $str_html .= '<select id="combobox-position" class="form-control" style="width: 180px; height: 25px;">' . "\r\n";
     $cur_temp = "";
     foreach ($items as $k => $item) {
         if ($cur_temp != $item['temp']) {
             if ($cur_temp != "") {
                 $str_html .= '</optgroup>' . "\r\n";
             }
             $str_html .= '<optgroup label="' . $item['temp'] . '">' . "\r\n";
             $cur_temp = $item['temp'];
         }
         if ($mainItem->position == $item['position']) {
             $str_html .= '<option value="' . $item['position'] . '" selected ="">' . $item['position'] . '</option>' . "\r\n";
         } else {
             $str_html .= '<option value="' . $item['position'] . '">' . $item['position'] . '</option>' . "\r\n";
         }
         if ($k == count($items) - 1) {
             $str_html .= '</optgroup>' . "\r\n";
         }
     }
     $str_html .= "</select>";
     $str_html .= '<input id="position" class="form-control" type="text" value="' . $mainItem->position . '" name="position" style="position: absolute; z-index: 1000; left: 0px; top: 0px; width: 162px; height: 25px; padding: 3px;">' . "\r\n";
     $str_html .= '</div>';
     $str_html .= '<script> $(window).ready(function($) {
                             $("#combobox-position").change(function(){
                                 var cur_pos = $("#combobox-position").val();
                                 $("#position").val(cur_pos);
                             });
                         });</script>';
     $lists['position'] = $str_html;
     $items = array();
     $items[] = array("value" => 0, "text" => "Unpublish");
     $items[] = array("value" => 1, "text" => "Publish");
     $items[] = array("value" => -1, "text" => "Hidden");
     $lists['status'] = buildHtml::select($items, $mainItem->status, "status");
     return $lists;
 }
Example #4
0
 function changeStatus($cid, $value)
 {
     global $mainframe, $user;
     if (!$user->isSuperAdmin()) {
         YiiMessage::raseNotice("Your account not have permission to modify module");
         $this->redirect(Router::buildLink("cpanel"));
     }
     $obj_module = YiiModule::getInstance();
     $obj_row = $obj_module->loadItem($cid);
     $obj_row->status = $value;
     $obj_row->store();
 }