faysalmirmd

Socialsites custom Joomla fields

Nov 26th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.35 KB | None | 0 0
  1. <?php
  2. /*------------------------------------------------------------------------
  3. # socialsite.php - Module - My Social Time Line
  4. # ------------------------------------------------------------------------
  5. # author    Codeboxr Team
  6. # copyright Copyright (C) 2010-2012 codeboxr.com. All Rights Reserved.
  7. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
  8. # Websites: http://codeboxr.com
  9. # Technical Support:  Forum - http://codeboxr.com/product/my-social-timeline-for-joomla
  10. -------------------------------------------------------------------------*/
  11.  
  12. // no direct access
  13. defined( '_JEXEC' ) or die( 'Restricted access' );
  14.  
  15. jimport('joomla.form.helper');
  16. JFormHelper::loadFieldClass('list');
  17.  
  18. class JFormFieldSocialsite extends JFormFieldList{
  19.        
  20.         protected $type = 'socialsite';
  21.    
  22.        
  23.        
  24.         protected function getInput(){                      
  25.            
  26.            
  27.             $html = array();
  28.             $attr = '';
  29.  
  30.             // Initialize some field attributes.
  31.             $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
  32.  
  33.             // To avoid user's confusion, readonly="true" should imply disabled="true".
  34.             if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true')
  35.             {
  36.                     $attr .= ' disabled="disabled"';
  37.             }
  38.  
  39.             $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
  40.             $attr .= $this->multiple ? ' multiple="multiple"' : '';
  41.  
  42.             // Initialize JavaScript field attributes.
  43.             $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
  44.  
  45.             // Get the field options.
  46.             //$options    = (array) $this->getOptions();
  47.            
  48.             $sites      = array('facebook' => 'Facebook', 'twitter' => 'Twitter', 'gplus' => 'Google Plus', 'delicious' => 'Delicious', 'flickr' => 'Flickr', 'linkedin' => 'Linkedin', 'pinterest' => 'Pinterest', 'youtube' => 'Youtube'
  49.                 , 'blogspot' => 'Blogspot', 'wordpress' => 'Wordpress','tumblr' => 'Tumblr', 'reddit' => 'Reddit', 'myspace' => 'Myspace', 'lastfm' => 'Last.fm','foursquare' => 'Foursquare', 'instagram' => 'Instagram','customfeed'=>'Custom Feeds','comcontent'=>'Latest Content Articles','comk2'=>'Latest K2 Articles' );
  50.            
  51.             $networks   = array();
  52.             foreach($sites as $key => $val) :
  53.                 $networks[] = JHTML::_('select.option', $key, $val);
  54.             endforeach;
  55.            
  56.             // Create a read-only list (no name) with a hidden input to store the value.
  57.             if ((string) $this->element['readonly'] == 'true')
  58.             {
  59.                     $html[] = JHtml::_('select.genericlist', $networks, '', trim($attr), 'value', 'text', $this->value, $this->id);
  60.                     $html[] = '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '"/>';
  61.             }
  62.             // Create a regular list.
  63.             else
  64.             {
  65.                     $html[] = JHtml::_('select.genericlist', $networks, $this->name, trim($attr), 'value', 'text', $this->value, $this->id);
  66.             }
  67.  
  68.             return implode($html);
  69.            
  70.  
  71.     }//end function fectchElement
  72.        
  73. }//end class
  74. ?>
Advertisement
Add Comment
Please, Sign In to add comment