public function resize($src, $width = null, $save = true, $cache = true, $height = null, $preventCache = false, $icon = false, $forceHandler = '') { error_log('resize : ' . $src); XApp_Image_Utils::$cacheDir = xo_get(self::IMAGE_CACHE_DIR, $this); $errors = array(); if ($icon) { $operation = XApp_Image_Utils::OPERATION_ICONIFY; } else { $operation = XApp_Image_Utils::OPERATION_RESIZE; } $jobs = ' [ { "' . XApp_Image_Utils::IMAGE_OPERATION . '" : "' . $operation . '", "' . XApp_Image_Utils::OPERATION_OPTIONS . '" : { "' . XApp_Image_Utils::OPTION_WIDTH . '" : "' . $width . '", "' . XApp_Image_Utils::OPTION_HEIGHT . '" : "' . $height . '", "' . XApp_Image_Utils::OPTION_PREVENT_CACHE . '" : "' . $preventCache . '", "' . XApp_Image_Utils::OPTION_FORCE_IMAGE_HANDLER . '" : "' . $forceHandler . '" } } ] '; XApp_Image_Utils::execute($src, "", $jobs, $errors, $save, $cache); }
public function write($data) { $pass = null; if (xapp_has_option(self::CONF_PASSWORD)) { $pass = xapp_get_option(self::CONF_PASSWORD); } return XApp_Utils_JSONUtils::write_json(xo_get(self::CONF_FILE, $this), $data, 'json', true, $pass); }
protected function parseOptions($options) { if (xo_has(self::SCOPE_CONFIGS, $options) && xo_get(self::SCOPE_CONFIGS, $options)) { $scopeConfigs = xo_get(self::SCOPE_CONFIGS); $scopes = array(); foreach ($scopeConfigs as $scopeConfig) { $scopeConfig[XIDE_Scope::RELATIVE_REGISTRY_NAMESPACE] = xo_get(self::SCOPE_NS_PREFIX) . '.' . $scopeConfig[XIDE_Scope::SCOPE_NAME] . '.absolute'; $scopeConfig[XIDE_Scope::ABSOLUTE_REGISTRY_NAMESPACE] = xo_get(self::SCOPE_NS_PREFIX) . '.' . $scopeConfig[XIDE_Scope::SCOPE_NAME] . '.relative'; $scopes[] = new XIDE_Scope($scopeConfig); } xo_set(self::SCOPES, $scopes); } }
public function ls($which = '') { $path = realpath(xo_get(self::LOG_PATH, $this)); if (!file_exists($path)) { $this->log('log file path : ' . xo_get(self::LOG_PATH, $this) . ' doesnt exists'); return '{}'; } $result = array(); if (file_exists($path) && is_readable($path)) { $handle = fopen($path, "r"); if ($handle) { while (($line = fgets($handle)) !== false) { $result[] = json_decode($line); } } else { // error opening the file. } fclose($handle); } else { return '{}'; } return $result; }
public function registerAbsolute($key, $value) { $resourceNamespace = xo_get(self::ABSOLUTE_REGISTRY_NAMESPACE, $this); $registry = $this->getRegistry($resourceNamespace); $registry->set($key, $value, $resourceNamespace); }
/** * Logs user into session * @param $user * @param $pw * @return bool */ public function login($user, $pw) { $flags = xapp_get_option(self::FLAGS); if ($this->testFlag(XAPP_BOOTSTRAP_NEEDS_AUTHENTICATION, $flags) && xo_get(self::USER_CONF)) { self::loadJSONTools(); self::loadXAppJSONStoreClasses(); xapp_import('xapp.Store.Json.Json'); $userMgr = new XApp_UserManager(array(XApp_UserManager::STORE_CONF => array(XApp_Store_JSON::CONF_FILE => xapp_get_option(self::USER_CONF, $this)))); $userMgr->init(); $userMgr->initSessionStorage(); $errors = array(); $result = $userMgr->login($user, $pw, $errors); return $result; } return true; }
public function initStore($force = false) { //skip if ($force === false && $this->_store) { return true; } //Try with store data first if (xo_has(self::STORE_DATA) && is_object(xo_get(self::STORE_DATA))) { $this->initWithData(xo_get(self::STORE_DATA)); return true; } //No store data provided from outside, use the store class if (xo_has(self::STORE_CLASS) && xo_get(self::STORE_CLASS)) { $_storeClz = xo_get(self::STORE_CLASS); //check its an instance already : if (is_object($_storeClz)) { $this->_store = $_storeClz; return true; } elseif (is_string($_storeClz) && class_exists($_storeClz)) { $_ctrArgs = xo_has(self::STORE_CONF) ? xo_get(self::STORE_CONF) : array(); $this->_store = new $_storeClz($_ctrArgs); return true; } } return false; }
public function setup() { $this->loadMin(); /*** * Get run-time configuration, there is 'debug' and 'release'. For both cases there are * different resources to load. */ $XAPP_RUN_TIME_CONFIGURATION = XApp_Service_Entry_Utils::getRunTimeConfiguration(); /*** * Now include all xapp stuff */ //pull in registry of xapp core framework XApp_Service_Entry_Utils::includeXAppRegistry(); //pull in parts of xapp json framework self::loadXAppJSONStoreClasses(); //pull in json utils (to read client app's resource configuration self::loadJSONTools(); //some debugging tools self::loadDebuggingTools(); //pull in legacy client app renderer xapp_import('xapp.app.Renderer'); //pull in xapp resource renderer xapp_import('xapp.Resource.Renderer'); //pull in custom resource Renderer xapp_import('xapp.xide.Resource.Renderer'); /*** * Prepare resource renderer */ //clients resource config path $XAPP_RESOURCE_CONFIG_PATH = '' . xapp_get_option(self::APPDIR, $this) . DIRECTORY_SEPARATOR; if ($XAPP_RUN_TIME_CONFIGURATION === 'debug') { $XAPP_RESOURCE_CONFIG_PATH .= 'lib' . DIRECTORY_SEPARATOR . xapp_get_option(self::APP_NAME, $this) . DIRECTORY_SEPARATOR . 'resources-' . $XAPP_RUN_TIME_CONFIGURATION . xapp_get_option(self::RESOURCE_CONFIG_SUFFIX, $this) . '.json'; } else { if ($XAPP_RUN_TIME_CONFIGURATION === 'release') { $XAPP_RESOURCE_CONFIG_PATH .= DIRECTORY_SEPARATOR . xapp_get_option(self::APP_FOLDER, $this) . DIRECTORY_SEPARATOR . xapp_get_option(self::APP_NAME, $this) . DIRECTORY_SEPARATOR . 'resources-' . $XAPP_RUN_TIME_CONFIGURATION . xapp_get_option(self::RESOURCE_CONFIG_SUFFIX, $this) . '.json'; } } if (!file_exists($XAPP_RESOURCE_CONFIG_PATH)) { $this->log('have no client resource configuration at ' . $XAPP_RESOURCE_CONFIG_PATH . ', aborting'); } //load resource configuration $resources = (object) XApp_Utils_JSONUtils::read_json($XAPP_RESOURCE_CONFIG_PATH, 'json', false, true); $pluginResources = null; $resourceRendererOptions = array(XApp_Resource_Renderer::DOC_ROOT => xapp_get_option(self::DOC_ROOT, $this), XApp_Resource_Renderer::DOC_ROOT_PATH => xapp_get_option(self::APPDIR, $this), XApp_Resource_Renderer::RESOURCES_DATA => $resources); $clz = xapp_get_option(self::RESOURCE_RENDERER_CLZ, $this); $xappResourceRenderer = new $clz($resourceRendererOptions); $xappResourceRenderer->registerDefault(); if (xapp_has_option(self::RELATIVE_VARIABLES)) { $rVariables = xapp_get_option(self::RELATIVE_VARIABLES, $this); foreach ($rVariables as $variable => $value) { $xappResourceRenderer->registerRelative($variable, $value); } } //determine Dojo package paths and store them as JSON serialized resource variable $XAPP_DOJO_PACKAGE_LOCATION_PREFIX = $xappResourceRenderer->resolveRelative('%PLUGIN_PACKAGE_ROOT_URL%'); $javascriptPlugins = $xappResourceRenderer->getJavascriptPlugins(); $dojoPackages = $this->getDojoPackages($XAPP_DOJO_PACKAGE_LOCATION_PREFIX, $javascriptPlugins, XApp_Service_Entry_Utils::isDebug()); $xappResourceRenderer->registerRelative('XAPP_PLUGIN_RESOURCES', $dojoPackages['plugins']); $xappResourceRenderer->registerRelative('DOJOPACKAGES', $dojoPackages['packages']); /**** * Build XApp-App-Renderer - Config */ $opt = array(XApp_App_Renderer::DOC_ROOT_PATH => xapp_get_option(self::APPDIR, $this), XApp_App_Renderer::DOC_ROOT => xapp_get_option(self::DOC_ROOT, $this), XApp_App_Renderer::APP_NAME => xapp_get_option(self::APP_NAME, $this), XApp_App_Renderer::APP_FOLDER => xapp_get_option(self::APP_FOLDER, $this), XApp_App_Renderer::CONFIG_NAME => $XAPP_RUN_TIME_CONFIGURATION, XApp_App_Renderer::SERVICE_URL => xapp_get_option(self::SERVICE, $this), XApp_App_Renderer::RESOURCE_RENDERER => $xappResourceRenderer); $this->appRenderer = new XApp_App_Renderer($opt); $this->resourceRenderer = xo_get(XApp_App_Renderer::RESOURCE_RENDERER, $this->appRenderer); }
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; } }
public function write($data) { return XApp_Utils_JSONUtils::write_json(xo_get(self::CONF_FILE, $this), $data, 'json', true); }
public function getResource($name, $enabledOnly = true) { $resourceData = xapp_get_option(self::RESOURCES_DATA, $this); if ($resourceData !== null) { $resourceItem = (array) xapp_object_find($resourceData, '.items', array('class=' . 'cmx.types.Resource', 'name=' . $name, 'type=' . xo_get(self::RESOURCES_TYPE, $this), 'enabled=' . $enabledOnly)); if (count($resourceItem) && is_object($resourceItem[0])) { return $resourceItem[0]; } } return null; }
/** * @return mixed|null */ public function getResources() { return xo_get(self::RESOURCES_DATA, $this); }
public function init() { if ($this->workbench == null) { $siteConfigPath = xo_get(self::SITE_CONFIG_DIRECTORY, $this) . DIRECTORY_SEPARATOR; $this->workbench = $this->createWorkbench($siteConfigPath); } if ($this->workbench->userInfo == null) { $this->workbench->userInfo = $this->createUserInfo(xo_get(self::WORKBENCH_USER, $this)); } }
private function parseOptions($options) { if ($this->_object == null && $options && xo_has(self::MANAGED_CLASS, $options)) { //the class $_managedClass = xo_get(self::MANAGED_CLASS, $options); //check its an instance already : if (is_object($_managedClass)) { $this->_object = $_managedClass; } elseif (is_string($_managedClass) && class_exists($_managedClass)) { $baseClasses = xo_has(self::MANAGED_CLASS_BASE_CLASSES, $options) ? xo_get(self::MANAGED_CLASS_BASE_CLASSES, $options) : null; $_ctrArgs = xo_has(self::MANAGED_CLASS_OPTIONS, $options) ? xo_get(self::MANAGED_CLASS_OPTIONS, $options) : array(); //no additional base classes : if ($baseClasses == null || !count($baseClasses)) { $this->_object = new $_managedClass($_ctrArgs); } else { //mixin new base classes xapp_import('xapp.Commons.ClassMixer'); $newClassName = "NEW_" . $_managedClass; XApp_ClassMixer::create_mixed_class($newClassName, $_managedClass, $baseClasses); $this->_object = new $newClassName($_ctrArgs); } } if ($this->_object) { if (method_exists($this->_object, 'init')) { $this->_object->init(); } } } }
protected function cachePath() { return xo_get(self::PATH, $this) . xo_get(self::SUBPATH); }
public static function run($cmd, array $args = array(), $return = null, $options = array()) { self::_escapeArguments($args); error_log("run " . $cmd); if (!xo_has(self::OPTION_BACKGROUND, $options)) { $options[self::OPTION_BACKGROUND] = true; } $command = $cmd . " " . implode(" ", $args); $os = PHP_OS; $isWindows = false; switch ($os) { case "WINNT": $isWindows = true; $command = str_replace('/', '\\', $command); } if (xo_has(self::OPTION_STDOUT_TO, $options)) { $command .= " >> " . xo_get(self::OPTION_STDOUT_TO, $options); } if (xo_has(self::OPTION_WORKING_PATH, $options)) { $working_path = xo_get(self::OPTION_WORKING_PATH, $options); if (!$isWindows) { $command = "cd {$working_path} ; " . $command; } else { if (xo_get(self::OPTION_BACKGROUND, $options)) { $command = "cd {$working_path} & start " . $command; } else { $command = "cd {$working_path} & " . $command; } } } if (xo_get(self::OPTION_BACKGROUND, $options)) { if (xo_get(self::OPTION_PRE_DELAY, $options)) { // Add 1 second delay $command = "sleep 1 ; " . $command; } if (!$isWindows) { $command .= " & "; ignore_user_abort(true); register_shutdown_function(array(new self(), '__exec'), $command); $result = "Postponed: {$command}"; } else { ignore_user_abort(true); register_shutdown_function(array(new self(), '__exec'), $command); $result = "Postponed: {$command}"; } } else { $result = self::__exec($command); } return $result; }