[CS-Project-svn_notify] SF.net SVN: cs-project: [731] trunk/lib
Brought to you by:
crazedsanity
From: <cra...@us...> - 2007-12-28 01:53:12
|
Revision: 731 http://cs-project.svn.sourceforge.net/cs-project/?rev=731&view=rev Author: crazedsanity Date: 2007-12-27 17:53:11 -0800 (Thu, 27 Dec 2007) Log Message: ----------- Lib changes for tag icons.... WEE! /lib/mainRecordClass.php: * get_records(): -- don't use tag_list() stored procedure anymore. -- create tag list using tagClass::get_tag_list_for_record(). /lib/tagClass.php: * MAIN::: -- new constant iconPath='/images/tags/' -- new constant iconExt='.gif' * get_tags_for_record(): -- ARG CHANGE: NEW ARG: #2 ($getIconName=FALSE) -- optionally retrieve icon_name from database. -- if $getIconName is set, pull a more complex array, including calling the new "create_icon_image_html()" method & placing the output into an index called "imgHtml". * get_tag_list_for_record() [NEW]: -- pull list of tags that can contain icons (possibly only the icons). * create_icon_image_html() [NEW]: -- create HTML for the image location of the icon. Modified Paths: -------------- trunk/lib/mainRecordClass.php trunk/lib/tagClass.php Modified: trunk/lib/mainRecordClass.php =================================================================== --- trunk/lib/mainRecordClass.php 2007-12-28 01:48:00 UTC (rev 730) +++ trunk/lib/mainRecordClass.php 2007-12-28 01:53:11 UTC (rev 731) @@ -186,8 +186,7 @@ //TODO: when retrieving the list of projects, "record_get_num_children()" is unaware of the group, and can't even guess what status it should filter on... leads to the "Project #<blah> disappeared" problem. $query = "SELECT r.*, record_get_num_children(record_id) as num_children, s.name as status_text, " . - "u.username as assigned, ce.email, c.fname, c.lname, c.company, " . - "tag_list(r.record_id) " . + "u.username as assigned, ce.email, c.fname, c.lname, c.company " . "FROM record_table AS r INNER JOIN status_table AS s ON (s.status_id=r.status_id) " . "INNER JOIN contact_table AS c ON (r.creator_contact_id=c.contact_id) " . "INNER JOIN contact_email_table AS ce ON (c.contact_email_id=ce.contact_email_id)" . @@ -212,12 +211,16 @@ $retval = $this->db->farray_fieldnames("public_id",NULL,0); //format the start_date + $tagObj = new tagClass($this->db); foreach($retval as $index=>$data) { $tmp = explode('.', $data['start_date']); if(preg_match('/00:00:00$/', $tmp[0])) { $tmp[0] = preg_replace('/ 00:00:00$/', '', $tmp[0]); } $retval[$index]['start_date'] = $tmp[0]; + + //retrieve a list of tags. + $retval[$index]['tag_list'] = $tagObj->get_tag_list_for_record($data['record_id'], TRUE, FALSE); } //set it into cache. Modified: trunk/lib/tagClass.php =================================================================== --- trunk/lib/tagClass.php 2007-12-28 01:48:00 UTC (rev 730) +++ trunk/lib/tagClass.php 2007-12-28 01:53:11 UTC (rev 731) @@ -26,6 +26,12 @@ /** Object for logging stuff */ private $logsObj; + /** Path to tag images... */ + const iconPath = '/images/tags/'; + + /** Extension for all tag images... */ + const iconExt = '.gif'; + //========================================================================= /** * Constructor. Requires connected phpDB{} object. @@ -143,12 +149,18 @@ * @return NULL FAIL: no records * @return (exception) FAIL: database error */ - public function get_tags_for_record($recordId) { + public function get_tags_for_record($recordId, $getIconName=FALSE) { // $sqlArr = array ( 'record_id' => cleanString($recordId, 'numeric') ); - $sql = "SELECT tag_name_id, name FROM tag_name_table INNER JOIN tag_table USING (tag_name_id) " . + + $selectThis = 'tag_name_id, name'; + if($getIconName) { + $selectThis .= ', icon_name'; + } + + $sql = "SELECT ". $selectThis ." FROM tag_name_table INNER JOIN tag_table USING (tag_name_id) " . "WHERE ". string_from_array($sqlArr, 'select') .' ORDER BY lower(name)'; $numrows = $this->db->exec($sql); @@ -168,7 +180,15 @@ } else { //retrieve the data for returning. - $retval = $this->db->farray_nvp('tag_name_id', 'name'); + if($getIconName) { + $retval = $this->db->farray_fieldnames('tag_name_id', NULL, 0); + foreach($retval as $index=>$value) { + $retval[$index]['imgHtml'] = $this->create_icon_image_html($value['icon_name'], $value['name']); + } + } + else { + $retval = $this->db->farray_nvp('tag_name_id', 'name'); + } } return($retval); @@ -492,6 +512,60 @@ return($retval); }//end update_tag_modifier() //========================================================================= + + + + //========================================================================= + public function get_tag_list_for_record($recordId, $addImageHTML=TRUE, $onlyShowIcons=FALSE) { + $data = $this->get_tags_for_record($recordId, TRUE); + + + + $retval = NULL; + if(is_array($data)) { + $gf = new cs_globalFunctions(); + + foreach($data as $index=>$value) { + if($addImageHTML) { + if($onlyShowIcons) { + if(strlen($value['icon_name'])) { + $current = $this->create_icon_image_html($value['icon_name'], $value['name']); + } + else { + $current = $value['name']; + } + } + else { + if(strlen($value['icon_name'])) { + $current = $value['name'] .' '. $this->create_icon_image_html($value['icon_name'], $value['name']); + } + else { + $current = $value['name']; + } + } + } + else { + $current = $value['icon_name']; + } + $retval = $gf->create_list($retval, $current, ','); + } + } + + return($retval); + }//end get_tag_list_for_record() + //========================================================================= + + + + //========================================================================= + public function create_icon_image_html($icon, $name=NULL) { + $retval = NULL; + if(strlen($icon)) { + $retval = '<img src="' . self::iconPath . $icon . self::iconExt . '" alt="'. $name .'" border="0">'; + } + return($retval); + }//end create_icon_image_html() + //========================================================================= } ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |