public function run()
    {
        if (Yii::app()->user->isGuest) {
            return;
        }
        $powerAdmin = array('sagittaros', 'yiseng', 'yugene');
        $username = Yii::app()->user->id;
        if (in_array($username, $powerAdmin)) {
            $solr = new Solr('search-engine');
            $res = $solr->query('id:"' . $this->dealUrl . '"');
            $docs = $res->response->docs;
            if (array_key_exists(0, $docs)) {
                $options = array('Eateries' => 'Eateries', 'Fun & Activities' => 'Fun & Activities', 'Beauty & Wellness' => 'Beauty & Wellness', 'Goods' => 'Goods', 'Services & Others' => 'Services & Others', 'Travel' => 'Travel');
                $ajaxScript = <<<EOD
jQuery.get('/admin/dealCrud/updateCategory',
    {'id':'{$this->dealUrl}','category':jQuery(this).val()},
    postUpdateCategoryAction
); 

function postUpdateCategoryAction(data) {
    if(data == 'SUCCESS'){
        console.log("success");
        alert('success');
    } else {
        console.log(data);
        alert("update failed");
    }
}

EOD;
                $htmlOptions = array('onchange' => $ajaxScript);
                echo CHtml::dropDownList('category', $res->response->docs[0]->category_raw, $options, $htmlOptions);
            }
        }
    }
Пример #2
0
 public function actionUpdateCategory($id, $category)
 {
     $solr = new Solr('search-engine');
     $solr_arc = new Solr('archive');
     $res = $solr->query('id:"' . $id . '"');
     $oldDoc = (array) $res->response->docs[0];
     $doc = $solr->getDoc();
     $doc->id = $id;
     $doc->category = $category;
     foreach ($oldDoc as $k => $v) {
         switch ($k) {
             case 'title':
             case 'dealsource':
             case 'price':
             case 'discount':
             case 'worth':
             case 'description':
             case 'imgsrc':
             case 'expiry':
             case 'merchant':
             case 'location':
             case 'bought':
             case 'created':
                 $doc->{$k} = $v;
                 break;
         }
     }
     try {
         $solr->getService()->addDocument($doc);
         $solr->getService()->commit();
         $solr->getService()->optimize();
         $solr_arc->getService()->addDocument($doc);
         $solr_arc->getService()->commit();
         $solr_arc->getService()->optimize();
         echo 'SUCCESS';
     } catch (Exception $e) {
         echo $e->getMessage();
         echo $e->getTrace();
     }
     Yii::app()->end();
 }
Пример #3
0
 $word_variations = getRequestParam("wv") == "1";
 $filter_lang = getRequestParam("lang");
 $filter_country = getRequestParam("country");
 $filter_mimetype = getRequestParam("mime");
 $filter_source = getRequestParam("org");
 $filter_tag = array();
 if ($tag != "") {
     $filter_tag = explode(",", $tag);
 }
 if ($filter_country != "" || $filter_lang != "" || $filter_mimetype != "" || $filter_source != "") {
     $mode = "advanced";
 } else {
     $mode = "simple";
 }
 $queryField = getQueryField($search_language_code);
 $response = $solr->query($crit, $queryField, $querylang, '', 0, 0, 100, $fqitms, $word_variations, $filter_lang, $filter_country, $filter_mimetype, $filter_source, $filter_collection, $filter_tag, '', '', '', '', '', true, false);
 if ($response->getHttpStatus() == 200) {
     //print_r( $response->getRawResponse() );
     $url = $config->get("application.url");
     $title = $config->get("application.title");
     $feed = new RSS();
     $feed->title = $title;
     $feed->link = $url;
     $feed->description = "Recent articles matching your criteria : " . $crit;
     if ($response->response->numFound > 0) {
         foreach ($response->response->docs as $doc) {
             $item = new RSSItem();
             $item->title = $doc->title_dis;
             $item->link = $doc->id;
             $item->setPubDate($doc->createtime);
             $item->description = "<![CDATA[ {$doc->summary} ]]>";
Пример #4
0
                    }
                }
            }
            if (count($fqsearch) > 0) {
                $fqsearch[$fqcount] = '(' . $fqsearch[$fqcount] . ')';
            }
            if (!$facet_union) {
                $fqsearch = $fqitms;
            }
            $queryField = getQueryField($search_language_code);
            if ($groupsize > 0) {
                $item_per_page = intval($item_per_page / $groupdisplaysize);
            }
            $debug = false;
            $solr->setDebug($debug);
            $response = $solr->query($crit, $queryField, $querylang, $sort, $groupsize, ($page - 1) * $item_per_page, $item_per_page, $fqsearch, $word_variations, $filter_lang, $filter_country, $filter_mimetype, $filter_source, $filter_collection, $filter_tag, $filter_location_lat, $filter_location_lng, $filter_location_radius, $theme->getSolrFields(), $theme->getParamExtra(), $mode, false, $debug);
            if ($response->getHttpStatus() == 200) {
                $res .= $theme->generateResults();
            } else {
                $res .= $response->getHttpStatusMessage();
            }
        }
    } else {
        $res = "not pinging";
        //$res .= " (http://" . $solr_host . ":" . $solr_port . $solr_baseurl . $solr_corename . ")";
    }
} else {
    if ($action == "preferences_display") {
        $config_facet_union_check = "";
        if ($facet_union) {
            $config_facet_union_check = 'checked="checked"';