| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /inetpub/wwwroot/icd/components/com_staffmaster/helper/ |
Upload File : |
<?php
/**
* File: smoutputhelper.php
*
* Staff Master 1.0 RC 1
*
* Staff Master - Staff Members and Departments Manager
*
* @version 1.0.rc.1
* @package StaffMaster_1_0_rc_1
* @subpackage: frontend_helper
* @copyright (C) 2007-2008 Travis Hubbard
* @license http://www.gnu.org/licenses/ GNU/GPL v3
* @link http://www.systemsunited.net/
**/
class SMOutputHelper
{
/**
* Helper Function: Create HTML necessary for contact info to slide into View
*
* @param stdObject Complete params object comes in
* @param stdObjectRow One row from the staff list comes in by reference
* @param string One row from the staff list comes in by reference
*
* @return nothing By Reference; HTML for Contact Info passed back to function via $staff->address4
* @access private
**/
function createContactInfo( $params , $staff )
{
$COLON = ': ';
$tag_label = 'li';
$class_label = 'contact_label';
$tag_data = 'li';
$class_data = 'contact_data';
$tag_list = 'ul';
$class_list = 'contact_info';
$multiline = $params->contact_info_multiline;
$has_data = false;
$contact_html = '';
// CONTACT INFO - PHONE 1
if( !empty( $staff->phone1 ) )
{
// Check to see if contact label Phone1 is empty
if( !empty( $params->cl_phone1 ) )
{
if( substr( $params->cl_phone1 , -1 , 1 ) != $COLON )
$params->cl_phone1 .= $COLON;
$contact_html .= '<' . $tag_label .' class="' . $class_label .'">' . $params->cl_phone1;
if( $multiline )
$contact_html .= ' </'. $tag_label .'>';
}
if( $multiline )
$contact_html .= '<'. $tag_data .' class="'. $class_data .'">';
$contact_html .= $staff->phone1;
// CONTACT INFO - PHONE 1 EXTENSION
if( !empty( $staff->ext1 ) ) {
$contact_html .= ' ' . $params->cl_phone_ext1 . ' ' .$staff->ext1;
}
if( $multiline )
$contact_html .= ' </'. $tag_data .'>';
else
$contact_html .= ' </'. $tag_label .'>';
$has_data = true;
}
// CONTACT INFO - PHONE 2
if( !empty( $staff->phone2 ) )
{
if( !empty( $params->cl_phone2 ) )
{
if( substr( $params->cl_phone2 , -1 , 1 ) != $COLON )
$params->cl_phone2 .= $COLON;
$contact_html .= '<' . $tag_label .' class="' . $class_label .'">' . $params->cl_phone2;
if( $multiline )
$contact_html .= ' </'. $tag_label .'>';
}
if( $multiline )
$contact_html .= '<'. $tag_data .' class="'. $class_data .'">';
$contact_html .= $staff->phone2;
// CONTACT INFO - PHONE 2 EXTENSION
if( !empty( $staff->ext2 ) ) {
$contact_html .= ' ' . $params->cl_phone_ext2 . ' ' .$staff->ext2;
}
if( $multiline )
$contact_html .= ' </'. $tag_data .'>';
else
$contact_html .= ' </'. $tag_label .'>';
$has_data = true;
}
// CONTACT INFO - EMAIL
if( !empty( $staff->email ) )
{
if( !empty( $params->cl_email ) )
{
if( substr( $params->cl_email , -1 , 1 ) != $COLON )
$params->cl_email .= $COLON;
$contact_html .= '<' . $tag_label .' class="' . $class_label .'">' . $params->cl_email;
if( $multiline )
$contact_html .= ' </'. $tag_label .'>';
}
if( $multiline )
$contact_html .= '<'. $tag_data .' class="'. $class_data .'">';
//$staff->email = 'mailto:' . $staff->email;
$email = JHTML::_( 'Email.cloak' , $staff->email );
//$email = $staff->email;
$contact_html .= $email;
if( $multiline )
$contact_html .= ' </'. $tag_data .'>';
else
$contact_html .= ' </'. $tag_label .'>';
$has_data = true;
}
// CONTACT INFO - ADDRESS 1
if( !empty( $staff->address1 ) )
{
if( !empty( $params->cl_address1 ) )
{
if( substr( $params->cl_address1 , -1 , 1 ) != $COLON )
$params->cl_address1 .= $COLON;
$contact_html .= '<' . $tag_label .' class="' . $class_label .'">' . $params->cl_address1;
if( $multiline )
$contact_html .= ' </li>';
}
if( $multiline )
$contact_html .= '<'. $tag_data .' class="'. $class_data .'">';
$contact_html .= $staff->address1;
if( $multiline )
$contact_html .= ' </'. $tag_data .'>';
else
$contact_html .= ' </'. $tag_label .'>';
$has_data = true;
}
// CONTACT INFO - ADDRESS 2
if( !empty( $staff->address2 ) )
{
if( !empty( $params->cl_address2 ) )
{
if( substr( $params->cl_address2 , -1 , 1 ) != $COLON )
$params->cl_address2 .= $COLON;
}
$contact_html .= '<' . $tag_label .' class="' . $class_label .'">' . $params->cl_address2;
if( $multiline )
{
$contact_html .= ' </li>';
$contact_html .= '<'. $tag_data .' class="'. $class_data .'">';
}
$contact_html .= $staff->address2;
if( $multiline )
$contact_html .= ' </'. $tag_data .'>';
else
$contact_html .= ' </'. $tag_label .'>';
$has_data = true;
}
// CONTACT INFO - ADDRESS 3
if( !empty( $staff->address3 ) )
{
if( !empty( $params->cl_address3 ) )
{
if( substr( $params->cl_address3 , -1 , 1 ) != $COLON )
$params->cl_address3 .= $COLON;
}
$contact_html .= '<' . $tag_label .' class="' . $class_label .'">' . $params->cl_address3;
if( $multiline )
{
$contact_html .= ' </li>';
$contact_html .= '<'. $tag_data .' class="'. $class_data .'">';
}
$contact_html .= $staff->address3;
if( $multiline )
$contact_html .= ' </'. $tag_data .'>';
else
$contact_html .= ' </'. $tag_label .'>';
$has_data = true;
}
// CONTACT INFO - ADDRESS 4
if( !empty( $staff->address4 ) )
{
if( !empty( $params->cl_address4 ) )
{
if( substr( $params->cl_address4 , -1 , 1 ) != $COLON )
$params->cl_address4 .= $COLON;
}
$contact_html .= '<' . $tag_label .' class="' . $class_label .'">' . $params->cl_address4;
if( $multiline )
{
$contact_html .= ' </li>';
$contact_html .= '<'. $tag_data .' class="'. $class_data .'">';
}
$contact_html .= $staff->address4;
if( $multiline )
$contact_html .= ' </'. $tag_data .'>';
else
$contact_html .= ' </'. $tag_label .'>';
$has_data = true;
}
if( $has_data ) {
$contact_html = '<' . $tag_list . ' class="' . $class_list . ' ' . $params->staff_image_pos . '">' . $contact_html . '<li> </li> </ul>';
}
return $contact_html;
}
/**
* Helper Function: Truncate Staff Bio passed in By Reference via &$staff, truncated down to $bioLen
*
* @param stdObject One row from the staff list comes in by reference
* @param int bioLen = length to stop staff bio and add Read More
*
* @return string By Reference; HTML for Staff Bio passed back to function via $staff->bio
* @access private
**/
function cropBios( $staff , $bioLen ) {
global $option;
$bio = $staff->bio;
if( strlen( $bio ) > $bioLen ) {
$bio = substr( $bio , 0 , $bioLen );
$bio_readmore_link = JRoute::_( 'index.php?option=' . $option . '&view=staff&name=' . $staff->alias );
$bio_readmore_html = '<br /><br /><a href="' . $bio_readmore_link .'" >' . JText::_("SM_READ_MORE") . '</a>';
$staff->bio = $bio . $bio_readmore_html;
}
return $bio;
}
function createDepartmentFooters( $department , $params )
{
$department_footer_output = array();
$department_footer_output['hasData'] = false;
if( !empty( $department->footer_text ) ) {
$department_footer_output['footer_text'] = $department->footer_text;
$department_footer_output['hasData'] = true;
}
else {
$department_footer_output['footer_text'] = '';
}
if( $params->show_dept_footer_text1 && !empty( $params->job_text1 ) ) {
$department_footer_output[ 'job_text1' ] = $params->job_text1;
$department_footer_output['hasData'] = true;
}
else {
$department_footer_output['job_text1'] = '';
}
if( $params->show_dept_footer_text2 && !empty( $params->job_text2 ) ) {
$department_footer_output[ 'job_text2' ] = $params->job_text2;
$department_footer_output['hasData'] = true;
}
else {
$department_footer_output['job_text2'] = '';
}
if( $params->show_dept_footer_text3 && !empty( $params->job_text3 ) ) {
$department_footer_output[ 'job_text3' ] = $params->job_text3;
$department_footer_output['hasData'] = true;
}
else {
$department_footer_output['job_text3'] = '';
}
if( !$department_footer_output['hasData'] )
$department_footer_output['dept_break'] = '<div class="dept_break"><br /></div>';
return $department_footer_output;
}
/**
* getCustomColors create the custom colors assoc array
*
* @param string $params_custom_colors
* @return array with following options
*
* USABLE DISPLAY OPTIONS
* page_title_style
* dept_name_style
* dept_desc_style
* staff_name_style
* staff_title_style
* staff_bio_style
* dept_unique_foot_style
* dept_general_foot_style
* contact_details_style
* contact_details_link_style
*
*/
function getCustomColors( $params_custom_colors , $use_colors = true )
{
// Return Variable
$ret_cc = array();
$custom_colors = array();
$cc = explode( ';' , $params_custom_colors );
foreach( $cc as $tcc )
{
$tcc = explode( '=' , $tcc );
$custom_colors[ trim( $tcc[ 0 ] ) ] = $tcc[ 1 ];
}
if( !empty( $custom_colors['page_title_color'] ) && $use_colors )
$ret_cc[ 'page_title_style' ] = 'style="color:#' . $custom_colors['page_title_color'] .'"';
else
$ret_cc[ 'page_title_style' ] = '';
if( !empty( $custom_colors['dept_name_color'] ) && $use_colors )
$ret_cc[ 'dept_name_style' ] = 'style="color:#' . $custom_colors['dept_name_color'] .'"';
else
$ret_cc[ 'dept_name_style' ] = '';
if( !empty( $custom_colors['dept_desc_color'] ) && $use_colors )
$ret_cc[ 'dept_desc_style' ] = 'style="color:#' . $custom_colors['dept_desc_color'] .'"';
else
$ret_cc[ 'dept_desc_style' ] = '';
if( !empty( $custom_colors['staff_name_color'] ) && $use_colors )
$ret_cc[ 'staff_name_style' ] = 'style="color:#' . $custom_colors['staff_name_color'] .'"';
else
$ret_cc[ 'staff_name_style' ] = '';
if( !empty( $custom_colors['staff_title_color'] ) && $use_colors )
$ret_cc[ 'staff_title_style' ] = 'style="color:#' . $custom_colors['staff_title_color'] .'"';
else
$ret_cc[ 'staff_title_style' ] = '';
if( !empty( $custom_colors['staff_bio_color'] ) && $use_colors )
$ret_cc[ 'staff_bio_style' ] = 'style="color:#' . $custom_colors['staff_bio_color'] .'"';
else
$ret_cc[ 'staff_bio_style' ] = '';
if( !empty( $custom_colors['dept_unique_foot_color'] ) && $use_colors )
$ret_cc[ 'dept_unique_foot_style' ] = 'style="color:#' . $custom_colors['dept_unique_foot_color'] .'"';
else
$ret_cc[ 'dept_unique_foot_style' ] = '';
if( !empty( $custom_colors['dept_general_foot_color'] ) && $use_colors )
$ret_cc[ 'dept_general_foot_style' ] = 'style="color:#' . $custom_colors['dept_general_foot_color'] .'"';
else
$ret_cc[ 'dept_general_foot_style' ] = '';
if( !empty( $custom_colors['contact_details'] ) && $use_colors )
$ret_cc[ 'contact_details_style' ] = 'style="color:#' . $custom_colors['contact_details'] .'"';
else
$ret_cc[ 'contact_details_style' ] = '';
if( !empty( $custom_colors['contact_details_link'] ) && $use_colors )
$ret_cc[ 'contact_details_link_style' ] = 'style="color:#' . $custom_colors['contact_details_link'] .'"';
else
$ret_cc[ 'contact_details_link_style' ] = '';
return $ret_cc;
}
function createImageHtml( $attribs )
{
$image_html = '<img ';
$image_html .= 'src="' . $attribs->src . '" ';
if( !empty( $attribs->alt ) )
$image_html .= 'alt="' . $attribs->alt . '" ';
if( !empty( $attribs->title ) )
$image_html .= 'title="' . $attribs->title . '" ';
if( !empty( $attribs->class ) )
$image_html .= 'class="' . $attribs->class . '" ';
if( !empty( $attribs->id ) )
$image_html .= 'id="' . $attribs->id . '" ';
if( !empty( $attribs->style ) )
$image_html .= 'style="' . $attribs->style . '" ';
if( !empty( $attribs->width ) )
$image_html .= 'width="' . $attribs->width . '" ';
if( !empty( $attribs->height ) )
$image_html .= 'height="'. $attribs->height . '" ';
$image_html .= '/>';
return $image_html;
}
/**
* creates the html for a staff title
*
* @param int $loc does this staff title belong in bio or next to name? 1=bio 0=name
* @param String $style any associated style/color with title
* @param String $title actual title text
* @return String $ret_title title + HTML
*/
function createStaffTitleHtml( $loc , $style , $title )
{
$tag = 'span';
$ret_title = '<' . $tag . ' class="';
if( $loc )
$ret_title .= 'staff_title_bio';
else
$ret_title .= 'staff_title';
$ret_title .= '" ' . $style . '>' . $title . '</' . $tag . '>';
return $ret_title;
}
/**
* takes staff bio/department description text and parses for system-readmore break
*
* @param String $staffDept is this 'staff' or 'department' for link
* @param String $text_to_parse the actual text ( bio / description ) to be parsed
* @param String $link_alias staff/department alias for creating the link
* @param String $crop_at_readmore should we crop this text at the readmore break?
* @return String $ret_text returns the text back minus the system-readmore, adding the staff master readmore
*/
function parseReadMore( $staffDept , $text_to_parse , $link_alias , $crop_at_readmore )
{
global $option;
$ret_text = '';
$pattern = '#<hr\s+id=("|\')system-readmore("|\')\s*\/*>#i';
$text = stripslashes( str_replace( '<br>' , '<br />' , $text_to_parse ) );
$tagPos = preg_match( $pattern , $text );
if ($tagPos == 0)
{
$ret_text = $text;
}
else
{
$text_to_parse = preg_split( $pattern , $text , 2 );
$link = JRoute::_( 'index.php?option=' . $option . '&view=' . $staffDept . '&name=' . $link_alias );
$link_html = '<br /><a href="' . $link .'" >'
. '<span class="staff-readmore">'
. JText::_('SM_READ_MORE')
. '</span></a>';
if( $crop_at_readmore )
{
$ret_text = $text_to_parse[0] . $link_html;
}
else
{
$ret_text = $text_to_parse[0] . $text_to_parse[1];
}
}
return $ret_text;
}
/**
* If a Staff/Dept Name needs to be made into a link, this creates the name link html
*
* @param String $view which View ( all/staff/department/etc ) is calling this function
* @param String $staffDept is this 'staff' or 'department' for link
* @param String $name the actual staff/dept name text
* @param String $link_alias the staff/dept alias
* @param String $text_style any associated style/color
* @return String $ret_link html or text for name
*/
function createNameLink( $view , $staffDept , $name , $link_alias , $text_style = '' )
{
global $option;
$ret_link = '';
if( $view != 'staff' )
{
$link = JRoute::_( 'index.php?option=' . $option . '&view=' . $staffDept .'&name=' . $link_alias );
$ret_link = '<a href="' . $link .'" ';
if( !empty( $text_style ) )
$ret_link .= $text_style;
$ret_link .= '>' . $name . '</a>';
}
else
{
$ret_link = $name;
}
return $ret_link;
}
/**
* Creates the Powered By Staff Master Version HTML
*
* @param string $version
* @return string $tag HTML
*/
function createPoweredByTag( $version )
{
$tag = '<div id="staff_master_link">Powered By: <a href="http://www.systemsunited.net/" '
. 'target="_blank">Staff Master</a> v' . $version . '</div>';
return $tag;
}
/**
* Simple debug function to help with output of objects/arrays
*
* @param unknown_type $data
* @param unknown_type $label
*/
function pr( $data , $label = false)
{
echo '<br />************************************<br /><p style="text-align:left"><pre>';
if( $label )
echo $label . '<br />';
print_r( $data );
echo '</pre></p><br />************************************<br />';
}
}
?>