Esempio n. 1
0
 /**
  * Set the attributes of the scheme
  *
  * @param One_Scheme $scheme
  * @param DOMXPath $xpath
  * @param DOMElement $meta
  */
 protected static function setAttributes(One_Scheme $scheme, DOMXPath $xpath, DOMElement $meta)
 {
     // create the attribute set for this scheme
     $attributes = array();
     $rAttributes = $xpath->query($meta->getNodePath() . '/attributes/attribute');
     for ($i = 0; $i < $rAttributes->length; $i++) {
         $att_spec = $rAttributes->item($i);
         // Get the name and type of the attribute and remove them to easily pass the other attributes
         $att_name = $att_spec->getAttribute('name');
         $att_type = $att_spec->getAttribute('type');
         $att_spec->removeAttribute('name');
         $att_spec->removeAttribute('type');
         $att_options = array();
         foreach ($att_spec->attributes as $att) {
             $att_options[$att->name] = $att->value;
         }
         //*** quarantine: calculated functionality
         //        if ('calculated' == $att_type) {
         //          $att_type = 'calculated_' . ucfirst($scheme->getName()) . '_' . ucfirst($att_name);
         //        }
         $a = new One_Scheme_Attribute($att_name, $att_type, $att_options);
         $attributes[$a->getName()] = $a;
         //*** this code breaks encapsulation: flex should be handles outside standard models
         // When dealing with a flex-type attribute, automatically add the flex behavior
         //        if ($a->getType() instanceof One_SchemeAttribute_Type_Flex) {
         //          $behavior = One_Repository::getBehavior('flex', $scheme->getName());
         //          $spec     = array('flexfield' => $a->getName());
         //          $scheme->addBehavior($behavior, $spec);
         //        }
         // When dealing with a calculated-type attribute, automatically add the flex behavior
         //        if ($a->getType() instanceof One_SchemeAttribute_Type_Calculated) {
         //          $behavior = One_Repository::getBehavior('calculated', $scheme->getName());
         //          $spec     = array('attribute' => $a->getName());
         //          $scheme->addBehavior($behavior, $spec);
         //        }
     }
     $scheme->set('attributes', $attributes);
 }
Esempio n. 2
0
 public function formatAttribute(One_Scheme_Attribute $attribute, $value)
 {
     return '' . $attribute->getName() . ' = ' . $attribute->toString(mysql_real_escape_string($value));
 }