本文整理汇总了PHP中Component::decodeComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP Component::decodeComponent方法的具体用法?PHP Component::decodeComponent怎么用?PHP Component::decodeComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Component
的用法示例。
在下文中一共展示了Component::decodeComponent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadStaticConfig
public static function loadStaticConfig($pref, $pre, $path = '', $file = null)
{
CConfig::$onload = true;
if ($path != '') {
$path .= '/';
}
$path = str_replace("\\", '/', $path);
$ff = $path . $pre . CConfig::$CONF_FILE;
if ($file != null) {
$ff = $path . $file;
}
if (file_exists($ff)) {
// file was found, create a Component object from file content
$com = Component::decodeComponent(file_get_contents($ff));
$com->setPrefix($pref);
// check if the links
// know their prefixes
$conf = $com;
$links = $conf->getLinks();
// always been an array
if (!is_array($links)) {
$links = array($links);
}
$changed = false;
foreach ($links as &$link) {
// if a link has no prefix, we have to ask the link target
// for the prefix list
if ($link->getPrefix() === null) {
$result = Request::get($link->getAddress() . '/control', array(), '');
if ($result['status'] == 200) {
// the link target has send its component definition,
// so that we can remember this
$changed = true;
$obj = Component::decodeComponent($result['content']);
$link->setPrefix($obj->getPrefix());
$link->setClassFile($obj->getClassFile());
$link->setClassName($obj->getClassName());
$link->setLocalPath($obj->getLocalPath());
}
}
}
// if any new prefix was found, we have to store the link definitions
if ($changed) {
$conf->setLinks($links);
CConfig::saveConfigGlobal($pre, Component::encodeComponent($conf), substr($path, 0, -1), $file);
$com = $conf;
}
CConfig::$onload = false;
return $com;
} else {
// can't find the file, create an empty object
$com = new Component();
$com->setPrefix($pref);
CConfig::$onload = false;
return $com;
}
CConfig::$onload = false;
}
示例2: install
public static function install($data, &$fail, &$errno, &$error)
{
$fail = false;
$url = $data['PL']['init'];
$components = array();
// inits all components
$result = Request::get($data['PL']['url'] . '/' . $url . '/definition/send', array(), '');
//echo $result['content'];
if (isset($result['content']) && isset($result['status'])) {
// component routers
$router = array();
$results = Component::decodeComponent($result['content']);
$results = Installation::orderBy(json_decode(Component::encodeComponent($results), true), 'name', SORT_ASC);
$results = Component::decodeComponent(json_encode($results));
if (!is_array($results)) {
$results = array($results);
}
if (count($results) == 0) {
$fail = true;
$error = Language::Get('components', 'noComponents');
}
foreach ($results as $res) {
$components[$res->getName()] = array();
$components[$res->getName()]['init'] = $res;
}
// get component definitions from database
$result4 = Request::get($data['PL']['url'] . '/' . $url . '/definition', array(), '');
if (isset($result4['content']) && isset($result4['status']) && $result4['status'] === 200) {
$definitions = Component::decodeComponent($result4['content']);
if (!is_array($definitions)) {
$definitions = array($definitions);
}
if (count($definitions) == 0) {
$fail = true;
$error = Language::Get('components', 'noDefinitions');
}
$result2 = new Request_MultiRequest();
$result3 = new Request_MultiRequest();
$tempDef = array();
foreach ($definitions as $definition) {
if (strpos($definition->getAddress() . '/', $data['PL']['urlExtern'] . '/') === false) {
continue;
}
$components[$definition->getName()]['definition'] = $definition;
$tempDef[] = $definition;
$request = Request_CreateRequest::createGet($definition->getAddress() . '/info/commands', array(), '');
$result2->addRequest($request);
$request = Request_CreateRequest::createGet($definition->getAddress() . '/info/links', array(), '');
$result3->addRequest($request);
}
$definitions = $tempDef;
$result2 = $result2->run();
$result3 = $result3->run();
foreach ($results as $res) {
if ($res === null) {
$fail = true;
continue;
}
$countLinks = 0;
$resultCounter = -1;
foreach ($definitions as $definition) {
//if (strpos($definition->getAddress().'/', $data['PL']['urlExtern'].'/')===false) continue;
$resultCounter++;
if ($definition->getId() === $res->getId()) {
$links = $definition->getLinks();
$links = Installation::orderBy(json_decode(Link::encodeLink($links), true), 'name', SORT_ASC);
$links = Link::decodeLink(json_encode($links));
if (!is_array($links)) {
$links = array($links);
}
$components[$definition->getName()]['links'] = $links;
if (isset($result2[$resultCounter]['content']) && isset($result2[$resultCounter]['status']) && $result2[$resultCounter]['status'] === 200) {
$commands = json_decode($result2[$resultCounter]['content'], true);
if ($commands !== null) {
$components[$definition->getName()]['commands'] = $commands;
}
}
if (isset($result3[$resultCounter]['content']) && isset($result3[$resultCounter]['status']) && $result3[$resultCounter]['status'] === 200) {
$calls = json_decode($result3[$resultCounter]['content'], true);
$components[$definition->getName()]['call'] = $calls;
}
break;
}
}
if ($res->getStatus() !== 201) {
$fail = true;
}
}
} else {
$fail = true;
$error = Language::Get('components', 'noDefinitions');
}
} else {
$fail = true;
$error = Language::Get('components', 'operationFailed');
}
if (isset($result['status']) && $result['status'] !== 200) {
$fail = true;
$error = Language::Get('components', 'operationFailed');
$errno = $result['status'];
//.........这里部分代码省略.........
示例3: sendComponentDefinitions
/**
* Initializes all components, with the data, which can be found in database.
*/
public function sendComponentDefinitions()
{
$this->_app->response->setStatus(200);
// starts a query
ob_start();
eval("?>" . file_get_contents(dirname(__FILE__) . '/Sql/GetComponentDefinitions.sql'));
$sql = ob_get_contents();
ob_end_clean();
$result = DBRequest::request($sql, false, parse_ini_file(dirname(__FILE__) . '/config.ini', TRUE));
// checks the correctness of the query
if ((!isset($result['errno']) || !$result['errno']) && $result['content']) {
$data = DBJson::getRows($result['content']);
$Components = DBJson::getObjectsByAttributes($data, Component::getDBPrimaryKey(), Component::getDBConvert());
$Links = DBJson::getObjectsByAttributes($data, Link::getDBPrimaryKey(), Link::getDBConvert());
$objects = DBJson::concatResultObjectLists($data, $Components, Component::getDBPrimaryKey(), Component::getDBConvert()['CO_links'], $Links, Link::getDBPrimaryKey());
$request = new Request_MultiRequest();
$data = parse_ini_file(dirname(__FILE__) . '/config.ini', TRUE);
$tempObjects = array();
foreach ($objects as $object) {
$object = Component::decodeComponent(json_encode($object));
// prüfen, welche Komponente auf diesem Server ist
if (strpos($object->getAddress() . '/', $data['PL']['urlExtern'] . '/') === false) {
continue;
}
$object->setAddress($data['PL']['url'] . substr($object->getAddress(), strlen($data['PL']['urlExtern'])));
$links = $object->getLinks();
foreach ($links as &$link) {
if (strpos($link->getAddress() . '/', $data['PL']['urlExtern'] . '/') === false) {
continue;
}
$link->setAddress($data['PL']['url'] . substr($link->getAddress(), strlen($data['PL']['urlExtern'])));
}
$object->setLinks($links);
$result = Request_CreateRequest::createPost($object->getAddress() . '/control', array(), Component::encodeComponent($object));
$tempObjects[] = $object;
$request->addRequest($result);
}
$results = $request->run();
$objects = $tempObjects;
$i = 0;
$res = array();
foreach ($objects as $object) {
$object = Component::decodeComponent(Component::encodeComponent($object));
$result = $results[$i++];
$newObject = new Component();
$newObject->setId($object->getId());
$newObject->setName($object->getName());
$newObject->setAddress($object->getAddress());
$newObject->setDef($object->getDef());
$newObject->setStatus($result['status']);
$res[] = $newObject;
if ($result['status'] != 201) {
$add = '';
$this->_app->response->setStatus(409);
if (isset($result['content'])) {
$add = $result['content'];
}
Logger::Log($result['status'] . '--' . $object->getName() . '--' . $object->getAddress() . "\n" . $add . "\n", LogLevel::ERROR);
}
}
$this->_app->response->setBody(json_encode($res));
} else {
Logger::Log('GET SendComponentDefinitions failed', LogLevel::ERROR);
$this->_app->response->setStatus(isset($result['status']) ? $result['status'] : 409);
}
}
示例4: __construct
/**
* the constructor
*
* @param $data an assoc array with the object informations
*/
public function __construct($data = array())
{
if ($data === null) {
$data = array();
}
foreach ($data as $key => $value) {
if (isset($key)) {
if ($key == 'attachment') {
$this->{$key} = Attachment::decodeAttachment($value, false);
} else {
if ($key == 'workFiles') {
$this->{$key} = Attachment::decodeAttachment($value, false);
} else {
if ($key == 'target') {
$this->{$key} = Component::decodeComponent($value, false);
} else {
if ($key == 'submission') {
$this->{$key} = Submission::decodeSubmission($value, false);
} else {
if ($key == 'rawSubmission') {
$this->{$key} = Submission::decodeSubmission($value, false);
} else {
if ($key == 'marking') {
$this->{$key} = Marking::decodeMarking($value, false);
} else {
if ($key == 'exercise') {
$this->{$key} = Exercise::decodeExercise($value, false);
} else {
$func = 'set' . strtoupper($key[0]) . substr($key, 1);
$methodVariable = array($this, $func);
if (is_callable($methodVariable)) {
$this->{$func}($value);
} else {
$this->{$key} = $value;
}
}
}
}
}
}
}
}
}
}
}