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


PHP Url::model方法代码示例

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


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

示例1: afterDelete

 protected function afterDelete()
 {
     $url = Url::model()->findByPk($this->url_id);
     $url->delete();
     @unlink(Yii::getPathOfAlias('webroot') . '/archivos/' . $this->carpeta->ruta . '/' . $this->archivo);
     return parent::afterDelete();
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:7,代码来源:Archivo.php

示例2: verificar_slug

 private function verificar_slug($slug)
 {
     if ($slug == 'radio/emisora') {
         Yii::app()->request->redirect('http://radio.telemedellin.tv', true, 301);
     }
     return Url::model()->findByAttributes(array('slug' => $slug));
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:7,代码来源:TmUrlRule.php

示例3: getUrl

 protected function getUrl($item)
 {
     if (!$item) {
         return false;
     }
     if (isset($item->tipo_link_id) && $item->tipo_link_id == 2) {
         $url = $this->parseExtUrl($item->url);
     } else {
         $u = Url::model()->findByPk($item->url_id);
         $url = bu($u->slug);
     }
     return $url;
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:13,代码来源:MenuM.php

示例4: verificarSlug

 public function verificarSlug($slug, $baseUrl = '')
 {
     $slug = trim($slug);
     $c = Url::model()->findByAttributes(array('slug' => $baseUrl . $slug));
     if ($c) {
         $lc = substr($slug, -1);
         if (is_numeric($lc)) {
             $slug = substr($slug, 0, -1) . ((int) $lc + 1);
         } else {
             $slug = $slug . '-1';
         }
         $slug = $this->verificarSlug($slug);
     }
     return $slug;
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:15,代码来源:Utilities.php

示例5: getUrl

 protected function getUrl($item)
 {
     if (!$item) {
         return false;
     }
     switch ($item->tipo_link_id) {
         case 1:
             $u = Url::model()->findByPk($item->url_id);
             $url = bu($u->slug);
             break;
         case 2:
             $url = $this->parseExtUrl($item->url);
             break;
     }
     return $url;
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:16,代码来源:MenuW.php

示例6: afterSave

 protected function afterSave()
 {
     if (!$this->isNewRecord) {
         if (isset($this->oldAttributes['nombre']) && $this->nombre != $this->oldAttributes['nombre']) {
             $url = Url::model()->findByPk($this->url_id);
             $slug = '#imagenes/' . $this->slugger($this->nombre);
             $slug = $this->verificarSlug($slug);
             $url->slug = $slug;
             $url->save();
             foreach ($this->fotos as $foto) {
                 $uid = $foto->url_id;
                 $u = Url::model()->findByPk($uid);
                 $nslug = '#imagenes/' . $this->slugger($this->nombre) . '/' . $this->slugger($foto->nombre);
                 $nslug = $this->verificarSlug($nslug);
                 $u->slug = $nslug;
                 $u->save();
             }
         }
     }
     parent::afterSave();
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:21,代码来源:AlbumFoto.php

示例7: afterSave

 protected function afterSave()
 {
     if (!$this->isNewRecord) {
         if (isset($this->oldAttributes['nombre']) && $this->nombre != $this->oldAttributes['nombre']) {
             $url = Url::model()->findByPk($this->url_id);
             $slug = '#videos/' . $this->slugger($this->albumVideo->nombre) . '/' . $this->slugger($this->nombre);
             $slug = $this->verificarSlug($slug);
             $url->slug = $slug;
             $url->save();
         }
     }
     parent::afterSave();
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:13,代码来源:Video.php

示例8: 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

示例9: afterSave

 protected function afterSave()
 {
     if (!$this->isNewRecord) {
         if (isset($this->oldAttributes['nombre']) && $this->nombre != $this->oldAttributes['nombre']) {
             $micrositio = Micrositio::model()->findByPk($this->micrositio_id);
             $url = Url::model()->findByPk($this->url_id);
             if ($micrositio->seccion->nombre == 'sin-seccion') {
                 $slug = $this->slugger($micrositio->nombre) . '/' . $this->slugger($this->nombre);
             } else {
                 $slug = $this->slugger($micrositio->seccion->nombre) . '/' . $this->slugger($micrositio->nombre) . '/' . $this->slugger($this->nombre);
             }
             $slug = $this->verificarSlug($slug);
             $url->slug = $slug;
             $url->save();
         }
     }
     parent::afterSave();
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:18,代码来源:Pagina.php

示例10: actionUrls_mass

 public function actionUrls_mass()
 {
     if (!Yii::app()->request->isPostRequest) {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
     $action = $_GET['action'];
     if (isset($_POST['extendedSelect'])) {
         AdvancedSelectableGridView::mapUrlToGET();
         $dataProvider = Url::searchDataProvider();
         $criteria = AdvancedSelectableGridView::getExtendedSelectCriteria('Url', $dataProvider);
         if (!$criteria->condition) {
             $criteria->condition = "1=1";
         }
         if ($action == 'download') {
             Url::model()->downloadUrls($criteria->condition, $criteria->params);
         } elseif ($action == 'delete') {
             Url::model()->deleteUrls($criteria->condition, $criteria->params);
         } elseif ($action == 'enable') {
             Yii::app()->db->createCommand("UPDATE urls_url SET enabled_url=1 WHERE " . $criteria->condition)->execute($criteria->params);
         } elseif ($action == 'disable') {
             Yii::app()->db->createCommand("UPDATE urls_url SET enabled_url=0 WHERE " . $criteria->condition)->execute($criteria->params);
         }
     } elseif (isset($_POST['selected']) && is_array($_POST['selected']) && count($_POST['selected'])) {
         foreach ($_POST['selected'] as $k => $v) {
             // value must be integer
             $_POST['selected'][$k] = (int) $v;
         }
         if (count($_POST['selected']) == 1) {
             $condition = "id_url=" . $_POST['selected'][0];
         } else {
             $condition = "id_url='" . implode("' OR id_url='", $_POST['selected']) . '\'';
         }
         if ($action == 'download') {
             Url::model()->downloadUrls($condition);
         } elseif ($action == 'delete') {
             Url::model()->deleteUrls($condition);
         } elseif ($action == 'enable') {
             Yii::app()->db->createCommand("UPDATE urls_url SET enabled_url=1 WHERE " . $condition)->execute();
         } elseif ($action == 'disable') {
             Yii::app()->db->createCommand("UPDATE urls_url SET enabled_url=0 WHERE " . $condition)->execute();
         }
     } else {
         throw new CHttpException(400, 'Bad request.');
     }
     header("Location: " . $_SERVER['HTTP_REFERER']);
     die;
 }
开发者ID:vman747,项目名称:virex,代码行数:47,代码来源:ManageController.php

示例11: actionArchivo

 public function actionArchivo()
 {
     if (!$_GET['hash']) {
         throw new CHttpException(404, 'No se encontró la página solicitada');
     }
     $hash = $_GET['hash'];
     $url = Url::model()->findByAttributes(array('slug' => $hash));
     $params = array();
     if ($url->tipo_id == 10) {
         $c = Carpeta::model()->findByAttributes(array('url_id' => $url->id));
         if ($c) {
             $params['carpeta_id'] = $c->id;
             $w = ' carpeta_id = ' . $c->id . ' AND ';
         }
     } else {
         if ($url->tipo_id == 11) {
             $params['url_id'] = $url->id;
             $w = ' url_id = ' . $url->id . ' AND ';
         }
     }
     $json = '';
     $dependencia = new CDbCacheDependency("SELECT GREATEST(MAX(creado), MAX(modificado)) FROM archivo WHERE estado <> 0");
     $a = Archivo::model()->findAllByAttributes($params, array('order' => 'nombre ASC'));
     if ($a) {
         $json .= '[';
         foreach ($a as $archivo) {
             $json .= '{';
             $json .= '"id":"' . CHtml::encode($archivo->id) . '",';
             $json .= '"url":"' . CHtml::encode($archivo->url->slug) . '",';
             $json .= '"tipo_archivo":"' . $archivo->tipoArchivo->nombre . '",';
             //$json .= '"carpeta":"'.CHtml::encode($archivo->carpeta->ruta).'",';
             $json .= '"carpeta":';
             $json .= '{';
             $json .= '"ruta":"' . CHtml::encode($archivo->carpeta->ruta) . '",';
             $json .= '"url":"' . CHtml::encode($archivo->carpeta->url->slug) . '"';
             $json .= '},';
             $json .= '"nombre":"' . CHtml::encode($archivo->nombre) . '",';
             $json .= '"archivo":"' . $archivo->archivo . '"';
             $json .= '},';
         }
         $json = substr($json, 0, -1);
         $json .= ']';
     }
     $this->_sendResponse(200, $json, 'application/json');
     Yii::app()->end();
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:46,代码来源:ApiController.php

示例12: afterSave

 protected function afterSave()
 {
     if (!$this->isNewRecord) {
         if (isset($this->oldAttributes['nombre']) && $this->nombre != $this->oldAttributes['nombre']) {
             $url = Url::model()->findByPk($this->url_id);
             $slug = '#videos/' . $this->slugger($this->nombre);
             $slug = $this->verificarSlug($slug);
             $url->slug = $slug;
             $url->save();
             foreach ($this->videos as $video) {
                 $uid = $video->url_id;
                 $u = Url::model()->findByPk($uid);
                 $nslug = '#videos/' . $this->slugger($this->nombre) . '/' . $this->slugger($video->nombre);
                 $nslug = $this->verificarSlug($nslug);
                 $u->slug = $nslug;
                 $u->save();
             }
             //Recorrer los videos y cambiarles el slug de la URL
         }
     }
     parent::afterSave();
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:22,代码来源:AlbumVideo.php

示例13: resetClick

 public function resetClick()
 {
     $url = Url::model()->findBySql("SELECT * FROM " . $this->tableName() . " ORDER BY id DESC");
     if ($url->day_update != date('d')) {
         Url::model()->updateAll(array('day_update' => date('d'), 'day_click' => 0, 'total' => 0));
         if ($url->month_update != date('m')) {
             Url::model()->updateAll(array('month_update' => date('m'), 'month_click' => 0));
         }
         $files = File::model()->findAll(array('order' => 'id'));
         foreach ($files as $file) {
             $statistic = new Statistic();
             $statistic->file_id = $file->id;
             $statistic->date = date('dmY');
             $statistic->save();
         }
     }
 }
开发者ID:daobv,项目名称:mobile-detect,代码行数:17,代码来源:Url.php

示例14: actionRenamearchivo

 public function actionRenamearchivo()
 {
     if (!Yii::app()->request->isAjaxRequest || !isset($_POST['name']) || !isset($_POST['new_name'])) {
         throw new CHttpException(404, 'No se encontró la página solicitada');
     }
     $new_name = $_POST['new_name'];
     $archivo = Archivo::model()->with('carpeta')->findByAttributes(array('archivo' => $_POST['name']));
     $parent = Carpeta::model()->findByPk($archivo->carpeta_id);
     $nombre_slug = $this->slugger($new_name);
     $nueva_ruta = $parent->ruta . '/' . $nombre_slug;
     $url = Url::model()->findByPk($archivo->url_id);
     $slug = $parent->url->slug . '/' . $nombre_slug;
     $slug = $this->verificarSlug($slug);
     $url->slug = $slug;
     $url->save();
     $base = Yii::getPathOfAlias('webroot') . '/archivos/';
     header('HTTP/1.1 200 OK');
     $archivo->archivo = $new_name;
     $archivo->nombre = $new_name;
     if (!$archivo->save()) {
         $json = array('error' => '1');
         echo json_encode($json);
     }
     Yii::app()->end();
 }
开发者ID:Telemedellin,项目名称:tm,代码行数:25,代码来源:CarpetaController.php

示例15: loadModel

 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Url the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Url::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:daobv,项目名称:mobile-detect,代码行数:15,代码来源:UrlController.php


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