/** * Displays a view * * @param mixed What page to display * @return void * @throws NotFoundException When the view file could not be found * or MissingViewException in debug mode. */ public function display() { $path = func_get_args(); //debug($path); $count = count($path); //debug($count); if (!$count) { return $this->redirect('/'); } $page = $subpage = $title_for_layout = null; //debug(Inflector::humanize($path[$count - 1])); if (!empty($path[0])) { $page = $path[0]; } if (!empty($path[1])) { $subpage = $path[1]; } if (!empty($path[$count - 1])) { $title_for_layout = Inflector::humanize($path[$count - 1]); } $this->set(compact('page', 'subpage', 'title_for_layout')); //debug($this->render(implode('/', $path))); //debug($page); //debug($subpage); //debug($title_for_layout); try { $this->render(implode('/', $path)); } catch (MissingViewException $e) { if (Configure::read('debug')) { throw $e; } throw new NotFoundException(); } }
/** * Handle the event. * * @param ChildWasRegistered $event * @return void */ public function handle(ChildWasRegistered $event) { $parent = $event->user; Mail::send('register.mail.registered', compact('parent'), function ($message) use($parent) { $message->to($parent->email)->from('*****@*****.**')->subject('Thank you for registering'); }); }
public function about() { $first = 'Haonan'; $last = 'Xu'; $people = []; return view('pages.about', compact('first', 'last', 'people')); }
/** * Return the install path based on package type. * * @param PackageInterface $package * @param string $frameworkType * @return string */ public function getInstallPath(PackageInterface $package, $frameworkType = '') { $type = $this->package->getType(); $prettyName = $this->package->getPrettyName(); if (strpos($prettyName, '/') !== false) { list($vendor, $name) = explode('/', $prettyName); } else { $vendor = ''; $name = $prettyName; } $availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type')); $extra = $package->getExtra(); if (!empty($extra['installer-name'])) { $availableVars['name'] = $extra['installer-name']; } if ($this->composer->getPackage()) { $extra = $this->composer->getPackage()->getExtra(); if (!empty($extra['installer-paths'])) { $customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type); if ($customPath !== false) { return $this->templatePath($customPath, $availableVars); } } } $packageType = substr($type, strlen($frameworkType) + 1); $locations = $this->getLocations(); if (!isset($locations[$packageType])) { throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type)); } return $this->templatePath($locations[$packageType], $availableVars); }
/** * Return an index of archived posts. * * @param PostRepositoryInterface $posts * @param $year * @param null $month * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index(PostRepositoryInterface $posts, $year, $month = null) { $this->dispatch(new AddPostsBreadcrumb()); $this->dispatch(new AddArchiveBreadcrumb()); $posts = $posts->findManyByDate($year, $month); return view('anomaly.module.posts::archive/index', compact('year', 'month', 'posts')); }
/** * index method * * @access public * @return void */ public function index() { $this->set('testData', 'Some test data'); $test2 = 'more data'; $test3 = 'even more data'; $this->set(compact('test2', 'test3')); }
public function sendEmailConfirmationTo(User $user) { $this->to = $user->email; $this->view = 'emails.confirm'; $this->data = compact('user'); $this->deliver(); }
/** * Init the index view with the current * average rate data stored in the db. * * @return Response */ public function index() { // Select the rates of the year 2015. // NOTE: Just for the purpose of the exercise, // would be nicer to provide all the results available // grouped accordingly $rates = Db::table('monthly_rates')->select('currency_from', 'currency_to', 'month', 'avg_rate')->where('year', 2015)->orderBy('currency_from')->orderBy('currency_to')->get(); // Initialize the messages array as charts.js expects it if (empty($rates)) { $messages = [[]]; } else { $messages = []; } $monthRates = []; $totRates = count($rates); // Aggregate the messages as an array // currencyfrom_currencyto => [1 => avg_rate, 2 => ...] // where the inner array index corresponds to a month for ($i = 0; $i < $totRates; $i++) { $rate = $rates[$i]; $monthRates[$rate->month] = $rate->avg_rate; if ($i == $totRates - 1) { $key = $rate->currency_from . '-' . $rate->currency_to; $messages[$key] = $monthRates; } elseif ($rate->currency_from != $rates[$i + 1]->currency_from || $rate->currency_to != $rates[$i + 1]->currency_to) { // Build the array key and store the data $key = $rate->currency_from . '-' . $rate->currency_to; $messages[$key] = $monthRates; $monthRates = []; } } return view('socket', compact('messages')); }
public function actionProject() { $form = ""; if (Yii::app()->getRequest()->ispostRequest) { $project_des = Yii::app()->request->getParam('project_des'); $project_price = Yii::app()->request->getParam('project_price'); $project_name = Yii::app()->request->getParam('project_name'); $project_type = Yii::app()->request->getParam('project_type'); $project_time = Yii::app()->request->getParam('project_time'); if ($project_des != '') { Yii::app()->session['project_des'] = Yii::app()->request->getParam('project_des'); } if ($project_name != '') { Yii::app()->session['project_name'] = Yii::app()->request->getParam('project_name'); } if ($project_price != '') { Yii::app()->session['project_price'] = Yii::app()->request->getParam('project_price'); } if ($project_type != '') { Yii::app()->session['project_type'] = Yii::app()->request->getParam('project_type'); } if ($project_time != '') { Yii::app()->session['project_time'] = Yii::app()->request->getParam('project_time'); } echo 'success!'; } $this->renderPartial('_project', compact("form"), false, true); }
public function index(WpApiContract $wp_client) { $posts = $wp_client->getPosts(); $posts = json_decode($posts); //dd($posts); return view('layouts.index', compact('posts')); }
/** * Display a listing of products on the wishlist. * * @return \Illuminate\View\View */ public function index() { $wishlist = $this->wishlist; $items = $this->wishlist->items(); $total = $this->wishlist->total(); return View::make('cart.wishlist', compact('wishlist', 'items', 'total')); }
public function pending_leads_by_source() { $data_sources = $this->reporting->pendingLeadsBySource()->lists('label'); $data_count = $this->reporting->pendingLeadsBySource()->lists('data'); $leads = $this->reporting->allPendingBySource(); return view('admin.leadrouter.pending_leads_by_source', compact('leads', 'data_sources', 'data_count')); }
public function demo() { $data = []; $data['username'] = '******'; $data['password'] = '******'; return view('page.demo', compact('data')); }
/** * index method * * @return void * @access public */ public function index($type = null, $lat = null, $long = null, $opt1 = null, $opt2 = null) { $params = array('limit' => 35, 'page' => 1); if (!empty($type) && !empty($lat) && !empty($long)) { $lat = floatval($lat); $long = floatval($long); $opt1 = floatval($opt1); $opt2 = floatval($opt2); switch ($type) { case 'near': if (!empty($opt1)) { $cond = array('loc' => array('$near' => array($lat, $long), '$maxDistance' => $opt1)); } else { $cond = array('loc' => array('$near' => array($lat, $long))); } break; case 'box': $lowerLeft = array($lat, $long); $upperRight = array($opt1, $opt2); $cond = array('loc' => array('$within' => array('$box' => array($lowerLeft, $upperRight)))); break; case 'circle': $center = array($lat, $long); $radius = $opt1; $cond = array('loc' => array('$within' => array('$center' => array($center, $radius)))); break; } $params['conditions'] = $cond; } else { $params['order'] = array('_id' => -1); } $results = $this->Geo->find('all', $params); $this->set(compact('results')); }
public function getIndex() { $title = 'Search'; $company_results = Company::select('companies.*', 'c.name as country', 'a.city as city')->join('adresses as a', 'companies.address_id', '=', 'a.id')->join('countries as c', 'a.country_id', '=', 'c.id')->orderBy('companies.id', 'DESC')->take(5)->get(); $company_data = []; foreach ($company_results as $curr_company) { $curr_company = (object) ['DT_RowId' => $curr_company->id, 'name' => $curr_company->name, 'references' => $curr_company->references, 'country' => $curr_company->country, 'city' => $curr_company->city]; $curr_entry = (object) $curr_company; $company_data[] = $curr_entry; } $company_init = json_encode(['data' => $company_data]); $venue_results = Venue::select('venues.*', 'c.name as country', 'a.city as city')->join('adresses as a', 'venues.address_id', '=', 'a.id')->join('countries as c', 'a.country_id', '=', 'c.id')->orderBy('venues.id', 'DESC')->take(5)->get(); $venue_data = []; foreach ($venue_results as $curr_venue) { $curr_venue = (object) ['DT_RowId' => $curr_venue->id, 'name' => $curr_venue->name, 'capacity' => $curr_venue->capacity, 'rigging_capacity' => $curr_venue->rigging_capacity, 'country' => $curr_venue->country, 'city' => $curr_venue->city]; $curr_entry = (object) $curr_venue; $venue_data[] = $curr_entry; } $venue_init = json_encode(['data' => $venue_data]); $contact_results = Contact::select('contacts.*', 'c.name as country')->join('adresses as a', 'contacts.address_id', '=', 'a.id')->join('countries as c', 'a.country_id', '=', 'c.id')->orderBy('contacts.id', 'DESC')->take(5)->get(); $contact_data = []; foreach ($contact_results as $curr_contact) { $curr_contact = (object) ['DT_RowId' => $curr_contact->id, 'first_name' => $curr_contact->first_name, 'last_name' => $curr_contact->last_name, 'country' => $curr_contact->country, 'function' => $curr_contact->function]; $curr_entry = (object) $curr_contact; $contact_data[] = $curr_entry; } $contact_init = json_encode(['data' => $contact_data]); return View::make('site/' . $this->name . '/index', compact('title', 'company_init', 'venue_init', 'contact_init')); }
/** * HTTP GET handler * * @throws NotFoundException If record not found * @param string $search_term * @return void */ protected function _get($search_term = null) { $model = $this->_model(); $findMethod = $this->_getFindMethod('search'); $query = array(); $query['conditions'] = array($model->displayField => $search_term); $query['recursive'] = -1; $query['limit'] = 6; $subject = $this->_trigger('beforeFind', compact('id', 'query', 'findMethod')); $item = $model->find($subject->findMethod, $subject->query); if (empty($item)) { $this->_trigger('recordNotFound', compact('id')); $message = $this->message('recordNotFound', array('id' => $search_term)); $exceptionClass = $message['class']; throw new $exceptionClass($message['text'], $message['code']); } //Cleanup the returned arrays $finalItems = []; foreach ($item as $i) { $finalItems[] = $i[$model->name]; } $item = $finalItems; $success = true; $viewVar = $this->viewVar(); $subject = $this->_trigger('afterFind', compact('id', 'viewVar', 'success', 'item')); $this->_controller()->set(array('success' => $subject->success, $subject->viewVar => $subject->item)); $this->_trigger('beforeRender', $subject); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $user = $this->userService->getCurrentUser(); $stocks = $this->stockRepo->getStockList($user->id); $templates = $this->templateRepo->getAll(); return \View::make('stocks.index', compact('stocks', 'templates')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $suppliers = Supplier::orderBy('name')->get(); $employees = Employee::orderBy('firstname')->get(); $customers = Customer::orderBy('name')->get(); return view('inventory.home', compact(['suppliers', 'employees', 'customers'])); }
public function formatTokens($content) { $upperCaseModelName = ucfirst($this->modelName); $field_name = snake_case($this->modelName) . '_name'; $modelId = $this->formatInstanceVariable() . '->id'; $modelAttribute = $this->formatInstanceVariable() . '->' . $field_name; $createdAt = $this->formatInstanceVariable() . '->created_at'; $modelRoute = '/' . $this->folderName; $dtTableName = snake_case($this->modelName) . '_table'; $masterPage = $this->masterPage; $modelName = $this->modelName; $modelsUpperCase = ucwords(str_plural($this->modelName)); $folderName = $this->folderName; $gridName = $this->formatVueGridName() . '-grid'; $endGridName = '/' . $this->formatVueGridName() . '-grid'; $vueApiRoute = 'api/' . $this->folderName . '-vue'; $parent = $this->parent; $parentInstance = $this->formatParentInstanceVariable($this->parent); $parentInstances = $this->formatParents($this->parent); $parent_id = strtolower(snake_case($this->parent)) . '_id'; $parentFieldName = strtolower(snake_case($this->parent)) . '_name'; $child = $this->child; $slug = $this->slug; //create token array using compact $tokens = compact('upperCaseModelName', 'field_name', 'modelId', 'modelAttribute', 'createdAt', 'modelRoute', 'dtTableName', 'masterPage', 'modelName', 'modelsUpperCase', 'folderName', 'gridName', 'endGridName', 'vueApiRoute', 'parent', 'parentInstance', 'parentInstances', 'parent_id', 'parentFieldName', 'child', 'slug'); $content = $this->insertTokensInContent($content, $tokens); return $content; }
public function sliderExhibitAttachment($attachment) { $item = $attachment->getItem(); $file = $attachment->getFile(); if ($file) { if (!isset($fileOptions['imgAttributes']['alt'])) { $fileOptions['imgAttributes']['alt'] = metadata($item, array('Dublin Core', 'Title'), array('no_escape' => true)); } if ($forceImage) { $imageSize = isset($fileOptions['imageSize']) ? $fileOptions['imageSize'] : 'square_thumbnail'; $image = file_image($imageSize, $fileOptions['imgAttributes'], $file); $html = exhibit_builder_link_to_exhibit_item($image, $linkProps, $item); } else { if (!isset($fileOptions['linkAttributes']['href'])) { $fileOptions['linkAttributes']['href'] = exhibit_builder_exhibit_item_uri($item); } $html = file_markup($file, $fileOptions, null); } } else { if ($item) { $html = exhibit_builder_link_to_exhibit_item(null, $linkProps, $item); } } // Don't show a caption if we couldn't show the Item or File at all if (isset($html)) { if (!is_string($attachment['caption']) || $attachment['caption'] == '') { return ''; } $html .= '<div class="exhibit-item-caption">' . $attachment['caption'] . '</div>'; return apply_filters('exhibit_attachment_caption', $html, array('attachment' => $attachment)); } else { $html = ''; } return apply_filters('exhibit_attachment_markup', $html, compact('attachment', 'fileOptions', 'linkProps', 'forceImage')); }
public function update(Request $request, $id) { $assignment = App\Assignment::findOrFail($id); $assignment->completed_at = Carbon::now(); $assignment->save(); return view('assignments.show', compact('assignment')); }
/** * {@inheritdoc} */ protected function fire() { $caches = '*'; $tool = craft()->components->getComponentByTypeAndClass(ComponentType::Tool, 'ClearCaches'); if ($this->option('select')) { $reflectionMethod = new ReflectionMethod($tool, '_getFolders'); $reflectionMethod->setAccessible(true); $values = $reflectionMethod->invoke($tool); $values['assetTransformIndex'] = Craft::t('Asset transform index'); $values['assetIndexingData'] = Craft::t('Asset indexing data'); $values['templateCaches'] = Craft::t('Template caches'); $keys = array_keys($values); $options = array_values($values); $dialog = $this->getHelper('dialog'); $selected = $dialog->select($this->output, 'Select which caches to clear (separate multiple by comma)', $options, null, false, 'Value "%s" is invalid', true); $caches = array(); foreach ($selected as $index) { $caches[] = $keys[$index]; } } $this->suppressOutput(function () use($tool, $caches) { $tool->performAction(compact('caches')); }); $this->info('Cache(s) cleared.'); }
public function create() { $academicdegrees = Academicdegree::all(); $localizationController = new LocalizationController(); $localizations_depts = $localizationController->getDepartments(); return View::make('registro', compact('academicdegrees', 'localizations_depts')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $Beatles = ['John', 'Paul', 'George', 'Ringo']; //alert()->overlay('Listen', 'I hear Beatle music!', 'success'); //alert()->error('Problem', 'Cannot hear'); return view('test.index', compact('Beatles')); }
/** * Submit Idea * * @param int $idea_id * @param int $user_id * @param array $fields * @return Submission */ public function submit($idea_id, $user_id, array $fields) { /** Todo: Find a way to not massassign the user ID */ /** @var MorphMany $submission */ $submission = $this->model($idea_id)->submissions(); return $submission->create(array_merge($fields, compact('user_id'))); }
/** * Retrieve an item and expiry time from the cache by key. * * @param string $key * @return array */ protected function getPayload($key) { $path = $this->path($key); // If the file doesn't exists, we obviously can't return the cache so we will // just return null. Otherwise, we'll get the contents of the file and get // the expiration UNIX timestamps from the start of the file's contents. try { $expire = substr($contents = $this->files->get($path), 0, 10); } catch (Exception $e) { return ['data' => null, 'time' => null]; } // If the current time is greater than expiration timestamps we will delete // the file and return null. This helps clean up the old files and keeps // this directory much cleaner for us as old files aren't hanging out. if (time() >= $expire) { $this->forget($key); return ['data' => null, 'time' => null]; } $data = unserialize(substr($contents, 10)); // Next, we'll extract the number of minutes that are remaining for a cache // so that we can properly retain the time for things like the increment // operation that may be performed on the cache. We'll round this out. $time = ceil(($expire - time()) / 60); return compact('data', 'time'); }
protected function prepare() { include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; try { $this->api = $api = Sputnik::get_plugin($this->id); } catch (Exception $e) { status_header(500); $this->header(); echo '<p>' . $e->getMessage() . '</p>'; $this->footer(); return; } if (!Sputnik::is_purchased($this->api->slug)) { wp_redirect(Sputnik_Admin::build_url(array('buy' => $this->id))); die; } if (!current_user_can('install_plugins')) { wp_die(__('You do not have sufficient permissions to install plugins for this site.', 'sputnik')); } check_admin_referer($this->nonce_prefix . $this->api->slug); include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; $title = sprintf($this->title_format, $this->api->name . ' ' . $this->api->version); $nonce = $this->nonce_prefix . $this->id; $url = 'update.php?action=install-plugin&plugin=' . $this->id; if (isset($_GET['from'])) { $url .= '&from=' . urlencode(stripslashes($_GET['from'])); } $type = 'web'; //Install plugin type, From Web or an Upload. if ($this->api->is_theme) { $this->upgrader = new Sputnik_ThemeUpgrader(new Sputnik_View_Install_Skin(compact('title', 'url', 'nonce', 'plugin', 'api'))); } else { $this->upgrader = new Sputnik_Upgrader(new Sputnik_View_Install_Skin(compact('title', 'url', 'nonce', 'plugin', 'api'))); } }
public function actionCategoryIndex($slug) { $blogCategory = $this->findBlogCategory($slug); $query = BlogPost::find()->joinWith('translations')->joinWith('blogCategory.translations')->where(['is_published' => true])->andWhere(['<>', 'blog_post_lang.slug', ''])->andWhere(['blog_post_lang.language' => Yii::$app->language])->andWhere(['blog_category_lang.slug' => $blogCategory->slug])->orderBy(['created_at' => SORT_DESC]); $blogPostProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['forcePageParam' => false, 'defaultPageSize' => 10]]); return $this->render('category-index', compact('blogPostProvider', 'blogCategory')); }
/** * Get all the necessary details to directly upload a private file to S3 * asynchronously with JavaScript. * * @param string $s3Bucket your bucket's name on s3. * @param string $region the bucket's location, see here for details: http://amzn.to/1FtPG6r * @param string $acl the visibility/permissions of your file, see details: http://amzn.to/18s9Gv7 * * @return array ['url', 'inputs'] the forms url to s3 and any inputs the form will need. */ function getS3Details($s3Bucket, $region, $acl = 'private') { // Options and Settings $algorithm = "AWS4-HMAC-SHA256"; $service = "s3"; $date = gmdate('Ymd\\THis\\Z'); $shortDate = gmdate('Ymd'); $requestType = "aws4_request"; $expires = '86400'; // 24 Hours $successStatus = '201'; $url = '//' . $s3Bucket . '.' . $service . '-' . $region . '.amazonaws.com'; // Step 1: Generate the Scope $scope = [AWS_ACCESS_KEY, $shortDate, $region, $service, $requestType]; $credentials = implode('/', $scope); // Step 2: Making a Base64 Policy $policy = ['expiration' => gmdate('Y-m-d\\TG:i:s\\Z', strtotime('+6 hours')), 'conditions' => [['bucket' => $s3Bucket], ['acl' => $acl], ['starts-with', '$key', ''], ['starts-with', '$Content-Type', ''], ['success_action_status' => $successStatus], ['x-amz-credential' => $credentials], ['x-amz-algorithm' => $algorithm], ['x-amz-date' => $date], ['x-amz-expires' => $expires]]]; $base64Policy = base64_encode(json_encode($policy)); // Step 3: Signing your Request (Making a Signature) $dateKey = hash_hmac('sha256', $shortDate, 'AWS4' . AWS_SECRET, true); $dateRegionKey = hash_hmac('sha256', $region, $dateKey, true); $dateRegionServiceKey = hash_hmac('sha256', $service, $dateRegionKey, true); $signingKey = hash_hmac('sha256', $requestType, $dateRegionServiceKey, true); $signature = hash_hmac('sha256', $base64Policy, $signingKey); // Step 4: Build form inputs // This is the data that will get sent with the form to S3 $inputs = ['Content-Type' => '', 'acl' => $acl, 'success_action_status' => $successStatus, 'policy' => $base64Policy, 'X-amz-credential' => $credentials, 'X-amz-algorithm' => $algorithm, 'X-amz-date' => $date, 'X-amz-expires' => $expires, 'X-amz-signature' => $signature]; return compact('url', 'inputs'); }
public function about() { $people = ['Taylor Otwell', 'Dayle Rees', 'Erci Barnes', 'Jeffrey Way']; $first = 'Frank'; $last = 'Pigeon Jr.'; return view('pages.about', compact('first', 'last', 'people')); }