Exemplo n.º 1
0
 public static function valueToJavascript($value, $lazy = false)
 {
     $resolvedValue = $value;
     if (is_bool($value)) {
         $resolvedValue = $value ? "true" : "false";
     } else {
         if (is_null($value)) {
             $resolvedValue = null;
         } else {
             if (is_string($value)) {
                 $resolvedValue = "'{$value}'";
             } else {
                 if (is_array($value)) {
                     $resolvedValue = PhpExt_Javascript::jsonEncode($value);
                 } else {
                     if (PhpExt_Object::isExtObject($value)) {
                         $resolvedValue = $value->getJavascript($lazy);
                     } else {
                         if (PhpExt_ObjectCollection::isExtObjectCollection($value)) {
                             if ($value->getCount() > 0) {
                                 $resolvedValue = $value->getJavascript($lazy);
                             }
                         } else {
                             if (PhpExt_Javascript::isJavascript($value) || PhpExt_Javascript::isJavascriptStm($value)) {
                                 $resolvedValue = $value->output();
                             } else {
                                 if (is_object($value)) {
                                     $resolvedValue = PhpExt_Javascript::jsonEncode($value);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $resolvedValue;
 }
Exemplo n.º 2
0
 /**
  * Static method to retrieve Ext.Element objects.
  * Uses simple caching to consistently return the same object. Automatically fixes if an object was recreated with the same id via AJAX or DOM.
  * To retrieve an element by Id use {@link PhpExt_Element::getById}
  * @param string $id The DOM node to retrieve
  * @return PhpExt_Element
  */
 public static function getByDOM($domNode)
 {
     if (!PhpExt_Javascript::isJavascriptStm($domNode)) {
         $domNode = PhpExt_Javascript::variable($domNode);
     }
     $e = new PhpExt_Element();
     $e->domNode = $domNode;
     $args = array($domNode);
     $methodSig = $e->createMethodSignature("get", $args, true);
     $e->createMethod = $e->getMethodInvokeStm('Ext.Element', $methodSig, true);
     return $e;
 }