/** * @throws \Exception */ private function postProcess() { foreach ($this->config->PostProcessors as $processor) { if (Classes::validateProcessor($processor)) { $process = Factory::build($processor); $process->process($this); } else { throw new \Exception('Mongular: Attempt to access invalid processor ' . $this->request); } } }
function fntDeletaClassePergunta() { try { $t = new Classes(); $t->setCodigo(base64_decode($_POST['id'])); if ($t->DeletarClassePergunta()) { echo Comuns::Idioma("@lng[Classificação de exercício excluída com sucesso.]"); } else { echo Comuns::Idioma("@lng[Não foi possível excluír a classificação de exercícios.] " . $t->getErro()); } } catch (Exception $ex) { echo $ex->getMessage(); } }
/** * load all app files for given path and build.xml document * * @param string $path app base path * @param DOMDocument $build build.xml * @return boolean */ private function _doBuild($path, DOMDocument $build) { $Classes = Classes::get(); $x = new DOMXPath($build); $app = $x->query('/build/app'); if ($app->length != 1) { throw new PException('App error!'); } $app = $app->item(0); if (!$app->hasAttribute('name')) { throw new PException('App name error!'); } $this->_apps[$app->getAttribute('name')] = $build; $files = $x->query('/build/files/file'); foreach ($files as $file) { if ($file->hasAttribute('class')) { $Classes->addClass($file->getAttribute('class'), $path . $file->nodeValue); continue; } if ($file->hasAttribute('include')) { if (!file_exists($path . $file->nodeValue)) { continue; } $this->_includes[] = $path . $file->nodeValue; continue; } } return true; }
public function showParent() { $data = array(); $loginid = Session::get('user')->id; $collegeid = Session::get('user')->collegeid; $flag = Session::get('user')->flag; $tb = ""; if ($flag == 1) { $tb = "Admin"; } else { if ($flag == 2) { $tb = "Teacher"; } else { if ($flag == 3) { $tb = "Student"; } else { $tb = "Staff"; } } } $dt = $tb::where('loginid', '=', $loginid)->first(); $data['name'] = $dt->name; $data['pic'] = $dt->profilepic; $data['id'] = $loginid; $colid = Session::get('user')->collegeid; //$colid = "bt123"; $classes = Classes::where('collegeid', '=', $colid)->get(); $data['class'] = []; $i = 0; for ($i = 0; $i < sizeof($classes); $i++) { $data['class'][$i]['id'] = $classes[$i]->id; $data['class'][$i]['name'] = $classes[$i]->classname; } return View::make('pages.parent', array('data' => $data, 'flag' => $flag)); }
public function go() { $this->setViewTemplate('classmembership.tpl'); $user_id = $_GET['id']; $user = User::getUser($user_id); if (isset($_POST['submit'])) { $class_id = $_POST['class_id']; if (ClassMemberships::doesMembershipExist($user_id, $class_id)) { $this->addErrorMessage("User is already a member of this class"); } else { ClassMemberships::addMembership($user_id, $class_id); $this->addSuccessMessage("User has been added to the class succesfully"); } } elseif (isset($_GET['action']) && $_GET['action'] == "del") { $class_id = $_GET['class_id']; ClassMemberships::deleteMembership($user_id, $class_id); $this->addSuccessMessage("User has been deleted from the class succesfully"); } $class_memberships = ClassMemberships::getMembershipsOfUser($user_id); $classes = Classes::getAllClasses(); $this->addToView('classes', $classes); $this->addToView('class_memberships', $class_memberships); $this->addToView('user', $user); $this->setViewTemplate('classmembership.tpl'); $this->generateView(); }
/** * The singleton method * * alias for Classes::get() * * @return Classes */ public static function singleton() { if (!isset(self::$_instance)) { $c = __CLASS__; self::$_instance = new $c(); } return self::$_instance; }
/** * Api for getting Classes by Stream Id */ public function postGetClassesFromStreamId() { $stream_id = Input::get('stream_id'); $school_id = Sentry::getUser()->school_id; $classes = Classes::where('streams_id', '=', $stream_id)->where('school_id', '=', $school_id)->get(); $response = array('status' => 'success', 'result' => array('classes' => $classes)); return Response::json($response); }
protected static function getDataFormatted($data) { $personFormatted = array(); if (is_array($data)) { foreach ($data as $k => $person) { $personFormatted[$k] = Classes::formatData($person); } } return $personFormatted; }
public static function syncClasses() { $teacher = Teacher::find(self::$lastTeacherId); try { $classes = Classes::where('teacher_id', '=', $teacher->teacher_id)->update(array('teacher_id' => 0)); if ($teacher->classes_id > 0) { $classes = Classes::find($teacher->classes_id)->update(array('teacher_id' => $teacher->teacher_id)); } } catch (Exception $e) { } }
public static function getMembershipsOfUserObjects($user_id) { $classes = self::getMembershipsOfUser($user_id); $object_array = array(); foreach ($classes as $class) { $temp = array('id' => $class['class_id'], 'name' => $class['name']); $obj = Classes::instantiate($temp); array_push($object_array, $obj); } return $object_array; }
protected function _is($type, $file) { $file = $this->rpath($file); $validType = $this->methods[$type] ?? NULL; if (!function_exists($validType) || $validType === NULL) { die(getErrorMessage('Error', 'undefinedFunction', Classes::onlyName(get_called_class()) . '::' . $type . '()')); } if ($validType($file)) { return true; } return false; }
public function postSaveTimetable() { if (Request::ajax()) { $class = Classes::find(Input::get('id')); $times = Input::get('time'); $times = substr($times, 1, -1); $class->classtimes = $times; if ($class->save()) { return Response::json('success', 200); } } }
function Main() { $cod = $_POST["c"]; $des = urldecode($_POST["d"]); $com = urldecode($_POST["com"]); header('Content-Type: text/html; charset=iso-8859-1'); try { $c = new Classes(); if ($cod != "") { $c->setCodigo($cod); } if ($des != "") { $c->setDescricao($des); } if ($com != "") { $c->setComplemento($com); } if ($cod == "") { if ($c->AdicionarClassePergunta()) { echo "GRAVADO"; } } else { if ($c->AtualizaClassePerguntas()) { echo "GRAVADO"; } } } catch (Exception $ex) { echo $ex->getMessage(); } }
public static function GetClass($ClassName) { $Statement = Classes::$DBConnection->prepare('SELECT * FROM classes WHERE class_name = :class'); $Statement->bindParam(':class', $ClassName); $Statement->execute(); $Result = $Statement->fetch(PDO::FETCH_ASSOC); $Result['class_full_name'] = Classes::$TM->GetConfigVars('Class_' . str_replace('-', '_', ucfirst($Result['class_name']))); $Result['indicator_first_type'] = Classes::$TM->GetConfigVars($Result['indicator_first_type']); $Result['indicator_second_type'] = Classes::$TM->GetConfigVars($Result['indicator_second_type']); $Result['can_be_picked_by'] = Classes::RaceClassMatch($ClassName); $Result['abilities'] = Classes::GetAbilities($ClassName); return $Result; }
/** * @throws \Exception */ public function __construct() { if (isset($_GET['q'])) { $parameters = explode('/', $_GET['q']); $this->request = Classes::getControllerRoute(array_shift($parameters)); if (!$this->request) { throw new \Exception('Mongular: Request not valid.'); } $this->values = $parameters; $this->query_parameters = Headers::get('QueryParameters'); } else { throw new \Exception('Mongular: No valid parameters passed.'); } }
/** * 取得班級資料(提供給select用) */ public static function getClassesSelectArray($hasNone = true) { if ($hasNone == true) { $classesSelectArray[0] = '無'; } $classes = Classes::orderBy('classes_name')->get(); foreach ($classes as $classItem) { $string = $classItem->classes_name; if ($teacher = $classItem->teacher) { $string .= '(' . $teacher->teacher_name . ')'; } $classesSelectArray[$classItem->classes_id] = $string; } return $classesSelectArray; }
public function go() { $this->setViewTemplate("rankings.tpl"); if ($this->isLoggedIn()) { $username = $this->getLoggedInUser(); if (Session::isAdmin() || Session::isTeacher()) { $classes = Classes::getAllClasses(); } else { $user = User::findByUserName($username); $classes = ClassMemberships::getMembershipsOfUserObjects($user->id); } $this->addToView('classes', $classes); } if (!isset($_GET["class"]) || $_GET["class"] == "") { $rankings = ChallengeAttempts::getUniversalRankings(); } else { $class_id = $_GET["class"]; $class = Classes::getClass($class_id); if (!$class) { $this->addErrorMessage("Not a valid class"); return $this->generateView(); } else { $rankings = ChallengeAttempts::getClasswiseRankings($class_id); } } $final = array(); $counter = 1; $rank = 1; $rankcount = 1; $prevcount = null; foreach ($rankings as $ranking) { if ($counter != 1 && $prevcount == $ranking['count']) { $rank = $rankcount; $rankcount++; } if ($counter != 1 && $prevcount != $ranking['count']) { $rankcount++; $rank = $rankcount; } $prevcount = $ranking['count']; $counter++; $temp = array('user_id' => $ranking['user_id'], 'time' => $ranking['time'], 'count' => $ranking['count'], 'username' => $ranking['username'], 'rank' => $rank); array_push($final, $temp); } $this->addToView('rankings', $final); return $this->generateView(); }
public function loadModules() { if (!isset($this->_moduleDir)) { return false; } $Classes = Classes::get(); $dir = dir($this->_moduleDir); while ($d = $dir->read()) { if ($d == '.' || $d == '..') { continue; } $dp = $dir->path . '/' . $d; if (!is_dir($dp)) { continue; } if (!file_exists($dp . '/module.xml')) { continue; } $d = @DOMDocument::load($dp . '/module.xml'); if (!$d) { continue; } $d->XPath = new DOMXPath($d); $moduleName = $d->XPath->query('/module/moduleName'); if ($moduleName->length != 1) { throw new PException('Module load error in "' . $dp . '/module.xml"!'); } $moduleFiles = $d->XPath->query('/module/moduleFiles'); if ($moduleFiles->length != 1) { throw new PException('Module load error in "' . $dp . '/module.xml"!'); } foreach ($moduleFiles->item(0)->childNodes as $node) { if (!is_a($node, 'DOMElement')) { continue; } foreach ($node->childNodes as $file) { if (!is_a($file, 'DOMElement')) { continue; } if ($file->hasAttribute('class')) { $Classes->addClass($file->getAttribute('class'), $dp . '/' . $node->nodeName . '/' . $file->nodeValue); } } } $this->_modules[$moduleName->item(0)->nodeValue] = $d; } }
function draw() { global $display; $keyword = Url::get('keyword'); if (!$keyword) { $keyword = Url::get('keyword_mobile'); } $order_str = ''; $where_class = ' WHERE `name` LIKE "%' . addslashes($keyword) . '%" AND is_active = 1 '; $where_subject = ' WHERE `name` LIKE "%' . addslashes($keyword) . '%" '; $where_lesson = ' WHERE `name` LIKE "%' . addslashes($keyword) . '%" '; $per_page = 21; $list_class = Classes::get_collection(' LIMIT 0, ' . $per_page, $where_class, $order_str); $list_subject = Subjects::get_collection(' LIMIT 0, ' . $per_page, $where_subject, $order_str); $list_lesson = Lessons::get_collection(' LIMIT 0, ' . $per_page, $where_lesson, $order_str); $current_url = strtok($_SERVER['REQUEST_URI'], '&'); if (count($list_class) == $per_page) { $is_next_class = 1; array_pop($list_class); } else { $is_next_class = 0; } if (count($list_subject) == $per_page) { $is_next_subject = 1; array_pop($list_subject); } else { $is_next_subject = 0; } if (count($list_lesson) == $per_page) { $is_next_lesson = 1; array_pop($list_lesson); } else { $is_next_lesson = 0; } $display->add('current_url', $current_url); $display->add('is_next_class', $is_next_class); $display->add('is_next_subject', $is_next_subject); $display->add('is_next_lesson', $is_next_lesson); $display->add('list_class', $list_class); $display->add('list_subject', $list_subject); $display->add('list_lesson', $list_lesson); $display->add('keyword_view', htmlspecialchars($keyword)); $display->add('keyword', $keyword); $display->add('keyword_mobile', $keyword); // Output $display->output("list"); }
public function go() { $this->setViewTemplate('showclass.tpl'); if (!isset($_GET['id'])) { header('Location: ' . SOURCE_ROOT_PATH . "admin/pages/manageclass.php"); } $class_id = $_GET['id']; if (isset($_POST['submit'])) { if (isset($_POST['updateclassname'])) { if ($_POST['updateclassname'] == '') { header('Location: ' . SOURCE_ROOT_PATH . "admin/pages/showclass.php?id={$class_id}&action=editerror"); } else { $this->name = $_POST['updateclassname']; Classes::updateClassName($class_id, $this->name); header('Location: ' . SOURCE_ROOT_PATH . "admin/pages/showclass.php?id={$class_id}&action=editsuccess"); } } } if (isset($_GET['action']) && $_GET['action'] == "editerror") { $this->addErrorMessage("Class name should not be empty"); } if (isset($_GET['action']) && $_GET['action'] == "editsuccess") { $this->addSuccessMessage("Class name updated successfully"); } if (isset($_GET['action']) && $_GET['action'] == "del") { if (isset($_GET['uid'])) { ClassMemberships::deleteMembership($_GET['uid'], $class_id); $this->addSuccessMessage("User has been deleted from the class succesfully"); } else { if (isset($_GET['cid'])) { ClassChallenges::deleteMembership($_GET['cid'], $class_id); $this->addSuccessMessage("Challenge has been deleted from the class succesfully"); } } } $class = Classes::getClass($class_id); $user_members = ClassMemberships::getAllMemberships($class_id); $challenges_assigned = ClassChallenges::getAllMemberships($class_id); $this->addToView('class', $class); $this->addToView('users', $user_members); $this->addToView('challenges', $challenges_assigned); return $this->generateView(); }
public function processCall($payload) { $this->checkPermutationStrongName(); try { $rpcRequest = RPC::decodeRequest($payload, Classes::classOf($this->delegate), $this); $this->onAfterRequestDeserialized($rpcRequest); return RPC::invokeAndEncodeResponse($this->delegate, $rpcRequest->getMethod(), $rpcRequest->getParameters(), $rpcRequest->getSerializationPolicy(), $rpcRequest->getFlags()); } catch (IncompatibleRemoteServiceException $ex) { echo $ex; /*log( "An IncompatibleRemoteServiceException was thrown while processing this call.", ex); */ return RPC::encodeResponseForFailure(null, $ex); } catch (RpcTokenException $ex) { //log("An RpcTokenException was thrown while processing this call.", //tokenException); return RPC::encodeResponseForFailure(null, $ex); } }
function change_item() { $filter_type = Url::get('filter_type'); if ($filter_type == 1) { $result = Lessons::get_collection_with_join(null); } if ($filter_type == 0) { $result = Classes::get_collection_with_join(null); } $html = ""; if ($result) { foreach ($result as $row) { if ($row['name'] != '' && $row['subject_type'] == 1) { $html .= '<option value="' . $row['id'] . '">' . $row['id'] . '. ' . $row['name'] . '</option>'; } } } echo $html; exit; }
public function go() { $this->setViewTemplate('addclass.tpl'); if (isset($_POST['submit'])) { if ($_POST['classname'] == '') { $this->addErrorMessage("Name of the class should not be empty"); } else { // $this->created_by= Session::getLoggedInUser(); $classname = $_POST['classname']; $date_created = date("Y-m-d H:i:s"); if (Classes::doesClassExist($classname)) { $this->addErrorMessage(" This Classname already exists"); } else { Classes::addClass($classname, $date_created); header('Location: ' . SOURCE_ROOT_PATH . "admin/pages/manageclass.php?source=addclass"); } } } $this->generateView(); }
function initializeGlobalState() { // load data in base.xml $base_xml_xpath = $this->loadBaseXML(); $this->simulateMissingFunctions(); if (!($settings = $this->loadConfiguration())) { // ini files are not set.. // launch repair program!! die('STOP'); } $this->initSession($settings); // initialize classes autoloading require_once SCRIPT_BASE . 'roxlauncher/autoload.plug.php'; require_once SCRIPT_BASE . 'roxlauncher/classloader.php'; $class_loader = new ClassLoader(); AutoloadPlug::setCallback(array($class_loader, 'autoload')); spl_autoload_register(array('AutoloadPlug', 'autoload'), true, true); $this->loadRoxClasses($class_loader); $this->loadPTClasses($class_loader); require_once SCRIPT_BASE . 'pthacks/classes.php'; Classes::set($class_loader); // ??? PSurveillance::get(); // $this->loadRoxClasses($class_loader); $this->loadPModules($class_loader); $this->loadPApps($class_loader); // TODO: fill with class names.. $this->classes = array(); // these two may actually kill the process $this->loadDefaults($base_xml_xpath, $settings); $this->checkEnvironment(); // initialize global vars and global registry $this->_initPVars($settings); $this->_initBWGlobals($settings); PSurveillance::setPoint('base_loaded'); // print_r($class_loader); }
function Main() { // Leitura do template $tpl = file_get_contents("tpl/classes.html"); // Número de registros a exibir por página $limite = 10; $pagina = isset($_GET['pag']) ? $_GET['pag'] : 1; // Instancia a classe Pergunta $c = new Classes(); // Se vier a instrução de inserir uma pergunta, faz isso $descricao = isset($_POST['txtDescricao']) ? $_POST['txtDescricao'] : null; if ($descricao) { $c->setDescricao($descricao); if (isset($_POST['txtComplemento'])) { $c->setComplemento($_POST['txtComplemento']); } $c->adicionar(); } // Começa a listagem das perguntas já cadastradas // Retorna uma lista das perguntas cadastradas $lista = $c->listarclasses($pagina, $limite); if ($lista != 0 && mysql_num_rows($lista) > 0) { // Se tem perguntas cadastradas, começa a montar a lista $html = '<ul>'; while ($linha = mysql_fetch_array($lista)) { $html .= '<li>' . $linha["Descricao"] . ' ( <a href="javascript:void(0);" title="' . $linha["TextoDescritivo"] . '">X</a> )</li>'; } $html .= '</ul><br /><br />'; // Verifica quantas perguntas tem cadastradas ao todo $registros = $c->contaclasses(); // Se for necessário, adiciona ao fim da página os links para navegação (da paginação) if ($pagina > 1) { $html .= '<a href="classificacoes.php?pag=' . ($pagina - 1) . '">@lng[Anterior]</a> | '; } if ($registros > $limite * $pagina) { $html .= '<a href="classificacoes.php?pag=' . ($pagina + 1) . '">@lng[Proximo]</a>'; } } else { // Se não tem perguntas cadastradas, informa que não tem nenhuma $html = "@lng[Nenhuma pergunta cadastrada]"; } $tpl = str_replace("<!--ListaClasses-->", $html, $tpl); echo $tpl; }
private static function getCustomFieldSerializer($qualifiedSerializerName) { try { return Classes::classOf($qualifiedSerializerName); } catch (ClassNotFoundException $e) { return null; } }
<div id="maincontent"> <div class="textcontentalone"> <h1>join the class of <?php echo DateManager::frontdisplaytimefromtmstp($classtojoin->c_date); ?> part of the <?php echo $sessiontojoin->name; ?> </h1> <p>Please fill out the form below to register for a class in the upcoming Spring Session. Please be sure to look at DAY and TIME to be sure you are registering for the correct time slot. </p> <?php $stillspots = Classes::anyspots($classtojoin->id); if ($stillspots) { echo '<h2>CLASS FULL</h2>'; } else { if (isset($captchaerror)) { $p_firstname = $database->escape_value($_POST['p_firstname']); $p_lastname = $database->escape_value($_POST['p_lastname']); $k_firstname = $database->escape_value($_POST['k_firstname']); $k_lastname = $database->escape_value($_POST['k_lastname']); $phone = $database->escape_value($_POST['phone']); $email = $database->escape_value($_POST['email']); ?> <script> $(document).ready(function(){ $("#commentForm").validate(); });
/** * Used for general category browsing (which is really a search by category or family) * The URL manager passes the category request_url which we look up here */ public function actionBrowse() { $strC = Yii::app()->getRequest()->getQuery('cat'); $strB = Yii::app()->getRequest()->getQuery('brand'); $strS = Yii::app()->getRequest()->getQuery('class_name'); $strInv = ''; //If we haven't passed any criteria, we just query the database $criteria = new CDbCriteria(); $criteria->alias = 'Product'; if (!empty($strC)) { $objCategory = Category::LoadByRequestUrl($strC); if ($objCategory) { $criteria->join = 'LEFT JOIN xlsws_product_category_assn as ProductAssn ON ProductAssn.product_id=Product.id'; $intIdArray = array($objCategory->id); $intIdArray = array_merge($intIdArray, $objCategory->GetBranchPath()); $criteria->addInCondition('category_id', $intIdArray); $this->pageTitle = $objCategory->PageTitle; $this->pageDescription = $objCategory->PageDescription; $this->pageImageUrl = $objCategory->CategoryImage; $this->breadcrumbs = $objCategory->Breadcrumbs; $this->pageHeader = Yii::t('category', $objCategory->label); $this->subcategories = $objCategory->getSubcategoryTree($this->MenuTree); if ($objCategory->custom_page) { $this->custom_page_content = $objCategory->customPage->page; } $this->canonicalUrl = $objCategory->getCanonicalUrl(); } } if (!empty($strB)) { $objFamily = Family::LoadByRequestUrl($strB); if ($objFamily) { $criteria->addCondition('family_id = :id'); $criteria->params = array(':id' => $objFamily->id); $this->pageTitle = $objFamily->PageTitle; $this->pageHeader = $objFamily->family; $this->canonicalUrl = $objFamily->getCanonicalUrl(); } } if (!empty($strS)) { $objClasses = Classes::LoadByRequestUrl($strS); if ($objClasses) { $criteria->addCondition('class_id = :id'); $criteria->params = array(':id' => $objClasses->id); $this->pageHeader = $objClasses->class_name; $this->canonicalUrl = $objClasses->getCanonicalUrl(); } } if (_xls_get_conf('INVENTORY_OUT_ALLOW_ADD') == Product::InventoryMakeDisappear) { $criteria->addCondition('(inventory_avail>0 OR inventoried=0)'); } if (!_xls_get_conf('CHILD_SEARCH') || empty($strQ)) { $criteria->addCondition('Product.parent IS NULL'); } if (Product::HasFeatured() && empty($strS) && empty($strB) && empty($strC)) { $criteria->addCondition('featured=1'); $this->pageHeader = 'Featured Products'; } $criteria->addCondition('web=1'); $criteria->addCondition('current=1'); $criteria->order = 'Product.' . _xls_get_sort_order(); $productsGrid = new ProductGrid($criteria); $this->returnUrl = $this->canonicalUrl; $this->pageImageUrl = ""; if ($strB == '*') { $familiesCriteria = new CDbCriteria(); $familiesCriteria->order = 'family'; if (CPropertyValue::ensureBoolean(Yii::app()->params['DISPLAY_EMPTY_CATEGORY']) === false) { $familiesCriteria->addCondition('child_count > 0'); } $families = Family::model()->findAll($familiesCriteria); $this->render('brands', array('model' => $families)); } else { $this->render('grid', array('model' => $productsGrid->getProductGrid(), 'item_count' => $productsGrid->getNumberOfRecords(), 'page_size' => Yii::app()->params['PRODUCTS_PER_PAGE'], 'items_count' => $productsGrid->getNumberOfRecords(), 'pages' => $productsGrid->getPages())); } }
public static function loadFromStream($filename, GenericList $classNotFoundExceptions) { if (is_null($filename)) { throw new NullPointerException('InputStream'); } $whitelistSer = new HashMap(); $whitelistDeser = new HashMap(); $typeIds = new HashMap(); $clientFields = new HashMap(); $br = new BufferedReader($filename); $line = $br->readLine(); $lineNum = 1; while (!is_null($line)) { $line = trim($line); if (mb_strlen($line) > 0) { $components = explode(',', $line); if ($components[0] === self::CLIENT_FIELDS_KEYWORD) { /* * Lines starting with '@ClientFields' list potentially serializable fields known to * client code for classes that may be enhanced with additional fields on the server. * If additional server fields are found, they will be serizalized separately from the * normal RPC process and transmitted to the client as an opaque blob of data stored * in a WeakMapping associated with the object instance. */ $binaryTypeName = trim($components[1]); try { $clazz = Classes::classOf($binaryTypeName); $fieldNames = new HashSet(); for ($i = 2; $i < count($components); $i++) { $fieldNames->add($components[$i]); } $clientFields->put($clazz, $fieldNames); } catch (ClassNotFoundException $e) { // Ignore the error, but add it to the list of errors if one was // provided. if (!is_null($classNotFoundExceptions)) { $classNotFoundExceptions->add($e); } } } else { if (count($components) != 2 && count($components) != 7) { throw new ParseException(self::FORMAT_ERROR_MESSAGE, $lineNum); } for ($i = 0; $i < count($components); $i++) { $components[$i] = trim($components[$i]); if (mb_strlen($components[$i]) == 0) { throw new ParseException(self::FORMAT_ERROR_MESSAGE, $lineNum); } } $binaryTypeName = trim($components[0]); if (count($components) == 2) { $fieldSer = $fieldDeser = true; $instantSer = $instantDeser = Boolean::valueOf($components[1]); $typeId = $binaryTypeName; } else { $idx = 1; // TODO: Validate the instantiable string better $fieldSer = Boolean::valueOf($components[$idx++]); $instantSer = Boolean::valueOf($components[$idx++]); $fieldDeser = Boolean::valueOf($components[$idx++]); $instantDeser = Boolean::valueOf($components[$idx++]); $typeId = $components[$idx++]; if (!$fieldSer && !$fieldDeser && TypeNameObfuscator::SERVICE_INTERFACE_ID != $typeId) { throw new ParseException('Type ' . $binaryTypeName . ' is neither field serializable, field deserializable ' . 'nor the service interface : ', $lineNum); } } try { $clazz = Classes::classOf($binaryTypeName); if ($fieldSer) { $whitelistSer->put($clazz, $instantSer); } if ($fieldDeser) { $whitelistDeser->put($clazz, $instantDeser); } $typeIds->put($clazz, $typeId); } catch (ClassNotFoundException $e) { // Ignore the error, but add it to the list of errors if one was // provided. if (!is_null($classNotFoundExceptions)) { $classNotFoundExceptions->add($e); } } } } $line = $br->readLine(); $lineNum++; } return new StandardSerializationPolicy($whitelistSer, $whitelistDeser, $typeIds, $clientFields); }
public static function streamResponse2(ClientOracle $clientOracle, $payload, $payloadType, CommandSink $sink, $asThrow) { $command = null; if ($asThrow) { $command = new ThrowCommand(); assert($payload instanceof Exception); $payload = new Throwable(get_class($payload), (string) $payload); } else { $command = new ReturnCommand(); } $out = new CommandServerSerializationStreamWriter(new HasValuesCommandSink($command), $clientOracle); if (empty($payloadType)) { $out->writeObject($payload); } else { $clazz = Classes::classOf($payloadType); $out->writeValue($clazz, $payload); } $sink->accept($command); }