示例#1
0
 public function actionEditBlog($id)
 {
     $model = new Post();
     $rec = Post::model()->findByPk($id);
     $r = Lookup::model()->findAll(array('condition' => 'type=:t', 'params' => array(':t' => 'PostStatus')));
     //echo "<pre>";print_r($r);die;
     foreach ($r as $type) {
         //echo "<pre>";print_r($type);
         $i[] = $type->id;
         $n[] = $type->name;
         $op = array_combine($i, $n);
     }
     //die;
     //echo "<pre>";print_r($rec);die;
     if (isset($_POST['Post'])) {
         $model->attributes = $_POST['Post'];
         if ($model->validate()) {
             $res = Post::model()->findByPk($id);
             $res->title = $_REQUEST['Post']['title'];
             $res->content = $_REQUEST['Post']['content'];
             $res->tags = $_REQUEST['Post']['tags'];
             $res->status = $_REQUEST['Post']['status'];
             $res->update_time = date('Y-m-d');
             if ($res->save(false)) {
                 $this->redirect(array('postlisting'));
             }
         } else {
             $errors = $model->getErrors();
         }
     }
     $this->render('editblog', array('edit' => $rec, 'model' => $model, 'type' => $op, 'i' => $i));
 }
 function actionSearch()
 {
     header('Content-type: application/json');
     //	   if(Yii::app()->user->isGuest){
     //			IjoyPlusServiceUtils::exportServiceError(Constants::SEESION_IS_EXPIRED);
     //			return ;
     //		}
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     $keyword = Yii::app()->request->getParam("keyword");
     if (!(isset($keyword) && !is_null($keyword) && strlen($keyword) > 0)) {
         IjoyPlusServiceUtils::exportServiceError(Constants::KEYWORD_IS_NULL);
         return;
     }
     $keyword = trim($keyword);
     Lookup::model()->saveLookup($keyword);
     if (!FilterUtils::keyWordValid($keyword)) {
         IjoyPlusServiceUtils::exportEntity(array('results' => array()));
         return;
     }
     //   		$keyword= iconv("GBK","UTF-8",$keyword);n
     //   		var_dump($keyword);
     //$keyword='???';
     //        var_dump($keyword);
     $keyword = strtr($keyword, array('%' => '\\%', '_' => '\\_'));
     //   		var_dump($keyword);
     $page_size = Yii::app()->request->getParam("page_size");
     $page_num = Yii::app()->request->getParam("page_num");
     if (!(isset($page_size) && is_numeric($page_size))) {
         $page_size = 10;
         $page_num = 1;
     } else {
         if (!(isset($page_num) && is_numeric($page_num))) {
             $page_num = 1;
         }
     }
     $type = Yii::app()->request->getParam("type");
     try {
         if (is_null($type) || $type == '') {
             $prods = SearchManager::searchProgram($keyword, $page_size, $page_size * ($page_num - 1));
         } else {
             $prods = SearchManager::searchProgramByType($keyword, $type, $page_size, $page_size * ($page_num - 1));
         }
         if (isset($prods) && is_array($prods)) {
             IjoyPlusServiceUtils::exportEntity(array('results' => $prods));
         } else {
             IjoyPlusServiceUtils::exportEntity(array('results' => array()));
         }
     } catch (Exception $e) {
         var_dump($e);
         IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR);
     }
 }
示例#3
0
 public function actionAvatars()
 {
     $this->layout = '//layouts/blank';
     $dataProvider = null;
     if (isset($_GET['uid'])) {
         $id = $_GET['uid'];
         $type = $_GET['type'] ? $_GET['type'] : Lookup::USER_PIC_FOLDER;
         $lookup = Lookup::model()->find(array('condition' => 'uid = :uid AND type = :type', 'params' => array(':uid' => $id, ':type' => $type)));
         if ($lookup !== null) {
             $pid = $lookup->id;
             $criteria = new CDbCriteria(array('condition' => 'pid = :pid AND uid = :uid', 'order' => 'id DESC', 'params' => array(':pid' => $pid, ':uid' => $id)));
             $count = File::model()->count($criteria);
             $pages = new CPagination($count);
             // results per page
             $pages->pageSize = 14;
             $pages->applyLimit($criteria);
             $dataProvider = new CActiveDataProvider('File', array('criteria' => $criteria, 'pagination' => $pages));
         }
     }
     $this->render('avatars', array('dataProvider' => $dataProvider));
 }
	/**
	 * Manages all models.
	 */
	public function actionAdmin()
	{
		$all = Lookup::model()->getAll();
		Y::dump($all);
		$model = new Portfolio('search');
		$model->unsetAttributes();  // clear any default values
		$model = $model->current($cat);
		
		if (isset($_GET['Portfolio']))
			$model->attributes=$_GET['Portfolio'];
		
		if (isset($_GET['ajax'])) {
			$this->renderPartial('admingrid',array(
	            'model'=>$model,
		    ));
    	} else {
    		$this->render('admin',array(
				'model'=>$model,
    			'cat'=>$cat
    		));
		}
	}
 /**
  * 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.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = Lookup::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404);
         }
     }
     return $this->_model;
 }
示例#6
0
 public function actionGetRemoteImage()
 {
     $url = isset($_POST['url']) ? $_POST['url'] : die('图片地址不正确~');
     $info = UtilHelper::resourceLocalize($url);
     //        UtilHelper::dump($info);
     $model = new File();
     $model->name = $info['filename'];
     $model->ext = $info['extension'];
     $model->created = time();
     $model->size = $info['size'];
     $model->pid = Lookup::model()->getUserAdThemeAlbum(Yii::app()->user->id)->id;
     $model->mime = File::model()->getMimeType($model->ext, $info['mime']);
     $src = './public/favorite/' . $model->name . '.' . $model->ext;
     $target = File::model()->generateFileName($model, 'adtheme', true);
     //        UtilHelper::dump($model->attributes);
     if ($model->save()) {
         UtilFile::moveFile($src, $target);
         $result = array('id' => $model->id, 'path' => File::model()->generateFileName($model, 'adtheme', false));
         echo json_encode($result);
     }
 }
示例#7
0
 /**
  * 获取用户图片上传目录信息
  */
 private function getUserAlbum($userID, $name, $type)
 {
     $model = Lookup::model()->find(array('condition' => 'uid = :uid AND type = :type', 'params' => array(':uid' => $userID, ':type' => $type)));
     if ($model == null) {
         $model = new Lookup();
         $model->type = $type;
         $model->name = $name;
         $model->ename = Yii::app()->user->name . '_' . ucfirst(UtilHelper::words2PinYin($name)) . 'Album';
         $model->weight = 1;
         $model->description = $name . '相关图册';
         $model->save();
     }
     return $model;
 }
示例#8
0
echo $form->labelEx($model, 'ename');
?>
		<?php 
echo $form->textField($model, 'ename', array('size' => 30, 'maxlength' => 30, 'class' => 'span-5 poshy', 'title' => '项目名称别名,由字母a-z组成'));
?>
		<?php 
echo $form->error($model, 'ename', array('class' => 'clear', 'style' => 'color:red;'));
?>
	</div>
	
	<div class="row span-5">
		<?php 
echo $form->labelEx($model, 'type');
?>
		<?php 
echo $form->dropDownList($model, 'type', Lookup::model()->generateLookUpItemList(), array('class' => 'span-5 poshy', 'title' => '项目分类'));
?>
		<?php 
echo $form->error($model, 'type');
?>
	</div>
	
	<div class="row span-11">
		<?php 
echo $form->labelEx($model, 'weight');
?>
		<?php 
echo $form->dropDownList($model, 'weight', array_combine(range(1, 20), range(1, 20)), array('class' => 'span-11 poshy', 'title' => '项目权重'));
?>
		<?php 
echo $form->error($model, 'weight');
示例#9
0
 /**
  * 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 Lookup the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Lookup::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#10
0
<?php

$this->widget('ext.uploadify.uploadifyWidget', array('script' => $this->createUrl('/archiver/upload'), 'checkScript' => $this->createUrl('/archiver/checkupload'), 'onComplete' => 'js:function(event, ID, fileObj, response, data){updateImage(response);}', 'fileExt' => '*.jpg;*.gif;*.jpeg;*.png;', 'pid' => Lookup::model()->getUserDefaultAlbum(Yii::app()->user->id)->id, 'auto' => true));
示例#11
0
					
				uu.alertInfo('头像已更改');	

			});		
			
			return ;
		}
		
		uu.alertInfo('请选择一个剪切区域,然后点击“更换头像”按钮.');
		return false;
	};
    
    function loadAvatars()
    {
        $("#loadAvatars").load('<?php 
echo $this->createUrl('/file/avatars', array('uid' => Yii::app()->user->id, 'pid' => Lookup::model()->getUserAdThemeAlbum(Yii::app()->user->id)->id, 'type' => Lookup::USER_ADTHEME_PIC_FOLDER));
?>
');
       
    }
    
    
    
    //加载上传控件
    function loadUpload()
	{
		$('#loadUpload').load('<?php 
echo $this->createUrl("/theme/uploadimage");
?>
');
	}
示例#12
0
<?php

$this->pageTitle = Yii::app()->name . ' - ' . Yii::t('LookupModule.ui', 'Lookup Names');
$this->breadcrumbs = array(Yii::t('LookupModule.ui', 'Lookup Names'));
?>

<h2><?php 
echo Yii::t('LookupModule.ui', 'Lookup Names');
?>
</h2>

<?php 
$this->widget('zii.widgets.CMenu', array('items' => Lookup::model()->menu, 'htmlOptions' => array('style' => 'line-height:200%')));
示例#13
0
 public function actionToDoTest()
 {
     //上传配置
     $config = array("uploadPath" => Yii::app()->params['uploadPath']['advertisement'], "fileType" => array(".gif", ".png", ".jpg", ".jpeg", ".bmp"), "fileSize" => 1000);
     //文件上传状态,当成功时返回SUCCESS,其余值将直接返回对应字符窜并显示在图片预览框,同时可以在前端页面通过回调函数获取对应字符窜
     $state = "SUCCESS";
     $title = htmlspecialchars($_POST['pictitle'], ENT_QUOTES);
     $path = $config['uploadPath'];
     if (!file_exists($path)) {
         mkdir("{$path}", 0777);
     }
     //格式验证
     $current_type = strtolower(strrchr($_FILES["picdata"]["name"], '.'));
     if (!in_array($current_type, $config['fileType'])) {
         $state = "不支持的图片类型!";
     }
     //大小验证
     $file_size = 1024 * $config['fileSize'];
     if ($_FILES["picdata"]["size"] > $file_size) {
         $state = "图片大小超出限制!";
     }
     //保存图片
     if ($state == "SUCCESS") {
         $tmp_file = $_FILES["picdata"]["name"];
         $file = $path . rand(1, 10000) . time() . strrchr($tmp_file, '.');
         $info = pathinfo($_FILES['picdata']['name']);
         $model = new File();
         $model->pid = Lookup::model()->getUserAdvertisementAlbum(Yii::app()->user->id)->id;
         $model->size = $_FILES['picdata']['size'];
         $model->ext = strtolower($info['extension']);
         $model->name = $info['filename'];
         $model->created = time();
         $model->mime = File::model()->getMimeType($model->ext, $_FILES['picdata']['type']);
         UtilHelper::writeToFile($_FILES, './public/testd.txt', 'w+');
         UtilHelper::writeToFile(pathinfo($_FILES['picdata']['name']), './public/testd.txt', 'a+');
         UtilHelper::writeToFile($model->attributes);
         $file = File::model()->generateFileName($model, 'advertisement', true);
         UtilHelper::writeToFile($file, './public/testd.txt', 'a+');
         if ($model->save()) {
             $result = move_uploaded_file($_FILES["picdata"]["tmp_name"], $file);
             if (!$result) {
                 $state = "图片保存失败!";
             }
         } else {
             $state = "数据保存失败!";
         }
     }
     //向浏览器返回数据json数据
     $file = str_replace(array('../', './'), '', $file);
     //为方便理解,替换掉所有类似../和./等相对路径标识
     $str = "{'url':'" . $file . "','title':'" . $title . "','state':'" . $state . "'}";
     echo $str;
 }
示例#14
0
 * @author Brett O'Donnell <*****@*****.**>
 * @author Zain Ul abidin <*****@*****.**>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-dressing
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-dressing/master/license.txt
 */
$this->pageTitle = $this->getName() . ' ' . Yii::t('dressing', ucfirst($task));
$lookup = $id ? Lookup::model()->findByPk($id) : new Lookup('search');
/** @var YdActiveForm $form */
$form = $this->beginWidget('dressing.widgets.YdActiveForm', array('id' => 'lookup-' . $task . '-form', 'type' => 'horizontal', 'action' => array('/lookup/delete', 'id' => $id, 'task' => $task, 'confirm' => 1)));
echo $this->getGridIdHiddenFields($id);
echo $form->beginModalWrap();
echo $form->errorSummary($lookup);
echo '<fieldset>';
echo '<legend>' . Yii::t('dressing', 'Selected Records') . '</legend>';
$lookups = Lookup::model()->findAll('t.id IN (' . implode(',', YdHelper::getGridIds($id)) . ')');
if ($lookups) {
    echo '<ul>';
    foreach ($lookups as $lookup) {
        echo '<li>';
        echo $lookup->getName();
        echo '</li>';
    }
    echo '</ul>';
}
echo '</fieldset>';
echo $form->endModalWrap();
echo '<div class="' . $form->getSubmitRowClass() . '">';
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => Yii::t('dressing', 'Confirm ' . ucfirst($task)), 'htmlOptions' => array('class' => 'pull-right')));
echo '</div>';
$this->endWidget();