public function actionIndex() {

    	$this->active_link = 'dashboard';
    	//count users
    	$users = User::model()->count('status != '.User::STATUS_DELETED);
        $objects = Objects::model()->active()->count(array('select'=>'id'));
        $objectsNew = Objects::model()->active()->count(array('select'=>'id','condition'=>'verified = false'));
        $polls = PollChoice::model()->count();
        $photos = ObjectsImages::model()->count();
        $videos = ObjectsHttp::model()->count(array('condition'=>'type='.ObjectsHttp::TYPE_VIDEO));
        $this->render('dashboard',array('users'=>$users,'objects'=>$objects,
            'objectsNew'=>$objectsNew, 'polls'=>$polls,'photos'=>$photos,
            'videos'=>$videos

        ));
    }
    public function run() {

        $controller = $this->getController();
       
    	$id = (int)Yii::app()->request->getQuery('id',null);
        // check that you have access to this note
        $file = ObjectsImages::model()->findByPk($id);
        if(isset($file->objectid)){
           // $pin = $controller->_loadModel($file->pinboard->id);
            // remove it from disk also in model issueFile
           // if($file->delete()) {

                if(isset(Yii::app()->session['deleteObjectsFiles'])){
                	$sessAr = unserialize(Yii::app()->session['deleteObjectsFiles']);
                	if(isset($sessAr['id']) && $sessAr['id'] == $file->objectid->id && isset($sessAr['files']) && is_array($sessAr['files']))
                	{
                		$files = $sessAr['files'];
                		if(!in_array($id, $files))
                		{
                			$files[] = $id;
                		}
                		$sessAr = serialize(array('id'=>$file->objectid->id,'files'=>$files));
                		Yii::app()->session['deleteObjectsFiles'] = $sessAr;
                	
                	}
                } 
                else
                {
                	$sessAr = serialize(array('id'=>$file->objectid->id,'files'=>array($id)));
                	Yii::app()->session['deleteObjectsFiles'] = $sessAr;
                }
                echo "[]";
                Yii::app()->end();
           // }
        }
        echo 'error';
        Yii::app()->end();
    }
Exemple #3
0
 protected function beforeDelete()
 {
     if (!parent::beforeDelete()) {
         return false;
     }
     Comment::model()->updateAll(array('user_id' => 0), array('condition' => 'user_id=' . $this->id));
     ObjectsImages::model()->updateAll(array('uploaded_by' => null), array('condition' => 'uploaded_by=' . $this->id));
     Objects::model()->updateAll(array('author' => null), array('condition' => 'author=' . $this->id));
     $this->deleteModelDir();
     // удалили модель? удаляем и файл и всю папку
     return true;
 }
   public function actionObject($id){

        $id   = (int)$id;
        $model = ObjectsImages::model()->findByPk($id); 
        if(!$model)
            throw new CHttpException(404, Yii::t('site','Page not found'));

       // if(Yii::app()->user->isGuest && $model->issue->is_public !== true)
       //     Yii::app()->user->loginRequired();

        $available_mime = Yii::app()->params['mime_fileview'];

        $filename = $model->filename;
        $realname = $model->realname;

        $uploadPath = $model->objectid->getFileFolder();    

        if(file_exists($uploadPath.$filename )) {

            $type = CFileHelper::getMimeType($uploadPath.$filename); // get yii framework mime
            
            if(in_array($type, $available_mime)){

                //.. get the content of the requested file 
                $content=file_get_contents($uploadPath.$filename);
                //.. send appropriate headers
                header('Content-Type:' . $type);
                header("Content-Length: ". filesize($uploadPath.$filename));

                header('Content-Disposition: inline; filename="' . $realname . '"');
                header('Content-Transfer-Encoding: binary');
                header('Accept-Ranges: bytes');

                echo $content;
                exit; 
                
            } else {
                throw new CHttpException(404, Yii::t('site','Page not found'));
            }
        }
        else{
            throw new CHttpException(404, Yii::t('site','Page not found'));
        }   

    }
Exemple #5
0
<?php
if(!empty($pohs)){ ?>
<div class="row">
<div class="col-sm-12  col-md-10 col-md-offset-1">
<div class="rootCategory" style="font-size:18px;text-align:center;margin-bottom:18px;">
      ПОХОЖЕЕ
 </div>
<div class="card">
<div class="item-article-list three-column">

<?php 
foreach ($pohs as $poh) { 

$url = Yii::app()->createAbsoluteUrl('/fastreview/item', array( 'id'=>$poh->id, 'dash'=>'-', 'itemurl'=>$poh->url));

$imgs = ObjectsImages::model()->find(array('condition'=>'object='.$poh->id,'order'=>'date_uploaded, id'));

if($imgs)
{

 $src = $imgs->getUrl('320x320xT','adaptiveResizeQuadrant',false,'filename');
 } else {
    $src = '/img/cap.gif';
 }
    ?>
    <div class="article-bg-container" >
    <a href="<?php echo $url; ?>" class="article-bg  c-white t-uppercase text-center" style="background-image:url('<?php echo $src; ?>');">
     <div class="article_caption_title vertical-align-center p-l-20 p-r-20"><?php echo CHtml::encode($poh->title); ?></div>
    </a>
    </div>
<?php }
Exemple #6
0
    public function addDropboxFiles($uploadsession)
    {
        $files = $this->tmpFiles;
        $existFiles = count($this->images);
        $availableFiles = $this->maxFiles - $existFiles;
        $cnt = 0;
        if($files){

            if(Yii::app()->session->itemAt($uploadsession)){

                $folder='uploads'. DIRECTORY_SEPARATOR .'tmp'. DIRECTORY_SEPARATOR;

                $dataSession = Yii::app()->session->itemAt($uploadsession);
                

                foreach($files as $fileUploadName){

                    if(is_array($dataSession)){
                        foreach($dataSession as $key => $value){
                            if($fileUploadName == $key){
                                if(file_exists($folder.$value )) {

                                	if($cnt >= $availableFiles)	
                                		break 2;

                                    $file = $folder.$value;
                                    $ext = pathinfo($folder.$value, PATHINFO_EXTENSION);

                                    $base = md5(rand(1000,4000));
                                    $unique = $base.'_obj';
                                    $suffix = 1;

                                    while (file_exists($this->getFileFolder() . $unique . $ext)){
                                        $unique = $base.'_'.$suffix;
                                        $suffix++;
                                    }
                                    $filename =  $unique . '.' . $ext;
                                    $fullPath = $this->getFileFolder() . $filename;
                                    
                                    if (copy($folder.$value, $fullPath)) {
                                        unlink($folder.$value);
                                        $image = new ObjectsImages();
                                        $image->object = $this->getPrimaryKey();
                                        $image->filename = $filename;
                                        $image->realname = $key;

                                        Yii::import('ext.phpthumb.PhpThumbFactory');
										$thumb  = PhpThumbFactory::create($fullPath);
										$thumb->setOptions(array('jpegQuality'=>100));
										$thumb->resize(1500)->save($fullPath);

                                        $image->save();
                                        $cnt++;
                                        	
                                    } else {
                                       // throw new CHttpException(404, Yii::t('Site', 'Cannot copy file to folder.'));
                                    }
                                    

                                }
                            break;
                            }
                        }
                    }

                    
                }
            }
            
        }
    }
	public function actionIndex()
    {
        
        $this->main_page = true;
        
        if(!isset($_GET['city'])){
          $this->pageTitle = 'Каталог организаций России — Зазадун';
          $cr = new CDbCriteria;
         /* $cr->with = array('cityOther'=>array(
	            'condition'=>'(hh_city_id is not null or sj_city_id is not null)'
	            )
	        );
	        $cr->together = true; */
	        $cr->condition = '(pos>0 and pos<10000)';
	        $cr->order = 'title';
          	$cities = City::model()->cache(4000)->findAll($cr);
          	$this->layout = '//layouts/main';

           $this->render('main', array('cities'=>$cities));
        } else {
          $this->layout = '//layouts/zazadun';
          $this->pageTitle = 'Справочник-каталог — '.$this->city->rodpad;
           $roots = $cats = array();
          // $roots = Category::model()->cache(4000)->active()->findAll(array('condition'=>'lft=1', 'order'=>'t.title'));
    	     
          /* $criteria = new CDbCriteria;
           $criteria->select = 'category';
           $criteria->distinct = true;
           $criteria->condition = 'city_id='.$this->city->id .' and status_org=1';
           $cats = OrgsCategory::model()->findAll($criteria); */

           $cats =  Category::getRubsByParentId($this->city->id);
           $criteria = new CDbCriteria;
         $criteria->with = array(
         	'city'=>array(
	         	'condition'=>'city.id='.$this->city->id
	         	),
         	'images'
         	);
         $criteria->limit = 5;
         $criteria->condition = 't.part is null';
         $dataProvider = new CActiveDataProvider(Article::model()->active(), array(
                'criteria' => $criteria,
                'sort'=>array(
                    'defaultOrder' => 't.created_date DESC',
                ),
                'pagination' => false,
            ));
         // Load last comments
		 $comments = Comment::getLastComments(5, $this->city->id);
		 $lastImages = ObjectsImages::getLastImages(5, $this->city->id);
         $this->beginClip('cityheader');
         $this->renderPartial('_city_header_no_slider'); 
		 $this->endClip();


           $this->render('index', array(
            'roots'=>$roots,
            'cats'=>$cats,
            'dataProvider'=>$dataProvider,
            'comments'=>$comments,
            'lastImages'=>$lastImages
            ));
        }
    }
 public function actionDeleteFile($id)
 {
     $id = (int)$id;
     // check that you have access to this note
     $file = ObjectsImages::model()->findByPk($id);
     if(isset($file->objectid)){
         // remove it from disk also in model issueFile
         if($file->delete()) {
             echo "[]";
             Yii::app()->end();
         }
     }
     echo 'error';
     Yii::app()->end();
 }