/** * API Method queries for ModeloCertificado records and render as JSON */ public function Query() { try { $criteria = new ModeloCertificadoCriteria(); if (RequestUtil::Get('idPalestra')) { $criteria->IdPalestra_Equals = RequestUtil::Get('idPalestra'); } // TODO: this will limit results based on all properties included in the filter list $filter = RequestUtil::Get('filter'); if ($filter) { $criteria->AddFilter(new CriteriaFilter('IdModeloCertificado,Nome,TextoParticipante,TextoPalestrante,ArquivoCss,Elementos', '%' . $filter . '%')); } // TODO: this is generic query filtering based only on criteria properties foreach (array_keys($_REQUEST) as $prop) { $prop_normal = ucfirst($prop); $prop_equals = $prop_normal . '_Equals'; if (property_exists($criteria, $prop_normal)) { $criteria->{$prop_normal} = RequestUtil::Get($prop); } elseif (property_exists($criteria, $prop_equals)) { // this is a convenience so that the _Equals suffix is not needed $criteria->{$prop_equals} = RequestUtil::Get($prop); } } $output = new stdClass(); // if a sort order was specified then specify in the criteria $output->orderBy = RequestUtil::Get('orderBy'); $output->orderDesc = RequestUtil::Get('orderDesc') != ''; if ($output->orderBy) { $criteria->SetOrder($output->orderBy, $output->orderDesc); } $page = RequestUtil::Get('page'); if ($page != '') { // if page is specified, use this instead (at the expense of one extra count query) $pagesize = $this->GetDefaultPageSize(); $modelocertificados = $this->Phreezer->Query('ModeloCertificadoReporter', $criteria)->GetDataPage($page, $pagesize); $output->rows = $modelocertificados->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = $modelocertificados->TotalResults; $output->totalPages = $modelocertificados->TotalPages; $output->pageSize = $modelocertificados->PageSize; $output->currentPage = $modelocertificados->CurrentPage; } else { // return all results $modelocertificados = $this->Phreezer->Query('ModeloCertificadoReporter', $criteria); $output->rows = $modelocertificados->ToObjectArray(true, $this->SimpleObjectParams()); //RETIRA CAMPO PARA ASSINATURA DO PARTICIPANTE SE FOR CERTIFICADO DE PALESTRANTE if (RequestUtil::Get('palestrante')) { $regex = '/(class=\\"hide-palestrante)/'; $output->rows[0]->elementos = preg_replace($regex, '$1 hide', $output->rows[0]->elementos); } $output->totalResults = count($output->rows); $output->totalPages = 1; $output->pageSize = $output->totalResults; $output->currentPage = 1; } $this->RenderJSON($output, $this->JSONPCallback()); } catch (Exception $ex) { $this->RenderExceptionJSON($ex); } }
/** * API Method queries for Palestra records and render as JSON */ public function Query() { try { $criteria = new PalestraCriteria(); //Filtra pelo evento caso ele exista na URL (e no arquivo js correspondente a esse controller) $evento = RequestUtil::Get('evento'); if ($evento) { $criteria->AddFilter(new CriteriaFilter('IdEvento', $evento)); } // TODO: this will limit results based on all properties included in the filter list $filter = RequestUtil::Get('filter'); if ($filter) { $criteria->AddFilter(new CriteriaFilter('IdPalestra,Nome,Data,CargaHoraria,ProprioEvento,IdEvento,IdModeloCertificado', '%' . $filter . '%')); } $criteria->Nome_NotEquals = '.'; //PARA NÃO LISTAR AS PALESTRAS COM NOME . QUE SÃO CRIADAS AUTOMATICAMENTE PARA CONTROLE // TODO: this is generic query filtering based only on criteria properties foreach (array_keys($_REQUEST) as $prop) { $prop_normal = ucfirst($prop); $prop_equals = $prop_normal . '_Equals'; if (property_exists($criteria, $prop_normal)) { $criteria->{$prop_normal} = RequestUtil::Get($prop); } elseif (property_exists($criteria, $prop_equals)) { // this is a convenience so that the _Equals suffix is not needed $criteria->{$prop_equals} = RequestUtil::Get($prop); } } $output = new stdClass(); // if a sort order was specified then specify in the criteria $output->orderBy = RequestUtil::Get('orderBy'); $output->orderDesc = RequestUtil::Get('orderDesc') != ''; if ($output->orderBy) { $criteria->SetOrder($output->orderBy, $output->orderDesc); } $page = RequestUtil::Get('page'); if ($page != '') { // if page is specified, use this instead (at the expense of one extra count query) $pagesize = $this->GetDefaultPageSize(); $palestras = $this->Phreezer->Query('PalestraReporter', $criteria)->GetDataPage($page, $pagesize); $output->rows = $palestras->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = $palestras->TotalResults; $output->totalPages = $palestras->TotalPages; $output->pageSize = $palestras->PageSize; $output->currentPage = $palestras->CurrentPage; } else { // return all results $palestras = $this->Phreezer->Query('PalestraReporter', $criteria); $output->rows = $palestras->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = count($output->rows); $output->totalPages = 1; $output->pageSize = $output->totalResults; $output->currentPage = 1; } $this->RenderJSON($output, $this->JSONPCallback()); } catch (Exception $ex) { $this->RenderExceptionJSON($ex); } }
/** * Get connection string based on request variables */ protected function GetConnectionString() { $cstring = new DBConnectionString(); $cstring->Host = RequestUtil::Get('host'); $cstring->Port = RequestUtil::Get('port'); $cstring->Username = RequestUtil::Get('username'); $cstring->Password = RequestUtil::Get('password'); $cstring->DBName = RequestUtil::Get('schema'); return $cstring; }
/** * Process the login, create the user session and then redirect to * the appropriate page */ public function Login() { $user = new ExampleUser(); if ($user->Login(RequestUtil::Get('username'), RequestUtil::Get('password'))) { // login success $this->SetCurrentUser($user); $this->Redirect('SecureExample.UserPage'); } else { // login failed $this->Redirect('SecureExample.LoginForm', 'Unknown username/password combination'); } }
/** * Process the login, create the user session and then redirect to * the appropriate page */ public function Login() { $user = new User($this->Phreezer); if ($user->Login(RequestUtil::Get('username'), RequestUtil::Get('password'))) { // login success $this->SetCurrentUser($user); $this->Redirect('Secure.UserPage'); } else { // login failed $this->Redirect('Secure.LoginForm', 'Usuario e senha invalidos.'); } }
/** * API Method queries for Usuario records and render as JSON */ public function Query() { try { $criteria = new UsuarioCriteria(); $criteria->IdUsuario_GreaterThan = 1; // para não lista o usuario Master // TODO: this will limit results based on all properties included in the filter list $filter = RequestUtil::Get('filter'); if ($filter) { $criteria->AddFilter(new CriteriaFilter('Nome,Email,Login,TipoUsuario', '%' . $filter . '%')); } // TODO: this is generic query filtering based only on criteria properties foreach (array_keys($_REQUEST) as $prop) { $prop_normal = ucfirst($prop); $prop_equals = $prop_normal . '_Equals'; if (property_exists($criteria, $prop_normal)) { $criteria->{$prop_normal} = RequestUtil::Get($prop); } elseif (property_exists($criteria, $prop_equals)) { // this is a convenience so that the _Equals suffix is not needed $criteria->{$prop_equals} = RequestUtil::Get($prop); } } $output = new stdClass(); // if a sort order was specified then specify in the criteria $output->orderBy = RequestUtil::Get('orderBy'); $output->orderDesc = RequestUtil::Get('orderDesc') != ''; if ($output->orderBy) { $criteria->SetOrder($output->orderBy, $output->orderDesc); } $page = RequestUtil::Get('page'); if ($page != '') { // if page is specified, use this instead (at the expense of one extra count query) $pagesize = $this->GetDefaultPageSize(); $usuarios = $this->Phreezer->Query('Usuario', $criteria)->GetDataPage($page, $pagesize); $output->rows = $usuarios->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = $usuarios->TotalResults; $output->totalPages = $usuarios->TotalPages; $output->pageSize = $usuarios->PageSize; $output->currentPage = $usuarios->CurrentPage; } else { // return all results $usuarios = $this->Phreezer->Query('Usuario', $criteria); $output->rows = $usuarios->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = count($output->rows); $output->totalPages = 1; $output->pageSize = $output->totalResults; $output->currentPage = 1; } $this->RenderJSON($output, $this->JSONPCallback()); } catch (Exception $ex) { $this->RenderExceptionJSON($ex); } }
/** * Process the login, create the user session and then redirect to * the appropriate page */ public function Login() { $user = new ExampleUser(); if ($user->Login(RequestUtil::Get('username'), RequestUtil::Get('password'))) { // login success $this->SetCurrentUser($user); $this->Redirect('SecureExample.UserPage'); } else { // login failed $this->Redirect('SecureExample.LoginForm', 'Combinaçãoo de usuário ou senha incorretos'); } }
/** * API Method queries for Media records and render as JSON */ public function Query() { try { $criteria = new MediaCriteria(); // TODO: this will limit results based on all properties included in the filter list $filter = RequestUtil::Get('filter'); if ($filter) { $criteria->AddFilter(new CriteriaFilter('Idmedia,Idhistory,Storage,Iddocumentation,Institution,Idreference,Mediatype,Mediaurl,Digitizationdate,Digitizationresponsable,Polarity,Colorspace,Iccprofile,Xresolution,Yresolution,Thumbnail,Digitizationequipment,Format,Ispublic,Ordername,Sent,Exif,Textual,Sizemedia,Nameoriginal,Mainmedia,Mediadir,Thumbnaildir,Thumbnailurl', '%' . $filter . '%')); } // TODO: this is generic query filtering based only on criteria properties foreach (array_keys($_REQUEST) as $prop) { $prop_normal = ucfirst($prop); $prop_equals = $prop_normal . '_Equals'; if (property_exists($criteria, $prop_normal)) { $criteria->{$prop_normal} = RequestUtil::Get($prop); } elseif (property_exists($criteria, $prop_equals)) { // this is a convenience so that the _Equals suffix is not needed $criteria->{$prop_equals} = RequestUtil::Get($prop); } } $output = new stdClass(); // if a sort order was specified then specify in the criteria $output->orderBy = RequestUtil::Get('orderBy'); $output->orderDesc = RequestUtil::Get('orderDesc') != ''; if ($output->orderBy) { $criteria->SetOrder($output->orderBy, $output->orderDesc); } $page = RequestUtil::Get('page'); if ($page != '') { // if page is specified, use this instead (at the expense of one extra count query) $pagesize = $this->GetDefaultPageSize(); $medias = $this->Phreezer->Query('Media', $criteria)->GetDataPage($page, $pagesize); $output->rows = $medias->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = $medias->TotalResults; $output->totalPages = $medias->TotalPages; $output->pageSize = $medias->PageSize; $output->currentPage = $medias->CurrentPage; } else { // return all results $medias = $this->Phreezer->Query('Media', $criteria); $output->rows = $medias->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = count($output->rows); $output->totalPages = 1; $output->pageSize = $output->totalResults; $output->currentPage = 1; } $this->RenderJSON($output, $this->JSONPCallback()); } catch (Exception $ex) { $this->RenderExceptionJSON($ex); } }
/** * API Method queries for PlaceLocation records and render as JSON */ public function Query() { try { $criteria = new PlaceLocationCriteria(); // TODO: this will limit results based on all properties included in the filter list $filter = RequestUtil::Get('filter'); if ($filter) { $criteria->AddFilter(new CriteriaFilter('Id,Complement,Latituded,Local,Longitude,Number,Otherinformation,Street,Type,Zipcode,City,Country,Institution,State', '%' . $filter . '%')); } // TODO: this is generic query filtering based only on criteria properties foreach (array_keys($_REQUEST) as $prop) { $prop_normal = ucfirst($prop); $prop_equals = $prop_normal . '_Equals'; if (property_exists($criteria, $prop_normal)) { $criteria->{$prop_normal} = RequestUtil::Get($prop); } elseif (property_exists($criteria, $prop_equals)) { // this is a convenience so that the _Equals suffix is not needed $criteria->{$prop_equals} = RequestUtil::Get($prop); } } $output = new stdClass(); // if a sort order was specified then specify in the criteria $output->orderBy = RequestUtil::Get('orderBy'); $output->orderDesc = RequestUtil::Get('orderDesc') != ''; if ($output->orderBy) { $criteria->SetOrder($output->orderBy, $output->orderDesc); } $page = RequestUtil::Get('page'); if ($page != '') { // if page is specified, use this instead (at the expense of one extra count query) $pagesize = $this->GetDefaultPageSize(); $placelocations = $this->Phreezer->Query('PlaceLocation', $criteria)->GetDataPage($page, $pagesize); $output->rows = $placelocations->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = $placelocations->TotalResults; $output->totalPages = $placelocations->TotalPages; $output->pageSize = $placelocations->PageSize; $output->currentPage = $placelocations->CurrentPage; } else { // return all results $placelocations = $this->Phreezer->Query('PlaceLocation', $criteria); $output->rows = $placelocations->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = count($output->rows); $output->totalPages = 1; $output->pageSize = $output->totalResults; $output->currentPage = 1; } $this->RenderJSON($output, $this->JSONPCallback()); } catch (Exception $ex) { $this->RenderExceptionJSON($ex); } }
/** * API Method queries for Physicaldescription records and render as JSON */ public function Query() { try { $criteria = new PhysicaldescriptionCriteria(); // TODO: this will limit results based on all properties included in the filter list $filter = RequestUtil::Get('filter'); if ($filter) { $criteria->AddFilter(new CriteriaFilter('Id,Item,Apexiso,Arabicpagenumbering,Asaiso,Boundtype,Color,Colorsystem,Columnnumber,Compressionmethod,Contentcolor,Contentextent,Contentfinishing,Contentsubstract,Contenttype,Covercolor,Coverfinishing,Coversubstract,Defaultapplication,Dustjacketcolor,Dustjacketfinishing,Dustjacketsubstract,Endpaper,Exif,Format,Framerate,Hasdustjacket,Hassound,Hasspecialfold,Iscompressed,Lengthtxt,Master,Media,Mediasupport,Movements,Other,Projectionmode,Romanpage,Sizetxt,Soundsystem,Specialfold,Specialpagenumebring,Technique,Timecode,Tinting,Titlepage,Totaltime,Type,Writingformat', '%' . $filter . '%')); } // TODO: this is generic query filtering based only on criteria properties foreach (array_keys($_REQUEST) as $prop) { $prop_normal = ucfirst($prop); $prop_equals = $prop_normal . '_Equals'; if (property_exists($criteria, $prop_normal)) { $criteria->{$prop_normal} = RequestUtil::Get($prop); } elseif (property_exists($criteria, $prop_equals)) { // this is a convenience so that the _Equals suffix is not needed $criteria->{$prop_equals} = RequestUtil::Get($prop); } } $output = new stdClass(); // if a sort order was specified then specify in the criteria $output->orderBy = RequestUtil::Get('orderBy'); $output->orderDesc = RequestUtil::Get('orderDesc') != ''; if ($output->orderBy) { $criteria->SetOrder($output->orderBy, $output->orderDesc); } $page = RequestUtil::Get('page'); if ($page != '') { // if page is specified, use this instead (at the expense of one extra count query) $pagesize = $this->GetDefaultPageSize(); $physicaldescriptions = $this->Phreezer->Query('Physicaldescription', $criteria)->GetDataPage($page, $pagesize); $output->rows = $physicaldescriptions->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = $physicaldescriptions->TotalResults; $output->totalPages = $physicaldescriptions->TotalPages; $output->pageSize = $physicaldescriptions->PageSize; $output->currentPage = $physicaldescriptions->CurrentPage; } else { // return all results $physicaldescriptions = $this->Phreezer->Query('Physicaldescription', $criteria); $output->rows = $physicaldescriptions->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = count($output->rows); $output->totalPages = 1; $output->pageSize = $output->totalResults; $output->currentPage = 1; } $this->RenderJSON($output, $this->JSONPCallback()); } catch (Exception $ex) { $this->RenderExceptionJSON($ex); } }
/** * API Method queries for Itemdescription records and render as JSON */ public function Query() { try { $criteria = new ItemdescriptionCriteria(); // TODO: this will limit results based on all properties included in the filter list $filter = RequestUtil::Get('filter'); if ($filter) { $criteria->AddFilter(new CriteriaFilter('Id,Item,Abstracttext,Accrual,Appraisaldesstructionschedulling,Arrangement,Broadcastmethod,Era,Fromcorporate,Frompersonal,Geographiccoodnates,Geographicname,Label,Language,Mediapresentation,Movement,Other,Period,Periodicity,Preservationstatus,Scope,Style,Subject,Tableofcontents,Targetaudience,Tocorporate,Topersonal', '%' . $filter . '%')); } // TODO: this is generic query filtering based only on criteria properties foreach (array_keys($_REQUEST) as $prop) { $prop_normal = ucfirst($prop); $prop_equals = $prop_normal . '_Equals'; if (property_exists($criteria, $prop_normal)) { $criteria->{$prop_normal} = RequestUtil::Get($prop); } elseif (property_exists($criteria, $prop_equals)) { // this is a convenience so that the _Equals suffix is not needed $criteria->{$prop_equals} = RequestUtil::Get($prop); } } $output = new stdClass(); // if a sort order was specified then specify in the criteria $output->orderBy = RequestUtil::Get('orderBy'); $output->orderDesc = RequestUtil::Get('orderDesc') != ''; if ($output->orderBy) { $criteria->SetOrder($output->orderBy, $output->orderDesc); } $page = RequestUtil::Get('page'); if ($page != '') { // if page is specified, use this instead (at the expense of one extra count query) $pagesize = $this->GetDefaultPageSize(); $itemdescriptions = $this->Phreezer->Query('Itemdescription', $criteria)->GetDataPage($page, $pagesize); $output->rows = $itemdescriptions->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = $itemdescriptions->TotalResults; $output->totalPages = $itemdescriptions->TotalPages; $output->pageSize = $itemdescriptions->PageSize; $output->currentPage = $itemdescriptions->CurrentPage; } else { // return all results $itemdescriptions = $this->Phreezer->Query('Itemdescription', $criteria); $output->rows = $itemdescriptions->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = count($output->rows); $output->totalPages = 1; $output->pageSize = $output->totalResults; $output->currentPage = 1; } $this->RenderJSON($output, $this->JSONPCallback()); } catch (Exception $ex) { $this->RenderExceptionJSON($ex); } }
/** * API Method queries for Item records and render as JSON */ public function Query() { try { $criteria = new ItemCriteria(); // TODO: this will limit results based on all properties included in the filter list $filter = RequestUtil::Get('filter'); if ($filter) { $criteria->AddFilter(new CriteriaFilter('Iditem,Holder,Level,Institution,Inventoryid,Uritype,Uri,Keywords,Description,Uidtype,Uid,Class,Type,Iseletronic,Creationdate,Acquisitiondate,Scopecontent,Originalexistence,Originallocation,Repositorycode,Copyexistence,Copylocation,Legalaccess,Accesscondition,Reproductionrights,Reproductionrightsdescription,Itemdate,Publishdate,Publisher,Itematributes,Ispublic,Preliminaryrule,Punctuation,Notes,Otherinformation,Idfather,Titledefault,Subitem,Deletecomfirm,Typeitem,Edition,Isexposed,Isoriginal,Ispart,Haspart,Ispartof,Numberofcopies,Tobepublicin,Creationdateattributed,Itemdateattributed,Publishdateattributed,Serachdump,Itemmediadir', '%' . $filter . '%')); } // TODO: this is generic query filtering based only on criteria properties foreach (array_keys($_REQUEST) as $prop) { $prop_normal = ucfirst($prop); $prop_equals = $prop_normal . '_Equals'; if (property_exists($criteria, $prop_normal)) { $criteria->{$prop_normal} = RequestUtil::Get($prop); } elseif (property_exists($criteria, $prop_equals)) { // this is a convenience so that the _Equals suffix is not needed $criteria->{$prop_equals} = RequestUtil::Get($prop); } } $output = new stdClass(); // if a sort order was specified then specify in the criteria $output->orderBy = RequestUtil::Get('orderBy'); $output->orderDesc = RequestUtil::Get('orderDesc') != ''; if ($output->orderBy) { $criteria->SetOrder($output->orderBy, $output->orderDesc); } $page = RequestUtil::Get('page'); if ($page != '') { // if page is specified, use this instead (at the expense of one extra count query) $pagesize = $this->GetDefaultPageSize(); $items = $this->Phreezer->Query('Item', $criteria)->GetDataPage($page, $pagesize); $output->rows = $items->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = $items->TotalResults; $output->totalPages = $items->TotalPages; $output->pageSize = $items->PageSize; $output->currentPage = $items->CurrentPage; } else { // return all results $items = $this->Phreezer->Query('Item', $criteria); $output->rows = $items->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = count($output->rows); $output->totalPages = 1; $output->pageSize = $output->totalResults; $output->currentPage = 1; } $this->RenderJSON($output, $this->JSONPCallback()); } catch (Exception $ex) { $this->RenderExceptionJSON($ex); } }
/** * Process the login, create the user session and then redirect to * the appropriate page */ public function Login() { $user = new Usuario($this->Phreezer); if ($user->Login(RequestUtil::Get('username'), RequestUtil::Get('password'))) { // login success $this->SetCurrentUser($user); $_SESSION['nomeUser'] = $this->GetCurrentUser()->Nome; //se existir uma pagina na url, senão manda para pagina padrao if ($this->paginaLoginRedirect) { $pagina = $this->paginaLoginRedirect; } elseif ($this->GetCurrentUser()->TipoUsuario != '') { $pagina = 'Default.Home'; } //$pagina = ; $this->Redirect($pagina); } else { // login failed $this->Redirect('SecureExample.LoginForm', 'Combinação de usuário ou senha incorretos'); } }
/** * API Method queries for PalestraPalestrante records and render as JSON */ public function Query() { try { $criteria = new PalestraPalestranteCriteria(); //Filtra pelo evento caso ele exista na URL (e no arquivo js correspondente a esse controller) $palestrante_not_in = RequestUtil::Get('idPalestrante'); if ($palestrante_not_in) { $criteria->AddFilter(new CriteriaFilter('IdPalestrante', $palestrante_not_in)); } if (RequestUtil::Get('idPalestrante')) { $criteria->IdPalestrante_Equals = RequestUtil::Get('idPalestrante'); } if (RequestUtil::Get('temCertificado')) { $criteria->TemCertificado = RequestUtil::Get('temCertificado'); } if (RequestUtil::Get('innerJoinCertificado')) { $criteria->InnerJoinCertificado = RequestUtil::Get('innerJoinCertificado'); } if (RequestUtil::Get('naoTemCertificado')) { $criteria->NaoTemCertificado = RequestUtil::Get('naoTemCertificado'); } if (RequestUtil::Get('orderByNomePalestrante')) { $criteria->OrderByNomePalestrante = true; } if (RequestUtil::Get('limite')) { $criteria->Limite = RequestUtil::Get('limite'); } // TODO: this will limit results based on all properties included in the filter list $filter = RequestUtil::Get('filter'); if ($filter) { $criteria->AddFilter(new CriteriaFilter('Id,IdPalestrante,IdPalestra,IdCertificado', '%' . $filter . '%')); } // TODO: this is generic query filtering based only on criteria properties foreach (array_keys($_REQUEST) as $prop) { $prop_normal = ucfirst($prop); $prop_equals = $prop_normal . '_Equals'; if (property_exists($criteria, $prop_normal)) { $criteria->{$prop_normal} = RequestUtil::Get($prop); } elseif (property_exists($criteria, $prop_equals)) { // this is a convenience so that the _Equals suffix is not needed $criteria->{$prop_equals} = RequestUtil::Get($prop); } } $output = new stdClass(); // if a sort order was specified then specify in the criteria $output->orderBy = RequestUtil::Get('orderBy'); $output->orderDesc = RequestUtil::Get('orderDesc') != ''; if ($output->orderBy) { $criteria->SetOrder($output->orderBy, $output->orderDesc); } $page = RequestUtil::Get('page'); if ($page != '') { // if page is specified, use this instead (at the expense of one extra count query) $pagesize = $this->GetDefaultPageSize(); $palestrapalestrantes = $this->Phreezer->Query('PalestraPalestranteReporter', $criteria)->GetDataPage($page, $pagesize); $output->rows = $palestrapalestrantes->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = $palestrapalestrantes->TotalResults; $output->totalPages = $palestrapalestrantes->TotalPages; $output->pageSize = $palestrapalestrantes->PageSize; $output->currentPage = $palestrapalestrantes->CurrentPage; } else { // return all results $palestrapalestrantes = $this->Phreezer->Query('PalestraPalestranteReporter', $criteria); $output->rows = $palestrapalestrantes->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = count($output->rows); $output->totalPages = 1; $output->pageSize = $output->totalResults; $output->currentPage = 1; } $this->RenderJSON($output, $this->JSONPCallback()); } catch (Exception $ex) { $this->RenderExceptionJSON($ex); } }
/** * Output a Json error message to the browser * @param string $message * @param array key/value pairs where the key is the fieldname and the value is the error */ protected function RenderErrorJSON($message, $errors = null, $exception = null) { $err = new stdClass(); $err->success = false; $err->message = $message; $err->errors = array(); if ($errors != null) { foreach ($errors as $key => $val) { $err->errors[lcfirst($key)] = $val; } } if ($exception) { $err->stackTrace = explode("\n#", substr($exception->getTraceAsString(), 1)); } @header('HTTP/1.1 401 Unauthorized'); $this->RenderJSON($err, RequestUtil::Get('callback')); }
/** * @inheritdocs */ public function GetUrlParam($paramKey, $default = '') { // if the route hasn't been requested, then we need to initialize before we can get url params if ($this->matchedRoute == null) { $this->GetRoute(); } $params = $this->GetUrlParams(); $uri = $this->GetUri(); $count = 0; $routeMap = $this->matchedRoute["key"]; if (isset($this->matchedRoute["params"][$paramKey])) { $indexLocation = $this->matchedRoute["params"][$paramKey]; return $params[$indexLocation]; } else { return RequestUtil::Get($paramKey, ""); } }
/** * Generate the application based on the selected tables and options */ public function Generate() { // check for all required fields if (empty($_REQUEST["table_name"])) { throw new Exception("Please select at least one table to generate"); } $cstring = $this->GetConnectionString(); // initialize the database connection $handler = new DBEventHandler(); $connection = new DBConnection($cstring, $handler); $server = new DBServer($connection); $dbSchema = new DBSchema($server); $debug = isset($_REQUEST["debug"]) && $_REQUEST["debug"] == "1"; $parameters = array(); $tableNames = $_REQUEST["table_name"]; $packageName = $_REQUEST["package"]; $debug_output = ""; $selectedTables = array(); foreach ($tableNames as $tableName) { $selectedTables[] = $dbSchema->Tables[$tableName]; } // see if arbitrary parameters were passed in - in which case they will be passed through to the templates $tmp = RequestUtil::Get('parameters'); if ($tmp) { $pairs = explode("\n", str_replace("\r", "", $tmp)); foreach ($pairs as $pair) { list($key, $val) = explode("=", $pair, 2); $parameters[$key] = $val; } } // check for required parameters if (!array_key_exists('max_items_in_topnav', $parameters)) { $parameters['max_items_in_topnav'] = self::$DEFAULT_MAX_ITEMS_IN_TOPNAV; } $zipFile = new zipfile(); $codeRoot = GlobalConfig::$APP_ROOT . '/code/'; $tempRoot = GlobalConfig::$APP_ROOT . '/temp/'; // initialize smarty $smarty = new Smarty(); $smarty->template_dir = $codeRoot; $smarty->compile_dir = $tempRoot; $smarty->config_dir = $tempRoot; $smarty->cache_dir = $tempRoot; $smarty->caching = false; $appname = RequestUtil::Get("appname"); $appRoot = RequestUtil::Get("appRoot"); $includePath = RequestUtil::Get("includePath"); $includePhar = RequestUtil::Get("includePhar"); $enableLongPolling = RequestUtil::Get("enableLongPolling"); $config = new AppConfig($codeRoot . $packageName); foreach ($config->GetTemplateFiles() as $templateFile) { if ($templateFile->generate_mode == 3) { if ($includePhar == '1') { // proceed, copy the phar file $templateFile->generate_mode = 2; } else { // skip the phar file continue; } } if ($templateFile->generate_mode == 2) { // this is a template that is copied without parsing to the project (ie images, static files, etc) $templateFilename = str_replace(array('{$appname}', '{$appname|lower}', '{$appname|upper}'), array($appname, strtolower($appname), strtoupper($appname)), $templateFile->destination); $contents = file_get_contents($codeRoot . $templateFile->source); // this is a direct copy if ($debug) { $debug_output .= "\r\n###############################################################\r\n" . "# {$templateFilename}\r\n###############################################################\r\n" . "(contents of " . $codeRoot . $templateFile->source . ")\r\n"; } else { $zipFile->addFile($contents, $templateFilename); } } elseif ($templateFile->generate_mode == 1) { // single template where one is generated for the entire project instead of one for each selected table $templateFilename = str_replace(array('{$appRoot}', '{$appRoot|lower}', '{$appRoot|upper}'), array($appRoot, strtolower($appRoot), strtoupper($appRoot)), $templateFile->destination); $smarty->clearAllAssign(); foreach ($parameters as $key => $val) { $smarty->assign($key, $val); } $smarty->assign("tableNames", $tableNames); $smarty->assign("templateFilename", $templateFilename); $smarty->assign("schema", $dbSchema); $smarty->assign("tables", $dbSchema->Tables); $smarty->assign("connection", $cstring); $smarty->assign("appname", $appname); $smarty->assign("appRoot", $appRoot); $smarty->assign("includePath", $includePath); $smarty->assign("includePhar", $includePhar); $smarty->assign("enableLongPolling", $enableLongPolling); $smarty->assign("PHREEZE_VERSION", Phreezer::$Version); $tableInfos = array(); // add all tables to a tableInfos array that can be used for cross-referencing by table name foreach ($dbSchema->Tables as $table) { if ($table->GetPrimaryKeyName()) { $tableName = $table->Name; $tableInfos[$tableName] = array(); $tableInfos[$tableName]['table'] = $dbSchema->Tables[$tableName]; $tableInfos[$tableName]['singular'] = $_REQUEST[$tableName . "_singular"]; $tableInfos[$tableName]['plural'] = $_REQUEST[$tableName . "_plural"]; $tableInfos[$tableName]['prefix'] = $_REQUEST[$tableName . "_prefix"]; $tableInfos[$tableName]['templateFilename'] = $templateFilename; } } $smarty->assign("tableInfos", $tableInfos); $smarty->assign("selectedTables", $selectedTables); if ($debug) { $debug_output .= "\r\n###############################################################\r\n" . "# {$templateFilename}\r\n###############################################################\r\n" . $smarty->fetch($templateFile->source) . "\r\n"; } else { // we don't like bare linefeed characters $content = $body = preg_replace("/^(?=\n)|[^\r](?=\n)/", "\\0\r", $smarty->fetch($templateFile->source)); $zipFile->addFile($content, $templateFilename); } } else { // enumerate all selected tables and merge them with the selected template // append each to the zip file for output foreach ($tableNames as $tableName) { $singular = $_REQUEST[$tableName . "_singular"]; $plural = $_REQUEST[$tableName . "_plural"]; $prefix = $_REQUEST[$tableName . "_prefix"]; $templateFilename = str_replace(array('{$singular}', '{$plural}', '{$table}', '{$appname}', '{$singular|lower}', '{$plural|lower}', '{$table|lower}', '{$appname|lower}', '{$singular|upper}', '{$plural|upper}', '{$table|upper}', '{$appname|upper}'), array($singular, $plural, $tableName, $appname, strtolower($singular), strtolower($plural), strtolower($tableName), strtolower($appname), strtoupper($singular), strtoupper($plural), strtoupper($tableName), strtoupper($appname)), $templateFile->destination); $smarty->clearAllAssign(); $smarty->assign("appname", $appname); $smarty->assign("singular", $singular); $smarty->assign("plural", $plural); $smarty->assign("prefix", $prefix); $smarty->assign("templateFilename", $templateFilename); $smarty->assign("table", $dbSchema->Tables[$tableName]); $smarty->assign("connection", $cstring); $smarty->assign("appRoot", $appRoot); $smarty->assign("includePath", $includePath); $smarty->assign("includePhar", $includePhar); $smarty->assign("enableLongPolling", $enableLongPolling); $smarty->assign("PHREEZE_VERSION", Phreezer::$Version); $tableInfos = array(); // add all tables to a tableInfos array that can be used for cross-referencing by table name foreach ($dbSchema->Tables as $table) { if ($table->GetPrimaryKeyName()) { $tableName = $table->Name; $tableInfos[$tableName] = array(); $tableInfos[$tableName]['table'] = $dbSchema->Tables[$tableName]; $tableInfos[$tableName]['singular'] = $_REQUEST[$tableName . "_singular"]; $tableInfos[$tableName]['plural'] = $_REQUEST[$tableName . "_plural"]; $tableInfos[$tableName]['prefix'] = $_REQUEST[$tableName . "_prefix"]; $tableInfos[$tableName]['templateFilename'] = $templateFilename; } } $smarty->assign("tableInfos", $tableInfos); $smarty->assign("selectedTables", $selectedTables); foreach ($parameters as $key => $val) { $smarty->assign($key, $val); } //print "<pre>"; print_r($dbSchema->Tables[$tableName]->PrimaryKeyIsAutoIncrement()); die(); if ($debug) { $debug_output .= "\r\n###############################################################\r\n" . "# {$templateFilename}\r\n###############################################################\r\n" . $smarty->fetch($templateFile->source) . "\r\n"; } else { $zipFile->addFile($smarty->fetch($templateFile->source), $templateFilename); } } } } if ($debug) { header("Content-type: text/plain"); print $debug_output; } else { // now output the zip as binary data to the browser header("Content-type: application/force-download"); // laplix 2007-11-02. // Use the application name provided by the user in show_tables. //header("Content-disposition: attachment; filename=".str_replace(" ","_",$G_CONNSTR->DBName).".zip"); header("Content-disposition: attachment; filename=" . str_replace(" ", "_", strtolower(str_replace("/", "", $appRoot))) . ".zip"); header("Content-Transfer-Encoding: Binary"); header('Content-Type: application/zip'); print $zipFile->file(); } }
/** * Returns how the Dispatcher plucks it's controller and method from the URL. * * @param $default_action The Default action in case the argument hasn't been supplied */ public function GetAction($url_param = "action", $default_action = "Account.DefaultAction") { switch ($this->_mode) { // TODO: Determine mobile/joomla URL action (if different from default) /* * case UrlWriterMode::JOOMLA: * break; * case UrlWriterMode::MOBILE: * break; */ default: // default is to return the standard browser-based action=%s.%s&%s: return RequestUtil::Get($url_param, $default_action); break; } }
/** * Stub method */ function Save() { if (!RequestUtil::Get("SaveInline")) { throw new Exception("Save is not implemented by this controller"); } require_once "ValidationResponse.php"; $vr = new ValidationResponse(); $vr->Success = false; $vr->Errors = array(); $vr->Message = "SaveInline is not implemented by this controller"; $this->RenderJSON($vr); }
/** * @inheritdocs */ public function GetUrlParam($paramKey, $default = '') { if ($this->cachedRoute == null) { throw new Exception("Call GetRoute before accessing GetUrlParam"); } $params = $this->GetUrlParams(); $uri = $this->GetUri(); $count = 0; $routeMap = $this->cachedRoute["key"]; if (isset($this->cachedRoute["params"][$paramKey])) { $indexLocation = $this->cachedRoute["params"][$paramKey]; return $params[$indexLocation]; } else { return RequestUtil::Get($paramKey, ""); } }
/** * Test for performing updates */ public function Updates() { require_once "Model/World.php"; // Read number of queries to run from URL parameter $query_count = RequestUtil::Get('queries', 1); $arr = array(); for ($i = 0; $i < $query_count; $i++) { $id = mt_rand(1, 10000); $world = $this->Phreezer->Get("World", $id); // update the random number and persist the record $world->Randomnumber = mt_rand(1, 10000); $world->Save(); // convert the Phreezable object into a simple structure for output $arr[] = array('id' => $world->Id, 'randomNumber' => $world->Randomnumber); } $this->RenderJSON($arr); }
/** * API Method queries for Palestrante records and render as JSON */ public function Query() { try { $criteria = new PalestranteCriteria(); // FILTRA OS PALESTRANTES PELA PALESTRA SE EXISTIR TAL DADO NA URL $arquivoReporter = 'Palestrante'; if (RequestUtil::Get('palestra')) { $criteria->IdPalestra_Equals = RequestUtil::Get('palestra'); $arquivoReporter .= 'Reporter'; } if (RequestUtil::Get('outerJoinPalestras')) { $criteria->OuterJoinPalestras = RequestUtil::Get('outerJoinPalestras'); $arquivoReporter .= 'Reporter'; } if (RequestUtil::Get('ordemLouca')) { $criteria->OrdemLouca = RequestUtil::Get('ordemLouca'); $arquivoReporter .= 'Reporter'; } // TODO: this will limit results based on all properties included in the filter list $filter = RequestUtil::Get('filter'); if ($filter) { $criteria->AddFilter(new CriteriaFilter('IdPalestrante,Nome,Email,Cpf,Cargo,ImagemAssinatura', '%' . $filter . '%')); } // TODO: this is generic query filtering based only on criteria properties foreach (array_keys($_REQUEST) as $prop) { $prop_normal = ucfirst($prop); $prop_equals = $prop_normal . '_Equals'; if (property_exists($criteria, $prop_normal)) { $criteria->{$prop_normal} = RequestUtil::Get($prop); } elseif (property_exists($criteria, $prop_equals)) { // this is a convenience so that the _Equals suffix is not needed $criteria->{$prop_equals} = RequestUtil::Get($prop); } } $output = new stdClass(); // if a sort order was specified then specify in the criteria $output->orderBy = RequestUtil::Get('orderBy'); $output->orderDesc = RequestUtil::Get('orderDesc') != ''; if ($output->orderBy) { $criteria->SetOrder($output->orderBy, $output->orderDesc); } $page = RequestUtil::Get('page'); if ($page != '') { // if page is specified, use this instead (at the expense of one extra count query) $pagesize = $this->GetDefaultPageSize(); // book with id of 3 has 3 authors assigned, this will run one query //$palestra = $this->Phreezer->Get('Palestra',85); // LOOK AT THE SOURCE OF Book->GetAuthorsUsingReporter TO SEE HOW A CUSTOM REPORTER IS USED // $palestrantes = $palestra->GetPalestrantesUsingReporter(); $palestrantes = $this->Phreezer->Query('PalestranteReporter', $criteria)->GetDataPage($page, $pagesize); $output->rows = $palestrantes->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = $palestrantes->TotalResults; $output->totalPages = $palestrantes->TotalPages; $output->pageSize = $palestrantes->PageSize; $output->currentPage = $palestrantes->CurrentPage; } else { // return all results $palestrantes = $this->Phreezer->Query('PalestranteReporter', $criteria); $output->rows = $palestrantes->ToObjectArray(true, $this->SimpleObjectParams()); $output->totalResults = count($output->rows); $output->totalPages = 1; $output->pageSize = $output->totalResults; $output->currentPage = 1; } $this->RenderJSON($output, $this->JSONPCallback()); } catch (Exception $ex) { $this->RenderExceptionJSON($ex); } }
/** * Process the login, create the user session and then redirect to * the appropriate page */ public function Autenticar() { //$autenticacao = new Autenticacao($this->Phreezer); if (!Autenticacao::Login(RequestUtil::Get('username'), RequestUtil::Get('password'))) { //Se o login falhar $this->Redirect('SecureExample.LoginForm', 'Usuário ou senha incorretos.'); } }
/** * API Method para inserir um array de participantes vindos da handsontable */ public function UpdateAll() { $this->RequirePermission(Usuario::$P_ADMIN, 'SecureExample.LoginForm', 'Autentique-se para acessar esta página', 'Você não possui permissão para acessar essa página ou sua sessão expirou'); //$someJSON = $_GET['dados']; require_once "Model/PalestraParticipante.php"; try { $json = json_decode(RequestUtil::GetBody()); //$json = $_GET['dados']; //FILTRA OBJETOS DUPLICADOS NA TABELA DE PARTICIPANTES HANDSONTABLE $unique = array(); //throw new Exception($json); foreach ($json->data as $object) { if (isset($unique[$object->idParticipante])) { continue; } $unique[$object->idParticipante] = $object; } //$json = json_decode($someJSON); if (!$json) { throw new Exception('The request body does not contain valid JSON'); } $errors_p = array(); $row = 0; foreach ($json->data as $json) { //trocar $unique por $json->data se nao for usa-lo if ($json->idParticipante == '' && $json->nome == '' && $json->email == '' && $json->nome == '') { //se linha estiver em branco } else { $pk = $this->SafeGetVal($json, 'idParticipante', null); $cpf = $this->SafeGetVal($json, 'cpf', null); $jatem = true; if ($pk != '') { //SE TIVER ID É EDIÇÃOO SENÃO CRIA UM NOVO PARTICIPANTE try { $participante = $this->Phreezer->Get('Participante', $pk); } catch (NotFoundException $ex) { throw new Exception('Participante não encontrado'); } } elseif ($pk == '' && $cpf != '') { //SE TIVER CPF É EDIÇÃO SENÃO CRIA UM NOVO PARTICIPANTE // try { // $participante = $this->Phreezer->Get('Participante',$pk); // } catch (NotFoundException $ex){ // throw new Exception('Participante não encontrado'); // } $criteria = new ParticipanteCriteria(); $criteria->Cpf_Equals = $cpf; $jatem = true; try { $participante = $this->Phreezer->GetByCriteria("Participante", $criteria); //throw new Exception('MAQU'); } catch (NotFoundException $nfex) { //throw new Exception($nfex); $participante = new Participante($this->Phreezer); //$this->RenderExceptionJSON($nfex); } } else { $participante = new Participante($this->Phreezer); } //se existir id, mas tudo estiver em branco o sistema exclui do banco if ($json->idParticipante != '' && $json->nome == '' && $json->email == '' && $json->nome == '') { $participante->Delete(); } else { $participante->Nome = $this->SafeGetVal($json, 'nome', $participante->Nome); $participante->Email = $this->SafeGetVal($json, 'email', $participante->Email); $participante->Cpf = $this->SafeGetVal($json, 'cpf', $participante->Cpf); $participante->Validate(); $errors = $participante->GetValidationErrors(); //if(!$participante->Cpf) echo $participante->Nome .'--' . $participante->Cpf.'mmmm'; if (count($errors) > 0) { $errors_p[$participante->IdParticipante]['message'] = $participante->GetValidationErrors(); $errors_p[$participante->IdParticipante]['success'] = false; $errors_p[$participante->IdParticipante]['row'] = $row; } else { //Salva o participante no banco $participante->Save(); //para fazer a associaçãoo na tabela palestra_participante $table2 = new PalestraParticipante($this->Phreezer); $table2->IdParticipante = $participante->IdParticipante; $table2->IdPalestra = RequestUtil::Get('idPalestra'); $table2->Presenca = 0; $table2->IdCertificado = 0; $table2->Save(false, true); if ($pk == '' or $jatem == true) { $dados = array('idParticipante' => $participante->IdParticipante, 'row' => $row); $sucesso['novo'][] = $dados; } } // if (count($errors) > 0) // { // $this->RenderErrorJSON('Verifique erros no preenchimento do formulario',$errors); // } // else // { // $participante->Save(); // $this->RenderJSON($participante, $this->JSONPCallback(), true, $this->SimpleObjectParams()); // } } //fim do cadastro se nao for exclusao } //fim do cadastro caso nada esteja em branco $row++; } if (count($errors_p) > 0) { $this->RenderErrorJSON('Verifique erros no preenchimento do formulário', $errors_p); } else { $sucesso['success'] = true; $sucesso['message'] = 'Participantes salvos com sucesso'; $this->RenderJSON($sucesso); } } catch (Exception $ex) { $this->RenderExceptionJSON($ex); } }