Ejemplo n.º 1
0
 private function renderNone($text, $name, $attribs = null)
 {
     if (is_array($attribs)) {
         $attribs = JArrayHelper::toString($attribs);
     }
     return '<span style="color:red" ' . $attribs . '><input type="hidden" name="' . $name . '" value="none" />' . JText::_($text) . '</span>';
 }
Ejemplo n.º 2
0
 /**
  * Generates an HTML radio list.
  *
  * @param   array    $data       An array of objects
  * @param   string   $name       The value of the HTML name attribute
  * @param   string   $attribs    Additional HTML attributes for the <select> tag
  * @param   mixed    $optKey     The key that is selected
  * @param   string   $optText    The name of the object variable for the option value
  * @param   string   $selected   The name of the object variable for the option text
  * @param   boolean  $idtag      Value of the field id or null by default
  * @param   boolean  $translate  True if options will be translated
  *
  * @return  string HTML for the select list
  *
  * @since  3.0
  */
 public function radiolist($data, $name, $attribs = null, $optKey = 'value', $optText = 'text', $selected = null, $idtag = false, $translate = false)
 {
     reset($data);
     $result = array();
     if (is_array($attribs)) {
         $attribs = JArrayHelper::toString($attribs);
     }
     $id_text = $idtag ? $idtag : $name;
     foreach ($data as $obj) {
         $k = $obj->{$optKey};
         $t = $translate ? JText::_($obj->{$optText}) : $obj->{$optText};
         $id = isset($obj->id) ? $obj->id : null;
         $extra = '';
         $extra .= $id ? ' id="' . $obj->id . '"' : '';
         if (is_array($selected)) {
             foreach ($selected as $val) {
                 $k2 = is_object($val) ? $val->{$optKey} : $val;
                 if ($k == $k2) {
                     $extra .= ' selected="selected"';
                     break;
                 }
             }
         } else {
             $extra .= (string) $k == (string) $selected ? ' checked="checked"' : '';
         }
         $result[] = '<input type="radio" name="' . $name . '"' . ' id="' . $id_text . $k . '" value="' . $k . '"' . ' ' . $extra . ' ' . $attribs . '/>' . "\n\t" . '<label for="' . $id_text . $k . '"' . ' id="' . $id_text . $k . '-lbl" class="radiobtn">' . $t . '</label>';
     }
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * Method to create the html string for control
  * @return string html
  */
 public function getControlHtml()
 {
     $field = $this->field->getField();
     $clabel = $this->createlabel();
     $ccustomtext = $this->getCustomText();
     $html = "";
     $html .= '<div class="fc-tbx' . $field->errorId . '"></div>';
     //we wrap the control in a div if the field isCondtional, so that we can easily hide the whole control
     $html .= '<div class="';
     $html .= isset($field->isConditional) && $field->isConditional == true ? 'conditional field' . $field->id : 'field' . $field->id;
     $html .= isset($field->attribute_required) && $field->attribute_required == true ? ' required' : '';
     //closing quote for class attribute
     $html .= '"';
     $html .= isset($field->isDisabled) && $field->isDisabled == true ? ' style="display:none;" ' : "";
     $html .= '>';
     if ($ccustomtext != '' && isset($field->customtextposition) && ($field->customtextposition == 0 || $field->customtextposition == 1)) {
         $html .= $ccustomtext;
     }
     $html .= '<label class="checkbox asterix-ancor ' . $field->labelCSSclass . '" id="' . $field->name . 'lbl" for="field' . $field->id . '">';
     $html .= '<input ';
     if (!empty($field->attributeArray)) {
         //add all attributes
         $html .= JArrayHelper::toString($field->attributeArray, '=', ' ', true);
     }
     $html .= '/>';
     $html .= JHTML::_('visforms.createTip', $field);
     $html .= "</label>";
     if ($ccustomtext != '' && (isset($field->customtextposition) && $field->customtextposition == 2 || !isset($field->customtextposition))) {
         $html .= $ccustomtext;
     }
     $html .= '</div>';
     return $html;
 }
Ejemplo n.º 4
0
 /**
  * Method to create the html string for control
  * @return string html
  */
 public function getControlHtml()
 {
     $field = $this->field->getField();
     $clabel = $this->createlabel();
     $ccustomtext = $this->getCustomText();
     $html = "";
     $html .= '<div class="';
     $html .= isset($field->isConditional) && $field->isConditional == true ? 'conditional field' . $field->id : 'field' . $field->id;
     $html .= isset($field->attribute_required) && $field->attribute_required == true ? ' required' : '';
     //closing quote for class attribute
     $html .= '"';
     $html .= isset($field->isDisabled) && $field->isDisabled == true ? ' style="display:none;" ' : "";
     $html .= '>';
     //error container
     $html .= '<div class="fc-tbx' . $field->errorId . '"></div>';
     if ($ccustomtext != '' && isset($field->customtextposition) && ($field->customtextposition == 0 || $field->customtextposition == 1)) {
         $html .= $ccustomtext;
     }
     //label
     $html .= $clabel;
     //input
     $html .= '<input ';
     if (!empty($field->attributeArray)) {
         //add all attributes
         $html .= JArrayHelper::toString($field->attributeArray, '=', ' ', true);
     }
     $html .= '/>';
     if ($ccustomtext != '' && (isset($field->customtextposition) && $field->customtextposition == 2 || !isset($field->customtextposition))) {
         $html .= $ccustomtext;
     }
     $html .= '<p class="visCSSclear"><!-- --></p>';
     $html .= '</div>';
     return $html;
 }
Ejemplo n.º 5
0
 /**
  * savefilters task
  *
  *
  * @return	void
  * @since	1.0
  * @author	Sakis Terz
  */
 public function savefilters()
 {
     $model = $this->getModel();
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $type_ids = $jinput->get('type_id', array(), 'array');
     $alias = $jinput->get('alias', array(), 'array');
     $smart_search = $jinput->get('smart_search', array(), 'array');
     $expanded = $jinput->get('expanded', array(), 'array');
     $scrollbar_after = $jinput->get('scrollbar_after', array(), 'array');
     $params_array = array();
     JArrayHelper::toInteger($type_ids);
     JArrayHelper::toInteger($smart_search);
     JArrayHelper::toInteger($expanded);
     JArrayHelper::toString($alias);
     JArrayHelper::toString($scrollbar_after);
     //store the params in an assoc array an use the item id as key
     foreach ($smart_search as $key => $val) {
         $params_array[$key] = array('smart_search' => $val, 'expanded' => $expanded[$key], 'scrollbar_after' => $scrollbar_after[$key]);
     }
     $params_fromated = $this->formatParams($params_array);
     //sanitize the input to be int
     if ($type_ids || $alias || $params_fromated) {
         if (!$model->savefilters($type_ids, $alias, $params_fromated)) {
             JError::raiseWarning(500, $model->getError());
         } else {
             $this->setMessage(JText::_('COM_CUSTOMFILTERS_FILTERS_SAVED_SUCCESS'));
         }
     }
     $this->setRedirect('index.php?option=com_customfilters&view=customfilters');
 }
Ejemplo n.º 6
0
 public function callElement()
 {
     // get request vars
     $element = YRequest::getCmd('element', '');
     $method = YRequest::getCmd('method', '');
     $args = YRequest::getVar('args', array(), 'default', 'array');
     $item_id = (int) YRequest::getInt('item_id', 0);
     JArrayHelper::toString($args);
     // get item
     $item = YTable::getInstance('item')->get($item_id);
     // raise warning when item can not be accessed
     if (empty($item->id) || !$item->canAccess($this->user)) {
         JError::raiseError(500, JText::_('Unable to access item'));
         return;
     }
     // raise warning when item is not published
     $nulldate = JFactory::getDBO()->getNullDate();
     $date = JFactory::getDate()->toUnix();
     $publish_up = JFactory::getDate($item->publish_up);
     $publish_down = JFactory::getDate($item->publish_down);
     if ($item->state != 1 || !(($item->publish_up == $nulldate || $publish_up->toUnix() <= $date) && ($item->publish_down == $nulldate || $publish_down->toUnix() >= $date))) {
         JError::raiseError(404, JText::_('Item not published'));
         return;
     }
     // get element and execute callback method
     if ($element = $item->getElement($element)) {
         $element->callback($method, $args);
     }
 }
Ejemplo n.º 7
0
 static function link($url, $text, $attribs = null)
 {
     if (is_array($attribs)) {
         $attribs = JArrayHelper::toString($attribs);
     }
     return "<a href='" . $url . "' " . $attribs . ">" . $text . "</a>";
 }
Ejemplo n.º 8
0
 /** this function returns math expression into your form, the parameter is optional
  * quite simmilar to insertQuestion, but returns the output as a text instead of echoing
  */
 public static function returnQuestion($attributes = array(), $suffix = '')
 {
     //default prime is 37, you can change it when specifying the different parameter
     $a = rand() % 10;
     // generates the random number
     $b = rand() % 10;
     // generates the random number
     $code = $a + $b;
     if (!is_array($attributes)) {
         $attributes = array();
     }
     if (!isset($attributes['name'])) {
         $suffix = $suffix . rand(1, 99999);
         $attributes['name'] = 'captcha_code' . $suffix;
     }
     if (!isset($attributes['id'])) {
         $attributes['id'] = $attributes['name'];
     }
     if (!isset($attributes['size'])) {
         $attributes['size'] = '2';
     }
     if (!isset($attributes['class'])) {
         $attributes['class'] = 'inputbox mathguard-answer required';
     }
     $session =& JFactory::getSession();
     $session->set($attributes['name'], $code);
     return $a . ' + ' . $b . ' = ' . '<input type="text" ' . JArrayHelper::toString($attributes) . ' />';
 }
Ejemplo n.º 9
0
 public static function getArray($name, $default = array(), $type = 'array', $hash = 'default', $mask = 0)
 {
     // explode name
     $parts = explode('.', $name);
     if (count($parts) > 1) {
         $name = $parts[0];
         $key = $parts[1];
     }
     $array = self::getVar($name, $default, $hash, 'array', $mask);
     if (isset($key)) {
         if (is_array($array) && array_key_exists($key, $array)) {
             $value = $array[$key];
             settype($value, $type);
             return $value;
         }
         return $default;
     }
     if ($type == 'string') {
         JArrayHelper::toString($array);
     } else {
         if ($type == 'int') {
             JArrayHelper::toInteger($array);
         }
     }
     return $array;
 }
Ejemplo n.º 10
0
 public static function getLink(&$params)
 {
     $document = JFactory::getDocument();
     foreach ($document->_links as $link => $value) {
         $value = JArrayHelper::toString($value);
         if (strpos($value, 'application/' . $params->get('format') . '+xml')) {
             return $link;
         }
     }
 }
Ejemplo n.º 11
0
 /**
  * Method to create the html string for control
  * @return string html
  */
 public function getControlHtml()
 {
     $field = $this->field->getField();
     //input
     $html = '';
     $html .= '<input ';
     if (!empty($field->attributeArray)) {
         //add all attributes
         $html .= JArrayHelper::toString($field->attributeArray, '=', ' ', true);
     }
     $html .= '/>';
     return $html;
 }
Ejemplo n.º 12
0
 static function _HtmlElement($tagName, $id, $name = '', $content = '', $attributes = array())
 {
     $attributes["id"] = JCKOutput::fixId($id);
     if ($name) {
         $attributes["name"] = $name;
     }
     $attrStr = "";
     if (!empty($attributes)) {
         $attrStr = JArrayHelper::toString($attributes);
     }
     $html = chr(13) . "<{$tagName} {$attrStr}>{$content}</{$tagName}>";
     return $html;
 }
Ejemplo n.º 13
0
 /**
  * Method to create the html string for control
  * @return string html
  */
 public function getControlHtml()
 {
     $field = $this->field->getField();
     //input
     $html = '';
     if (!isset($field->noborder) || isset($field->noborder) && $field->noborder != "1") {
         $html .= '<hr ';
         if (!empty($field->attributeArray)) {
             //add all attributes
             $html .= JArrayHelper::toString($field->attributeArray, '=', ' ', true);
         }
         $html .= '/>';
     }
     return $html;
 }
Ejemplo n.º 14
0
 /**
  * Method to parse an image on the filesystem to an HMLT-tag
  *
  * @access public
  * @param string $file
  * @param string $alt
  * @param mixed $attribs 
  * @return string HTML output
  */
 public function image($file, $alt = null, $attribs = null)
 {
     if (!file_exists(JPATH_SITE . '/' . $file)) {
         return null;
     }
     $info = getimagesize(JPATH_SITE . '/' . $file);
     if (empty($alt)) {
         $alt = basename($file);
     }
     if (is_array($attribs)) {
         $attribs = JArrayHelper::toString($attribs);
     }
     $picture = JURI::base() . '/' . $file;
     return '<img src="' . $picture . '" alt="' . $alt . '" ' . $attribs . ' ' . $info[3] . ' />';
 }
Ejemplo n.º 15
0
 public static function checkbox($name, $class, $attribs = array(), $selected = null, $id = false)
 {
     $selectedHtml = '';
     $html = '';
     if (is_array($attribs)) {
         $attribs = JArrayHelper::toString($attribs);
     }
     if ($selected) {
         $selectedHtml .= " checked=\"checked\"";
     }
     $html .= "\n<input type='hidden' value='0' name=\"{$name}\">";
     // Self destruct
     $html .= "\n<input type=\"checkbox\" name=\"{$name}\" class=\"{$class}\" value=\"1\" {$attribs} {$selectedHtml} />";
     $html .= "\n<span class=\"lbl\"></span>";
     return $html;
 }
Ejemplo n.º 16
0
 /**
  * Method to create the html string for control
  * @return string html
  */
 public function getControlHtml()
 {
     $field = $this->field->getField();
     //input
     $html = '';
     $html .= '<input ';
     if (!empty($field->attributeArray)) {
         //add all attributes
         $html .= JArrayHelper::toString($field->attributeArray, '=', ' ', true);
     }
     $html .= '/>';
     //create an empty span that can take on the required asterix
     if (isset($field->attribute_required) && $field->attribute_required == 'required' && (isset($field->show_label) && $field->show_label == 1)) {
         $html .= '<span class="asterix-ancor"></span>';
     }
     return $html;
 }
Ejemplo n.º 17
0
 function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null)
 {
     JHTML::_('behavior.calendar');
     //load the calendar behavior
     if (is_array($attribs)) {
         $attribs = JArrayHelper::toString($attribs);
     }
     $document = JFactory::getDocument();
     $document->addScriptDeclaration('window.addEvent(\'domready\', function() {Calendar.setup({
     inputField     :    "' . $id . '",     // id of the input field
     ifFormat       :    "' . $format . '",      // format of the input field
     button         :    "' . $id . '_img",  // trigger for the calendar (button ID)
     align          :    "Tl",           // alignment (defaults to "Bl")
     singleClick    :    true
 });});');
     return '<input type="text" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />' . '<img class="calendar" src="' . JURI::root(true) . '/templates/system/images/calendar.png" alt="calendar" id="' . $id . '_img" />';
 }
Ejemplo n.º 18
0
 public static function toString($array = null, $inner_glue = '=', $outer_glue = ' ', $keepOuterKey = false)
 {
     $output = array();
     if (is_array($array)) {
         foreach ($array as $key => $item) {
             if (is_array($item)) {
                 if ($keepOuterKey) {
                     $output[] = $key;
                 }
                 // This is value is an array, go and do it again!
                 $output[] = JArrayHelper::toString($item, $inner_glue, $outer_glue, $keepOuterKey);
             } else {
                 $output[] = $key . $inner_glue . '"' . $item . '"';
             }
         }
     }
     return implode($outer_glue, $output);
 }
Ejemplo n.º 19
0
 /**
  * Generates an Array HTML checkbox list
  *
  * @param array An array of objects
  * @param string The value of the HTML name attribute
  * @param string Additional HTML attributes for the <input> tag
  * @param string The name of the object variable for the option value
  * @param string The name of the object variable for the option text
  * @param string/array the objects checked
  * @param string/array object disabled
  * @returns string HTML for the select list
  */
 function genericlist($arr, $name, $attribs = null, $key = 'value', $text = 'text', $selected = null, $disabled = null, $idtag = false, $translate = false)
 {
     reset($arr);
     $html = array();
     if (is_array($attribs)) {
         $attribs = JArrayHelper::toString($attribs);
     }
     $id_text = $name;
     if ($idtag) {
         $id_text = $idtag;
     }
     for ($i = 0, $n = count($arr); $i < $n; $i++) {
         $k = $arr[$i]->{$key};
         $t = $translate ? JText::_($arr[$i]->{$text}) : $arr[$i]->{$text};
         $id = isset($arr[$i]->id) ? @$arr[$i]->id : null;
         $extra = '';
         $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : '';
         if (is_array($disabled)) {
             foreach ($disabled as $val) {
                 $k2 = is_object($val) ? $val->{$key} : $val;
                 if ($k == $k2) {
                     $extra .= " disabled=\"disabled\"";
                     break;
                 }
             }
         } else {
             $extra .= (string) $k == (string) $disabled ? " disabled=\"disabled\"" : '';
         }
         if (is_array($selected)) {
             foreach ($selected as $val) {
                 $k2 = is_object($val) ? $val->{$key} : $val;
                 if ($k == $k2) {
                     $extra .= " checked=\"checked\"";
                     break;
                 }
             }
         }
         if (!is_null($selected) && is_string($selected)) {
             $extra .= (string) $k == (string) $selected ? " checked=\"checked\"" : '';
         }
         $html[] = "\n\t<input type=\"checkbox\" name=\"{$name}\" id=\"{$id_text}{$k}\" value=\"" . $k . "\"{$extra} {$attribs} />" . "\n\t<label for=\"{$id_text}{$k}\">{$t}</label>";
     }
     return $html;
 }
Ejemplo n.º 20
0
    public static function calendarJquery($value, $name, $id, $inputformat = 'm/d/Y', $outputformat = 'm/d/Y', $formatjs = '%Y-%m-%d', $attribs = null, $jqueryOptions = array())
    {
        static $done;
        if ($done === null) {
            $done = array();
        }
        $readonly = isset($attribs['readonly']) && $attribs['readonly'] == 'readonly';
        $disabled = isset($attribs['disabled']) && $attribs['disabled'] == 'disabled';
        if (is_array($attribs)) {
            $attribs = JArrayHelper::toString($attribs);
        }
        $date = DateTime::createFromFormat($inputformat, $value);
        if (!$readonly && !$disabled) {
            // Only display the triggers once for each control.
            if (!in_array($id, $done)) {
                $document = JFactory::getDocument();
                $optString = '';
                foreach ($jqueryOptions as $key => $option) {
                    $optString .= ', ' . $key . ': ' . $option;
                }
                $scriptDeclare = '
				var ' . $id . ' = null;
				jQuery(function($) {
					' . $id . ' = function() { $("#' . $id . '").datepicker({
						defaultDate: "+2d"
						,changeMonth: true
						,changeYear: true
						,dateFormat: "' . $formatjs . '"
						' . $optString . '
					})};
					' . $id . '();
				});
				';
                $document->addScriptDeclaration($scriptDeclare);
                $done[] = $id;
            }
            return '<input type="text" title="' . (0 !== (int) $value ? JHtml::_('date', $value) : '') . '" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($date->format($outputformat), ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />';
        } else {
            return '<input type="text" title="' . (0 !== (int) $value ? JHtml::_('date', $value) : '') . '" value="' . (0 !== (int) $value ? JHtml::_('date', $value, JFactory::getDbo()->getDateFormat()) : '') . '" ' . $attribs . ' />';
        }
    }
Ejemplo n.º 21
0
 /**
  * Render the single menu item
  *
  * @return string The html for this menu item
  */
 public function render()
 {
     $hidemainmenu = $this->app->request->getVar('hidemainmenu');
     $html = array('<li ' . JArrayHelper::toString($this->_attributes) . '>');
     $icon = $this->getAttribute('icon') ? '<i class="uk-icon-' . $this->getAttribute('icon') . '">&#160;</i>' : '';
     $has_children = count($this->getChildren());
     if (!$hidemainmenu) {
         $html[] = '<a href="' . JRoute::_($this->_link) . '">' . $icon . $this->getName() . ($has_children ? '&#160;<i class="uk-icon-caret-down">&#160;</i>' : '') . '</a>';
     } else {
         $html[] = '<span>' . $this->getName() . '</span>';
     }
     if ($has_children && !$hidemainmenu) {
         $html[] = '<div class="uk-dropdown uk-dropdown-navbar"><ul>';
         foreach ($this->getChildren() as $child) {
             $html[] = $child->render();
         }
         $html[] = '</ul></div>';
     }
     $html[] = '</li>';
     return implode("\n", $html);
 }
Ejemplo n.º 22
0
 /**
  * Method to create the html string for control
  * @return string html
  */
 public function getControlHtml()
 {
     $field = $this->field->getField();
     $html = '';
     $k = count($field->opts);
     $checked = "";
     $inputAttributes = !empty($field->attributeArray) ? JArrayHelper::toString($field->attributeArray, '=', ' ', true) : '';
     if (isset($field->display) && $field->display == 'LST') {
         //Show radios as a list; Wrap them in an div
         $html .= '<div class="visCSSclear ' . $field->fieldCSSclass . '">';
     } else {
         $html .= '<p class="visCSStop0 visCSSmargLeft visCSSrbinl ' . $field->fieldCSSclass . '">';
     }
     for ($j = 0; $j < $k; $j++) {
         if ($field->opts[$j]['selected'] != false) {
             $checked = 'checked="checked" ';
         } else {
             $checked = "";
         }
         if (isset($field->display) && $field->display == 'LST') {
             if ($j != 0) {
                 $html .= '<br />';
             }
             $labelClass = 'visCSSbot5 visCSSrllst ';
             $html .= '<label class="' . $labelClass . ' ' . $field->labelCSSclass . '" id="' . $field->name . 'lbl_' . $j . '" for="field' . $field->id . '_' . $j . '">' . $field->opts[$j]['label'] . '</label>';
             $html .= '<input id="field' . $field->id . '_' . $j . '" name="' . $field->name . '" value="' . $field->opts[$j]['value'] . '" ' . $checked . $inputAttributes . ' aria-labelledby="' . $field->name . 'lbl ' . $field->name . 'lbl_' . $j . '" />';
         } else {
             $labelClass = 'visCSStop10 visCSSright20 visCSSrlinl ';
             $html .= '<input id="field' . $field->id . '_' . $j . '" name="' . $field->name . '" value="' . $field->opts[$j]['value'] . '" ' . $checked . $inputAttributes . '  aria-labelledby="' . $field->name . 'lbl ' . $field->name . 'lbl_' . $j . '"/>';
             $html .= '<label class="' . $labelClass . ' ' . $field->labelCSSclass . '" id="' . $field->name . 'lbl_' . $j . '" for="field' . $field->id . '_' . $j . '">' . $field->opts[$j]['label'] . '</label>';
         }
     }
     if (isset($field->display) && $field->display == 'LST') {
         $html .= '</div>';
     } else {
         $html .= '</p>';
     }
     return $html;
 }
Ejemplo n.º 23
0
 /**
  * Method to create the html string for control
  * @return string html
  */
 public function getControlHtml()
 {
     $field = $this->field->getField();
     $html = '';
     if ($field->customtext != '' && isset($field->customtextposition) && ($field->customtextposition == 0 || $field->customtextposition == 1)) {
         JPluginHelper::importPlugin('content');
         $customtext = JHtml::_('content.prepare', $field->customtext);
         $html .= '<div class="visCustomText ">' . $customtext . '</div>';
     }
     $html .= '<input ';
     if (!empty($field->attributeArray)) {
         //add all attributes
         $html .= JArrayHelper::toString($field->attributeArray, '=', ' ', true);
     }
     $html .= '/>&nbsp;';
     if ($field->customtext != '' && (isset($field->customtextposition) && $field->customtextposition == 2 || !isset($field->customtextposition))) {
         JPluginHelper::importPlugin('content');
         $customtext = JHtml::_('content.prepare', $field->customtext);
         $html .= '<div class="visCustomText ">' . $customtext . '</div>';
     }
     return $html;
 }
Ejemplo n.º 24
0
 /**
  * Method to create the html string for control
  * @return string html
  */
 public function getControlHtml()
 {
     $field = $this->field->getField();
     //input
     $html = '';
     //We inclose textareas with HTML-Editor that are not readonly in a div
     if (isset($field->hasHTMLEditor) && $field->hasHTMLEditor) {
         $html .= '<div class="editor">';
     }
     $html .= '<textarea ';
     if (!empty($field->attributeArray)) {
         //add all attributes
         $html .= JArrayHelper::toString($field->attributeArray, '=', ' ', true);
     }
     $html .= '>';
     $html .= $field->initvalue;
     $html .= '</textarea>';
     //field is a textarea with html Editor we have to close the div
     if (isset($field->hasHTMLEditor) && $field->hasHTMLEditor) {
         $html .= '</div>';
     }
     return $html;
 }
Ejemplo n.º 25
0
 /**
  * Generates an HTML radio list
  * 
  * Overloads Joomla's one to unsure id attribute only contains valid characters
  *
  * @param array An array of objects
  * @param string The value of the HTML name attribute
  * @param string Additional HTML attributes for the <select> tag
  * @param mixed The key that is selected
  * @param string The name of the object variable for the option value
  * @param string The name of the object variable for the option text
  * @returns string HTML for the select list
  */
 function radiolist($arr, $name, $attribs = null, $key = 'value', $text = 'text', $selected = null, $idtag = false, $translate = false)
 {
     reset($arr);
     $html = '';
     if (is_array($attribs)) {
         $attribs = JArrayHelper::toString($attribs);
     }
     $id_text = $name;
     if ($idtag) {
         $id_text = $idtag;
     }
     $id_text = str_replace('[', '', $id_text);
     $id_text = str_replace(']', '', $id_text);
     for ($i = 0, $n = count($arr); $i < $n; $i++) {
         $k = $arr[$i]->{$key};
         $t = $translate ? JText::_($arr[$i]->{$text}) : $arr[$i]->{$text};
         $id = isset($arr[$i]->id) ? @$arr[$i]->id : null;
         $extra = '';
         $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : '';
         if (is_array($selected)) {
             foreach ($selected as $val) {
                 $k2 = is_object($val) ? $val->{$key} : $val;
                 if ($k == $k2) {
                     $extra .= " selected=\"selected\"";
                     break;
                 }
             }
         } else {
             $extra .= $k == $selected ? " checked=\"checked\"" : '';
         }
         $html .= "\n\t<input type=\"radio\" name=\"{$name}\" id=\"{$id_text}{$k}\" value=\"" . $k . "\"{$extra} {$attribs} />";
         $html .= "\n\t<label for=\"{$id_text}{$k}\">{$t}</label>";
     }
     $html .= "\n";
     return $html;
 }
Ejemplo n.º 26
0
 /**
  * Method to create the html string for control
  * @return string html
  */
 public function getControlHtml()
 {
     $field = $this->field->getField();
     $html = '';
     $k = count($field->opts);
     $checked = "";
     $inputAttributes = !empty($field->attributeArray) ? JArrayHelper::toString($field->attributeArray, '=', ' ', true) : '';
     if (isset($field->display) && $field->display == 'LST') {
         $labelClass = "radio";
     } else {
         $labelClass = "radio inline";
     }
     for ($j = 0; $j < $k; $j++) {
         if ($field->opts[$j]['selected'] != false) {
             $checked = 'checked="checked" ';
         } else {
             $checked = "";
         }
         $html .= '<label class="' . $labelClass . ' ' . $field->labelCSSclass . '" id="' . $field->name . 'lbl_' . $j . '" for="field' . $field->id . '_' . $j . '">' . $field->opts[$j]['label'];
         $html .= '<input id="field' . $field->id . '_' . $j . '" name="' . $field->name . '" value="' . $field->opts[$j]['value'] . '" ' . $checked . $inputAttributes . ' aria-labelledby="' . $field->name . 'lbl ' . $field->name . 'lbl_' . $j . '" />';
         $html .= '</label>';
     }
     return $html;
 }
Ejemplo n.º 27
0
    /**
     * Displays a calendar control field
     *
     * @param   string  $value    The date value
     * @param   string  $name     The name of the text field
     * @param   string  $id       The id of the text field
     * @param   string  $format   The date format
     * @param   mixed   $attribs  Additional HTML attributes
     *
     * @return  string  HTML markup for a calendar field
     *
     * @since   1.5
     */
    public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null)
    {
        static $done;
        if ($done === null) {
            $done = array();
        }
        $readonly = isset($attribs['readonly']) && $attribs['readonly'] == 'readonly';
        $disabled = isset($attribs['disabled']) && $attribs['disabled'] == 'disabled';
        if (is_array($attribs)) {
            $attribs['class'] = isset($attribs['class']) ? $attribs['class'] : 'input-medium';
            $attribs['class'] = trim($attribs['class'] . ' hasTooltip');
            $attribs = JArrayHelper::toString($attribs);
        }
        static::_('bootstrap.tooltip');
        // Format value when not nulldate ('0000-00-00 00:00:00'), otherwise blank it as it would result in 1970-01-01.
        if ($value && $value != JFactory::getDbo()->getNullDate()) {
            $tz = date_default_timezone_get();
            date_default_timezone_set('UTC');
            $inputvalue = strftime($format, strtotime($value));
            date_default_timezone_set($tz);
        } else {
            $inputvalue = '';
        }
        // Load the calendar behavior
        static::_('behavior.calendar');
        // Only display the triggers once for each control.
        if (!in_array($id, $done)) {
            $document = JFactory::getDocument();
            $document->addScriptDeclaration('jQuery(document).ready(function($) {Calendar.setup({
			// Id of the input field
			inputField: "' . $id . '",
			// Format of the input field
			ifFormat: "' . $format . '",
			// Trigger for the calendar (button ID)
			button: "' . $id . '_img",
			// Alignment (defaults to "Bl")
			align: "Tl",
			singleClick: true,
			firstDay: ' . JFactory::getLanguage()->getFirstDay() . '
			});});');
            $done[] = $id;
        }
        // Hide button using inline styles for readonly/disabled fields
        $btn_style = $readonly || $disabled ? ' style="display:none;"' : '';
        $div_class = !$readonly && !$disabled ? ' class="input-group"' : '';
        return '<div' . $div_class . '>' . '<input type="text" title="' . ($inputvalue ? static::_('date', $value, null, null) : '') . '" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($inputvalue, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />' . '<span class="input-group-btn">' . '<button type="button" class="btn btn-default btn-block" id="' . $id . '_img"' . $btn_style . '><span class="icon-calendar"></span></button>' . '</span>' . '</div>';
    }
Ejemplo n.º 28
0
    $script[] = "           \$('.modal-body').css({'max-height': maxModalBodyHeight, 'overflow-y': 'auto'});";
    $script[] = "       }";
}
$script[] = "   }).on('hide.bs.modal', function () {";
$script[] = "       \$('body').removeClass('modal-open');";
$script[] = "       \$('.modal-body').css({'max-height': 'initial', 'overflow-y': 'initial'});";
$script[] = "       \$('.modalTooltip').tooltip('destroy');";
$script[] = "   });";
$script[] = "});";
JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
?>
<div id="<?php 
echo $selector;
?>
" <?php 
echo JArrayHelper::toString($modalAttributes);
?>
>
	<?php 
// Header
if (!isset($params['closeButton']) || isset($params['title']) || $params['closeButton']) {
    echo JLayoutHelper::render('joomla.modal.header', $displayData);
}
// Body
echo JLayoutHelper::render('joomla.modal.body', $displayData);
// Footer
if (isset($params['footer'])) {
    echo JLayoutHelper::render('joomla.modal.footer', $displayData);
}
?>
</div>
Ejemplo n.º 29
0
    /**
     * Displays a calendar control field
     *
     * @param   string  $value    The date value
     * @param   string  $name     The name of the text field
     * @param   string  $id       The id of the text field
     * @param   string  $format   The date format
     * @param   array   $attribs  Additional HTML attributes
     *
     * @return  string  HTML markup for a calendar field
     *
     * @since   11.1
     */
    public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null)
    {
        static $done;
        if ($done === null) {
            $done = array();
        }
        $readonly = isset($attribs['readonly']) && $attribs['readonly'] == 'readonly';
        $disabled = isset($attribs['disabled']) && $attribs['disabled'] == 'disabled';
        if (is_array($attribs)) {
            $attribs = JArrayHelper::toString($attribs);
        }
        if (!$readonly && !$disabled) {
            // Load the calendar behavior
            self::_('behavior.calendar');
            self::_('behavior.tooltip');
            // Only display the triggers once for each control.
            if (!in_array($id, $done)) {
                $document = JFactory::getDocument();
                $document->addScriptDeclaration('window.addEvent(\'domready\', function() {Calendar.setup({
				// Id of the input field
				inputField: "' . $id . '",
				// Format of the input field
				ifFormat: "' . $format . '",
				// Trigger for the calendar (button ID)
				button: "' . $id . '_img",
				// Alignment (defaults to "Bl")
				align: "Tl",
				singleClick: true,
				firstDay: ' . JFactory::getLanguage()->getFirstDay() . '
				});});');
                $done[] = $id;
            }
            return '<input type="text" title="' . (0 !== (int) $value ? self::_('date', $value) : '') . '" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />' . self::_('image', 'system/calendar.png', JText::_('JLIB_HTML_CALENDAR'), array('class' => 'calendar', 'id' => $id . '_img'), true);
        } else {
            return '<input type="text" title="' . (0 !== (int) $value ? self::_('date', $value) : '') . '" value="' . (0 !== (int) $value ? self::_('date', $value, JFactory::getDbo()->getDateFormat()) : '') . '" ' . $attribs . ' /><input type="hidden" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" />';
        }
    }
Ejemplo n.º 30
0
 /**
  * Get the master query for retrieving a list of articles subject to the model state.
  *
  * @return	JDatabaseQuery
  * @since	1.6
  */
 protected function getListQuery()
 {
     // Create a new query object.
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     // Select the required fields from the table.
     $query->select($this->getState('list.select', 'a.id, a.title, a.alias, a.introtext, ' . 'a.checked_out, a.checked_out_time, ' . 'a.catid, a.created, a.created_by, a.created_by_alias, ' . 'CASE WHEN a.modified = ' . $db->q($db->getNullDate()) . ' THEN a.created ELSE a.modified END as modified, ' . 'a.modified_by, uam.name as modified_by_name,' . 'CASE WHEN a.publish_up = ' . $db->q($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END as publish_up,' . 'a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access, ' . 'a.hits, a.xreference, a.featured,' . ' ' . $query->length('a.fulltext') . ' AS readmore'));
     // Process an Archived Article layout
     if ($this->getState('filter.published') == 2) {
         // If badcats is not null, this means that the article is inside an archived category
         // In this case, the state is set to 2 to indicate Archived (even if the article state is Published)
         $query->select($this->getState('list.select', 'CASE WHEN badcats.id is null THEN a.state ELSE 2 END AS state'));
     } else {
         // Process non-archived layout
         // If badcats is not null, this means that the article is inside an unpublished category
         // In this case, the state is set to 0 to indicate Unpublished (even if the article state is Published)
         $query->select($this->getState('list.select', 'CASE WHEN badcats.id is not null THEN 0 ELSE a.state END AS state'));
     }
     $query->from('#__content AS a');
     // Join over the frontpage articles.
     if ($this->context != 'com_content.featured') {
         $query->join('LEFT', '#__content_frontpage AS fp ON fp.content_id = a.id');
     }
     // Join over the categories.
     $query->select('c.title AS category_title, c.path AS category_route, c.access AS category_access, c.alias AS category_alias');
     $query->join('LEFT', '#__categories AS c ON c.id = a.catid');
     // Join over the users for the author and modified_by names.
     $query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author");
     $query->select("ua.email AS author_email");
     $query->join('LEFT', '#__users AS ua ON ua.id = a.created_by');
     $query->join('LEFT', '#__users AS uam ON uam.id = a.modified_by');
     // Join on contact table
     $subQuery = $db->getQuery(true);
     $subQuery->select('contact.user_id, MAX(contact.id) AS id, contact.language');
     $subQuery->from('#__contact_details AS contact');
     $subQuery->where('contact.published = 1');
     $subQuery->group('contact.user_id, contact.language');
     $query->select('contact.id as contactid');
     $query->join('LEFT', '(' . $subQuery . ') AS contact ON contact.user_id = a.created_by');
     // Join over the categories to get parent category titles
     $query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias');
     $query->join('LEFT', '#__categories as parent ON parent.id = c.parent_id');
     // Join on voting table
     $query->select('ROUND(v.rating_sum / v.rating_count, 0) AS rating, v.rating_count as rating_count');
     $query->join('LEFT', '#__content_rating AS v ON a.id = v.content_id');
     // Join to check for category published state in parent categories up the tree
     $query->select('c.published, CASE WHEN badcats.id is null THEN c.published ELSE 0 END AS parents_published');
     $subquery = 'SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ';
     $subquery .= 'ON cat.lft BETWEEN parent.lft AND parent.rgt ';
     $subquery .= 'WHERE parent.extension = ' . $db->quote('com_content');
     if ($this->getState('filter.published') == 2) {
         // Find any up-path categories that are archived
         // If any up-path categories are archived, include all children in archived layout
         $subquery .= ' AND parent.published = 2 GROUP BY cat.id ';
         // Set effective state to archived if up-path category is archived
         $publishedWhere = 'CASE WHEN badcats.id is null THEN a.state ELSE 2 END';
     } else {
         // Find any up-path categories that are not published
         // If all categories are published, badcats.id will be null, and we just use the article state
         $subquery .= ' AND parent.published != 1 GROUP BY cat.id ';
         // Select state to unpublished if up-path category is unpublished
         $publishedWhere = 'CASE WHEN badcats.id is null THEN a.state ELSE 0 END';
     }
     $query->join('LEFT OUTER', '(' . $subquery . ') AS badcats ON badcats.id = c.id');
     // Filter by access level.
     if ($access = $this->getState('filter.access')) {
         $user = JFactory::getUser();
         $groups = implode(',', $user->getAuthorisedViewLevels());
         $query->where('a.access IN (' . $groups . ')');
         $query->where('c.access IN (' . $groups . ')');
     }
     // Filter by published state
     $published = $this->getState('filter.published');
     if (is_numeric($published)) {
         // Use article state if badcats.id is null, otherwise, force 0 for unpublished
         $query->where($publishedWhere . ' = ' . (int) $published);
     } elseif (is_array($published)) {
         JArrayHelper::toInteger($published);
         $published = implode(',', $published);
         // Use article state if badcats.id is null, otherwise, force 0 for unpublished
         $query->where($publishedWhere . ' IN (' . $published . ')');
     }
     // Filter by featured state
     $featured = $this->getState('filter.featured');
     switch ($featured) {
         case 'hide':
             $query->where('a.featured = 0');
             break;
         case 'only':
             $query->where('a.featured = 1');
             break;
         case 'show':
         default:
             // Normally we do not discriminate
             // between featured/unfeatured items.
             break;
     }
     // Filter by a single or group of articles.
     $articleId = $this->getState('filter.article_id');
     if (is_numeric($articleId)) {
         $type = $this->getState('filter.article_id.include', true) ? '= ' : '<> ';
         $query->where('a.id ' . $type . (int) $articleId);
     } elseif (is_array($articleId)) {
         JArrayHelper::toInteger($articleId);
         $articleId = implode(',', $articleId);
         $type = $this->getState('filter.article_id.include', true) ? 'IN' : 'NOT IN';
         $query->where('a.id ' . $type . ' (' . $articleId . ')');
     }
     // Filter by a single or group of categories
     $categoryId = $this->getState('filter.category_id');
     if (is_numeric($categoryId)) {
         $type = $this->getState('filter.category_id.include', true) ? '= ' : '<> ';
         // Add subcategory check
         $includeSubcategories = $this->getState('filter.subcategories', false);
         $categoryEquals = 'a.catid ' . $type . (int) $categoryId;
         if ($includeSubcategories) {
             $levels = (int) $this->getState('filter.max_category_levels', '1');
             // Create a subquery for the subcategory list
             $subQuery = $db->getQuery(true);
             $subQuery->select('sub.id');
             $subQuery->from('#__categories as sub');
             $subQuery->join('INNER', '#__categories as this ON sub.lft > this.lft AND sub.rgt < this.rgt');
             $subQuery->where('this.id = ' . (int) $categoryId);
             if ($levels >= 0) {
                 $subQuery->where('sub.level <= this.level + ' . $levels);
             }
             // Add the subquery to the main query
             $query->where('(' . $categoryEquals . ' OR a.catid IN (' . $subQuery->__toString() . '))');
         } else {
             $query->where($categoryEquals);
         }
     } elseif (is_array($categoryId) && count($categoryId) > 0) {
         JArrayHelper::toInteger($categoryId);
         $categoryId = implode(',', $categoryId);
         if (!empty($categoryId)) {
             $type = $this->getState('filter.category_id.include', true) ? 'IN' : 'NOT IN';
             $query->where('a.catid ' . $type . ' (' . $categoryId . ')');
         }
     }
     // Filter by author
     $authorId = $this->getState('filter.author_id');
     $authorWhere = '';
     if (is_numeric($authorId)) {
         $type = $this->getState('filter.author_id.include', true) ? '= ' : '<> ';
         $authorWhere = 'a.created_by ' . $type . (int) $authorId;
     } elseif (is_array($authorId)) {
         JArrayHelper::toInteger($authorId);
         $authorId = implode(',', $authorId);
         if ($authorId) {
             $type = $this->getState('filter.author_id.include', true) ? 'IN' : 'NOT IN';
             $authorWhere = 'a.created_by ' . $type . ' (' . $authorId . ')';
         }
     }
     // Filter by author alias
     $authorAlias = $this->getState('filter.author_alias');
     $authorAliasWhere = '';
     if (is_string($authorAlias)) {
         $type = $this->getState('filter.author_alias.include', true) ? '= ' : '<> ';
         $authorAliasWhere = 'a.created_by_alias ' . $type . $db->Quote($authorAlias);
     } elseif (is_array($authorAlias)) {
         $first = current($authorAlias);
         if (!empty($first)) {
             JArrayHelper::toString($authorAlias);
             foreach ($authorAlias as $key => $alias) {
                 $authorAlias[$key] = $db->Quote($alias);
             }
             $authorAlias = implode(',', $authorAlias);
             if ($authorAlias) {
                 $type = $this->getState('filter.author_alias.include', true) ? 'IN' : 'NOT IN';
                 $authorAliasWhere = 'a.created_by_alias ' . $type . ' (' . $authorAlias . ')';
             }
         }
     }
     if (!empty($authorWhere) && !empty($authorAliasWhere)) {
         $query->where('(' . $authorWhere . ' OR ' . $authorAliasWhere . ')');
     } elseif (empty($authorWhere) && empty($authorAliasWhere)) {
         // If both are empty we don't want to add to the query
     } else {
         // One of these is empty, the other is not so we just add both
         $query->where($authorWhere . $authorAliasWhere);
     }
     // Filter by start and end dates.
     $nullDate = $db->Quote($db->getNullDate());
     $nowDate = $db->Quote(JFactory::getDate()->toSql());
     $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')');
     $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
     // Filter by Date Range or Relative Date
     $dateFiltering = $this->getState('filter.date_filtering', 'off');
     $dateField = $this->getState('filter.date_field', 'a.created');
     switch ($dateFiltering) {
         case 'range':
             $startDateRange = $db->Quote($this->getState('filter.start_date_range', $nullDate));
             $endDateRange = $db->Quote($this->getState('filter.end_date_range', $nullDate));
             $query->where('(' . $dateField . ' >= ' . $startDateRange . ' AND ' . $dateField . ' <= ' . $endDateRange . ')');
             break;
         case 'relative':
             $relativeDate = (int) $this->getState('filter.relative_date', 0);
             $query->where($dateField . ' >= DATE_SUB(' . $nowDate . ', INTERVAL ' . $relativeDate . ' DAY)');
             break;
         case 'off':
         default:
             break;
     }
     // process the filter for list views with user-entered filters
     $params = $this->getState('params');
     if (is_object($params) && $params->get('filter_field') != 'hide' && ($filter = $this->getState('list.filter'))) {
         // clean filter variable
         $filter = JString::strtolower($filter);
         $hitsFilter = (int) $filter;
         $filter = $db->Quote('%' . $db->escape($filter, true) . '%', false);
         switch ($params->get('filter_field')) {
             case 'author':
                 $query->where('LOWER( CASE WHEN a.created_by_alias > ' . $db->quote(' ') . ' THEN a.created_by_alias ELSE ua.name END ) LIKE ' . $filter . ' ');
                 break;
             case 'hits':
                 $query->where('a.hits >= ' . $hitsFilter . ' ');
                 break;
             case 'title':
             default:
                 // default to 'title' if parameter is not valid
                 $query->where('LOWER( a.title ) LIKE ' . $filter);
                 break;
         }
     }
     // Filter by language
     if ($this->getState('filter.language')) {
         $query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
         $query->where('(contact.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ') OR contact.language IS NULL)');
     }
     // Add the list ordering clause.
     $query->order($this->getState('list.ordering', 'a.ordering') . ' ' . $this->getState('list.direction', 'ASC'));
     $query->group('a.id, a.title, a.alias, a.introtext, a.checked_out, a.checked_out_time, a.catid, a.created, a.created_by, a.created_by_alias, a.created, a.modified, a.modified_by, uam.name, a.publish_up, a.attribs, a.metadata, a.metakey, a.metadesc, a.access, a.hits, a.xreference, a.featured, a.fulltext, a.state, a.publish_down, badcats.id, c.title, c.path, c.access, c.alias, uam.id, ua.name, ua.email, contact.id, parent.title, parent.id, parent.path, parent.alias, v.rating_sum, v.rating_count, c.published, c.lft, a.ordering, parent.lft, fp.ordering, c.id, a.images, a.urls');
     return $query;
 }