Exemple #1
0
 public function groups(array $config = array())
 {
     $config = new KConfig($config);
     $config->append(array('name' => 'group', 'core' => null));
     $attribs = KHelperArray::toString($config->attribs);
     $groups = $this->getService('com://admin/groups.model.groups')->set('core', is_null($config->core) ? null : $config->core)->getList();
     if ($config->exclude instanceof KDatabaseRowInterface && $config->exclude->id) {
         foreach (clone $groups as $group) {
             if ($group->lft >= $config->exclude->lft && $group->rgt <= $config->exclude->rgt) {
                 $groups->extract($group);
             }
         }
     }
     foreach ($groups as $group) {
         $checked = $config->selected == $group->id ? ' checked' : '';
         if ($group->depth) {
             $html[] = '<div style="padding-left: ' . $group->depth * 15 . 'px" class="clearfix">';
             $html[] = '<input type="radio" name="' . $config->name . '" id="' . $config->name . $group->id . '" value="' . $group->id . '"' . $checked . ' ' . $attribs . '/>';
             $html[] = '<label for="' . $config->name . $group->id . '">' . $group->name . '</label>';
             $html[] = '</div>';
         } else {
             $html[] = '<h4>' . $group->name . '</h4>';
         }
     }
     return implode(PHP_EOL, $html);
 }
Exemple #2
0
	/**
	 * Render script information
	 * 
	 * @param string	The script information
	 * @param array		Associative array of attributes
	 * @return string 	
	 */
	protected function _renderLink($link, $attribs = array())
	{
		$attribs = KHelperArray::toString($attribs);
		
		$html = '<link href="'.$link.'" '.$attribs.'/>'."\n";
		return $html;
	}
Exemple #3
0
 /**
  * Loads the calendar behavior and attaches it to a specified element
  *
  * @TODO generate patch for 12.3 making this bootstrap friendly
  *
  * @return string	The html output
  */
 private function _calendar($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('date' => gmdate("M d Y H:i:s"), 'name' => '', 'format' => '%Y-%m-%d %H:%M:%S', 'attribs' => array('size' => 25, 'maxlenght' => 19, 'class' => 'input-small', 'placeholder' => ''), 'gmt_offset' => JFactory::getConfig()->get('config.offset') * 3600));
     if ($config->date && $config->date != '0000-00-00 00:00:00' && $config->date != '0000-00-00') {
         $config->date = strftime($config->format, strtotime($config->date));
     } else {
         $config->date = '';
     }
     $html = '';
     // Load the necessary files if they haven't yet been loaded
     if (!isset(self::$_loaded['calendar'])) {
         $html .= '<script src="media://lib_koowa/js/calendar.js" />';
         $html .= '<script src="media://lib_koowa/js/calendar-setup.js" />';
         $html .= '<style src="media://lib_koowa/css/calendar.css" />';
         $html .= '<script>' . $this->_calendarTranslation() . '</script>';
         self::$_loaded['calendar'] = true;
     }
     $html .= "<script>\n\t\t\t\t\twindow.addEvent('domready', function() {Calendar.setup({\n        \t\t\t\tinputField     :    '" . $config->name . "',\n        \t\t\t\tifFormat       :    '" . $config->format . "',\n        \t\t\t\tbutton         :    'button-" . $config->name . "',\n        \t\t\t\talign          :    'Tl',\n        \t\t\t\tsingleClick    :    true,\n        \t\t\t\tshowsTime\t   :    false\n    \t\t\t\t});});\n    \t\t\t</script>";
     $attribs = KHelperArray::toString($config->attribs);
     $html .= '<div class="input-append">';
     $html .= '<input type="text" name="' . $config->name . '" id="' . $config->name . '" value="' . $config->date . '" ' . $attribs . ' />';
     $html .= '<button type="button" id="button-' . $config->name . '" class="btn" >';
     $html .= '<i class="icon-calendar"></i>&zwnj;';
     //&zwnj; is a zero width non-joiner, helps the button get the right height without adding to the width (like with &nbsp;)
     $html .= '</button>';
     $html .= '</div>';
     return $html;
 }
 /**
  * Checks to see if an image exists in the current templates image directory
  * if it does it loads this image.  Otherwise the default image is loaded.
  *
  * @param	string	The file name, eg foobar.png
  * @param	string	The path to the image
  * @param	string	Alt text
  * @param	array	An associative array of attributes to add
  * @param	boolean	True (default) to display full tag, false to return just the path
  */
 public static function template($file, $folder = 'media/', $alt = NULL, $attribs = null, $toHtml = 1)
 {
     static $paths;
     if (!$paths) {
         $paths = array();
     }
     if (is_array($attribs)) {
         $attribs = KHelperArray::toString($attribs);
     }
     $template = KFactory::get('lib.joomla.application')->getTemplate();
     $path = JPATH_BASE . '/templates/' . $template . '/images/' . $file;
     if (!isset($paths[$path])) {
         if (file_exists(JPATH_BASE . '/templates/' . $template . '/images/' . $file)) {
             $paths[$path] = 'templates/' . $template . '/images/' . $file;
         } else {
             // outputs only path to image
             $paths[$path] = $folder . $file;
         }
     }
     $src = $paths[$path];
     // Prepend the base path
     $src = JURI::base(true) . '/' . $src;
     // outputs actual html <img> tag
     if ($toHtml) {
         return '<img src="' . $src . '" alt="' . html_entity_decode($alt) . '" ' . $attribs . ' />';
     }
     return $src;
 }
 public function radiolist($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('list' => null, 'name' => 'id', 'attribs' => array(), 'key' => 'id', 'text' => 'title', 'selected' => null, 'translate' => false));
     $name = $config->name;
     $attribs = KHelperArray::toString($config->attribs);
     $html = array();
     foreach ($config->list as $row) {
         $key = $row->{$config->key};
         $text = $config->translate ? JText::_($row->{$config->text}) : $row->{$config->text};
         $id = isset($row->id) ? $row->id : null;
         $extra = '';
         if ($config->selected instanceof KConfig) {
             foreach ($config->selected as $value) {
                 $sel = is_object($value) ? $value->{$config->key} : $value;
                 if ($key == $sel) {
                     $extra .= 'selected="selected"';
                     break;
                 }
             }
         } else {
             $extra .= $key == $config->selected ? 'checked="checked"' : '';
         }
         $html[] = '<label class="radio" for="' . $name . $id . '">' . $text;
         $html[] = '<input type="radio" name="' . $name . '" id="' . $name . $id . '" value="' . $key . '" ' . $extra . ' ' . $attribs . ' />';
         $html[] = '</label>';
     }
     return implode(PHP_EOL, $html);
 }
 /**
  * Creates a tab panel with title and starts that panel
  *
  * @param   array   An optional array with configuration options
  * @return  string  Html
  */
 public function startPanel($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('title' => '', 'attribs' => array(), 'options' => array(), 'translate' => true));
     $title = $config->translate ? JText::_($config->title) : $config->title;
     $attribs = KHelperArray::toString($config->attribs);
     return '<dt ' . $attribs . '><span>' . $title . '</span></dt><dd>';
 }
 /**
  * Creates a tab panel with title and starts that panel
  *
  * @param	string	The title of the tab
  * @param	array	An associative array of pane attributes
  */
 public function startPanel($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('title' => 'Slide', 'attribs' => array(), 'translate' => true));
     $title = $config->translate ? JText::_($config->title) : $config->title;
     $attribs = KHelperArray::toString($config->attribs);
     $html = '<div class="panel"><h3 class="jpane-toggler title" ' . $attribs . '><span>' . $title . '</span></h3><div class="jpane-slider content">';
     return $html;
 }
Exemple #8
0
 public function fetchElement($name, $value, &$node, $control_name)
 {
     $config = new KConfig();
     $config->append(array('name' => 'id', 'attribs' => array(), 'key' => 'id', 'text' => 'title', 'selected' => $value, 'translate' => false));
     $name = $config->name;
     $attribs = KHelperArray::toString($config->attribs);
     $options = array();
     foreach ($node->children() as $option) {
         $options[] = (object) array($config->key => $option['value'], $config->text => (string) $option);
     }
     $config->list = $options;
     $class = isset($node['class']) ? $node['class'] : 'value';
     $html = array('<ul id="' . $this->name . '_id" class="' . $class . '">');
     foreach ($config->list as $row) {
         $key = $row->{$config->key};
         $text = $config->translate ? JText::_($row->{$config->text}) : $row->{$config->text};
         $id = isset($row->id) ? $row->id : null;
         $extra = '';
         if ($config->selected instanceof KConfig) {
             foreach ($config->selected as $value) {
                 $sel = is_object($value) ? $value->{$config->key} : $value;
                 if ($key == $sel) {
                     $extra .= 'checked="checked"';
                     break;
                 }
             }
         } else {
             $extra .= $key == $config->selected ? 'checked="checked"' : '';
         }
         $html[] = '<li class="value">';
         $html[] = '<label for="' . $this->name . '_' . $key . '"><input type="checkbox" name="' . $this->name . '[]" id="' . $this->name . '_' . $key . '" value="' . $key . '" ' . $extra . ' ' . $attribs . ' />' . $text . '</label>';
         $html[] = '</li>';
     }
     $html[] = '</ul>';
     return implode(PHP_EOL, $html);
     $options = array();
     foreach ($node->children() as $option) {
         $val = (string) $option['value'];
         $text = (string) $option;
         $options[] = (object) array('value' => $val, 'text' => $text);
     }
     $vertical = isset($node['vertical']) ? ' vertical' : null;
     $html[] = '<ul class="group' . $vertical . '">';
     $realname = $this->field . '[' . $this->group . '][' . $name . ']';
     $idname = $this->field . '_' . $this->group . '_' . $name;
     $checklist = KTemplateHelperSelect::checklist($options, $realname, $value, array('id' => '{id}'), 'value', 'text');
     $search = array('for="' . $realname, 'id="' . $realname);
     $replace = array('for="' . $idname, 'id="' . $idname);
     $checklist = str_replace($search, $replace, $checklist);
     foreach (explode('</label>', $checklist) as $check) {
         $html[] = '<li class="value">';
         $html[] = $check;
         $html[] = '</label></li>';
     }
     $html[] = '</ul>';
     return implode($html);
 }
Exemple #9
0
 /**
  * Renders the input element, with the accept attribute set when needed
  *
  * @author Stian Didriksen <*****@*****.**>
  * @return string
  */
 public function input($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('attributes' => array('name' => 'attachments[]', 'type' => 'file')));
     $params = JComponentHelper::getParams('com_media');
     if (!$params->get('check_mime', false)) {
         $config->attributes->append(array('accept' => htmlspecialchars($params->get('upload_mime'))));
     }
     return '<input ' . KHelperArray::toString($config->attributes->toArray()) . '/>';
 }
 /**
  * Get a list of langpacks that haven't been added to the nooku languages table yet
  *
  * @return	array
  */
 public function getUnused()
 {
     $langs = KFactory::get('admin::com.nooku.model.languages')->getList();
     $list = $this->getList();
     foreach (KHelperArray::getColumn($langs->toArray(), 'iso_code') as $iso_code) {
         if (isset($list[$iso_code])) {
             unset($list[$iso_code]);
         }
     }
     return $list;
 }
 /**
  * Render style information
  * 
  * @param 	string	The style information
  * @param 	boolean	True, if the style information is a URL
  * @param 	array	Associative array of attributes
  * @return string
  */
 protected function _renderStyle($style, $link, $attribs = array())
 {
     $attribs = KHelperArray::toString($attribs);
     if (!$link) {
         $html = '<style type="text/css" ' . $attribs . '>' . "\n";
         $html .= trim($style['data']);
         $html .= '</style>' . "\n";
     } else {
         $html = '<link type="text/css" rel="stylesheet" href="' . $style . '" ' . $attribs . ' />' . "\n";
     }
     return $html;
 }
Exemple #12
0
 /**
  * Render script information
  *
  * @param string	The script information
  * @param boolean	True, if the script information is a URL.
  * @param array		Associative array of attributes
  * @return string
  */
 protected function _renderScript($script, $link, $attribs = array())
 {
     $attribs = KHelperArray::toString($attribs);
     if (!$link) {
         $html = '<script type="text/javascript" ' . $attribs . '>' . "\n";
         $html .= trim($script);
         $html .= '</script>' . "\n";
     } else {
         $html = '<script type="text/javascript" src="' . $script . '" ' . $attribs . '></script>' . "\n";
     }
     return $html;
 }
Exemple #13
0
 /**
  * Fixes blockquotes.
  *
  * @param string Block of text to parse
  *
  * @return KTemplateFilterLink
  */
 public function write(&$text)
 {
     $matches = array();
     if (preg_match_all('/<a(.*?)>/', $text, $matches)) {
         foreach ($matches[1] as $index => $match) {
             $attribs = $this->_parseAttributes($match);
             $attribs['style'] = 'color:#076da0;text-decoration:none';
             $attribs = KHelperArray::toString($attribs);
             $text = str_replace($matches[0][$index], '<a ' . $attribs . ' >', $text);
         }
     }
     return $this;
 }
Exemple #14
0
 public function select($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('name' => '', 'attribs' => array(), 'visible' => true, 'link' => '', 'link_text' => $this->translate('Select'), 'link_selector' => 'modal'))->append(array('id' => $config->name, 'value' => $config->name));
     $attribs = KHelperArray::toString($config->attribs);
     $input = '<input name="%1$s" id="%2$s" value="%3$s" %4$s size="40" %5$s />';
     $link = '<a class="%s btn"
                 rel="{\'handler\': \'iframe\', \'size\': {\'x\': 690}}"
                 href="%s">%s</a>';
     $html = sprintf($input, $config->name, $config->id, $config->value, $config->visible ? 'type="text" readonly' : 'type="hidden"', $attribs);
     $html .= sprintf($link, $config->link_selector, $config->link, $config->link_text);
     return $html;
 }
Exemple #15
0
	public function calendar($config = array())
	{
		$config = new KConfig($config);
		$config->append(array(
			'date'	  => gmdate("M d Y H:i:s"),
		    'name'    => '',
		    'format'  => '%Y-%m-%d %H:%M:%S',
		    'attribs' => array('size' => 25, 'maxlenght' => 19),
		    'gmt_offset' => KFactory::get('joomla:config')->getValue('config.offset') * 3600
 		));
 		
	    if(!is_numeric($config->date)) {
            $config->date = strtotime($config->date);
        }
        
        if($config->date) { 
            $config->date = strftime($config->format, $config->date /*+ $config->gmt_offset*/);
        } 
        
	    $html = '';
		// Load the necessary files if they haven't yet been loaded
		if (!isset(self::$_loaded['calendar']))
		{
			$html .= '<script src="media://system/js/calendar.js" />';
			$html .= '<script src="media://system/js/calendar-setup.js" />';
			$html .= '<style src="media://system/css/calendar-jos.css" />';
			
			$html .= '<script>'.$this->_calendartranslation().'</script>';

			self::$_loaded['calendar'] = true;
		}
	   
		$html .= "<script>
					window.addEvent('domready', function() {Calendar.setup({
        				inputField     :    '".$config->name."',     	 
        				ifFormat       :    '".$config->format."',   
        				button         :    'button-".$config->name."', 
        				align          :    'Tl',
        				singleClick    :    true,
        				showsTime	   :    false
    				});});
    			</script>";
		
		$attribs = KHelperArray::toString($config->attribs);

   		$html .= '<input type="text" name="'.$config->name.'" id="'.$config->name.'" value="'.$config->date.'" '.$attribs.' />';
		$html .= '<img class="calendar" src="media://system/images/calendar.png" alt="calendar" id="button-'.$config->name.'" />';
		
		return $html;
	}
 public function original($config)
 {
     $config = new KConfig($config);
     $config->append(array('attribs' => array('class' => 'original-lang')));
     $item = $config->item;
     $html = '';
     if ($item->isTranslatable() && !$item->translated) {
         $original = $this->getService('com://admin/translations.model.translations')->table($item->getTable()->getName())->row($item->id)->original(1)->getItem();
         if ($original->iso_code != $item->language && $original->id) {
             $html .= '<span ' . KHelperArray::toString($config->attribs) . '>' . $this->translate('ONLY_AVAILABLE_' . strtoupper($original->lang) . '_SHORT') . '</span>';
         }
     }
     return $html;
 }
Exemple #17
0
 /**
  * Creates a pane and creates the javascript object for it
  *
  * @param 	array 	An optional array with configuration options
  * @return 	string	Html
  */
 public function startPane($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('id' => 'pane', 'attribs' => array(), 'options' => array()));
     $html = '';
     // Load the necessary files if they haven't yet been loaded
     if (!isset($this->_loaded['tabs'])) {
         $this->_loaded['tabs'] = true;
     }
     $id = strtolower($config->id);
     $attribs = KHelperArray::toString($config->attribs);
     $html .= "\n\t\t\t<script>\n\t\t\t\twindow.addEvent('domready', function(){ new KTabs('tabs-" . $id . "', " . json_encode($config->toData($config->options)) . "); });\n\t\t\t</script>";
     $html .= '<dl class="tabs" id="tabs-' . $id . '" ' . $attribs . '>';
     return $html;
 }
Exemple #18
0
 /**
  * MooTools.lang localization for Form.Validator.js and Date.js
  * 
  * Will likely be moved to Napi once stable
  *
  * @author Stian Didriksen <*****@*****.**>
  * @return void
  */
 protected function lang()
 {
     $lang = KFactory::get('lib.joomla.language')->getTag();
     $translate = create_function('$text', 'return ucfirst(JText::_($text));');
     $months = json_encode(array_map($translate, array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')));
     $days = json_encode(array_map($translate, array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')));
     $dateParts = explode('-', str_replace(array('%Y', '%M', '%D'), array('year', 'month', 'date'), JText::_('%Y-%M-%D')));
     $dateOrder = json_encode($dateParts);
     $shortDate = JText::_('DATE_FORMAT_LC4');
     $translate = create_function('$text', 'return JText::_($text);');
     $parts = array_map($translate, array('lessThanMinuteAgo' => 'less than a minute ago', 'minuteAgo' => 'about a minute ago', 'minutesAgo' => '{delta} minutes ago', 'hourAgo' => 'about an hour ago', 'hoursAgo' => 'about {delta} hours ago', 'dayAgo' => '1 day ago', 'daysAgo' => '{delta} days ago', 'weekAgo' => '1 week ago', 'weeksAgo' => '{delta} weeks ago', 'monthAgo' => '1 month ago', 'monthsAgo' => '{delta} months ago', 'yearAgo' => '1 year ago', 'yearsAgo' => '{delta} years ago', 'lessThanMinuteUntil' => 'less than a minute from now', 'minuteUntil' => 'about a minute from now', 'minutesUntil' => '{delta} minutes from now', 'hourUntil' => 'about an hour from now', 'hoursUntil' => 'about {delta} hours from now', 'dayUntil' => '1 day from now', 'daysUntil' => '{delta} days from now', 'weekUntil' => '1 week from now', 'weeksUntil' => '{delta} weeks from now', 'monthUntil' => '1 month from now', 'monthsUntil' => '{delta} months from now', 'yearUntil' => '1 year from now', 'yearsUntil' => '{delta} years from now'));
     echo KHelperArray::toString($parts, ':', ',"');
     die('<pre>' . var_export($parts, true) . '</pre>');
     $this->_document->addScriptDeclaration("\n\t\t\tMooTools.lang.set('{$lang}', 'Date', {\n\t\t\t\n\t\t\t\tmonths: {$months},\n\t\t\t\tdays: {$days},\n\t\t\t\t//culture's date order: MM/DD/YYYY\n\t\t\t\tdateOrder: {$dateOrder},\n\t\t\t\tshortDate: '{$shortDate}',\t\t\t\n\t\t\t\t{$parts}\n\t\t\t});\n\t\t\t\n\t\t\tMooTools.lang.set('{$lang}', 'Form.Validator', {\n\t\t\t\n\t\t\t\trequired:'This field is required.',\n\t\t\t\tminLength:'Please enter at least {minLength} characters (you entered {length} characters).',\n\t\t\t\tmaxLength:'Please enter no more than {maxLength} characters (you entered {length} characters).',\n\t\t\t\tinteger:'Please enter an integer in this field. Numbers with decimals (e.g. 1.25) are not permitted.',\n\t\t\t\tnumeric:'Please enter only numeric values in this field (i.e. \"1\" or \"1.1\" or \"-1\" or \"-1.1\").',\n\t\t\t\tdigits:'Please use numbers and punctuation only in this field (for example, a phone number with dashes or dots is permitted).',\n\t\t\t\talpha:'Please use letters only (a-z) with in this field. No spaces or other characters are allowed.',\n\t\t\t\talphanum:'Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed.',\n\t\t\t\tdateSuchAs:'Please enter a valid date such as {date}',\n\t\t\t\tdateInFormatMDY:'Please enter a valid date such as MM/DD/YYYY (i.e. \"12/31/1999\")',\n\t\t\t\temail:'Please enter a valid email address. For example \"fred@domain.com\".',\n\t\t\t\turl:'Please enter a valid URL such as http://www.google.com.',\n\t\t\t\tcurrencyDollar:'Please enter a valid \$ amount. For example \$100.00 .',\n\t\t\t\toneRequired:'Please enter something for at least one of these inputs.',\n\t\t\t\terrorPrefix: 'Error: ',\n\t\t\t\twarningPrefix: 'Warning: ',\n\t\t\t\n\t\t\t\t//Form.Validator.Extras\n\t\t\t\n\t\t\t\tnoSpace: 'There can be no spaces in this input.',\n\t\t\t\treqChkByNode: 'No items are selected.',\n\t\t\t\trequiredChk: 'This field is required.',\n\t\t\t\treqChkByName: 'Please select a {label}.',\n\t\t\t\tmatch: 'This field needs to match the {matchName} field',\n\t\t\t\tstartDate: 'the start date',\n\t\t\t\tendDate: 'the end date',\n\t\t\t\tcurrendDate: 'the current date',\n\t\t\t\tafterDate: 'The date should be the same or after {label}.',\n\t\t\t\tbeforeDate: 'The date should be the same or before {label}.',\n\t\t\t\tstartMonth: 'Please select a start month',\n\t\t\t\tsameMonth: 'These two dates must be in the same month - you must change one or the other.',\n\t\t\t\tcreditcard: 'The credit card number entered is invalid. Please check the number and try again. {length} digits entered.'\n\t\t\t\n\t\t\t});\n\t\t\tMooTools.lang.setLanguage('{$lang}');\n\t\t");
 }
Exemple #19
0
 /**
  * Renders a text input with autocomplete behavior
  *
  * @see    KTemplateHelperBehavior::autocomplete
  * @return string	The html output
  */
 protected function _autocomplete($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('model' => KInflector::pluralize($this->getIdentifier()->package)))->append(array('validate' => true, 'identifier' => 'com://' . $this->getIdentifier()->application . '/' . $this->getIdentifier()->package . '.identifier.' . KInflector::pluralize($config->model)));
     if (!is_a($config->identifier, 'KServiceIdentifier')) {
         $config->identifier = $this->getIdentifier($config->identifier);
     }
     $config->append(array('url' => JRoute::_('&option=com_' . $config->identifier->package . '&view=' . $config->identifier->name . '&format=json', false), 'column' => KInflector::singularize($config->identifier->name) . '_id'))->append(array('value' => $config->{$config->column} ? $config->{$config->column} : '', 'attribs' => array('name' => $config->column, 'type' => 'text', 'class' => 'inputbox value', 'size' => 60)))->append(array('options' => array('valueField' => $config->attribs->name . '-value')))->append(array('attribs' => array('id' => $config->attribs->name, 'data-value' => $config->options->valueField)));
     if ($config->validate) {
         $config->attribs->class = $config->attribs->class . ' ma-required';
     }
     //For the autocomplete behavior
     $config->element = $config->attribs->id;
     $html = $this->autocomplete($config);
     $html .= '<input ' . KHelperArray::toString($config->attribs) . ' />';
     $html .= '<input ' . KHelperArray::toString(array('type' => 'hidden', 'name' => $config->attribs->name, 'id' => $config->options->valueField, 'value' => $config->value)) . ' />';
     return $html;
 }
Exemple #20
0
 /**
  * this sucks but we need to override this in order to use correct language strings
  *
  * @param   array   An optional array with configuration options
  * @return  string  Html
  */
 public function command($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('command' => NULL));
     $command = $config->command;
     //Add a toolbar class
     $command->attribs->class->append(array('toolbar'));
     //Create the id
     $id = 'toolbar-' . $command->id;
     $command->attribs->class = implode(" ", KConfig::unbox($command->attribs->class));
     $html = '<td class="button" id="' . $id . '">';
     $html .= '  <a ' . KHelperArray::toString($command->attribs) . '>';
     $html .= '      <span class="' . $command->icon . '" title="' . JText::_($command->title) . '"></span>';
     $html .= JText::_('COM_PORTFOLIO_' . $command->label);
     $html .= '   </a>';
     $html .= '</td>';
     return $html;
 }
 /**
  * Render a menubar command
  *
  * @param   array   An optional array with configuration options
  * @return  string  Html
  */
 public function command($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('command' => null));
     $command = $config->command;
     //Add a nolink class if the command is disabled
     if ($command->disabled) {
         $command->attribs->class->append(array('nolink'));
     }
     if ($command->active) {
         $command->attribs->class->append(array('active'));
     }
     //Explode the class array
     $command->attribs->class = implode(" ", KConfig::unbox($command->attribs->class));
     if ($command->disabled) {
         $html = '<span ' . KHelperArray::toString($command->attribs) . '>' . JText::_($command->label) . '</span>';
     } else {
         $html = '<a href="' . $command->href . '" ' . KHelperArray::toString($command->attribs) . '>' . JText::_($command->label) . '</a>';
     }
     return $html;
 }
Exemple #22
0
 public function checkbox($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('row' => null, 'permissions' => true, 'attribs' => array()));
     if ($config->row->isLockable() && $config->row->locked()) {
         $html = '<span class="editlinktip hasTip" title="' . $config->row->lockMessage() . '">
         <img src="media://lib_koowa/images/locked.png"/>
         </span>';
     } else {
         $column = $config->row->getIdentityColumn();
         $value = $config->row->{$column};
         $permissions = '';
         if ($config->permissions === true && $config->row->isAclable()) {
             $data = $config->row->getPermissions()->toArray();
             $permissions = sprintf('data-permissions="%s"', htmlentities(json_encode($data)));
         }
         $attribs = KHelperArray::toString($config->attribs);
         $html = '<input type="checkbox" class="-koowa-grid-checkbox" name="%s[]" value="%s" %s %s />';
         $html = sprintf($html, $column, $value, $permissions, $attribs);
     }
     return $html;
 }
Exemple #23
0
 public function getItem()
 {
     $state = $this->getState();
     if ($state->container) {
         $container = $this->getService('com://admin/cloudinary.model.accounts')->slug($state->container)->getItem();
     } else {
         // Select default account
         $container = $this->getService('com://admin/cloudinary.model.accounts')->default(1)->getItem();
     }
     Cloudinary::config(array('cloud_name' => $container->cloud_name, 'api_key' => $container->api_key, 'api_secret' => $container->api_secret));
     // Force the path to a string so object with __toString() function will work
     $this->set('path', (string) $state->path);
     if (parent::getItem()->isNew()) {
         if (!$state->type) {
             $image = \Cloudinary\Uploader::upload(JPATH_FILES . '/' . $state->path);
         }
         $this->_item = $this->getRow()->setData(array('public_id' => $state->type ? $state->path : $image['public_id'], 'path' => $state->path, 'url' => $state->type ? '' : $image['url'], 'format' => $state->type ? '' : $image['format'], 'cloudinary_account_id' => $container->id));
         $this->_item->save();
     }
     if ($state->flags) {
         if (is_array($state->flags)) {
             $state->flags = implode('.', $state->flags);
         }
     }
     $file = $state->type ? $this->_item->public_id : $this->_item->public_id . '.' . $this->_item->format;
     $this->_item->setData(array('url' => cloudinary_url($file, $state->toArray())));
     if ($state->cache) {
         $this->_item->setData(array('url' => $this->_item->getImage($this->_item->url, $state->toArray())));
     }
     if ($state->getsize) {
         $curl = curl_init($this->_item->url);
         curl_setopt_array($curl, array(CURLOPT_HTTPHEADER => array('Range: bytes=0-32768'), CURLOPT_RETURNTRANSFER => 1));
         $image = imagecreatefromstring(curl_exec($curl));
         $this->_item->setData(array('width' => imagesx($image), 'height' => imagesy($image)));
         curl_close($curl);
     }
     $this->_item->setData(array('attribs' => KHelperArray::toString($state->attribs)));
     return $this->_item;
 }
Exemple #24
0
    /**
     * Email Updates button
     *
     * @author Stian Didriksen
     */
    public function watch($config = array())
    {
        $config = new KConfig($config);
        $config->append(array('view' => KRequest::get('get.view', 'cmd'), 'id' => false, 'active' => 'watching', 'hover' => 'unwatch', 'class' => 'watch', 'lang' => array('subscribe' => JText::_('Subscribe'), 'subscribed' => JText::_('Subscribed'), 'unsubscribe' => JText::_('Unsubscribe'))));
        $table = KFactory::get('admin::com.ninjaboard.database.table.watches');
        $config->append(array('type' => $table->getTypeIdFromName($config->view), 'type_id' => $config->id));
        $url = '?option=com_ninjaboard&view=watches&format=json';
        $selector = KFactory::get('admin::com.ninja.helper.default')->formid('watch');
        static $loaded;
        if (!$loaded) {
            $loaded = array();
        }
        if (!isset($loaded[$selector])) {
            $loaded[$selector] = true;
            KFactory::get('admin::com.ninja.helper.default')->js('/watch.js');
            KFactory::get('admin::com.ninja.helper.default')->js('
				jQuery(function($){
					$(\'.' . $selector . '\').ninjaboardWatch(' . json_encode(array('active' => $config->active, 'hover' => $config->hover, 'lang' => $config->lang->toArray(), 'watch' => array('url' => JRoute::_($url, false), 'data' => array('_token' => JUtility::getToken(), 'subscription_type' => $config->type, 'subscription_type_id' => $config->type_id, 'action' => 'add')), 'unwatch' => array('url' => $url . '&type=' . $config->type . '&type_id=' . $config->type_id, 'data' => array('_token' => JUtility::getToken(), 'action' => 'delete')))) . ');
				});');
        }
        $me = KFactory::get('admin::com.ninjaboard.model.people')->getMe();
        $params = KFactory::get('admin::com.ninjaboard.model.settings')->getParams();
        $watching = (bool) KFactory::tmp('admin::com.ninjaboard.model.watches')->by($me->id)->type($config->type)->type_id($config->type_id)->getTotal();
        //@TODO make this a model method that fetches just the id
        $id = KFactory::tmp('admin::com.ninjaboard.model.watches')->by($me->id)->type($config->type)->type_id($config->type_id)->limit(0)->getList()->getData();
        if (!$id) {
            $id = false;
        }
        if (is_array($id)) {
            $id = key($id);
        }
        $attr = KHelperArray::toString(array('class' => $config->class . ' ' . $selector . ($watching ? ' ' . $config->active : ''), 'data-watching' => (int) $watching, 'data-id' => $id));
        $html[] = '<div ' . $attr . '>';
        $html[] = '<a>' . ($watching ? $config->lang->subscribed : $config->lang->subscribe) . '</a>';
        $html[] = '</div>';
        return implode($html);
    }
 public function append($name = null, $attr = null, $msg = 'Add %s&hellip;')
 {
     if (!$name) {
         $name = $this->name;
     }
     $attributes = array('class' => $name, 'style' => '-moz-user-select: none', 'onselectstart' => 'return false;', 'ondragstart' => 'return false;', 'onclick' => "this.addClass('active'); return this;");
     if (is_string($attr)) {
         $attributes['href'] = $attr;
     } else {
         $attributes = array_merge($attributes, (array) $attr);
     }
     $icon = KFactory::get('admin::com.ninja.helper.default')->img('/32/' . $name . '.png');
     $style = '.placeholder .' . $attributes['class'] . ' > span { background-image: url(' . $icon . '); }';
     if ($icon) {
         KFactory::get('lib.joomla.document')->addStyleDeclaration($style);
     }
     $attributes['class'] .= ' button';
     $title = KInflector::humanize(KInflector::singularize($name));
     $text = sprintf(JText::_($msg), JText::_($title));
     if ($this->showButton) {
         $this->buttons[$name] = '<a ' . KHelperArray::toString($attributes) . '><span><span></span></span>' . $text . '</a>';
     }
     return $this;
 }
 /**
  * Loads the calendar behavior and attaches it to a specified element
  *
  * @return string	The html output
  */
 public function calendar($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('date' => gmdate("M d Y H:i:s"), 'name' => '', 'format' => '%Y-%m-%d %H:%M:%S', 'attribs' => array('size' => 25, 'maxlenght' => 19), 'gmt_offset' => JFactory::getConfig()->getValue('config.offset') * 3600));
     if ($config->date && $config->date != '0000-00-00 00:00:00' && $config->date != '0000-00-00') {
         $config->date = strftime($config->format, strtotime($config->date));
     } else {
         $config->date = '';
     }
     $html = '';
     // Load the necessary files if they haven't yet been loaded
     if (!isset(self::$_loaded['calendar'])) {
         $html .= '<script src="media://lib_koowa/js/calendar.js" />';
         $html .= '<script src="media://lib_koowa/js/calendar-setup.js" />';
         $html .= '<style src="media://lib_koowa/css/calendar.css" />';
         $html .= '<script>' . $this->_calendarTranslation() . '</script>';
         self::$_loaded['calendar'] = true;
     }
     $html .= "<script>\n\t\t\t\t\twindow.addEvent('domready', function() {Calendar.setup({\n        \t\t\t\tinputField     :    '" . $config->name . "',     \t \n        \t\t\t\tifFormat       :    '" . $config->format . "',   \n        \t\t\t\tbutton         :    'button-" . $config->name . "', \n        \t\t\t\talign          :    'Tl',\n        \t\t\t\tsingleClick    :    true,\n        \t\t\t\tshowsTime\t   :    false\n    \t\t\t\t});});\n    \t\t\t</script>";
     $attribs = KHelperArray::toString($config->attribs);
     $html .= '<input type="text" name="' . $config->name . '" id="' . $config->name . '" value="' . $config->date . '" ' . $attribs . ' />';
     $html .= '<a class="btn" id="button-' . $config->name . '" /><i class="icon-calendar"></i></a>';
     return $html;
 }
Exemple #27
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $config = new KConfig();
     $config->append(array('name' => 'id', 'attribs' => array(), 'key' => 'id', 'text' => 'title', 'selected' => $value, 'translate' => false));
     $name = $config->name;
     $attribs = KHelperArray::toString($config->attribs);
     $options = array();
     foreach ($node->children() as $option) {
         $options[] = (object) array($config->key => $option['value'], $config->text => (string) $option);
     }
     $config->list = $options;
     $class = isset($node['class']) ? $node['class'] : 'value';
     $html = array('<ul id="' . $this->name . '_id" class="' . $class . '">');
     foreach ($config->list as $row) {
         $key = $row->{$config->key};
         $text = $config->translate ? JText::_($row->{$config->text}) : $row->{$config->text};
         $id = isset($row->id) ? $row->id : null;
         $extra = '';
         if ($config->selected instanceof KConfig) {
             foreach ($config->selected as $value) {
                 $sel = is_object($value) ? $value->{$config->key} : $value;
                 if ($key == $sel) {
                     $extra .= 'checked="checked"';
                     break;
                 }
             }
         } else {
             $extra .= $key == $config->selected ? 'checked="checked"' : '';
         }
         $html[] = '<li class="value">';
         $html[] = '<label for="' . $this->name . '_' . $key . '"><input type="radio" name="' . $this->name . '" id="' . $this->name . '_' . $key . '" value="' . $key . '" ' . $extra . ' ' . $attribs . ' />' . JText::_($text) . '</label>';
         $html[] = '</li>';
     }
     $html[] = '</ul>';
     return implode(PHP_EOL, $html);
 }
 /**
  * Render a toolbar command
  *
  * @param   array   An optional array with configuration options
  * @return  string  Html
  */
 public function command($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('command' => NULL));
     $command = $config->command;
     //Add a toolbar class
     $command->attribs->class->append(array('toolbar'));
     $command->attribs->append(array('href' => '#'));
     //Create the id
     $id = 'toolbar-' . $command->id;
     $command->attribs->class = implode(" ", KConfig::unbox($command->attribs->class));
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $html = '<li class="button" id="' . $id . '">';
     } else {
         $html = '<td class="button" id="' . $id . '">';
     }
     $html .= '	<a ' . KHelperArray::toString($command->attribs) . '>';
     $html .= '		<span class="' . $command->icon . '" title="' . $this->translate($command->title) . '"></span>';
     $html .= $this->translate($command->label);
     $html .= '   </a>';
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $html .= '</li>';
     } else {
         $html .= '</td>';
     }
     return $html;
 }
Exemple #29
0
 /**
  * Generates an HTML image preview listbox
  * 
  * $config options:
  * 
  * name			string		column name of helper
  * directory	string		image directory (relative to docroot)
  * width		int			image width
  * height		int			image height
  * border		int			border width
  * style		string		style string
  * selected		string		currently selected vallue
  * 
  * @param   array   An optional array with configuration options
  * @return  string  Html
  */
 public function preview($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('name' => 'image_name', 'directory' => JPATH_IMAGES . '/stories', 'width' => 80, 'height' => 80, 'border' => 2, 'style' => 'margin: 10px 0;'))->append(array('selected' => $config->{$config->name}));
     $image = JURI::root(true) . '/' . str_replace(JPATH_ROOT . '/', '', $config->directory) . '/' . $config->selected;
     $path = $config->selected ? $image : 'media://system/images/blank.png';
     $html = '<img ' . KHelperArray::toString(array('src' => $path, 'id' => $config->name . '-preview', 'class' => 'preview', 'width' => $config->width, 'height' => $config->width, 'border' => $config->border, 'alt' => JText::_('Preview'), 'style' => $config->style)) . ' />';
     return $html;
 }
Exemple #30
0
 /**
  * Render a toolbar command
  *
  * @param   array   An optional array with configuration options
  * @return  string  Html
  */
 public function command($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('command' => NULL));
     $command = $config->command;
     //Add a toolbar class
     $command->attribs->class->append(array('toolbar'));
     $command->attribs->append(array('href' => '#'));
     //Create the id
     $id = 'toolbar-' . $command->id;
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $command->attribs->class->append(array('btn', 'btn-small'));
         $icon = str_replace('icon-32-', '', $command->icon);
         if ($command->id === 'new' || $command->id === 'apply') {
             $command->attribs->class->append(array('btn-success'));
             $icon .= ' icon-white';
         }
         $command->attribs->class = implode(" ", KConfig::unbox($command->attribs->class));
         $html = '<div class="btn-group" id="' . $id . '">';
         $html .= '<a ' . KHelperArray::toString($command->attribs) . '>';
         $html .= '<i class="icon-' . $icon . '"></i> ';
         $html .= $this->translate($command->label);
         $html .= '</a>';
         $html .= '</div>';
         return $html;
     }
     $command->attribs->class = implode(" ", KConfig::unbox($command->attribs->class));
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $html = '<li class="button" id="' . $id . '">';
     } else {
         $html = '<td class="button" id="' . $id . '">';
     }
     $html .= '<a ' . KHelperArray::toString($command->attribs) . '>';
     $html .= '<span class="' . $command->icon . '" title="' . $this->translate($command->title) . '"></span>';
     $html .= $this->translate($command->label);
     $html .= '</a>';
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $html .= '</li>';
     } else {
         $html .= '</td>';
     }
     return $html;
 }