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


PHP Files::model方法代码示例

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


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

示例1: run

 public function run($thumb)
 {
     $key = key($_GET);
     if (NULL == ($file = Files::model()->findByPk($key))) {
         throw new CException('Page not found', 404);
     }
     $path = Yii::getPathOfAlias('webroot') . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . 'photos';
     $src_file = $file->id . '.' . $file->extension;
     $in_file = $path . DIRECTORY_SEPARATOR . $src_file;
     $out_file = $path . DIRECTORY_SEPARATOR . $thumb . DIRECTORY_SEPARATOR . $src_file;
     if (is_file($out_file)) {
         $mime = CFileHelper::getMimeType($out_file);
         header('Content-Type: ' . $mime);
         readfile($out_file);
         exit;
     }
     if (is_file($in_file)) {
         $dir = $path . DIRECTORY_SEPARATOR . $thumb;
         if (YII_DEBUG && !file_exists($dir)) {
             mkdir($dir, 0777);
         }
         if (file_exists($dir)) {
             if (($out_file = $file->resize($thumb)) == 0) {
                 throw new CException('Page not found', 404);
             }
             $mime = CFileHelper::getMimeType($in_file);
             header('Content-Type: ' . $mime);
             readfile($out_file);
             exit;
         }
     }
     return parent::run($thumb);
 }
开发者ID:BGCX067,项目名称:facecom-svn-to-git,代码行数:33,代码来源:ImagesController.php

示例2: create_item

 public function create_item($page_id = null, $model)
 {
     $controller = Yii::app()->getController();
     if (isset($_POST['ModuleList3'])) {
         $_POST['ModuleList3']['mpage_id'] = ModulesInPages::model()->getLink($page_id, $this->module_id);
         $model->attributes = $_POST['ModuleList3'];
         if ((int) $_POST['ModuleList3']['img_id']) {
             Files::model()->saveTempFile((int) $_POST['ModuleList3']['img_id']);
         }
         if ($model->save()) {
             $item_id = $model->primaryKey;
             // обработка input-параметров
             if (isset($_POST['ModuleList3Values']) && is_array($_POST['ModuleList3Values']) && count($_POST['ModuleList3Values'])) {
                 foreach ($_POST['ModuleList3Values'] as $key => $value) {
                     if (is_array($value) && count($value)) {
                         foreach ($value as $key2 => $value2) {
                             $params_value = new ModuleList3Values();
                             $params_value->attributes = array('param_id' => (int) $key, 'item_id' => $item_id, 'value' => $value2);
                             $params_value->save();
                         }
                     } else {
                         $params_value = new ModuleList3Values();
                         $params_value->attributes = array('param_id' => (int) $key, 'item_id' => $item_id, 'value' => $value);
                         $params_value->save();
                     }
                 }
             }
             Yii::app()->user->setFlash($this->module_id . '_add_message', '<p style="color:green;">Добавлено</p>');
             $controller->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id . '&/#!/tab_' . $this->module_id);
         } else {
             Yii::app()->user->setFlash($this->module_id . '_add_message', '<p style="color:red;">Ошибка</p>');
         }
     }
 }
开发者ID:arduanov,项目名称:eco,代码行数:34,代码来源:Module_list3.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Issues();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['Issues'])) {
         $model->attributes = $_POST['Issues'];
         if ($model->save()) {
             if ($model->attachments != null) {
                 $fileids = explode(",", $model->attachments);
                 for ($i = 1; $i < sizeof($fileids); $i++) {
                     $file = Files::model()->findByPk($fileids[$i]);
                     if ($file->uploadedby == Yii::app()->user->id) {
                         $file->objecttype = "issues";
                         $file->objectid = $model->id;
                         $file->save();
                     }
                 }
             }
             //$this->redirect(array('view','id'=>$model->id));
             echo CJSON::encode(array('errors' => $model->getErrors(), 'redirect' => $this->createURL("/issues/view", array('id' => $model->id))));
             exit;
         }
     }
     if (!Yii::app()->request->isAjaxRequest) {
         $this->render('create', array('model' => $model));
     } else {
         $string = $this->renderPartial('_formajax', array('model' => $model), true);
         echo CJSON::encode(array('html' => $string, 'errors' => $model->getErrors()));
     }
 }
开发者ID:ranvirp,项目名称:rdp,代码行数:35,代码来源:IssuesController.php

示例4: loadModel

 public function loadModel($id)
 {
     $model = Files::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:BroneKot,项目名称:CS-Bans,代码行数:8,代码来源:FilesController.php

示例5: findFile

 private static function findFile($model, $name)
 {
     $files = Files::model()->findAllByAttributes(array("parent_type" => 'Docs', "parent_id" => $model->id, "name" => $name));
     foreach ($files as $file) {
         if ($file->name == $name) {
             return $file;
         }
     }
     return false;
 }
开发者ID:hkhateb,项目名称:linet3,代码行数:10,代码来源:PrintDoc.php

示例6: actionDelete

 public function actionDelete($page_id = null, $item_id = null, $id = null)
 {
     $model = ModuleList4Files::model()->findByPk($id);
     if ($model != null) {
         $fileId = $model->file_id;
         if ($model->delete()) {
             Files::model()->deleteFile($fileId, $this->module->id);
         }
     }
     $this->redirect(Yii::app()->baseUrl . '?r=' . $this->module->id . '/main/update&page_id=' . $page_id . '&id=' . $item_id . '&/#!/tab_third');
 }
开发者ID:arduanov,项目名称:eco,代码行数:11,代码来源:FilesController.php

示例7: showAttachments

 public static function showAttachments($model)
 {
     $x = $model->attachments;
     //echo $x;
     $y = explode(",", $x);
     $str = "<ul>";
     for ($i = 1; $i < sizeof($y); $i++) {
         $files = Files::model()->findByPk($y[$i]);
         $str .= "<li>" . CHtml::link($files->originalname, Ccontroller::createUrl('/files/file', array('id' => $y[$i])));
     }
     $str .= "</ul>";
     return $str;
 }
开发者ID:ranvirp,项目名称:rdp,代码行数:13,代码来源:Files.php

示例8: actionCreate

 public function actionCreate()
 {
     Yii::app()->clientScript->registerPackage('items-edit');
     if (!isset($_GET['id']) || NULL == ($model = Items::model()->findByAttributes(array('user_id' => Yii::app()->user->id, 'id' => (int) $_GET['id'])))) {
         $model = new Items();
     }
     if (isset($_POST['Items'])) {
         $model->attributes = $_POST['Items'];
         $fn = Files::model()->uploadFile('Items[image]');
         if ($fn) {
             $model->image = $fn['filename'];
         } elseif (isset($_POST['Items']['image_src'])) {
             $model->image = $_POST['Items']['image_src'];
         }
         $new = $model->isNewRecord;
         if ($model->save()) {
             $cats = isset($_POST['categories']) ? $_POST['categories'] : array();
             if (!$new && empty($cats)) {
                 ItemsCategory::model()->deleteAllByAttributes(array('item_id' => $model->id));
             } else {
                 if (!$new) {
                     $dbcats = ItemsCategory::model()->findAll('item_id=:iid', array('iid' => $model->id));
                     $ids = array();
                     foreach ($dbcats as $i => $dbc) {
                         if (false !== ($k = array_search($dbc->category_id, $cats))) {
                             unset($cats[$k]);
                             unset($dbc[$i]);
                         } else {
                             $ids[] = $dbc->category_id;
                         }
                     }
                     //deleteing corresponding categories
                     if (!empty($ids)) {
                         $ids = implode(",", $ids);
                         ItemsCategory::model()->deleteAll('item_id=:iid AND category_id IN (:cid)', array('iid' => $model->id, 'cid' => $ids));
                     }
                 }
                 if (!empty($cats)) {
                     foreach ($cats as $cat) {
                         $c = new ItemsCategory();
                         $c->attributes = array('category_id' => $cat, 'item_id' => $model->id);
                         $c->save();
                     }
                 }
             }
             Yii::app()->user->setFlash('ItemSaved', '1');
             $this->refresh();
         }
     }
     $this->render('_form', array('model' => $model));
 }
开发者ID:BGCX067,项目名称:facecom-svn-to-git,代码行数:51,代码来源:ItemsController.php

示例9: create_item

 public function create_item($page_id = null, $model)
 {
     $controller = Yii::app()->getController();
     if (isset($_POST['ModuleList2'])) {
         $_POST['ModuleList2']['mpage_id'] = ModulesInPages::model()->getLink($page_id, $this->module_id);
         $model->attributes = $_POST['ModuleList2'];
         if ((int) $_POST['ModuleList2']['img_id']) {
             Files::model()->saveTempFile((int) $_POST['ModuleList2']['img_id']);
         }
         if ($model->save()) {
             Yii::app()->user->setFlash($this->module_id . '_add_message', '<p style="color:green;">Добавлено</p>');
             $controller->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id . '&/#!/tab_' . $this->module_id);
         } else {
             Yii::app()->user->setFlash($this->module_id . '_add_message', '<p style="color:red;">Ошибка</p>');
         }
     }
 }
开发者ID:arduanov,项目名称:eco,代码行数:17,代码来源:Module_list2.php

示例10: actionUpdate

 public function actionUpdate($page_id = null, $id = null)
 {
     if (!is_null($page_id) && Pages::model()->existsPage($page_id)) {
         $link_id = ModulesInPages::model()->getLink((int) $page_id, $this->module->id);
         if (!is_null($id) && ModuleFiles::model()->existsItem($link_id, $id)) {
             $model = ModuleFiles::model()->findByPk($id);
             if (isset($_POST['ModuleFiles'])) {
                 $old_file_id = $model->file_id;
                 if ($_POST['ModuleFiles']['file_id'] == 'NULL') {
                     $_POST['ModuleFiles']['file_id'] = '';
                 }
                 if ((int) $old_file_id && (int) $old_file_id != (int) $_POST['ModuleFiles']['file_id']) {
                     $_POST['ModuleFiles']['link'] = NULL;
                     $_POST['ModuleFiles']['extension'] = NULL;
                     $_POST['ModuleFiles']['size'] = 0;
                     Files::model()->deleteFile($old_file_id, $this->module->id);
                 }
                 if ((int) $_POST['ModuleFiles']['file_id']) {
                     $file_name = Files::model()->findByPk($_POST['ModuleFiles']['file_id'])->file_name;
                     $_POST['ModuleFiles']['link'] = '/upload/' . md5($this->module->id) . '/' . $file_name;
                     $_POST['ModuleFiles']['extension'] = explode('.', $file_name);
                     $_POST['ModuleFiles']['extension'] = $_POST['ModuleFiles']['extension'][count($_POST['ModuleFiles']['extension']) - 1];
                     $_POST['ModuleFiles']['size'] = round(filesize($_SERVER['DOCUMENT_ROOT'] . rawurldecode($_POST['ModuleFiles']['link'])) / 1024);
                     Files::model()->saveTempFile((int) $_POST['ModuleFiles']['file_id']);
                 }
                 if (isset($_POST['ModuleFiles']['group_id']) && empty($_POST['ModuleFiles']['group_id'])) {
                     $_POST['ModuleFiles']['group_id'] = NULL;
                 }
                 $model->attributes = $_POST['ModuleFiles'];
                 if ($model->save()) {
                     Yii::app()->user->setFlash('message', '<p style="color:green;">Сохранено</p>');
                     $this->redirect(Yii::app()->baseUrl . '?r=' . $this->module->id . '/main/update&page_id=' . $page_id . '&id=' . $id);
                 } else {
                     Yii::app()->user->setFlash('message', '<p style="color:red;">Ошибка</p>');
                 }
             }
             $model = ModuleFiles::model()->getItem($id, $link_id);
             $this->render('update', array('page_id' => $page_id, 'model' => $model));
         } else {
             $this->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id . '&/#!/tab_' . $this->module->id);
         }
     } else {
         $this->redirect(Yii::app()->request->scriptUrl);
     }
 }
开发者ID:arduanov,项目名称:eco,代码行数:45,代码来源:MainController.php

示例11: getList

 public function getList($id = null)
 {
     if ($id === null) {
         return false;
     }
     $files = $this->findAllByAttributes(array('item_id' => $id));
     if (count($files) == 0) {
         return false;
     }
     $list = array();
     foreach ($files as $file) {
         $list[$file->id]['file_id'] = $file->file_id;
         $list[$file->id]['short'] = $file->short;
         $list[$file->id]['ref'] = Files::model()->getVirtualPath('list3', $file->file_id);
         $list[$file->id]['file_name'] = Files::model()->findByPk($file->file_id)->file_name;
     }
     return $list;
 }
开发者ID:arduanov,项目名称:eco,代码行数:18,代码来源:ModuleList3Files.php

示例12: send

 public function send()
 {
     Yii::import('application.extensions.smtpmail.PHPMailer');
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->Host = Yii::app()->user->getSetting('company.mail.server');
     $mail->SMTPAuth = Yii::app()->user->getSetting('company.mail.user') != '' ? true : false;
     $mail->SMTPSecure = Yii::app()->user->getSetting('company.mail.ssl') ? 'tls' : '';
     $mail->CharSet = 'utf-8';
     $mail->Port = Yii::app()->user->getSetting('company.mail.port');
     $mail->Username = Yii::app()->user->getSetting('company.mail.user');
     $mail->Password = Yii::app()->user->getSetting('company.mail.password');
     //$mail->SetFrom($this->from);
     //echo $this->files;
     if ($this->files != '') {
         $file = Files::model()->findByPk($this->files);
         if ($file != null) {
             //echo $file->getFullPath().";;".$file->name;
             $mail->AddAttachment($file->getFullFilePath(), $file->name);
         }
     }
     $mail->SetFrom(Yii::app()->user->settings['company.mail.address']);
     $mail->AddCC($this->cc);
     //.$this->cc
     $mail->AddBcc($this->bcc);
     $mail->Subject = $this->subject;
     $mail->MsgHTML($this->body);
     $mail->AddAddress($this->to, "");
     if (!$mail->Send()) {
         //echo "Mailer Error: " . $mail->ErrorInfo;
         throw new CHttpException(501, Yii::t('app', "Mailer Error: ") . $mail->ErrorInfo . $mail->Username);
     } else {
         $this->sent++;
         $this->save();
         Yii::app()->user->setFlash('success', Yii::t('app', 'Message sent!'));
         //echo "Message sent!";
     }
     //*/
     //Yii::app()->end();
 }
开发者ID:hkhateb,项目名称:linet3,代码行数:40,代码来源:Mail.php

示例13: actionUpdate

 public function actionUpdate($page_id = null, $id = null)
 {
     if (!is_null($page_id) && Pages::model()->existsPage($page_id)) {
         $link_id = ModulesInPages::model()->getLink((int) $page_id, $this->module->id);
         if (!is_null($id) && ModuleList2::model()->existsItem($link_id, $id)) {
             $model = ModuleList2::model()->findByPk($id);
             if (isset($_POST['ModuleList2'])) {
                 $old_file_id = $model->img_id;
                 if ($_POST['ModuleList2']['img_id'] == 'NULL') {
                     $_POST['ModuleList2']['img_id'] = '';
                 }
                 $model->attributes = $_POST['ModuleList2'];
                 if ((int) $_POST['ModuleList2']['img_id']) {
                     Files::model()->saveTempFile((int) $_POST['ModuleList2']['img_id']);
                 } elseif ($_POST['ModuleList2']['img_id'] == '') {
                     Files::model()->deleteFile($old_file_id, $this->module->id);
                 }
                 if ($model->save()) {
                     if ($old_file_id != $model->img_id) {
                         Files::model()->deleteFile($old_file_id, $this->module->id);
                     }
                     Yii::app()->user->setFlash('message', '<p style="color:green;">Сохранено</p>');
                     $this->redirect(Yii::app()->baseUrl . '?r=' . $this->module->id . '/main/update&page_id=' . $page_id . '&id=' . $id);
                 } else {
                     Yii::app()->user->setFlash('message', '<p style="color:red;">Ошибка</p>');
                 }
             }
             $model = ModuleList2::model()->getItem($id, $link_id);
             $this->render('update', array('page_id' => $page_id, 'model' => $model));
         } else {
             $this->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id . '&/#!/tab_' . $this->module->id);
         }
     } else {
         $this->redirect(Yii::app()->request->scriptUrl);
     }
 }
开发者ID:arduanov,项目名称:eco,代码行数:36,代码来源:MainController.php

示例14: getImageById

 public function getImageById($id)
 {
     $result = null;
     if (!empty($id)) {
         $result = '/' . Files::model()->getUploadFolder('list2', false, true) . Files::model()->findByPk($id)->file_name;
     } else {
         $result = null;
     }
     if (!file_exists($_SERVER['DOCUMENT_ROOT'] . $result)) {
         $result = null;
     }
     if ($result != null) {
         $images = array();
         $i = 0;
         $result = $_SERVER['DOCUMENT_ROOT'] . $result;
         foreach (array(array(93, 60), array(205, 0), array(96, 96), array(220, 220)) as $size) {
             // [0] - админка список, [1] - админка редактир, [2] - сайт (мини в списке), [3] — сайт (страница конкретной акции)
             $i++;
             $cache_folder = explode('/', $result);
             $cache_folder[count($cache_folder) - 1] = 'cache';
             $cache_folder = implode('/', $cache_folder);
             $img = explode('/', $result);
             $img[count($img) - 1] = 'cache/size' . $i . '_' . $img[count($img) - 1];
             $img = implode('/', $img);
             if (!is_dir($cache_folder)) {
                 mkdir($cache_folder, 777);
             }
             if (!file_exists($img)) {
                 $thumb = Yii::app()->thumb->create($result);
                 $thumb->resize($size[0], $size[1]);
                 $thumb->save($img);
             }
             $img = explode($_SERVER['DOCUMENT_ROOT'], $img);
             $images[] = $img[1];
         }
     } else {
         $images = $this->img_default;
     }
     return $images;
 }
开发者ID:arduanov,项目名称:eco,代码行数:40,代码来源:ModuleList2.php

示例15: json_decode

		<?php 
} else {
    ?>
			<?php 
    echo $full;
    ?>
		<?php 
}
?>
	</div>
	<div class="all_posts_files">
		<?php 
$multimedia = json_decode($item->multimedia);
if (is_array($multimedia)) {
    foreach ($multimedia as $ind => $file) {
        $image = Files::model()->findByPk($file->id);
        ?>
		<div class="all_posts_files_item"><a href="/id<?php 
        echo $item->authors->id;
        ?>
/aphotos/showposts/<?php 
        echo $file->nomber;
        ?>
/<?php 
        echo $item->id;
        ?>
"><img src="<?php 
        echo Yii::app()->request->baseUrl;
        ?>
/upload/photos/80x80/<?php 
        echo $image->id;
开发者ID:BGCX067,项目名称:facecom-svn-to-git,代码行数:31,代码来源:_postItem.php


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