Example #1
0
 /**
  * tries to create a new view
  */
 public function testCreate()
 {
     $viewObj = View::model()->findByPk(array('TABLE_SCHEMA' => 'viewtest', 'TABLE_NAME' => 'view1'));
     $createView = $viewObj->getCreateView();
     $this->assertType('string', $createView);
     $this->assertType('string', $viewObj->delete());
     $cmd = View::$db->createCommand($createView);
     $this->assertEquals(0, $cmd->execute());
     $viewObj = View::model()->findByPk(array('TABLE_SCHEMA' => 'viewtest', 'TABLE_NAME' => 'view1'));
     $this->assertType('View', $viewObj);
 }
 public function actionDelete()
 {
     if (isset($_POST['img'])) {
         $model = View::model()->findByAttributes(array('uid' => Yii::app()->user->id, 'photo' => $_POST['img']));
         if (is_object($model)) {
             if ($model->delete()) {
                 return true;
             }
         } else {
             return false;
         }
     } else {
         echo 'false';
     }
 }
Example #3
0
 public function preFilter($filter_chain)
 {
     if (is_null($this->model_id)) {
         throw new CException('Required model_id attribute!');
     }
     if (!Yii::app()->user->isGuest && ($id = Yii::app()->request->getParam('id'))) {
         $attributes = array('user_id' => Yii::app()->user->id, 'object_id' => $id, 'model_id' => $this->model_id);
         $exist = View::model()->existsByAttributes($attributes);
         if (!$exist) {
             $view = new View();
             $view->attributes = $attributes;
             if (!$view->save()) {
                 throw new CException("Can't save views");
             }
         }
     }
     return true;
 }
Example #4
0
<?php

$this->widget('application.extensions.tooltipster.tooltipster', array('identifier' => '#show_tooltip', 'options' => array('position' => 'bottom')));
foreach ($model as $item) {
    $c = StudioHals::model()->findByPk($item->portfolio_id);
    if ($c->picture == $item->file) {
        $chk = 'checked';
    } else {
        $chk = '';
    }
    $top = View::model()->findByAttributes(array('uid' => Yii::app()->user->id, 'photo' => $item->file));
    if (is_object($top)) {
        if ($top->photo == $item->file) {
            $class = 'cabinet__photo__item-selected';
            $del = 'yes';
        } else {
            $class = 'cabinet__photo__item-select';
            $del = 'no';
        }
    } else {
        $class = 'cabinet__photo__item-select';
        $del = 'no';
    }
    ?>
    <div class="data_<?php 
    echo $item->id;
    ?>
">
        <figure class="cabinet__photo__item2">
            <a href="/users/<?php 
    echo Yii::app()->user->id;
Example #5
0
              <?php 
            } else {
                ?>
              <a href="/id<?php 
                echo $data->id;
                ?>
/prices">Стоимость услуг</a>
              <?php 
            }
            ?>
            </div>
            <div class="clfx"></div>
            <?php 
            $top = View::model()->countByAttributes(array('uid' => $data->id));
            if ($top >= 4) {
                $top = View::model()->findAllBySql('select * from {{view}} where uid=' . $data->id . ' ORDER BY RAND() limit 4');
                $i = 1;
                foreach ($top as $file) {
                    $img = $file->photo;
                    $link_data = Files::model()->findBySql('select id, portfolio_id from {{files}} where uid=' . $data->id . ' and type="photo" and source="portfolio" and visible=1 and file="' . $img . '"');
                    $img_link = $this->createUrl('/user/album', array('id' => $link_data->portfolio_id)) . '?photo=photo' . $link_data->id;
                    if ($i == 4) {
                        if ($file->photo != '') {
                            //echo '<a href="/id'.$data->id.'" class="cat-photo-img__link last"><img class="cat-photo-img" src="/users/'.$data->id.'/370_'.$img.'" alt="'.$data->name.' - '.Occupation::getName($data->occupation_id).'"></a>';
                            echo '<a href="' . $img_link . '" class="cat-photo-img__link last"><img class="cat-photo-img" src="/users/' . $data->id . '/370_' . $img . '" alt="' . $data->name . ' - ' . Occupation::getName($data->occupation_id) . '"></a>';
                        } else {
                            echo '<a href="/id' . $data->id . '" class="cat-photo-img__link last"><img class="cat-photo-img" src="/img/zaglushka.png" alt="' . $data->name . ' - ' . Occupation::getName($data->occupation_id) . '"></a>';
                        }
                    } else {
                        if ($file->photo != '') {
                            //echo '<a href="/id'.$data->id.'" class="cat-photo-img__link"><img class="cat-photo-img" src="/users/'.$data->id.'/370_'.$img.'" alt="'.$data->name.' - '.Occupation::getName($data->occupation_id).'"></a>';
 public function actionVKatagorys($pk)
 {
     $Katagory = Katagory::model()->findByPk($pk);
     $Views = View::model()->findAll();
     $Menus = Menu::model()->findAll();
     if (isset($_POST['Katagory'])) {
         $Katagory->attributes = $_POST['Katagory'];
         if ($Katagory->save()) {
             $this->redirect(array('vkatagorys', 'pk' => $Katagory->id_katagory));
         }
     }
     $this->render('vkatagorys', array('Katagory' => $Katagory, 'Views' => $Views, 'Menus' => $Menus));
 }
Example #7
0
 /**
  * Exports all views of the given array and writes the dump to the output buffer.
  *
  * @param	array					list of views
  */
 private function exportViews($views)
 {
     // Get DbConnection object
     $db = Yii::app()->db;
     // Escape all view names
     $viewNames = array();
     foreach ($views as $view) {
         $viewNames[] = Yii::app()->db->quoteValue($view);
     }
     // Find all views
     $views = View::model()->findAll('TABLE_NAME IN (' . implode(',', $viewNames) . ') ' . 'AND TABLE_SCHEMA = ' . Yii::app()->db->quoteValue($this->schema));
     foreach ($views as $view) {
         $this->comment('View ' . $db->quoteTableName($view->TABLE_NAME));
         echo "\n\n";
         // Structure
         if ($this->settings['addDropObject']) {
             echo 'DROP VIEW IF EXISTS ', $db->quoteTableName($view->TABLE_NAME), ";\n";
         }
         echo $view->getCreateView(), ";\n\n";
     }
 }
Example #8
0
 /**
  * Loads the current view.
  *
  * @return	View
  */
 public function loadView()
 {
     if (is_null($this->_view)) {
         $pk = array('TABLE_SCHEMA' => $this->schema, 'TABLE_NAME' => $this->view);
         $this->_view = View::model()->findByPk($pk);
         $this->_view->columns = Column::model()->findAllByAttributes($pk);
         if (is_null($this->_view)) {
             throw new CHttpException(500, 'The requested view does not exist.');
         }
     }
     return $this->_view;
 }
Example #9
0
 /**
  * Lists all views.
  */
 public function actionViews()
 {
     $schema = $this->loadSchema();
     // Criteria
     $criteria = new CDbCriteria();
     $criteria->condition = 'TABLE_SCHEMA = :schema';
     $criteria->params = array(':schema' => $this->schema);
     if ($this->request->getParam('sideBar')) {
         $views = array();
         foreach (View::model()->findAll($criteria) as $view) {
             $views[] = array('viewName' => $view->TABLE_NAME);
         }
         $this->sendJSON($views);
     } else {
         // Pagination
         $pages = new Pagination(View::model()->count($criteria));
         $pages->setupPageSize('pageSize', 'schema.views');
         $pages->applyLimit($criteria);
         $pages->route = '#views';
         // Sort
         $sort = new CSort('View');
         $sort->attributes = array('name' => 'TABLE_NAME', 'updatable' => 'IS_UPDATABLE');
         $sort->route = '#views';
         $sort->applyOrder($criteria);
         // Load data
         $schema->views = View::model()->findAll($criteria);
         // Render
         $this->render('views', array('schema' => $schema, 'viewCount' => count($schema->views), 'pages' => $pages, 'sort' => $sort));
     }
 }
Example #10
0
 /**
  * Loads the current table.
  *
  * @return	Table
  */
 public function loadTable()
 {
     if (is_null($this->_table) && !is_null($this->table)) {
         $pk = array('TABLE_SCHEMA' => $this->schema, 'TABLE_NAME' => $this->table);
         $this->_table = Table::model()->findByPk($pk);
         if ($this->_table->TABLE_TYPE == "VIEW") {
             $this->_table = View::model()->findByPk($pk);
         }
         $this->_table->columns = Column::model()->findAllByAttributes($pk);
         if (is_null($this->_table)) {
             throw new CHttpException(500, 'The requested table does not exist.');
         }
     }
     return $this->_table;
 }
Example #11
0
        
        <main class="cabinet__portfolio">
          <header class="cabinet__portfolio__title clfx">
            <div class="col-4 albom-name"><a href="/my/video">все альбомы</a></div>
            <div class="col-4"><h3><?php 
echo $model->title;
?>
</h3></div>
            <div class="col-4 albom-edit"><!--i></i><a href="/my/portfolio/update/id/<?php 
echo $model->id;
?>
">Редактировать альбом</a--></div>
          </header>
              <div class="col-9 cabinet__portfolio__select4-photo">
                <?php 
$top = View::model()->countByAttributes(array('uid' => Yii::app()->user->id));
if ($top < 4) {
    ?>
 
                <a href="#">Выберите любые 4-е фотографии из любых альбомов для главной страницы</a>
                <?php 
}
?>
              </div>
              <div class="col-3 cabinet__portfolio__add-photo cabinet__portfolio__add-photo">      
                <div class="col-12 global__plus__btn-container">
                    <a href="#" class="global__plus__btn add_video" data-toggle="modal" data-target="#__accaunt_video"><i></i><span>Добавить видео</span></a>
                    
                    <div class="modal fade" id="__accaunt_video" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                      <div class="modal-dialog">
                        <div class="modal-content" style="text-align: center;">
Example #12
0
    }
});
</script>
</figure>
<?php 
} elseif ($str['host'] == 'vimeo.com') {
    if (isset($path[3])) {
        $code = $path[3];
    } else {
        $code = $path[1];
    }
    if ($xml = simplexml_load_file('http://vimeo.com/api/v2/video/' . $code . '.xml')) {
        //$image = $xml->video->thumbnail_large ? (string) $xml->video->thumbnail_large: (string) $xml->video->thumbnail_medium;
        $image = $xml->video->thumbnail_medium;
    }
    $top = View::model()->findByAttributes(array('uid' => Yii::app()->user->id, 'photo' => 'video_' . $code . '.jpg'));
    if (is_object($top)) {
        if ($top->photo == 'video_' . $code . '.jpg') {
            $class = 'cabinet__video__item-selected';
            $del = 'yes';
        } else {
            $class = 'cabinet__photo__item-select';
            $del = 'no';
        }
    } else {
        $class = 'cabinet__video__item-select';
        $del = 'no';
    }
    ?>
<figure class="cabinet__video__item data_<?php 
    echo $data->id;
 /**
  * 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 View the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = View::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function actionVisible($id)
 {
     $m = $this->loadModel($id);
     if ($m->uid == Yii::app()->user->id) {
         if ($m->visible == 1) {
             $m->visible = 0;
             View::model()->deleteAllByAttributes(array('uid' => $m->uid, 'photo' => $m->file));
             $cover = Portfolio::model()->findBySql('select id from {{portfolio}} where uid=:uid and picture=:pic', array('uid' => $m->uid, 'pic' => $m->file));
             Portfolio::model()->updateByPk($cover->id, array('picture' => ''));
         } elseif ($m->visible == 0) {
             $m->visible = 1;
         }
         if ($m->save()) {
             $this->redirect($_GET['back']);
         }
     } else {
         throw new CHttpException(404, 'The requested album does not exist.');
     }
 }