コード例 #1
0
ファイル: PageController.php プロジェクト: Romerohub/Yii-blog
 protected function prepareText($post)
 {
     /*Если не указан main_pic то найдем првй попавшейся по посту и поставим*/
     if (empty($post['main_pic']) && !empty($post['id'])) {
         $img_arr = Images::items($post['id']);
         /*Если что то найдет то вставит*/
         if (!empty($img_arr)) {
             reset($img_arr);
             $img_arr = current($img_arr);
             $post['main_pic'] = $img_arr['file_name'];
         }
     } elseif (!empty($post['main_pic'])) {
         $post['main_pic'] = explode("/", $post['main_pic']);
         $post['main_pic'] = end($post['main_pic']);
         $post['main_pic'] = trim($post['main_pic']);
     }
     /**подготавливаем текст для сохранения*/
     $post['full_text'] = $post['content'];
     if ($str_res = strpos($post['full_text'], '<!--more-->')) {
         $post['text_preview'] = substr($post['full_text'], 0, $str_res);
     } else {
         $post['full_text'] = strip_tags($post['full_text']);
         $post['text_preview'] = substr($post['full_text'], 0, 400);
         if ($str_res = strripos($post['text_preview'], ' ')) {
             $post['text_preview'] = substr($post['text_preview'], 0, $str_res);
         }
     }
     $post['full_text'] = str_replace('<!--more-->', " ", $post['content']);
     return $post;
 }
コード例 #2
0
ファイル: _form.php プロジェクト: Romerohub/Yii-blog
         <input type="file" name="my-pic" id="file-field" /><br/>
         <input type="hidden" value="<?php if(!empty($model->id)) echo $model->id; ?>" name="post_id" id="post_id" />
         <input type="hidden" value="page" id="note_type" />
        или просто перетащи в область ниже &dArr;
    </form>
    <div class="img-container" id="img-container">
        <ul class="img-list" id="img-list"></ul>
    </div>
        <button id="upload-all">Загрузить все</button>
    <button id="cancel-all">Отменить все</button>
   <br> Уже загружены<br>
    <div class="img-container-1" id="img-container-present">
        <ul class="img-list" id="img-list-present">
   		<?php 
   		if(!empty($model->id) or !empty($_POST['Post']['id'])){
   			$img_item = Images::items($model->id, "page");
   			//print_r($img_item); echo "ddddd";
		foreach($img_item as $k=>$v){
			?>
			<li><div><?=$v['file_name'];?><br><a class="addMainPic" href="#">Сделать главной</a></div>
			<img width="80px" id="<?=$k;?>" src="<?=Yii::app()->baseUrl."/uploads/images/".date('Y',$v['date_add'])."/".date('m',$v['date_add'])."/".$v['file_name'];?>"></li>
		<?}} ?>
        
        </ul>
    </div>

    
    </div>
</div>​

コード例 #3
0
ファイル: _form.php プロジェクト: Romerohub/Yii-blog
    <form action="/index.php/images/addajax" method="POST" enctype="multipart/form-data">
         <input type="file" name="my-pic" id="file-field" /><br/>
         <input type="hidden" value="" name="post_id" id="post_id" />
        или просто перетащи в область ниже &dArr;
    </form>
    <div class="img-container" id="img-container">
        <ul class="img-list" id="img-list"></ul>
    </div>
        <button id="upload-all">Загрузить все</button>
    <button id="cancel-all">Отменить все</button>
   <br> Уже загружены<br>
    <div class="img-container-1" id="img-container-present">
        <ul class="img-list" id="img-list-present">
   		<?php 
   		if((int)$model->id){
		foreach(Images::items() as $k=>$v){?>
			<li><div><?=$v['file_name'];?><br><a class="addMainPic" href="#">Сделать главной</a></div>
			<img width="80px" id="<?=$v['id'];?>" src="<?=Yii::app()->baseUrl."/uploads/images/".date('Y',$v['date_add'])."/".date('m',$v['date_add'])."/".$v['file_name'];?>"></li>
		<?}}?>
        
        </ul>
    </div>

    
    </div>
</div>​



<div class="form">