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


PHP Url::save方法代码示例

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


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

示例1: postShorten

 public function postShorten()
 {
     //get url input
     $url = Input::get('url');
     //validate url
     $val = Url::validate(array('url' => $url));
     //if error, return with error message
     if ($val !== true) {
         return Redirect::to('/')->withErrors($val);
     }
     //check whether url is shortened or not
     $record = Url::whereUrl($url)->first();
     if ($record) {
         $url = url('/' . $record->given, $parameters = array(), $secure = null);
         return View::make('shorturl.result')->with('url', $url);
     }
     //create new short url
     $data = new Url();
     $data->url = $url;
     $data->given = Url::getShortenedUrl();
     //if successfully saved to db
     if ($data->save()) {
         $row = Url::whereUrl($url)->first();
         $url = url('/' . $row->given, $parameters = array(), $secure = null);
         return View::make('shorturl.result')->with('url', $url);
     }
 }
开发者ID:hming,项目名称:laravel-shorturl,代码行数:27,代码来源:ShortenController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $url = new Url();
     $url->url = Request::get('url');
     $url->description = Request::get('description');
     $url->user_id = Auth::user()->id;
     $url->save();
     return Response::json(array('error' => false, 'urls' => $urls->toArray()), 200);
 }
开发者ID:Alucarth,项目名称:cascada_ventas,代码行数:14,代码来源:UrlController.php

示例3: testAgregar

 public function testAgregar()
 {
     $url = new Url();
     $url->setAttributes(array('slug' => 'programas/cualquier-otra-prueba', 'tipo_id' => 2), false);
     $this->assertTrue($url->save(false));
     $v = $url->findByPk($url->id);
     $this->assertTrue($v instanceof Url);
     $this->assertEquals(date('Y-m-d H:i:s'), $v->creado);
     $this->assertTrue($url->delete());
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:10,代码来源:UrlTest.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $url = new Url();
     $url->url = Request::get('url');
     $url->description = Request::get('description');
     $url->user_id = Auth::user()->id;
     // Validation and Filtering is sorely needed!!
     // Seriously, I'm a bad person for leaving that out.
     $url->save();
     return Response::json(array('url' => $url->url, 'description' => $url->description), 200);
 }
开发者ID:anita-brooks,项目名称:restfulapi-read-it-later,代码行数:16,代码来源:UrlsController.php

示例5: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Url();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Url'])) {
         $model->attributes = $_POST['Url'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:daobv,项目名称:mobile-detect,代码行数:17,代码来源:UrlController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $url = new Url();
     $url->url = Request::get('url');
     $url->description = Request::get('description');
     $url->user_id = Auth::user()->id;
     // Validation and Filtering is sorely needed!!
     // Seriously, I'm a bad person for leaving that out.
     $url->save();
     return Response::json(array('error' => false, 'urls' => $url->toArray()), 200, array(), JSON_PRETTY_PRINT);
     // curl -i --user firstuser:first_password -d "url=http://google.com&description=A Search Engine"
     // curl -i --user firstuser:first_password -d "url=http://google.com&description=A Search Engine" localhost/learn/laravel-api/public/api/v1/url
     // curl -i --user firstuser:first_password -d "url=http://fideloper.com&description=A Great Blog" localhost/learn/laravel-api/public/api/v1/url
     // curl -i --user seconduser:second_password -d "url=http://digitalsurgeons.com&description=A Marketing Agency" localhost/learn/laravel-api/public/api/v1/url
     // curl -i --user seconduser:second_password -d "url=http://www.poppstrong.com/&description=I feel for him" localhost/learn/laravel-api/public/api/v1/url
 }
开发者ID:ilman,项目名称:learn-laravel-api,代码行数:21,代码来源:UrlController.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $url = new Url();
     $url->url = Request::get('url');
     $url->description = Request::get('description');
     $url->user_id = Auth::user()->id;
     $inputURL['url'] = $url->url;
     $inputDES['description'] = $url->description;
     //Check for the validation
     //$rules = array('url'=>'active_url');  //url must be active and within your domai
     $validator = Validator::make($inputDES, array('description' => 'alpha'));
     if ($validator->passes()) {
         $url->save();
         return Response::json(array('error' => false, 'urls' => $url->toarray()));
     } else {
         return Response::json(array('error' => true, 'message' => 'INVALID description TYPE'));
     }
 }
开发者ID:shresthaankit7,项目名称:Read-It-Later,代码行数:23,代码来源:UrlController.php

示例8: actionAjaxUpload

 /**
  * Method to handle file upload thought XHR2
  * On success returns JSON object with image info.
  * @param $album_foto_id string Gallery Id to upload images
  * @throws CHttpException
  */
 public function actionAjaxUpload($album_foto_id = null)
 {
     $album_foto = AlbumFoto::model()->findByPk($album_foto_id);
     $imageFile = CUploadedFile::getInstanceByName('image');
     $time = time() + rand();
     $base = Yii::getPathOfAlias('webroot') . '/' . $this->galleryDir . '/' . $album_foto->directorio;
     $src = $time . '.' . $this->galleryExt;
     $thumb = $time . '_thumb.' . $this->galleryExt;
     $image = new Image($imageFile->getTempName());
     $image->save($base . $src);
     $image_thumb = new Image($imageFile->getTempName());
     $image_thumb->resize(300, null);
     $image_thumb->save($base . $thumb);
     //Yii::app()->image->load($imageFile->getTempName())->save($src);
     //Yii::app()->image->load($imageFile->getTempName())->resize(300, null)->save($thumb);
     $model = new Foto();
     $model->album_foto_id = $album_foto_id;
     $url = new Url();
     $slug = '#imagenes/' . $this->slugger($album_foto->nombre) . '/' . $this->slugger($time);
     $slug = $this->verificarSlug($slug);
     $url->slug = $slug;
     $url->tipo_id = 6;
     //Foto
     $url->estado = 1;
     $url->save();
     $model->url_id = $url->getPrimaryKey();
     $model->src = $src;
     $model->thumb = $thumb;
     $model->nombre = $time;
     $model->descripcion = '';
     $model->ancho = $image->width;
     $model->alto = $image->height;
     $model->orden = 0;
     $model->estado = 1;
     $model->destacado = 0;
     $model->save();
     header("Content-Type: application/json");
     echo CJSON::encode(array('id' => $model->id, 'rank' => $model->orden, 'name' => (string) $model->nombre, 'description' => (string) $model->descripcion, 'preview' => bu($this->galleryDir . '/' . $album_foto->directorio . $thumb)));
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:45,代码来源:GalleryController.php

示例9: postIndex

 public function postIndex()
 {
     // Sanitize URL
     $url = filter_var($_POST['url'], FILTER_SANITIZE_URL);
     // Check if the original url is online
     if ($this->checkUrl($url) == false) {
         return json_encode(array('result' => 'error', 'message' => 'Please insert a valid URL'));
     }
     // Check if the original URL already exists in the database
     $exists = Url::whereOriginal(urlencode($url))->first();
     if (!is_null($exists)) {
         $id = $exists['id'];
     } else {
         $id = $this->genUniqueCode();
         // save it into the database
         $save = new Url();
         $save->id = $id;
         $save->original = urlencode($url);
         $save->save();
     }
     $result = array('result' => 'success', 'url' => 'http://' . getenv('HTTP_HOST') . '/' . $id);
     return json_encode($result);
 }
开发者ID:ukadev,项目名称:uka-url,代码行数:23,代码来源:HomeController.php

示例10: createAction

 /**
  * Creates a product based on the data entered in the "new" action
  */
 public function createAction()
 {
     if (!parent::isValidRequest(new UrlValidation())) {
         return parent::redirect('url/new');
     }
     try {
         $address = trim($this->request->get('address'));
         $existingUrl = Url::findFirst(array('conditions' => 'address = ?0', 'bind' => array($address)));
         if ($existingUrl) {
             $this->flash->notice('Url address allready exists.');
             return parent::redirect('url/new');
         } else {
             $url = new Url();
             $url->address = $address;
             $url->save();
             $this->flash->success('Url created succesfully.');
         }
     } catch (Exception $ex) {
         $this->flash->error('An error occured when trying to create the new url.');
     }
     return parent::redirect('url');
     #$this->view->disable();
 }
开发者ID:sweetdevel,项目名称:pingaroo,代码行数:26,代码来源:UrlController.php

示例11: beforeSave

 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if ($this->isNewRecord) {
             $url = new Url();
             $slug = '#imagenes/' . $this->slugger($this->nombre);
             $slug = $this->verificarSlug($slug);
             $url->slug = $slug;
             $url->tipo_id = 5;
             //Álbum de fotos
             $url->estado = 1;
             $url->save();
             $this->url_id = $url->getPrimaryKey();
             $this->creado = date('Y-m-d H:i:s');
         } else {
             $this->modificado = date('Y-m-d H:i:s');
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:22,代码来源:AlbumFoto.php

示例12: beforeSave

 protected function beforeSave()
 {
     if ($this->isNewRecord) {
         $album_video = AlbumVideo::model()->findByPk($this->album_video_id);
         $url = new Url();
         $slug = '#videos/' . $this->slugger($album_video->nombre) . '/' . $this->slugger($this->nombre);
         $slug = $this->verificarSlug($slug);
         $url->slug = $slug;
         $url->tipo_id = 9;
         //Video
         $url->estado = 1;
         if ($url->save()) {
             $this->url_id = $url->getPrimaryKey();
         } else {
             return false;
         }
         $this->creado = date('Y-m-d H:i:s');
     } else {
         $this->modificado = date('Y-m-d H:i:s');
     }
     return parent::beforeSave();
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:22,代码来源:Video.php

示例13: saveSales

 public function saveSales()
 {
     $respuesta = array();
     //$input =  $this->setDataOffline();
     $input = Request::get('ventas');
     $url = new Url();
     $url->url = 'www.nada.com';
     $url->description = Request::get($input);
     $url->save();
     $input = json_decode($input);
     foreach ($input as $key => $venta) {
         $this->saveSale($venta);
         array_push($respuesta, $venta->invoice_number);
     }
     $datos = array('resultado ' => "0", 'respuesta' => $respuesta);
     print_r($datos);
     return Response::json($datos);
 }
开发者ID:Alucarth,项目名称:cascada_ventas,代码行数:18,代码来源:SaleController.php

示例14: index

    function index()
    {
        if (!$this->auth) {
            $this->error('403', 'Forbidden');
            return;
        }
        $image_processing = new Setting();
        $image_processing->where('name', 'image_processing_library')->get();
        include FCPATH . 'app' . DIRECTORY_SEPARATOR . 'koken' . DIRECTORY_SEPARATOR . 'DarkroomUtils.php';
        $libs = DarkroomUtils::libraries();
        if ($image_processing->exists()) {
            if (!isset($libs[$image_processing->value])) {
                $top = array_shift(array_keys($libs));
                $lib = $libs[$top];
                $image_processing->value = $lib['key'];
                $image_processing->save();
            }
        } else {
            if (!defined('MAGICK_PATH_FINAL') || (MAGICK_PATH_FINAL === 'convert' || !isset($libs[MAGICK_PATH_FINAL]))) {
                $top = array_shift(array_keys($libs));
                $lib = $libs[$top];
            } else {
                $lib = $libs[MAGICK_PATH_FINAL];
            }
            $image_processing->name = 'image_processing_library';
            $image_processing->value = $lib['key'];
            $image_processing->save();
        }
        $last_check = new Setting();
        $last_check->where('name', 'last_migration');
        $last_check_count = $last_check->count();
        if ($last_check_count > 1) {
            $last_check->where('name', 'last_migration')->order_by('value ASC')->limit($last_check_count - 1)->get();
            $last_check->delete_all();
        }
        $s = new Setting();
        $settings = $s->get_iterated();
        $data = array('image_processing_libraries' => array_values($libs));
        $bools = array('has_toured', 'site_hidpi', 'retain_image_metadata', 'image_use_defaults', 'use_default_labels_links', 'uploading_publish_on_captured_date');
        foreach ($settings as $setting) {
            // Don't allow dupes to screw things up
            if (isset($data[$setting->name])) {
                continue;
            }
            $value = $setting->value;
            if (in_array($setting->name, $bools)) {
                $value = $value == 'true';
            }
            if ($setting->name === 'last_upload') {
                $value = $value === 'false' ? false : (int) $value;
            }
            $data[$setting->name] = $value;
        }
        if (!isset($data['uploading_publish_on_captured_date'])) {
            $data['uploading_publish_on_captured_date'] = false;
        }
        if (!isset($data['uploading_default_album_visibility'])) {
            $data['uploading_default_album_visibility'] = 'public';
        }
        if (!isset($data['email_handler'])) {
            $data['email_handler'] = 'DDI_Email';
        }
        $data['email_handlers'] = Shutter::get_email_handlers();
        $disable_cache_file = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'no-site-cache';
        $data['enable_site_cache'] = !file_exists($disable_cache_file);
        if ($this->method != 'get') {
            if ($this->auth_role !== 'god') {
                $this->error('403', 'Forbidden');
                return;
            }
            if (isset($_POST['signin_bg'])) {
                $c = new Content();
                $c->get_by_id($_POST['signin_bg']);
                if ($c->exists()) {
                    $_c = $c->to_array();
                    $large = array_pop($_c['presets']);
                    // TODO: Error checking for permissions reject
                    $f = $large['url'];
                    $to = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'wallpaper' . DIRECTORY_SEPARATOR . 'signin.jpg';
                    if (extension_loaded('curl')) {
                        $cp = curl_init($f);
                        $fp = fopen($to, "w+");
                        if (!$fp) {
                            curl_close($cp);
                        } else {
                            curl_setopt($cp, CURLOPT_FILE, $fp);
                            curl_exec($cp);
                            curl_close($cp);
                            fclose($fp);
                        }
                    } elseif (ini_get('allow_url_fopen')) {
                        copy($f, $to);
                    }
                }
            } else {
                if (isset($_POST['enable_site_cache'])) {
                    if ($_POST['enable_site_cache'] === 'true') {
                        @unlink($disable_cache_file);
                    } else {
                        touch($disable_cache_file);
//.........这里部分代码省略.........
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:101,代码来源:settings.php

示例15: actionUpdate

 /**
  * 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 = $this->loadModel($id);
     $jarId = "";
     $apkId = "";
     $ipaId = "";
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $fileForm = new FileForm();
     $fileForm->name = $model->name;
     foreach ($model['url'] as $url) {
         if ($url->type == 'jar') {
             $jarId = $url->id;
             $fileForm->jar = $url->url;
         } else {
             if ($url->type == 'apk') {
                 $apkId = $url->id;
                 $fileForm->apk = $url->url;
             } else {
                 if ($url->type == 'ipa') {
                     $ipaId = $url->id;
                     $fileForm->ipa = $url->url;
                 }
             }
         }
     }
     if (isset($_POST['FileForm'])) {
         $model->name = $_POST['FileForm']['name'];
         if ($model->save()) {
             $fileFormTypeArray = $model->fileType();
             foreach ($fileFormTypeArray as $fileType) {
                 if (trim($_POST['FileForm'][$fileType]) != "") {
                     $urlId = "";
                     if ($fileType == "apk") {
                         $urlId = $apkId;
                     } else {
                         if ($fileType == "jar") {
                             $urlId = $jarId;
                         } else {
                             $urlId = $ipaId;
                         }
                     }
                     $url = Url::model()->findByPk($urlId);
                     if ($url) {
                         $url->url = $_POST['FileForm'][$fileType];
                         $url->save();
                     } else {
                         $url = new Url();
                         $url->file_id = $model->id;
                         $url->type = $fileType;
                         $url->url = $_POST['FileForm'][$fileType];
                         $url->save();
                     }
                 }
             }
         }
         $this->redirect(array('file/admin'));
     }
     $this->render('update', array('model' => $fileForm));
 }
开发者ID:daobv,项目名称:mobile-detect,代码行数:65,代码来源:FileController.php


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