public function run($isTab = false) { /** @var TourBuilderForm $tourForm */ $tourForm = Yii::app()->user->getState('tourForm'); $eventId = $tourForm->eventId; $startCities = Yii::app()->user->getState('startCities'); $currentStartCityIndex = Yii::app()->user->getState('startCitiesIndex') - 1; $currentStartCity = City::model()->findByPk($startCities[$currentStartCityIndex]->id); $startCityId = $currentStartCity->id; $event = Event::model()->findByPk($eventId); $tripStorage = new TripStorage(); $order = $tripStorage->saveOrder($event, $startCityId, 'Тур для события "' . $event->title . '" из ' . $currentStartCity->caseGen); $eventOrder = new EventOrder(); $eventOrder->startCityId = $startCityId; $eventOrder->orderId = $order->id; $eventOrder->eventId = $event->id; $eventOrder->save(); $eventPrice = EventPrice::model()->findByAttributes(array('eventId' => $eventId, 'cityId' => $startCityId)); if (!$eventPrice) { $eventPrice = new EventPrice(); } $eventPrice->eventId = $event->id; $eventPrice->cityId = $startCityId; $eventPrice->bestPrice = $tripStorage->getPrice(); if (!$eventPrice->save()) { throw new CHttpException('Could not save price for event - city.' . CVarDumper::dumpAsString($eventPrice)); } $this->controller->redirect($this->controller->createUrl('showEventTrip')); }
public function actionReadTopic($id) { $thread = Thread::model()->getThreadInfoById($id); $this->areaLarge = $thread['program_name']; $this->areaSmall = $thread['semester_name']; $reply = new Reply(); $complaint = new Complaint('postComplaint'); if (isset($_POST['Reply'])) { $reply->attributes = $_POST['Reply']; $reply->post_item_id = $id; if ($reply->save()) { Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.reply.success')); $reply->unsetAttributes(); } else { Yii::app()->user->setFlash('error', Yii::t('forum', 'forum.view.reply.error')); } } if (isset($_POST['Complaint'])) { $complaint->attributes = $_POST['Complaint']; if ($complaint->save()) { if ($complaint->post_item_id == $id) { Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success')); } else { Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success')); } $complaint->unsetAttributes(); } else { Yii::app()->clientScript->registerScript('show_modal', "\$('#reportModal').modal('show');", CClientScript::POS_READY); } } $dataProvider = Thread::model()->getPostsDataInThread($id); Yii::log(CVarDumper::dumpAsString($dataProvider->getData())); $this->render('application.modules.community.views.front.post.view', array('thread' => $thread, 'threadId' => $id, 'dataProvider' => $dataProvider, 'reply' => $reply, 'complaint' => $complaint)); }
public function run() { $nav = $content = ''; $first = true; $type = rtrim($this->type, 's'); foreach ($this->items as $id => $item) { if (is_array($item['content'])) { $id = "{$this->id}-{$id}"; $opts = $first ? array('class' => 'active') : array(); $opts['class'] = isset($opts['class']) ? $opts['class'] . ' dropdown' : 'dropdown'; $dropdown = array(); foreach ($item['content'] as $subId => $subTab) { Yii::trace(CVarDumper::dumpAsString($subTab)); $subOpts = array(); $subOpts['id'] = "{$id}-{$subId}"; $subOpts['class'] = 'tab-pane'; $content .= CHtml::tag('div', $subOpts, $subTab['content']); $dropdown[$subTab['title']] = '#' . $subOpts['id']; } Yii::trace(CVarDumper::dumpAsString($dropdown)); $nav .= CHtml::tag('li', $opts, BHtml::dropdownToggle($item['title']) . BHtml::dropdownMenu($dropdown, array('linkOptions' => array('data-toggle' => 'tab')))); } else { $id = "{$this->id}-{$id}"; $opts = $first ? array('class' => 'active') : array(); $nav .= CHtml::tag('li', $opts, CHtml::link($item['title'], "#{$id}", array('data-toggle' => $type))); $opts['id'] = $id; $opts['class'] = isset($opts['class']) ? $opts['class'] . ' tab-pane' : 'tab-pane'; $content .= CHtml::tag('div', $opts, $item['content']); } $first = false; } echo CHtml::tag('div', $this->htmlOptions, CHtml::tag('ul', $this->navOptions, $nav) . CHtml::tag('div', array('class' => 'tab-content'), $content)); BHtml::registerBootstrapJs(); }
public function actionAdd() { $model = new Umbrella(); if (isset($_POST['Umbrella'])) { $model->attributes = $_POST; $model->umbrellaid = uniqid('', true); $model->attributes = $_POST['Umbrella']; $model->create_userid = $this->user_id; $model->now_userid = $this->user_id; $model->create_at = $this->getTime(); if (SERVER_TEST) { $model->img = "http://umbrella.b0.upaiyun.com/991c/991c1b1f34d6d076bcf7e01925af1e43/7GTMyFS_QW00m6fdAzzdphLPJtGAvlF9Gd4ivkWNQ9-olR2mFgn6NBn8JW8e78H2.jpg"; } // $model->status=UMBRELLASTATUS::IDLE; if ($model->validate()) { $model->img = $this->updateWxImage($model->img); if (!$model->save()) { Yii::log(CVarDumper::dumpAsString($user->errors), 'error', "Add umbrella save error"); } $this->actionInfo($model->umbrellaid); return; } } $this->render('add', array('model' => $model, 'status' => 'new')); }
/** * @param array $options options for tree searching. Valid options are: * exclude: array list of children exclusions * level: integer, recursion depth, default=-1 * Level -1 means searching for all children under root; * Level 0 means searching for only the child DIRECTLY under the root; * level N means searching for those children that are within N levels. */ public function findTree($options = array()) { $exclude = array(); $level = -1; extract($options); $cache = $this->getCache(); $cacheKey = get_class($this->getOwner()) . '-' . $this->getOwner()->{$this->primaryKey} . '-' . $this->className . '-' . $this->primaryKey . '-' . $this->attributeName . '-' . CVarDumper::dumpAsString($this->attributes) . '-' . CVarDumper::dumpAsString($this->criteria) . '-' . CVarDumper::dumpAsString($exclude) . '-' . CVarDumper::dumpAsString($level); $cacheKey = md5($cacheKey); if (isset($cache) && ($data = $cache->get($cacheKey)) !== false) { Yii::trace('Find tree from cache:' . $cacheKey, 'Xpress.extensions.web.behaviors'); return $data; } $event = new NestedEvent($this); $event->params = array('exclude' => $exclude, 'level' => $level); if ($this->hasEventHandler('onBeforeFindTree')) { $this->onBeforeFindTree($event); } $tree = $this->findTreeRecursive($exclude, 0, NULL, $level); $event->data =& $tree; if ($this->hasEventHandler('onAfterFindTree')) { $this->onAfterFindTree($event); } if (isset($cache)) { $cache->set($cacheKey, $tree); } Yii::trace('Find tree from database', 'Xpress.extensions.web.behaviors'); return $tree; }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { /* @param Slide $model*/ $model = $this->loadModel($id); $maxPositions = Slide::model()->count(); Yii::log("PrevImage: " . $model->slide_image, 'log'); if (isset($_POST['Slide'])) { $model->oldPosition = $model->position; $model->attributes = $_POST['Slide']; Yii::log("CurrImage: " . $model->slide_image, 'log'); $fileUpload = CUploadedFile::getInstance($model, 'slide_image'); Yii::log("FileUpload: " . CVarDumper::dumpAsString($fileUpload), 'log'); if ($fileUpload !== null) { $model->removeImage(); $model->slide_image = $fileUpload; } if ($model->validate() && $model->save()) { if ($fileUpload !== null) { $model->slide_image->saveAs(Yii::app()->basePath . '/../files/images/slides/' . $model->slide_image . "_" . $model->getPrimaryKey()); } $this->redirect(array('view', 'id' => $model->slide_id)); } } $viewablePositions = array(); foreach (range(0, $maxPositions - 1) as $position) { $viewablePositions[$position] = Formatter::formatOrdinal($position + 1); } $this->positions = $viewablePositions; $this->render('update', array('model' => $model)); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = new WorkshopForm('view', $id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['WorkshopForm'])) { $model->attributes = $_POST['WorkshopForm']; $model->postItem->attributes = $_POST['PostItem']; $model->workshop->attributes = $_POST['Workshop']; $model->workshopFile = CUploadedFile::getInstance($model, 'workshopFile'); Yii::log(CVarDumper::dumpAsString($model->workshopFile)); if ($model->validate()) { $fileUpload = $model->workshopFile; if ($fileUpload !== null) { $model->workshop->removeFile(); $model->workshop->workshop_file = $fileUpload; $fileName = $fileUpload->name; } if ($model->save()) { if ($model->workshop->workshop_file !== null) { $userFilePath = FileHelper::getFilePath(Yii::getPathOfAlias('site.files') . '/workshops/' . $model->postItem->primaryKey . '/'); $model->workshopFile->saveAs($userFilePath . $fileName); } $this->redirect(array('view', 'id' => $model->workshop->post_item_id)); } } } $this->render('update', array('model' => $model)); }
public static function createOrUpdate($id, $title, $address, $latitude, $longitude, $type = 'create') { $querystring_arrays = array(); $uri = ''; if ($type == 'create') { //这里是创建 $uri = '/geodata/v3/poi/create'; $querystring_arrays = array('id' => $id, 'title' => $title, 'latitude' => $latitude, 'longitude' => $longitude, 'coord_type' => 1, 'geotable_id' => GEOTABLE_ID, 'ak' => MAP_AK); } else { //这里是更新 $uri = '/geodata/v3/poi/update'; $querystring_arrays = array('id' => $id, 'title' => $title, 'latitude' => $latitude, 'longitude' => $longitude, 'coord_type' => 1, 'geotable_id' => GEOTABLE_ID, 'ak' => MAP_AK); } $sn = BDLbs::caculateAKSN($uri, $querystring_arrays, "POST"); $querystring_arrays['sn'] = $sn; Yii::trace(CVarDumper::dumpAsString($querystring_arrays), 'create or update baidu poi post'); $ret = Yii::app()->curl->post(Yii::app()->params['baiduapi'] . $uri, $querystring_arrays); $ret = json_decode($ret, true); Yii::trace(CVarDumper::dumpAsString($ret), 'create or update baidu poi'); if ($ret['status'] == 0) { return $ret['id']; } else { Yii::log(CVarDumper::dumpAsString($ret), 'error', 'create or update baidu poi ERROR'); return -1; } }
public static function injectForBe($flightVoyages, $injectSearchParams = false) { $newFlights = array(); try { if (!is_iterable($flightVoyages)) { throw new CException('Flight Voyages are not iterable.'); } foreach ($flightVoyages as $key => $flight) { $newFlight = $flight; if ($injectSearchParams) { $newFlight['serviceClass'] = $injectSearchParams['serviceClass']; $newFlight['freeWeight'] = $newFlight['serviceClass'] == 'E' ? $flight['economFreeWeight'] : $flight['businessFreeWeight']; $newFlight['freeWeightDescription'] = $newFlight['serviceClass'] == 'E' ? $flight['economDescription'] : $flight['businessDescription']; unset($newFlight['economFreeWeight']); unset($newFlight['businessFreeWeight']); unset($newFlight['economDescription']); unset($newFlight['businessDescription']); } $newFlights[] = $newFlight; } return $newFlights; } catch (Exception $e) { $newException = new Exception("Error: " . $e->getMessage() . " Data: " . CVarDumper::dumpAsString($flightVoyages)); Yii::app()->RSentryException->logException($newException); return $newFlights; } }
public function registerScript($id, $script, $position = null, array $htmlOptions = array()) { // assumed config includes the required path aliases to use // EScriptBoost $debug = YII_DEBUG; // Check if this script is in the exceptions - if so, skip caching. foreach ($this->skipList as $s) { $skip |= strpos($id, $s) === 0; if ($skip) { break; } } $compressed = !$debug ? false : Yii::app()->cache->get($id); if ($skip) { // Skipping scripts that should not be cached. $compressed = EScriptBoost::minifyJs($script); } elseif ($debug && $compressed !== false) { // During debug check that the newly minified script is not different from the cached one. // If so, log the difference so that it can be fixed. $c = EScriptBoost::minifyJs($script); if ($c !== $compressed) { Yii::log("Issue with caching of compressed script '{$id}'\n" . CVarDumper::dumpAsString($c) . "\nXXX\n" . CVarDumper::dumpAsString($compressed), CLogger::LEVEL_ERROR); } } elseif ($compressed === false) { $compressed = EScriptBoost::minifyJs($script); Yii::app()->cache->set($id, $compressed, $this->cacheDuration); } parent::registerScript($id, $compressed, $position, $htmlOptions); }
public function bookAndReturnTripElementWorkflowItem($index) { try { $bookedTripElementWorkflow = array(); $item = $this->itemsOnePerGroup[$index]; if ($this->isDoubleRequest($item)) { throw new CHttpException(400, 'Double request'); } $tripElementWorkflow = $item->createTripElementWorkflow(); $tripElementWorkflow->bookItem(); $this->markItemGroupAsBooked($tripElementWorkflow->getItem()); $tripElementWorkflow->runWorkflowAndSetFinalStatus(); $this->saveWorkflowState($tripElementWorkflow->finalStatus); $tripElementWorkflow->updateBookingId(); Yii::app()->shoppingCart->update($item, 1); $bookedTripElementWorkflow[] = $tripElementWorkflow; if ($this->areAllStatusesCorrect()) { Yii::app()->user->setState('blockedToBook', null); return $bookedTripElementWorkflow; } else { throw new CHttpException(500, 'At least one of workflow status at step 1 is incorrect:' . CVarDumper::dumpAsString($this->finalWorkflowStatuses)); } } catch (Exception $e) { throw new CHttpException(500, 'We can not book ' . $index . '-th item: ' . $e->getMessage()); } }
public function filterLogRequest($filterChain) { if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) { Yii::log(CVarDumper::dumpAsString($GLOBALS["HTTP_RAW_POST_DATA"]), 'trace', 'WX_RAW_REQUEST_DATA'); } Yii::log(CVarDumper::dumpAsString($_REQUEST), 'trace', 'WX_RAW_REQUEST'); $filterChain->run(); }
public function renderCoreScripts() { $folder = 'frontend.tmp'; $path = Yii::getPathOfAlias($folder); $filePath = $path . '/core.txt'; file_put_contents($filePath, CVarDumper::dumpAsString($this->coreScripts)); parent::renderCoreScripts(); }
/** * Dumps a variable or the object itself in terms of a string. * * @param mixed variable to be dumped */ protected function dump($var = 'dump-the-object', $highlight = true) { if ($var === 'dump-the-object') { return CVarDumper::dumpAsString($this, $depth = 15, $highlight); } else { return CVarDumper::dumpAsString($var, $depth = 15, $highlight); } }
/** * Generates the required HTML and Javascript */ public function run() { //echo 'Chức năng upload file tạm thời Off để bảo trì, liên hệ trangptk@vega.com.vn'; list($name, $id) = $this->resolveNameID(); $model = $this->model; if (!isset($this->options['uploadTable'])) { $uploadTable = "files"; $this->options['uploadTable'] = "#files"; } else { $uploadTable = $this->options['uploadTable']; $this->options['uploadTable'] = "#{$uploadTable}"; } if (!isset($this->options['downloadTable'])) { $downloadTable = "files"; $this->options['downloadTable'] = "#files"; } else { $downloadTable = $this->options['downloadTable']; $this->options['downloadTable'] = "#{$downloadTable}"; } if (!isset($this->options['buildUploadRow'])) { $this->options['buildUploadRow'] = $this->_getBuildUploadRow(); } if (!isset($this->options['buildDownloadRow'])) { $this->options['buildDownloadRow'] = $this->_getBuildDownloadRow(); } if (!isset($this->htmlOptions['enctype'])) { $this->htmlOptions['enctype'] = 'multipart/form-data'; } if (!isset($this->htmlOptions['class'])) { $this->htmlOptions['class'] = 'xupload-form file_upload'; } if (!isset($this->htmlOptions['id'])) { $this->htmlOptions['id'] = get_class($model) . "_form"; } $options = CJavaScript::encode($this->options); CVarDumper::dumpAsString($options, 10, true); Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $this->htmlOptions['id'], "jQuery('#{$this->htmlOptions['id']}').fileUploadUI({$options});", CClientScript::POS_READY); //echo "<pre>";print_r($options);exit(); echo CHtml::beginForm($this->url, 'post', $this->htmlOptions); $htmlOptions = array(); if ($this->multiple) { $htmlOptions["multiple"] = true; } if ($this->hasModel()) { echo CHtml::activeFileField($this->model, $this->attribute, $htmlOptions); } else { echo CHtml::fileField($name, $this->value, $htmlOptions); } echo CHtml::tag("button", array(), "Upload", true); echo CHtml::tag("div", array(), $this->text, true); echo CHtml::endForm(); if ($uploadTable == $downloadTable) { echo CHtml::tag("table", array("id" => $uploadTable), "", true); } else { echo CHtml::tag("table", array("id" => $uploadTable), "", true); echo CHtml::tag("table", array("id" => $downloadTable), "", true); } }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { // renders the view file 'protected/views/site/studentIndex.php' // using the default layout 'protected/views/layouts/main.php' $articleData = Article::model()->getBriefArticlesData(self::homePageArticleLimit); $slideItems = Slide::getSliderItems(); Yii::log(CVarDumper::dumpAsString($slideItems)); $this->render('index', array('articleData' => $articleData, 'slideItems' => $slideItems)); }
public function beforeSave() { parent::beforeSave(); $dumper = new FlightCacheDumper(); $dumper->model = $this; $dumper->save(); Yii::log("FLIGHT CACHE DUMPER = \n" . CVarDumper::dumpAsString($dumper->model->attributes)); return false; }
/** * If debug = 2 in application/config.php this will produce output in the console / firebug * similar to var_dump. It will also include the filename and line that called this method. * * @param mixed $variable The variable to be dumped * @param int $depth Maximum depth to go into the variable, default is 10 */ function traceVar($variable, $depth = 10) { $msg = CVarDumper::dumpAsString($variable, $depth, false); $fullTrace = debug_backtrace(); $trace = array_shift($fullTrace); if (isset($trace['file'], $trace['line']) && strpos($trace['file'], YII_PATH) !== 0) { $msg = $trace['file'] . ' (' . $trace['line'] . "):\n" . $msg; } Yii::trace($msg, 'vardump'); }
private function saveItemsOfOrder() { foreach ($this->itemsOnePerGroup as $item) { if (!$item->saveToOrderDb()) { $errMsg = "Could not save order's item" . PHP_EOL . CVarDumper::dumpAsString($item); $this->logAndThrowException($errMsg, 'TripStorage.saveItemsOfOrder'); } $item->saveReference($this->order); } }
private function doRequest($postData) { $curl = curl_init(); $curlOptions = array(CURLOPT_URL => 'http://atompark.com/members/sms/xml.php', CURLOPT_FOLLOWLOCATION => false, CURLOPT_POST => true, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => 15, CURLOPT_TIMEOUT => 100, CURLOPT_POSTFIELDS => array('XML' => $postData)); curl_setopt_array($curl, $curlOptions); if (false === ($response = curl_exec($curl))) { throw new Exception('Http request failed with code ' . CVarDumper::dumpAsString($response)); } curl_close($curl); return $response; }
private function doRequest($url, $args) { $argsJson = CJSON::encode($args); $curl = curl_init(); $curlOptions = array(CURLOPT_URL => $url, CURLOPT_FOLLOWLOCATION => false, CURLOPT_POST => true, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => 15, CURLOPT_TIMEOUT => 100, CURLOPT_POSTFIELDS => $argsJson); curl_setopt_array($curl, $curlOptions); if (false === ($response = curl_exec($curl))) { throw new Exception('Http request failed with code ' . CVarDumper::dumpAsString($response)); } curl_close($curl); return CJSON::decode($response); }
private function createFlightBookerWorkflow() { Yii::trace("Create FlightBooker", "FlightTripElementWorkflow.createFlightBookerWorkflow"); $flightBookerComponent = new FlightBookerComponent(); $flightBookerComponent->setFlightBookerFromFlightVoyage($this->item->flightVoyage, $this->item->searchParams); $currentFlightBookerComponent = $flightBookerComponent->getCurrent(); $currentFlightBookerComponent->orderBookingId = self::$bookingContactInfo->id; if (!$currentFlightBookerComponent->save()) { $errMsg = "Could not save FlightBooker" . PHP_EOL . CVarDumper::dumpAsString($currentFlightBookerComponent->getErrors()); $this->logAndThrowException($errMsg, 'OrderComponent.saveCredentialsForFlight'); } Yii::trace("FlightBooker saved. FlighBooker id is " . $currentFlightBookerComponent->getPrimaryKey(), "OrderComponent.saveCredentialsForFlight"); return $flightBookerComponent; }
public function soapRequest($method, $request) { if (empty($this->soapClient)) { return array('success' => false); } try { $ret = $this->soapClient->{$method}($request); $success = true; } catch (SoapFault $e) { Yii::log(__METHOD__ . ' soapRequest failed: ' . $e->getMessage() . "\n\n" . '$method: ' . CVarDumper::dumpAsString($method) . "\n\n" . '$request: ' . CVarDumper::dumpAsString($request), 'warning', 'soap.behavior'); $success = false; } return array('success' => $success, 'wsReturn' => $ret); }
/** * Responds to {@link CActiveRecord::onAfterSave} event. * Overrides this method if you want to handle the corresponding event of the {@link CBehavior::owner owner}. * @param CModelEvent $event event parameter */ public function afterSave($event) { $data = array(); $objectId = $this->getOwner()->{$this->objectAttribute}; if ($this->useActiveField) { $data = $this->getOwner()->{$this->name}; if (!is_array($data) && !is_object($data)) { $data = array((int) $data); } } else { if (isset($_POST[$this->name])) { $data = $_POST[$this->name]; if (!is_array($data) && !is_object($data)) { $data = array((int) $data); } } } //delete old $sql = "DELETE FROM " . SITE_ID . '_' . "taxonomy_index t" . "\n USING " . SITE_ID . '_' . "taxonomy_term tt, " . SITE_ID . '_' . "taxonomy_vocabulary tv" . "\n WHERE tt.id = t.term_id AND tv.id = tt.v_id" . (is_numeric($this->taxonomy) ? "\n AND (tv.id = :id)" : "\n AND (tv.alias = :alias)") . "\n AND tv.module = :module AND t.object_id = :object_id"; if (count($data)) { foreach ($data as $index => $val) { $data[$index] = CPropertyValue::ensureInteger($val); } $dataString = implode(',', $data); $sql .= "\n AND t.term_id NOT IN ({$dataString})"; } $command = TermRelation::model()->getDbConnection()->createCommand($sql); if (is_numeric($this->taxonomy)) { $command->bindParam(":id", $this->taxonomy, PDO::PARAM_INT); } else { $command->bindParam(":alias", $this->taxonomy, PDO::PARAM_STR); } $command->bindParam(":module", $this->module, PDO::PARAM_STR); $command->bindParam(":object_id", $objectId, PDO::PARAM_INT); $command->execute(); //update/create if (count($data)) { foreach ($data as $val) { $relation = TermRelation::model()->findByAttributes(array('object_id' => $objectId, 'term_id' => $val)); if (!is_object($relation)) { $relation = new TermRelation(); } $relation->object_id = $objectId; $relation->term_id = $val; if (!$relation->save()) { Yii::log(CVarDumper::dumpAsString($relation->getErrors()), CLogger::LEVEL_ERROR); } } } }
public static function getAirlineByCode($code) { if (isset(Airline::$codeIdMap[$code])) { return Airline::$airlines[Airline::$codeIdMap[$code]]; } else { $airline = Airline::model()->findByAttributes(array('code' => $code)); if ($airline) { Airline::$airlines[$airline->id] = $airline; Airline::$codeIdMap[$airline->code] = $airline->id; return Airline::$airlines[Airline::$codeIdMap[$code]]; } else { throw new CException(Yii::t('application', 'Airline with code ' . CVarDumper::dumpAsString($code) . ' not found')); } } }
private function saveChildrenPassports($i, $roomPassport, $hotelBookerId) { foreach ($roomPassport->childrenPassports as $childInfo) { $hotelPassport = new HotelBookingPassport(); $hotelPassport->scenario = 'child'; $hotelPassport->attributes = $childInfo->attributes; $hotelPassport->hotelBookingId = $hotelBookerId; $hotelPassport->roomKey = $i; if (!$hotelPassport->save()) { $errMsg = 'Incorrect child passport data.' . PHP_EOL . CVarDumper::dumpAsString($hotelPassport->errors); Yii::trace($errMsg, 'HotelBooker.EnterCredentials.childPassport'); throw new CException($errMsg); } } }
function dump($var, $echo = true, $title = "") { $result = ""; if ($title != "") { $result .= "<b>" . $title . ":</b><br/>"; } $result .= "<pre>"; $result .= CVarDumper::dumpAsString($var, 10, false); $result .= "</pre>"; $result .= "<br/>"; if ($echo) { echo $result; } return $result; //return var_dump($var); }
/** * Sends get request to reset the data * @return boolean Returns true if everything went well, false otherwise */ public function resetData() { $is_successful = false; $resetUrl = Yii::app()->params['reset_url']; $curlRes = curl_init($resetUrl); curl_setopt($curlRes, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curlRes, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curlRes, CURLOPT_RETURNTRANSFER, true); $returnedData = curl_exec($curlRes); $httpcode = curl_getinfo($curlRes, CURLINFO_HTTP_CODE); if ($httpcode == '200') { $is_successful = true; } Yii::log(CVarDumper::dumpAsString($returnedData), CLogger::LEVEL_INFO, "reset"); return $is_successful; }
public function addImages() { //If we have pending images if (Yii::app()->user->hasState('images')) { $userImages = Yii::app()->user->getState('images'); // dump($userImages);exit; //Resolve the final path for our images // $path = Yii::app()->getBasePath() . "/../images/uploads/"; // $path = realpath(Yii::app()->getBasePath() . "/../upload/item/image") . "/"; // //Create the folder and give permissions if it doesnt exists // if (!is_dir($path)) { // mkdir($path); // chmod($path, 0777); // } //Now lets create the corresponding models and move the files foreach ($userImages as $k => $image) { if (is_file($image["path"])) { // if (rename($image["path"], $path . $image["url"])) { // chmod($path . $image["filename"], 0777); // $img = new ItemImg( ); $img = new ARGrouponAttach(); $img->relation_id = $this->id; $img->title = $this->name . '合同附件'; $img->file_path = $image['filename']; $img->create_time = time(); // $img->size = $image["size"]; // $img->mime = $image["mime"]; // $img->name = $image["name"]; if (!$img->save()) { //Its always good to log something Yii::log("Could not save Image:\n" . CVarDumper::dumpAsString($img->getErrors()), CLogger::LEVEL_ERROR); //this exception will rollback the transaction throw new Exception('Could not save Image'); } // } } else { //You can also throw an execption here to rollback the transaction Yii::log($image["path"] . " is not a file", CLogger::LEVEL_WARNING); } } //Clear the user's session Yii::app()->user->setState('images', null); } }
public function compare($other) { if (!is_object($other)) { return false; } if (get_class($this) !== get_class($other)) { return false; } $diff = array(); $match = true; foreach ($this->attributes as $key => $value) { if ($this->tableSchema->primaryKey != $key && $key != 'order_options' && $key != 'total' && $key != 'quantity' && $this->{$key} != $other->{$key}) { $diff[$key] = array('old' => $this->{$key}, 'new' => $other->{$key}); $match = false; } } Yii::log("OrderCreateActiondiff: " . CVarDumper::dumpAsString($diff), CLogger::LEVEL_ERROR, "order.actions.create"); $match2 = true; if ($match) { if (!empty($this->order_options) && !empty($other->order_options)) { $flag = true; foreach ($this->order_options as $cartorderoption) { foreach ($other->order_options as $orderoption) { if ($orderoption->product_option_id == $cartorderoption->product_option_id) { if (!$orderoption->compare($cartorderoption)) { $match2 = false; } break; } } if (!$match2) { break; } } } else { if (!empty($this->order_options) || !empty($other->order_options)) { $match2 = false; } } } return $match && $match2; }