示例#1
0
文件: Tags.php 项目: ph7pal/wedding
 public static function findAndAdd($title, $classify, $logid)
 {
     $title = zmf::filterInput($title, 't', 1);
     if (!$title) {
         return false;
     }
     $info = Tags::model()->find('title=:title AND classify=:classify', array(':title' => $title, ':classify' => $classify));
     if (!$info) {
         if (Yii::app()->session['checkHasBadword'] == 'yes') {
             $status = Posts::STATUS_STAYCHECK;
         } else {
             $status = Posts::STATUS_PASSED;
         }
         unset(Yii::app()->session['checkHasBadword']);
         $_data = array('title' => $title, 'name' => tools::pinyin($title), 'classify' => $classify, 'status' => $status, 'cTime' => time(), 'length' => mb_strlen($title, 'GBK'));
         $modelB = new Tags();
         $modelB->attributes = $_data;
         if ($modelB->save()) {
             $tagid = $modelB->id;
         }
     } else {
         $tagid = $info['id'];
     }
     if ($tagid && $logid) {
         $_info = TagRelation::model()->find('tagid=:tagid AND logid=:logid AND classify=:classify', array(':tagid' => $tagid, ':logid' => $logid, ':classify' => $classify));
         if (!$_info) {
             $_tagre = array('tagid' => $tagid, 'logid' => $logid, 'classify' => $classify, 'cTime' => zmf::now());
             $modelC = new TagRelation();
             $modelC->attributes = $_tagre;
             $modelC->save();
         }
     }
     return $tagid;
 }
示例#2
0
 /**
  * 获取 Taglist 标签列表内容
  */
 public function actionTaglist()
 {
     $Rolelist = Tags::model();
     $cri = new CDbCriteria();
     $total = $Rolelist->count($cri);
     $pager = new CPagination($total);
     $pager->pageSize = 10;
     $pager->applyLimit($cri);
     $Infolist = $Rolelist->findAll($cri);
     $this->render('tag_list', array('taglist' => $Infolist, 'Pagers' => $pager));
 }
示例#3
0
 /**
  * Конструктор
  * @return bool
  */
 protected function beforeAction()
 {
     $this->layout = 'start_page';
     $this->topMenu = Mainmenu::getMenu('top', 'site');
     $this->middleMenu = Mainmenu::getMenu('middle', 'site');
     $this->listChat = Chat::getListChat();
     $this->randomArt = Articles::getRandomArticles(10);
     $this->tags = Tags::getMenu(Tags::model()->findAll());
     $settingChat = Settings::model()->findByAttributes(array('parameter' => Yii::app()->params['parameter']['chat']));
     $this->stateChat = null != $settingChat ? (int) $settingChat->value : 0;
     if (!Yii::app()->user->isGuest) {
         $this->_user = Users::model()->findByPk(Yii::app()->user->id);
     } else {
         $this->_loginModel = new LoginForm();
     }
     return true;
 }
示例#4
0
 public function actionCreate($id = '')
 {
     $this->checkPower('addTag');
     if ($id) {
         $model = Tags::model()->findByPk($id);
         if (!$model) {
             $this->message(0, '该标签不存在');
         }
     } else {
         $model = new Tags();
         $model->classify = 'posts';
     }
     if (isset($_POST['Tags'])) {
         $model->attributes = $_POST['Tags'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
示例#5
0
 /**
  * 检查传入的标签是否已存在,不存在则创建,并检查是否已存在对应关系,不存在则创建
  * @param type $id
  * @param type $crumb
  */
 public function checkAndWriteTag($id, $crumb, $tagid = 0)
 {
     if (!$tagid) {
         $_crumb = strip_tags(trim($crumb));
         $_taginfo = Tags::model()->find('title=:title', array(':title' => $_crumb));
         if (!$_taginfo) {
             $_tagdata = array('title' => $_crumb, 'name' => zmf::pinyin($_crumb), 'classify' => 'posts', 'cTime' => time(), 'status' => 1);
             $model_tag = new Tags();
             $model_tag->attributes = $_tagdata;
             $_tagid = $model_tag->save(false);
         } else {
             $_tagid = $_taginfo['id'];
         }
     } else {
         $_tagid = $tagid;
     }
     $_tagrel = array('logid' => $id, 'tagid' => $_tagid, 'classify' => 'posts');
     $reinfo = TagRelation::model()->find('logid=:logid AND tagid=:tagid AND classify="posts"', array(':logid' => $id, ':tagid' => $_tagid));
     if (!$reinfo) {
         $model_tagrel = new TagRelation();
         $model_tagrel->attributes = $_tagrel;
         $model_tagrel->save(false);
     }
 }
 /**
  * Save a product in the database (Create if need be)
  *
  * @param string $passkey
  * @param int $intRowid
  * @param string $strCode
  * @param string $strName
  * @param string $blbImage
  * @param string $strClassName
  * @param int $blnCurrent
  * @param string $strDescription
  * @param string $strDescriptionShort
  * @param string $strFamily
  * @param int $blnGiftCard
  * @param int $blnInventoried
  * @param double $fltInventory
  * @param double $fltInventoryTotal
  * @param int $blnMasterModel
  * @param int $intMasterId
  * @param string $strProductColor
  * @param string $strProductSize
  * @param double $fltProductHeight
  * @param double $fltProductLength
  * @param double $fltProductWidth
  * @param double $fltProductWeight
  * @param int $intTaxStatusId
  * @param double $fltSell
  * @param double $fltSellTaxInclusive
  * @param double $fltSellWeb
  * @param string $strUpc
  * @param int $blnOnWeb
  * @param string $strWebKeyword1
  * @param string $strWebKeyword2
  * @param string $strWebKeyword3
  * @param int $blnFeatured
  * @param string $strCategoryPath
  * @return string
  */
 public function save_product($passkey, $intRowid, $strCode, $strName, $blbImage, $strClassName, $blnCurrent, $strDescription, $strDescriptionShort, $strFamily, $blnGiftCard, $blnInventoried, $fltInventory, $fltInventoryTotal, $blnMasterModel, $intMasterId, $strProductColor, $strProductSize, $fltProductHeight, $fltProductLength, $fltProductWidth, $fltProductWeight, $intTaxStatusId, $fltSell, $fltSellTaxInclusive, $fltSellWeb, $strUpc, $blnOnWeb, $strWebKeyword1, $strWebKeyword2, $strWebKeyword3, $blnFeatured, $strCategoryPath)
 {
     if (!$this->check_passkey($passkey)) {
         return self::FAIL_AUTH;
     }
     // We must preservice the Rowid of Products within the Web Store
     // database and must therefore see if it already exists
     $objProduct = Product::model()->findByPk($intRowid);
     if (!$objProduct) {
         $objProduct = new Product();
         $objProduct->id = $intRowid;
     }
     $strName = trim($strName);
     $strName = trim($strName, '-');
     $strName = substr($strName, 0, 255);
     $strCode = trim($strCode);
     $strCode = str_replace('"', '', $strCode);
     $strCode = str_replace("'", '', $strCode);
     if (empty($strName)) {
         $strName = 'missing-name';
     }
     if (empty($strDescription)) {
         $strDescription = '';
     }
     $objProduct->code = $strCode;
     $objProduct->title = $strName;
     //$objProduct->class_name = $strClassName;
     $objProduct->current = $blnCurrent;
     $objProduct->description_long = $strDescription;
     $objProduct->description_short = $strDescriptionShort;
     //$objProduct->family = $strFamily;
     $objProduct->gift_card = $blnGiftCard;
     $objProduct->inventoried = $blnInventoried;
     $objProduct->inventory = $fltInventory;
     $objProduct->inventory_total = $fltInventoryTotal;
     $objProduct->master_model = $blnMasterModel;
     if ($intMasterId > 0) {
         $objProduct->parent = $intMasterId;
     } else {
         $objProduct->parent = null;
     }
     $objProduct->product_color = $strProductColor;
     $objProduct->product_size = $strProductSize;
     $objProduct->product_height = $fltProductHeight;
     $objProduct->product_length = $fltProductLength;
     $objProduct->product_width = $fltProductWidth;
     $objProduct->product_weight = $fltProductWeight;
     $objProduct->tax_status_id = $intTaxStatusId;
     $objProduct->sell = $fltSell;
     $objProduct->sell_tax_inclusive = $fltSellTaxInclusive;
     //If we're in TaxIn Mode, then SellWeb has tax and we reverse it.
     if (_xls_get_conf('TAX_INCLUSIVE_PRICING', 0) == 1) {
         if ($fltSellWeb != 0) {
             //Tax in with a sell on web price
             $objProduct->sell_web_tax_inclusive = $fltSellWeb;
             //LS sends tax in web already
             $objProduct->sell_web = Tax::StripTaxesFromPrice($fltSellWeb, $intTaxStatusId);
         } else {
             //We use our regular prices and copy them price
             $objProduct->sell_web_tax_inclusive = $fltSellTaxInclusive;
             $objProduct->sell_web = $fltSell;
         }
     } else {
         if ($fltSellWeb != 0) {
             $objProduct->sell_web = $fltSellWeb;
         } else {
             $objProduct->sell_web = $fltSell;
         }
     }
     $objProduct->upc = $strUpc;
     $objProduct->web = $blnOnWeb;
     $objProduct->featured = $blnFeatured;
     $fltReserved = $objProduct->CalculateReservedInventory();
     $objProduct->inventory_reserved = $fltReserved;
     if (Yii::app()->params['INVENTORY_FIELD_TOTAL'] == 1) {
         $objProduct->inventory_avail = $fltInventoryTotal - $fltReserved;
     } else {
         $objProduct->inventory_avail = $fltInventory - $fltReserved;
     }
     //Because Lightspeed may send us products out of sequence (child before parent), we have to turn this off
     Yii::app()->db->createCommand('SET FOREIGN_KEY_CHECKS=0;')->execute();
     if (!$objProduct->save()) {
         Yii::log("SOAP ERROR : Error saving product {$intRowid} {$strCode} " . print_r($objProduct->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         return self::UNKNOWN_ERROR . " Error saving product {$intRowid} {$strCode} " . print_r($objProduct->getErrors(), true);
     }
     $strFeatured = _xls_get_conf('FEATURED_KEYWORD', 'XnotsetX');
     if (empty($strFeatured)) {
         $strFeatured = 'XnotsetX';
     }
     //Save keywords
     $strTags = trim($strWebKeyword1) . "," . trim($strWebKeyword2) . "," . trim($strWebKeyword3);
     $strTags = str_replace(",,", ",", $strTags);
     $arrTags = explode(",", $strTags);
     ProductTags::DeleteProductTags($objProduct->id);
     foreach ($arrTags as $indivTag) {
         if (!empty($indivTag)) {
             $tag = Tags::model()->findByAttributes(array('tag' => $indivTag));
             if (!$tag instanceof Tags) {
                 $tag = new Tags();
                 $tag->tag = $indivTag;
                 $tag->save();
             }
             $objProductTag = new ProductTags();
             $objProductTag->product_id = $objProduct->id;
             $objProductTag->tag_id = $tag->id;
             $objProductTag->save();
             if ($strFeatured != 'XnotsetX' && $objProduct->web && $indivTag == $strFeatured) {
                 $objProduct->featured = 1;
                 $objProduct->save();
             }
         }
     }
     if (!empty($strFamily)) {
         $objFamily = Family::model()->findByAttributes(array('family' => $strFamily));
         if ($objFamily instanceof Family) {
             $objProduct->family_id = $objFamily->id;
             $objProduct->save();
         } else {
             $objFamily = new Family();
             $objFamily->family = $strFamily;
             $objFamily->child_count = 0;
             $objFamily->request_url = _xls_seo_url($strFamily);
             $objFamily->save();
             $objProduct->family_id = $objFamily->id;
             $objProduct->save();
         }
         $objFamily->UpdateChildCount();
     } else {
         if ($objProduct->family_id) {
             $objFamily = Family::model()->findByAttributes(array('id' => $objProduct->family_id));
             $objProduct->family_id = null;
             $objProduct->save();
             $objFamily->UpdateChildCount();
         }
     }
     if (!empty($strClassName)) {
         $objClass = Classes::model()->findByAttributes(array('class_name' => $strClassName));
         if ($objClass instanceof Classes) {
             $objProduct->class_id = $objClass->id;
             $objProduct->save();
         } else {
             $objClass = new Classes();
             $objClass->class_name = $strClassName;
             $objClass->child_count = 0;
             $objClass->request_url = _xls_seo_url($strClassName);
             $objClass->save();
             $objProduct->class_id = $objClass->id;
             $objProduct->save();
         }
         $objClass->UpdateChildCount();
     }
     // Save category
     $strCategoryPath = trim($strCategoryPath);
     if ($strCategoryPath && $strCategoryPath != "Default") {
         $arrCategories = explode("\t", $strCategoryPath);
         $intCategory = Category::GetIdByTrail($arrCategories);
         if (!is_null($intCategory)) {
             $objCategory = Category::model()->findByPk($intCategory);
             //Delete any prior categories from the table
             ProductCategoryAssn::model()->deleteAllByAttributes(array('product_id' => $objProduct->id));
             $objAssn = new ProductCategoryAssn();
             $objAssn->product_id = $objProduct->id;
             $objAssn->category_id = $intCategory;
             $objAssn->save();
             $objCategory->UpdateChildCount();
         }
     } else {
         ProductCategoryAssn::model()->deleteAllByAttributes(array('product_id' => $objProduct->id));
     }
     Product::convertSEO($intRowid);
     //Build request_url
     Yii::app()->db->createCommand('SET FOREIGN_KEY_CHECKS=1;')->execute();
     $objEvent = new CEventProduct('LegacysoapController', 'onSaveProduct', $objProduct);
     _xls_raise_events('CEventProduct', $objEvent);
     //
     return self::OK;
 }
示例#7
0
 /**
  * Called by the duplicate checker when discarding the new record.
  */
 public function actionDiscardNew()
 {
     if (isset($_POST['id'])) {
         $ref = $_POST['ref'];
         // Referring action
         $action = $_POST['action'];
         $oldId = $_POST['id'];
         if ($ref == 'create' && is_null($action) || $action == 'null') {
             echo CHtml::encode($oldId);
             return;
         } elseif ($ref == 'create') {
             $oldRecord = X2Model::model('Contacts')->findByPk($oldId);
             if (isset($oldRecord)) {
                 $oldRecord->disableBehavior('X2TimestampBehavior');
                 Relationships::model()->deleteAllByAttributes(array('firstType' => 'Contacts', 'firstId' => $oldRecord->id));
                 Relationships::model()->deleteAllByAttributes(array('secondType' => 'Contacts', 'secondId' => $oldRecord->id));
                 if ($action == 'hideThis') {
                     $oldRecord->dupeCheck = 1;
                     $oldRecord->assignedTo = 'Anyone';
                     $oldRecord->visibility = 0;
                     $oldRecord->doNotCall = 1;
                     $oldRecord->doNotEmail = 1;
                     $oldRecord->save();
                     $notif = new Notification();
                     $notif->user = '******';
                     $notif->createdBy = Yii::app()->user->getName();
                     $notif->createDate = time();
                     $notif->type = 'dup_discard';
                     $notif->modelType = 'Contacts';
                     $notif->modelId = $oldId;
                     $notif->save();
                     return;
                 } elseif ($action == 'deleteThis') {
                     $oldRecord->delete();
                     return;
                 }
             }
         } elseif (isset($_POST['newId'])) {
             $newId = $_POST['newId'];
             $oldRecord = X2Model::model('Contacts')->findByPk($oldId);
             $oldRecord->disableBehavior('X2TimestampBehavior');
             $newRecord = Contacts::model()->findByPk($newId);
             $newRecord->disableBehavior('X2TimestampBehavior');
             $newRecord->dupeCheck = 1;
             $newRecord->save();
             if ($action === '') {
                 $newRecord->delete();
                 echo CHtml::encode($oldId);
                 return;
             } else {
                 if (isset($oldRecord)) {
                     if ($action == 'hideThis') {
                         $oldRecord->dupeCheck = 1;
                         $oldRecord->assignedTo = 'Anyone';
                         $oldRecord->visibility = 0;
                         $oldRecord->doNotCall = 1;
                         $oldRecord->doNotEmail = 1;
                         $oldRecord->save();
                         $notif = new Notification();
                         $notif->user = '******';
                         $notif->createdBy = Yii::app()->user->getName();
                         $notif->createDate = time();
                         $notif->type = 'dup_discard';
                         $notif->modelType = 'Contacts';
                         $notif->modelId = $oldId;
                         $notif->save();
                     } elseif ($action == 'deleteThis') {
                         Relationships::model()->deleteAllByAttributes(array('firstType' => 'Contacts', 'firstId' => $oldRecord->id));
                         Relationships::model()->deleteAllByAttributes(array('secondType' => 'Contacts', 'secondId' => $oldRecord->id));
                         Tags::model()->deleteAllByAttributes(array('type' => 'Contacts', 'itemId' => $oldRecord->id));
                         Actions::model()->deleteAllByAttributes(array('associationType' => 'Contacts', 'associationId' => $oldRecord->id));
                         $oldRecord->delete();
                     }
                 }
                 echo CHtml::encode($newId);
             }
         }
     }
 }
示例#8
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $connection = Yii::app()->db;
     $transaction = $connection->beginTransaction();
     $model = $this->loadModel($id);
     $arrTags = $this->getAllTags();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Article'])) {
         $model->attributes = $_POST['Article'];
         $model->modifiedAt = date('Y-m-d');
         try {
             if ($model->save()) {
                 $articleId = $model->article_id;
                 Articletags::model()->deleteAll('article_id = ' . $id);
                 if ($_POST['Article']['tags'] != null) {
                     $postToLower = strtolower($_POST['Article']['tags']);
                     $arrPostTags = explode(',', $postToLower);
                     $arrDiffTags = array_diff($arrPostTags, $arrTags);
                     if (!empty($arrDiffTags)) {
                         foreach ($arrDiffTags as $arrDiffTag) {
                             $row[] = array('tag' => $arrDiffTag);
                         }
                         GeneralRepository::insertSeveral(Tags::model()->tableName(), $row);
                     }
                     $newArrTags = $this->getAllTags();
                     $newArrDiffTags = array_intersect($newArrTags, $arrPostTags);
                     foreach ($newArrDiffTags as $key => $newArrDiffTag) {
                         $newRow[] = array('article_id' => $articleId, 'tag_id' => $key);
                     }
                     GeneralRepository::insertSeveral(Articletags::model()->tableName(), $newRow);
                 }
                 $transaction->commit();
                 $this->redirect(array('view', 'id' => $model->article_id));
             }
         } catch (Exception $e) {
             $transaction->rollback();
             Yii::app()->user->setFlash('error', "{$e->getMessage()}");
             $this->refresh();
         }
     }
     $model['tags'] = $this->getArticleTags($id);
     $this->render('update', array('model' => $model, 'category_list' => $this->getAllCategories()));
 }
示例#9
0
 /**
  * Delete all tags associated with a model
  */
 public function cleanUpTags($model)
 {
     Tags::model()->deleteAllByAttributes(array('itemId' => $model->id));
     /*$type=get_class($model);
     		if(substr($type,-1)!="s"){
     			$type=substr($type,0,-5)."s";
     		}
     		$change="";
     		if($model instanceof Contacts)
     			$change=$model->backgroundInfo;
     		else if($model instanceof Actions)
     			$change=$model->actionDescription;
     		else if($model instanceof Docs)
     			$change=$model->text;
     		else
     			$change=$model->description;
     		if($change!=""){
     			$forDeletion=$change;
     			preg_match_all('/(^|\s|)#(\w\w+)/',$forDeletion,$deleteMatches);
     			$deleteMatches=$deleteMatches[0];
     			foreach($deleteMatches as $match){
     				$oldTag=Tags::model()->findByAttributes(array('tag'=>$match,'type'=>$type,'itemId'=>$model->id));
     				if(isset($oldTag)) {
     					$oldTag->delete();
     				}
     			}
     		}*/
 }
示例#10
0
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $Category = new Category();
     $Tags = new Tags();
     $RewardImages = new RewardImages();
     if (isset($_POST['Reward']) && !empty($_POST['Reward'])) {
         //echo "<pre>";
         //print_r($_POST);
         //echo "<pre>";
         //print_r($_FILES);
         //die;
         $model->attributes = $_POST['Reward'];
         $model->category_id = $_POST['Reward']['category_id'];
         //echo "<pre>";
         //print_r($model->attributes);
         if ($model->save()) {
             //echo "----";
             $useridFolder = $model->id;
             if (isset($_POST['tags'])) {
                 $getTags = $_POST['tags'];
                 $mystring = $getTags;
                 $findme = ',';
                 $pos = strpos($mystring, $findme);
                 if ($pos === false) {
                     //echo "The string '$findme' was not found in the string '$mystring'";
                     //if that tag name already exist, skip that tag
                     $chkTagExist = Tags::model()->find('name = :name', array(':name' => $getTags));
                     if (empty($chkTagExist)) {
                         // echo "Tag not exist";
                         $insertMultiDoc = Yii::app()->db->createCommand()->insert('tags', array('reward_id' => $model->id, 'name' => $getTags));
                     } else {
                         //echo "dont save the Tag record";
                     }
                 } else {
                     //echo "The string '$findme' was found in the string '$mystring'";
                     //echo " and exists at position $pos";
                     //explode with comma
                     $getTagArray = explode(',', $getTags);
                     //insert into tags table with reward model id.
                     foreach ($getTagArray as $tagVal) {
                         //if that tag name already exist, skip that tag
                         $chkTagExist = Tags::model()->find('name = :name', array(':name' => $tagVal));
                         if (empty($chkTagExist)) {
                             // echo "Tag not exist";
                             $insertMultiDoc = Yii::app()->db->createCommand()->insert('tags', array('reward_id' => $model->id, 'name' => $tagVal));
                         } else {
                             //echo "dont save the Tag record";
                         }
                     }
                 }
             }
             //end tags
             $images = CUploadedFile::getInstancesByName('images');
             //echo "<pre>";
             //print_r($images);
             // proceed if the images have been set
             if (isset($images) && count($images) > 0) {
                 //upload multiple images, first create folder with reward id and store all related images in that folder.
                 // create folder
                 if ($_SERVER['DOCUMENT_ROOT'] == '/var/www/html') {
                     $setDir = $_SERVER['DOCUMENT_ROOT'] . "/images/reward/" . $useridFolder;
                 } else {
                     $setDir = $_SERVER['DOCUMENT_ROOT'] . "/jobstar/images/reward/" . $useridFolder;
                 }
                 if (is_dir($setDir) == false) {
                     mkdir("{$setDir}", 0777, true);
                     chmod("{$setDir}", 0777);
                 }
                 //end
                 //echo  $setDir;
                 //die;
                 // go through each uploaded image
                 $i = 0;
                 foreach ($images as $image => $pic) {
                     //echo "i am in images";
                     if ($i == '0') {
                         //first image will be default
                         $setDefaultStatus = '1';
                     } else {
                         $setDefaultStatus = '0';
                     }
                     //echo $pic->name.'<br />';
                     $finalName = $setDir . "/" . $pic->name;
                     //echo "<br>";
                     if ($pic->saveAs($finalName)) {
                         $chkImageExist = RewardImages::model()->find('image = :image', array(':image' => $pic->name));
                         if (empty($chkImageExist)) {
                             // echo "Image not exist";
                             // add it to the main model now
                             $insertMultiDoc = Yii::app()->db->createCommand()->insert('rewardimages', array('reward_id' => $model->id, 'image' => $pic->name, 'defaultImage' => $setDefaultStatus));
                         } else {
                             //echo "dont save the record";
                         }
                     } else {
                         //echo " handle the errors here, if you want";
                     }
                     $i++;
                 }
                 //end foreach
             }
             // if image is uploaded by admin
         }
         //die('end');
         $this->redirect(array('admin', 'id' => $model->id));
     }
     //end post method
     $this->render('update', array('model' => $model, 'Category' => $Category, 'Tags' => $Tags, 'RewardImages' => $RewardImages));
 }
示例#11
0
	        <?php 
echo $form->listBox($model, 'classes', CHtml::listData(Classes::model()->findAll(array('order' => 'class_name')), 'class_name', 'class_name'), array('multiple' => 'multiple', 'class' => 'tall', 'onChange' => 'js:FillListValues(this)', 'onMouseDown' => 'js:GetCurrentListValues(this)'));
?>
	        <div class="clearfix"></div><?php 
echo CHtml::link(Yii::t('admin', 'Clear All'), '#', array('class' => 'listboxReset', 'onclick' => 'js:jQuery($("#' . CHtml::activeId($model, 'classes') . '").find("option").prop("selected", false))'));
?>
			<?php 
echo $form->error($model, 'classes');
?>
        </div>
        <div class="span2">
		    <?php 
echo $form->labelEx($model, 'keywords');
?>
		    <?php 
echo $form->listBox($model, 'keywords', CHtml::listData(Tags::model()->findAll(array('select' => 't.tag', 'order' => 'tag', 'distinct' => true)), 'tag', 'tag'), array('multiple' => 'multiple', 'class' => 'tall', 'onChange' => 'js:FillListValues(this)', 'onMouseDown' => 'js:GetCurrentListValues(this)'));
?>
	        <div class="clearfix"></div><?php 
echo CHtml::link(Yii::t('admin', 'Clear All'), '#', array('class' => 'listboxReset', 'onclick' => 'js:jQuery($("#' . CHtml::activeId($model, 'keywords') . '").find("option").prop("selected", false))'));
?>
		    <?php 
echo $form->error($model, 'keywords');
?>
        </div>
<!--        <div class="span2">-->
<!--		    --><?php 
//echo $form->labelEx($model,'codes');
?>
<!--		    --><?php 
//echo $form->listBox($model,'codes',
//		        CHtml::listData(Product::model()->findAllByAttributes(array('web'=>1),array('order'=>'code','limit'=>1000)), 'code', 'code'),
示例#12
0
 public static function SetFeaturedByKeyword($strKeyword)
 {
     Product::model()->updateAll(array('featured' => 0));
     Yii::app()->db->createCommand('update ' . Product::model()->tableName() . ' as a left join ' . ProductTags::model()->tableName() . ' as b on a.id=b.product_id left join ' . Tags::model()->tableName() . ' as c on b.tag_id=c.id set featured=1 where tag=:tag')->bindValue(':tag', $strKeyword)->execute();
 }
示例#13
0
 public function actionVideo($id)
 {
     if (!is_numeric($id)) {
         exit;
     }
     $this->ogtype = "yes";
     $this->videoID = $id;
     $ModalSeo = new CmsvideoSettings();
     $DataSeo = $ModalSeo->DownloadSettings();
     $ModelCategories = CmsvideoCategories::model()->findAll();
     $Model = CmsvideoVideo::model()->find('video_id=:IdVideo', array(':IdVideo' => $id));
     $criteria = new CDbCriteria(array('select' => 'video_id, video_title, video_thumb, video_views, video_alias', 'condition' => 'video_views >= 0 AND video_id != :IdVideo', 'order' => 'video_views DESC', 'params' => array(':IdVideo' => $id)));
     $total = CmsvideoVideo::model()->count();
     $pages = new CPagination($total);
     $pages->pageSize = 7;
     $pages->applyLimit($criteria);
     $VideoList = CmsvideoVideo::model()->findAll($criteria);
     $TagsId = unserialize($Model->video_tags);
     $ModelTags = array();
     if (is_array($TagsId) && !empty($TagsId)) {
         $TagsIdArr = join(',', $TagsId);
         $ModelTags = Tags::model()->findAllBySQL('SELECT tag_name FROM videocms_tags WHERE tag_id IN (' . $TagsIdArr . ')');
     }
     $session = Yii::app()->getSession();
     $video_arr = array();
     $ses_arr = array();
     if ($session['video_arr']) {
         $ses_arr = $session['video_arr'];
     }
     if (!in_array($id, $ses_arr)) {
         $video_arr = $ses_arr;
         $video_arr[] = $id;
         $Views = CmsvideoVideo::model()->find('video_id=:id', array(':id' => $id));
         if ($Views->video_views) {
             $Views->video_views = $Views->video_views + 1;
         } else {
             $Views->video_views = 1;
         }
         $Views->save();
         $session['video_arr'] = $video_arr;
     }
     foreach ($DataSeo as $Seoo) {
         $this->pageMetaRobots = $Seoo['settings_robots'];
         $this->disqus_shortname = $Seoo['disqus_shortname'];
         $this->player_autoplay = $Seoo['player_autoplay'];
         $this->player_preload = $Seoo['player_preload'];
         $this->player_loop = $Seoo['player_loop'];
         $this->player_controls = $Seoo['player_controls'];
     }
     // foreach ($Model as $Video)
     //  {
     $this->pageTitle = $Model->video_title;
     $this->pageMetaKeywords = $Model->video_keywords;
     $this->pageMetaDescription = $Model->video_description;
     $this->pageMetaOgImage = $Model->video_image;
     $this->pageAlias = $Model->video_alias;
     // $this->pageMetaDescription = $Video['video_description'];
     //}
     $this->render('video', array('ModelCategories' => $ModelCategories, 'ModelTags' => $ModelTags, 'Model' => $Model, 'VideoList' => $VideoList, 'pages' => $pages));
 }
示例#14
0
<?php 
//$this->renderPartial('_search',array('model'=>$model,));
?>

</div>

<!-- search-form -->

<?php 
//echo CHtml::resetButton('Reset Search!', array('id'=>'form-reset-button'));
//echo CHtml::resetButton('Search', array('id'=>'form-search'));
?>

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'reward-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'image', 'header' => 'Image', 'type' => 'html', 'value' => 'Reward::showImage($data->id)', 'filter' => false), 'title', array('name' => 'category_id', 'header' => 'Category', 'type' => 'html', 'value' => 'Reward::searchCat($data->category_id)', 'filter' => CHtml::listData(Category::model()->findAll(), 'id', 'name')), array('name' => 'tags', 'header' => 'Tags', 'type' => 'html', 'value' => 'Reward::searchTag($data->id)', 'filter' => CHtml::listData(Tags::model()->findAll(), 'id', 'name')), array('name' => 'Posted Date', 'type' => 'html', 'value' => '$data["createTime"]', 'filter' => false), array('name' => 'Status', 'type' => 'html', 'value' => array($this, 'getStatus'), 'filter' => false), array('class' => 'CButtonColumn', 'template' => '{update}{view}{delete}{status}'))));
?>


<script type="text/javascript">
/*<![CDATA[*/
function Show_Div(Div_id) {
            if (false == $(Div_id).is(':visible')) {
                $(Div_id).fadeIn();
            }
            else {
                $(Div_id).fadeOut();
            }
        }
jQuery(function($) {
示例#15
0
 /**
  * Creates a {@link CActiveDataProvider} object for search queries.
  *
  * @param string $modelClass Optional, class of {@link CActiveRecord}. If
  *  unspecified, the class of {@link staticModel} will be used.
  * @param CDbCriteria $extraCriteria Criteria to merge with the automatically
  *  created criteria.
  * @param string $combineOp How to combine the custom/extra criteria
  */
 public function getDataProvider($modelClass = null, $extraCriteria = null, $combineOp = 'AND')
 {
     // Check for model
     $class = $modelClass == null && isset($_GET['_class']) ? get_class($this->staticModel) : $modelClass;
     if (empty($class) || !class_exists($class)) {
         $this->send(500, 'Method getDataProvider called without specifying ' . 'a valid model class, in action "' . $this->action->id . '".');
     }
     $staticModel = CActiveRecord::model($class);
     $model = new $class('search');
     // Compose attributes in the query parameters for the comparison:
     $searchAttributes = array_intersect_key($_GET, $staticModel->attributes);
     // Get search option parameters
     $optionParams = array_fill_keys($this->reservedParams['search'], 0);
     $searchOptions = array_intersect_key($_GET, $optionParams);
     // Configure the CDbCriteria object
     $criteria = new CDbCriteria();
     $criteria->alias = 't';
     if ($model instanceof X2Model) {
         // Special handling of X2Model subclasses:
         if ($model->asa('permissions') && $model->asa('permissions')->enabled) {
             // Working with an X2Model instance having its permissions behavior
             // enabled. Include access/permissions criteria.
             $criteria->mergeWith($model->getAccessCriteria());
         }
         if (isset($searchOptions['_tags'])) {
             // Add tag search criteria
             $criteria->distinct = true;
             $tags = array_map(function ($t) {
                 return '#' . $t;
             }, explode(',', $_GET['_tags']));
             $tagTable = Tags::model()->tableName();
             if (empty($searchOptions['_tagOr']) || !(bool) (int) $searchOptions['_tagOr']) {
                 // Perform an "and" tag search (must have all tags)
                 $i_tag = 0;
                 $joins = array();
                 foreach ($tags as $tag) {
                     $tagParam = ":apiSearchTag{$i_tag}";
                     $classParam = ":apiTagItemClass{$i_tag}";
                     $joinAlias = "tag{$i_tag}";
                     $joins[] = "INNER JOIN `{$tagTable}` `{$joinAlias}` " . "ON `{$joinAlias}`.`type`= {$classParam} " . "AND `{$joinAlias}`.`itemId`=`{$criteria->alias}`.`id` " . "AND `{$joinAlias}`.`tag`={$tagParam}";
                     $criteria->params[$tagParam] = $tag;
                     $criteria->params[$classParam] = get_class($model);
                     $i_tag++;
                 }
                 $criteria->join .= implode(' ', $joins);
             } else {
                 // Perform an "or" tag search (could have any one of the
                 // tags in the list)
                 $tagParam = AuxLib::bindArray($tags, 'apiSearchTag');
                 $tagIn = AuxLib::arrToStrList(array_keys($tagParam));
                 $criteria->join .= "INNER JOIN `{$tagTable}` `tag`" . "ON `tag`.`type`=:apiTagItemClass " . "AND `tag`.`itemId`=`{$criteria->alias}`.`id` " . "AND `tag`.`tag` IN {$tagIn}";
                 $tagParam[":apiTagItemClass"] = get_class($model);
                 foreach ($tagParam as $param => $value) {
                     $criteria->params[$param] = $value;
                 }
             }
         }
         // Special "codes" in comparison values.
         //
         // Not intended for more advanced formulae parsing but for basic
         // stuff, i.e. dynamic points in time like "yesterday"
         $now = time();
         $yesterday = $now - 86400;
         $tomorrow = $now + 86400;
         $codes = array('date' => compact('now', 'yesterday', 'tomorrow'), 'dateTime' => compact('now', 'yesterday', 'tomorrow'));
         $fields = $model->getFields();
         foreach ($fields as $field) {
             if (isset($searchAttributes[$field->fieldName])) {
                 if (isset($codes[$field->type])) {
                     foreach ($codes[$field->type] as $name => $value) {
                         $searchAttributes[$field->fieldName] = preg_replace('/' . $name . '$/', $value, $searchAttributes[$field->fieldName]);
                     }
                 }
             }
         }
     }
     // Search options:
     //
     // Send with parameter _partial=1 to enable partial match in searches
     $partialMatch = isset($searchOptions['_partial']) ? (bool) (int) $searchOptions['_partial'] : false;
     // Send with parameter _or=1 to enable the "OR" operator in the search
     $operator = isset($searchOptions['_or']) && (bool) (int) $searchOptions['_or'] ? 'OR' : 'AND';
     // Send with parameter _escape=0 to enable searching with MySQL wildcards
     $escape = isset($searchOptions['_escape']) ? (bool) (int) $searchOptions['_escape'] : true;
     // If searching for Actions, perform additional stuff first:
     if ($class === 'Actions') {
         $this->kludgesForSearchingActions($searchAttributes, $criteria);
     }
     // Run comparisons:
     $searchCriteria = new CDbCriteria();
     foreach ($searchAttributes as $column => $value) {
         $searchCriteria->compare($column, $value, $partialMatch, $operator, $escape);
     }
     $criteria->mergeWith($searchCriteria);
     // Merge extra criteria:
     if ($extraCriteria instanceof CDbCriteria) {
         $criteria->mergeWith($extraCriteria, $combineOp);
     }
     // Interpret "order" configuration from parameters:
     if (isset($searchOptions['_order'])) {
         $orderBy = $searchOptions['_order'];
         if (preg_match('/^(?P<asc>[\\+\\-\\s])?(?P<col>[^\\+\\-\\s]+)$/', $orderBy, $match)) {
             $col = $match['col'];
             if (!in_array($col, $staticModel->attributeNames())) {
                 $this->send(400, "Specified attribute to order results by ({$col}) " . "does not exist in active record class \"{$class}\".");
             }
             $ascMap = array('+' => 'ASC', ' ' => 'ASC', '-' => 'DESC');
             $criteria->order = $col . (empty($match['asc']) ? '' : ' ' . $ascMap[$match['asc']]);
         }
     }
     // Interpret pagination from parameters:
     $pageSize = null;
     // Default query size
     $pageInd = 0;
     // Default page
     if (isset($searchOptions['_limit']) && ctype_digit((string) $searchOptions['_limit'])) {
         $pageSize = (int) $searchOptions['_limit'];
     }
     if (isset($searchOptions['_page']) && ctype_digit((string) $searchOptions['_page'])) {
         $pageInd = (int) $searchOptions['_page'];
     }
     $pagination = array('currentPage' => $pageInd, 'pageSize' => $pageSize !== null ? min($pageSize, $this->maxPageSize) : $this->maxPageSize);
     // Construct the data provider object
     return new CActiveDataProvider($class, compact('model', 'criteria', 'pagination'));
 }
示例#16
0
 public function actionDelContent()
 {
     $this->checkLogin();
     $data = zmf::val('data', 1);
     $type = zmf::val('type', 1);
     if (!$data || !$type) {
         $this->jsonOutPut(0, '数据不全,请核实');
     }
     if (!in_array($type, array('comment', 'post', 'notice', 'tag'))) {
         $this->jsonOutPut(0, '暂不允许的分类');
     }
     switch ($type) {
         case 'comment':
             $info = Comments::model()->findByPk($data);
             if (!$info) {
                 $this->jsonOutPut(0, '您所查看的内容不存在');
             } elseif ($info['uid'] != $this->uid) {
                 if ($this->checkPower('delComment', $this->uid, true)) {
                     //我是管理员,我就可以删除
                 } else {
                     $this->jsonOutPut(0, '您无权操作');
                 }
             }
             if (Comments::model()->updateByPk($data, array('status' => Posts::STATUS_DELED))) {
                 $this->jsonOutPut(1, '已删除');
             }
             $this->jsonOutPut(1, '已删除');
             break;
         case 'post':
             $info = Posts::model()->findByPk($data);
             if (!$info) {
                 $this->jsonOutPut(0, '您所查看的内容不存在');
             } elseif ($info['uid'] != $this->uid) {
                 if ($this->checkPower('delPost', $this->uid, true)) {
                     //我是管理员,我就可以删除
                 } else {
                     $this->jsonOutPut(0, '您无权操作');
                 }
             }
             if (Posts::model()->updateByPk($data, array('status' => Posts::STATUS_DELED))) {
                 $this->jsonOutPut(1, '已删除');
             }
             $this->jsonOutPut(1, '已删除');
             break;
         case 'notice':
             if (!$data || !is_numeric($data)) {
                 $this->jsonOutPut(0, '您所操作的内容不存在');
             }
             if (Notification::model()->deleteByPk($data)) {
                 $this->jsonOutPut(1, '已删除');
             }
             $this->jsonOutPut(1, '已删除');
             break;
         case 'tag':
             if (!$data || !is_numeric($data)) {
                 $this->jsonOutPut(0, '您所操作的内容不存在');
             }
             if (!$this->checkPower('delTag', $this->uid, true)) {
                 $this->jsonOutPut(0, '您无权操作');
             }
             if (Tags::model()->updateByPk($data, array('status' => Posts::STATUS_DELED))) {
                 $this->jsonOutPut(1, '已删除');
             }
             $this->jsonOutPut(1, '已删除');
             break;
         default:
             $this->jsonOutPut(0, '操作有误');
             break;
     }
 }
示例#17
0
文件: edit.php 项目: 42point/Vinum
                                    <div class="form-group">
                                        <label>URL</label>
                                        <input type="text" name="data[url]" value="<?php 
echo is_object($model) ? CHtml::encode($model->url) : '';
?>
" class="form-control alt-name-target" />
                                    </div>
                                    <div class="form-group">
                                        <label>Теги(перечислите через запятую)</label>
                                        <select name="data[tags][]" class="form-control control-tags" multiple="multiple">
                                            <?php 
if (is_object($model)) {
    $tags = TagsRelations::model()->findAllByAttributes(array("object_id" => $model->id, "model" => "catalog_object"));
    if (is_array($tags) && count($tags)) {
        foreach ($tags as $tr) {
            $tag = Tags::model()->findByPk($tr->tag_id);
            if (is_object($tag)) {
                ?>
                                                            <option value="<?php 
                echo CHtml::encode($tag->name);
                ?>
" selected="selected"><?php 
                echo CHtml::encode($tag->name);
                ?>
</option>
                                                            <?php 
            }
        }
    }
}
?>
示例#18
0
 public function getTagCloud()
 {
     return Tags::model()->findAllByAttributes(array('model' => Yii::app()->controller->module->id));
 }
示例#19
0
 public static function getTagLinks($model, $id, $limit = 0)
 {
     if (!is_numeric($limit) || empty($limit)) {
         $limit = null;
     }
     $tags = Tags::model()->findAllByAttributes(array('type' => $model, 'itemId' => $id), new CDbCriteria(array('order' => 'id DESC', 'limit' => $limit)));
     $tagCount = Tags::model()->countByAttributes(array('type' => $model, 'itemId' => $id));
     $links = array();
     foreach ($tags as &$tag) {
         $links[] = CHtml::link($tag->tag, array('search/search', 'term' => $tag->tag));
     }
     if (!empty($limit) && $tagCount > $limit) {
         $links[] = '...';
     }
     return implode(' ', $links);
 }
示例#20
0
文件: _formajax.php 项目: ranvirp/rdp
	<div class="row">
		<?php 
echo $form->labelEx($model, 'to');
?>
		<?php 
echo $form->dropDownList($model, 'to', CHtml::listData(Designation::model()->findAll(), 'id', 'name'), array('empty' => 'Select to whom to be sent'));
?>
	<?php 
echo $form->error($model, 'to');
?>
	</div>
<div class="row">
<?php 
echo "Subject:";
echo $form->dropDownList($model, 'tagid', CHtml::listData(Tags::model()->findAllByAttributes(array('schemeid' => 1)), 'id', 'tag'), array('0' => 'Others'));
?>
	<?php 
echo $form->error($model, 'tagid');
?>
	

</div>
	<div class="row">
		<?php 
echo $form->labelEx($model, 'description');
?>
		<?php 
echo $form->textArea($model, 'description');
?>
		<?php 
示例#21
0
文件: x2base.php 项目: shuvro35/X2CRM
 public function cleanUpTags($model)
 {
     Tags::model()->deleteAllByAttributes(array('itemId' => $model->id));
 }
示例#22
0
 public function actionEdit()
 {
     $this->layout = '//layouts/admin';
     $success = false;
     $id = $_REQUEST['id'];
     $model = NewsCategories::model()->findByPk($id);
     $this->pageTitle = is_object($model) ? $model->name : 'Новая категория';
     $this->breadcrumbs = array('Новости' => array('/admin/news'), 'Категории' => array('/admin/news/categories/list'), is_object($model) ? $model->name : 'Новая категория');
     if (isset($_POST['data']) && is_object($model)) {
         $tags = array();
         if (isset($_POST['data']['tags'])) {
             $tags = $_POST['data']['tags'];
             unset($_POST['data']['tags']);
         }
         $dataArray = $_POST['data'];
         $dataArray['is_active'] = isset($_POST['data']['is_active']) && $_POST['data']['is_active'] == 1 ? 1 : 0;
         $model->setAttributes($dataArray);
         if ($model->save()) {
             $success = true;
             if (isset($_FILES['anons_pic']) && $_FILES['anons_pic']['name'] || isset($_FILES['content_pic']) && $_FILES['content_pic']['name']) {
                 $uploaddir = 'images/upload/' . date("d.m.Y", time());
                 if (!is_dir($uploaddir)) {
                     mkdir($uploaddir);
                 }
                 if (isset($_FILES['anons_pic']) && $_FILES["anons_pic"]["name"]) {
                     if ($model->anons_pic) {
                         $anons_pic = Yii::app()->basePath . "/.." . $model->anons_pic;
                         if (is_file($anons_pic)) {
                             unlink($anons_pic);
                         }
                     }
                     $tmp_name = $_FILES["anons_pic"]["tmp_name"];
                     $name = $_FILES["anons_pic"]["name"];
                     if ($name) {
                         $uploadfile = $uploaddir . 'arca_' . $model->id . '_' . md5(basename($name) . time()) . "." . end(explode(".", $name));
                         if (move_uploaded_file($tmp_name, $uploadfile)) {
                             $model->setAttributes(array("anons_pic" => "/" . $uploadfile));
                             if (!$model->save()) {
                                 print_r($model->errors);
                                 die;
                             }
                         }
                     }
                 }
                 if (isset($_FILES['content_pic']) && $_FILES["content_pic"]["name"]) {
                     if ($model->content_pic) {
                         $content_pic = Yii::app()->basePath . "/.." . $model->content_pic;
                         if (is_file($content_pic)) {
                             unlink($content_pic);
                         }
                     }
                     $tmp_name = $_FILES["content_pic"]["tmp_name"];
                     $name = $_FILES["content_pic"]["name"];
                     if ($name) {
                         $uploadfile = $uploaddir . 'arcc_' . $model->id . '_' . md5(basename($name) . time()) . "." . end(explode(".", $name));
                         if (move_uploaded_file($tmp_name, $uploadfile)) {
                             $model->setAttributes(array("content_pic" => "/" . $uploadfile));
                             $model->save();
                         }
                     }
                 }
             }
             if (is_array($tags) && count($tags)) {
                 $trs = TagsRelations::model()->findAllByAttributes(array("object_id" => $id, "model" => "news_category"));
                 if (is_array($trs) && count($trs)) {
                     foreach ($trs as $tr) {
                         $tr->delete();
                     }
                 }
                 foreach ($tags as $tag) {
                     $tagModel = Tags::model()->findByAttributes(array("name" => $tag));
                     if (!is_object($tagModel)) {
                         $tagModel = new Tags();
                         $tagModel->setAttributes(array("name" => $tag, "count" => 0));
                     }
                     $tagModel->count += 1;
                     $tagModel->save();
                     $tagsRelations = new TagsRelations();
                     $tagsRelations->setAttributes(array("tag_id" => $tagModel->id, "object_id" => $model->id, "model" => "news_category"));
                     $tagsRelations->save();
                 }
             }
         }
     }
     $this->render('edit', array('model' => $model, 'success' => $success, 'errors' => $model->errors));
 }
示例#23
0
文件: Tags.php 项目: shayanyi/CRM
 /**
  * Return a list of tag links associated with a specified model
  * @param $model Model type, e.g., "Contacts"
  * @param $id Model ID
  * @param $limit Number of tags to return, or -1 to disable
  * @return string HTML containing links to each tag
  */
 public static function getTagLinks($model, $id, $limit = -1)
 {
     // Disable limit in CDbCriteria with a value less than 0
     if (!is_numeric($limit) || empty($limit)) {
         $limit = -1;
     }
     $tags = Tags::model()->findAllByAttributes(array('type' => $model, 'itemId' => $id), new CDbCriteria(array('order' => 'id DESC', 'limit' => $limit)));
     $tagCount = Tags::model()->countByAttributes(array('type' => $model, 'itemId' => $id));
     $links = array();
     foreach ($tags as &$tag) {
         $links[] = CHtml::link(CHtml::encode($tag->tag), array('/search/search', 'term' => CHtml::encode($tag->tag)));
     }
     if ($limit !== -1 && $tagCount > $limit) {
         $links[] = '...';
     }
     return implode(' ', $links);
 }
示例#24
0
 public function Posts()
 {
     return Tags::model()->findAllByAttributes(array('tag_id' => $this->tag_id));
 }
示例#25
0
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Tags::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#26
0
文件: Tags.php 项目: ph7pal/momo
 public static function getClassifyTags($classify)
 {
     $items = Tags::model()->findAll(array('condition' => 'classify=:class', 'params' => array(':class' => $classify), 'select' => 'id,title', 'limit' => '50'));
     return CHtml::listData($items, 'id', 'title');
 }
示例#27
0
 public function actionNetworkConnections()
 {
     //$this->header = 'network';
     $this->networkheader = 'network';
     // Added on 29-01-2013 to commonheader
     if (isset(Yii::app()->session['login'])) {
         $userid = Yii::app()->session['login']['id'];
         if (isset($_REQUEST['frndid'])) {
             $frndid = $_REQUEST['frndid'];
             if ($userid != $frndid) {
                 $userid = $frndid;
             }
         }
     } else {
         $this->redirect(array('/'));
     }
     $userid = Yii::app()->session['login']['id'];
     $invitedfdsocialid = "";
     $userdetails = "";
     $displaydata = "connections";
     //$this->allowjs = "allowminjs";
     $editprof = new User();
     if (isset($_REQUEST["displaydata"])) {
         $displaydata = $_REQUEST["displaydata"];
         if ($displaydata == "connections") {
             $this->networkheader = 'network';
         } elseif ($displaydata == "proflieOrg") {
             $this->networkheader = 'profileorg';
         }
     }
     $usertiles = UserTile::model()->findAll(array('condition' => 'userid = "' . $userid . '" AND status = 1'));
     $displaytiles = array();
     foreach ($usertiles as $tilename) {
         $displaytiles[$tilename->tile_name] = $tilename->tile_name;
     }
     $userDet = array();
     //$userAlpha = array();
     $i = 0;
     $firstCon = true;
     $firstConUserid = 0;
     $childInfo = array();
     $firstConnection = array();
     $userDetailsarray = array();
     $userDetailsarray = $this->populateUserDetails();
     $userDet = $userDetailsarray['userDet'];
     $firstConUserid = $userDetailsarray['firstConUserid'];
     $firstConnection = $userDetailsarray['firstConnection'];
     $userdetails = $userDetailsarray['userdetails'];
     $firstUserTag = Tags::model()->findAll(array('condition' => 'user_id = ' . $firstConUserid . ' and status = 1'));
     $firstUserTagValue = array();
     foreach ($firstUserTag as $usrtagid) {
         foreach ($alltags as $allintval) {
             if ($usrtagid->tag_id == $allintval->pv_lookup_id) {
                 $firstUserTagValue[$allintval->pv_lookup_id] = $allintval->lookup_name;
             }
         }
     }
     $firstusertiles = UserTile::model()->findAll(array('condition' => 'userid = "' . $firstConUserid . '" '));
     /*$firstdisplaytiles = array();
       
       
       
       foreach($firstusertiles as $tilename)
       
       
       
       {
       
       
       
       $firstdisplaytiles[$tilename->tile_name] = $tilename->tile_name;
       
       
       
       
       
       
       
       } */
     /********* Getting all the Intererest from lookup table    *****************/
     /** need to implement to display in option group *****/
     $allinterest = array();
     $allinterest = Lookups::model()->findAll(array('condition' => "lookup_type='interests' and lookup_parentid != 0 and lookup_status=1"));
     /*$childintrst = Lookups::model()->findAllByAttributes(array('lookup_type'=>'interests','lookup_parentid'=>0,'lookup_status'=>1));
       
       
       
       
       
       
       
       $i=0;
       
       
       
       foreach($childintrst as $childPar)
       
       
       
       {
       
       
       
       $allinterest[$i]["parentname"] = $childPar->lookup_name;
       
       
       
       $allinterest[$i]["parentid"] = $childPar->fn_lookup_id;
       
       
       
       $allinterest[$i++]["childint"] = Lookups::model()->findAllByAttributes(array('lookup_type'=>'interests','lookup_parentid'=>$childPar->fn_lookup_id,'lookup_status'=>1));
       
       
       
       } */
     /********** End of FirstUser Interest **************/
     /***** Getting the total available filter Interest *********/
     $inviteeuserId = "";
     $invteusrcondition = "";
     if ($userdetails != "" && count($userdetails) > 0) {
         foreach ($userdetails as $foreachuser) {
             $inviteeuserId .= $foreachuser["userid"] . ",";
         }
         $inviteeuserId = substr($inviteeuserId, 0, strlen($inviteeuserId) - 1);
         $invteusrcondition = "";
         if ($userdetails != "") {
             $invteusrcondition = ' userid in (' . $inviteeuserId . ') and ';
         }
     }
     /****  End of tags ****/
     /* Profile page details */
     $myprofile = User::model()->findAll(array("condition" => "userid = " . $userid . " and status = 1"));
     $addresstags = Lookups::model()->findAll(array('condition' => 'lookup_type = "address" and lookup_name in ("Home","Work") and lookup_status = 1'));
     if (!isset($_REQUEST["displaydata"])) {
         if ($displaydata == "connections") {
             $displaydata = $userdetails != "" ? $displaydata : "invitefriend";
         }
     }
     $this->render('network', array('userDet' => $userDet, 'displaydata' => $displaydata, 'totalConnections' => $userdetails != "" ? count($userdetails) : 0, 'childInfo' => $childInfo, 'myprofile' => $myprofile, 'editprof' => $editprof, 'allinterest' => $allinterest, 'firstConnection' => $firstConnection, 'userid' => $userid, 'usertiles' => $usertiles, 'displaytiles' => $firstusertiles));
 }
示例#28
0
 public function actionEdit()
 {
     $this->layout = '//layouts/admin';
     $success = false;
     $id = $_REQUEST['id'];
     $model = CatalogObjects::model()->findByPk($id);
     $this->pageTitle = is_object($model) ? $model->name : 'Новый товар';
     $this->breadcrumbs = array('Каталог' => array('/admin/catalog'), is_object($model) ? $model->name : 'Новый товар');
     if (isset($_POST['data']) && is_object($model)) {
         $tags = array();
         if (isset($_POST['data']['tags'])) {
             $tags = $_POST['data']['tags'];
             unset($_POST['data']['tags']);
         }
         $dataArray = $_POST['data'];
         $additionalDataArray = isset($dataArray['additional']) ? $dataArray['additional'] : array();
         unset($dataArray['additional']);
         $dataArray['is_active'] = isset($_POST['data']['is_active']) && $_POST['data']['is_active'] == 1 ? 1 : 0;
         $dataArray['on_main'] = isset($_POST['data']['on_main']) && $_POST['data']['on_main'] == 1 ? 1 : 0;
         $model->setAttributes($dataArray);
         if ($model->save()) {
             $success = true;
             if (isset($_FILES['anons_pic']) || isset($_FILES['content_pic'])) {
                 $uploaddir = 'images/upload/' . date("d.m.Y", time());
                 if (!is_dir($uploaddir)) {
                     mkdir($uploaddir);
                 }
                 if (isset($_FILES['anons_pic']) && $_FILES["anons_pic"]["name"]) {
                     if ($model->anons_pic) {
                         $anons_pic = Yii::app()->basePath . "/.." . $model->anons_pic;
                         if (is_file($anons_pic)) {
                             unlink($anons_pic);
                         }
                     }
                     $tmp_name = $_FILES["anons_pic"]["tmp_name"];
                     $name = $_FILES["anons_pic"]["name"];
                     if ($name) {
                         $ext = explode(".", $name);
                         $uploadfile = $uploaddir . '/na_' . $model->id . '_' . md5(basename($name) . time()) . "." . end($ext);
                         if (move_uploaded_file($tmp_name, $uploadfile)) {
                             $model->setAttributes(array("anons_pic" => "/" . $uploadfile));
                             $model->save();
                         }
                     }
                 }
                 if (isset($_FILES['content_pic']) && $_FILES["content_pic"]["name"]) {
                     if ($model->content_pic) {
                         $content_pic = Yii::app()->basePath . "/.." . $model->content_pic;
                         if (is_file($content_pic)) {
                             unlink($content_pic);
                         }
                     }
                     $tmp_name = $_FILES["content_pic"]["tmp_name"];
                     $name = $_FILES["content_pic"]["name"];
                     if ($name) {
                         $ext = explode(".", $name);
                         $uploadfile = $uploaddir . '/nc_' . $model->id . '_' . md5(basename($name) . time()) . "." . end($ext);
                         if (move_uploaded_file($tmp_name, $uploadfile)) {
                             $model->setAttributes(array("content_pic" => "/" . $uploadfile));
                             $model->save();
                         }
                     }
                 }
                 if (isset($_FILES['extra_img']) && $_FILES["extra_img"]["name"]) {
                     if ($model->extra_img) {
                         $extra_img = Yii::app()->basePath . "/.." . $model->extra_img;
                         if (is_file($extra_img)) {
                             unlink($extra_img);
                         }
                     }
                     $tmp_name = $_FILES["extra_img"]["tmp_name"];
                     $name = $_FILES["extra_img"]["name"];
                     if ($name) {
                         $ext = explode(".", $name);
                         $uploadfile = $uploaddir . '/nc_' . $model->id . '_' . md5(basename($name) . time()) . "." . end($ext);
                         if (move_uploaded_file($tmp_name, $uploadfile)) {
                             $model->setAttributes(array("extra_img" => "/" . $uploadfile));
                             $model->save();
                         }
                     }
                 }
             }
             if (is_array($tags) && count($tags)) {
                 $trs = TagsRelations::model()->findAllByAttributes(array("object_id" => $id, "model" => "catalog_object"));
                 if (is_array($trs) && count($trs)) {
                     foreach ($trs as $tr) {
                         $tr->delete();
                     }
                 }
                 foreach ($tags as $tag) {
                     $tagModel = Tags::model()->findByAttributes(array("name" => $tag));
                     if (!is_object($tagModel)) {
                         $tagModel = new Tags();
                         $tagModel->setAttributes(array("name" => $tag, "count" => 0));
                     }
                     $tagModel->count += 1;
                     $tagModel->save();
                     $tagsRelations = new TagsRelations();
                     $tagsRelations->setAttributes(array("tag_id" => $tagModel->id, "object_id" => $model->id, "model" => "catalog_object"));
                     $tagsRelations->save();
                 }
             }
             if (is_array($additionalDataArray) && count($additionalDataArray)) {
                 foreach ($additionalDataArray as $fieldName => $data) {
                     $fieldModel = CatalogFilteredFields::model()->findByAttributes(array("name" => $fieldName, "category_id" => $model->category_id));
                     if (is_object($fieldModel)) {
                         switch ($fieldModel->data_type) {
                             case 'varchar':
                             case 'text':
                             case 'html':
                                 if ($data) {
                                     $newVal = FieldsValues::model()->findByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id));
                                     if (!is_object($newVal)) {
                                         $newVal = new FieldsValues();
                                     }
                                     $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "text_val" => $data));
                                     $newVal->save();
                                 }
                                 break;
                             case 'int':
                             case 'list':
                                 if (is_numeric($data)) {
                                     $newVal = FieldsValues::model()->findByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id));
                                     if (!is_object($newVal)) {
                                         $newVal = new FieldsValues();
                                     }
                                     $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "int_val" => $data));
                                     $newVal->save();
                                 }
                                 break;
                             case 'bool':
                                 $data = $data ? 1 : 0;
                                 $newVal = FieldsValues::model()->findByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id));
                                 if (!is_object($newVal)) {
                                     $newVal = new FieldsValues();
                                 }
                                 $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "int_val" => $data));
                                 $newVal->save();
                                 break;
                             case 'date':
                                 $newVal = FieldsValues::model()->findByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id));
                                 if (!is_object($newVal)) {
                                     $newVal = new FieldsValues();
                                 }
                                 $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "int_val" => strtotime($data)));
                                 $newVal->save();
                                 break;
                             case 'multiple':
                                 /* 09.04.2015
                                  * TODO: придумать что то лучше, чем удаление записей перед созданием новых...
                                  */
                                 if (is_array($data) && count($data) && $data[0]) {
                                     $oldValues = FieldsValues::model()->findAllByAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id));
                                     if (is_array($oldValues) && count($oldValues)) {
                                         foreach ($oldValues as $ov) {
                                             $ov->delete();
                                         }
                                     }
                                     if (is_array($data) && count($data)) {
                                         foreach ($data as $v) {
                                             $newVal = new FieldsValues();
                                             $newVal->setAttributes(array("field_id" => $fieldModel->id, "object_id" => $model->id, "int_val" => $v));
                                             $newVal->save();
                                         }
                                     }
                                 }
                                 break;
                         }
                     }
                 }
             }
         }
     }
     $this->render('edit', array('model' => $model, 'success' => $success, 'errors' => $model->errors));
 }
示例#29
0
 /**
  * Runs when a model is deleted.
  * Clears any entries in <tt>x2_phone_numbers</tt>.
  * Fires onAfterDelete event.
  */
 public function afterDelete()
 {
     // Clear out old tags:
     $class = get_class($this);
     Tags::model()->deleteAllByAttributes(array('type' => $class, 'itemId' => $this->id));
     // Clear out old phone numbers
     X2Model::model('PhoneNumber')->deleteAllByAttributes(array('modelId' => $this->id, 'modelType' => $class));
     RecordAliases::model()->deleteAllByAttributes(array('recordId' => $this->id, 'recordType' => $class));
     // Change all references to this record so that they retain the name but
     // exclude the ID:
     if ($this->hasAttribute('nameId') && $this->hasAttribute('name')) {
         $this->_oldAttributes = $this->getAttributes();
         $this->nameId = $this->name;
         $this->updateNameIdRefs();
     }
     // clear out associated actions
     Actions::model()->deleteAllByAttributes(array('associationType' => strtolower(self::getAssociationType(get_class($this))), 'associationId' => $this->id));
     if ($this->hasEventHandler('onAfterDelete')) {
         $this->onAfterDelete(new CEvent($this));
     }
 }
示例#30
0
                <?php 
echo $form->labelEx($ModelVideo, 'player_type');
?>
                <?php 
echo $form->dropDownList($ModelVideo, 'player_type', array('video/mp4' => 'mp4', 'video/webm' => 'webm', 'video/ogg' => 'ogg', 'rtmp/mp4' => 'rtmp'), array('class' => 'form-control'));
?>
                <?php 
echo $form->error($ModelVideo, 'player_type');
?>
            </div>
            <div class="form-group">
                <?php 
echo $form->labelEx($ModelVideo, 'tag_slug');
?>
                <?php 
$tagi = Tags::model()->findAll('tag_idvideo LIKE :Id', array(':Id' => '%"' . $ModelVideo->video_id . '"%'));
?>

                <div class="panel panel-default">
                        <div class="panel-body">
                        <?php 
foreach ($tagi as $data) {
    ?>
                    
                        <div class="checkbox-inline checkbox-tag" id="<?php 
    echo $data->tag_slug;
    ?>
">
                        <input type="checkbox" name="c" class="checkbox checkbox-tag-delete" onclick="showMe('<?php 
    echo $data->tag_slug;
    ?>