Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - cyberxwolf

Pages: [1]
1
New Modules / Re: How to add custom built module to left menu?
« on: May 14, 2015, 04:49:30 AM »
Here is another easier way to add new menus.

create /usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php

Code: [Select]
<li>
<script type="text/javascript">
function add_custom_menu($icon_class,$menu_title,$sub_menu_items){
    $the_submenus = "";
    $.each($sub_menu_items,function(ind,itm){
    $the_submenus += "<li><a href='"+itm.link+"'><span class='icon16 icomoon-icon-arrow-right-3'></span>"+itm.link_title+"</a></li>";   
    });
    $(".mainnav > ul").append("<li><a href='#' onmousedown='javascript:return false;'><span class='icon16 "+$icon_class+"'></span>"+$menu_title+"<span class='hasDrop icon16 icomoon-icon-arrow-down-2'></span></a><ul class='sub'>"+$the_submenus+"</ul></li>");
}

//Add your menu items with the add_custom_menu function.

$(function(){
    add_custom_menu("icomoon-icon-hammer","MY NEW MENU 1",[{"link":"index.php?module=example","link_title":"TEST LINK 1"},{"link":"index.php?module=example","link_title":"TEST LINK 2"},{"link":"index.php?module=example","link_title":"TEST LINK 3"}]);
    add_custom_menu("icomoon-icon-hammer","MY NEW MENU 2",[{"link":"index.php?module=example","link_title":"TEST LINK 4"},{"link":"index.php?module=example","link_title":"TEST LINK 5"},{"link":"index.php?module=example","link_title":"TEST LINK 6"}]);

});
</script>
</li>

2
Here is another easier way to add new menus.

create /usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php

Code: [Select]
<li>
<script type="text/javascript">
function add_custom_menu($icon_class,$menu_title,$sub_menu_items){
    $the_submenus = "";
    $.each($sub_menu_items,function(ind,itm){
    $the_submenus += "<li><a href='"+itm.link+"'><span class='icon16 icomoon-icon-arrow-right-3'></span>"+itm.link_title+"</a></li>";   
    });
    $(".mainnav > ul").append("<li><a href='#' onmousedown='javascript:return false;'><span class='icon16 "+$icon_class+"'></span>"+$menu_title+"<span class='hasDrop icon16 icomoon-icon-arrow-down-2'></span></a><ul class='sub'>"+$the_submenus+"</ul></li>");
}

//Add your menu items with the add_custom_menu function.

$(function(){
    add_custom_menu("icomoon-icon-hammer","MY NEW MENU 1",[{"link":"index.php?module=example","link_title":"TEST LINK 1"},{"link":"index.php?module=example","link_title":"TEST LINK 2"},{"link":"index.php?module=example","link_title":"TEST LINK 3"}]);
    add_custom_menu("icomoon-icon-hammer","MY NEW MENU 2",[{"link":"index.php?module=example","link_title":"TEST LINK 4"},{"link":"index.php?module=example","link_title":"TEST LINK 5"},{"link":"index.php?module=example","link_title":"TEST LINK 6"}]);

});
</script>
</li>

3
Simple solution to adding custom built menu's to CWP 0.9.8.6 without needing to use the developer menu

Step #1 - Build your module, and add it to module directory for the admin panel.

ifconfig.php:
Code: [Select]
<?php
if(!isset($include_path)){
    echo(
"invalid access");
}else{
    
$ifconfig shell_exec("ifconfig");
    echo(
"<h3>IFCONFIG</h3><pre>".$ifconfig."</pre>");
}
?>

save your module into the admin modules directory.
/usr/local/cwpsrv/htdocs/resources/admin/modules/ifconfig.php

Step #2 - create a file named 3rdparty.php in /usr/local/cwpsrv/htdocs/resources/admin/include

The default way this file works is meant to let users add modules to the submenu Developer Menu.

The file expects modules to be added as list items like the following:
Code: [Select]
<li><a href="index.php?module=ifconfig"><span class="icon16 icomoon-icon-arrow-right-3"></span>Network Interface</a></li>
However with some minor changes we can create our own menu to use instead of the Developer Menu.

3rdparty.php:
Code: [Select]
<?php
/* File: /usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php */
?>

</ul></li> <!-- This line closes the opened submenu tag and menu item for the Developer menu -->

<li class="custom-menu"> <!-- this class "custom-menu" was added so you can remove the Developer Menu easily if you want -->
    <a class="hasUl" href="#"><span class="icon16 icomoon-icon-hammer"></span>MY CUSTOM MENU<span class="hasDrop icon16 icomoon-icon-arrow-down-2"></span></a>
    <ul class="sub">
        <li><a href="index.php?module=ifconfig"><span class="icon16 icomoon-icon-arrow-right-3"></span>Network Interface</a></li>
    </ul>
</li>

<li style="display:none;"><ul> <!-- This line opens a new menu item and submenu that's hidden because CWP will add closing ul and li tags to the end of this file -->
<?php
/* End 3rdparty.php */
?>

Now we have added a new menu with the title "MY CUSTOM MENU" and have added the ifconfig module we built to it.

If you want to add more menus then you simply create another menu block in 3rdparty.php like so:
3rdparty.php:
Code: [Select]
<?php
/* File: /usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php */
?>

</ul></li> <!-- This line closes the opened submenu tag and menu item for the Developer menu -->

<li class="custom-menu"> <!-- this class "custom-menu" was added so you can remove the Developer Menu easily if you want -->
    <a class="hasUl" href="#"><span class="icon16 icomoon-icon-hammer"></span>MY CUSTOM MENU<span class="hasDrop icon16 icomoon-icon-arrow-down-2"></span></a>
    <ul class="sub">
        <li><a href="index.php?module=ifconfig"><span class="icon16 icomoon-icon-arrow-right-3"></span>Network Interface</a></li>
    </ul>
</li>

<li>
    <a class="hasUl" href="#"><span class="icon16 icomoon-icon-hammer"></span>IM ANOTHER MENU<span class="hasDrop icon16 icomoon-icon-arrow-down-2"></span></a>
    <ul class="sub">
        <li><a href="index.php?module=ifconfig"><span class="icon16 icomoon-icon-arrow-right-3"></span>Network Interface</a></li>
    </ul>
</li>

<li style="display:none;"><ul> <!-- This line opens a new menu item and submenu that's hidden because CWP will add closing ul and li tags to the end of this file -->
<?php
/* End 3rdparty.php */
?>

And now there is a second new menu titled "IM ANOTHER MENU" now you can organize your modules better.
But I will write a proper module to handle menu modification to handle the menu from the UI.

If you would like to hide the Developer Menu because you aren't using it like me then you may hide it with a little jquery.
You can add this script to the end of the /usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php
Code: [Select]
<script type='text/javascript'>$(document).ready(function(){$(".custom-menu").prev("LI").css("display","none");});</script>
That's all for now I hope you enjoyed this and can make use of it.
I have just begun to play with CentOS WebPanel but I have so many ideas of how to add some really cool stuff. it's just too bad a lot of the code is obfuscated because I would love to help build some of this stuff.

4
New Modules / Re: How to add custom built module to left menu?
« on: May 13, 2015, 06:46:38 PM »
Simple solution to adding custom built menu's to CWP 0.9.8.6 without needing to use the developer menu

Step #1 - Build your module, and add it to module directory for the admin panel.

ifconfig.php:
Code: [Select]
<?php
if(!isset($include_path)){
    echo(
"invalid access");
}else{
    
$ifconfig shell_exec("ifconfig");
    echo(
"<h3>IFCONFIG</h3><pre>".$ifconfig."</pre>");
}
?>

save your module into the admin modules directory.
/usr/local/cwpsrv/htdocs/resources/admin/modules/ifconfig.php

Step #2 - create a file named 3rdparty.php in /usr/local/cwpsrv/htdocs/resources/admin/include

The default way this file works is meant to let users add modules to the submenu Developer Menu.

The file expects modules to be added as list items like the following:
Code: [Select]
<li><a href="index.php?module=ifconfig"><span class="icon16 icomoon-icon-arrow-right-3"></span>Network Interface</a></li>
However with some minor changes we can create our own menu to use instead of the Developer Menu.

3rdparty.php:
Code: [Select]
<?php
/* File: /usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php */
?>

</ul></li> <!-- This line closes the opened submenu tag and menu item for the Developer menu -->

<li class="custom-menu"> <!-- this class "custom-menu" was added so you can remove the Developer Menu easily if you want -->
    <a class="hasUl" href="#"><span class="icon16 icomoon-icon-hammer"></span>MY CUSTOM MENU<span class="hasDrop icon16 icomoon-icon-arrow-down-2"></span></a>
    <ul class="sub">
        <li><a href="index.php?module=ifconfig"><span class="icon16 icomoon-icon-arrow-right-3"></span>Network Interface</a></li>
    </ul>
</li>

<li style="display:none;"><ul> <!-- This line opens a new menu item and submenu that's hidden because CWP will add closing ul and li tags to the end of this file -->
<?php
/* End 3rdparty.php */
?>

Now we have added a new menu with the title "MY CUSTOM MENU" and have added the ifconfig module we built to it.

If you want to add more menus then you simply create another menu block in 3rdparty.php like so:
3rdparty.php:
Code: [Select]
<?php
/* File: /usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php */
?>

</ul></li> <!-- This line closes the opened submenu tag and menu item for the Developer menu -->

<li class="custom-menu"> <!-- this class "custom-menu" was added so you can remove the Developer Menu easily if you want -->
    <a class="hasUl" href="#"><span class="icon16 icomoon-icon-hammer"></span>MY CUSTOM MENU<span class="hasDrop icon16 icomoon-icon-arrow-down-2"></span></a>
    <ul class="sub">
        <li><a href="index.php?module=ifconfig"><span class="icon16 icomoon-icon-arrow-right-3"></span>Network Interface</a></li>
    </ul>
</li>

<li>
    <a class="hasUl" href="#"><span class="icon16 icomoon-icon-hammer"></span>IM ANOTHER MENU<span class="hasDrop icon16 icomoon-icon-arrow-down-2"></span></a>
    <ul class="sub">
        <li><a href="index.php?module=ifconfig"><span class="icon16 icomoon-icon-arrow-right-3"></span>Network Interface</a></li>
    </ul>
</li>

<li style="display:none;"><ul> <!-- This line opens a new menu item and submenu that's hidden because CWP will add closing ul and li tags to the end of this file -->
<?php
/* End 3rdparty.php */
?>

And now there is a second new menu titled "IM ANOTHER MENU" now you can organize your modules better.
But I will write a proper module to handle menu modification to handle the menu from the UI.

If you would like to hide the Developer Menu because you aren't using it like me then you may hide it with a little jquery.
You can add this script to the end of the /usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php
Code: [Select]
<script type='text/javascript'>$(document).ready(function(){$(".custom-menu").prev("LI").css("display","none");});</script>
That's all for now I hope you enjoyed this and can make use of it.
I have just begun to play with CentOS WebPanel but I have so many ideas of how to add some really cool stuff. it's just too bad a lot of the code is obfuscated because I would love to help build some of this stuff.

Pages: [1]