]> git.andy128k.dev Git - ipf.git/commitdiff
code style
authorAndrey Kutejko <andy128k@gmail.com>
Tue, 25 Jun 2013 21:37:40 +0000 (00:37 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Tue, 25 Jun 2013 21:37:40 +0000 (00:37 +0300)
ipf/admin/modelinline.php
ipf/admin/views.php

index d1619d6aabaaa05623aac3c804e97c145a1eefa9..f49d666465455822b8a71f66fdb13d2a0fba479f 100644 (file)
@@ -8,7 +8,8 @@ abstract class IPF_Admin_ModelInline
 
     var $orderby = 'id';
 
-    function __construct($parentModel,$data=null){
+    function __construct($parentModel,$data=null)
+    {
         $this->parentModel = $parentModel;
 
         $modelName = $this->getModelName();
@@ -23,16 +24,21 @@ abstract class IPF_Admin_ModelInline
         return IPF_Utils::appByModel($this->getModelName());
     }
 
-    function getAddNum(){ return 4; }
+    function getAddNum()
+    {
+        return 4;
+    }
 
-    function getLegend(){
+    function getLegend()
+    {
         return get_class($this->model);
     }
 
-    function isValid(){
-        foreach($this->formset as &$form){
-            if (!$form->isValid()){
-                if (!$form->isAdd){
+    function isValid()
+    {
+        foreach ($this->formset as &$form) {
+            if (!$form->isValid()) {
+                if (!$form->isAdd) {
                     return false;
                 }
             }
@@ -45,17 +51,19 @@ abstract class IPF_Admin_ModelInline
         return IPF_Shortcuts::GetFormForModel($model_obj, $data, $extra);
     }
 
-    function getFkName(){
-        foreach($this->model->getTable()->getRelations() as $rel){
+    function getFkName()
+    {
+        foreach($this->model->getTable()->getRelations() as $rel) {
             if ($rel->getClass()==get_class($this->parentModel))
                 return $rel->getAlias();
         }
         throw new IPF_Exception(__('Cannot get fkName for '.$this->getModelName()));
     }
 
-    function getFkLocal(){
-        foreach($this->model->getTable()->getRelations() as $rel){
-            if ($rel->getClass()==get_class($this->parentModel))
+    function getFkLocal()
+    {
+        foreach($this->model->getTable()->getRelations() as $rel) {
+            if ($rel->getClass() == get_class($this->parentModel))
                 return $rel->getLocal();
         }
         throw new IPF_Exception(__('Cannot get fkLocal for '.$this->getModelName()));
@@ -78,7 +86,7 @@ abstract class IPF_Admin_ModelInline
 
         $first = true;
 
-        if ($this->parentModel->exists()){
+        if ($this->parentModel->exists()) {
             $query = IPF_ORM_Query::create()
                 ->from(get_class($this->model))
                 ->where($this->getFkLocal().'='.$this->parentModel->id);
@@ -88,54 +96,52 @@ abstract class IPF_Admin_ModelInline
             else
                 $objects = $query->orderby($this->orderby)->execute();
 
-            foreach ($objects as $obj){
+            foreach ($objects as $obj) {
                 $prefix = 'edit_'.get_class($this->model).'_'.$obj->id.'_';
                 $d = array();
 
-                if ($data===null){
-                    foreach ($obj->getData() as $k=>$v){
+                if ($data===null) {
+                    foreach ($obj->getData() as $k=>$v) {
                         $d[$prefix.$k] = $v;
                     }
-                }
-                else{
-                    foreach ($data as $k=>$v){
-                        if (strpos($k,$prefix)==0)
+                } else {
+                    foreach ($data as $k=>$v) {
+                        if (strpos($k,$prefix) == 0)
                             $d[$k] = $v;
                     }
                 }
 
                 $form = $this->_getForm($obj, $d, $form_extra);
 
-
                 $form->prefix = $prefix;
                 $form->fields = array_merge(array(
                     new IPF_Form_Field_Boolean(array('label'=>'Del','name'=>'is_remove')),
-                ),$form->fields);
+                ), $form->fields);
 
                 $form->isAdd = false;
-                if ($first){
+                if ($first) {
                     $form->isFirst = true;
                     $first = false;
-                }
-                else
+                } else {
                     $form->isFirst = false;
+                }
                 $this->formset[] = $form;
             }
         }
 
         $n_addnum = $this->getAddNum();
-        for($i=0; $i<$n_addnum; $i++ ){
+        for ($i = 0; $i < $n_addnum; $i++) {
             $form = $this->_getForm($this->model->copy(), null, $form_extra);
             $form->fields = array_merge(array(new IPF_Form_Field_Boolean(array('label'=>'Del','name'=>'delete_', 'widget_attrs'=>array('disabled'=>'disabled')))),$form->fields);
             $form->prefix = 'add_'.get_class($this->model).'_'.$i.'_';
             $form->data = $data;
             $form->isAdd = true;
-            if ($first){
+            if ($first) {
                 $form->isFirst = true;
                 $first = false;
-            }
-            else
+            } else {
                 $form->isFirst = false;
+            }
             $this->formset[] = $form;
         }
     }
@@ -183,7 +189,7 @@ abstract class IPF_Admin_ModelInline
         $fk_local = $this->getFkLocal();
         foreach ($this->formset as $form) {
             if ($form->isValid()) {
-                if ($form->isAdd){
+                if ($form->isAdd) {
                     unset($form->cleaned_data[0]);
                     $form->cleaned_data[$fk_local] = $parent_obj->id;
                     $form->save();
index b451d0614893b85b682daca9a4faeae4213a6f22..98d6f88fef75c3a525a343cc1ad1b6d25c7c140a 100644 (file)
@@ -440,7 +440,7 @@ function IPF_Admin_Views_FileBrowser($request, $match){
     $pth = explode('/',$curr_dir);
     $path = array();
     $cd = '/admin/filebrowser/';
-    foreach($pth as $p){
+    foreach($pth as $p) {
         $cd.=$p.'/';
         $path[] = array('cd'=>$cd, 'name'=>$p);
     }
@@ -470,3 +470,4 @@ function IPF_Admin_Views_FileBrowserRename($request, $match)
         $name=$old_name;
     return new IPF_HTTP_Response($name);
 }
+