Permalink
Browse files

Merge branch 'devel' of https://github.com/atk4/atk4 into devel

  • Loading branch information...
2 parents 74decbe + f1f81d3 commit ae5489294f25c7177fd51a066d7fc4114fcc7901 Mayack committed May 17, 2011
View
@@ -78,6 +78,9 @@ function setModel($model,$actual_fields=null){
$this->setController($c);
return $c;
}
+ function getModel(){
+ return $this->getController()->getModel();
+ }
function setController($controller){
if(is_object($controller)){
$this->controller=$controller;
View
@@ -35,7 +35,7 @@ function __construct($str,$info=null,$shift=0){
}
function getDetailedHTML(){
// first, perhaps we can highlight error in a query
- $cause = ereg_replace('.*near \'(.*)\' at line .*','\1',$this->info['mysql_error']);
+ $cause = preg_replace('/.*near \'(.*)\' at line .*/','\1',$this->info['mysql_error']);
if($cause!=$this->info['mysql_error']){
$this->info['last_query']=str_replace($cause,"<font color=red><b>".$cause."</b></font>",$this->info['last_query']);
}
View
@@ -354,13 +354,19 @@ function init(){
function getInput($attr=array()){
$this->template->trySet('field_caption','');
$this->template->tryDel('label_container');
+ if(strpos('<',$this->caption)!==null){
+ // HTML in label
+ $label=$this->caption;
+ }else{
+ $label='<label for="'.$this->name.'">'.$this->caption.'</label>';
+ }
return parent::getInput(array_merge(
array(
'type'=>'checkbox',
'value'=>'Y',
'checked'=>$this->value=='Y'
),$attr
- )).' &ndash; <label for="'.$this->name.'">'.$this->caption.'</label>';
+ )).' &ndash; '.$label;
}
function loadPOST(){
if(isset($_POST[$this->name])){
@@ -388,9 +394,7 @@ function getInput($attr=array()){
));
}
function render(){
- $this->template = $this->owner->template_chunks['hidden_form_line'];
- $this->template->set('hidden_field_input',$this->getInput());
- $this->owner->template_chunks['form']->append('Content',$this->template->render());
+ $this->owner->template_chunks['form']->append('Content',$this->getInput());
}
}
@@ -455,7 +459,7 @@ function validate(){
if(substr_count($this->value, $this->sep) != 2){
$this->invalid();
}else{
- $c = split($this->sep, $this->value);
+ $c = explode($this->sep, $this->value);
//day must go first, month should be second and a year should be last
if(strlen($c[0]) != 4 ||
$c[1] <= 0 || $c[1] > 12 ||
@@ -40,7 +40,7 @@ class Form_Field_Grouped extends Form_Field{
protected $separator='-';
function getInput($attr=array()){
- $input=split($this->separator,$this->format);
+ $input=explode($this->separator,$this->format);
$count=count($input);
//$onChange=($this->onchange)?$this->onchange->getString():'';
$output=$this->getTag('span', array('style'=>'white-space: nowrap;'));
@@ -88,7 +88,7 @@ function setFormat($format,$separator='-'){
function loadPOST(){
if(empty($_POST))return;
// value consists of several parts that are in separate POST items
- $input=split($this->separator,$this->format);
+ $input=explode($this->separator,$this->format);
$this->value='';
for($i=0;$i<count($input);$i++)$this->value.=$_POST[$this->name."_$i"];
}
View
@@ -25,8 +25,6 @@
class Grid_Basic extends CompleteLister {
public $columns;
protected $no_records_message="No matching records to display";
- private $table;
- private $id;
public $last_column;
public $sortby='0';
@@ -119,6 +117,10 @@ function addColumn($type,$name=null,$descr=null){
return $this;
}
+ function getColumn($column){
+ $this->last_column=$column;
+ return $this;
+ }
function removeColumn($name){
unset($this->columns[$name]);
if($this->last_column==$name)$this->last_column=null;
@@ -275,7 +277,7 @@ function format_expander($field, $column){
// $this->current_row[$field]=$this->add('Button',null,false)
// ->
//
- @$this->current_row[$field]='<input type="checkbox" class="buttonx_'.$field.' '.$class.'"
+ @$this->current_row[$field]='<input type="checkbox" class="button_'.$field.' '.$class.'"
id="'.$this->name.'_'.$field.'_'.$this->current_row[$column['idfield']?$column['idfield']:'id'].'"
rel="'.$this->api->getDestinationURL($column['page']?$column['page']:'./'.$field,
array('expander'=>$field,
@@ -294,7 +296,7 @@ function init_expander_widget($field){
return $this->init_expander($field);
}
function init_expander($field){
- $this->js(true)->find('.buttonx_'.$field)->button();
+ $this->js(true)->find('.button_'.$field)->button();
if(!isset($this->columns[$field]['refid'])){
// TODO: test
@@ -401,28 +403,42 @@ function format_delete($field){
function init_button($field){
$this->js(true)->find('.button_'.$field)->button();
}
+ function setButtonClass($class){
+ $this->columns[$this->last_field]['button_class']=$class;
+ }
+ function init_delete($field){
+ $this->columns[$field]['button_class']='red';
+ $g=$this;
+ $this->api->addHook('post-init',function() use($g,$field){
+ if($g->hasColumn($field))$g->addOrder()->move($field,'last')->now();
+ });
+ return $this->init_confirm($field);
+ }
function init_confirm($field){
$this->js(true)->find('.button_'.$field)->button();
}
function init_prompt($field){
$this->js(true)->find('.button_'.$field)->button();
}
function format_button($field){
- $this->current_row[$field]='<button type="button" class="button_'.$field.'" '.
+ $this->current_row[$field]='<button type="button" class="'.$this->columns[$field]['button_class'].'button_'.$field.'" '.
'onclick="$(this).univ().ajaxec(\''.$this->api->getDestinationURL(null,
array($field=>$this->current_row['id'],$this->name.'_'.$field=>$this->current_row['id'])).'\')">'.
+ (isset($this->columns[$field]['icon'])?$this->columns[$field]['icon']:'').
$this->columns[$field]['descr'].'</button>';
}
function format_confirm($field){
- $this->current_row[$field]='<button type="button" class="button_'.$field.'" '.
+ $this->current_row[$field]='<button type="button" class="'.$this->columns[$field]['button_class'].' button_'.$field.'" '.
'onclick="$(this).univ().confirm(\'Are you sure?\').ajaxec(\''.$this->api->getDestinationURL(null,
array($field=>$this->current_row['id'],$this->name.'_'.$field=>$this->current_row['id'])).'\')">'.
+ (isset($this->columns[$field]['icon'])?$this->columns[$field]['icon']:'').
$this->columns[$field]['descr'].'</button>';
}
function format_prompt($field){
- $this->current_row[$field]='<button type="button" class="button_'.$field.'" '.
+ $this->current_row[$field]='<button type="button" class="'.$this->columns[$field]['button_class'].'button_'.$field.'" '.
'onclick="value=prompt(\'Enter value: \');$(this).univ().ajaxec(\''.$this->api->getDestinationURL(null,
array($field=>$this->current_row['id'],$this->name.'_'.$field=>$this->current_row['id'])).'&value=\'+value)">'.
+ (isset($this->columns[$field]['icon'])?$this->columns[$field]['icon']:'').
$this->columns[$field]['descr'].'</button>';
}
function format_checkbox($field){
View
@@ -1,51 +0,0 @@
-<?php
-/***********************************************************
- ..
-
- Reference:
- http://atk4.com/doc/ref
-
- **ATK4*****************************************************
- This file is part of Agile Toolkit 4
- http://www.atk4.com/
-
- (c) 2008-2011 Agile Technologies Ireland Limited
- Distributed under Affero General Public License v3
-
- If you are using this file in YOUR web software, you
- must make your make source code for YOUR web software
- public.
-
- See LICENSE.txt for more information
-
- You can obtain non-public copy of Agile Toolkit 4 at
- http://www.atk4.com/commercial/
-
- *****************************************************ATK4**/
-/**
- * Renderer for JSON objects
- * Can be used by any type of javascript controls which require JSON data as an input:
- * - SigmaGrid
- * - flexbox
- * - etc.
- *
- * Acts as a generic CompleteLister and can get data from DB or static arrays
- *
- * @author Camper (cmd@adevel.com) on 14.04.2009
- */
-class JsonLister extends CompleteLister{
- function init(){
- // we don't need anything from CompleteLister
- AbstractView::init();
- }
- function execQuery(){
- $this->data=$this->dq->do_getAllHash();
- }
- function render(){
- return (json_encode(array('results'=>$this->data)));
- }
- function defaultTemplate(){
- // we need an empty template with Content in it
- return array('empty','Content');
- }
-}
View
@@ -50,7 +50,10 @@ function now(){
// check if element exists
if(!isset($this->array[$name]))
- throw new Exception_InitError('Element '.$name.' does not exist when trying to move it '.$where.' '.$relative);
+ throw $this->exception('Element does not exist when trying to move it')
+ ->addMoreInfo('element',$name)
+ ->addMoreInfo('move',$where)
+ ->addMoreInfo('relative',$relative);
$v=$this->array[$name];
unset($this->array[$name]);
@@ -75,9 +78,12 @@ function now(){
$tmp[$key]=$value;
}
$this->array=$tmp;
- if($name)throw new Exception_InitError('Unable to perform move, relative key does not exist');
+ if($name)throw $this->exception('Relative element not found while moving')
+ ->addMoreInfo('element',$name)
+ ->addMoreInfo('move',$where)
+ ->addMoreInfo('relative',$relative);
- if($where=='after')$this->array=array_reverse($this->array);
+ if($where=='after')$this->array=array_reverse($this->array);
break;
View
@@ -167,7 +167,7 @@ function isNodeHasChildren($node_id){
function formatItem(){
$this->current_row['caption']="";
foreach($this->display_field as $tmp=>$field){
- $formatters = split(',',$field['format']);
+ $formatters = explode(',',$field['format']);
$this->current_row['caption'].=$field['prefix'];
foreach($formatters as $formatter){
if(method_exists($this,$m="format_".$formatter)){
@@ -30,8 +30,7 @@ $.widget("ui.atk4_expander", {
this.element.closest('table').find('.expander').atk4_expander('collapseFast');
// Make button look like it's bein pushed
- this.element.removeClass("ui-state-default");
- this.element.addClass("ui-state-active").addClass('expander');
+ this.element.addClass('expander');
// add additional row after ours
this.this_tr=this.element.closest('tr');
@@ -58,8 +57,7 @@ $.widget("ui.atk4_expander", {
collapse: function() {
if(!this.expanded || this.transition)return false;
- this.element.removeClass("ui-state-active").removeClass('expander');
- this.element.addClass("ui-state-default");
+ this.element.removeClass('expander');
var ttr=this.this_tr;
@@ -85,10 +83,14 @@ $.widget("ui.atk4_expander", {
collapseFast: function() {
if(!this.expanded || this.transition)return false;
- this.element.removeClass("ui-state-active").removeClass('expander');
- this.element.addClass("ui-state-default");
- var ttr=this.this_tr;
+ console.log(this.element[0]);
+ this.element.filter('input').each(function(junk,cb){
+ cb.checked=false;
+ $(cb).change();
+ });
+ this.element.removeClass('expander');
+ var ttr=this.this_tr;
var remove_this=this.expander_id;
@@ -294,15 +294,20 @@ $.widget("ui.atk4_form", {
});
console.log('old=',params);
*/
- params=this.element.find(":input").serializeArray()
// console.log(params);
// btn is clicked
+ params=this.element.find(":input").serializeArray()
if(btn){
- params['ajax_submit']=btn;
- }
+ for (var el in params){
+ if (params[el].name == 'ajax_submit'){
+ params[el].value=btn;
+ break;
+ }
+ }
+ }
var properties={
type: "POST",
@@ -138,7 +138,7 @@ $.widget("ui.atk4_uploader", {
self.element.attr('name')+'_save_action='+
$(this).closest('div').attr('rel')
);
- })
+ });
tpl.appendTo(tb);
});
self.updateToken();
View
@@ -1,10 +0,0 @@
-<?php
-$safe_extensions=array(
- 'gif','jpg','css','js','png'
- );
-@list($fn,$ext,$junk)=explode('.',$_GET['file']);
-header("Content-type: ".str_replace(',','/',$_GET['ct']));
-if(isset($junk))exit;
-if(!in_array($ext,$safe_extensions))exit;
-$fn=ereg_replace('^amodules3',$amodules3_path,$fn);
-readfile($fn.'.'.$ext);

0 comments on commit ae54892

Please sign in to comment.