示例#1
0
 protected function load($linkName, $entityName)
 {
     $parentRelation = parent::load($linkName, $entityName);
     $foreignEntityName = $this->getForeignEntityName();
     $relation = array($entityName => array('relations' => array($linkName => array('midKeys' => array(lcfirst($entityName) . 'Id', lcfirst($foreignEntityName) . 'Id')))));
     $relation = \Fox\Core\Utils\Util::merge($parentRelation, $relation);
     return $relation;
 }
示例#2
0
 function generMultipleClassSelectionField($attr, $val, &$lllProp)
 {
     global $lll;
     $size = isset($val["size"]) ? $val["size"] : 1;
     $width = isset($val["width"]) ? $val["width"] : 0;
     $hasMany = FALSE;
     if (isset($val["get_values_callback"])) {
         eval('$objects=$this->base->' . $val["get_values_callback"] . ';');
     } else {
         $hasMany = HasMany::construct($this->base, $attr, $val);
         if (isset($val["query"])) {
             // ha egy fuggvenyt adunk meg query-kent:
             if (!preg_match("{^SELECT.*}", $val["query"])) {
                 eval("\$query={$val['query']};");
             } else {
                 $query = $val["query"];
             }
             //echo $query;
         } elseif ($hasMany) {
             $query = $hasMany->getSelectFieldQuery();
         } else {
             $query = "SELECT id, {$val['labelAttr']} FROM @{$val['class']}";
         }
         if (isset($val["where"])) {
             // ha egy osztalyfuggvenyt adunk meg where feltetelkent: pl. "where"=>"\$this->base->getWhere()"
             if (strstr($val["where"], "\$this->base")) {
                 eval("\$w={$val['where']};");
             } else {
                 $w = $val["where"];
             }
             $query .= " WHERE {$w}";
         }
         if (isset($val["ordered"])) {
             $query .= " ORDER BY {$val['ordered']}";
         }
         //echo $query;
         $objects = new $val["class"]();
         loadObjectsSQL($objects, $query, $objects);
     }
     if (in_array("variablesize", $val)) {
         $count = count($objects);
         if (isset($val["nothing selected"])) {
             $count++;
         }
         $size = $count > $size ? $size : $count;
     }
     $labels = array();
     $values = array();
     if (isset($val["nothing selected"])) {
         $values[] = 0;
         $labels[] = $lll[$val["nothing selected"]];
     }
     if (isset($val["labelFormat"])) {
         $labelAttrs = split(", *", $val["labelAttr"]);
         $e = "sprintf('{$val['labelFormat']}'";
         foreach ($labelAttrs as $l) {
             $e .= ", \$obj->{$l}";
         }
         $e .= ")";
     }
     $default = array();
     foreach ($objects as $obj) {
         $values[] = $obj->id;
         if ($obj->id && isset($val["labelFormat"])) {
             eval("\$temp={$e};");
             $labels[] = $temp;
         } elseif ($obj->id) {
             $labels[] = $obj->{$val["labelAttr"]};
         } else {
             $labels[] = $lll["nothingSelected"];
         }
         if (!empty($obj->selected)) {
             $default[] = $obj->id;
         }
     }
     if (!$hasMany || get_class($hasMany) == "HasManyWithoutLinkClass" || in_array("overridedefault", $val)) {
         $default = in_array("nodefaultselected", $val) ? 0 : $this->base->{$attr};
     }
     // if( is_array($this->base->{$attr}))
     // {
     // $default = in_array("nodefaultselected",$val) ? 0 : $this->base->{$attr};
     // }
     // elseif( $this->base->{$attr} ) $default=$this->base->{$attr};
     if (isset($val["onclick"])) {
         JavaScript::addEvent('#' . $attr, "click", $val["onclick"]);
     }
     if (isset($val["onchange"])) {
         JavaScript::addEvent('#' . $attr, "change", $val["onchange"]);
     }
     $showRelation = isset($val["show_relation"]) ? $val["show_relation"] : "";
     $anyfield = isset($val["anyfield"]) ? $val["anyfield"] : "";
     $asmSelect = isset($val["asmselect"]) ? $val["asmselect"] : "";
     $asmSelectLabel = isset($val["asmselect_label"]) ? $val["asmselect_label"] : "";
     $s = GenerWidget::generMultipleSelection($attr, $labels, $values, $default, $size, $width, $showRelation, $anyfield, $asmSelect, $asmSelectLabel);
     if (in_array("selectfilter", $val)) {
         $s = GenerWidget::generSelectFilterField($attr, $labels, $width) . $s;
     }
     return $s;
 }
示例#3
0
文件: hasmany.php 项目: alencarmo/OCF
 function __construct($base, $attribute, $attrInfo)
 {
     parent::__construct($base, $attribute, $attrInfo);
     $classNames = array($this->thisTable, $this->otherTable);
     sort($classNames);
     $this->linkTable = implode("_", $classNames);
     // pl. event_user
 }