Beispiel #1
0
 public function actionImport_csv($page_id = null, $id = null)
 {
     if (!is_null($page_id) && Pages::model()->existsPage($page_id)) {
         die;
         $mpage_id = ModulesInPages::model()->getLink($page_id, $this->module->id);
         $params = ModuleYmaps::model()->getList(3);
         foreach ($params as $k => $v) {
             $model = new ModuleList4();
             $model->attributes = array('date' => date('Y-m-d'), 'title' => $v->title, 'latitude' => $v->latitude, 'longitude' => $v->longitude, 'active' => $v->active, 'order_id' => $v->order_id, 'mpage_id' => $mpage_id);
             $model->save();
             $new_id = $model->id;
             // адрес
             if (ModuleYmapsValues::model()->existsItem(24, $v->id)) {
                 $old_value = ModuleYmapsValues::model()->getItem(24, $v->id);
                 $value = new ModuleList4Values();
                 $value->attributes = array('param_id' => 287, 'item_id' => $new_id, 'value' => $old_value->value);
                 $value->save();
             }
             // время раюоты
             if (ModuleYmapsValues::model()->existsItem(1, $v->id)) {
                 $old_value = ModuleYmapsValues::model()->getItem(1, $v->id);
                 $value = new ModuleList4Values();
                 $value->attributes = array('param_id' => 288, 'item_id' => $new_id, 'value' => $old_value->value);
                 $value->save();
             }
             // фото
             if (ModuleYmapsValues::model()->existsItem(25, $v->id)) {
                 $old_value = ModuleYmapsValues::model()->getItem(25, $v->id);
                 $value = new ModuleList4Values();
                 $value->attributes = array('param_id' => 289, 'item_id' => $new_id, 'value' => $old_value->value);
                 $value->save();
                 $img_id = (int) $old_value->value;
                 if ($img_id > 0 && Files::model()->existsFile($img_id)) {
                     $file = Files::model()->findByPk($img_id);
                     $file->attributes = array('module' => 'list4');
                     $file->save();
                 }
             }
             // схема
             if (ModuleYmapsValues::model()->existsItem(26, $v->id)) {
                 $old_value = ModuleYmapsValues::model()->getItem(26, $v->id);
                 $value = new ModuleList4Values();
                 $value->attributes = array('param_id' => 290, 'item_id' => $new_id, 'value' => $old_value->value);
                 $value->save();
                 $img_id = (int) $old_value->value;
                 if ($img_id > 0 && Files::model()->existsFile($img_id)) {
                     $file = Files::model()->findByPk($img_id);
                     $file->attributes = array('module' => 'list4');
                     $file->save();
                 }
             }
         }
         echo 'done';
         /*
         // перенос видео
         // $youtube = file_get_contents('http://gdata.youtube.com/feeds/api/videos?max-results=50&alt=json&author=permopera');
         $youtube = file_get_contents('http://gdata.youtube.com/feeds/api/videos?max-results=50&start-index=51&alt=json&author=permopera');
         $youtube = json_decode($youtube);
         echo '<pre>';
         print_r($youtube->feed->entry);
         $i = 0;
         foreach($youtube->feed->entry as $value){
         	$url = '';
         	foreach($value->id as $key2 => $value2){
         		$value2 = explode('/',$value2);
         		$value2 = $value2[count($value2)-1];
         		$url = 'https://www.youtube.com/watch?v='.$value2;
         	}
         	// echo ', ';
         	$date = date('Y-m-d');
         	foreach($value->published as $key2 => $value2){
         		$value2 = explode('T',$value2);
         		$value2 = $value2[0];
         		$date = $value2;
         	}
         	// echo ', ';
         	$title = '';
         	foreach($value->title as $key2 => $value2){
         		$title = $value2;
         		break;
         	}
         	// echo ', ';
         	$content = '';
         	foreach($value->content as $key2 => $value2){
         		$content = $value2;
         		break;
         	}
         	// echo '<br>';
         	$criteria = new CDbCriteria();
         	$criteria->condition = 'mpage_id = :mpage_id AND video = :video';
         	$criteria->params = array('mpage_id' => 15, 'video' => $url);
         	if(ModuleVideo::model()->count($criteria)==0){
         		$video = new ModuleVideo();
         		$video->attributes = array(
         			'date' => $date,
         			'title' => $title,
         			'video' => $url,
         			'preview' => $content,
         			'active' => 1,
         			'mpage_id' => 15
         		);
         		print_r(array(
         			'date' => $date,
         			'title' => $title,
         			'video' => $url,
         			'preview' => $content,
         			'active' => 1,
         			'mpage_id' => 15
         		));
         		$video->save();
         		$i++;
         	}
         }
         echo '</pre>';
         echo $i;
         */
         die;
         $mpage_id = ModulesInPages::model()->getLink($page_id, $this->module->id);
         $host = '192.168.0.2';
         $user = '******';
         $pwd = '';
         $db = mysql_connect($host, $user, $pwd);
         mysql_select_db("operaold", $db);
         // $spektakl_id_where_people_with_more_than_1_id = array();
         $sql = "\n\t\t\t\tSELECT id, type, published, scenario, director, notes FROM ds_performances\n\t\t\t";
         $sqlres = mysql_query($sql) or die("Query failed: " . $sql);
         while ($row = mysql_fetch_array($sqlres)) {
             /*
             // обновление данных о репертуаре
             $reper = ModuleList4::model()->findByAttributes(array(
             	'old_info_1' => $row['id'],
             	'mpage_id' => $mpage_id
             ));
             $id = $reper->id;
             if($row['published']=='n'){
             	$reper->attributes = array('active' => 0);
             	$reper->save();
             }
             
             $model = new ModuleList4Values();
             $model->attributes = array(
             	'param_id' => 79,
             	'item_id' => $id,
             	'value' => iconv('cp1251', 'utf-8', $row['scenario'])
             );
             $model->save();
             
             $director = iconv('cp1251', 'utf-8', $row['director']);
             $director = explode(',', $director);
             foreach($director as $k => $d){
             		$director[$k] = trim($d);
             }
             foreach($director as $k => $d){
             
             	$people_id = array();
             	$criteria = new CDbCriteria();
             	$criteria->condition = 'title = :title';
             	$criteria->params = array('title' => $d);
             	foreach(ModuleList4::model()->findAll($criteria) as $value){
             		$people_id[] = $value->id;
             	}
             	if(count($people_id)){
             		if(count($people_id)>1){
             			$spektakl_id_where_people_with_more_than_1_id[] = $id;
             		}
             		foreach($people_id as $value){
             			// сохраняем постановщика для существующих людей в БД
             			$model = new ModuleList4List4();
             			$model->attributes = array(
             				'id_1' => $id,
             				'id_2' => $value
             			);
             			$model->save();
             		}
             		unset($director[$k]);
             	}
             }
             if(count($director)){
             	$model = new ModuleList4Values();
             	$model->attributes = array(
             		'param_id' => 93,
             		'item_id' => $id,
             		'value' => implode(', ', $director)
             	);
             	$model->save();
             }else{
             	$model = new ModuleList4Values();
             	$model->attributes = array(
             		'param_id' => 93,
             		'item_id' => $id,
             		'value' => ''
             	);
             	$model->save();
             }
             
             $value_old = $row['type'];
             if($value_old>2){
             	$sql2 = "SELECT * FROM ds_perfom_types WHERE id = $value_old";
             	$sqlres2 = mysql_query($sql2) or die("Query failed: ".$sql2);
             	while ($row2 = mysql_fetch_array($sqlres2)){
             		$model = new ModuleList4Values();
             		$model->attributes = array(
             			'param_id' => 101,
             			'item_id' => $id,
             			'value' => iconv('cp1251', 'utf-8', $row2['type_name'])
             		);
             		$model->save();
             	}
             }
             */
             /*
             			// перенос афиши
             			$mpage_id_spek = ModulesInPages::model()->getLink(50, $this->module->id);
             			$mpage_id_afi = ModulesInPages::model()->getLink(8, $this->module->id);
             			$mpage_id_rep = 17;
             			$sql = "
             SELECT * FROM ds_playbill ORDER BY date ASC, timeb ASC
             			";
             			$sqlres = mysql_query($sql) or die("Query failed: ".$sql);
             			$spektakl_id_where_people_with_more_than_1_id = array();
             			while ($playbill = mysql_fetch_array($sqlres)){
             $repertuar = ModuleList4::model()->findByAttributes(array(
             	'old_info_1' => iconv('cp1251', 'utf-8', $playbill['category_id']),
             	'mpage_id' => $mpage_id_rep,
             ));
             $repertuar_id = $repertuar->id;
             
             $date = new DateTime($playbill['date']);
             // echo $repertuar->title,' (',$date->format('d.m.Y'),' в ',$playbill['timeb'],')<br><ul>';
             
             // сохраняем спектакль
             $spektakl = new ModuleList4();
             $spektakl->attributes = array(
             	'date' => $playbill['date'],
             	'title' => $repertuar->title.' ('.$date->format('d.m.Y').' в '.$playbill['timeb'].')',
             	'old_info_1' => iconv('cp1251', 'utf-8', $playbill['id']),
             	'old_info_2' => iconv('cp1251', 'utf-8', $playbill['category_id']),
             	'old_info_3' => iconv('cp1251', 'utf-8', $playbill['page_id']),
             	'active' => 1,
             	'mpage_id' => $mpage_id_spek
             );
             $spektakl->save();
             $spektakl_id = $spektakl->id;
             // связь с репертуаром
             $model = new ModuleList4List4();
             $model->attributes = array(
             	'id_1' => $spektakl_id,
             	'id_2' => $repertuar_id
             );
             $model->save();
             
             $sql2 = "
             	SELECT * FROM ds_roles_playbill WHERE category_id = ".$playbill['id']."
             ";
             $sqlres2 = mysql_query($sql2) or die("Query failed: ".$sql2);
             $role_arr = array();
             while ($role_playbill = mysql_fetch_array($sqlres2)){
             	$sql3 = "
             		SELECT * FROM ds_truppa WHERE id = ".$role_playbill['actor_id']."
             	";
             	$sqlres3 = mysql_query($sql3) or die("Query failed: ".$sql3);
             	while ($actor = mysql_fetch_array($sqlres3)){
             		$actor_fio = trim(iconv('cp1251', 'utf-8', $actor['fio']));
             		if(!isset($role_arr[$actor_fio])){
             			$role_arr[$actor_fio] = array(
             				'text' => array(),
             				'people_id' => array()
             			);
             			$criteria = new CDbCriteria();
             			$criteria->condition = 'title = :title';
             			$criteria->params = array('title' => $actor_fio);
             			foreach(ModuleList4::model()->findAll($criteria) as $value){
             				$role_arr[$actor_fio]['people_id'][] = $value->id;
             			}
             		}
             	}
             	
             	$sql3 = "
             		SELECT * FROM ds_roles WHERE id = ".$role_playbill['rep_id']."
             	";
             	$sqlres3 = mysql_query($sql3) or die("Query failed: ".$sql3);
             	while ($role = mysql_fetch_array($sqlres3)){
             		$role_arr[$actor_fio]['text'][] = iconv('cp1251', 'utf-8', $role['name']);
             	}
             }
             $others = array();
             foreach($role_arr as $actor_fio => $value){
             	// echo '<li>',implode(', ',$value['people_id']),' : ',$actor_fio,' - ',implode(', ',$value['text']),'</li>';
             	if(count($value['people_id'])){
             		if(count($value['people_id'])>1){
             			$spektakl_id_where_people_with_more_than_1_id[] = $spektakl_id;
             		}
             		foreach($value['people_id'] as $people_id){
             			// сохраняем роли для существующих людей в БД
             			$model = new ModuleList4List4();
             			$model->attributes = array(
             				'id_1' => $spektakl_id,
             				'id_2' => $people_id,
             				'text1' => implode(', ',$value['text'])
             			);
             			$model->save();
             		}
             	}else{
             		$others[] = $actor_fio.' — '.implode(', ',$value['text']);
             	}
             }
             
             // сохраняем других людей
             $others = implode("\r\n",$others);
             $model = new ModuleList4Values();
             $model->attributes = array(
             	'param_id' => 96,
             	'item_id' => $spektakl_id,
             	'value' => $others
             );
             $model->save();
             
             // echo '<li>',$others,'</li>';
             // echo '</ul>';
             
             // сохраняем афишу
             $afisha = new ModuleList4();
             $afisha->attributes = array(
             	'date' => $playbill['date'],
             	'title' => $repertuar->title,
             	'old_info_1' => iconv('cp1251', 'utf-8', $playbill['id']),
             	'old_info_2' => iconv('cp1251', 'utf-8', $playbill['category_id']),
             	'old_info_3' => iconv('cp1251', 'utf-8', $playbill['page_id']),
             	'active' => 1,
             	'mpage_id' => $mpage_id_afi
             );
             $afisha->save();
             $afisha_id = $afisha->id;
             // время начала
             $model = new ModuleList4Values();
             $model->attributes = array(
             	'param_id' => 86,
             	'item_id' => $afisha_id,
             	'value' => $playbill['timeb']
             );
             $model->save();
             // время окончания
             $model = new ModuleList4Values();
             $model->attributes = array(
             	'param_id' => 87,
             	'item_id' => $afisha_id,
             	'value' => $playbill['timee']
             );
             $model->save();
             // связь со спектаклем
             $model = new ModuleList4List4();
             $model->attributes = array(
             	'id_1' => $afisha_id,
             	'id_2' => $spektakl_id
             );
             $model->save();
             */
             /*
             				// перенос репертуара
             				$model = new ModuleList4();
             				$model->attributes = array(
             					'date' => date('Y-m-d'),
             					'title' => iconv('cp1251', 'utf-8', $row['name']),
             					'short' => iconv('cp1251', 'utf-8', $row['desc']),
             					'text' => iconv('cp1251', 'utf-8', $row['notes']),
             					'old_info_1' => iconv('cp1251', 'utf-8', $row['id']),
             					'old_info_2' => iconv('cp1251', 'utf-8', $row['type']),
             					'old_info_3' => iconv('cp1251', 'utf-8', $row['page_id']),
             					'active' => 1,
             					'mpage_id' => $mpage_id
             				);
             				$model->save();
             				$id = $model->id;
             				
             				$model = new ModuleList4Values();
             				$model->attributes = array(
             					'param_id' => 93,
             					'item_id' => $id,
             					'value' => iconv('cp1251', 'utf-8', $row['scenario'])."\r\n".iconv('cp1251', 'utf-8', $row['director'])
             				);
             				$model->save();
             				
             				$value_old = iconv('cp1251', 'utf-8', $row['type']);
             				if(in_array($value_old, array(1,4,6,10,13,15))) $value = 57;
             				elseif(in_array($value_old, array(2,7,8,9))) $value = 58;
             				else $value = 0;
             				if($value>0){
             					//тип постановки 57 опера /58 балет
             					$model = new ModuleList4Values();
             					$model->attributes = array(
             						'param_id' => 80,
             						'item_id' => $id,
             						'value' => $value
             					);
             					$model->save();
             				}
             				if($value_old>2){
             					$sql2 = "SELECT * FROM ds_perfom_types WHERE id = $value_old";
             					$sqlres2 = mysql_query($sql2) or die("Query failed: ".$sql2);
             					while ($row2 = mysql_fetch_array($sqlres2)){
             						$model = new ModuleList4Values();
             						$model->attributes = array(
             							'param_id' => 101,
             							'item_id' => $id,
             							'value' => $row2['type_name']
             						);
             						$model->save();
             					}
             				} */
             /*
             				// перенос подписчиков
             				$model = new ModuleList4();
             				$model->attributes = array(
             					'date' => iconv('cp1251', 'utf-8', $row['date']),
             					'title' => iconv('cp1251', 'utf-8', $row['tel']),
             					'short' => iconv('cp1251', 'utf-8', $row['fio']),
             					'active' => 1,
             					'mpage_id' => $mpage_id_sms
             				);
             				$model->save();
             				$id_1 = $model->id;
             				
             				$model = new ModuleList4();
             				$model->attributes = array(
             					'date' => iconv('cp1251', 'utf-8', $row['date']),
             					'title' => iconv('cp1251', 'utf-8', $row['mail']),
             					'short' => iconv('cp1251', 'utf-8', $row['fio']),
             					'active' => 1,
             					'mpage_id' => $mpage_id_mail
             				);
             				$model->save();
             				$id_2 = $model->id;
             				
             				$model = new ModuleList4List4();
             				$model->attributes = array(
             					'id_1' => $id_1,
             					'id_2' => $id_2
             				);
             				$model->save(); */
             // $sugar_name = iconv('cp1251', 'utf-8', $row['name']);
             /* echo iconv('cp1251', 'utf-8', $row['fio']);
             			echo iconv('cp1251', 'utf-8', $row['tel']);
             			echo iconv('cp1251', 'utf-8', $row['mail']);
             			echo iconv('cp1251', 'utf-8', $row['date']); */
         }
         /*
         // перенос афиши
         $spektakl_id_where_people_with_more_than_1_id = array_unique($spektakl_id_where_people_with_more_than_1_id);
         foreach($spektakl_id_where_people_with_more_than_1_id as $id){
         	echo '<a href="/admin.php?r=/list4/main/update&page_id=9&id='.$id.'#!/tab_second">Репертуар ID: '.$id.'</a><br>';
         }
         */
         mysql_close();
     } else {
         $this->redirect(Yii::app()->request->scriptUrl);
     }
 }
Beispiel #2
0
 /**
  *
  * @param type $mpage_id
  * @param type $offset
  * @param type $limit
  * @param type $active
  * @return type 
  */
 public function getList($mpage_id, $offset = 0, $limit = 0, $active = NULL, $points = NULL)
 {
     $data = array();
     $criteria = new CDbCriteria();
     if (!is_null($active)) {
         $criteria->condition = 'mpage_id = :mpage_id AND active = :active';
         $criteria->params = array('mpage_id' => $mpage_id, 'active' => $active);
     } else {
         $criteria->condition = 'mpage_id = :mpage_id';
         $criteria->params = array('mpage_id' => $mpage_id);
     }
     $criteria->offset = floor($offset);
     $criteria->order = 'title ASC';
     if ($limit != 0) {
         $criteria->limit = floor($limit);
     }
     foreach ($this->findAll($criteria) as $value) {
         $data[$value->id] = $value;
         if (!is_null($points) && $points) {
             $data[$value->id]->points = ModuleYmaps::model()->getList($value->id, $active);
         }
     }
     return $data;
 }
Beispiel #3
0
 /**
  * Снятие с публикации группы точек
  * @param integer $page_id ID страницы
  * @param integer $id ID категории
  */
 public function actionDeactivate_point($page_id = 0, $category_id = 0, $id = 0)
 {
     $page_id = (int) $page_id;
     if ($page_id > 0 && Pages::model()->existsPage($page_id)) {
         $link_id = ModulesInPages::model()->getLink((int) $page_id, $this->module->id);
         if ($category_id > 0 && $id > 0 && ModuleYmapsCategories::model()->existsItem($link_id, $category_id) && ModuleYmaps::model()->existsItem($category_id, $id)) {
             ModuleYmaps::model()->updateByPk($id, array('active' => 0));
         }
         $this->redirect(Yii::app()->baseUrl . '?r=' . $this->module->id . '/main/update&page_id=' . $page_id . '&id=' . $category_id . '');
     } else {
         $this->redirect(Yii::app()->request->scriptUrl);
     }
 }