public static function getDirections(Route $route, $version = 0) { /** * @var DB */ $dbObj = DBPool::getInstance(); $version = $version == 0 ? TableUpdate::getVersion() : $version; $dbObj->bindParams(array($route->getId(), $version)); $directions = $dbObj->get_results("SELECT * FROM direction WHERE route_id=?\n AND version = ?"); if ($dbObj->num_rows > 0) { $directionArray = array(); foreach ($directions as $d) { $dirObj = new Direction(); $dirObj->setId($d->id); $dirObj->setName($d->name); $dirObj->setPrettyName($d->pretty_name); $dirObj->setRoute($route); $dirObj->setTag($d->tag); $dirObj->setTitle($d->title); $dirObj->setPrettyTitle($d->pretty_title); $dirObj->setUseForUi($d->use_for_ui); $dirObj->setShow($d->show); $directionArray[$d->tag] = $dirObj; } return $directionArray; } else { //TODO: Don't use a generic exception throw new Exception("No data available - Direction::getDirections"); } }
/** * This is construct base of the class. * * A public constructor; initializes the variable $instanceDataBase. * */ public function __construct($instanceDataBase) { parent::__construct($instanceDataBase); Direction::setDataOperationBusiness($instanceDataBase); Direction::getBusiness(); Direction::getDescriptionBusiness(); }
/** * Add apartment page * @return \Illuminate\View\View */ public function home() { $apartment = new ListApartment(); //Hard code $apartment->username = Auth::user()->username; // Get all district $district = ListDistrict::lists('name_district', 'id_district'); // Get all province $province = ListProvice::lists('name_province', 'id_province'); // Get all project $projects = ListProject::lists('name', 'ID'); //Get project $project_id = Input::get('project'); $apartment->project = $project_id; // Get all furniture $furnitures = Furniture::lists('name', 'ID'); // Get all management company $directions = Direction::lists('name', 'ID'); // Get all floor material $floor_materials = FloorMaterial::lists('name', 'ID'); // Clear Session for ($i = -2; $i < 8; $i++) { if (Session::has("image[{$i}]")) { Session::remove("image[{$i}]"); } } return View::make('pages.apartment', compact('apartment', 'district', 'province', 'projects', 'project_id', 'furnitures', 'directions', 'floor_materials')); }
public function actionGetGroups() { $keys = array_keys($_GET); $direction_id = (int) $keys[0]; $direction = Direction::model()->findByPk($direction_id); $groups = CHtml::listData($direction->groups, 'id', 'name'); foreach ($groups as $value => $name) { echo '<option value="' . $value . '">' . $name . '</option>'; } }
function generateXMLFile(Agency $agencyObj) { $dbObj = DBPool::getInstance(); $routeArray = Route::getRoutes($agencyObj); $stopArray = Stop::getStops($agencyObj); $xmlStr = '<?xml version="1.0" encoding="UTF-8" ?><agency title="' . $agencyObj->getTitle() . '" shortTitle="' . $agencyObj->getShortTitle() . '"></agency>'; $xml = new SimpleXMLElement($xmlStr); foreach ($stopArray as $s) { $stop = $xml->addChild("stop"); $stop->addAttribute("tag", $s->getTag()); $stop->addAttribute("title", $s->getPrettyTitle()); $stop->addAttribute("lat", $s->getLatitude()); $stop->addAttribute("lon", $s->getLongitude()); $stop->addAttribute("oppositeStopTag", $s->getFlipStopTag()); } foreach ($routeArray as $r) { $route = $xml->addChild("route"); $route->addAttribute("tag", $r->getTag()); $route->addAttribute("title", $r->getTitle()); $route->addAttribute("shortTitle", $r->getShortTitle()); $route->addAttribute("color", $r->getColor()); $route->addAttribute("latMin", $r->getLatMin()); $route->addAttribute("latMax", $r->getLatMax()); $route->addAttribute("lonMin", $r->getLonMin()); $route->addAttribute("lonMax", $r->getLonMax()); $route->addAttribute("vehicle", $r->getVehicleType()); $route->addAttribute("sortOrder", $r->getPosition()); $directionsArray = Direction::getDirections($r); foreach ($directionsArray as $d) { $dir = $route->addChild("direction"); $dir->addAttribute("tag", $d->getTag()); $dir->addAttribute("title", $d->getPrettyTitle()); $dir->addAttribute("name", $d->getPrettyName()); $dir->addAttribute("show", $d->getShow() ? "true" : "false"); $dir->addAttribute("useForUI", $d->getUseForUi() ? "true" : "false"); $dbObj->bindParams(array($d->getId())); $stopDirMap = $dbObj->get_results("SELECT a.tag, b.position\n FROM stop as a, stop_direction_map as b\n WHERE a.id=b.stop_id AND b.direction_id=?\n ORDER BY b.position"); if ($dbObj->num_rows > 0) { foreach ($stopDirMap as $m) { $map = $dir->addChild("stop"); $map->addAttribute("tag", $m->tag); } } } } $fileName = Util::getBaseDirectoryPath(Util::XML_FILE) . $agencyObj->getShortTitle() . ".xml"; Util::prettyPrintXml($xml, $fileName); }
public function updateStopDirMap() { /** * @var DB */ $dbObj = DBPool::getInstance(); $routeArray = Route::getRoutes($this->agency); $stopArray = Stop::getStops($this->agency); $bartApiKey = $this->appConfig['BART_API_KEY']; foreach ($routeArray as $routeTag => $routeObj) { $pos = 0; $directionArray = Direction::getDirections($routeObj); foreach ($directionArray as $dirTag => $dirObj) { //We're only interested in the directions we're showing if (!$dirObj->getShow()) { continue; } //Fetch the direction details $apiURL = str_replace(BartApiEndPoints::DIRECTION, $dirObj->getTag(), BartApiEndPoints::ROUTE_INFO . $bartApiKey); $dirInfoXmlBuilder = new XmlObjBuilder($apiURL); $dirInfoXml = $dirInfoXmlBuilder->getXmlObj(); foreach ($dirInfoXml->routes->route->config as $c) { foreach ($c as $station) { $pos++; $stopTag = (string) $station; $tempStopObj = $stopArray[$stopTag]; $stopId = $tempStopObj->getId(); $tempDirObj = $directionArray[$dirTag]; $dirId = $tempDirObj->getId(); $dbObj->bindParams(array($stopId, $dirId, $pos, TableUpdate::getVersion())); $dbObj->query("INSERT INTO stop_direction_map\n (stop_id, direction_id, position, version, created_date)\n VALUES (?, ?, ?, ?, NOW())"); if ($dbObj->rows_affected != 1) { //TODO: Log it } } //Stations } } //Directions } //Routes }
public function updateStopDirMap() { /** * @var DB */ $dbObj = DBPool::getInstance(); $routeArray = Route::getRoutes($this->agency); $stopArray = Stop::getStops($this->agency); foreach ($this->xml->route as $r) { $routeTag = (string) $r['tag']; $routeObj = $routeArray[$routeTag]; foreach ($r->direction as $d) { $pos = 0; $dirTag = (string) $d['tag']; $directionArray = Direction::getDirections($routeObj); $dirObj = $directionArray[$dirTag]; //We're only interested in the directions we're showing //if (!$dirObj->getShow()) { continue; } foreach ($d->stop as $s) { $pos++; $stopTag = (string) $s['tag']; $tempStop = $stopArray[$stopTag]; if (empty($tempStop)) { var_dump("{$routeTag} {$stopTag}"); } $stopId = $tempStop->getId(); $tempDir = $directionArray[$dirTag]; $dirId = $tempDir->getId(); $dbObj->bindParams(array($stopId, $dirId, $pos, TableUpdate::getVersion())); $dbObj->query("INSERT INTO stop_direction_map\n (stop_id, direction_id, position, version, created_date)\n VALUES (?, ?, ?, ?, NOW())"); if ($dbObj->rows_affected != 1) { //TODO: Log it } } } } }
public function updateDirections() { //Fetch all the routes that are already in the database try { $routeArray = Route::getRoutes($this->agency); } catch (Exception $ex) { throw new Exception("BART directions could not be updated"); } foreach ($routeArray as $routeTag => $routeObj) { //Build an array of direction objects $directionInfo = array(); //Add the directions for every route foreach ($this->xml->routes->route as $d) { $tempRouteTag = BartColorCodes::getBartColor(substr((string) $d->color, 1)); if ($tempRouteTag == $routeTag) { $dirObj = new Direction(); $dirTag = (string) $d->number; $useForUiValue = true; //Always true for BART $dirObj->setRoute($routeObj); $dirObj->setTag($dirTag); $dirObj->setTitle($this->formatTitle((string) $d->name)); $dirObj->setName((string) $d->abbr); $dirObj->setUseForUi($useForUiValue); $dirObj->setShow($useForUiValue); $directionInfo[$dirTag] = $dirObj; } } //var_dump($directionInfo);exit; //Update the database try { //Pass it to the base DirectionUpdate class $dirUpdate = new DirectionUpdate($routeObj, $directionInfo); $dirUpdate->updateDB(); } catch (Exception $ex) { throw new Exception($ex->getMessage()); } } }
public function updateDirections() { //Fetch all the routes that are already in the database try { $routeArray = Route::getRoutes($this->agency); } catch (Exception $ex) { throw new Exception("Nextbus directions could not be updated. Error building route array."); } //Add the directions for every route foreach ($this->xml->route as $r) { $routeTag = (string) $r['tag']; $routeObj = $routeArray[$routeTag]; //Build an array of direction objects $directionInfo = array(); foreach ($r->direction as $d) { $dirObj = new Direction(); $dirTag = (string) $d['tag']; $useForUiValue = (string) $d['useForUI'] == "false" ? false : true; $dirObj->setRoute($routeObj); $dirObj->setTag($dirTag); $dirObj->setTitle((string) $d['title']); $dirObj->setName((string) $d['name']); $dirObj->setUseForUi($useForUiValue); $dirObj->setShow($this->getShowValue($routeTag, $dirTag, $useForUiValue)); $directionInfo[$dirTag] = $dirObj; } //Update the database try { //Pass it to the base DirectionUpdate class $dirUpdate = new DirectionUpdate($routeObj, $directionInfo); $dirUpdate->updateDB(); } catch (Exception $ex) { throw new Exception($ex->getMessage()); } } }
public function save_recipe($post_id) { $ingredients = $_POST["ingredients"]; $directions = $_POST["directions"]; $directions_array = array(); libxml_use_internal_errors(true); $dom = new DOMDocument(); $dom->loadHTML('<?xml encoding="UTF-8">' . $ingredients); $items = $dom->documentElement; $result = array(); foreach ($items->childNodes as $item) { if ($item->hasChildNodes()) { $childs = $item->childNodes; foreach ($childs as $i) { $result = array_merge($result, $this->input_parser($i)); } } } Ingredient::delete_recipe_ingredients($post_id); $lines = $result; //$resulpreg_split( "/[\n\r]+/", $ingredients ); $count = 1; foreach ($lines as $line) { $ing = Ingredient::process($line, $count); if ($ing) { $ing->add_to_database($post_id); $count++; } } $dom->loadHTML('<?xml encoding="UTF-8">' . $directions); $items = $dom->documentElement; $result = array(); foreach ($items->childNodes as $item) { if ($item->hasChildNodes()) { $childs = $item->childNodes; foreach ($childs as $i) { $result = array_merge($result, $this->input_parser($i)); } } } $lines = $result; //preg_split( "/[\n\r]+/", $directions ); $count = 1; foreach ($lines as $line) { $step = Direction::process($count, $line); if ($step) { $directions_array[] = $step; } $count++; } update_post_meta($post_id, 'directions', $directions_array); if (isset($_POST["recipe_asin"])) { $array = explode(",", wp_strip_all_tags($_POST["recipe_asin"])); $array = array_filter($array); update_post_meta($post_id, 'equipment', implode(",", $array)); } if (isset($_POST["notes"])) { update_post_meta($post_id, 'notes', wp_strip_all_tags($_POST["notes"])); } if (isset($_POST["source"])) { update_post_meta($post_id, 'source', wp_strip_all_tags($_POST["source"])); } if (isset($_POST["source-url"])) { update_post_meta($post_id, 'source_url', wp_strip_all_tags($_POST["source-url"])); } if (strlen($_POST["prep-time-hour"]) || strlen($_POST["prep-time-min"])) { $min = 0 + (int) $_POST["prep-time-hour"] * 60; $min = $min + (int) $_POST["prep-time-min"]; update_post_meta($post_id, 'prep_time', $min); } else { update_post_meta($post_id, 'prep_time', 0); } if (strlen($_POST["cooking-time-hour"]) || strlen($_POST["cooking-time-min"])) { $min = 0 + (int) $_POST["cooking-time-hour"] * 60; $min = $min + (int) $_POST["cooking-time-min"]; update_post_meta($post_id, 'cooking_time', $min); } else { update_post_meta($post_id, 'cooking_time', 0); } if (strlen($_POST["total-time-hour"]) || strlen($_POST["total-time-min"])) { $min = 0 + (int) $_POST["total-time-hour"] * 60; $min = $min + (int) $_POST["total-time-min"]; update_post_meta($post_id, 'total_time', $min); } else { update_post_meta($post_id, 'total_time', 0); } if (isset($_POST["yield"])) { update_post_meta($post_id, 'yield', wp_strip_all_tags($_POST["yield"])); } if (isset($_POST["category"])) { update_post_meta($post_id, 'category', wp_strip_all_tags($_POST["category"])); } if (isset($_POST["cuisine"])) { update_post_meta($post_id, 'cuisine', wp_strip_all_tags($_POST["cuisine"])); } }
function Edit_Building(Building $Building, $BUL_ID, Place $Place, $Place_ID, Direction $Dir, $Direction_ID) { //start the transaction $query1 = "START TRANSACTION"; $result1 = mysqli_query($this->getDbc(), $query1); $Building_Name = $Building->getName(); $Building_Name_Amharic = $Building->getNameAmharic(); $Building_Description = $Building->getBuildingDescription(); $Building_Description_Amharic = $Building->getBuildingDescriptionAmharic(); $Parking_Area = $Building->getParkingArea(); $Building_ID = $BUL_ID; //now edit the company; $query2 = "Update Building set\n\t\tName='{$Building_Name}',Name_Amharic = '{$Building_Name_Amharic}'\n\t\t,Building_Description='{$Building_Description}'\n\t\t,Building_Description_Amharic='{$Building_Description_Amharic}',\n\t\tParking_Area='{$Parking_Area}' where ID='{$Building_ID}'"; $result2 = mysqli_query($this->getDbc(), $query2); if ($result2) { echo "result 2"; } //edit the place $Region_ID = $Place->getRegionID(); $City_ID = $Place->getCityID(); $Sub_City_ID = $Place->getSubCityID(); $Wereda_ID = $Place->getWeredaID(); $Sefer_ID = $Place->getSeferID(); $Street_ID = $Place->getStreetID(); $query3 = "update place set\n\t\t\t\tRegion='{$Region_ID}',City='{$City_ID}',Sub_City='{$Sub_City_ID}',Wereda='{$Wereda_ID}',Sefer='{$Sefer_ID}',Street='{$Street_ID}'\n\t\t\t\twhere ID='{$Place_ID}'"; $result3 = mysqli_query($this->getDbc(), $query3); if ($result3) { echo "result 3"; } //update direction $Direction = $Dir->getDirection(); $Direction_Amharic = $Dir->getDirectionAmharic(); $query4 = "update direction set\n\t\t\t\t\tDirection='{$Direction}',Direction_Amharic='{$Direction_Amharic}'\n\t\t\t\t\twhere ID='{$Direction_ID}'"; $result4 = mysqli_query($this->getDbc(), $query4); if ($result4) { echo "result 4"; } if ($result1 and $result2 and $result3 and $result4) { $query_last = "COMMIT"; mysqli_query($this->getDbc(), $query_last); return TRUE; } else { $query_last = "ROLLBACK"; mysqli_query($this->getDbc(), $query_last); return FALSE; } }
public function ToHTMLUserPrivateShortInTable() { $author = User::FetchBy(['eq_conds' => ['id' => $this->author_id], 'select_list' => 'id, name, surname, login', 'is_unique' => true]); $res = '<tr>'; $res .= '<td>' . Direction::FetchByID($this->direction_id)->LinkToThis() . '</td>'; $res .= '<td>' . htmlspecialchars($this->name) . '</td>'; $res .= '<td>' . date('d : m : Y - H : i', $this->creating_date) . '</td>'; $res .= '<td>' . $author->LinkToThis() . '</td>'; $res .= '<td>'; $res .= '<div class="row">'; if (GetUserLogin() === $author->GetLogin() || GetUserLogin() === 'admin') { $res .= '<div class="' . ColAllTypes(4) . '">'; } else { $res .= '<div class="' . ColAllTypes(12) . '">'; } $res .= $this->ToHTMLFullVers(); $res .= '</div>'; if (GetUserLogin() === $author->GetLogin() || GetUserLogin() === 'admin') { $res .= '<div class="' . ColAllTypes(4) . '">'; $res .= $this->ToHTMLEdit(); $res .= '</div>'; $res .= '<div class="' . ColAllTypes(4) . '">'; $res .= $this->ToHTMLDel(); $res .= '</div>'; } $res .= '</div>'; $res .= '</td>'; $res .= '</tr>'; return $res; }
function Add_Direction(Direction $direction) { $Direction = $direction->getDirection(); $Direction_Amharic = $direction->getDirectionAmharic(); $query = "INSERT INTO Direction (Direction,Direction_Amharic) VALUES('{$Direction}','{$Direction_Amharic}')"; $result = mysqli_query($this->getDbc(), $query); if ($result) { return TRUE; } else { return FALSE; } }
public function updateStops() { $routeArray = Route::getRoutes($this->agency); $flipStopMap = $this->getFlipStopOverrides(); $stopTitleMap = array(); $stopLatLonMap = array(); $uniqueStopsAcrossRoutes = array(); //Generate maps of stopTag => StopTitle and stopTag => [lat, lon] for //later look up foreach ($this->xml->route as $r) { foreach ($r->stop as $s) { $stopTag = (string) $s['tag']; $stopTitle = html_entity_decode((string) $s['title']); $lat = (string) $s['lat']; $lon = (string) $s['lon']; $stopTitleMap[$stopTag] = $stopTitle; $stopLatLonMap[$stopTag] = array("lat" => $lat, "lon" => $lon); $uniqueStopsAcrossRoutes[] = $stopTag; } //Stops } //Routes //We'll only consider the stops in the directions with show=true foreach ($this->xml->route as $r) { $routeTag = (string) $r['tag']; //if($routeTag != "25") {continue;} $routeObj = $routeArray[$routeTag]; $dirArray = Direction::getDirections($routeObj); $agencyName = $routeObj->getAgency()->getShortTitle(); $trackDuplicatesInDir = array(); /** * @var Array $routeDirDetails - Array representation of the * directions and stops in a route */ $routeDirDetails = array(); foreach ($r->direction as $d) { $dirTag = (string) $d['tag']; $dirObj = $dirArray[$dirTag]; $dirStops = array(); //if ($dirObj->getShow()) { foreach ($d->stop as $s) { $stopTag = (string) $s['tag']; $stopTitle = $stopTitleMap[$stopTag]; $dirStops[$stopTag] = $stopTitle; } //Stops $routeDirDetails[$dirObj->getTag()] = $dirStops; //} //Check for show=true } //Directions //Now that we have the details of the directions for this group, //let's find the flip stops foreach ($routeDirDetails as $fDirTag => $fDirStops) { foreach ($routeDirDetails as $fDirTagDiffDir => $fDirStopsDiffDir) { if ($fDirTag == $fDirTagDiffDir) { continue; } foreach ($fDirStops as $fStopTag => $fStopTitle) { //Check if we have one or more matching flip stops in the //direction we are checking against $fFlipStopInOppDir = $this->getFlipStopsInOppDir($fStopTag, $fStopTitle, $fDirStopsDiffDir); //If we don't have any flip stops continue to the next stop if (count($fFlipStopInOppDir) == 0) { continue; } if (count($fFlipStopInOppDir) > 1) { //We have encountered more than one stop at the //same intersection in a different direction //TODO: This has to go in the e-mail report //Generate the (stopTag, lat, lon) string $fstopLatLonMap = array(); $fstopLatLonMap[] = "{$fStopTag}," . implode(",", $stopLatLonMap[$fStopTag]); foreach ($fFlipStopInOppDir as $tempStopForOppDir) { $fstopLatLonMap[] = "{$tempStopForOppDir}," . implode(",", $stopLatLonMap[$tempStopForOppDir]); } $logStr = "More than one stop in diff. direction [agency: " . $agencyName . "] [route: " . $routeTag . "] [current stop|dir: {$fStopTag}|{$fDirTag}] [other stops|dir: " . implode(",", $fFlipStopInOppDir) . "|{$fDirTagDiffDir}] [stop title: " . $fStopTitle . "] [" . implode("|", $fstopLatLonMap) . "]"; //$this->logger->log($logStr, Logger::WARN, NxtbusStop::PACKAGE); } else { if (!array_key_exists($fStopTag, $flipStopMap)) { $tempFlipStopTag = $fFlipStopInOppDir[0]; $flipStopMap[$fStopTag] = $tempFlipStopTag; $flipStopMap[$tempFlipStopTag] = $fStopTag; } } } } // Inner loop } //Find flip stops } //Routes //Check if any of the stops don't have a flip stop $uniqueStopsAcrossRoutes = array_unique($uniqueStopsAcrossRoutes); foreach ($uniqueStopsAcrossRoutes as $finalCheckStopTag) { if (!array_key_exists($finalCheckStopTag, $flipStopMap)) { $flipStopMap[$finalCheckStopTag] = ""; } } //Create the Stop objects $stopArray = array(); foreach ($this->xml->route as $r) { foreach ($r->stop as $s) { $stopTag = (string) $s['tag']; $stopTitle = html_entity_decode($s['title']); if (array_key_exists($stopTag, $flipStopMap) && !array_key_exists($stopTag, $stopArray)) { $stopObj = new Stop(); $stopObj->setAgency($this->agency); $stopObj->setTag($stopTag); $stopObj->setTitle((string) $stopTitle); $stopObj->setFlipStopTag($flipStopMap[$stopTag]); $stopObj->setLatitude((string) $s['lat']); $stopObj->setLongitude((string) $s['lon']); $stopArray[$stopTag] = $stopObj; } } //Stops } //Routes try { //Pass it to the base RouteUpdate class $stopUpdate = new StopUpdate($this->agency, $stopArray); $stopUpdate->updateDB(); } catch (Exception $ex) { throw new Exception($ex->getMessage()); } }
function displayClueEditForm(Clue $clue) { $dateSelect = ui_select('date', Date::getAllDates(), $clue->getFormDate()); $defaultStateSelect = ui_select('defaultState', State::getAllStates(), $clue->getDefaultState()); $startDateSelect = ui_select("startDate", Date::getAllDatesNullable(), $clue->getStartFormDate()); $hintDateSelect = ui_select("hintDate", Date::getAllDatesNullable(), $clue->getHintFormDate()); $answerDateSelect = ui_select("answerDate", Date::getAllDatesNullable(), $clue->getAnswerFormDate()); $startCitySelect = ui_select("startCity", City::getAllCityNames(), $clue->getStartCityID()); $hintCitySelect = ui_select("hintCity", City::getAllCityNames(), $clue->getHintCityID()); $answerCitySelect = ui_select("answerCity", City::getAllCityNames(), $clue->getAnswerCityID()); $startDirectionSelect = ui_select("startDirection", Direction::getAllDirections(), $clue->getStartDirection()); $hintDirectionSelect = ui_select("hintDirection", Direction::getAllDirections(), $clue->getHintDirection()); $answerDirectionSelect = ui_select("answerDirection", Direction::getAllDirections(), $clue->getAnswerDirection()); return <<<EOT <form method="POST" action="clues.php"> Name (admin use only): <input type="hidden" name="id" value="{$clue->getID()}" /> <input type="text" name="name" value="{$clue->getName()}" /> <br /> Date (for sorting): {$dateSelect} <input type="text" size="8" name="time" value="{$clue->getFormTime()}" /> <br /> Default state: {$defaultStateSelect} <br /> Question: <br /> <textarea name="question" cols="45" rows="8">{$clue->getQuestion()}</textarea><br /> Hint: <br /> <textarea name="hint" cols="45" rows="4">{$clue->getHint()}</textarea><br /> Answers (1 per line, * for wildcard): <br /> <textarea name="answer" cols="45" rows="4">{$clue->getAnswerText()}</textarea><br /> <br /><br /> Answering prerequisites:<br /> <input type="text" size="4" name="startDistance" value="{$clue->getStartDistance()}" /> miles {$startDirectionSelect} {$startCitySelect} or after time {$startDateSelect} <input type="text" size="8" name="startTime" value="{$clue->getStartFormTime()}" />.<br /><br /> Hint conditions:<br /> <input type="text" size="4" name="hintDistance" value="{$clue->getHintDistance()}" /> miles {$hintDirectionSelect} {$hintCitySelect} or after time {$hintDateSelect} <input type="text" size="8" name="hintTime" value="{$clue->getHintFormTime()}" />.<br /><br /> Auto-answering conditions:<br /> <input type="text" size="4" name="answerDistance" value="{$clue->getAnswerDistance()}" /> miles {$answerDirectionSelect} {$answerCitySelect} or after time {$answerDateSelect} <input type="text" size="8" name="answerTime" value="{$clue->getAnswerFormTime()}" />.<br /><br /> <input type="submit" name="edit" value="Edit Clue" /> <br /><br /> Delete clue: <input type="submit" name="delete" value="Delete Clue" /> </form> EOT; }
include_once '../common/headers.php'; echo '<p>Select route:'; $dropdown = new DropDown('routeID', Route::GetAllRoutes()); $form = new Form(); $form->Add($dropdown); $form->Add(new SubmitButton()); echo $form->ToString(); if (isset($_POST['routeID'])) { /* adding a direction */ echo '<hr />'; $route_id = $_POST['routeID']; $dir = $_POST['direction']; $descr = $_POST['description']; $stops = explode(',', $_POST['stops']); echo 'adding direction ' . $descr . ' to route ' . $route_id; $new_dir = new Direction($route_id, $dir, $descr); $new_dir->WriteToDatabase(); echo '<p>route direction created as ID ' . $new_dir->GetID() . ', adding stops... '; $sequence = 0; foreach ($stops as $stopValue) { $stop = trim($stopValue); $new_dir->AddStop($stop, $sequence); $sequence++; } echo $sequence . ' stops added.</p>'; echo '<hr/>'; } if (isset($_GET['routeID'])) { $route = new Route(false, false, $_GET['routeID']); echo '<p>Route: ' . $route->short_name . ' ' . $route->long_name; $route_directions = $route->GetDirections();
$title = Language::Word('project editing'); $header = $title; } else { if (isset($_REQUEST['add_lang'])) { $project = Project::FetchByID($_REQUEST['id']); $proj_langs = $project->FetchLanguages(); $free_languages = array_diff($languages, $proj_langs); if (count($free_languages) === 0) { $content = AlertMessage('alert-danger', Language::Word('all languages of this project is implemented')); } else { $id = User::GetIDByLogin($_SESSION['user_login']); clear_tmp_images_dir(Project::$type, $id); global $link_to_utility_sql_worker; global $link_to_img_upload; global $languages; $dirs = Direction::FetchAll(); $select_fields = array(); for ($i = 0, $size = count($dirs); $i < $size; ++$i) { $select_fields[$dirs[$i]->id] = $dirs[$i]->name; } $content .= '<form method="post" action="' . $link_to_utility_sql_worker . '">'; $content .= PairLabelAndInput(4, 5, Language::Word('header'), 'name', Language::Word('insert header')) . '<br>'; $content .= PairLabelAndSelect(4, 5, Language::Word('language'), 'language', $free_languages, array(key($free_languages), current($free_languages))); $content .= WrapToHiddenInputs(array('type' => Project::$type, 'yes' => '', 'id' => $id, 'glob_id' => $project->id, 'direction_id' => $project->direction_id)); $content .= '<div class="row"><h3>' . Language::Word('text') . '</h3></div>'; $content .= '<div class="row">'; $content .= '<div class="' . ColAllTypes(8) . ' ' . ColOffsetAllTypes(2) . '" align="center">'; $content .= '<textarea id="text_block" name="text_block"></textarea>'; $content .= '</div>'; $content .= '</div>'; $content .= '<script>';
echo $form->labelEx($model, 'faculty_id'); ?> <?php echo $form->dropDownList($model, 'faculty_id', Faculty::all()); ?> <?php echo $form->error($model, 'faculty_id'); ?> </div> <br> <div class="row"> <?php echo $form->labelEx($model, 'direction_id'); ?> <?php echo $form->dropDownList($model, 'direction_id', Direction::all()); ?> <?php echo $form->error($model, 'direction_id'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?> </div> <?php $this->endWidget(); ?>
} } break; case Direction::$type: $assoc = $_POST; $assoc['author_id'] = $_POST['id']; unset($assoc['id']); $direction = Direction::FetchFromAssoc($assoc); if ($direction === NULL) { $content = AlertMessage('alert-danger', Language::Word('error during direction adding')); } else { $glob_id = 0; if (isset($_POST['glob_id'])) { $glob_id = $_POST['glob_id']; } if (Direction::InsertToDB($direction, $_POST['language'], $glob_id)) { $content = AlertMessage('alert-success', Language::Word('direction is successfully added')); } else { $content = AlertMessage('alert-danger', Language::Word('error during direction inserting')); } } break; case Project::$type: $assoc = $_POST; $assoc['author_id'] = $_POST['id']; unset($assoc['id']); $project = Project::FetchFromAssoc($assoc); if ($project === NULL) { $content = AlertMessage('alert-danger', Language::Word('error during project adding')); } else { $glob_id = 0;
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Direction the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Direction::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionDone() { $id = $_GET['id']; $model = Direction::model()->findByPk($id); $model->done = 1; if ($model->save()) { $this->actionAdmin(); } }
$tmp = Project::FetchByDirectionID($directions[$i]->id); if ($tmp !== NULL) { $projects = array_merge($projects, $tmp); } } $size = count($projects); if ($size) { require $link_to_pagination_init_template; for ($i = $from; $i <= $to; ++$i) { $project = $projects[$i]; if ($i === $from || $i > $from && $projects[$i - 1]->direction_id != $project->direction_id) { if ($i != $from) { $content .= '<hr>'; } $content .= '<div align="left" style="padding: 15px; background-color: #eeeeee;">'; $content .= Language::Word('direction') . ': ' . Direction::FetchByID($project->direction_id)->LinkToThis(); $content .= '</div><hr>'; } $content .= $project->ToHTMLAutoShortForTable(GetUserPrivileges()); } } else { $content .= ToPageHeader(Language::Word('no projects'), 'h3', 'black'); } $header .= Language::PublicMenu('projects'); } } } else { //Manage articles $content .= MenuButton(Language::PublicMenu('articles'), $_SERVER['PHP_SELF'] . '?content_type=' . $content_types_short['articles']); //Manage directions $content .= MenuButton(Language::PublicMenu('directions'), $_SERVER['PHP_SELF'] . '?content_type=' . $content_types_short['directions']);
public static function Delete($id) { global $db_connection; global $link_to_direction_images; global $link_to_logo; $direction = Direction::FetchByID($id); $langs = $direction->FetchLanguages(); $from_table = Direction::$table; if ($direction->language !== 'rus') { $from_table .= '_' . $direction->language; } if (!$db_connection->query("DELETE FROM `" . $from_table . "` WHERE `id` = " . $id)) { return 0; } else { if (count($langs) < 2) { $projs = Project::FetchByDirectionID($id, array('all')); if ($projs != NULL) { for ($i = 0, $size = count($projs); $i < $size; ++$i) { if (!$projs[$i]->DeleteThis()) { echo 'error while deleting projects on proj id: ' . $projs[$i]->id; return 0; } } } removeDirectory($link_to_direction_images . $id); } else { if ($direction->path_to_image !== $link_to_logo) { unlink($direction->path_to_image); } } return 1; } }
public function qualifies(Team $team, $time, $city, $direction, $distance, $defaultIfNull) { if ($time != null) { if (current_mysql_time() >= $time) { return true; } } if ($direction != null && $distance != null && $city != null) { $checkIn = CheckIn::getMostRecent($team); if ($checkIn != null && Direction::inRange($checkIn, $city, $direction, $distance)) { return true; } } if ($time == null && ($direction == null || $distance == null || $city == null)) { return $defaultIfNull; } return false; }
/** * Determine changes between two directions of the same route with the same tag * * @param Direction $o * @param Direction $n * @return Array - of changes */ protected function dataUpdated(Direction $o, Direction $n) { $changes = array(); if ($o->getName() != $n->getName()) { $changes["name"] = $o->getName() . " | " . $n->getName(); } if ($o->getTitle() != $n->getTitle()) { $changes["title"] = $o->getTitle() . " | " . $n->getTitle(); } if ($o->getUseForUi() != $n->getUseForUi()) { $changes["useForUI"] = $o->getUseForUi() . " | " . $n->getUseForUi(); } return $changes; }
<?php /* @var $this GroupController */ /* @var $model Group */ $this->breadcrumbs = array('Groups' => array('index'), 'Manage'); $this->menu = array(array('label' => 'List Group', 'url' => array('index')), array('label' => 'Create Group', 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$('#group-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>Manage Groups</h1> <p> You may optionally enter a comparison operator (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b> or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done. </p> <?php echo CHtml::link('Advanced Search', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'group-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id' => ['name' => 'id', 'htmlOptions' => ['width' => 30]], 'name', 'faculty_id' => ['name' => 'faculty_id', 'value' => '$data->faculty->name', 'filter' => Faculty::all()], 'direction_id' => ['name' => 'direction_id', 'value' => '$data->direction->name', 'filter' => Direction::all()], array('class' => 'CButtonColumn'))));
<?php $action = 'LIST'; if (isset($_POST['ACTION'])) { $action = $_POST['ACTION']; } else { if (isset($_GET['ACTION'])) { $action = $_GET['ACTION']; } } $person = new Person($registry[$nameDataBase]); $contact = new Contact($registry[$nameDataBase]); $assContact = new AssignPersonContact($registry[$nameDataBase]); $assDoc = new AssignPersonIdentifyDoc($registry[$nameDataBase]); $assProf = new AssignPersonProfession($registry[$nameDataBase]); $direction = new Direction($registry[$nameDataBase]); $assDir = new AssignPersonDirection($registry[$nameDataBase]); $bill = new BillingData($registry[$nameDataBase]); switch ($action) { case 'INSERT': $transaction = new Transaction($registry[$nameDataBase]); Person::setDataOperationBusiness($registry[$nameDataBase]); $idTransaction = $transaction->insertTransaction(array(Person::$business, Person::$insert, Person::$descriptionBusiness)); //name,last_name,maternal_name,married_name,fk_id_gender,birthday,birth_city,country_birth,locality_birth,foto,ext_file_foto $ext_file_foto = null; $foto = null; if (is_uploaded_file($_FILES['EXT_FILE_PHOTO']['tmp_name'])) { $nombreDirectorio = "upload/person_img/"; $idUnico = time(); $nombreFichero = $idUnico . "_" . $_FILES['EXT_FILE_PHOTO']['name']; //movemos el archivo a la ruta especifica
$content .= '<textarea id="text_block" name="text_block"></textarea>'; $content .= '</div>'; $content .= '</div>'; $content .= '<script>'; $content .= 'CKEDITOR.replace("text_block",'; $content .= '{ filebrowserImageUploadUrl: "' . $link_to_img_upload . '?type=' . Direction::$type . '&id=' . $id . '&add=add&glob_id=' . $direction->id . '",'; $content .= 'filebrowserImageBrowseUrl : "' . $link_to_img_browse . '?type=' . Direction::$type . '&id=' . $direction->id . '&edit=edit",'; $content .= 'contentsCss: [CKEDITOR.basePath + "contents.css", "css/styles.css", "css/bootstrap.min.css"],'; $content .= 'allowedContent: true, });'; $content .= 'CKEDITOR.config.height = 400;'; $content .= '</script>'; $content .= '<div class="row">'; $content .= '<input type="submit" class="btn btn-primary btn-lg" name="add" value="' . Language::Word('save') . '">'; $content .= '</div>'; $content .= '</form>'; $title = Language::Word('language adding'); $header = $title; } } else { if (!isset($_REQUEST['id'])) { echo 'user id is unset'; exit; } $direction = Direction::FetchByID($_REQUEST['id']); $title = Language::Word('direction'); $header = htmlspecialchars($direction->name); $content = $direction->ToHTMLAutoFull(GetUserPrivileges()); } } } include_once $link_to_admin_template;
} } else { if (isset($_REQUEST['search'])) { switch ($_REQUEST['search']) { case 'global': $text = $_REQUEST['text']; $users = User::FetchLike($text, ['select_list' => 'id, name, surname', 'is_assoc' => true, 'special' => ['link_to_full']]); for ($i = 0; $i < count($users); ++$i) { $users[$i]['name'] = Language::Translit($users[$i]['name']); $users[$i]['surname'] = Language::Translit($users[$i]['surname']); } $res = array('users' => $users, 'users_name' => Language::Word('users')); $articles = Article::FetchLike('name', ['text' => $text, 'select_list' => 'id, name', 'special' => 'link_to_full', 'is_assoc' => true]); $res['articles'] = $articles; $res['articles_name'] = Language::PublicMenu('articles'); $directions = Direction::FetchByName($text, array('format' => 'assoc', 'select_list' => array('id', 'name', 'link_to_full'))); $res['directions'] = $directions; $res['directions_name'] = Language::PublicMenu('directions'); $projects = Project::FetchByName($text, array('format' => 'assoc', 'select_list' => array('id', 'name', 'link_to_full'))); $res['projects'] = $projects; $res['projects_name'] = Language::PublicMenu('projects'); $content = json_encode($res); break; default: break; } } else { if (isset($_REQUEST['download'])) { switch ($_REQUEST['download']) { case 'link': switch ($_REQUEST['type']) {