public function makeModelStateCity($id) { $this->layout->body_class = ''; $make = Make::find(explode("-", $id)[0]); $model = Model::find(explode("-", $id)[1]); $state = null; foreach ($this->getStates() as $entity) { if (explode("-", $id)[2] == $entity['code']) { $state = $entity; break; } } $columns = array(array(), array(), array()); $cities = DB::select(DB::raw("SELECT DISTINCT city FROM vehicle WHERE make = :make AND model = :model AND state = :state ORDER BY city"), array('make' => $make->id, 'model' => $model->id, 'state' => $state['code'])); foreach ($cities as $key => $value) { $location = Location::where('state', '=', $state['code'])->where('city', '=', $value->city); if ($location->count()) { $zip = $location->first()->zip_code; $search = $make->make . ' ' . $model->model; $link = '/search?make=' . $make->id . '&model=' . $model->id . '&zip_code=' . $zip . '&search_text=' . $search . '&distance=50&page=1&sort=price-1'; $title = $make->make . ' ' . $model->model . ' for sale near ' . $value->city . ', ' . $state['code']; $city = array('link' => $link, 'title' => $title); array_push($columns[$key % 3], $city); } } $data = array('search_text' => '', 'make' => $make, 'model' => $model, 'state' => $state, 'columns' => $columns); $this->layout->contents = View::make('browse/make-model-state-city', $data); }
public function play(EntityManager $entityManager, array $args) { $vehicle = new Car(); $vehicle->setOffer("Brand New Audi A8 for just 80.000 €"); $vehicle->setPrice(80000); $vehicle->setAdmission(new \DateTime("2012-01-01")); $vehicle->setKilometres(400); $make = new Make(); $make->setLabel("Audi"); $vehicle->setMake($make); $entityManager->persist($vehicle); $entityManager->persist($make); $this->tick("flush"); $entityManager->flush(); $this->tick("flush"); $entityManager->clear(); $vehicle = $entityManager->find('CarDealer\\Inheritance\\Vehicle', $vehicle->getId()); echo "The price is: " . $vehicle->getPrice() . "\n"; }
public static function validate($object, $fields, $message) { foreach ($fields as $fieldName) { if (isset($object->{$fieldName})) { $objClass = get_class($object); $objQuery = Make::a($objClass)->equal($fieldName, $object->{$fieldName}); $objIsNotUnique = isset($object->id) ? $objQuery->notEqual('id', $object->id)->exists() : $objQuery->exists(); if ($objIsNotUnique) { $object->errors[] = self::labelForObjectProperty($object, $fieldName) . ' ' . $message; } } } }
public function index() { $this->layout->body_class = ''; $zip_code = Input::query('zip_code', ''); $distance = Input::query('distance', '50'); if (empty($zip_code)) { $this->findLocation(); $zip_code = Session::get('zip_code', ''); } Session::put('zip_code', $zip_code); Session::put('distance', $distance); $data = array('search_text' => '', 'zip_code' => $zip_code, 'distance' => $distance, 'status' => $this->getStatus(), 'makes' => $this->getPropertiesList(Make::orderBy('make')->get(), 'make'), 'bodies' => $this->getPropertiesList(Body::orderBy('body')->get(), 'body'), 'transmissions' => $this->getPropertiesList(Transmission::orderBy('transmission')->get(), 'transmission'), 'drives' => $this->getPropertiesList(Drive::orderBy('drive')->get(), 'drive'), 'interiors' => $this->getPropertiesList(Interior::orderBy('interior', 'DESC')->take(10)->get(), 'interior'), 'exteriors' => $this->getPropertiesList(Exterior::orderBy('exterior', 'DESC')->take(10)->get(), 'exterior'), 'fuels' => $this->getPropertiesList(Fuel::orderBy('fuel')->get(), 'fuel'), 'doors_count' => $this->getDoorsCounts(), 'cylinders_count' => $this->getCylindersCounts()); $this->layout->contents = View::make('search/search-advanced', $data); }
public function findSelectedFilter($filters, $aggregations, $make_filter) { if (!empty($make_filter)) { $values = array(); $make_ranges = explode("-", $make_filter); foreach ($make_ranges as $make_range) { $makes = Make::where('id', '=', $make_range); if ($makes->count()) { $title = $makes->first()->make; array_push($values, array("title" => $title, "index" => 'make-remove-' . $make_range)); } } array_push($filters, array("name" => "Make", "values" => $values, "modal" => "make")); } return $filters; }
public function register() { $this->output->set_content_type('application/json'); $config = [['field' => 'login', 'label' => 'Login Name', 'rules' => 'trim|required|min_length[2]|max_length[50]|is_unique[user.login]'], ['field' => 'email', 'label' => 'Email Address', 'rules' => 'trim|required|valid_email|is_unique[user.email]'], ['field' => 'password', 'label' => 'Password', 'rules' => 'trim|required|min_length[5]|max_length[50]'], ['field' => 'confirm_password', 'label' => 'Password Confirmation', 'rules' => 'required|matches[password]']]; $this->form_validation->set_message('is_unique', 'The {field} field already exist please choose another one'); $this->form_validation->set_rules($config); if ($this->form_validation->run() == false) { $this->output->set_output(json_encode(['result' => 0, 'error' => $this->form_validation->error_array()])); return false; } $data = ['login' => $this->input->post('login'), 'email' => $this->input->post('email'), 'password' => Make::Hash($this->input->post('password')), 'date_added' => date('Y-m-d H:i:s')]; $insert = $this->User_Model->insert($data); if ($insert) { $this->output->set_output(json_encode(['result' => 1])); } else { $this->output->set_output(json_encode(['result' => 0, 'error' => 'The user not created'])); } }
public function loadFromRow(\stdClass $row) { $this->setId($row->id)->setTypeId($row->type_id)->setVin($row->vin)->setMakeId($row->make_id)->setModelId($row->model_id)->setInventoryNumber($row->inventory_number)->setYear($row->year)->setOdometerReading($row->odometer_reading)->setDescription($row->description)->setPrice($row->price)->setPricePostfix($row->price_postfix)->setIsVisible($row->is_visible)->setIsFeatured($row->is_featured)->setExterior($row->exterior)->setInterior($row->interior)->setCreatedAt($row->created_at)->setImportedAt($row->imported_at)->setUpdatedAt($row->updated_at); if (isset($row->make)) { $this->make = new Make(); $this->make->setId($row->make_id)->setTitle($row->make); } if (isset($row->model)) { $this->model = new Model(); $this->model->setId($row->model_id)->setTitle($row->model); } if (isset($row->type)) { $this->type = new AutoType(); $this->type->setId($row->type_id)->setTitle($row->type); } $features = json_decode($row->features, TRUE); if (!empty($features)) { foreach ($features as $f) { $feature = new AutoFeature(); $feature->setId($f['id'])->setFeatureId($f['feature_id'])->setFeatureTitle($f['feature_title'])->setValue($f['value'])->setCreatedAt($f['created_at'])->setUpdatedAt($f['updated_at']); $this->addFeature($feature); } } }
public function index() { $this->layout->body_class = 'srp'; $zip_code = Input::query('zip_code', ''); $distance = Input::query('distance', '50'); if (empty($zip_code)) { $this->findLocation(); $zip_code = Session::get('zip_code', ''); } Session::put('zip_code', $zip_code); Session::put('distance', $distance); $title = ''; $make_filter = Input::get('make', ''); $makes = explode("-", $make_filter); $model_filter = Input::get('model', ''); $models = explode("-", $model_filter); foreach ($makes as $make) { $entities = Make::where('id', '=', $make); if ($entities->count()) { $entity = $entities->first(); $title = $title . $entity->make . ' '; } } $models_available = false; foreach ($models as $model) { $entities = Model::where('id', '=', $model); if ($entities->count()) { $entity = $entities->first(); $title = $title . $entity->model . ' - '; $models_available = true; } } if ($models_available == true) { $title = substr($title, 0, -2); } $search_title = $title; $search_text = ''; if (sizeof($makes) == 1 && sizeof($models) <= 1) { $entities = Make::where('id', '=', $makes[0]); if ($entities->count()) { $entity = $entities->first(); $search_text = $entity->make; if (sizeof($models) == 1) { $entities = Model::where('id', '=', $models[0]); if ($entities->count()) { $entity = $entities->first(); $search_text = $search_text . ' ' . $entity->model; } } } } $search_location = ''; $location_info = 'change location'; if (!empty($zip_code)) { $locations = Location::where('zip_code', '=', $zip_code); if ($locations->count()) { $location = Location::where('zip_code', '=', $zip_code)->first(); $city = $location->city; $state = $location->state; if (!empty($city) && !empty($state)) { if ($distance == 0) { $search_location = 'Within ' . 'unlimited miles from ' . $city . ', ' . $state; $location_info = 'unlimited miles from ' . $city . ', ' . $state . ' (change)'; } else { $search_location = 'Within ' . $distance . ' miles from ' . $city . ', ' . $state; $location_info = $distance . ' miles from ' . $city . ', ' . $state . ' (change)'; } if (strlen($title) > 0) { $title = $title . ' near ' . $city . ', ' . $state; } } } } $results = $this->executeSearch(); $aggregations = $this->executeAggregations(); $selected_filters = $this->findSelectedFilters($aggregations); $remaining_filters = $this->findRemainingFilters(); $search_filter = ''; foreach ($selected_filters as $filter) { $search_filter = $search_filter . '<strong -class->' . $filter['name'] . ':' . '</strong>'; foreach ($filter['values'] as $value) { $search_filter = $search_filter . $value['title'] . ','; } $search_filter = substr($search_filter, 0, -1) . ' '; } $paid = $aggregations['paid']; $page = Input::get('page', '1'); $from = ($page - 1) * 10; $featured = -1; $standard = -1; if ($paid > 0 && $page == 1) { $featured = 0; } if ($from == $paid) { $standard = 0; } else { if ($paid - $from < 9) { $standard = $paid - $from; } } $new_status_id = ''; $used_status_id = ''; $statuses = Status::all(); foreach ($statuses as $status) { if ($status->status == 'Used') { $used_status_id = $status->id; } else { if ($status->status == 'New') { $new_status_id = $status->id; } } } $tab = array(); $tab['all_link'] = ''; $tab['new_link'] = $new_status_id; $tab['used_link'] = $used_status_id; $all_count = 0; $new_count = 0; $used_count = 0; $status_aggs = $aggregations['status']; if (array_key_exists($new_status_id, $status_aggs)) { $new_count = $status_aggs[$new_status_id]['count']; } if (array_key_exists($used_status_id, $status_aggs)) { $used_count = $status_aggs[$used_status_id]['count']; } $all_count = $new_count + $used_count; $tab['all_count'] = '(' . $all_count . ')'; $tab['new_count'] = '(' . $new_count . ')'; $tab['used_count'] = '(' . $used_count . ')'; $tab['all_class'] = 'inactive'; $tab['new_class'] = 'inactive'; $tab['used_class'] = 'inactive'; $selected_status = Input::get('status', ''); if ($selected_status == $new_status_id) { $tab['new_class'] = 'active'; } else { if ($selected_status == $used_status_id) { $tab['used_class'] = 'active'; } else { $tab['all_class'] = 'active'; } } $save_search_popup = 'saveSearchModalGuest'; $save_vehicle_popup = 'saveVehicleModalGuest'; if (Auth::check()) { $save_search_popup = 'saveSearchModalUser'; $save_vehicle_popup = 'saveVehicleModalUser'; } $data = array('zip_code' => $zip_code, 'distance' => $distance, 'search_text' => $search_text, 'title' => $title, 'location_info' => $location_info, 'total' => $results['total'], 'selected_filters' => $selected_filters, 'remaining_filters' => $remaining_filters, 'results' => $results['results'], 'aggregations' => $aggregations, 'standard' => $standard, 'featured' => $featured, 'tab' => $tab, 'save_search_popup' => $save_search_popup, 'save_vehicle_popup' => $save_vehicle_popup, 'search_title' => $search_title, 'search_location' => $search_location, 'search_filter' => $search_filter); $this->layout->contents = View::make('search/search', $data); }
public function adsParameter() { $make_input = Input::get('make', ''); $model_input = Input::get('model', ''); $body_input = Input::get('body', ''); $status_input = Input::get('status', ''); $statuses = ''; $makes = ''; $models = ''; $bodies = ''; $new_status_id = ''; $used_status_id = ''; $status_values = Status::all(); foreach ($status_values as $status) { if ($status->status == 'Used') { $used_status_id = $status->id; } else { if ($status->status == 'New') { $new_status_id = $status->id; } } } if ($status_input == $new_status_id) { $statuses = 'New-'; } else { if ($status_input == $used_status_id) { $statuses = 'Used-'; } } foreach (explode("-", $make_input) as $make) { $entities = Make::where('id', '=', $make); if ($entities->count()) { $entity = $entities->first(); $makes = $makes . $entity->make . '-'; } } foreach (explode("-", $model_input) as $model) { $entities = Model::where('id', '=', $model); if ($entities->count()) { $entity = $entities->first(); $models = $models . $entity->model . '-'; } } foreach (explode("-", $body_input) as $body) { $entities = Body::where('id', '=', $body); if ($entities->count()) { $entity = $entities->first(); $bodies = $bodies . $entity->body . '-'; } } $ads = ''; if (!empty($statuses)) { $ads = $ads . $statuses; } if (!empty($makes)) { $ads = $ads . $makes; } if (!empty($models)) { $ads = $ads . $models; } if (!empty($bodies)) { $ads = $ads . $bodies; } if (!empty($ads)) { $ads = substr($ads, 0, -1); } return Response::json(array('ads' => $ads)); }
function testTicket68FirstAfterEqual() { $person = Make::a('Person')->equal('phone', '321-456-7890')->first(); $this->assertEquals($person->id, 1); $this->assertEquals($person->phone, '321-456-7890'); }
public function editInventory() { if (strlen($_REQUEST['new_make']) > 0 && strlen($_REQUEST['new_model']) > 0) { $make = new Make(); $make->setTitle($_REQUEST['new_make'])->create(); $model = new Model(); $model->setTitle($_REQUEST['new_model'])->setMake($make)->create(); } else { $model = new Model($_REQUEST['model_id']); $model->loadMake(); } $auto = new Auto($_REQUEST['id']); $auto->setPrice($_REQUEST['price'])->setPricePostfix($_REQUEST['price_postfix'])->setTypeId($_REQUEST['type_id'])->setInventoryNumber($_REQUEST['inventory_number'])->setVin($_REQUEST['vin'])->setMakeId($model->getMakeId())->setModelId($model->getId())->setYear($_REQUEST['year'])->setDescription($_REQUEST['description'])->setIsVisible($_REQUEST['is_visible'])->setIsFeatured($_REQUEST['is_featured'])->setInterior($_REQUEST['interior'])->setExterior($_REQUEST['exterior'])->setOdometerReading($_REQUEST['odometer_reading']); /* Features */ $auto->setFeatures(NULL); $features = json_decode(stripslashes($_REQUEST['features']), TRUE); foreach ($features as $f) { if ($f['remove'] == 0) { $feature = new AutoFeature(); $feature->setId(uniqid())->setFeatureId($f['feature_id'])->setFeatureTitle($f['title'])->setValue($f['value'])->setCreatedAt(time())->setUpdatedAt(time()); $auto->addFeature($feature); } } $auto->update(); $images = json_decode(stripslashes($_REQUEST['images']), TRUE); /** Remove deleted images */ if ($auto->getImageCount() > 0) { foreach ($auto->getImages() as $image) { $delete_me = TRUE; foreach ($images as $i) { if ($image->getId() == $i['id']) { $delete_me = FALSE; break; } } if ($delete_me) { $auto->deleteImage($image->getId()); } } } foreach ($images as $i) { /** Add new images */ if ($i['id'] == 0) { $image = new Image(); $image->setInventoryId($auto->getId())->setMediaId($i['media_id'])->setUrl($i['url'])->setIsDefault($i['def'])->create(); $auto->addImage($image); } else { $image = new Image($i['id']); $image->setInventoryId($auto->getId())->setMediaId($i['media_id'])->setUrl($i['url'])->setIsDefault($i['def'])->update(); $auto->setImage($i['id'], $image); } } return $auto->getId(); }
/** * 公司信息保存 */ public function actionSavemakeorgan() { $OrganID = Yii::app()->user->getOrganID(); $Organ = Yii::app()->request->getParam("Organ"); $model = Organ::model()->findByPK($OrganID); if (empty($model)) { $model = new Organ(); } //保存organ数据 $model->attributes = $Organ; //判断基本信息是否为空,为空则不提交 if ($Organ) { //接收删除图片的地址 $photoId = Yii::app()->request->getParam("photoId"); //判断是否删除图片 if (!empty($photoId)) { $imageids = explode(',', $photoId); foreach ($imageids as $imageid) { $picture = OrganPhoto::model()->find('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID)); //判断该图片路径是否存在数据库中 if (empty($picture)) { $myfileurl = Yii::app()->params['uploadPath'] . $imageid; if (file_exists($myfileurl)) { $result = unlink($myfileurl); } } else { $myfileurl = Yii::app()->params['uploadPath'] . $picture->Path; OrganPhoto::model()->deleteAll('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID)); if (file_exists($myfileurl)) { $result = unlink($myfileurl); } } } } //接收上传图片地址 $goodsImages = Yii::app()->request->getParam("goodsImages"); //判断是否有上传图片 if (!empty($goodsImages)) { $imglegth = count($goodsImages); for ($i = 0; $i < $imglegth; $i++) { $goodsImg = new OrganPhoto(); $goodsImg->OrganID = $OrganID; $goodsImg->Path = $goodsImages[$i]; $goodsImg->save(); } } //判断是否上传营业执照 $BLPoto = Yii::app()->request->getParam("BLPoto"); if ($model->BLPoto != $BLPoto) { if (!empty($model->BLPoto)) { $filePath = Yii::app()->params['uploadPath'] . $model->BLPoto; if (file_exists($filePath)) { unlink($filePath); } } $model->BLPoto = $BLPoto; } //接收make数据 $make = Yii::app()->request->getParam("Make"); //保存make数据 $makemodel = Make::model()->find("OrganID=:organid", array(":organid" => $OrganID)); if (empty($makemodel)) { //判断是否第一次添加 $makemodel = new Make(); $makemodel->OrganID = $OrganID; } $makemodel->SaleMoney = $make['SaleMoney']; $makemodel->SaleDomain = $make['SaleDomain']; if ($makemodel->save() && $model->save()) { //保存成功 $this->redirect(array('index')); } else { var_dump($makemodel->errors); var_dump($model->errors); die; } } }
/** !Route GET */ public function home() { $this->checkTables(); $this->classes = Make::a('RecessReflectorClass')->all()->orderBy('name'); $this->packages = Make::a('RecessReflectorPackage')->all()->orderBy('name'); }
header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Headers: user, token'); //use files require_once 'classes/make.php'; require_once 'classes/model.php'; require_once 'classes/catalogs.php'; require_once 'classes/generatetoken.php'; //get headers $headers = getallheaders(); //validate parameter and headers if (isset($_GET['makeid']) & isset($headers['user']) & isset($headers['token'])) { //validate token if ($headers['token'] == generate_token($headers['user'])) { try { //create make $make = new Make($_GET['makeid']); //start json $json = '{ "status" : 0, "make" : { "id" : ' . $make->get_id() . ', "name" : "' . $make->get_name() . '" }, "models" : ['; //read models $first = true; foreach ($make->get_models() as $m) { if ($first) { $first = false; } else { $json .= ','; }
public function testCreate() { $make = new Make(); $make->setName('Ford'); $this->assertSame('Ford', $make->getName()); }
public function update($f3, $params) { $obj = new Make($this->db); echo json_encode($obj->edit($params["MakeID"], $this->f3->get("POST.postdata"))); }
function execute() { $hako = new Hako(); $cgi = new Cgi(); $cgi->parseInputData(); $cgi->getCookies(); $fp = ""; if (!$hako->readIslands($cgi)) { HTML::header(); HakoError::noDataFile(); HTML::footer(); Util::unlock($lock); exit; } $lock = Util::lock($fp); if (FALSE == $lock) { exit; } $cgi->setCookies(); $_developmode = isset($cgi->dataSet['DEVELOPEMODE']) ? $cgi->dataSet['DEVELOPEMODE'] : ""; if (mb_strtolower($_developmode) == "javascript") { $html = new HtmlMapJS(); $com = new MakeJS(); } else { $html = new HtmlMap(); $com = new Make(); } switch ($cgi->mode) { case "turn": $turn = new Turn(); $html = new HtmlTop(); $html->header(); $turn->turnMain($hako, $cgi->dataSet); $html->main($hako, $cgi->dataSet); // ターン処理後、TOPページopen $html->footer(); break; case "owner": $html->header(); $html->owner($hako, $cgi->dataSet); $html->footer(); break; case "command": $html->header(); $com->commandMain($hako, $cgi->dataSet); $html->footer(); break; case "new": $html->header(); $com->newIsland($hako, $cgi->dataSet); $html->footer(); break; case "comment": $html->header(); $com->commentMain($hako, $cgi->dataSet); $html->footer(); break; case "print": $html->header(); $html->visitor($hako, $cgi->dataSet); $html->footer(); break; case "targetView": $html->head(); $html->printTarget($hako, $cgi->dataSet); //$html->footer(); break; case "change": $html->header(); $com->changeMain($hako, $cgi->dataSet); $html->footer(); break; case "ChangeOwnerName": $html->header(); $com->changeOwnerName($hako, $cgi->dataSet); $html->footer(); break; case "conf": $html = new HtmlTop(); $html->header(); $html->register($hako, $cgi->dataSet); $html->footer(); break; case "log": $html = new HtmlTop(); $html->header(); $html->log(); $html->footer(); break; default: $html = new HtmlTop(); $html->header(); $html->main($hako, $cgi->dataSet); $html->footer(); } Util::unlock($lock); exit; }
<?php require_once 'Make.php'; if ($argc > 2) { //Next explode very next argument by ':' // Then verify both portion $make_argument = explode(':', $argv[1]); if ($make_argument[0] == 'make' && !empty($make_argument[1])) { $class_type = strtolower($make_argument[1]); $available_class = ['controller', 'model']; $class_name = $argv[2]; if (in_array($class_type, $available_class)) { $make = new Make(); echo $make->request($class_name, $class_type); // echo "got it\n"; } else { echo "Currently Unavailable\n"; exit; } } else { echo "\nInvalid Argument\n"; echo "\n\n******* Available Command *************\n"; echo "php fast make:controller {controller_name}\n"; echo "php fast make:model {model_name}\n"; echo "***********************************\n\n"; exit; } }
$lines = explode(PHP_EOL, $code); $begin = -1; $end = -1; $tab = ''; for ($i = 0; $i < count($lines); $i++) { if ($begin === -1 && preg_match('/(\\s*).*function.*' . $name . '.*/', $lines[$i], $match)) { $begin = $i; $tab = $match[1]; } if ($end === -1 && $begin !== -1 && preg_match('/^' . $tab . '}/', $lines[$i], $match)) { $end = $i; } } $return = ''; if ($begin !== -1 & $end !== -1) { $return = array_splice($lines, $begin, $end - $begin + 1); $return = implode("\n", $return); } return $return; } public static function loadFile($file) { return file_get_contents($file); } } $code = Make::loadFile('kriss_feed.php'); $code = Make::replaceAutoload($code); $code = Make::removeComments($code); $code = Make::replaceRainTpl($code); $code = Make::includeFiles($code); echo $code;
function test() { $people = Make::a('Person')->in('id', array(1, 2, 3)); $this->assertEquals($people[0]->id, 1); $this->assertEquals($people[0]->phone, '321-456-7890'); }
/** * Creates individual Entry objects of the appropriate type and * stores them as members of this entry based upon DOM data. * * @param DOMNode $child The DOMNode to process */ protected function takeChildFromDOM($child) { $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; switch ($absoluteNodeName) { case $this->lookupNamespace('exif') . ':' . 'distance'; $distance = new Distance(); $distance->transferFromDOM($child); $this->_distance = $distance; break; case $this->lookupNamespace('exif') . ':' . 'exposure'; $exposure = new Exposure(); $exposure->transferFromDOM($child); $this->_exposure = $exposure; break; case $this->lookupNamespace('exif') . ':' . 'flash'; $flash = new Flash(); $flash->transferFromDOM($child); $this->_flash = $flash; break; case $this->lookupNamespace('exif') . ':' . 'focallength'; $focalLength = new FocalLength(); $focalLength->transferFromDOM($child); $this->_focalLength = $focalLength; break; case $this->lookupNamespace('exif') . ':' . 'fstop'; $fStop = new FStop(); $fStop->transferFromDOM($child); $this->_fStop = $fStop; break; case $this->lookupNamespace('exif') . ':' . 'imageUniqueID'; $imageUniqueId = new ImageUniqueId(); $imageUniqueId->transferFromDOM($child); $this->_imageUniqueId = $imageUniqueId; break; case $this->lookupNamespace('exif') . ':' . 'iso'; $iso = new ISO(); $iso->transferFromDOM($child); $this->_iso = $iso; break; case $this->lookupNamespace('exif') . ':' . 'make'; $make = new Make(); $make->transferFromDOM($child); $this->_make = $make; break; case $this->lookupNamespace('exif') . ':' . 'model'; $model = new Model(); $model->transferFromDOM($child); $this->_model = $model; break; case $this->lookupNamespace('exif') . ':' . 'time'; $time = new Time(); $time->transferFromDOM($child); $this->_time = $time; break; } }
public function savemakerdata() { $OrganID = Yii::app()->user->getOrganID(); //接收make数据 $make = Yii::app()->request->getParam("Make"); //保存make数据 $makemodel = Make::model()->find("OrganID=:organid", array(":organid" => $OrganID)); if (empty($makemodel)) { //判断是否第一次添加 $makemodel = new Make(); $makemodel->OrganID = $OrganID; } $makemodel->SaleMoney = $make['SaleMoney']; $makemodel->SaleDomain = $make['SaleDomain']; if (!$makemodel->save()) { //var_dump($makemodel->errors);die; throw new CHttpException(400, '保存机构信息失败!'); } }
/** * This returns all models sorted by Make Title, then Model Title * * @return \SquirrelsInventory\Model[] */ public static function getAllModels() { $models = array(); $makes = Make::getAllMakes(); $parents = array(0 => array()); foreach ($makes as $make_id => $make) { $parents[$make_id] = array(); } $query = new \WP_Query(array('post_type' => self::CUSTOM_POST_TYPE, 'post_status' => 'publish', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC')); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $custom = get_post_custom(get_the_ID()); $model = new Model(get_the_ID(), get_the_title()); if (array_key_exists('make_id', $custom)) { $make_id = $custom['make_id'][0]; $model->setMakeId($make_id); if (array_key_exists($model->getMakeId(), $makes)) { $model->setMake($makes[$model->getMakeId()]); } } else { $make_id = 0; } $parents[$make_id][] = $model; } } foreach ($parents as $parent_id => $_models) { /** @var Model[] $_models */ foreach ($_models as $model) { $models[$model->getId()] = $model; } } return $models; }
protected function icons_in_post($full_post) { $post = $full_post['.postmsg'][0]; if (strpos($post->html(), '<img') === false) { return array(); } $post_text = self::clean_up_post($post); $artist_name = $full_post['.postleft dt'][0]->text(); $post_imgs = $post['img.postimg']; if (empty($post_imgs)) { return array(); } $icons = self::find_icon_names_in_post($post_imgs, $post_text); $post_icons = array(); foreach ($icons as $img_src => $name) { $icon = Make::an('Icon')->like('src', $img_src)->first(); $changed = false; if (!$icon) { $icon = new Icon(); $icon->src = $img_src; $icon->theme_id = $this->theme->id; // TODO: make this DRYer too if ($artist_name) { $artist = Make::an('Artist')->like('name', $artist_name)->first(); if (!$artist) { $artist = new Artist(); $artist->name = $artist_name; $artist->save(); } $icon->setArtist($artist); } $changed = true; } if ($name && !$icon->app()) { $app = Make::an('App')->like('name', $name)->first(); if (!$app) { $app = new App(); $app->name = $name; $app->save(); } $icon->setApp($app); $changed = true; } if ($changed) { $icon->save(); } $post_icons[] = $icon; } /* $matches = array(); $maybe_names = array(); if (preg_match('/(([a-z0-9\-]{2,}), )+([a-z0-9\- ]{2,})/i', $post_text, $matches)) { $maybe_names = explode(',', $matches[0]); # [0] == entire match $maybe_names = array_map('trim', $maybe_names); } else { $w = self::WORD_REGEXP; $and_match = array(); if (preg_match('/'.$w.' and '.$w.'/iu', $post_text, $and_match)) { $maybe_names = explode(' and ', $and_match[0]); $maybe_names = array_map('trim', $maybe_names); } } if ($maybe_names) { foreach ($post_icons as &$post_icon) { $post_icon->maybe_names = array_merge($post_icon->maybe_names, $maybe_names); } } */ return $post_icons; }