易栈网-膘叔

浏览模式: 标准 | 列表 | 图文
为supesite中的文章添加背景音乐

为supesite中的文章添加背景音乐

以前我写过一篇测试播放器的文章,当然,在我自己的网站是正常了。正好遇到一朋友需要在supesite下面为每篇文章增加不同的背景音乐,于是调试了一下。由于supesite的编辑器会自动过滤一些标签,最终我的处理方案如下:

1、先选中编辑器状态栏中的“源代码”,点击后,输入

<div id='audio_file' style="display:none">aaa.mp3</div>



其中,aaa.mp3就是你要播放的音乐文件,默认在根目录下的music目录里,如果你在里面建立了目录hongkong来存放香港歌英,则aaa.mp3就变成了hongkong/aaa.mp3,即在文件名前要加上目录路径,id=audio_file不能被改变,

2、取消选中源代码,继续编辑你的文章,这时候刚才的 aaa.mp3 会显示在内容里,不用理会他,成功后不会影响文件的编辑的。或者,你也可以在文件内容编辑完毕后,再选中源代码,在源代码的最上面加入这一行就行了。

3、在模版里加上相应的代码

<script language="JavaScript" src="http://www.xxxx.com/public/audioplayer.js"></script>
<script>
try
{
var audio = document.getElementById('audio_file');
if(audio.innerText != ''){
var audio_flash = 'http://www.xxxxx.com/public/player.swf';
var audio_vars = {};
audio_vars.soundFile = 'http://www.xxxxx.com/music/' + audio.innerText;
audio_vars.loop = 'yes';
audio_vars.autostart = 'yes';
set_audioplayer( audio_flash , audio_vars );
}
}
catch (e){}

</script>

4、成功……现在测试

具体的代码就不提供了。网上应该是有的下载。。。。只是提供这个解决方法。

演示地址:http://www.l2foto.com/s/?action-viewnews-itemid-4

测试JS的速度

在mootools的官方网站有一个网页专门用来测试几个框架的速度,大概是:mootools,jquery,prototype,dojo,yui,测试下来jquery的平均速度应该算是最快的。

那个评测下来IE下JS运行速度慢果然是很明显的。同样的测试在IE下面比FF下面,速度慢了一倍左右啊。

不多了。自己测试一下看结果吧。。
http://mootools.net/slickspeed/

zendframework 1.6终于将SOAP放进去了

zendframework 1.6终于将SOAP放进去了

1.6版本的zf终于将SOAP放进来了,同时也增加了DOJO的支持。不过我没有想通。为什么那么多的JS框架,最终会选择了DOJO。

这些不是我能够想得通的。还是看看到底更新了什么再说吧。

An overview of new features:

  • Dojo Integration
    • JSON-RPC
    • Dojo Data packing
    • Dojo View Helper
    • Dijit integration with Zend_Form & Zend_View
    • Dojo Library Distribution
  • SOAP
    • SOAP Server
    • SOAP Client
    • Autodiscovery
    • WSDL access
    • WSDL Generation
  • Preview of Tooling Project in Laboratory (see /laboratory folder)
    • Command Line Interface
    • Project Asset Management
  • Unit Testing Harness for Controllers
  • Lucene 2.3 Index File Format Support
  • Zend_Session save handler for Database Tables
  • Paginator Component
  • Text/Figlet Support
  • ReCaptcha Service
  • Zend_Config_Xml Attribute Support
  • Character Set Option for DB Adapters
  • Zend File Transfer Component
  • New Media View Helpers (Flash, Quicktime, Object, and Page)
  • Support in Zend_Translate for INI File Format

This obviously marks a very important step towards a high-quality, highly tested 1.6 GA release. Thanks to everyone who has contributed to this release in any way: with patches/check ins, documentation/translations, and bug reports.

But our work is not yet over! Let's do our best to bring this release to the breaking point to find areas we can improve the release for General Availability. Based on your feedback we will determine in the next few weeks whether we require additional release candidates, so please provide feedback on our issue tracker (http://framework.zend.com/issues) as soon as you can and ask any questions/post your experiences on the appropriate mailing list.

Again, the Zend Framework community does NOT recommend this release for production use. We do, however, recommend evaluating new features in this release with existing and new applications.

Enjoy 1.6RC1, and see you on the issue tracker, wiki, and mailing lists!

————END————

不知道:Zend File Transfer Component,这个会给我们带来什么样的惊喜?大文件传输还是其他的?下载源码研究一下,哈哈

Zend_Acl and MVC Integration Part I (Basic Use)

Zend_Acl and MVC Integration Part I (Basic Use)

原文地址:http://devzone.zend.com/article/3509-Zend_Acl-and-MVC-Integration-Part-I-Basic-Use

原文内容:

By Aldemar Bernal

So, what is wrong with Zend_Acl and the current MVC implementation in the Zend Framework? there is nothing wrong, it is just that it gets not too obvious for developers how to achieve an optimal integration between these two important parts of the framework.

First at all, this article is based on the following Zend Framework Proporsal (link), by this moment this proposal is in Pending Recommendation state.

Well, how it works? There are two key components in this proposal:

  1. A Front Controller Plugin: This component resolves if the current user has access to the page which is being opened.
  2. An Action Helper: This component allows you to check whether the current user has access inside a controller.

Based on these two components, let's try them with an example. Let's talk about a website like DevZone, we would need a controller that work with the user management and another one which will deal with article management, as well we need 3 types of users (roles), one for guests, one for writers and another one which will approve the articles; resuming, we have:

Resources:

  1. user controller.
  2. article controller.

Roles:

  1. Guest.
  2. Writer.
  3. Admin.

Setting up the Zend_Acl component

After defined what we want to do, the next step will create a Zend_Acl instance which will reflect our model.

/** Creating the ACL object */
require_once 'Zend/Acl.php';
$myAcl = new Zend_Acl();

Creating the roles

Now we create the roles in our Zend_Acl instance.

/** Creating Roles */
require_once 'Zend/Acl/Role.php';
$myAcl->addRole(new Zend_Acl_Role('guest'))
->addRole(new Zend_Acl_Role('writer'), 'guest')
->addRole(new Zend_Acl_Role('admin'), 'writer');

Creating the resources

And then we create the resources needed (one per controller) and their relationship with the roles we created.

/** Creating resources */
require_once 'Zend/Acl/Resource.php';
$myAcl->add(new Zend_Acl_Resource('user'))
->add(new Zend_Acl_Resource('article'));

Creating the permissions

Now that we added the roles and resources to our Zend_Acl instance, it's time to explain what actions must be available to which roles.

  1. Guest won't have access to edit, add or approve an article.
  2. Writer won't have access to approve an article.
  3. Admin will have complete access.
/** Creating permissions */
$myAcl->allow('guest', 'user')
->deny('guest', 'article')
->allow('guest', 'article', 'view')
->allow('writer', 'article', array('add', 'edit'))
->allow('admin', 'article', 'approve');

Creating the access denied view file

We will need to create a view and an action which will address all those denied users, in order to do it, first we create a new action in our error controller:

class ErrorController extends Zend_Controller_Action
{
....

public function deniedAction()
{
}

....
}

And then we create our view file (/application/views/scripts/error/denied.phtml) with some warning message:

<h1>Error</h1>
<h2>Access denied</h2>
<p>You are trying to access an area which you have not allowed.</p>

Finishing the configuration

Okay, we have setup our Zend_Acl configuration, so far, it doesn't look like something new, but the next step is register the controller plugin, this important part takes the Zend_Acl instance we created and then validates it against the current page being accessed by an user.

/** Setting up the front controller */ 
require_once 'Zend/Controller/Front.php';
$front = Zend_Controller_Front::getInstance();
$front->setControllerDirectory('path/to/controllers');

/** Registering the Plugin object */
require_once 'Zend/Controller/Plugin/Acl.php';
$aclPlugin = new Zend_Controller_Plugin_Acl($myAcl);
$aclPlugin->setRoleName($currentUserRole);

$front->registerPlugin(new Zend_Controller_Plugin_Acl($acl, 'guest'));

/** Dispatching the front controller */
$front->dispatch();

After this configuration is done, once an user enters in our application, depending the role he/she has the page will be displayed or an access denied page will be displayed.

For more information about this you can go to:
Zend_Acl & MVC Integration
and here is a small implementation source code of this:
Source Code

————END————
由于本文并没有什么特别的地方,而且单词也没有什么,故不作翻译。

最常用的链接

最常用的链接

日常工作中,有一些网站是经常要去的,因此在这里加上链接,以后就可以偷懒了,而且,也防止自己以后找不到相应的网站。[逐步更新中]

PHP官方网站   PHP官方手册  PHP下载  PHP snap   pear for PHP

APACHE官方网站  APACHE手册  MYSQL官方网站  MYSQL官方中文手册

SMARTY官方网站  SMARTY手册  smarttemplate官方网站(改名叫quickskin了)

jQuery官方网站  prototype官方网站  mootools官方网站

PYTHON官方网站  PYTHON手册


下面是系统类的链接
FREEBSD操作手册

电视也弹窗

电视也弹窗

偶在网上闲逛。突然发现一段内容,对应家中现有的有线电视情况,突然感到好紧张。。。贴上部分内容,陪我一起震惊吧。

自从用了这个遥控器,我就感觉不对劲儿,怎么赛事正精彩的时侯屏幕上会出来个小窗口提示有奖答题呢? 第一次看到以为是央视搞的,后来频繁的出现感觉有点不对,按遥控器的"退出"键,居然提示,"确定退出么?" 按"确定",居然也要半天才能消失这个小浮动窗口。真是有些震惊啊,这下真的互动了,弹窗广告居然搞到电视上来了!

流氓会武术,谁都挡不住! 相信这个技术会被更多有线电视运营商采用的。到时候面对时不时的弹窗广告,加上原来就有的贴片广告,以及那些"精彩绝伦"的电视购物广告,这电视还能看下去么? 奥运过后,电视关闭!
好佩服现在的厂商呀。这是否和当年的分众一个想法?只是这个想法比分众还疯狂啊。估计是和电信学的吧?
smarty中的注释

smarty中的注释

写代码的时候不可避免的会使用到注释。大多数的情况下,我们都是使用<!-- 这里是注释 -->,因为这是HTML自带的注释功能,在这里的代码都不会被显示到浏览器。

然而,使用了smarty之类,我们确实不是很建议这样使用,因为,在<!---->标记里的smarty代码其实还是被解析了,如果是这样的话,那么,我们其实是多做了很多事情,却没有被显示出来,那就是说,我们其实多做了很多无用功。

因此,我们在使用smarty模版的时候,应该根据smarty的规范来。让我们看看手册怎么说:


所有例子中,我们假定你使用缺省的分隔符。Smarty中,所有在分隔符之外的内容被显示为静态内容,或者说不会被改变。一旦Smarty遇见分隔符,它将尝试解释它们,然后在其位置处显示合适的内容。

注释

模板注释由星号包围,继而由分隔符包围,型如:{* 这是一个注释 *}。Smarty注释不会在最终模板的输出中显示,这点和<!-- HTML comments -->不同。前者对于在模板中插入内部注释有用,因为没有人能看到。;-)

{* 这是Smarty注释,不出现在编译后的输出中 *}
<html>
<head>
<title>{$title}</title>
</head>
<body>

{* 另一个单行Smarty注释 *}
<!-- HTML注释将发送到浏览器 -->

{* 这是一个多行
Smarty注释
并不发送到浏览器
*}

{*********************************************************
多行注释块,包含了版权信息
@ author: bg@example.com
@ maintainer: support@example.com
@ para: var that sets block style
@ css: the style output
**********************************************************}

{* 包含了主LOGO和其他东西的头文件 *}
{include file='header.tpl'}


{* 开发注解:$includeFile变量在foo.php脚本中赋值 *}
<!-- 显示主内容块 -->
{include file=$includeFile}

{* 该<select>块是多余的 *}
{*
<select name="company">
{html_options options=$vals selected=$selected_id}
</select>
*}

{* 模板的cvs标记。下面的36应该是美元符号。
但是在CVS中被转换了。 *}
{* &#36;Id: Exp &#36; *}
{* $Id: *}
</body>
</html>
smarty中的变量使用

smarty中的变量使用

smarty中的变量和平时使用有点区别,比如$aa.bb其实代表的是$aa['bb'],具体如何个使用法,其实在手册里已经有详细说明了

Smarty可以识别嵌入在双引号中赋值的变量,只要变量名只包含数字,字母,下划线和方括号[](参见命名)。如果有其它字符(如句点,对象引用等),变量必须由反引号对`backticks`包含。你不可以嵌入修饰符,它们必须永远在引号之外使用。

实际使用中应该是这样的:

语法例子:
{func var="test $foo test"} <-- 使用$foo
{func var="test $foo_bar test"} <-- 使用$foo_bar
{func var="test $foo[0] test"} <-- 使用$foo[0]
{func var="test $foo[bar] test"} <-- 使用$foo[bar]
{func var="test $foo.bar test"} <-- 使用$foo(不是$foo.bar)
{func var="test `$foo.bar` test"} <-- 使用$foo.bar

{func var="test `$foo.bar` test"|escape} <-- 修饰符在引号外!

实际例子:
{include file="subdir/$tpl_name.tpl"} <-- 将以实际值替换$tpl_name
{cycle values="one,two,`$smarty.config.myval`"} <-- 必须有反引号!

看清楚哦。平时在使用的时候应该是感觉不出问题的,只有用在函数、循环里面,这才会成为使用中的问题。
一个程序员的13口决!

一个程序员的13口决!

看到这段,觉得有理。。。记录下来,实在不知道原作者是谁。。。。

一个程序员的13口决!
1、编程就像吃饭,不可能一口变成胖子。
2、还没练几天就想要高工资,不如去批发白菜好了。
3、程序员也民工,不觉得自己太高尚。
4、你的代码永远存在可优化的可能,所以有空要回头再看看。
5、编程时要永远开着记事本,测试数据,测试方法,搜到的代码等等要常放进去,存起来以备不时之需。
6、不要再回忆你的代码有多牛B,第二天早上别人的代码就可把你的程序替换了。
7、每一天都不是糟糕的,更糟的还在后面。
8、整理你的代码,文档,思维方式,以及行为方式。
9、第一次看到时千万别说你已经理解了。。。未来的变数还很大。
10、任何事物都是由简单开始,并最终回归简单。只是层次不同了而已。
11、首先感谢自己,然后再谢别人。还要感谢人民政府给你提供了就业机会。
12、永远都知道自己当前该做什么。
13、理解正念,并认真执行。

成语新解

成语新解

1.知书达礼:仅知道书本知识是不够的,还要学会送礼;
2.度日如年:日子非常好过,每天像过年一样;
3.杯水车薪:每天办公室喝喝茶,月底可以拿到一车工资;
4.知足常乐:知道有人请自己洗脚,心里就感到快乐;
5.见异思迁:看见漂亮的异性就想搬到她那里去住;
6.语重心长:别人话讲得重了,心里怀恨很长时间;
7.有机可乘:出门考察有飞机可以乘坐;
8.不学无术:不要白费工夫学那些不实用的东西;
9.夫唱妇随:丈夫进了歌厅,妻子跟踪尾随。