function __construct() { if (false == self::$enabled) { return redirect(URL::to('/'), 302)->send(); } Commons::init(); }
/** * Create a new instance. * * @return void */ public function __construct() { //Set API base url if empty if (empty($this->apiBaseUrl)) { $this->apiBaseUrl = URL::to('/'); } //Set API url if empty if (empty($this->apiUrl)) { $this->apiUrl = $this->apiBaseUrl . '/api/' . $this->apiVersion; } //Get the webste OAuth Client credentials $oauthClient = OauthClient::where('name', '=', 'website')->first(); if (is_object($oauthClient)) { $this->clientId = $oauthClient->id; $this->clientSecret = $oauthClient->secret; } unset($oauthClient); Blade::extend(function ($view) { return preg_replace(array('#@translate\\(\\s*\\"([^"]+)\\"\\s*\\)#', "#@translate\\(\\s*\\'([^']+)\\'\\s*\\)#"), array('Translate::t("$1")', 'Translate::t(\'$1\')'), $view); }); Blade::extend(function ($view) { return preg_replace(array('#@option\\(\\s*\\"([^"]+)\\"\\s*\\)#', "#@option\\(\\s*\\'([^']+)\\'\\s*\\)#"), array('Option::getAttribute(\'$1\')', 'Option::getAttribute(\'$1\')'), $view); }); Blade::extend(function ($view) { return preg_replace(array('#@hasPermission\\(\\s*\\"([^"]+)\\"\\s*\\)#', "#@hasPermission\\(\\s*\\'([^']+)\\'\\s*\\)#"), array('Access::has(\'$1\')', 'Access::has(\'$1\')'), $view); }); $this->getAccessToken(); View::share('basePath', Request::getBaseURL()); }
public function build() { $output = ""; $this->attributes["class"] = "form-control"; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if ($this->type == 'hidden' || $this->value == "") { $output = ""; } elseif (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = nl2br(htmlspecialchars($this->value)); } $output = "<div class='help-block'>" . $output . "</div>"; break; case "create": case "modify": Rapyd::js('packages/zofe/rapyd/assets/tinymce/tinymce.min.js'); $output = Form::textarea($this->db_name, $this->value, $this->attributes); $output .= Rapyd::script("\n tinymce.init({\n selector: 'textarea#" . $this->name . "',\n plugins: [\n 'advlist autolink link image lists charmap print preview hr anchor pagebreak',\n 'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',\n 'save table contextmenu directionality emoticons template paste textcolor responsivefilemanager'\n ],\n toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | responsivefilemanager | print preview media fullpage | forecolor backcolor emoticons', \n image_advtab: true ,\n external_filemanager_path:'" . URL::to('/') . "/packages/filemanager/',\n filemanager_title:'Upload',\n });"); break; case "hidden": $output = Form::hidden($this->db_name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
public function formatModel($model) { $script_url = str_replace(['http://', 'https://'], ['', ''], URL::to('/')) . '/zl.js'; $model->form_code = '<form class="zlform" action="' . URL::action('\\Zephia\\ZLeader\\Http\\Controllers\\Api\\LeadController@store', ['slug' => $model->slug]) . '" method="post">' . "\r\n<!-- Fields: (zlfield_example) -->\r\n" . '</form>' . "\r\n"; $model->form_code .= "<script type=\"text/javascript\">" . "\r\n" . "(function(d,s,e,t){e=d.createElement(s);e.type='text/java'+s;e.async='async';" . "\r\n" . "e.src='http'+('https:'===location.protocol?'s://':'://')+'" . $script_url . "';t=d.getElementsByTagName(s)[0];" . "\r\n" . "t.parentNode.insertBefore(e,t);})(document,'script');" . "\r\n" . "</script>"; return $model; }
public function postImageUpload(Request $request) { // $j = 0; // $target_path = "uploads/"; // for ($i = 0; $i < count($_FILES['file']['name']); $i++) { // $ext = explode('.', basename($_FILES['file']['name'][$i])); // $file_extension = end($ext); // $target_path = $target_path . md5(uniqid()) . "." . $ext[count($ext) - 1]; // $j = $j + 1; // move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path); // } $images = new Picture(); if ($request->hasFile('images')) { $listImage = array(); $files = $request->file('images'); foreach ($files as $file) { $name = $file->getClientOriginalName(); $extension = $file->getClientOriginalExtension(); $picture = time() . $name . '.' . $extension; $file->move('images/product', $picture); $src = 'images/product/' . $picture; $product_id = 1; $data = array('productID' => $product_id, 'imageName' => $name, 'imageSrc' => $src); autoAssignDataToProperty($images, $data); $listImage[] = $data; } $images->insert($listImage); return redirect(URL::to('/demo/image_upload'))->withSuccess('Image Upload'); } else { } }
public function product($id) { // Product Detail $product = Product::find($id); $producer = Producer::find($product->producer); $producerItem = "<a href='" . URL::to('/') . "/producer/" . $producer->id . "/" . strtolower($producer->producer) . ".html'>" . $producer->producer . "</a>"; // Category $productCategoryID = Product::find($id)->category_id; // breadcrumb $breadcrumb = $this->breadcrumb($productCategoryID, $id); // Best Seller $bestSeller = $this->bestSeller(); $image = Images::where('productID', $product['id'])->first(); $thumbnail = $image['imageSrc']; $thumbnailImage = '<a class="preView" rel="' . URL::to('/') . '/' . $thumbnail . '"><img src="' . URL::to('/') . '/' . $thumbnail . '" alt="" class="img-responsive"></a>'; $images = Images::where('productID', $id)->get(); $listImages = ""; foreach ($images as $image) { $img = $image['imageSrc']; $listImages .= '<a href="' . URL::to('/') . '/' . $img . '" class="fancybox-button" rel="photos-lib"><img alt="Berry Lace Dress" src="' . URL::to('/') . '/' . $img . '"></a>'; } $review = '<div class="fb-comments" data-href="' . URL::to('/') . '/product/' . $id . '" data-num-posts="10" data-width="700px"></div>'; return view('home.product.detail')->with(['breadcrumb' => $breadcrumb, 'product' => $product, 'producer' => $producerItem, 'bestSeller' => $bestSeller, 'thumbnailImage' => $thumbnailImage, 'listImages' => $listImages, 'review' => $review]); }
public function testGetSourceSetAttribute() { $srcset = $this->createSourceSet(); $base = URL::to('/'); $expected = "{$base}/path.jpg 200w, {$base}/path2.jpg 300w"; $this->assertEquals($expected, $srcset->getSrcSetAttribute()); }
public function latest() { if ($this->isLoggedIn && $this->request->has('personal') && $this->request->get('personal') == 'true') { $isCached = false; $bans = $this->repository->getPersonalBans($this->user->settings()->playerIds()); } else { $isCached = Cache::has('bans.latest'); $bans = $this->repository->getLatestBans(); } if ($this->request->has('type') && $this->request->get('type') == 'rss') { $feed = Feed::make(); $feed->title = sprintf('Latest Battlefield Bans by %s', Config::get('bfacp.site.title')); $feed->description = sprintf('Latest Battlefield Bans by %s', Config::get('bfacp.site.title')); $feed->setDateFormat('datetime'); $feed->link = URL::to('api/bans/latest?type=rss'); $feed->lang = 'en'; foreach ($bans as $ban) { $title = sprintf('%s banned for %s', $ban['player']['SoldierName'], $ban['record']['record_message']); $view = View::make('system.rss.ban_entry_content', ['playerId' => $ban['player']['PlayerID'], 'playerName' => $ban['player']['SoldierName'], 'banreason' => $ban['record']['record_message'], 'sourceName' => $ban['record']['source_name'], 'sourceId' => $ban['record']['source_id'], 'banReason' => $ban['record']['record_message']]); $feed->add($title, $ban['record']['source_name'], $ban['player']['profile_url'], $ban['ban_startTime'], $title, $view->render()); } return $feed->render('atom'); } return MainHelper::response(['cols' => Lang::get('dashboard.bans.columns'), 'bans' => $bans], null, null, null, $isCached, true); }
public function __toString() { $location = $this->getLocation(); $location = substr($location, 0) === '/' ? $location : '/' . $location; $url = URLFacade::to($location); return $location === '/' ? $url . '/' : $url; }
/** * Add a root if the URL is relative (helper method of the hasLink function). * * @return string */ protected function absoluteUrl() { if (!Str::startsWith($this->url, ['http', 'https'])) { return URL::to($this->url); } return $this->url; }
public function __construct() { $this->base_url = URL::to('/'); $this->upload_path = public_path() . '/uploads/'; $this->upload_url = $this->base_url . '/uploads/'; $this->script_url = $this->base_url . '/upload/'; $this->options = array('file_name' => uniqid()); }
public function destroy($id) { $Src = Images::find($id)->imageSrc; $imageSrc = URL::to('/') . '/' . $Src; File::delete($imageSrc); Images::find($id)->delete(); return redirect(URL::previous())->withSuccess(Lang::get('messages.delete_success')); }
private function redirectToPage($page, $request) { $pageSlug = $page->slug; $url = URL::to('/') . '/' . $pageSlug; //reflash any flash messages $request->session()->reflash(); return Redirect::to($url, 301); }
public function outputMenuItems() { $list = $this->menuCategory->orderby('order', 'asc')->get(); $menuItems = array(); foreach ($list as $item) { array_push($menuItems, ['link' => URL::to('menu/' . $item->url), 'name' => $item->name]); } return $menuItems; }
public function link($url = null, $name = null, $class = null) { $url = URL::to($url, [], null); // si no tenemos el $name pero tenemos $url if (isset($url) && is_null($name)) { $name = $url; } return view('HtmlGenerator.link', compact('name', 'url', 'class')); }
public function run() { DB::table('media')->delete(); DB::query(null, 'ALTER TABLE media AUTO_INCREMENT=0'); $data = [['name' => URL::to('/') . '/images/users/default-user.png'], ['name' => 'default-image.png'], ['name' => URL::to('/') . '/images/wishes/iphone.jpg']]; $query = "INSERT INTO media(name) VALUES(:name)"; foreach ($data as $key => $value) { DB::insert($query, ['name' => $value['name']]); } }
public function search(Request $request) { $keyword = $request->search; $breadcrumb = "<li>Home</li><li class='active'>Search</li>"; $products = DB::table('product')->where('name', 'LIKE', '%' . $keyword . '%')->paginate(8); $allProductInView = $this->allProducts('search', "", $keyword); $products->setPath(URL::to('/search/' . $keyword . '')); $pagination = $products->render(); return view('home.index.search')->with(['breadcrumb' => $breadcrumb, 'keyword' => $keyword, 'allProductInView' => $allProductInView, 'pagination' => $pagination]); }
public function pdf() { $data = (array) Input::get('data'); $pdf = new CreateOfertaPdf('L', 'A4', 'F', $data, true); $pdf->Output(); /* * getName(true) -> sa-mi dea calea * */ $this->insertUploadDoc($pdf); return URL::to("app/oferte/" . $pdf->getName(false)); }
public function testUrl() { // origin url: ex http://localhost $origin = URL::to('/'); // origin replaced url: ex //localhost $origin_replaced = str_replace('http:', null, $origin); // dist url: ex //localhost $dist = SURL::to('/'); // check if origin and dist are equal $this->assertEquals($origin_replaced, $dist); }
public function fractal() { if ($this->fractal === null) { $this->fractal = new Manager(); $this->fractal->setSerializer(new JsonApiSerializer(URL::to('/'))); } // parse includes if set if (isset($_GET['include'])) { $this->fractal->parseIncludes($_GET['include']); } return $this->fractal; }
public function getImageUrl() { if (preg_match('/< *img[^>]*src\\s*=\\s*["\']?([^"\']*)/i', $this->content, $matches)) { $url = $matches[1]; if (starts_with($url, '/') && !starts_with($url, '//')) { $url = URL::to($url); } } else { $url = URL::to('/images/logo.png'); } return $url; }
public function onInsertButtonFetch($def) { $url = URL::to(Config::get('builder::admin.uri') . '/tb/users/create'); $caption = isset($def['caption']) ? $def['caption'] : 'Add'; $html = '<a href="' . $url . '"> <button class="btn btn-default btn-sm btn-success" style="min-width: 66px;" type="button"> ' . __cms($caption) . ' </button> </a>'; return $html; }
/** * Render the current item * @param array $item part of the breadcrumb * @param boolean $active current breadcrumb is active * @return string */ public static function renderItem($item, $active) { $class = ""; if ($active === true) { $class = "current"; } $html = '<a href="' . URL::to($item["link"]) . '" class="tip-bottom ' . $class . '">'; if ($item["icon"] !== '') { $html .= '<i class="glyphicon ' . $item["icon"] . '"></i>'; } $html .= $item["title"] . '</a>'; return $html; }
/** * @param $path * @param array $data * @return string */ protected function evaluatePath($path, array $data = []) { $preferences = $this->XSLTSimple->addChild('Preferences'); $url = $preferences->addChild('url'); $url->addAttribute('isHttps', Request::secure()); $url->addAttribute('currentUrl', Request::url()); $url->addAttribute('baseUrl', URL::to('')); $url->addAttribute('previousUrl', URL::previous()); $server = $preferences->addChild('server'); $server->addAttribute('curretnYear', date('Y')); $server->addAttribute('curretnMonth', date('m')); $server->addAttribute('curretnDay', date('d')); $server->addAttribute('currentDateTime', date('Y-m-d H:i:s')); $language = $preferences->addChild('language'); $language->addAttribute('current', App::getLocale()); $default_language = \Config::get('app.default_language'); if (isset($default_language)) { $language->addAttribute('default', $default_language); } $languages = \Config::get('app.available_languages'); if (is_array($languages)) { foreach ($languages as $lang) { $language->addChild('item', $lang); } } // from form generator if (isset($data['form'])) { $this->XSLTSimple->addChild('Form', form($data['form'])); } // adding form errors to xml if (isset($data['errors'])) { $this->XSLTSimple->addData($data['errors']->all(), 'FormErrors', false); } // "barryvdh/laravel-debugbar": // adding XML tab if (true === class_exists('Debugbar')) { $dom = dom_import_simplexml($this->XSLTSimple)->ownerDocument; $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $prettyXml = $dom->saveXML(); // add new tab and append xml to it if (false === \Debugbar::hasCollector('XML')) { \Debugbar::addCollector(new \DebugBar\DataCollector\MessagesCollector('XML')); } \Debugbar::getCollector('XML')->addMessage($prettyXml, 'info', false); } $xsl_processor = new \XsltProcessor(); $xsl_processor->registerPHPFunctions(); $xsl_processor->importStylesheet(simplexml_load_file($path)); return $xsl_processor->transformToXML($this->XSLTSimple); }
public function getUrl() { if ($this->getRequiredOption('type') == 'share') { return $this->getSimpleShareUrl(); } $url = 'https://www.facebook.com/dialog/share?' . 'app_id=' . $this->getRequiredOption('app_id') . '&' . 'display=' . $this->getOption('display', 'popup') . '&' . 'href=' . urlencode($this->getOption('href', Request::url())) . '&' . 'redirect_uri=' . urlencode($this->getOption('redirect_uri', URL::to('_soc-share/close/window'))); $from = $this->getOption('from'); if ($from) { $url .= '&from=' . $from; } $to = $this->getOption('to'); if ($to) { $url .= '&to=' . $to; } $picture = $this->getOption('picture'); if ($picture) { $url .= '&picture=' . urlencode($picture); $source = $this->getOption('source'); if ($source) { $url .= '&source=' . urlencode($source); } } $name = $this->getOption('name'); if ($name) { $url .= '&name=' . urlencode($name); } $caption = $this->getOption('caption'); if ($caption) { $url .= '&caption=' . urlencode($caption); } $description = $this->getOption('description'); if ($description) { $url .= '&description=' . urlencode($description); } $properties = $this->getOption('properties'); if ($properties) { $url .= '&properties=' . json_encode($properties); } $actions = $this->getOption('actions'); if ($actions) { $url .= '&actions=' . json_encode($actions); } $ref = $this->getOption('ref'); if ($ref) { // FIXME: validate ref $url .= '&ref=' . urlencode(implode(',', $ref)); } return $url; }
public function getSitemap() { $sitemap = App::make("sitemap"); $sitemap->setCache('sitemap', 3600); if (!$sitemap->isCached()) { $sitemap->add(URL::to('p/about'), time(), '0.9', 'monthly'); $sitemap->add(URL::to('artisans'), time(), '1.0', 'monthly'); $sitemap->add(URL::to('sponsor'), time(), '0.9', 'monthly'); $users = User::all(); foreach ($users as $user) { $sitemap->add($user->username, $user->created_at, '0.9', 'monthly', $user->avatar); } } return $sitemap->render('xml'); }
/** * Handles user registration * * @param RegisterRequest $request * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @throws \Exception */ public function postRegister(RegisterRequest $request) { $user = new User(['username' => $request->input('username'), 'password' => Hash::make($request->input('password')), 'email' => $request->input('email'), 'deleted_at' => date('Y-m-d H:i:s'), 'confirm_token' => Hash::make(time() . env('APP_KEY'))]); $user->save(); $data = ['user_email' => $request->input('email'), 'username' => $request->input('username'), 'user_subject' => trans('users.successful_registration'), 'admin_subject' => trans('users.new_user_registered'), 'user_mail_data' => ['username' => $request->input('username'), 'link' => URL::to('users/confirm') . '?token=' . $user->confirm_token], 'admin_mail_data' => ['username' => $request->input('username'), 'email' => $request->input('email'), 'created_at' => $user->created_at]]; $mail_send = $this->sendMail($data, 'emails.register', 'emails.new_user'); if ($mail_send) { flash()->success(trans('users.register_success')); return redirect('/'); } else { $user->delete(); flash()->error(trans('users.registration_failed')); return redirect()->back()->withInput($request->input()); } }
/** * Add URLs to dynamic pages of the site. * * @return void */ public function addDynamicRoutes() { $tricks = $this->tricks->findAllForSitemap(); foreach ($tricks as $trick) { $this->sitemap->add(URL::to("tricks/{$trick->slug}"), $trick->created_at, '0.9', 'weekly'); } $categories = $this->categories->findAll(); foreach ($categories as $category) { $this->sitemap->add(URL::to("categories/{$category->slug}"), $category->created_at, '0.9', 'daily'); } $tags = $this->tags->findAll(); foreach ($tags as $tag) { $this->sitemap->add(URL::to("tags/{$tag->slug}"), $tag->created_at, '0.9', 'daily'); } return $this->sitemap; }
public function postUrl(Request $request) { if ($request->ajax()) { $url = $request->input('user_url'); if ($this->checkUserUrlRepetition($url)) { $key = DB::table('keys')->where('keys.url', '=', $url)->value('key'); return response()->json(['flag' => self::ALREADY_EXIST]); } else { $key = $this->getUniqueRandomKey(); $data = new Key(); $_id = $data->insertGetId(['url' => $url, 'user_id' => $request->input('user_id'), 'ip' => $request->getClientIp(), 'title' => 'No Title', 'key' => $key, 'created_at' => Carbon::now()]); } $full_url = URL::to('/') . '/' . $key; } return response()->json(['_id' => $_id, 'sorted_url' => $full_url, 'title' => 'Retriving...', 'original_url' => $url, 'flag' => self::NEW_VALUE]); }
public function getListValue($row) { if ($this->hasCustomHandlerMethod('onGetListValue')) { $res = $this->handler->onGetListValue($this, $row); if ($res) { return $res; } } if (!$this->getValue($row)) { return ''; } // FIXME: move to template $src = URL::to($this->getValue($row)); $html = '<a href="' . $src . '" target="_blank">' . $src . '</a>'; return $html; }