/** * Return the I2CE_FormField for the given field name. * @param string $field the field name or a form name:field name * @return I2CE_FormField */ public function getField($field) { if (strpos($field, ':') !== false) { list($name, $field) = explode(':', $field, 2); if ($name !== $this->name) { I2CE::raiseError("Using wrong reference to container name {$name} != {$this->name}"); return null; } } if ($field == 'parent') { return $this->parentField; } elseif ($field == 'last_modified') { return $this->lastModifiedField; } elseif ($field == 'created') { return $this->createdField; } else { return parent::getField($field); } }
/** * Remvoe a given I2CE_FieldContainer from the cache * @param I2CE_FieldContainer $containerObj */ public function removeFromCache($containerObj) { if (!$containerObj instanceof I2CE_FieldContainer) { return; } if (($id = $containerObj->getId()) === '0') { return; } $name = $containerObj->getName(); if (!array_key_exists($name, $this->containerCache) || !is_array($this->containerCache[$name])) { return; } if ($id == '0') { if (!array_key_exists('0', $this->containerCache[$name])) { return; } foreach ($this->containerCache[$name]['0'] as $i => $cObj) { if ($cObj === $containerObj) { //these are the same objects unset($this->containerCache[$name]['0'][$i]); break; } } } else { if (!array_key_exists($id, $this->containerCache[$name]) && array_key_exists('0', $this->containerCache[$name]) && is_array($this->containerCache[$name]['0'])) { foreach ($this->containerCache[$name]['0'] as $i => $cObj) { if ($cObj === $containerObj) { //these are the same objects. started as anonymous then got saved unset($this->containerCache[$name]['0'][$i]); break; } } return; } unset($this->containerCache[$name][$id]); } }