/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionGet()
 {
     if (Yii::app()->request->isAjaxRequest) {
         $criteria = new CDbCriteria();
         $criteria->condition = 'publish = :publish';
         $criteria->params = array(':publish' => 1);
         $criteria->order = 'creation_date DESC';
         $dataProvider = new CActiveDataProvider('OmmuWalls', array('criteria' => $criteria, 'pagination' => array('pageSize' => 5)));
         $data = '';
         $wall = $dataProvider->getData();
         if (!empty($wall)) {
             foreach ($wall as $key => $item) {
                 $data .= Utility::otherDecode($this->renderPartial('_view', array('data' => $item), true, false));
             }
         }
         $pager = OFunction::getDataProviderPager($dataProvider);
         if ($pager[nextPage] != '0') {
             $summaryPager = 'Displaying 1-' . $pager[currentPage] * $pager[pageSize] . ' of ' . $pager[itemCount] . ' results.';
         } else {
             $summaryPager = 'Displaying 1-' . $pager[itemCount] . ' of ' . $pager[itemCount] . ' results.';
         }
         $nextPager = $pager['nextPage'] != 0 ? Yii::app()->controller->createUrl('get', array($pager['pageVar'] => $pager['nextPage'])) : 0;
         $return = array('type' => 0, 'data' => $data, 'pager' => $pager, 'summarypager' => $summaryPager, 'nextpage' => $nextPager);
         echo CJSON::encode($return);
     } else {
         throw new CHttpException(404, Yii::t('phrase', 'The requested page does not exist.'));
     }
 }
 public function actionResult()
 {
     if (isset($_GET)) {
         $term = $_GET['keyword'];
         $index = new Zend_Search_Lucene(Yii::getPathOfAlias($this->_indexFilesPath));
         $results = $index->find($term);
         //print_r($results);
         //exit();
         if (isset($_GET['type'])) {
             $dataProvider = new CPagination(count($results));
             $currentPage = Yii::app()->getRequest()->getQuery('page', 1);
             $dataProvider->pageSize = 10;
             $pager = OFunction::getDataProviderPager($dataProvider, false);
             $get = array_merge($_GET, array($pager['pageVar'] => $pager['nextPage']));
             $nextPager = $pager['nextPage'] != 0 ? OFunction::validHostURL(Yii::app()->controller->createUrl('result', $get)) : '-';
             //print_r($pager);
             $data = '';
             if (!empty($results)) {
                 $i = $currentPage * $dataProvider->pageSize - $dataProvider->pageSize;
                 $end = $currentPage * $dataProvider->pageSize;
                 //foreach($results as $key => $item) {
                 for ($i = $i; $i < $end; $i++) {
                     $data[] = array('id' => CHtml::encode($results[$i]->id), 'category' => CHtml::encode($results[$i]->category), 'media' => CHtml::encode($results[$i]->media), 'title' => CHtml::encode($results[$i]->title), 'body' => CHtml::encode($results[$i]->body), 'date' => CHtml::encode($results[$i]->date), 'view' => CHtml::encode($results[$i]->view));
                 }
             } else {
                 $data = array();
             }
             $return = array('data' => $data, 'pager' => $pager, 'nextPager' => $nextPager);
             echo CJSON::encode($return);
         } else {
             $query = Zend_Search_Lucene_Search_QueryParser::parse($term);
             $this->pageTitleShow = true;
             $this->pageTitle = 'Hasil Pencarian: ' . $_GET['keyword'];
             $this->pageDescription = '';
             $this->pageMeta = '';
             $this->render('application.webs.search.front_result', compact('results', 'term', 'query'));
         }
     } else {
         $this->redirect(Yii::app()->createUrl('site/index'));
     }
 }
 /**
  * PHP Regex to Make Twitter Links Clickable
  */
 public static function OParse($data)
 {
     $return = OFunction::twitterParse($data);
     return $return;
 }
 *
 */
/* Get Comment */
$criteria = new CDbCriteria();
$criteria->condition = 'publish = :publish AND parent_id = :parent AND wall_id = :wall';
$criteria->params = array(':publish' => 1, ':parent' => 0, ':wall' => $data->wall_id);
$criteria->order = 'creation_date ASC';
$dataProvider = new CActiveDataProvider('OmmuWallComment', array('criteria' => $criteria, 'pagination' => array('pageSize' => 5)));
$val = '';
$comment = $dataProvider->getData();
if (!empty($comment)) {
    foreach ($comment as $key => $item) {
        $val .= Utility::otherDecode($this->renderPartial('/wall_comment/_view', array('data' => $item), true, false));
    }
}
$commentPager = OFunction::getDataProviderPager($dataProvider);
$commentNextPager = $commentPager['nextPage'] != 0 ? Yii::app()->createUrl('wallcomment/get', array('id' => $data->wall_id, $commentPager['pageVar'] => $commentPager['nextPage'])) : 0;
?>

<div class="sep comment-show" id="wall-<?php 
echo $data->wall_id;
?>
">
	<div class="user">
		<?php 
if ($data->user->photo_id == 0) {
    $images = Utility::getTimThumb(Yii::app()->request->baseUrl . '/public/users/default.png', 60, 60, 1);
} else {
    $images = Utility::getTimThumb(Yii::app()->request->baseUrl . '/public/users/' . Yii::app()->user->id . '/' . $data->user->photo->photo, 60, 60, 1);
}
?>
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionGet($id)
 {
     if (Yii::app()->request->isAjaxRequest) {
         $criteria = new CDbCriteria();
         $criteria->condition = 'publish = :publish AND parent_id = :parent AND wall_id = :wall';
         $criteria->params = array(':publish' => 1, ':parent' => 0, ':wall' => $id);
         $criteria->order = 'creation_date ASC';
         $dataProvider = new CActiveDataProvider('OmmuWallComment', array('criteria' => $criteria, 'pagination' => array('pageSize' => 5)));
         $data = '';
         $comment = $dataProvider->getData();
         if (!empty($comment)) {
             foreach ($comment as $key => $item) {
                 $data .= Utility::otherDecode($this->renderPartial('/wall_comment/_view', array('data' => $item), true, false));
             }
         }
         $pager = OFunction::getDataProviderPager($dataProvider);
         $nextPager = $pager['nextPage'] != 0 ? Yii::app()->controller->createUrl('get', array('id' => $id, $pager['pageVar'] => $pager['nextPage'])) : 0;
         $return = array('type' => 1, 'wallid' => 'wall-' . $id, 'data' => $data, 'pager' => $pager, 'nextpage' => $nextPager);
         echo CJSON::encode($return);
     } else {
         throw new CHttpException(404, Yii::t('phrase', 'The requested page does not exist.'));
     }
 }
 /**
  * Manages all models.
  */
 public function actionDashboard()
 {
     /* Wall Post */
     $model = new OmmuWalls();
     /* Get Walll */
     $criteria = new CDbCriteria();
     $criteria->condition = 'publish = :publish';
     $criteria->params = array(':publish' => 1);
     $criteria->order = 'creation_date DESC';
     $dataProvider = new CActiveDataProvider('OmmuWalls', array('criteria' => $criteria, 'pagination' => array('pageSize' => 5)));
     $data = '';
     $wall = $dataProvider->getData();
     if (!empty($wall)) {
         foreach ($wall as $key => $item) {
             $data .= Utility::otherDecode($this->renderPartial('/wall/_view', array('data' => $item), true, false));
         }
     }
     $pager = OFunction::getDataProviderPager($dataProvider);
     if ($pager[nextPage] != '0') {
         $summaryPager = 'Displaying 1-' . $pager[currentPage] * $pager[pageSize] . ' of ' . $pager[itemCount] . ' results.';
     } else {
         $summaryPager = 'Displaying 1-' . $pager[itemCount] . ' of ' . $pager[itemCount] . ' results.';
     }
     $nextPager = $pager['nextPage'] != 0 ? Yii::app()->createUrl('wall/get', array($pager['pageVar'] => $pager['nextPage'])) : 0;
     $this->pageTitle = Yii::t('phrase', 'Welcome') . ', ' . Yii::app()->user->displayname . '!';
     $this->pageDescription = Yii::t('phrase', 'Welcome to your social network control panel. Here you can manage and modify every aspect of your social network. Directly below, you will find a quick snapshot of your social network including some useful statistics.');
     $this->pageMeta = '';
     $this->render('application.webs.admin.admin_dashboard', array('model' => $model, 'data' => $data, 'pager' => $pager, 'summaryPager' => $summaryPager, 'nextPager' => $nextPager));
 }