1. <?php
  2. /*
  3. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
  4. *
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. *
  13. * Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the
  16. * distribution.
  17. *
  18. * Neither the name of Texas Instruments Incorporated nor the names of
  19. * its contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  28. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. */
  35.  
  36. # require() 语句包含并运行指定文件,和include()几乎完全一样,
  37. # 除了处理失败的方式不同之外
  38. require("helper_functions.php");
  39.  
  40. # 获取桌面json对象
  41. $var = read_desktop_file();
  42.  
  43. if($var==null)
  44. {
  45. echo "Json.txt file is empty or doesn't exist.";
  46. return;
  47. }
  48.  
  49. # 获取图标格点列数,行数
  50. $icon_per_col = $_COOKIE["iconGridCol"];
  51. $icon_per_row = $_COOKIE["iconGridRow"];
  52.  
  53. # 每一页一共有多少个图标
  54. $icons_per_page = $icon_per_col * $icon_per_row;
  55. # isset(): 检测变量是否设置
  56. # 如果page被作为请求参数设置了,那么取出页号,否则为0
  57. $current_page = isset($_GET["page"]) == true ? $_GET["page"] : ;
  58.  
  59. # 每一个单元格宽,高的所占对应的百分比
  60. $cell_height=/$icon_per_row;
  61. $cell_width=/$icon_per_col;
  62.  
  63. //Some parts of the code doesn't set the submenu variable when the user is at the Main Menu which is relected in the "top" variable
  64. # 如果请求参数里没有设置子菜单,那么就是主菜单
  65. # 查看了当前版本的json.txt文件,其中仅仅有main_menu内容,所以,在分析的时候
  66. # 可以不考虑submenu这个选项,想象力足够的话,也可以考虑在内
  67. $submenu = isset($_GET["submenu"]) == true ? $_GET["submenu"] : "main_menu" ;
  68.  
  69. //A value of -1 disables the next/previous page arrow
  70. # 本来就是第一月,到了最前面那一页,不能在往前了
  71. $previous_page = ($current_page != ) ? $current_page - : -;
  72. # 这里有待进一步的解析,因为var看上去像2维数组,这个要去解析前面的json对象
  73. # 这里count($var[$submenu]["apps"]))是统计json对象在"apps"这个阶层对象的个数
  74. $next_page = (($current_page+)*$icons_per_page < count($var[$submenu]["apps"])) ? $current_page + : -;
  75.  
  76. //Only enable exit link if your currently not in the main menu
  77. # 仅仅当你不在主页的时候才需要链接到主页
  78. $enable_main_menu_link = $submenu != "main_menu";
  79.  
  80. # 获取指定的子目录,主要是因为主界面下可能有很多子目录,可以通过这种方式进入子目录
  81. # 而且这种进入子目录的方式是采用在请求参数中指定
  82. $submenu_entry = get_submenu($var,$submenu);
  83.  
  84. # 设置菜单的标题
  85. # 由于解析的json.txt文件里面只有main_menu,没有其他的内容,
  86. # 所以我们只能看到:Aplex App Launcher v2 p+页码
  87. # 同时由于app很少,所以页码只能是1,因为current_page总是0
  88. $menu_title = ($submenu == "main_menu") ? "Aplex App Launcher v2 p".($current_page+) : $submenu_entry["Name"]." Submenu p".($current_page+);
  89.  
  90. # 起始索引,从当前页开始
  91. $start_index = $current_page * $icons_per_page;
  92. # 当前页最后的索引
  93. $end_index = $start_index + $icons_per_page - ;
  94.  
  95. # 有可能当前页是最后一页,并且最后一页没有占满,所以要修改正最后索引的下标
  96. if(count($var[$submenu]["apps"]) - < $end_index)
  97. $end_index = count($var[$submenu]["apps"]) - ;
  98. ?>
  99.  
  100. <!-- 动态设置css样式 -->
  101. <!-- 设置图标单元格的样式 -->
  102. <style type="text/css">
  103. .icons_cell
  104. {
  105. height:<?php echo $cell_height; ?>%; /* 设置图标单元格的高比例 */
  106. width:<?php echo $cell_width; ?>%; /* 设置图标单元格的宽比例 */
  107. }
  108. </style>
  109.  
  110. <!-- 自动生成菜单栏 -->
  111. <?php include "menubar.php"; ?>
  112.  
  113. <!-- 是用table生成Icon List(图标矩阵) -->
  114. <table id = "iconlist" >
  115.  
  116. <?php
  117. # x: 在这里代表的是行数
  118. # i: 在这里代表的是图标数组的起始索引的下标
  119. for($x = ,$i = $start_index;$x<$icon_per_row;$x++)
  120. {
  121. echo "<tr>";
  122. # y: 在这里代表的是列数
  123. for($y = ;$y<$icon_per_col;$y++,$i++)
  124. {
  125. # 单元格的相关设置
  126. echo "<td class = 'icons_cell' align = 'center' >";
  127.  
  128. if($i<=$end_index)
  129. {
  130. $current_app = $var[$submenu]["apps"][$i]; # 但前要显示的app
  131. $img_src = $current_app["Icon"]; # 获取当前app的图标
  132. $app_title = $current_app["Name"]; # 获取当前app的名字
  133. $type = strtolower($current_app["Type"]); # 获取当前app的类型
  134. $class = ""; # 当前app的css修饰
  135. $disable_link = false; # 超级链接
  136. # 如果当前的类型是目录
  137. if($type=="directory")
  138. {
  139. # 获取分类名字
  140. $category = $current_app["Category"];
  141. # 合成超级链接
  142. $link = "submenu.php?submenu=$category";
  143.  
  144. # 如果这个分类不存在
  145. if(isset($var[$category]["apps"]) == false)
  146. {
  147. # 采用这种超级链接,起内容主要是说,这个功能将来会被支持
  148. # 但目前还没有被支持
  149. $link = "coming_soon.php?submenu=$category";
  150. }
  151. }
  152. elseif($type=="application") # 应用程序
  153. {
  154. # 判断是否有超级链接描述
  155. # 就目前的json.txt中的Description_link值而言,都是-
  156. # 也就是说没有Description_link
  157. $has_description_page = $current_app["Description_Link"] != -;
  158.  
  159. //This check to see if the application doesn't have a description page. If it doesn't then directly launch the application"
  160. // 如果没有应用程序描述,那么直接运行程序,如果有程序描述,那么先运行描述文件,
  161. // 再通过描述文件来运行app程序
  162. if($has_description_page == false)
  163. {
  164. # urlencode(): 是指针对网页url中的中文字符的一种编码转换方式
  165. # 没有url描述,那就相当于直接运行程序
  166. $link = "run_script.php?&submenu=".urlencode($submenu)."&app=".urlencode($app_title);
  167.  
  168. //Determine if the application is GUI based. If it is then add a class to the link so the javascript code can
  169. //manipulate the link if it needs to
  170. if($var[$submenu]["apps"][$i]["ProgramType"]=="gui")
  171. $class = "class = 'is_gui_app'";
  172. }
  173. else
  174. $link = "app_description.php?submenu=".urlencode($submenu)."&app=".urlencode($app_title);
  175. }
  176.  
  177. # 合成超级连接
  178. echo "<a href = '$link' $class><img src= '$img_src' ></a>";
  179. # 合成对应的应用标题
  180. echo "<p>$app_title</p>";
  181. }
  182. echo "</td>";
  183. }
  184. echo "</tr>";
  185. }
  186.  
  187. echo "</table>";
  188. ?>
  189.  
  190. <!-- 总感觉这部分脚本跑完,前面没有描述内容的app都必须跑描述文件了 -->
  191. <!-- 从app_description文件内容可知,其实也没事,会提示没有描述内容而已 -->
  192. <script>
  193. //Don't launch GUI based application directly if the application is being launched remotely
  194. //or if the target doesn't have an attached graphic device
  195. if(client_is_host == false || has_graphics == false)
  196. {
  197. // 遍历所有的带有".is_gui_app"class
  198. $('.is_gui_app').each(function(index) {
  199. var link = $(this).attr("href"); // 获取超级链接
  200. var new_link = link.substr(link.indexOf("&submenu=")); // 获取参数
  201. new_link = "app_description.php?" + new_link; // 合成新的超级链接
  202. $(this).attr("href",new_link); // 重新设置超级链接
  203. });
  204. }
  205. </script>

Texas Instruments matrix-gui-2.0 hacking -- submenu.php的更多相关文章

  1. Texas Instruments matrix-gui-2.0 hacking -- app_description.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  2. Texas Instruments matrix-gui-2.0 hacking -- run_script.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  3. Texas Instruments matrix-gui-2.0 hacking -- index.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  4. Texas Instruments matrix-gui-2.0 hacking -- menubar.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  5. Texas Instruments matrix-gui-2.0 hacking -- generate.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  6. Texas Instruments matrix-gui-2.0 hacking -- execute_command.sh

    #!/bin/sh #Copyright (C) Texas Instruments Incorporated - http://www.ti.com/ # # # Redistribution an ...

  7. 【LeetCode每天一题】Set Matrix Zeroes(设置0矩阵)

    Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Exampl ...

  8. Texas Instruments matrix-gui-2.0 hacking -- helper_functions.php

    <?php # PHP_SELF: 但前正在执行脚本的文件名,与document root相关 # QUERY_STRING: 查询(query)的字符串 $cachefile = " ...

  9. Texas Instruments matrix-gui-2.0 hacking -- json.txt

    { "main_menu": { "apps": [ { "Name":"Profiling", ", &qu ...

随机推荐

  1. pyqt 调用颜色选择器

    # -*- coding: utf- -*- from PyQt5.QtWidgets import QApplication, QPushButton, QColorDialog , QWidget ...

  2. windows服务部署

    1.新建windows服务项目 2.编辑业务代码 我这里只写2句记录文本的测试代码 using System; using System.IO; using System.ServiceProcess ...

  3. 技术分享:SSH实战项目

    1.需求分析 系统概述: 企业人事管理系统. 要求对员工信息进行维护. 后台系统先登录,才能操作员工;添加.修改.删除. 没有登录,只能查看列表,不能操作. 功能分类: 1)[管理员模块] 注册/登录 ...

  4. spring boot 启动报错(spring-boot-devtools热部署后):The elements [spring.resources.cache-period] were left unbound. Update your application's configuration

    详细错误代码: *************************** APPLICATION FAILED TO START *************************** Descript ...

  5. English trip -- VC(情景课)5 Around Town

     Around Town  城市周围 Talk about the picture 看图说话 sentences Where are you? I'm in the Meten classroom. ...

  6. 3.6 MIPS指令简介

    计算机组成 3 指令系统体系结构 3.6 MIPS指令简介 MIPS秉承着指令数量少,指令功能简单的设计理念.那这样的设计理念是如何实现的呢?在这一节,我们就将来分析MIPS指令的特点. 相比于X86 ...

  7. Confluence 6 嵌套用户组的影响

    本部分说明了嵌套用户组对用户登录,权限和查看更新用户组的影响. 登录 如果用户属于一个授权的用户组或者授权用户组中的子用户组,当用户登录后,用户可以访问应用程序. 权限 如果用户属于的用户组或者用户组 ...

  8. splice的多种用法

    (一)splice的多种用法: splice(n,m) 从索引n开始删除m个.返回删除项组成新数组 splice(n) 从索引n开始删除到末尾 splice(n,m,x) 从索引n开始删除m个,并且把 ...

  9. Python中的魔术方法详解

    介绍 在Python中,所有以“__”双下划线包起来的方法,都统称为“Magic Method”,中文称『魔术方法』,例如类的初始化方法 __init__ ,Python中所有的魔术方法均在官方文档中 ...

  10. Python的第二次作业

    羊车门问题 1.我认为 会 增加选中汽车的机会,原因如下: 不换的情况:对于参赛者而言无论选哪一扇门都有1/3的几率能获得车子. 换的情况  :对于参赛者而言,有两种情况「1.参赛者第一次就选择到了正 ...