_php Techniques for displaying article class examples in CMS based on PHP

Source: Internet
Author: User
Tags modifier php programming strlen

The examples in this article describe the article classes in the PHP based CMS. Share to everyone for your reference. The specific analysis is as follows:

<?php/***********************************************//instance: include ("config.inc.php");
Database Connection File $info = new Sys_function;
$test = new Show_article; $test->set_sql ("Select ' id", ' title ', ' DateAndTime ', ' thetype ' from ' df_company_bringup ' ORDER by ' dateandtime ' DESC ')
);
$test->set_filename ("display");
$test->set_morename ("morearticle");
$test->set_icon ("☆");
$test->set_omitstr ("...");
$test->show_company_bringup (); //****article List class****/Class show_article {/**** declaration ****/var $sq
  L, $query, $arr, $article _list;
  var $strlen, $articleline, $dateandtime;
  var $len, $line, $icon, $omitstr, $line _height, $more _name;
  var $year, $month, $day, $datetype;
 var $showmore, $showdate, $showomit, $showclueon, $showicon; /**** constructor ****/function show_article () {$this->set_strlen (40);//Set the number of words per line; $this->set_articleline (10);//Set A Rticle shows the number of rows, $this->set_showmore (false); Whether to show "more article"; $this->set_showdate (true);Whether to display the article release date; $this->set_showomit (true);
  Whether the characters that are set are displayed when the word number exceeds the specified character, such as "..."; $this->set_showclueon (TRUE); Whether to display the article prompt (mouse moves to the prompt shown above article caption); $this->set_open (true);
  Whether to open in a new window; $this->set_showicon (TRUE);
  Whether to display article modification prefix; $this->set_lineheight (1.5);
  Paragraph row high value; $this->set_datetype (1);
 Set date format, 1 for 2004-10-21 2 for October 21, 2004;
  /**** sets the number of words ****/function Set_strlen ($strlen) {$this->len = $strlen for each line;
  /**** Set article display line number ****/function Set_articleline ($articleline) {$this->line = $articleline;
  /**** set Query statement ****/function Set_sql ($sql) {$this->sql = $sql;
  /**** Set article title prefix modifier ****/function Set_icon ($icon) {$this->icon = $icon;
  /**** whether to display article title prefix modifier ****/function Set_showicon ($showicon) {$this->showicon = $showicon;
  /**** whether to open a new window ****/function Set_open ($open) {$this->open = $open;
  /**** sets the character ****/function Set_omitstr ($omitstr) {$this->omitstr = $omitstr that is displayed after the article header length exceeds the limit;
} /**** setting opens article filename ****/function set_filename ($filename) {$this->filename = $filename;
  /**** more article page names ****/function set_morename ($more _name) {$this->more_name = $more _name;
  /****article category name ****/function set_typename ($type _name) {$this->type_name = $type _name;
  /**** Show more article****/function Set_showmore ($showmore) {$this->showmore = $showmore;
  /**** Set Date format (1:2004-10-21 2: October 21, 2004) ****/function Set_datetype ($datetype) {$this->datetype = $datetype; /**** format Date ****/function FormatDate ($dateandtime, $num) {list ($year, $month, $day) = Split ("[-]", substr ($dateandtim
  e,0,10)); if ($num = = 1) {return $year. " -". $month."
  -". $day; }else{return $year. " Year ". $month." Month ". $day."
  Day ";
  }/**** whether to display article release date ****/function Set_showdate ($showdate) {$this->showdate = $showdate;
  /**** paragraph row high value ****/function set_lineheight ($line _height) {$this->line_height = $line _height; /**** whether the article header length is displayedThe character ****/function Set_showomit ($showomit) {$this->showomit = $showomit is displayed after the degree exceeds the limit;
  /**** whether the prompt displayed after mouse movement to article ****/function Set_showclueon ($showclueon) {$this->showclueon = $showclueon;
  /**** gets one row from the result set as an enumerated array ****/function Execute_row ($query) {return $this->arr = mysql_fetch_row ($query); /**** gets one row from the result set as an associative array, or a numeric array, or both ****/function Execute_array ($query) {return $this->arr = mysql_fetch_array ($q
  Uery);
  /**** will release all memory ****/function Free_record ($query) {@mysql_free_result ($query) associated with result identifier results;
  The/**** call specifies article list****/function Show_company_bringup () {$n = 1; $article _list = "<div id= ' Article_list". $n. "' Style= ' line-height:". $this->line_height. "'
  > ";
  $this->query = mysql_query ($this->sql);
  while ($this->execute_row ($this->query)) {if ($this->showicon) {$article _list. = $this->icon;} $article _list. = "<a href=". $this->filename. ".
   Php?id= ". $this->arr[0]." ' "; if ($this-&Gt;showclueon) {$article _list. = "title=". $this->arr[1]. "
   ";}
  if ($this->open) {$article _list. = "target= ' _blank '";}
   $article _list. = ">"; if (strlen ($this->arr[1]) > $this->len) {if ($this->showomit) {$article _list. = substr ($this->arr[1
   ],0, $this->len). $this->omitstr;
   }else{$article _list. = substr ($this->arr[1],0, $this->len);
   }else{$article _list. = $this->arr[1];
  } if ($this->showdate) {$article _list. = "[". $this->formatdate ($this->arr[2], $this->datetype). "]";}
   $article _list. = "</a><br>\n";
  if ($n = = $this->line) {break;}
  $n + +; } if ($this->showmore) {$article _list. = "</div><div id= ' Article_list_more" $n. "' align= ' right ' ><a h Ref= ' ". $this->more_name.". Php?type= ". $this->type_name." '
  >>> > More </a></div> ";
  }else{$article _list. = "</div>";
  $this->free_record ($this->query);
  Print $article _list; }};

 

I hope this article will help you with your PHP programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.