public function ArticleDetails()
 {
     global $dbObj, $common;
     $action = $common->replaceEmpty('action', '');
     $number = $common->replaceEmpty('number', '');
     $retvalArray = array();
     $finalArray1 = array();
     $serverrul = "http://" . $_SERVER['HTTP_HOST'];
     if ($action = 'newsdetails') {
         if (!isset($number) || ($number == "" || $number == 0)) {
             $page = 1;
         } else {
             $page = $number;
         }
         $query = "SELECT ac.id as cid,ac.title,ac.alias,ac.introtext,ab.params,\n\t\tac.fulltext,ac.created,ac.images,ac.urls,ac.attribs FROM ras_categories as ab left join ras_content as\n\t\tac on ab.id = ac.catid where ab.id = '11' and ac.state='1' order by ac.created desc ";
         ######### FOr Android Pagination #################
         $sql = $dbObj->runQuery($query);
         $total_records = mysql_num_rows($sql);
         $num_pages = ceil($total_records / 10);
         //$start = 0; //10 * ($page-1);
         $start = 10 * ($page - 1);
         //$end = 20 * $page;
         $end = 10;
         $query .= " limit {$start},{$end} ";
         $rs1 = $dbObj->runQuery($query);
         ########################################################
         if (mysql_num_rows($rs1) > 0) {
             while ($data1 = mysql_fetch_assoc($rs1)) {
                 $tempArray1 = array();
                 $tempArray1['cid'] = $data1['cid'];
                 $tempArray1['title_short1'] = htmlspecialchars(truncateWords(strip_tags(mb_convert_encoding($data1['title'], 'utf-8')), 10, "..."));
                 $tempArray1['title_short'] = str_replace('&', '&', $tempArray1['title_short1']);
                 $tempArray1['introtext_short'] = htmlspecialchars(truncateWords(strip_tags(mb_convert_encoding($data1['introtext'], 'utf-8')), 20, "..."));
                 $created = date('d-m-Y', strtotime($data1['created']));
                 $tempArray1['created'] = date('d F Y', strtotime($created));
                 $paramsArray1 = array();
                 $paramsArray1 = json_decode($data1['urls'], true);
                 if ($paramsArray1['urlb'] != '') {
                     $tempArray1['urlb'] = $serverrul . '/' . $paramsArray1['urlb'];
                 } else {
                     $tempArray1['urlb'] = $serverrul . '/images/5.jpg';
                 }
                 $finalArray1[] = $tempArray1;
                 array_push($tempArray1, $finalArray1);
             }
             $dat1 = array('status' => '1', 'num_pages' => $num_pages, 'result' => $finalArray1);
             //header( 'Content-Type: text/html; charset=utf-8' );
             echo json_encode($dat1);
             exit;
         } else {
             $finalArray1['status'] = '0';
             echo json_encode($finalArray1);
             exit;
         }
     }
 }
 $start = 4 * ($page - 1);
 $end = 4;
 $query .= " limit {$start},{$end} ";
 $rs = mysql_query($query);
 ########################################################
 if (mysql_num_rows($rs) > 0) {
     while ($data = mysql_fetch_assoc($rs)) {
         $result['title'] = $logindetails['title'];
         $tempArray = array();
         $tempArray['cid'] = $data['cid'];
         $tempArray['title'] = $data['title'];
         $tempArray['title_short'] = truncateWords(str_replace('&', '&', strip_tags(mb_convert_encoding($data['title'], 'utf-8'))), 5, "...");
         $tempArray['alias'] = $data['alias'];
         $serverrul = "http://" . $_SERVER['HTTP_HOST'];
         $tempArray['introtext'] = str_replace('&', '&', strip_tags(mb_convert_encoding($data['introtext'], 'utf-8')));
         $tempArray['introtext_short'] = truncateWords(str_replace('&', '&', strip_tags(mb_convert_encoding($data['introtext'], 'utf-8'))), 20, "...");
         //$tempArray['introtext_short'] =  truncateWords(strip_tags(mb_convert_encoding($data['introtext'],'utf-8')), 20, "...");
         $created = date('d-m-Y', strtotime($data['created']));
         $tempArray['created'] = date('d F Y', strtotime($created));
         $paramsArray = array();
         $paramsArray = json_decode($data['images'], true);
         $tempArray['images'] = $serverrul . '/' . $paramsArray['image_intro'];
         $paramsArray = array();
         $paramsArray = json_decode($data['urls'], true);
         if ($paramsArray['urlb'] != '') {
             $tempArray['urlb'] = $serverrul . '/' . $paramsArray['urlb'];
         } else {
             $tempArray['urlb'] = $serverrul . '/images/5.jpg';
         }
         if ($paramsArray['urlc'] != '') {
             $tempArray['urlc'] = $serverrul . '/' . $paramsArray['urlc'];
function prepareDescription($desc)
{
    $truncated = truncateWords($desc, 10);
    $output = $truncated == '' ? '' : '<span title="' . $desc . '">' . $truncated . '</span>';
    return $output;
}
 public function ArticleDetails12()
 {
     global $dbObj, $common;
     $action = $common->replaceEmpty('action', '');
     $number = $common->replaceEmpty('number', '');
     $retvalArray = array();
     $finalArray = array();
     if ($action = 'articlelist') {
         if (!isset($number) || ($number == "" || $number == 0)) {
             $page = 1;
         } else {
             $page = $number;
         }
         $query = "SELECT ac.id AS cid, ac.title, ac.alias, ac.introtext, ab.params, ac.fulltext, ac.created, ac.images, ac.urls, ac.attribs\n\t\t\t\tFROM ras_categories AS ab\n\t\t\t\tLEFT JOIN ras_content AS ac ON ab.id = ac.catid \n\t\t\t\tWHERE ab.id =  '27' and ac.state='1'\n\t\t\t\tORDER BY ac.created DESC ";
         // $sql = $dbObj->runQuery($query);
         //$total_records = mysql_num_rows($sql);
         //$num_pages = ceil($total_records/4);
         // $start =  4* ($page-1);
         //$end = 4;
         // $query .= "limit $start,$end";
         //$rs = $dbObj->runQuery($query);
         ######### FOr Android #################
         $sql = $dbObj->runQuery($query);
         $total_records = mysql_num_rows($sql);
         $num_pages = ceil($total_records / 4);
         //$start = 0;
         //10 * ($page-1);
         $start = 4 * ($page - 1);
         //$end = 4 * $page;
         $end = 4;
         $query .= " limit {$start},{$end} ";
         $rs = $dbObj->runQuery($query);
         //echo "num_pages".".$num_pages." ;
         ########################################################
         if (mysql_num_rows($rs) > 0) {
             while ($data = mysql_fetch_assoc($rs)) {
                 // print_r($data); //strip_tags
                 $tempArray = array();
                 $tempArray['cid'] = $data['cid'];
                 //$tempArray['title']     = $data['title'];
                 $tempArray['title'] = $data['title'];
                 $tempArray['title_short'] = truncateWords(str_replace('&amp;', '&', strip_tags(mb_convert_encoding($data['title'], 'utf-8'))), 5, "...");
                 $tempArray['alias'] = $data['alias'];
                 $serverrul = "http://" . $_SERVER['HTTP_HOST'];
                 $tempArray['introtext'] = str_replace('&amp;', '&', strip_tags(mb_convert_encoding($data['introtext'], 'utf-8')));
                 $tempArray['introtext_short'] = truncateWords(str_replace('&amp;', '&', strip_tags(mb_convert_encoding($data['introtext'], 'utf-8'))), 20, "...");
                 //$tempArray['introtext_short'] =  truncateWords(strip_tags(mb_convert_encoding($data['introtext'],'utf-8')), 20, "...");
                 $created = date('d-m-Y', strtotime($data['created']));
                 $tempArray['created'] = date('d F Y', strtotime($created));
                 $paramsArray = array();
                 $paramsArray = json_decode($data['images'], true);
                 $tempArray['images'] = $serverrul . '/' . $paramsArray['image_intro'];
                 $paramsArray = array();
                 $paramsArray = json_decode($data['urls'], true);
                 if ($paramsArray['urlb'] != '') {
                     $tempArray['urlb'] = $serverrul . '/' . $paramsArray['urlb'];
                 } else {
                     $tempArray['urlb'] = $serverrul . '/images/5.jpg';
                 }
                 if ($paramsArray['urlc'] != '') {
                     $tempArray['urlc'] = $serverrul . '/' . $paramsArray['urlc'];
                 } else {
                     $tempArray['urlc'] = $serverrul . '/images/5.jpg';
                 }
                 $finalArray[] = $tempArray;
                 array_push($tempArray, $finalArray);
             }
             $dat = array('status' => '1', 'num_pages' => $num_pages, 'result' => $finalArray);
             echo json_encode($dat);
             exit;
         } else {
             $retvalArray['status'] = '0';
             echo json_encode($retvalArray);
             exit;
         }
     }
 }
Example #5
0
 $end = 10;
 $query .= " limit {$start},{$end} ";
 $rs = mysql_query($query);
 ########################################################
 if (mysql_num_rows($rs) > 0) {
     while ($data1 = mysql_fetch_assoc($rs)) {
         $tempArray1 = array();
         $tempArray1['cid'] = $data1['cid'];
         $tempArray1['title'] = $data1['title'];
         $tempArray1['title_short1'] = htmlspecialchars(truncateWords(strip_tags(mb_convert_encoding($data1['title'], 'utf-8')), 10, "..."));
         $tempArray1['title_short'] = str_replace('&amp;', '&', $tempArray1['title_short1']);
         $tempArray1['alias'] = $data1['alias'];
         $serverrul = "http://" . $_SERVER['HTTP_HOST'];
         $tempArray1['introtext_short'] = htmlspecialchars(truncateWords(strip_tags(mb_convert_encoding($data1['introtext'], 'utf-8')), 20, "..."));
         $tempArray1['introtext'] = str_replace('&amp;', '&', strip_tags(mb_convert_encoding($data1['introtext'], 'utf-8')));
         $tempArray1['introtext_short'] = htmlspecialchars(truncateWords(strip_tags(mb_convert_encoding($data1['introtext'], 'utf-8')), 20, "..."));
         $created = date('d-m-Y', strtotime($data1['created']));
         $tempArray1['created'] = date('d F Y', strtotime($created));
         $paramsArray1 = array();
         $paramsArray1 = json_decode($data1['urls'], true);
         if ($paramsArray1['urlb'] != '') {
             $tempArray1['urlb'] = $serverrul . '/' . $paramsArray1['urlb'];
         } else {
             $tempArray1['urlb'] = $serverrul . '/images/5.jpg';
         }
         $finalArray1[] = $tempArray1;
         array_push($tempArray1, $finalArray1);
     }
     $dat1 = array('status' => '1', 'num_pages' => $num_pages, 'result' => $finalArray1);
     //header( 'Content-Type: text/html; charset=utf-8' );
     echo json_encode($dat1);