[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11237] test ajax menu
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11237] test ajax menu |
Date: |
Fri, 05 Jul 2013 13:49:51 +0000 |
Revision: 11237
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11237
Author: sigurdne
Date: 2013-07-05 13:49:50 +0000 (Fri, 05 Jul 2013)
Log Message:
-----------
test ajax menu
Modified Paths:
--------------
trunk/index.php
trunk/phpgwapi/inc/class.menu.inc.php
trunk/property/inc/class.soadmin_entity.inc.php
trunk/property/js/yahoo/test.menu.js
trunk/property/test_menu.php
Modified: trunk/index.php
===================================================================
--- trunk/index.php 2013-07-04 22:12:01 UTC (rev 11236)
+++ trunk/index.php 2013-07-05 13:49:50 UTC (rev 11237)
@@ -124,6 +124,11 @@
}
else
{
+ if(phpgw::get_var('phpgw_return_as', 'string', 'GET')
=='noframes')
+ {
+ $GLOBALS['phpgw_info']['flags']['noframework']
= true;
+
$GLOBALS['phpgw_info']['flags']['headonly']=true;
+ }
$GLOBALS[$class]->$method();
}
unset($app);
Modified: trunk/phpgwapi/inc/class.menu.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.menu.inc.php 2013-07-04 22:12:01 UTC (rev
11236)
+++ trunk/phpgwapi/inc/class.menu.inc.php 2013-07-05 13:49:50 UTC (rev
11237)
@@ -373,31 +373,105 @@
{
$node = phpgw::get_var('node');
- $selection = explode('::',$node);
-
+ $selection = explode('|',$node);
$app = $selection[0];
if(!isset($GLOBALS['phpgw_info']['user']['apps'][$app]))
{
return array();
}
+ $menu = array();
-// if(!$menu = phpgwapi_cache::session_get('phpgwapi',
"menu_{$node}"))
+ $_section = 'navigation';
+ if($app == 'admin')
{
+ if(!isset($selection[1]))
+ {
+
+ $navbar = $this->get('navbar');
+ $navigation = $this->get('admin');
+
+ foreach (
$GLOBALS['phpgw_info']['user']['apps'] as $_app => $app_info )
+ {
+ if(!in_array($_app,
array('logout', 'about', 'preferences')) && isset($navbar[$_app]))
+ {
+
if(isset($navigation[$_app]))
+ {
+ $menu[] = array
+ (
+ 'key'
=> $_app,
+
'is_leaf' => count($navigation[$_app]) > 1 ? false : true,
+ 'text'
=> $GLOBALS['phpgw']->translation->translate($_app, array(), true),
+ 'url'
=> $GLOBALS['phpgw']->link('/index.php',
+
array('menuaction' => 'admin.uiconfig.index', 'appname'
=> $_app))
+
+ );
+ }
+ }
+ }
+
+ return $menu;
+ }
+ else
+ {
+ $_section = 'admin';
+ $app = $selection[1];
+ array_shift($selection);
+ }
+ }
+
+
+ if(!$menu_gross =
phpgwapi_cache::session_get('phpgwapi', "menu_{$app}"))
+ {
$menu_gross =
execMethod("{$app}.menu.get_menu");
- $selection =
explode('::',$GLOBALS['phpgw_info']['flags']['menu_selection']);
- $level=0;
- $menu =
self::_get_sub_menu($menu_gross['navigation'],$selection,$level);
- phpgwapi_cache::session_set('phpgwapi',
"menu_{$node}",$menu);
- unset($menu_gross);
+ phpgwapi_cache::session_set('phpgwapi',
"menu_{$app}",$menu_gross);
}
-_debug_array($menu);
+ $menu_gross = $menu_gross[$_section];
+
+ $count_selection = count($selection);
+ if($count_selection > 1)
+ {
+ for ($i=1;$i<count($selection);$i++)
+ {
+ if(isset($menu_gross[$selection[$i]]))
+ {
+ $menu_gross =
$menu_gross[$selection[$i]];
+ }
+ else if
(isset($menu_gross['children'][$selection[$i]]))
+ {
+ $menu_gross =
$menu_gross['children'][$selection[$i]];
+ }
+ else
+ {
+ $menu_gross = array();
+ }
+ }
+ $children = isset($menu_gross['children']) ?
$menu_gross['children'] : array();
+ }
+ else
+ {
+ $children = $menu_gross;
+ }
+
+ $i=0;
+ foreach($children as $key => $vals)
+ {
+ $vals['url'] = str_replace('&','&',
$vals['url']);
+ $menu[$i] = $vals;
+ $menu[$i]['key'] = $key;
+ $menu[$i]['is_leaf'] = true;
+ if(isset($menu[$i]['children']))
+ {
+ $menu[$i]['is_leaf'] = false;
+ unset($menu[$i]['children']);
+ }
+ $i++;
+ }
+
return $menu;
}
-
-
protected static function _get_sub_menu($children = array(),
$selection=array(),$level=0)
{
$level++;
@@ -405,20 +479,24 @@
$menu = array();
foreach($children as $key => $vals)
{
- $menu[] = $vals;
+ $menu[$i] = $vals;
$menu[$i]['this'] = false;
+ $menu[$i]['key'] = $key;
+ $menu[$i]['is_leaf'] = true;
if($key == $selection[$level])
{
$menu[$i]['this'] = true;
if(isset($menu[$i]['children']))
{
$menu[$i]['children'] =
self::_get_sub_menu($menu[$i]['children'],$selection,$level);
+ $menu[$i]['is_leaf'] = false;
}
}
else
{
if(isset($menu[$i]['children']))
{
+ $menu[$i]['is_leaf'] = false;
unset($menu[$i]['children']);
}
}
Modified: trunk/property/inc/class.soadmin_entity.inc.php
===================================================================
--- trunk/property/inc/class.soadmin_entity.inc.php 2013-07-04 22:12:01 UTC
(rev 11236)
+++ trunk/property/inc/class.soadmin_entity.inc.php 2013-07-05 13:49:50 UTC
(rev 11237)
@@ -256,11 +256,11 @@
foreach($categories as $category)
{
- $this->category_tree[] = array
- (
- 'id' => $category['id'],
- 'name' => $category['name']
- );
+ $this->category_tree[$category['id']] = array
+ (
+ 'id' => $category['id'],
+ 'name' => $category['name']
+ );
$this->get_children2($entity_id,
$category['id'], 1);
}
return $this->category_tree;
Modified: trunk/property/js/yahoo/test.menu.js
===================================================================
--- trunk/property/js/yahoo/test.menu.js 2013-07-04 22:12:01 UTC (rev
11236)
+++ trunk/property/js/yahoo/test.menu.js 2013-07-05 13:49:50 UTC (rev
11237)
@@ -1,126 +1,158 @@
+
+function get_html (sUrl)
+{
+ document.getElementById('html_content').src = sUrl;
+
+ var callback_2 = {
+ success: function(oResponse)
+ {
+ var oResults = oResponse.responseText;
+
document.getElementById("html_content").innerHTML = oResults;
+ },
+
+ failure: function(oResponse) {
+ },
+ };
+
+ YAHOO.util.Connect.asyncRequest('GET', sUrl, callback_2);
+
+}
+
+
//an anonymous function wraps our code to keep our variables
//in function scope rather than in the global namespace:
(function() {
- var tree;
+ var tree;
- function loadNodeData(node, fnLoadComplete) {
- //We'll load node data based on what we get back when we
- //use Connection Manager topass the text label of the
- //expanding node to the Yahoo!
- //Music track search API. Here, we're at the
- //first part of the request -- we'll make the request to the
- //server. In our success handler, we'll build our new children
- //and then return fnLoadComplete back to the tree.
- //Get the node's label and urlencode it; this is the word/s
- //on which we'll search for related words:
- //var nodeLabelElId = encodeURI(node.labelElId);
-
- var mapping_str = node.labelElId
- mapping_id = mapping_str.replace('ygtvlabelel','');
- var app = mapping[mapping_id];
- //prepare URL for XHR request:
+ function loadNodeData(node, fnLoadComplete) {
+ //We'll load node data based on what we get back when we
+ //use Connection Manager topass the text label of the
+ //expanding node to the Yahoo!
+ //Music track search API. Here, we're at the
+ //first part of the request -- we'll make the request to the
+ //server. In our success handler, we'll build our new children
+ //and then return fnLoadComplete back to the tree.
+
+ //Get the node's label and urlencode it; this is the word/s
+ //on which we'll search for related words:
+ //var nodeLabelElId = encodeURI(node.labelElId);
+
+ var mapping_str = node.labelElId
+ mapping_id = mapping_str.replace('ygtvlabelel','');
+ var app = mapping[mapping_id];
+
+ //prepare URL for XHR request:
var oArgs =
{menuaction:'phpgwapi.menu.get_local_menu_ajax',node:app};
var sUrl = phpGWLink('index.php', oArgs, true);
- // var sUrl = "assets/ysuggest_proxy.php?query=" + nodeLabelElId;
+ //prepare our callback object
+ var callback = {
- //prepare our callback object
- var callback = {
+ //if our XHR call is successful, we want to make use
+ //of the returned data and create child nodes.
+ success: function(oResponse) {
+ // YAHOO.log("XHR transaction was successful.",
"info", "example");
- //if our XHR call is successful, we want to make use
- //of the returned data and create child nodes.
- success: function(oResponse) {
- YAHOO.log("XHR transaction was successful.", "info",
"example");
- //YAHOO.log(oResponse.responseText);
- var oResults = eval("(" + oResponse.responseText + ")");
- // var oResults = oResponse.responseText;
- console.log(oResults);
- var title, url, titles, tempNode;
+ var oResults = eval("(" +
oResponse.responseText + ")");
- if (YAHOO.lang.isArray(oResults)) {
+ var title, url, titles, tempNode;
- titles = {};
- for (var i = 0, len = oResults.length; i < len; i++) {
- title = oResults[i].text;
- url = oResults[i].url;
+ if (YAHOO.lang.isArray(oResults)) {
- // prevent duplicate track titles by creating a hash
of titles
- if (!titles[title]) {
- titles[title] = true;
- tempNode = new YAHOO.widget.TextNode(title, node,
false);
+ titles = {};
+ for (var i = 0, len = oResults.length;
i < len; i++) {
+ title = oResults[i].text;
+ key = oResults[i].key;
+ url = oResults[i].url;
+ is_leaf = !!oResults[i].is_leaf;
+ // prevent duplicate track
titles by creating a hash of titles
+ if (!titles[title]) {
+ titles[title] = true;
- // we can tell the tree node that this is a leaf
node so
- // that it doesn't try to dynamically load
children.
- // tempNode.isLeaf = true;
+ var myobj = {label:
title, href:url}//,target:"_self" };
+ //tempNode = new
YAHOO.widget.TextNode(title, node, false);
+ tempNode = new
YAHOO.widget.TextNode( myobj, node, false);
- // Define a href so that a click on the node will
navigate
- // to the page that has the track that you may be
able
- // to listen to.
- tempNode.href = url;
- }
- }
- }
+ var mapping_str =
tempNode.labelElId
+ mapping_id =
mapping_str.replace('ygtvlabelel','');
+ mapping[mapping_id] =
app + '|' + key;
- //When we're done creating child nodes, we execute the node's
- //loadComplete callback method which comes in via the argument
- //in the response object (we could also access it at
node.loadComplete,
- //if necessary):
- oResponse.argument.fnLoadComplete();
- },
+ // we can tell the tree
node that this is a leaf node so
+ // that it doesn't try
to dynamically load children.
- //if our XHR call is not successful, we want to
- //fire the TreeView callback and let the Tree
- //proceed with its business.
- failure: function(oResponse) {
- YAHOO.log("Failed to process XHR transaction.", "info",
"example");
- oResponse.argument.fnLoadComplete();
- },
+
+ tempNode.isLeaf =
is_leaf;
- //our handlers for the XHR response will need the same
- //argument information we got to loadNodeData, so
- //we'll pass those along:
- argument: {
- "node": node,
- "fnLoadComplete": fnLoadComplete
- },
+ // Define a href so
that a click on the node will navigate
+ // to the page that has
the track that you may be able
+ // to listen to.
+ tempNode.href = url;
+ }
+ }
+ }
- //timeout -- if more than 7 seconds go by, we'll abort
- //the transaction and assume there are no children:
- timeout: 7000
- };
+ //When we're done creating child nodes, we
execute the node's
+ //loadComplete callback method which comes in
via the argument
+ //in the response object (we could also access
it at node.loadComplete,
+ //if necessary):
+ oResponse.argument.fnLoadComplete();
+ },
- //With our callback object ready, it's now time to
- //make our XHR call using Connection Manager's
- //asyncRequest method:
- YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
- }
+ //if our XHR call is not successful, we want to
+ //fire the TreeView callback and let the Tree
+ //proceed with its business.
+ failure: function(oResponse) {
+ YAHOO.log("Failed to process XHR transaction.",
"info", "example");
+ oResponse.argument.fnLoadComplete();
+ },
- function init() {
- //create a new tree:
- tree = new YAHOO.widget.TreeView("treeDiv1");
+ //our handlers for the XHR response will need the same
+ //argument information we got to loadNodeData, so
+ //we'll pass those along:
+ argument: {
+ "node": node,
+ "fnLoadComplete": fnLoadComplete
+ },
- //turn dynamic loading on for entire tree:
- tree.setDynamicLoad(loadNodeData);
+ //timeout -- if more than 7 seconds go by, we'll abort
+ //the transaction and assume there are no children:
+ timeout: 7000
+ };
- //get root node for tree:
- var root = tree.getRoot();
+ //With our callback object ready, it's now time to
+ //make our XHR call using Connection Manager's
+ //asyncRequest method:
+ YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
+ }
- //add child nodes for tree; our top level nodes are apps - defined in
html
+ function init() {
+ //create a new tree:
+ tree = new YAHOO.widget.TreeView("treeDiv1");
- for (var i=0, j=apps.length; i<j; i++) {
- var myobj = { label:
apps[i]['text'],labelElId:apps[i]['labelElId'],
href:apps[i]['href']}//,target:"_self" };
- var tempNode = new YAHOO.widget.TextNode(myobj, root, false);
- }
+ //turn dynamic loading on for entire tree:
+ tree.setDynamicLoad(loadNodeData);
- //render tree with these toplevel nodes; all descendants of these nodes
- //will be generated as needed by the dynamic loader.
- tree.draw();
- }
+ //get root node for tree:
+ var root = tree.getRoot();
- //once the DOM has loaded, we can go ahead and set up our tree:
- YAHOO.util.Event.onDOMReady(init);
+ //add child nodes for tree; our top level nodes are apps - defined
in html
-
+ for (var i=0, j=apps.length; i<j; i++) {
+ // var myobj = { label: apps[i]['text'],
href:apps[i]['href']}//,target:"_self" };
+ var myobj = { label: apps[i]['text'],
href:'javascript:get_html("' + apps[i]['href'] + '");'}//,target:"_self" };
+
+ var tempNode = new YAHOO.widget.TextNode(myobj,
root, false);
+ }
+
+ //render tree with these toplevel nodes; all descendants of these
nodes
+ //will be generated as needed by the dynamic loader.
+ tree.draw();
+ }
+
+ //once the DOM has loaded, we can go ahead and set up our tree:
+ YAHOO.util.Event.onDOMReady(init);
+
+
})();
Modified: trunk/property/test_menu.php
===================================================================
--- trunk/property/test_menu.php 2013-07-04 22:12:01 UTC (rev 11236)
+++ trunk/property/test_menu.php 2013-07-05 13:49:50 UTC (rev 11237)
@@ -42,8 +42,9 @@
$applications[] = array
(
'text' => $app_data['text'],
- 'href' => $app_data['url'],
+ 'href' => str_replace('&','&',
$app_data['url']) . '&phpgw_return_as=noframes',
);
+
$mapping[$i] = $app;
$i ++;
}
@@ -51,18 +52,13 @@
$mapping = json_encode($mapping);
$html = <<<HTML
- <div
id="treeDiv1"></div>
- <!-- Some style
for the expand/contract section-->
- <style>
-
#expandcontractdiv {border:1px dotted #dedede; margin:0 0 .5em 0;
padding:0.4em;}
-
#treeDiv1 { background: #fff; padding:1em; margin-top:1em; }
- </style>
- <script
type="text/javascript">
- var apps =
{$applications};
- var mapping
= {$mapping};
- </script>
- <div
id="treeDiv1"/>
-
+ <div id="treeDiv1"></div>
+ <!--div id="html_content"></div-->
+ <iframe id="html_content" width="100%" height="100%"><p>Your
browser does not support iframes.</p></iframe>
+ <script type="text/javascript">
+ var apps = {$applications};
+ var mapping = {$mapping};
+ </script>
HTML;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11237] test ajax menu,
Sigurd Nes <=