/** * @param $transactions * @return array */ public function getXmlData(Collection $transactions) { $transactionData = []; foreach ($transactions as $totalTransaction) { $transaction = $totalTransaction->transaction; $sector = []; if (getVal($transaction, ['sector'])) { $vocabulary = $transaction['sector'][0]['sector_vocabulary']; if ($vocabulary == 1) { $sectorValue = $transaction['sector'][0]['sector_code']; } elseif ($vocabulary == 2) { $sectorValue = $transaction['sector'][0]['sector_category_code']; } elseif ($vocabulary == "") { $sectorValue = $transaction['sector'][0]['sector_code']; } else { $sectorValue = $transaction['sector'][0]['sector_text']; } $sector = ['@attributes' => ['vocabulary' => $vocabulary, 'vocabulary-uri' => getVal($transaction, ['sector', 0, 'vocabulary_uri']), 'code' => $sectorValue], 'narrative' => $this->buildNarrative(getVal($transaction, ['sector', 0, 'narrative'], []))]; } $recipientCountry = []; if (getVal($transaction, ['recipient_country'])) { $recipientCountry = ['@attributes' => ['code' => $transaction['recipient_country'][0]['country_code']], 'narrative' => $this->buildNarrative(getVal($transaction, ['recipient_country', 0, 'narrative'], []))]; } $recipientRegion = []; if (getVal($transaction, ['recipient_region'])) { $recipientRegion = ['@attributes' => ['code' => $transaction['recipient_region'][0]['region_code'], 'vocabulary' => $transaction['recipient_region'][0]['vocabulary'], 'vocabulary-uri' => getVal($transaction, ['recipient_region', 0, 'vocabulary_uri'])], 'narrative' => $this->buildNarrative(getVal($transaction, ['recipient_region', 0, 'narrative'], []))]; } $transactionData[] = ['@attributes' => ['ref' => $transaction['reference'], 'humanitarian' => getVal($transaction, ['humanitarian'])], 'transaction-type' => ['@attributes' => ['code' => $transaction['transaction_type'][0]['transaction_type_code']]], 'transaction-date' => ['@attributes' => ['iso-date' => $transaction['transaction_date'][0]['date']]], 'value' => ['@attributes' => ['currency' => $transaction['value'][0]['currency'], 'value-date' => $transaction['value'][0]['date']], '@value' => $transaction['value'][0]['amount']], 'description' => ['narrative' => $this->buildNarrative(getVal($transaction, ['description', 0, 'narrative'], []))], 'provider-org' => ['@attributes' => ['ref' => $transaction['provider_organization'][0]['organization_identifier_code'], 'provider-activity-id' => $transaction['provider_organization'][0]['provider_activity_id'], 'type' => getVal($transaction, ['provider_organization', 0, 'type'])], 'narrative' => $this->buildNarrative(getVal($transaction, ['provider_organization', 0, 'narrative'], []))], 'receiver-org' => ['@attributes' => ['ref' => $transaction['receiver_organization'][0]['organization_identifier_code'], 'receiver-activity-id' => $transaction['receiver_organization'][0]['receiver_activity_id'], 'type' => getVal($transaction, ['receiver_organization', 0, 'type'])], 'narrative' => $this->buildNarrative(getVal($transaction, ['receiver_organization', 0, 'narrative'], []))], 'disbursement-channel' => ['@attributes' => ['code' => getVal($transaction, ['disbursement_channel', 0, 'disbursement_channel_code'])]], 'sector' => $sector, 'recipient-country' => $recipientCountry, 'recipient-region' => $recipientRegion, 'flow-type' => ['@attributes' => ['code' => getVal($transaction, ['flow_type', 0, 'flow_type'])]], 'finance-type' => ['@attributes' => ['code' => getVal($transaction, ['finance_type', 0, 'finance_type'])]], 'aid-type' => ['@attributes' => ['code' => getVal($transaction, ['aid_type', 0, 'aid_type'])]], 'tied-status' => ['@attributes' => ['code' => getVal($transaction, ['tied_status', 0, 'tied_status_code'])]]]; } return $transactionData; }
/** * Build narratives for Elements. * @param $narratives * @return array */ public function buildNarrative($narratives) { $narrativeData = []; foreach ($narratives as $narrative) { $narrativeData[] = ['@value' => getVal($narrative, ['narrative']), '@attributes' => ['xml:lang' => getVal($narrative, ['language'])]]; } return $narrativeData; }
/** * @param $activity * @return array */ public function getXmlData(Activity $activity) { $activityData = []; $recipientRegions = (array) $activity->recipient_region; foreach ($recipientRegions as $recipientRegion) { $activityData[] = ['@attributes' => ['code' => getVal($recipientRegion, ['region_code']), 'percentage' => getVal($recipientRegion, ['percentage']), 'vocabulary' => getVal($recipientRegion, ['region_vocabulary']), 'vocabulary-uri' => getVal($recipientRegion, ['vocabulary_uri'])], 'narrative' => $this->buildNarrative(getVal($recipientRegion, ['narrative'], []))]; } return $activityData; }
/** * @param $activity * @return array */ public function getXmlData(Activity $activity) { $activityData = []; $participatingOrganizations = (array) $activity->participating_organization; foreach ($participatingOrganizations as $participatingOrganization) { $activityData[] = ['@attributes' => ['ref' => $participatingOrganization['identifier'], 'type' => $participatingOrganization['organization_type'], 'role' => $participatingOrganization['organization_role'], 'activity-id' => getVal($participatingOrganization, ['activity_id'])], 'narrative' => $this->buildNarrative($participatingOrganization['narrative'])]; } return $activityData; }
/** * @param $activity * @return array */ public function getXmlData(Activity $activity) { $activityData = []; $policyMarkers = (array) $activity->policy_marker; foreach ($policyMarkers as $policyMarker) { $activityData[] = ['@attributes' => ['vocabulary' => $policyMarker['vocabulary'], 'vocabulary-uri' => getVal($policyMarker, ['vocabulary_uri']), 'code' => getVal($policyMarker, ['policy_marker']), 'significance' => getVal($policyMarker, ['significance'])], 'narrative' => $this->buildNarrative(getVal($policyMarker, ['narrative'], []))]; } return $activityData; }
/** * @param $activity * @return array */ public function getXmlData(Activity $activity) { $activityData = []; $budgets = (array) $activity->budget; foreach ($budgets as $budget) { $activityData[] = ['@attributes' => ['type' => $budget['budget_type'], 'status' => getVal($budget, ['status'])], 'period-start' => ['@attributes' => ['iso-date' => $budget['period_start'][0]['date']]], 'period-end' => ['@attributes' => ['iso-date' => $budget['period_end'][0]['date']]], 'value' => ['@attributes' => ['currency' => $budget['value'][0]['currency'], 'value-date' => $budget['value'][0]['value_date']], '@value' => $budget['value'][0]['amount']]]; } return $activityData; }
/** * @param $activity * @return array */ public function getXmlData(Activity $activity) { $activityData = []; $documentLinks = $activity->documentLinks()->get(); foreach ($documentLinks as $documentLink) { $documentLink = $documentLink->document_link; $activityData[] = ['@attributes' => ['url' => $documentLink['url'], 'format' => $documentLink['format']], 'title' => ['narrative' => $this->buildNarrative(getVal($documentLink, ['title', 0, 'narrative'], []))], 'category' => ['@attributes' => ['code' => getVal($documentLink, ['category', 0, 'code'])]], 'language' => ['@attributes' => ['code' => getVal($documentLink, ['language', 0, 'language'])]], 'document-date' => ['@attributes' => ['iso-date' => getVal($documentLink, ['document_date', 0, 'date'])]]]; } return $activityData; }
function getStatusDrop(){ $choices = getStatusDropArr(); $ret = '<select class="input" name="status" id="status">'; foreach($choices as $k=>$v){ $selected = ($v == getVal('status'))?'selected="selected"':''; $ret .= '<option value="'.$v.'" '.$selected.'>'.$v.'</option>'; } $ret .= '</select>'; return $ret; }
/** * @param array $formFields * @return array */ protected function getMessagesForDocumentLink(array $formFields) { $messages = []; foreach ($formFields as $documentLinkIndex => $documentLink) { $documentLinkForm = sprintf('document_link.%s', $documentLinkIndex); $messages[sprintf('document_link.%s.url.required', $documentLinkIndex)] = 'Url is required'; $messages[sprintf('document_link.%s.url.url', $documentLinkIndex)] = 'Enter valid URL. eg. http://example.com'; $messages[sprintf('document_link.%s.format.required', $documentLinkIndex)] = 'Format is required'; $messages = array_merge($messages, $this->getMessagesForNarrative(getVal($documentLink, ['title', 0, 'narrative']), sprintf('%s.title.0', $documentLinkForm)), $this->getMessagesForDocumentCategory(getVal($documentLink, ['category'], []), $documentLinkForm)); $messages[sprintf('%s.title.0.narrative.0.narrative.required', $documentLinkForm)] = 'Narrative is required.'; } return $messages; }
/** * @param array $formFields * @return array */ protected function getRulesForBudget(array $formFields) { $rules = []; foreach ($formFields as $budgetIndex => $budget) { $budgetForm = sprintf('budget.%s', $budgetIndex); $rules = array_merge($rules, $this->getRulesForPeriodStart($budget['period_start'], $budgetForm), $this->getRulesForPeriodEnd($budget['period_end'], $budgetForm), $this->getRulesForValue($budget['value'], $budgetForm)); $startDate = getVal($budget, ['period_start', 0, 'date']); $newDate = $startDate ? date('Y-m-d', strtotime($startDate . '+1year')) : ''; if ($newDate) { $rules[$budgetForm . '.period_end.0.date'][] = sprintf('before:%s', $newDate); } } return $rules; }
/** * @param $activity * @return array */ public function getXmlData(Activity $activity) { $activityData = []; $plannedDisbursements = (array) $activity->planned_disbursement; foreach ($plannedDisbursements as $plannedDisbursement) { if (!array_key_exists('provider_org', $plannedDisbursement)) { $plannedDisbursement['provider_org'] = $this->plannedDisbursementTemplate(); } if (!array_key_exists('reciever_org', $plannedDisbursement)) { $plannedDisbursement['reciever_org'] = $this->plannedDisbursementTemplate(); } $activityData[] = ['@attributes' => ['type' => $plannedDisbursement['planned_disbursement_type']], 'period-start' => ['@attributes' => ['iso-date' => $plannedDisbursement['period_start'][0]['date']]], 'period-end' => ['@attributes' => ['iso-date' => $plannedDisbursement['period_end'][0]['date']]], 'value' => ['@attributes' => ['currency' => $plannedDisbursement['value'][0]['currency'], 'value-date' => $plannedDisbursement['value'][0]['value_date']], '@value' => $plannedDisbursement['value'][0]['amount']], 'provider-org' => ['@attributes' => ['ref' => getVal($plannedDisbursement, ['provider_org', 0, 'ref']), 'provider-activity-id' => getVal($plannedDisbursement, ['provider_org', 0, 'activity_id']), 'type' => getVal($plannedDisbursement, ['provider_org', 0, 'type'])], 'narrative' => $this->buildNarrative(getVal($plannedDisbursement, ['provider_org', 0, 'narrative'], []))], 'receiver-org' => ['@attributes' => ['ref' => getVal($plannedDisbursement, ['receiver_org', 0, 'ref']), 'receiver-activity-id' => getVal($plannedDisbursement, ['receiver_org', 0, 'activity_id']), 'type' => getVal($plannedDisbursement, ['receiver_org', 0, 'type'])], 'narrative' => $this->buildNarrative(getVal($plannedDisbursement, ['receiver_org', 0, 'narrative'], []))]]; } return $activityData; }
/** * @param $activity * @return array */ public function getXmlData(Activity $activity) { $activityData = []; $sectors = (array) $activity->sector; foreach ($sectors as $sector) { $vocabulary = $sector['sector_vocabulary']; if ($vocabulary == 1) { $sectorValue = $sector['sector_code']; } elseif ($vocabulary == 2) { $sectorValue = $sector['sector_category_code']; } else { $sectorValue = $sector['sector_text']; } $activityData[] = ['@attributes' => ['code' => $sectorValue, 'percentage' => $sector['percentage'], 'vocabulary' => $vocabulary, 'vocabulary-uri' => getVal($sector, ['vocabulary_uri'])], 'narrative' => $this->buildNarrative($sector['narrative'])]; } return $activityData; }
/** * Unlink a file from the IATI Registry. * @param $registryInfo * @param $changeDetails * @return bool * @throws Exception */ public function unlink($registryInfo, $changeDetails) { try { $apiKey = $registryInfo[0]['api_id']; $api = new CkanClient(env('REGISTRY_URL'), $apiKey); foreach ($changeDetails['previous'] as $filename => $previous) { $pieces = explode(".", $filename); $fileId = array_first($pieces, function () { return true; }); if (getVal($previous, ['published_status'])) { $api->package_delete($fileId); } } return true; } catch (Exception $exception) { throw $exception; } }
function getRepsDrop(){ global $DB; $sql = "SELECT * FROM reps WHERE 1 ORDER BY firstname"; $res = $DB->query($sql); $ret = '<select name="rep" id="rep" class="input">'; while($r = $DB->fetchNextObject($res)){ if($r->id == $_SESSION['loggedin'] && !isset($_REQUEST['e'])){ // if its from the logged in user $selected = 'selected="selected"'; }elseif($r->id == getVal('rep')){ // if its from the db of the global vars $selected = 'selected="selected"'; }else{ $selected = ''; } $ret .= '<option value="'.$r->id.'" '.$selected.'>'.$r->firstname.' '.$r->lastname.'</option>'; } $ret .= '</select>'; return $ret; }
$request = $_SERVER['REQUEST_URI']; $request = explode('/', substr($request, strpos($request, 'api') + 4)); $noun = $request[0]; $id = mysql_real_escape_string($request[1]); if (is_null($id)) { echo "id missing"; return; } // get variables // TODO this should eventually not be tied to Tasks so we can reuse this script for other objects // foreach($put as $var => $val){ // echo $var . ": " . $val; // }; $sql = "UPDATE task SET "; foreach ($put as $name => $val) { $sql .= getVal($put, $name); } // remove last , $sql = substr($sql, 0, strrpos($sql, ',')) . " "; $sql .= "WHERE id = {$id};"; // update in DB $result = mysql_query($sql); if (mysql_error()) { return false; } else { //echo mysql_affected_rows(); echo '{"id":' . $id . '}'; } function getVal($put, $varName) { if (isset($put->{$varName})) {
function backend_keywords($name, $input = null, $options = array(), $methode = null) { $keywords = getVal($input, $methode, $name); if ($keywords) { $keywords = substr($keywords, 1, -1); $keywords = str_replace('][', ',', $keywords) . ','; } $keywordsArr = explode(",", $keywords); $code = '<div id="keywordsStock" style="width:325px">'; foreach ($keywordsArr as $key) { $keyObj = Document::getDocumentInstance($key); if ($keyObj = Document::getDocumentInstance($key)) { $code .= '<div id="key_' . $key . '" class="s" onclick="removeKeyword(\'' . $key . '\')">' . $keyObj->getLabel() . '</div>'; } } $code .= '</div>'; $code .= input_hidden_tag($name, $keywords, array('id' => 'keywords')); $code .= '<br><div style="clear:both"></div>'; $code .= getDivLabel($options, $name); if ($options['size']) { $size = $options['size']; } else { $size = 50; } $code .= '<input type="text" id="keyword" autocomplete="off" size="' . $size . '" onfocus="document.getElementById(\'fk\').style.display = \'none\'" onkeyup="getKeywords(this.value, document.getElementById(\'fk\'))">  <input type="button" value="' . $options['btnLabel'] . '" onclick="addKeyword(document.getElementById(\'keyword\').value)"><div id="fk"></div>'; return $code; }
/** * Publish an Activity. * * If the auto-publish option is set, the Activity data is published into the IATI Registry. * @param $activity * @param $details * @return bool */ public function publish($activity, array $details) { try { $organization = $activity->organization; $settings = $organization->settings; $version = $settings->version; $this->xmlServiceProvider->initializeGenerator($version)->generate($activity, $this->organizationManager->getOrganizationElement(), $this->activityManager->getActivityElement()); if (getVal($settings['registry_info'], [0, 'publish_files']) == 'yes') { $this->publisher->publishFile($organization->settings['registry_info'], $this->organizationDataProvider->fileBeingPublished($activity->id), $organization, $organization->settings->publishing_type); $this->activityManager->activityInRegistry($activity); $this->twitter->post($organization->settings, $organization); } $this->update($details, $activity); return true; } catch (\ErrorException $exception) { $this->logger->error($exception); return null; } catch (Exception $exception) { $this->logger->error($exception); return array_first(explode("\n", $exception->getMessage()), function () { return true; }); } }
$fileInput = getValS(@$opt['i']); $fileOutput = getValS(@$opt['o']); if (isset($opt['N'])) { $fileOutput = str_replace('*',pathinfo($fileInput,PATHINFO_FILENAME),$fileOutput); } $font = loadFont($fileInput); $font['width'] = $font['width'] ? $font['width'] : 8; $maxChar = $font['max']; $pixX=getVal(@$opt['pxx'],1); $pixY=getVal(@$opt['pxy'],$pixX); $charXLine = getVal(@$opt['chl'],16); if (isset($opt['mktpl'])) { $tpl = array( 'i' => $fileOutput, 'chw' => $font['width'], 'chh' => $font['height'], 'name' => $font['name'], 'code' => $font['charset'], 'pxx' => $pixX, 'pxy' => $pixY, 'chars' => $font['max'], 'first' => 0, 'icw' => $font['width']*$pixX, 'ich' => $font['height']*$pixY, 'px' => 0,
$Applicant = @$_SESSION['SESS_Applicant_Name']; $Address = @$_SESSION['SESS_Address']; $NIC = @$_SESSION['SESS_NIC']; $Telephone = @$_SESSION['SESS_Telephone']; $Distance = @$_SESSION['SESS_Distance']; if (isset($_POST['submit'])) { $service = intval(getVal(@$_POST['service'])); $distance = intval(getVal(@$_POST['distance'])); $remoteCurrent = intval(getVal(@$_POST['remoteCurrent'])); $remote = intval(getVal(@$_POST['remote'])); $y2013 = intval(getVal(@$_POST['y2013'])); $y2012 = intval(getVal(@$_POST['y2012'])); $y2011 = intval(getVal(@$_POST['y2012'])); $y2010 = intval(getVal(@$_POST['y2010'])); $y2009 = intval(getVal(@$_POST['y2009'])); $schservice = intval(getVal(@$_POST['schservice'])); $marks31 = service(@$service); $marks32 = distance(@$distance); $marks33 = remote($remoteCurrent, $remote); $marks34 = leave($y2013, $y2012, $y2011, $y2010, $y2009); $marks35 = same_School_service($schservice); $markst = $marks31 + $marks32 + $marks33 + $marks34 + $marks35; if ($_POST['submit'] == "Submit") { $sql = "INSERT INTO educationwork_child_marks " . "(Application_ID, Category_ID, Service, Distance, RemotePresent, RemoteService, LeaveY1,LeaveY2,LeaveY3,LeaveY4,LeaveY5, ServiceSameSchool,Marks_Service, Marks_Distance, Marks_Remote, Marks_Leave, Marks_SameSchool, Marks_Total)" . "VALUES ('{$app}', '{$cat}', '{$service}', '{$distance}', '{$remoteCurrent}', '{$remote}', '{$y2013}', '{$y2012}', '{$y2011}', '{$y2010}', '{$y2009}','{$schservice}', '{$marks31}', '{$marks32}', '{$marks33}', '{$marks34}', '{$marks35}', '{$markst}') " . "ON DUPLICATE KEY UPDATE Service = VALUES (Service),Distance = VALUES (Distance),RemotePresent = VALUES (RemotePresent),RemoteService = VALUES (RemoteService),LeaveY1 = VALUES (LeaveY1),LeaveY2 = VALUES (LeaveY2),LeaveY3 = VALUES (LeaveY3),LeaveY4 = VALUES (LeaveY4),LeaveY5 = VALUES (LeaveY5),ServiceSameSchool = VALUES (ServiceSameSchool)," . "Marks_Service = VALUES (Marks_Service),Marks_Distance = VALUES (Marks_Distance),Marks_Remote = VALUES (Marks_Remote),Marks_Leave = VALUES (Marks_Leave),Marks_SameSchool = VALUES (Marks_SameSchool),Marks_Total = VALUES (Marks_Total);"; $retval = mysql_query($sql); if (!$retval) { die('Could not enter data: ' . mysql_error()); } else { $sql2 = "UPDATE application SET Marks = {$markst} WHERE Application_ID ={$app};"; $set = mysql_query($sql2); if (!$set) {
function getVar($var) { if ($var['0'] == '$') { $var = getVal(substr($var, 1)); } return $var; }
function frontend_date($name, $input = null, $options = array(), $methode = null) { $context = sfContext::getInstance(); $request = $context->getRequest(); $errors = $request->getErrors(); if (array_key_exists("err" . $name, $errors)) { $options["class"] .= " error"; } $errSpan = ""; $code = getDivLabel($options, $name); if (in_array('validate', $options)) { $errSpan = "<span id='" . $name . "Error'></span>"; } $code .= input_date_tag($name, getVal($input, $methode, $name), clearOptions($options)); $code .= $errSpan; return $code; }
</label> </div> </td> </tr> <tr> <td valign="top"><label >quoted by<br /> <?php print getRepsDrop('quotedby_repid'); ?> </label></td> </tr> <tr> <td colspan="3"> <label> comments<br /> <textarea name="comments" id="comments" cols="" rows="" class="input"><?php print getVal('comments');?></textarea> </label> </td> </tr> <tr> <td colspan="3"> <input type="hidden" name="hfname" id="hfname" /> <input type="hidden" name="hiddenuploaddir" id="hiddenuploaddir" value="<?php print $uploadDir;?>" /> <?php if(isset($_REQUEST['e'])){ print '<input type="hidden" name="e" value="'.$_REQUEST['e'].'" />'; } ?>
<!--Check whether the user is logged in.--> <?php require_once 'Authorize.php'; $app = intval(@$_SESSION['SESS_Appication']); $cat = intval(@$_SESSION['SESS_Category']); if ($app > 0 and $cat == 1) { require 'Validate.php'; //Connect to the database require_once 'Connection.php'; if (isset($_POST['submit'])) { $Elec_reg = intval(getVal(@$_POST['Elec_reg'])); $Elec_reg2 = intval(getVal(@$_POST['Elec_reg2'])); $ownership = getVal(@$_POST['ownership']); $proof = intval(getVal(@$_POST['proof'])); $other_sch = intval(getVal(@$_POST['other_sch'])); $ownerDuration = intval(getVal(@$_POST['ownerDuration'])); $marks1 = electorial_marks(@$Elec_reg, @$Elec_reg2); $marks2 = ownership(@$ownership, @$ownerDuration); $marks3 = extra_doc(@$proof); $marks4 = near($marks1, $other_sch); $markst = $marks1 + $marks2 + $marks3 + $marks4; if ($_POST['submit'] == "Submit") { $sql = "INSERT INTO residant_marks " . "(Application_ID, Category_ID, Electoral_Years, Electoral_only_One_Years, Ownership, Ownership_Years, Proofs_Count, School_Count, Marks_Electoral, Marks_Ownership, Marks_Proofs, Marks_School, Marks_Total)" . "VALUES ('{$app}', '{$cat}', '{$Elec_reg}', '{$Elec_reg2}', '{$ownership}', '{$ownerDuration}', '{$proof}', '{$other_sch}', '{$marks1}', '{$marks2}', '{$marks3}', '{$marks4}', '{$markst}') " . "ON DUPLICATE KEY UPDATE Electoral_Years = VALUES (Electoral_Years),Electoral_only_One_Years = VALUES (Electoral_only_One_Years),Ownership = VALUES (Ownership),Ownership_Years = VALUES (Ownership_Years)," . "Proofs_Count = VALUES (Proofs_Count),School_Count = VALUES (School_Count),Marks_Electoral = VALUES (Marks_Electoral),Marks_Ownership = VALUES (Marks_Ownership),Marks_Proofs = VALUES (Marks_Proofs),Marks_School = VALUES (Marks_School),Marks_Total = VALUES (Marks_Total);"; $retval = mysql_query($sql); if (!$retval) { die('Could not enter data: ' . mysql_error()); } else { $sql2 = "UPDATE application SET Marks = {$markst} WHERE Application_ID ={$app};"; $set = mysql_query($sql2); if (!$set) { die('Could not enter data: ' . mysql_error());
/** * Get transaction details provided transaction array. * @param array $transaction * @param $type * @return string */ function getTransactionProviderDetails(array $transaction, $type) { $organizationIdentifierCode = checkIfEmpty($transaction['organization_identifier_code']); $activityId = $type == 'provider' ? $transaction['provider_activity_id'] : $transaction['receiver_activity_id']; $activityId = checkIfEmpty($activityId); $transactionType = session('version') != 'V201' ? checkIfEmpty(getVal($transaction, ['type'], '<em> Not Available </em>')) : '<em>Not available</em>'; $activityIdText = $type == 'provider' ? 'Provider activity id' : 'Receiver activity id'; return sprintf('<em> (Organizational identifier code: %s , %s: %s , Type: %s) </em>', $organizationIdentifierCode, $activityIdText, $activityId, $transactionType); }
/** * @param $data * @return array */ protected function buildFunction($data) { $period = ['@attributes' => ['value' => $data[0]['value']], 'location' => $this->buildLocation(getVal($data, [0, 'location'], [])), 'dimension' => $this->buildDimension(getVal($data, [0, 'dimension'], [])), 'comment' => ['narrative' => $this->buildNarrative(getVal($data, [0, 'comment', 0, 'narrative'], []))]]; return $period; }
$Distance = @$_SESSION['SESS_Distance']; if (isset($_POST['submit'])) { if (DateTime::createFromFormat('Y-m-j', getVal(@$_POST['timef1'])) !== FALSE) { $timef1 = getVal(@$_POST['timef1']); } else { $timef1 = null; } if (DateTime::createFromFormat('Y-m-j', getVal(@$_POST['timef2'])) !== FALSE) { $timef2 = getVal(@$_POST['timef2']); } else { $timef2 = null; } $freson = getVal(@$_POST['freson']); $other_sch = intval(getVal(@$_POST['other_sch'])); $Elec_reg2 = intval(getVal(@$_POST['Elec_reg2'])); $proof = intval(getVal(@$_POST['proof'])); $marks1 = electorial_marks(0, @$Elec_reg2); $marks3 = extra_doc(@$proof); $marks41 = StayedFor($timef1, $timef2); $marks42 = reason(@$freson); $marks43 = nearforeign($marks1 + $marks3, $other_sch); $markst = $marks41 + $marks42 + $marks43; if ($_POST['submit'] == "Submit") { $sql = "INSERT INTO foreigntravel_marks " . "(Application_ID, Category_ID, JurneyFrom, JurneyTo, Reason, School_Count, Electoral_only_One_Years, Proofs_Count, Marks_Duration, Marks_Reason, Marks_School, Marks_Total)" . "VALUES ('{$app}', '{$cat}', '{$timef1}', '{$timef2}', '{$freson}', '{$other_sch}', '{$Elec_reg2}', '{$proof}', '{$marks41}', '{$marks42}', '{$marks43}', '{$markst}') " . "ON DUPLICATE KEY UPDATE JurneyFrom = VALUES (JurneyFrom),JurneyTo = VALUES (JurneyTo),Reason = VALUES (Reason),School_Count = VALUES (School_Count)," . "Electoral_only_One_Years = VALUES (Electoral_only_One_Years),Proofs_Count = VALUES (Proofs_Count),Marks_Duration = VALUES (Marks_Duration),Marks_Reason = VALUES (Marks_Reason),Marks_School = VALUES (Marks_School),Marks_Total = VALUES (Marks_Total);"; $retval = mysql_query($sql); if (!$retval) { die('Could not enter data: ' . mysql_error()); } else { $sql2 = "UPDATE application SET Marks = {$markst} WHERE Application_ID ={$app};"; $set = mysql_query($sql2); if (!$set) {
/** * Check if the Organization's publisher_id and api_id/api_key has been filled out. * @param Settings $settings * @return bool */ protected function hasNoPublisherInfo(Settings $settings) { return empty(getVal($settings->registry_info, [0, 'publisher_id'])) || empty(getVal($settings->registry_info, [0, 'api_id'])); }
$chw = getVal(@$opt['icw']); $chh = getVal(@$opt['ich'],$chw); $pixX=getVal(@$opt['pxx'],1); $pixY=getVal(@$opt['pxy'],$pixX); $pointX=intval(@$opt['px'],0); $pointY=intval(@$opt['py'] ? $opt['py'] : $pointX); $chWi = getVal(@$opt['chw']); if ($chWi<1 or $chWi>8) Helpex(); $chHe = getVal(@$opt['chh'],$chWi); $chBase = intval(@$opt['first']); $numChars=getVal(@$opt['chars'],256); $cPage=getValS(@$opt['code'],'ASCII'); $fName=getValS(@$opt['name'],pathinfo($fileInput,PATHINFO_FILENAME)); $im = imagecreatefrompng($fileInput) or die("Immagine PNG RGB non valida `$fileInput`\n"); $noise = 0xFFFFFF; if (isset($opt['n'])) $noise=0xC0C0C0; if (isset($opt['o'])) ob_start(); echo "@CP $cPage\n"; echo "@FH $chHe\n"; echo "@FW $chWi\n"; echo "@MAX $numChars\n"; echo "@VER 2\n"; echo "@NAME $fName\n";
/** * Get the file being published for the Activity with a specific activityId. * @param $activityId * @return ActivityPublished|null */ public function fileBeingPublished($activityId) { $activity = $this->activity->findOrFail($activityId); $settings = $activity->organization->settings; $publisherId = getVal($settings->registry_info, [0, 'publisher_id']); return $this->getFile($publisherId, $settings->publishing_type, $activityId, $activity->organization_id); }
function rest_getSong($artist, $songName, $fmt) { wfProfileIn(__METHOD__); global $wgRequest; // I'm not sure why, but in this context underscores don't behave like spaces automatically. $artist = str_replace("_", " ", $artist); $songName = str_replace("_", " ", $songName); // Allow debug suffix to persist (needs an underscore instead of a space). It is recommended to use debug=1 instead though. $songName = preg_replace("/ debug\$/i", "_debug", $songName); // allow the debug suffix to be passed through correctly. // Allow "&debug=1" as a URL param option instead of just messing with the song name (cleaner this way). $debugMode = $wgRequest->getBool('debug'); if ($debugMode) { $songName .= "_debug"; } $client = strtolower(getVal($_GET, 'client')); $lyricsTagFound = false; // will be modified by reference $doHyphens = true; $ns = NS_MAIN; $isOuterRequest = true; // optional parameters which we need to hardcode to get to the last parameter $result = getSong($artist, $songName, $doHyphens, $ns, $isOuterRequest, $debugMode, $lyricsTagFound); // Special case: if there was no lyrics tag found, attempt to parse the returned wikitext to look for a tracklisting. if (!$lyricsTagFound && 0 < preg_match("/\\[\\[.*\\]\\]/", getVal($result, 'lyrics'))) { // The result wasn't lyrics, but was some other page which appears to contain a tracklisting. Pass off processing to handle that. $this->rest_printListing($result['artist'] . ":" . $result['song'], $result['lyrics'], $fmt); } else { switch ($fmt) { case 'php': print serialize($result); break; case "text": print utf8_decode($result['lyrics']); //print "\n\n".$result['url']; break; case "js": $this->writeJS($result); break; case "json": $this->writeJSON_deprecated($result); break; case "realjson": /** * Add Comscore reporting (BugzId:33112), * unfortunately we can't repackage the app ATM, * this is hacky but we need to get that reporting now. * * @TODO remove when we'll get to v2 of the app * @author Jakub Olek */ $fullApiAuth = $wgRequest->getVal('fullApiAuth'); if (!empty($fullApiAuth)) { $result['lyrics'] .= self::COMSCORE_TAG_PLACEHOLDER; } $this->writeRealJSON($result); break; case "xml": header('Content-Type: application/xml', true); print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; print "<LyricsResult>\n"; // TODO: Would probably be best to extract this whole XMLing function and make it recursive for inner-arrays (look into dumpXml_hacky() and why that's not being used here). foreach ($result as $keyName => $val) { if (is_array($val)) { print "\t<{$keyName}>\n"; $innerTagName = $keyName . "_value"; // standard name of inner-tag // If wrapping tag is plural, make inner-tag the singular if that's straightforward. $matches = array(); if (0 < preg_match("/^(.*?)e?s\$/i", $keyName, $matches)) { $innerTagName = $matches[1]; } foreach ($val as $innerVal) { print "\t\t<{$innerTagName}>" . utf8_decode(htmlspecialchars($innerVal, ENT_QUOTES, "UTF-8")) . "</{$innerTagName}>\n"; } print "\t</{$keyName}>\n"; } else { print "\t<{$keyName}>" . utf8_decode(htmlspecialchars($val, ENT_QUOTES, "UTF-8")) . "</{$keyName}>\n"; } } print "</LyricsResult>\n"; break; case "html": default: // Link to the song & artist pages as a heading. $this->htmlHead($result['artist'] . " " . $result['song'] . " lyrics"); print Xml::openElement('h3'); print Xml::openElement('a', array('href' => $this->root . $this->linkEncode($result['artist'] . ":" . $result['song']))); print utf8_decode(htmlspecialchars($result['song'], ENT_QUOTES, "UTF-8")); print Xml::closeElement('a'); print ' by '; print Xml::openElement('a', array('href' => $this->root . $this->linkEncode($result['artist']))); print utf8_decode(htmlspecialchars($result['artist'], ENT_QUOTES, "UTF-8")); print Xml::closeElement('a'); print Xml::closeElement('h3'); print "\n"; print Xml::openElement('pre'); print "\n"; $lyricsHtml = utf8_decode(htmlspecialchars($result['lyrics'], ENT_QUOTES, "UTF-8")); // Special case to make sure the gracenote copyright symbol gets parsed correctly when needed. $lyricsHtml = str_replace("&copy;", "©", $lyricsHtml); print $lyricsHtml; print Xml::closeElement('pre'); // Make it extensible by displaying any extra data in a UL. unset($result['artist']); unset($result['song']); unset($result['lyrics']); if (count($result) > 0) { print "<hr/> Additional Info:\n"; print Xml::openElement('ul'); print "\n"; foreach ($result as $keyName => $val) { if (is_array($val)) { print Xml::openElement('li'); print Xml::openElement('strong'); print htmlspecialchars($keyName, ENT_QUOTES, "UTF-8") . ": "; print Xml::openElement('ul'); foreach ($val as $innerVal) { print Xml::openElement('li'); // TODO: IF keyName == "searchResults", MAKE THESE INTO LINKS TO WIKI PAGES INSTEAD OF JUST PLAINTEXT. print $innerVal; print Xml::closeElement('li'); } print Xml::closeElement('ul'); print Xml::closeElement('strong'); print Xml::closeElement('li'); } else { if (0 < preg_match("/^http:\\/\\//", $val)) { print Xml::openElement('a', array('href' => $val, 'title' => $keyName)); print utf8_decode(htmlspecialchars($val, ENT_QUOTES, "UTF-8")); print Xml::closeElement('a'); print "\n"; print Xml::openElement('li'); print Xml::openElement('strong'); print htmlspecialchars($keyName, ENT_QUOTES, "UTF-8") . ": "; print Xml::closeElement('strong'); print htmlspecialchars($val, ENT_QUOTES, "UTF-8"); print Xml::closeElement('li'); } else { print Xml::openElement('li'); print Xml::openElement('strong'); print htmlspecialchars($keyName, ENT_QUOTES, "UTF-8") . ": "; print Xml::closeElement('strong'); print utf8_decode(htmlspecialchars($val, ENT_QUOTES, "UTF-8")); print Xml::closeElement('li'); print "\n"; } } } print Xml::closeElement('ul') . "\n"; } print Xml::closeElement('body') . "\n" . Xml::closeElement('html') . "\n"; break; } // end switch } wfProfileOut(__METHOD__); }