May 29, 2008
Javascript, Zend Framework
No Comments
For a customer need, I’ve integrated the scriptaculous slider as shown here in Zend framework.
To achieve this, I’ve created a formSlider view helper which is then used by a slider form element.
The view helper and form element code is here. To allow ZF to find the helper, don’t forget to add path to helper in your bootstrap :
$layout->getView()->addHelperPath('Mc/View/Helper','Mc_View_Helper') ;
You need of course to include scriptaculous and prototype to make it work (available here and here) :
<script src="/prototype-1.6.0.2.js" type="text/javascript"></script>
<script src="/scriptaculous.js" type="text/javascript"></script>
Then, you can create a slider like this :
require_once('Mc/Form/Element/Slider.php') ;
$my_form->addElement(new Mc_Form_Element_Slider('my_element')
,'my_element') ;
$my_form->my_element->setLabel('My element : ')
->setMin(10)
->setMax(30)
->setStep(2);
and retrieve the value as usual :
$my_form->my_element->getValue() ;
And if you want to override the default style in your css, don’t forget the !important argument :
div.slider {
width:256px !important;
margin:10px 0 !important;
background-color:lightgray !important;
height:15px !important;
position: relative !important;
}
div.slider div.handle {
width:10px !important;
height:15px !important;
background-color:darkgray !important;
cursor:move !important;
position: absolute !important;
}
May 28, 2008
Javascript
No Comments
I was looking for a javascript which could automatically resize a textarea but the ones I’ve found were a bit buggy or ugly, so I’ve written mine. There’s just a tiny bug with copy/paste with mouse.
function autoresize(txtbox)
{
var cols = txtbox.cols ;
var content = txtbox.value ;
var lineCount = 0 ;
var lastEOL = -1 ;
do {
var begin = lastEOL+1 ;
lastEOL = content.indexOf("\n",lastEOL+1) ;
var line = "" ;
if(lastEOL != -1) {
line = content.substring(begin,lastEOL) ;
} else {
line = content.substring(begin,content.length) ;
}
var rows_in_line = Math.floor(line.length/cols)+1 ;
lineCount += rows_in_line
} while (lastEOL != -1) ;
txtbox.rows = lineCount ;
}
and html code :
<textarea name="my_textbox" onkeyup="autoresize(this)"
onmouseup="autoresize(this)" rows="24" cols="80"></textarea>
May 27, 2008
linux
No Comments
To see information about the dvd :
mplayer -identify -frames 0 dvd://
To encode the 17 chapters of the first title of a dvd :
for i in $(seq 17) ; do mplayer -vo null -ao pcm -ao pcm:file=$i.wav:fast -chapter $i-$i dvd://01 ; flac $i.wav --best & done
April 2, 2008
acceleo, apache
No Comments
Currently I’ve not much time to work on Wisss
However, I will make a tiny dsl and generator to have a virtualhost file generated (independent from Wisss, which already generate a vhost). I’ve already done this with a shell script but it will be more powerful and easy to maintain for a few hours of work.
The initial need is for my own server but it will also be useful for my company. The goal is to provide our best practice for vhost in a tool.
March 11, 2008
Wisss
No Comments
Following my last post about authentication, I’ve implemented it in Wisss. I’ve also added a simple ACL management which retrieves all resources, roles and privileges from database and constructs a Zend_Acl object in the boostrap. I’m not very happy to have to retrieve all stuffs about ACL each time, but for now, I have no time to implement something smarter.
To manage ACL, I’ve also begun to generate an admin interface which is also for now quite simple (displaying a big table with all roles and resources). Concerning resources, I’ve define three layers : module, screen, action. I don’t know yet what is the best practice to apply ACL to a particular object. I will think of it during next weeks.
I’ve also added a block view helper which displays blocks in the layout if you are allowed to. A block is just a screen rendered as a menu, what minimize concepts in the model. There’s also a special block : the context. Thanks to a context action helper, each action can register contextual action which will then appear in the context menu. For instance, the “create” action will be able to set “edit” and “delete” action as contextual actions.
I’m busy this week, and I was this last two weeks (giving a ZF formation
) but I will switch form generation to Zend_Form as soon as possible. Despite my first opinion, which was against the use of Zend_Form, I find this component very useful and productive. Even if it’s bad to put view logic in the controller, it seems to be far easier to maintain.
I think the 0.3.0 release will happen soon including everything to build a blog example (and many other application). 0.4.0 will focus on cleaning up the code, polishing the interface, trying to improve ACL. I hope there won’t be a 0.5 