<?php
/*
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/ # require() 语句包含并运行指定文件,和include()几乎完全一样,
# 除了处理失败的方式不同之外
require("helper_functions.php"); # 获取桌面json对象
$var = read_desktop_file(); if($var==null)
{
echo "Json.txt file is empty or doesn't exist.";
return;
} # 获取图标格点列数,行数
$icon_per_col = $_COOKIE["iconGridCol"];
$icon_per_row = $_COOKIE["iconGridRow"]; # 每一页一共有多少个图标
$icons_per_page = $icon_per_col * $icon_per_row;
# isset(): 检测变量是否设置
# 如果page被作为请求参数设置了,那么取出页号,否则为0
$current_page = isset($_GET["page"]) == true ? $_GET["page"] : ; # 每一个单元格宽,高的所占对应的百分比
$cell_height=/$icon_per_row;
$cell_width=/$icon_per_col; //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
# 如果请求参数里没有设置子菜单,那么就是主菜单
# 查看了当前版本的json.txt文件,其中仅仅有main_menu内容,所以,在分析的时候
# 可以不考虑submenu这个选项,想象力足够的话,也可以考虑在内
$submenu = isset($_GET["submenu"]) == true ? $_GET["submenu"] : "main_menu" ; //A value of -1 disables the next/previous page arrow
# 本来就是第一月,到了最前面那一页,不能在往前了
$previous_page = ($current_page != ) ? $current_page - : -;
# 这里有待进一步的解析,因为var看上去像2维数组,这个要去解析前面的json对象
# 这里count($var[$submenu]["apps"]))是统计json对象在"apps"这个阶层对象的个数
$next_page = (($current_page+)*$icons_per_page < count($var[$submenu]["apps"])) ? $current_page + : -; //Only enable exit link if your currently not in the main menu
# 仅仅当你不在主页的时候才需要链接到主页
$enable_main_menu_link = $submenu != "main_menu"; # 获取指定的子目录,主要是因为主界面下可能有很多子目录,可以通过这种方式进入子目录
# 而且这种进入子目录的方式是采用在请求参数中指定
$submenu_entry = get_submenu($var,$submenu); # 设置菜单的标题
# 由于解析的json.txt文件里面只有main_menu,没有其他的内容,
# 所以我们只能看到:Aplex App Launcher v2 p+页码
# 同时由于app很少,所以页码只能是1,因为current_page总是0
$menu_title = ($submenu == "main_menu") ? "Aplex App Launcher v2 p".($current_page+) : $submenu_entry["Name"]." Submenu p".($current_page+); # 起始索引,从当前页开始
$start_index = $current_page * $icons_per_page;
# 当前页最后的索引
$end_index = $start_index + $icons_per_page - ; # 有可能当前页是最后一页,并且最后一页没有占满,所以要修改正最后索引的下标
if(count($var[$submenu]["apps"]) - < $end_index)
$end_index = count($var[$submenu]["apps"]) - ;
?> <!-- 动态设置css样式 -->
<!-- 设置图标单元格的样式 -->
<style type="text/css">
.icons_cell
{
height:<?php echo $cell_height; ?>%; /* 设置图标单元格的高比例 */
width:<?php echo $cell_width; ?>%; /* 设置图标单元格的宽比例 */
}
</style> <!-- 自动生成菜单栏 -->
<?php include "menubar.php"; ?> <!-- 是用table生成Icon List(图标矩阵) -->
<table id = "iconlist" > <?php
# x: 在这里代表的是行数
# i: 在这里代表的是图标数组的起始索引的下标
for($x = ,$i = $start_index;$x<$icon_per_row;$x++)
{
echo "<tr>";
# y: 在这里代表的是列数
for($y = ;$y<$icon_per_col;$y++,$i++)
{
# 单元格的相关设置
echo "<td class = 'icons_cell' align = 'center' >"; if($i<=$end_index)
{
$current_app = $var[$submenu]["apps"][$i]; # 但前要显示的app
$img_src = $current_app["Icon"]; # 获取当前app的图标
$app_title = $current_app["Name"]; # 获取当前app的名字
$type = strtolower($current_app["Type"]); # 获取当前app的类型
$class = ""; # 当前app的css修饰
$disable_link = false; # 超级链接
# 如果当前的类型是目录
if($type=="directory")
{
# 获取分类名字
$category = $current_app["Category"];
# 合成超级链接
$link = "submenu.php?submenu=$category"; # 如果这个分类不存在
if(isset($var[$category]["apps"]) == false)
{
# 采用这种超级链接,起内容主要是说,这个功能将来会被支持
# 但目前还没有被支持
$link = "coming_soon.php?submenu=$category";
}
}
elseif($type=="application") # 应用程序
{
# 判断是否有超级链接描述
# 就目前的json.txt中的Description_link值而言,都是-
# 也就是说没有Description_link
$has_description_page = $current_app["Description_Link"] != -; //This check to see if the application doesn't have a description page. If it doesn't then directly launch the application"
// 如果没有应用程序描述,那么直接运行程序,如果有程序描述,那么先运行描述文件,
// 再通过描述文件来运行app程序
if($has_description_page == false)
{
# urlencode(): 是指针对网页url中的中文字符的一种编码转换方式
# 没有url描述,那就相当于直接运行程序
$link = "run_script.php?&submenu=".urlencode($submenu)."&app=".urlencode($app_title); //Determine if the application is GUI based. If it is then add a class to the link so the javascript code can
//manipulate the link if it needs to
if($var[$submenu]["apps"][$i]["ProgramType"]=="gui")
$class = "class = 'is_gui_app'";
}
else
$link = "app_description.php?submenu=".urlencode($submenu)."&app=".urlencode($app_title);
} # 合成超级连接
echo "<a href = '$link' $class><img src= '$img_src' ></a>";
# 合成对应的应用标题
echo "<p>$app_title</p>";
}
echo "</td>";
}
echo "</tr>";
} echo "</table>";
?> <!-- 总感觉这部分脚本跑完,前面没有描述内容的app都必须跑描述文件了 -->
<!-- 从app_description文件内容可知,其实也没事,会提示没有描述内容而已 -->
<script>
//Don't launch GUI based application directly if the application is being launched remotely
//or if the target doesn't have an attached graphic device
if(client_is_host == false || has_graphics == false)
{
// 遍历所有的带有".is_gui_app"class
$('.is_gui_app').each(function(index) {
var link = $(this).attr("href"); // 获取超级链接
var new_link = link.substr(link.indexOf("&submenu=")); // 获取参数
new_link = "app_description.php?" + new_link; // 合成新的超级链接
$(this).attr("href",new_link); // 重新设置超级链接
});
}
</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. 适用于目前环境的bug记录

    问测试,bugtracker.JIRA,你们用起来啊? 难道bugtracker/JIRA只有测试用吗? 截屏忽略,只有测试人员自己提bug,开发不管不顾,解决了也不关闭bug,bug提得太多,还嫌测 ...

  2. testNG 学习笔记 Day 3 常用的断言

    TestNG中最常用的一个断言类是Assert.java,里面有多个静态方法,这个类我们习惯叫硬断言.对应的还有一个软断言的类,叫SoftAssert.java,这个类是需要创建实例对象,才能调用相关 ...

  3. MongoDB(课时27 消除重复数据)

    3.7.2 消除重复数据 在SQL中对于重复的数据可以使用"DISTINCT"消除,在MongoDB中依然支持.(distinct不同的) 范例:查询所有name的信息 本次的操作 ...

  4. Android开机广播和关机广播

    有些时候我们需要我们的程序在系统开机后能自动运行,这个时候我们可以使用Android中的广播机制,编写一个继承BroadcastReceiver的类,接受系统启动关闭广播.代码如下: /** *@au ...

  5. python数据持久存储-pickle模块

    pickle模块实现了基本的数据序列和反序列化.pickle模块的序列化操作我们能够将程序中运行的对象信息保存到文件中去,通过pickle模块的反序列化操作,能够从文件中创建上一次程序保存的对象. 接 ...

  6. Ubuntu 14.04 的 VNC Server

    首先,如果是Desktop 版本的 Ubuntu,不需要另外安装vnc server. 网上也不知怎么搞的,一堆奇怪的方法,要安装TightVNCServer,然后一堆sb设置 然后,主要有两个配置 ...

  7. JAVA反射会降低你的程序性能吗?

    原文出处 早两天写了<从把三千行代码重构成15行代码谈起>这篇文章,看到评论中有一些同学的回复还是在质疑反射的性能,好像程序用上了反射,就像开上了拖拉机似的.本来我觉得这个话题没有什么好讨 ...

  8. R语言plot函数参数合集

    最近用R语言画图,plot 函数是用的最多的函数,而他的参数非常繁多,由此总结一下,以供后续方便查阅. plot(x, y = NULL, type = "p", xlim = N ...

  9. python-day27--hashlib模块-摘要算法

    1.用途: # 文件校验 # 文件是否被改变# 登录密码 #不能解密,但可以“撞库” #加盐 hashlib.md5('nezha'.encode('utf-8')) 2. import hashli ...

  10. 数据库到jsp页面报错(一)

    数据库到jsp页面报错(一) 这个错误的确比较坑. 控制台:     页面: 解决: 神坑啊!!!