Example #1
0
 public function _onItem($evt)
 {
     if ($this->_vfs !== null && is_array($evt) && array_key_exists('item', $evt)) {
         $item = $evt['item'];
         //clean meta data
         //pick ori name as path and swap with path!
         $item->{XAPP_NODE_FIELD_PATH} = '' . $item->{XAPP_NODE_FIELD_NAME};
         //track path
         $path = '' . $item->{XAPP_NODE_FIELD_NAME};
         //clean up file name
         $fileName = '' . $path;
         if (xo_has(self::FILE_NAME_CLEAN_PATTERN) && xo_get(self::FILE_NAME_CLEAN_PATTERN)) {
             $fileName = preg_replace(xo_get(self::FILE_NAME_CLEAN_PATTERN), '', $fileName);
         }
         $fileName = pathinfo($fileName, PATHINFO_FILENAME);
         //swap
         $item->{XAPP_NODE_FIELD_NAME} = $fileName;
         //file
         if ($item->{XAPP_NODE_FIELD_IS_DIRECTORY} === false) {
             $item->type = 'node';
             $this->_currentNodes['items'][] = $item;
             //dir
         } else {
             if ($item->{XAPP_NODE_FIELD_IS_DIRECTORY} === true) {
                 //tree specific
                 if (strpos($item->{XAPP_NODE_FIELD_PATH}, '/') !== false) {
                     $item->type = 'node';
                 } else {
                     $item->type = 'leaf';
                     $item->parentId = '';
                 }
                 //prepare directory scan options
                 $directoryOptions = array(XApp_Directory_Utils::OPTION_ONLY_FILES => false, XApp_Directory_Utils::OPTION_ONLY_DIRS => false, XApp_Directory_Utils::OPTION_RECURSIVE => false, XApp_Directory_Utils::OPTION_CLEAR_PATH => true);
                 //enumerate
                 $childList = $this->_vfs->ls('root/' . $item->{XAPP_NODE_FIELD_PATH} . '/', true, array(XApp_File_Utils::OPTION_DIR_LIST_FIELDS => XAPP_XFILE_SHOW_ISDIR, XApp_File_Utils::OPTION_DIR_LIST => $directoryOptions, XApp_File_Utils::OPTION_EMIT => false));
                 //store child references in item
                 if ($childList && count($childList)) {
                     //prepare array
                     if (!xapp_property_exists($item, XAPP_NODE_FIELD_CHILDREN)) {
                         $item->{XAPP_NODE_FIELD_CHILDREN} = array();
                     }
                     foreach ($childList as $child) {
                         //build item unique reference key
                         $key = $item->{XAPP_NODE_FIELD_PATH} . '/' . $child->name;
                         array_push($item->{XAPP_NODE_FIELD_CHILDREN}, array('_reference' => $key));
                         //$child->parentId = $item->{XAPP_NODE_FIELD_PATH};
                     }
                 } else {
                     if (xo_get(self::SHOW_EMPTY_FOLDERS) === false) {
                         //return null;
                     } else {
                         $item->{XAPP_NODE_FIELD_CHILDREN} = array();
                     }
                 }
                 //add to our flat! list
                 $this->_currentNodes['items'][] = $item;
             }
         }
         return $item;
     }
 }
Example #2
0
 /**
  * method that will return the absolute path of a mounted resource
  * @param $name :   mount point name
  * @return mixed|null
  */
 public function toAbsolutePath($name)
 {
     $name = str_replace('%', '', $name);
     $resource = $this->getResource($name, true);
     if ($resource) {
         $resource = $this->resolveResource($resource);
     } else {
         error_log('couldnt resolve resource : ' . $name);
         xapp_clog('couldnt resolve resource : ' . $name);
         return null;
     }
     if (xapp_property_exists($resource, XAPP_RESOURCE_PATH_ABSOLUTE)) {
         return xapp_property_get($resource, XAPP_RESOURCE_PATH_ABSOLUTE);
     }
     return null;
 }
Example #3
0
 /**
  * method that will return the absolute path of a mounted resource
  * @param $name :   mount point name
  * @return mixed|null
  */
 public function toAbsolutePath($name)
 {
     $resource = $this->getResource($name, true);
     if ($resource) {
         $resource = $this->resolveResource($resource);
     } else {
         /*xapp_dump($this);*/
         return null;
     }
     if (xapp_property_exists($resource, XAPP_RESOURCE_PATH_ABSOLUTE)) {
         return xapp_property_get($resource, XAPP_RESOURCE_PATH_ABSOLUTE);
     }
     return null;
 }
Example #4
0
 public function resolveResources()
 {
     $resourceData = xapp_get_option(self::RESOURCES_DATA, $this);
     if ($resourceData !== null) {
         $resourceItems = (array) xapp_object_find($resourceData, '.items', array('class=' . 'cmx.types.Resource'));
         if ($resourceItems != null && count($resourceItems)) {
             foreach ($resourceItems as $resourceItem) {
                 if (!xapp_property_exists($resourceItem, XAPP_RESOURCE_URL_RESOLVED) || !xapp_property_exists($resourceItem, XAPP_RESOURCE_PATH_ABSOLUTE)) {
                     $this->resolveResource($resourceItem);
                 }
             }
             xo_set(self::RESOURCES_DATA, $resourceItems);
         }
     } else {
         return false;
     }
     return true;
 }
Example #5
0
 public function addJSIncludes($print = false)
 {
     $scriptItems = $this->getResourcesByType(XAPP_RESOURCE_TYPE_JS_INCLUDE, true);
     if ($scriptItems != null && count($scriptItems)) {
         $scriptTags = '';
         foreach ($scriptItems as $resourceItem) {
             if (!is_object($resourceItem)) {
                 continue;
             }
             if (!xapp_property_exists($resourceItem, XAPP_RESOURCE_URL_RESOLVED)) {
                 $resourceItem = $this->resolveResource($resourceItem);
             }
             if (xapp_property_exists($resourceItem, XAPP_RESOURCE_URL_RESOLVED)) {
                 $url = xapp_property_get($resourceItem, XAPP_RESOURCE_URL_RESOLVED);
                 $scriptTag = "<script type='text/javascript' src='" . $url . "'></script>\n";
                 $scriptTags .= $scriptTag;
             }
         }
         if ($print) {
             echo $scriptTags;
         }
         return $scriptTags;
     }
     return '';
 }
Example #6
0
 /**
  * function to compile passed error message/object that has been received via the log
  * function. the function will return an array of compiled error messages ready to be logged
  * the default way. the function but will also return for every entry an object containing the
  * following data:
  * 1)   severity = contains the severity level
  * 2)   code = contains the error code
  * 3)   message = contains the already formatted log messages
  * 4)   object = contains an object of all log details as key => val pair
  *
  * @error 11604
  * @param null|string|Exception $e expects either a log message as string or exception object
  * @param null|int $c expects optional error code when passing log messages as string
  * @return null|object returns the compiled error object
  */
 protected function compile($e = null, $c = null)
 {
     if ($e !== null) {
         $message = "";
         $object = new stdClass();
         $led = xapp_get_option(self::ENTRY_DELIMITER, $this);
         $lld = xapp_get_option(self::LINE_DELIMITER, $this);
         $lfd = xapp_get_option(self::FIELD_DELIMITER, $this);
         $lve = xapp_get_option(self::VALUE_ENCLOSURE, $this);
         $hash = parent::hashify($e);
         if ($e instanceof Exception) {
             $severity = xapp_property_exists($e, 'severity') ? (int) $e->getSeverity() : self::LOG;
             $code = (int) $e->getCode();
             $message .= $led;
             $message .= $lve . ($object->timestamp = strftime(xapp_get_option(self::TIME_FORMAT, $this), time())) . $lve . $lfd;
             $message .= $lve . ($object->message = $e->getMessage()) . $lve . $lfd;
             $message .= $lve . ($object->file = $e->getFile()) . $lve . $lfd;
             $message .= $lve . ($object->line = $e->getLine()) . $lve . $lfd;
             $message .= $lve . ($object->code = $e->getCode()) . $lve . $lfd;
         } else {
             $severity = $c !== null && array_key_exists((int) $c, self::$_errorMap) ? self::$_errorMap[(int) $c] : XAPP_ERROR_ERROR;
             $code = $c !== null ? (int) $c : 0;
             $message .= $led;
             $message .= $lve . ($object->timestamp = strftime(xapp_get_option(self::TIME_FORMAT, $this), time())) . $lve . $lfd;
             $message .= $lve . ($object->message = trim($e)) . $lve . $lfd;
         }
         if ((bool) xapp_get_option(self::EXTENDED, $this)) {
             $message .= $lve . ($object->ip = (string) parent::getIp()) . $lve . $lfd;
             $message .= $lve . ($object->script_name = parent::getEnv('SCRIPT_NAME')) . $lve . $lfd;
             $message .= $lve . ($object->request_uri = parent::getEnv('REQUEST_URI')) . $lve . $lfd;
             $message .= $lve . ($object->http_user_agent = parent::getEnv('HTTP_USER_AGENT')) . $lve . $lfd;
             $message .= $lve . ($object->http_referer = parent::getEnv('HTTP_REFERER')) . $lve . $lfd;
         }
         if ((bool) xapp_get_option(self::STACK_TRACE, $this)) {
             if ($e instanceof Exception) {
                 $trace = $e->getTraceAsString();
             } else {
                 ob_start();
                 debug_print_backtrace();
                 $trace = ob_get_contents();
                 ob_end_clean();
             }
             $message .= $lve . ($object->trace = str_replace($lfd, " ", (string) $trace)) . $lve . $lfd;
         }
         if (!(bool) $this->pause) {
             return $this->stack[$hash] = (object) array('severity' => $severity, 'code' => $code, "message" => $message, "object" => $object);
         } else {
             return (object) array('severity' => $severity, 'code' => $code, "message" => $message, "object" => $object);
         }
     }
     return null;
 }
Example #7
0
 public function renderHTML($type = XAPP_RESOURCE_TYPE_HTML)
 {
     $html = '';
     $cssItems = $this->getResourcesByType($type, true);
     if ($cssItems != null && count($cssItems)) {
         foreach ($cssItems as $resourceItem) {
             if (!xapp_property_exists($resourceItem, XAPP_RESOURCE_URL_RESOLVED)) {
                 $resourceItem = $this->resolveResource($resourceItem);
             }
             if (xapp_property_exists($resourceItem, XAPP_RESOURCE_PATH_ABSOLUTE)) {
                 $path = xapp_property_get($resourceItem, XAPP_RESOURCE_PATH_ABSOLUTE);
                 if (file_exists($path)) {
                     $content = file_get_contents($path);
                     if ($content !== false) {
                         $keyValues = $this->registryToKeyValues(xapp_get_option(self::RELATIVE_REGISTRY_NAMESPACE, $this));
                         $content = $this->resolveRelative($content);
                         $html .= $content;
                     }
                 } else {
                 }
             } else {
             }
         }
     } else {
     }
     return $html;
 }
Example #8
0
 /**
  * map rpc faults by looking if faultMap exists a property that contains a mapping of
  * generic rpc fault codes to concrete server implementation fault codes
  *
  * @error 14215
  * @param int $code expects the fault code to map
  * @return int
  */
 protected function getFault($code)
 {
     if (xapp_property_exists($this, 'faultMap') && array_key_exists((int) $code, $this->faultMap)) {
         return (int) $this->faultMap[(int) $code];
     } else {
         return (int) $code;
     }
 }
Example #9
0
 /**
  * merge array properties of a subclass by iterating through all parent classes
  * looking for the array property of the same name return merge value as array.
  * this function will leave all properties untouched which are not of type array
  *
  * @error 10611
  * @param string|object $object expects instance of class or class name as string
  * @param string $property expects the property name as string
  * @param null|mixed $default expects default return value if property does not exist
  * @return array|mixed|null
  */
 public static final function mergeProperty($object, $property, $default = null)
 {
     $p = null;
     $tmp = array();
     if (Xapp_Reflection::hasProperty($object, $property)) {
         $p = Xapp_Reflection::propertyFactory($object, $property);
         if (is_array($p)) {
             $tmp = $p;
         } else {
             return $p;
         }
     }
     if (get_parent_class($object) !== false) {
         $class = $object;
         while ($class = get_parent_class($class)) {
             if (xapp_property_exists($class, $property)) {
                 $p = Xapp_Reflection::propertyFactory($class, $property);
                 if (is_array($p)) {
                     $tmp = array_merge($tmp, $p);
                 }
             }
         }
     }
     return !empty($tmp) ? $tmp : xapp_default($default);
 }