Beispiel #1
0
 public static function generate()
 {
     // Там еще в сайтмепе есть приоритетность. Для главной ставим самую высокую, для всех категорий чуть ниже и последняя приоритетность для постов
     //Создает XML-строку и XML-документ при помощи DOM
     $dom = new DomDocument('1.0');
     //добавление корня - <books>
     $urlset = $dom->appendChild($dom->createElement('urlset'));
     $urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     // Главная страница
     $url = $urlset->appendChild($dom->createElement('url'));
     $loc = $url->appendChild($dom->createElement('loc'));
     $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME']));
     $priority = $url->appendChild($dom->createElement('priority'));
     $priority->appendChild($dom->createTextNode('1.0'));
     // Категории фото
     $categoryPhoto = CategoryPhoto::find()->all();
     foreach ($categoryPhoto as $category) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/category/photo/" . $category->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.7'));
     }
     // Категории видео
     $categoryVideo = Category::find()->all();
     foreach ($categoryVideo as $category) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/category/video/" . $category->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.7'));
     }
     // Страницы фото
     $photoCatalog = PhotoCatalog::find()->where('publish = 1')->all();
     foreach ($photoCatalog as $photo) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/photo/" . $photo->category->url . "/" . $photo->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.5'));
     }
     // Страницы видео
     $videos = Video::find()->where('publish = 1')->all();
     foreach ($videos as $video) {
         $url = $urlset->appendChild($dom->createElement('url'));
         $loc = $url->appendChild($dom->createElement('loc'));
         $loc->appendChild($dom->createTextNode("http://" . $_SERVER['SERVER_NAME'] . "/video/" . $video->category->url . "/" . $video->url));
         $priority = $url->appendChild($dom->createElement('priority'));
         $priority->appendChild($dom->createTextNode('0.5'));
     }
     //генерация xml
     $dom->formatOutput = true;
     // установка атрибута formatOutput
     // domDocument в значение true
     // save XML as string or file
     //$test1 = $dom->saveXML(); // передача строки в test1
     $dom->save('../web/sitemap.xml');
     // сохранение файла
 }
 public function actionView($url)
 {
     $model = PhotoCatalog::find()->where("url = :url && publish = 0", [':url' => $url])->one();
     if ($model == null) {
         throw new HttpException(404);
     }
     return $this->render('/photo/view', ['model' => $model]);
 }
Beispiel #3
0
 public function beforeDelete()
 {
     $photos = PhotoCatalog::find()->where('category_id = :category_id', [':category_id' => $this->id])->all();
     foreach ($photos as $photo) {
         $photo->delete();
     }
     return parent::beforeDelete();
     // TODO: Change the autogenerated stub
 }
Beispiel #4
0
 public function run()
 {
     $model = null;
     if ($this->type == 'video') {
         $model = Video::find()->where('id <> :id && publish = 1', [':id' => $this->currentId])->orderBy('RAND()')->limit(3)->all();
     } else {
         $model = PhotoCatalog::find()->where('id <> :id && publish = 1', [':id' => $this->currentId])->orderBy('RAND()')->limit(4)->all();
     }
     return $this->render($this->type == 'video' ? 'randomize_video' : 'randomize_photo', ['model' => $model]);
 }
Beispiel #5
0
 public function actionView($url)
 {
     $model = PhotoCatalog::find()->where("url = :url && publish = 1", [':url' => $url])->one();
     if ($model == null) {
         throw new HttpException(404);
     }
     // счетчик показов
     $model->updateCounters(['hits' => 1]);
     return $this->render('view', ['model' => $model]);
 }
Beispiel #6
0
 public function run()
 {
     if ($this->type == 'video') {
         $model = Video::find()->orderBy('hits DESC')->limit(5)->all();
     }
     if ($this->type == 'photo') {
         $model = PhotoCatalog::find()->orderBy('hits DESC')->limit(5)->all();
     }
     return $this->render('teaser', ['model' => $model, 'type' => $this->type]);
 }
Beispiel #7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PhotoCatalog::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     if (!Yii::$app->user->can('admin')) {
         $query->andFilterWhere(['block_edit' => 0]);
     }
     $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'create_at' => $this->create_at, 'update_at' => $this->update_at, 'plus' => $this->plus, 'minus' => $this->minus, 'hits' => $this->hits]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]);
     $query->orderBy('id DESC');
     return $dataProvider;
 }
Beispiel #8
0
 public function actionIndex($type, $url)
 {
     if ($type != 'photo' && $type != 'video') {
         throw new HttpException(404);
     }
     if ($type == 'video') {
         $category = Category::find()->where('url = :url', [':url' => $url])->one();
     }
     if ($type == 'photo') {
         $category = CategoryPhoto::find()->where('url = :url', [':url' => $url])->one();
     }
     if ($category == null) {
         throw new HttpException(404);
     }
     if ($type == 'video') {
         $videos = Video::find()->where('category_id = :category_id && publish = :publish', [':category_id' => $category->id, ':publish' => 1])->orderBy('id DESC')->all();
         return $this->render('video', ['videos' => $videos, 'category' => $category]);
     }
     if ($type == 'photo') {
         $photo = PhotoCatalog::find()->where('category_id = :category_id && publish = :publish', [':category_id' => $category->id, ':publish' => 1])->orderBy('id DESC')->all();
         return $this->render('photo', ['photos' => $photo, 'category' => $category]);
     }
 }
 /**
  * Finds the PhotoCatalog model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return PhotoCatalog the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = PhotoCatalog::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #10
0
 public function actionIndex()
 {
     $videos = Video::find()->where('publish = :publish', [":publish" => 1])->orderBy('id DESC')->limit(9)->all();
     $photos = PhotoCatalog::find()->where('publish = :publish', [":publish" => 1])->orderBy('id DESC')->limit(12)->all();
     return $this->render('index', ['videos' => $videos, 'photos' => $photos]);
 }
Beispiel #11
0
echo \app\components\widgets\AdsWidget::widget(['url' => '/main/video']);
?>
        <!-- /ads -->

    </div>
    <!-- gallery -->

    <!-- subscription -->
   <?php 
echo \app\components\widgets\SubscriptionWidget::widget([]);
?>
    <!-- subscription -->

    <div class="c-c">
        <?php 
$photoSet = \app\models\PhotoCatalog::find()->count("*");
?>
        <div class="c">
            <p class="fs24 fw300 text-center opensans"><a class="pink" href="/photo" title="Эксклюзивные порно фото и видео в HD качестве!">Смотреть <span class="fw700"><?php 
echo $photoSet;
?>
+</span> фотосетов <span class="fw700">в лучшем качестве</span></a></p>
        </div>

        <!-- menu -->
       <?php 
echo \app\components\widgets\CategoryWidget::widget(['type' => 'photo']);
?>
        <!-- menu -->

        <!-- intro text -->
Beispiel #12
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCatalog()
 {
     return $this->hasOne(PhotoCatalog::className(), ['id' => 'catalog_id']);
 }
Beispiel #13
0
 public function actionIndex()
 {
     $videos = Video::find()->where("create_at > (now() - interval 7 day) && publish = 1")->orderBy('id DESC')->all();
     $photos = PhotoCatalog::find()->where("create_at > (now() - interval 7 day) && publish = 1")->orderBy('id DESC')->all();
     return $this->render('index', ['videos' => $videos, 'photos' => $photos]);
 }