当前位置: 首页>>代码示例>>PHP>>正文


PHP Countries::find方法代码示例

本文整理汇总了PHP中Countries::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Countries::find方法的具体用法?PHP Countries::find怎么用?PHP Countries::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Countries的用法示例。


在下文中一共展示了Countries::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isValid

 public function isValid($value, $context = null)
 {
     if (!empty($value)) {
         $this->vat = $value;
         $countryid = intval($context['country_id']);
         if ($countryid == 0) {
             $this->_error(self::ISNOTCOUNTRYID);
             return false;
         }
         $country = Countries::find($context['country_id']);
         if (!empty($country->code)) {
             $this->countryCode = $country->code;
         } else {
             return false;
         }
         if (Countries::isITbyId($countryid)) {
             if (!is_numeric($value) || strlen($value) != 11) {
                 $this->_error(self::INVALIDVAT);
                 return false;
             }
         } elseif (Countries::isUEbyId($countryid)) {
             return $this->eu_check();
         }
     }
     return true;
 }
开发者ID:kokkez,项目名称:shineisp,代码行数:26,代码来源:Vat.php

示例2: indexAction

 public function indexAction()
 {
     // set page title
     $this->view->pageTitle = 'Countries';
     // process get
     if ($this->request->isGet()) {
         // Current page to show
         $currentPage = $this->request->getQuery('page', 'int');
         $currentPage = empty($currentPage) ? 1 : $currentPage;
         // items per page
         $itemsPerPage = $this->request->getQuery('limit', 'int');
         $itemsPerPage = empty($itemsPerPage) ? $this->config->application['pagination']['itemsPerPage'] : $itemsPerPage;
         // filter
         $filter = $this->request->getQuery('filter', 'trim');
         // sort
         $sortBy = $this->request->getQuery('sort', 'string');
         $sortBy = empty($sortBy) ? 'name' : $sortBy;
         // direction
         $sortDirection = $this->request->getQuery('direction', 'string');
         $sortDirection = empty($sortDirection) ? 'asc' : $sortDirection;
     } else {
         // set defaults
         $currentPage = 1;
         $itemsPerPage = $this->config->application['pagination']['itemsPerPage'];
         $filter = null;
         $sortBy = 'name';
         $sortDirection = 'desc';
     }
     // order by
     if ($sortBy == 'date') {
         $orderBy = 'created ' . strtoupper($sortDirection);
     } elseif ($sortBy == 'name') {
         $orderBy = 'name ' . strtoupper($sortDirection);
     }
     // get all user activity logs
     if (!empty($filter)) {
         // find countries using filter
         $country = Countries::find(array('name LIKE :filter:', 'order' => $orderBy, 'bind' => array('filter' => '%' . $filter . '%')));
     } else {
         $country = Countries::find(array('order' => $orderBy));
     }
     // Create a Model paginator, show 10 rows by page starting from $currentPage
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $country, "limit" => $itemsPerPage, "page" => $currentPage));
     // Get the paginated results
     $this->view->page = $paginator->getPaginate();
     $this->view->itemsPerPage = $itemsPerPage;
     $this->view->filter = $filter;
     $this->view->sort = $sortBy;
     $this->view->direction = $sortDirection;
     $this->view->dropdownLinks = array('edit' => '/country/edit', 'delete' => '/country/delete');
 }
开发者ID:hacktm15,项目名称:CityBox,代码行数:51,代码来源:CountryController.php

示例3: indexAction

 /**
  * 返回所有国家
  * @api /country/
  * @return [type] [description]
  */
 public function indexAction()
 {
     $countries = Countries::find();
     $requestCnt = array_pick($this->request->getAcceptableContent(), 'accept', true);
     if (in_array('application/json', $requestCnt)) {
         $response = new Response();
         $response->setHeader("Content-Type", "application/json");
         echo json_encode($countries->toArray());
         $this->view->disable();
     } else {
         $this->view->setVar('countries', $countries);
         $this->view->setVar('title', '世界国家');
     }
 }
开发者ID:gamelife1314,项目名称:city,代码行数:19,代码来源:CountryController.php

示例4: imageSearchAction

 public function imageSearchAction($query = NULL)
 {
     $this->view->disable();
     $this->response->setContentType('application/json', 'UTF-8');
     $search = new SearchCategories();
     if (isset($query) === false) {
         $countries = Countries::find();
     } else {
         $countries = Countries::find("countryName like '%" . $query . "%'");
     }
     $search->fromDatabaseObjects($countries, function ($country) use($search) {
         $code = $country->getCountryCode();
         $description = "Population : " . number_format($country->getPopulation()) . "<br>Capital : " . $country->getCapital();
         $image = "https://lipis.github.io/flag-icon-css/flags/4x3/" . strtolower($code) . ".svg";
         $search->add(new SearchResult($code, $country->getCountryName(), $description, $image), $country->getContinentName());
     });
     echo $search->getResponse();
 }
开发者ID:jcheron,项目名称:phalcon-jquery-website,代码行数:18,代码来源:JsonController.php

示例5: update_profileAction

 public function update_profileAction($id = null)
 {
     if ($this->request->isPost()) {
         $member = Members::findFirstById($this->request->getPost('id'));
         $member->modified = date('Y-m-d H:i:s');
         $member->first_name = $this->request->getPost('first_name');
         $member->last_name = $this->request->getPost('last_name');
         $member->street = $this->request->getPost('street');
         $member->city = $this->request->getPost('city');
         $member->country_id = $this->request->getPost('country_id');
         $member->email = $this->request->getPost('email');
         $member->mobile = $this->request->getPost('mobile');
         if ($member->update()) {
             $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>You profile has been updated.');
             return $this->response->redirect('member/profile/' . $this->request->getPost('id'));
         }
     }
     $member = Members::findFirstById($id);
     $this->view->setVar('member', $member);
     $countries = Countries::find();
     $this->view->setVar('countries', $countries);
 }
开发者ID:hinjanobara,项目名称:mbimages,代码行数:22,代码来源:MemberController.php

示例6: indexAction

 /**
  * Makers list
  */
 public function indexAction()
 {
     $request = $this->request;
     $persistent = $this->persistent;
     // Reset
     $reset = $this->request->getQuery('reset', 'int');
     if (isset($reset)) {
         $persistent->makersParams = null;
     }
     // Persistent parameters
     if (!is_array($persistent->makersParams)) {
         $persistent->makersParams = ['qry' => ['conditions' => "id IS NOT NULL", 'order' => 'updated DESC'], 'sort' => ['page' => 1, 'perpage' => 50]];
     }
     $parameters = $persistent->makersParams;
     $parameters['sort']['perpage'] = isset($parameters['sort']['perpage']) ? $parameters['sort']['perpage'] : 50;
     $parameters['sort']['page'] = isset($parameters['sort']['page']) ? $parameters['sort']['page'] : 1;
     if ($request->getQuery('page', 'int')) {
         $parameters['sort']['page'] = $request->getQuery('page', 'int');
     }
     if ($request->getQuery('perpage', 'int')) {
         $parameters['sort']['perpage'] = $request->getQuery('perpage', 'int');
     }
     // Search
     if ($request->isPost()) {
         $parameters['search_region'] = null;
         $parameters['search_approved'] = null;
         // Placer
         if (!empty($_POST['search_region'])) {
             $search_region_get = $request->getPost('search_region', 'int');
             $parameters['search_region'] = $search_region_get;
             $search_region = " AND geo_id = {$search_region_get}";
         } else {
             $search_region = null;
         }
         // Name or ID
         if (!empty($_POST['search_name'])) {
             $search_name_get = $request->getPost('search_name', 'string');
             if (preg_match('/^[0-9,\\s]+$/', $request->getPost('search_name', 'string'))) {
                 $search_split = preg_split('/[,\\s]/', $search_name_get, 0, PREG_SPLIT_NO_EMPTY);
                 $search_name = implode(', ', $search_split);
                 $search_name = " AND id IN ({$search_name})";
             } else {
                 $search_name = " AND name LIKE '%{$search_name_get}%'";
             }
         } else {
             $search_name_get = null;
             $search_name = null;
         }
         // Email
         if (!empty($_POST['search_email'])) {
             $search_email_get = $request->getPost('search_email', 'string');
             $search_email = " AND email LIKE '%{$search_email_get}%'";
         } else {
             $search_email_get = null;
             $search_email = null;
         }
         // Phone
         if (!empty($_POST['search_phone'])) {
             $search_phone_get = $request->getPost('search_phone', 'string');
             $search_phone = " AND phone LIKE '%{$search_phone_get}%' OR phone2 LIKE '%{$search_phone_get}%'";
         } else {
             $search_phone_get = null;
             $search_phone = null;
         }
         // Approved status
         if (!empty($_POST['search_approved'])) {
             $search_approved_get = $request->getPost('search_approved', 'int');
             $parameters['search_approved'] = $search_approved_get;
             $search_approved = " AND approved = {$search_approved_get}";
         } else {
             $search_approved = null;
         }
         // Search parameters
         $parameters['qry'] = ['conditions' => "id IS NOT NULL\n                    {$search_region}\n                    {$search_name}\n                    {$search_email}\n                    {$search_phone}\n                    {$search_approved}"];
     }
     // Other parameters
     $parameters['count'] = PMaker::count($parameters['qry']);
     $parameters['qry']['order'] = "updated DESC";
     $parameters['qry']['limit'] = 10000;
     $persistent->makersParams = $parameters;
     //        var_dump($parameters);
     $makers = PMaker::find($parameters['qry']);
     // Paginator
     $paginator = new Paginator(["data" => $makers, "limit" => $parameters['sort']['perpage'], "page" => $parameters['sort']['page']]);
     $this->view->page = $paginator->getPaginate();
     // Set selected search values
     $this->view->selected_region = isset($parameters['search_region']) && !empty($parameters['search_region']) ? $parameters['search_region'] : null;
     $this->view->selected_approved = isset($parameters['search_approved']) && !empty($parameters['search_approved']) ? $parameters['search_approved'] : null;
     $this->view->makers_count = $parameters['count'];
     // All regions
     $this->view->regions_list = array_column(Geo::find(['order' => 'title ASC'])->toArray(), 'title', 'id');
     // Currencies
     $currencies_array = array_column(PCrosscurrency::find()->toArray(), 'title', 'title');
     $this->view->currencies_list = ['UAH' => $currencies_array['UAH']] + $currencies_array;
     // Countries
     $countries_array = array_column(Countries::find("active=1")->toArray(), 'title', 'id');
     $ukraine = array_search('Украина', $countries_array);
//.........这里部分代码省略.........
开发者ID:serge2300,项目名称:madeheart,代码行数:101,代码来源:MakerslistController.php

示例7: update_businessAction

 public function update_businessAction($businessId = null)
 {
     $business = Business::findFirst($businessId);
     if (!$business) {
         return $this->response->redirect('biz/business_search');
     }
     if ($this->request->isPost()) {
         $countryId = $this->request->getPost('country_id');
         $country = Countries::findFirst(array('columns' => '*', 'conditions' => 'id LIKE :id:', 'bind' => array('id' => $countryId)));
         $countryName = '';
         if ($country) {
             $countryName = $country->country;
         }
         $address = str_replace(' ', '+', $this->request->getPost('street') . '+' . $this->request->getPost('city') . '+' . $countryName);
         $userSession = $this->session->get("userSession");
         $content = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address=' . $address . '&key=AIzaSyAbpLPfBH8sNdVSzMULD_BZN9qrAqbL3V8');
         $json = json_decode($content, true);
         $lat = $json['results'][0]['geometry']['location']['lat'];
         $lng = $json['results'][0]['geometry']['location']['lng'];
         $business->modified = date('Y-m-d H:i:s');
         $business->member_id = $userSession['id'];
         $business->name = $this->request->getPost('name');
         $business->website = $this->request->getPost('website');
         $business->telephone = $this->request->getPost('telephone');
         $business->street = $this->request->getPost('street');
         $business->city = $this->request->getPost('city');
         $business->country_id = $this->request->getPost('country_id');
         $business->lat = $lat;
         $business->lng = $lng;
         $opened = '';
         if (!empty($this->request->getPost('opened'))) {
             $opened = 'Opened';
         }
         if (empty($this->request->getPost('opened'))) {
             $opened = 'Opening Soon';
         }
         $business->opened = $opened;
         if ($business->update()) {
             if (!empty($this->request->getPost('business_category_ids'))) {
                 $bCtegories = $this->request->getPost('business_category_ids');
                 $bCtegoryIds = explode(',', $bCtegories);
                 BusinessCategoryLists::find('business_id="' . $businessId . '"')->delete();
                 foreach ($bCtegoryIds as $key => $bCtegoryId) {
                     $businessCategoryLists = new BusinessCategoryLists();
                     $businessCategoryLists->created = date('Y-m-d H:i:s');
                     $businessCategoryLists->business_id = $businessId;
                     $businessCategoryLists->business_category_id = $bCtegoryId;
                     $businessCategoryLists->create();
                 }
             }
             $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>Business has been updated');
             return $this->response->redirect('business/view/' . $businessId);
         }
     }
     $this->view->setVar('business', $business);
     $countries = Countries::find();
     $this->view->setVar('countries', $countries);
     $businessCategoryLists = BusinessCategoryLists::find('business_id="' . $businessId . '"');
     $this->view->setVar('businessCategoryLists', $businessCategoryLists);
 }
开发者ID:hinjanobara,项目名称:mbimages,代码行数:60,代码来源:BizController.php

示例8: updateAction

 public function updateAction($id = null)
 {
     if ($this->request->isPost()) {
         $id = $this->request->getPost('id');
         $countryId = $this->request->getPost('country_id');
         $country = Countries::findFirst(array('columns' => '*', 'conditions' => 'id LIKE :id:', 'bind' => array('id' => $countryId)));
         $countryName = '';
         if ($country) {
             $countryName = $country->country;
         }
         $address = str_replace(' ', '+', $this->request->getPost('street') . '+' . $this->request->getPost('city') . '+' . $countryName);
         $userSession = $this->session->get("userSession");
         $content = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address=' . $address . '&key=AIzaSyAbpLPfBH8sNdVSzMULD_BZN9qrAqbL3V8');
         $json = json_decode($content, true);
         $lat = $json['results'][0]['geometry']['location']['lat'];
         $lng = $json['results'][0]['geometry']['location']['lng'];
         //error_log('LAT : '.$lat.' LONG : '.$lng);
         $property = Realties::findFirst($id);
         $property->modified = date('Y-m-d H:i:s');
         $property->member_id = $userSession['id'];
         $property->name = $this->request->getPost('name');
         $property->details = $this->request->getPost('details');
         $property->price = str_replace(',', '', $this->request->getPost('price'));
         $property->street = $this->request->getPost('street');
         $property->city = $this->request->getPost('city');
         $property->country_id = $this->request->getPost('country_id');
         $property->lat = $lat;
         $property->lng = $lng;
         $property->realty_condition_id = $this->request->getPost('realty_condition_id');
         $property->realty_category_id = $this->request->getPost('realty_category_id');
         $property->realty_type_id = $this->request->getPost('realty_type_id');
         $property->house_area = $this->request->getPost('house_area');
         $property->lot_area = $this->request->getPost('lot_area');
         $property->bedrooms = $this->request->getPost('bedrooms');
         $property->bathrooms = $this->request->getPost('bathrooms');
         $property->parking = $this->request->getPost('parking');
         $property->pets_allowed = $this->request->getPost('pets_allowed');
         if ($property->update()) {
             $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>New property has been updated');
             for ($i = 1; $i <= 7; $i++) {
                 $fileId = $this->request->getPost('fileId' . $i);
                 if (!empty($fileId)) {
                     $realtyPhotos = RealtyPhotos::findFirst($fileId);
                     $realtyPhotos->created = date('Y-m-d H:i:s');
                     $realtyPhotos->modified = date('Y-m-d H:i:s');
                     $realtyPhotos->member_id = $userSession['id'];
                     $realtyPhotos->caption = $this->request->getPost('caption' . $i);
                     $realtyPhotos->update();
                 }
             }
             if ($this->request->hasFiles() == true) {
                 //ini_set('upload_max_filesize', '64M');
                 set_time_limit(1200);
                 $uploads = $this->request->getUploadedFiles();
                 $isUploaded = false;
                 #do a loop to handle each file individually
                 foreach ($uploads as $upload) {
                     $imageName = $upload->getKey();
                     //$this->request->getPost('image'.$ctr);
                     $inputRow = str_replace('image', '', $imageName);
                     $fileId = $this->request->getPost('fileId' . $inputRow);
                     #define a “unique” name and a path to where our file must go
                     $fileName = $upload->getName();
                     $fileInfo = new SplFileInfo($fileName);
                     $fileExt = $fileInfo->getExtension();
                     $fileExt = strtolower($fileExt);
                     $newFileName = substr(md5(uniqid(rand(), true)), 0, 10) . date('ymdhis') . '.' . $fileExt;
                     //$fileExt = $upload->getExtension();
                     $fileImageExt = array('jpeg', 'jpg', 'png');
                     $fileType = '';
                     $filePath = '';
                     $path = '';
                     if (in_array($fileExt, $fileImageExt)) {
                         $path = 'img/realty/' . $newFileName;
                         $filePath = 'img/realty/';
                         //$fileType = 'Image';
                     }
                     #move the file and simultaneously check if everything was ok
                     $upload->moveTo($path) ? $isUploaded = true : ($isUploaded = false);
                     if ($isUploaded) {
                         if (!empty($fileId)) {
                             $realtyPhotos = RealtyPhotos::findFirst($fileId);
                             $realtyPhotos->modified = date('Y-m-d H:i:s');
                             $realtyPhotos->member_id = $userSession['id'];
                             $realtyPhotos->file_path = $filePath;
                             $realtyPhotos->filename = $newFileName;
                             $realtyPhotos->update();
                         } else {
                             $realtyPhotos = new RealtyPhotos();
                             $realtyPhotos->created = date('Y-m-d H:i:s');
                             $realtyPhotos->modified = date('Y-m-d H:i:s');
                             $realtyPhotos->member_id = $userSession['id'];
                             $realtyPhotos->realty_id = $id;
                             $realtyPhotos->file_path = $filePath;
                             $realtyPhotos->filename = $newFileName;
                             $realtyPhotos->caption = $this->request->getPost('caption' . $inputRow);
                             $realtyPhotos->create();
                         }
                     }
                 }
//.........这里部分代码省略.........
开发者ID:hinjanobara,项目名称:mbimages,代码行数:101,代码来源:RealEstateController.php

示例9: newAction


//.........这里部分代码省略.........
         }
         $userSession = $this->session->get("userSession");
         $eventName = $this->request->getPost("name");
         $website = $this->request->getPost("website");
         $telephone = $this->request->getPost("telephone");
         $street = $this->request->getPost("street");
         $city = $this->request->getPost("city");
         $info = $this->request->getPost("event_info");
         $category = $this->request->getPost("category");
         $country = $this->request->getPost("country");
         $raw_address = $this->request->getPost("address");
         $latitude = $this->request->getPost("lat");
         $longitude = $this->request->getPost("lng");
         $dates = $this->request->getPost("date");
         $fromTimes = $this->request->getPost("fromTime");
         $toTimes = $this->request->getPost("toTime");
         $event = new Events();
         $event->created = date('Y-m-d H:i:s');
         $event->modified = date('Y-m-d H:i:s');
         $event->member_id = $userSession['id'];
         $event->name = $eventName;
         $event->event_date = $this->request->getPost("date");
         $event->website = $website;
         $event->telephone = $telephone;
         $event->street = $street;
         $event->city = $city;
         $event->country_id = $country;
         $event->event_category_id = $category;
         $event->lng = $longitude;
         $event->lat = $latitude;
         $event->eventinfo = $info;
         if ($event->create()) {
             $id = $event->id;
             $i = 0;
             foreach ($dates as $date) {
                 $eventDatetime = new EventDatetimes();
                 $eventDatetime->event_id = $id;
                 $eventDatetime->date = $date;
                 $eventDatetime->from_time = $fromTimes[$i];
                 $eventDatetime->to_time = $toTimes[$i];
                 $i++;
                 if (!$eventDatetime->create()) {
                     $this->view->disable();
                     echo "failed to insert event date and time in event_datetimes table. :(";
                 }
             }
             $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>New event has been posted');
             if ($this->request->hasFiles() == true) {
                 $uploads = $this->request->getUploadedFiles();
                 $isUploaded = false;
                 $ctr = 1;
                 foreach ($uploads as $upload) {
                     # define a "unique" name and a path to where our file must go
                     $fileName = $upload->getname();
                     $fileInfo = new SplFileInfo($fileName);
                     $fileExt = $fileInfo->getExtension();
                     $fileExt = strtolower($fileExt);
                     $newFileName = substr(md5(uniqid(rand(), true)), 0, 10) . date('ymdhis') . '.' . $fileExt;
                     $fileImageExt = array('jpeg', 'jpg', 'png');
                     $fileType = '';
                     $filePath = '';
                     $path = '';
                     if (in_array($fileExt, $fileImageExt)) {
                         $path = 'img/event/' . $newFileName;
                         $filePath = 'img/event/';
                         //$fileType = 'Image';
                     }
                     # move the file and simultaneously check if everything was ok
                     $upload->moveTo($path) ? $isUploaded = true : ($isUploaded = false);
                     if ($isUploaded) {
                         $eventPhotos = new EventPhotos();
                         $eventPhotos->created = date('Y-m-d H:i:s');
                         $eventPhotos->modified = date('Y-m-d H:i:s');
                         $eventPhotos->member_id = $userSession['id'];
                         $eventPhotos->event_id = $id;
                         $eventPhotos->file_path = $filePath;
                         $eventPhotos->filename = $newFileName;
                         $eventPhotos->caption = $this->request->getPost('caption');
                         //$ctr++;
                         if ($eventPhotos->create()) {
                             echo "success";
                         } else {
                             $this->view->disable();
                             print_r($eventPhotos->getMessages());
                         }
                     }
                 }
             }
         } else {
             $this->view->disable();
             print_r($event->getMessages());
         }
         return $this->response->redirect('event/view/' . $id);
     }
     $events = Events::find();
     $categories = EventsCategories::find();
     $countries = Countries::find();
     $this->view->setVar('events', $events);
     $this->view->setVars(['events' => $events, 'categories' => $categories, 'countries' => $countries]);
 }
开发者ID:hinjanobara,项目名称:mbimages,代码行数:101,代码来源:EventController.php

示例10: updateAction

 public function updateAction($id = null)
 {
     if ($this->request->isPost()) {
         $id = $this->request->getPost('id');
         $userSession = $this->session->get("userSession");
         $jobs = Jobs::findFirst($id);
         $jobs->modified = date('Y-m-d H:i:s');
         $jobs->member_id = $userSession['id'];
         $jobs->position = $this->request->getPost('position');
         $jobs->job_category_id = $this->request->getPost('job_category_id');
         $jobs->job_description = $this->request->getPost('job_description');
         $jobs->requirements = $this->request->getPost('requirements');
         $jobs->benefits = $this->request->getPost('benefits');
         $jobs->salary_from = $this->request->getPost('salary_from');
         $jobs->salary_to = $this->request->getPost('salary_to');
         $jobs->company = $this->request->getPost('company');
         $jobs->website = $this->request->getPost('website');
         $jobs->telephone = $this->request->getPost('telephone');
         $jobs->email = $this->request->getPost('email');
         $jobs->street = $this->request->getPost('street');
         $jobs->city = $this->request->getPost('city');
         $jobs->country_id = $this->request->getPost('country_id');
         $jobs->how_to_apply = $this->request->getPost('how_to_apply');
         if ($jobs->update()) {
             $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>New job has been updated');
             if ($this->request->hasFiles() == true) {
                 set_time_limit(1200);
                 $uploads = $this->request->getUploadedFiles();
                 $isUploaded = false;
                 #do a loop to handle each file individually
                 foreach ($uploads as $upload) {
                     #define a “unique” name and a path to where our file must go
                     $fileName = $upload->getname();
                     $fileInfo = new SplFileInfo($fileName);
                     $fileExt = $fileInfo->getExtension();
                     $fileExt = strtolower($fileExt);
                     $newFileName = substr(md5(uniqid(rand(), true)), 0, 10) . date('ymdhis') . '.' . $fileExt;
                     //$fileExt = $upload->getExtension();
                     $fileImageExt = array('jpeg', 'jpg', 'png');
                     //error_log("File Extension :".$fileExt, 0);
                     $fileType = '';
                     $filePath = '';
                     $path = '';
                     //$path = ''.$newFileName;
                     if (in_array($fileExt, $fileImageExt)) {
                         $path = 'img/job/' . $newFileName;
                         $filePath = 'img/job/';
                         //$fileType = 'Image';
                     }
                     #move the file and simultaneously check if everything was ok
                     $upload->moveTo($path) ? $isUploaded = true : ($isUploaded = false);
                 }
                 #if any file couldn't be moved, then throw an message
                 if ($isUploaded) {
                     $jobLogo = JobLogos::findFirst('job_id="' . $id . '"');
                     if ($jobLogo) {
                         //delete previous logo first
                         unlink($jobLogo->file_path . $jobLogo->filename);
                         $jobLogo->created = date('Y-m-d H:i:s');
                         $jobLogo->modified = date('Y-m-d H:i:s');
                         $jobLogo->member_id = $userSession['id'];
                         $jobLogo->job_id = $id;
                         $jobLogo->file_path = $filePath;
                         $jobLogo->filename = $newFileName;
                         if ($jobLogo->update()) {
                         }
                         //before saving the new one
                     } else {
                         $jobLogo = new JobLogos();
                         $jobLogo->created = date('Y-m-d H:i:s');
                         $jobLogo->modified = date('Y-m-d H:i:s');
                         $jobLogo->member_id = $userSession['id'];
                         $jobLogo->job_id = $id;
                         $jobLogo->file_path = $filePath;
                         $jobLogo->filename = $newFileName;
                         if ($jobLogo->create()) {
                         }
                     }
                 }
             }
             return $this->response->redirect('job/view/' . $id);
         }
     }
     $this->view->setVar('job', Jobs::findFirst($id));
     $countries = Countries::find();
     $this->view->setVar('countries', $countries);
     $jobCategories = JobCategories::find();
     $this->view->setVar('jobCategories', $jobCategories);
     $jobLogo = JobLogos::findFirst('job_id="' . $id . '"');
     if ($jobLogo) {
         $jobLogo = $jobLogo->file_path . $jobLogo->filename;
     } else {
         $jobLogo = 'http://placehold.it/200x200';
     }
     $this->view->setVar('jobLogo', $jobLogo);
 }
开发者ID:hinjanobara,项目名称:mbimages,代码行数:96,代码来源:JobController.php

示例11: admin_addAction

 public function admin_addAction()
 {
     if ($this->request->isPost()) {
         $error = 0;
         // if($this->security->checkToken() == false){
         // 	$error = 1;
         // 	$this->flash->error('<button type="button" class="close" data-dismiss="alert">×</button>Invalid CSRF Token');
         // 	return $this->response->redirect('signup');
         // }
         $firstName = $this->request->getPost('first_name');
         $middleName = $this->request->getPost('middle_name');
         $lastName = $this->request->getPost('last_name');
         $street = $this->request->getPost('street');
         $city = $this->request->getPost('city');
         $country_id = $this->request->getPost('country_id');
         $mobile = $this->request->getPost('mobile');
         $email = $this->request->getPost('email');
         $password = $this->request->getPost('password');
         if (empty($firstName) || empty($lastName) || empty($email) || empty($password)) {
             $this->flash->warning('<button type="button" class="close" data-dismiss="alert">×</button>All fields required');
             return $this->response->redirect();
         }
         if (!empty($email) && Users::findFirstByEmail($email)) {
             $errorMsg = "Email is already in use. Please try again.";
             $this->flash->error('<button type="button" class="close" data-dismiss="alert">×</button>' . $errorMsg);
             return $this->response->redirect();
         }
         $user = new Users();
         $user->created = date('Y-m-d H:i:s');
         $user->modified = date('Y-m-d H:i:s');
         $user->first_name = $firstName;
         $user->middle_name = $middleName;
         $user->last_name = $lastName;
         $user->mobile = $mobile;
         $user->street = $street;
         $user->city = $city;
         $user->country_id = $country_id;
         $user->email = $email;
         $user->password = $this->security->hash($password);
         if ($user->create()) {
             $activationToken = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 0, 50);
             $emailConfimation = new EmailConfirmations();
             $emailConfimation->created = date('Y-m-d H:i:s');
             $emailConfimation->modified = date('Y-m-d H:i:s');
             $emailConfimation->user_id = $user->id;
             $emailConfimation->email = $email;
             $emailConfimation->token = $activationToken;
             $emailConfimation->confirmed = 'N';
             if ($emailConfimation->save()) {
                 $this->getDI()->getMail()->send(array($email => $firstName . ' ' . $lastName), 'Please confirm your email', 'confirmation', array('confirmUrl' => 'admin/user/emailConfimation/' . $user->id . '/' . $email . '/' . $activationToken));
             }
             $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>You\'ve successfully created a MyBarangay account. We sent a confirmation email to ' . $email . '.');
         } else {
             //print_r($user->getMessages());
             $this->flash->error('<button type="button" class="close" data-dismiss="alert">×</button>Registration failed. Please try again.');
         }
         return $this->response->redirect();
     }
     $countries = Countries::find();
     $this->view->setVar('countries', $countries);
 }
开发者ID:hinjanobara,项目名称:mbimages,代码行数:61,代码来源:UserController.php

示例12: new_eventAction

 public function new_eventAction()
 {
     if ($this->request->isPost()) {
         $countryId = $this->request->getPost('country_id');
         $country = Countries::findFirst(array('columns' => '*', 'conditions' => 'id LIKE :id:', 'bind' => array('id' => $countryId)));
         $countryName = '';
         if ($country) {
             $countryName = $country->country;
         }
         $address = str_replace(' ', '+', $this->request->getPost('street') . '+' . $this->request->getPost('city') . '+' . $countryName);
         $userSession = $this->session->get("userSession");
         $content = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address=' . $address . '&key=AIzaSyAbpLPfBH8sNdVSzMULD_BZN9qrAqbL3V8');
         $json = json_decode($content, true);
         $lat = $json['results'][0]['geometry']['location']['lat'];
         $lng = $json['results'][0]['geometry']['location']['lng'];
         //error_log('LAT : '.$lat.' LONG : '.$lng);
         $events = new Events();
         $events->created = date('Y-m-d H:i:s');
         $events->modified = date('Y-m-d H:i:s');
         $events->member_id = $userSession['id'];
         $events->name = $this->request->getPost('name');
         $events->website = $this->request->getPost('website');
         $events->telephone = $this->request->getPost('telephone');
         $events->street = $this->request->getPost('street');
         $events->city = $this->request->getPost('city');
         $events->country_id = $this->request->getPost('country_id');
         $events->lat = $lat;
         $events->lng = $lng;
         $events->event_date = $this->request->getPost('eventdate');
         $events->event_category_id = $this->request->getPost('event_category_id');
         $events->eventinfo = $this->request->getPost('eventinfo');
         if ($events->create()) {
             $id = $events->id;
             $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>New event has been created');
             if (!empty($this->request->getPost('review'))) {
                 $review = new Reviews();
                 $review->created = date('Y-m-d H:i:s');
                 $review->modified = date('Y-m-d H:i:s');
                 $review->member_id = $userSession['id'];
                 $review->event_id = $events->id;
                 $review->content = $this->request->getPost('review');
                 $review->rate = $this->request->getPost('rate');
                 if ($review->create()) {
                     $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>You\'re review has been submitted.');
                 }
             }
             return $this->response->redirect('events/view/' . $id);
         }
     }
     $countries = Countries::find();
     $this->view->setVar('countries', $countries);
     $eventsCategories = EventsCategories::find();
     $this->view->setVar('eventsCategories', $eventsCategories);
 }
开发者ID:hinjanobara,项目名称:mbimages,代码行数:54,代码来源:EventsController.php

示例13: updateAction

 public function updateAction($id = null)
 {
     $member = Members::findFirstById($id);
     $userSession = $this->session->get('userSession');
     if (!$member || $userSession['id'] != $member->id) {
         $this->response->redirect('member/upload_photo/' . $userSession['id']);
     }
     $oldEmail = $member->email;
     $this->view->setVar('member', $member);
     if ($this->request->isPost()) {
         $member = Members::findFirstById($this->request->getPost('id'));
         $member->modified = date('Y-m-d H:i:s');
         $member->first_name = $this->request->getPost('first_name');
         $member->last_name = $this->request->getPost('last_name');
         $member->street = $this->request->getPost('street');
         $member->city = $this->request->getPost('city');
         $member->country_id = $this->request->getPost('country_id');
         $member->email = $this->request->getPost('email');
         $member->mobile = $this->request->getPost('mobile');
         //email cookie
         if (!empty($this->request->getPost('email'))) {
             $cookie_name = "e";
             $cookie_value = $this->request->getPost('email');
             setcookie($cookie_name, $this->encrypt($cookie_value), $date_of_expiry, "/");
         }
         if ($member->update()) {
             if ($oldEmail != $this->request->getPost('email')) {
                 $activationToken = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 0, 50);
                 $emailConfimation = new EmailConfirmations();
                 $emailConfimation->created = date('Y-m-d H:i:s');
                 $emailConfimation->modified = date('Y-m-d H:i:s');
                 $emailConfimation->user_id = $member->id;
                 $emailConfimation->email = $this->request->getPost('email');
                 $emailConfimation->token = $activationToken;
                 $emailConfimation->confirmed = 'N';
                 if ($emailConfimation->save()) {
                     $this->getDI()->getMail()->send(array($this->request->getPost('email') => $member->first_name . ' ' . $member->last_name), 'Please confirm your email', 'email_update_confirmation', array('confirmUrl' => 'member/emailConfimation/' . $member->id . '/' . $this->request->getPost('email') . '/' . $activationToken));
                 }
             }
             $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>You profile has been updated.');
             return $this->response->redirect('member/page/' . $this->request->getPost('id'));
         }
     }
     $countries = Countries::find();
     $this->view->setVar('countries', $countries);
 }
开发者ID:hinjanobara,项目名称:mbimages,代码行数:46,代码来源:MemberController.php

示例14: updateAction

 public function updateAction($id = null)
 {
     if ($this->request->isPost()) {
         $id = $this->request->getPost('id');
         $userSession = $this->session->get("userSession");
         $jobs = Jobs::findFirst($id);
         $jobs->modified = date('Y-m-d H:i:s');
         $jobs->member_id = $userSession['id'];
         $jobs->position = $this->request->getPost('position');
         $jobs->job_category_id = $this->request->getPost('job_category_id');
         $jobs->job_description = $this->request->getPost('job_description');
         $jobs->requirements = $this->request->getPost('requirements');
         $jobs->benefits = $this->request->getPost('benefits');
         $jobs->salary_from = $this->request->getPost('salary_from');
         $jobs->salary_to = $this->request->getPost('salary_to');
         $jobs->company = $this->request->getPost('company');
         $jobs->website = $this->request->getPost('website');
         $jobs->telephone = $this->request->getPost('telephone');
         $jobs->email = $this->request->getPost('email');
         $jobs->street = $this->request->getPost('street');
         $jobs->city = $this->request->getPost('city');
         $jobs->country_id = $this->request->getPost('country_id');
         $jobs->how_to_apply = $this->request->getPost('how_to_apply');
         if ($jobs->update()) {
             $id = $jobs->id;
             $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>New job has been updated');
             return $this->response->redirect('job/view/' . $id);
         }
     }
     $this->view->setVar('job', Jobs::findFirst($id));
     $countries = Countries::find();
     $this->view->setVar('countries', $countries);
     $jobCategories = JobCategories::find();
     $this->view->setVar('jobCategories', $jobCategories);
 }
开发者ID:hinjanobara,项目名称:mbimages,代码行数:35,代码来源:JobController.php

示例15: indexAction


//.........这里部分代码省略.........
             }
             $parameters['search_id'] = $search_id_get;
         } else {
             $search_id = null;
         }
         // Country
         if (!empty($_POST['search_country'])) {
             $search_country_get = $request->getPost('search_country', 'int');
             $parameters['search_country'] = $search_country_get;
             $search_country = " AND countries_id = {$search_country_get}";
         } else {
             $search_country = null;
         }
         // Currency
         if (!empty($_POST['search_currency'])) {
             $search_currency_get = $request->getPost('search_currency', 'string');
             $parameters['search_currency'] = $search_currency_get;
             $search_currency = " AND currency = '{$search_currency_get}'";
         } else {
             $search_currency = null;
         }
         // Status
         if (!empty($_POST['search_status'])) {
             $search_status_get = $request->getPost('search_status', 'string');
             $parameters['search_status'] = $search_status_get;
             switch ($search_status_get) {
                 case 'y':
                     $search_status = " AND payed = 1";
                     break;
                 case 'n':
                     $search_status = " AND payed = 0";
                     break;
                 case 'c':
                     $search_status = " AND cancelled = 1";
                     break;
             }
         } else {
             $search_status = null;
         }
         // Date from
         if (!empty($_POST['search_date_from'])) {
             $search_date_from_get = strtotime($request->getPost('search_date_from', 'string'));
             $parameters['search_date_from'] = $search_date_from_get;
             $search_date_from = " AND created > {$search_date_from_get}";
         } else {
             $search_date_from = null;
         }
         // Date to
         if (!empty($_POST['search_date_to'])) {
             $search_date_to_get = strtotime($request->getPost('search_date_to', 'string')) + 86399;
             $parameters['search_date_to'] = $search_date_to_get;
             $search_date_to = " AND created < {$search_date_to_get}";
         } else {
             $search_date_to = null;
         }
         // Active
         if (!empty($_POST['search_active'])) {
             $search_active_get = (int) $request->getPost('search_active', 'int');
             $parameters['search_active'] = $search_active_get;
             $search_active = " AND deactivated IS NULL OR deactivated = 0";
         } else {
             $search_active = null;
         }
         // Search parameters
         $parameters['qry'] = ['conditions' => "id IS NOT NULL\n                    {$search_id}\n                    {$search_country}\n                    {$search_currency}\n                    {$search_status}\n                    {$search_date_from}\n                    {$search_date_to}\n                    {$search_active}"];
     }
     // Other parameters
     $parameters['count'] = POrder::count($parameters['qry']);
     $parameters['qry']['order'] = "{$sortField} {$sortOrder}";
     $parameters['qry']['limit'] = 1000;
     $persistent->searchOrderParams = $parameters;
     //        var_dump($parameters);
     // Find all products according to set parameters
     $orders = POrder::find($parameters['qry']);
     // Paginator
     $paginator = new Paginator(["data" => $orders, "limit" => $parameters['sort']['perpage'], "page" => $parameters['sort']['page']]);
     // Sorting and table headers mapping
     $headMapping = ['id' => 'Номер', 'created' => 'Дата', 'firstName' => 'Имя', 'lastName' => 'Фамилия', '__country' => 'Страна', 'price' => 'Сумма', 'currency' => 'Валюта', '__payed' => 'Статус', 'paySystem' => 'Способ оплаты'];
     // Sorting header and order arrow
     $headings = array();
     foreach ($headMapping as $field => $name) {
         $headings[$field] = ['field' => $field, 'name' => $name, 'sort' => $sortField == $field ? $sortOrder == 'desc' ? 'asc' : 'desc' : false, 'arrow' => $sortField == $field ? $sortOrder == 'desc' ? '&nbsp;&#8595;' : '&nbsp;&#8593;' : false];
     }
     $this->view->headings = $headings;
     $this->view->page = $paginator->getPaginate();
     // Show total count
     $this->view->count = $parameters['count'];
     // Set selected search values
     $this->view->selected_id = isset($parameters['search_id']) && !empty($parameters['search_id']) ? $parameters['search_id'] : null;
     $this->view->selected_country = isset($parameters['search_country']) && !empty($parameters['search_country']) ? $parameters['search_country'] : null;
     $this->view->selected_currency = isset($parameters['search_currency']) && !empty($parameters['search_currency']) ? $parameters['search_currency'] : null;
     $this->view->selected_status = isset($parameters['search_status']) && !empty($parameters['search_status']) ? $parameters['search_status'] : null;
     $this->view->selected_date_from = isset($parameters['search_date_from']) && !empty($parameters['search_date_from']) ? $parameters['search_date_from'] : null;
     $this->view->selected_date_to = isset($parameters['search_date_to']) && !empty($parameters['search_date_to']) ? $parameters['search_date_to'] : null;
     $this->view->selected_active = isset($parameters['search_active']) && !empty($parameters['search_active']);
     // List of countries
     $this->view->countries = array_column(Countries::find(['order' => 'title'])->toArray(), 'title', 'id');
     // List of currencies
     $this->view->currencies = array_column(PCrosscurrency::find(['conditions' => 'siteswitcher != 0', 'order' => 'siteswitcher'])->toArray(), 'title', 'title');
 }
开发者ID:serge2300,项目名称:madeheart,代码行数:101,代码来源:OrdersController.php


注:本文中的Countries::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。