Example #1
0
 /**
  * Method to get the field input markup for a generic list.
  * Use the multiple attribute to enable multiselect.
  *
  * @return  string  The field input markup.
  */
 protected function getInput()
 {
     // Initialize variables.
     $attributes = array('type' => 'text', 'value' => htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'), 'name' => $this->name, 'id' => $this->id, 'size' => $this->element['size'] ? (int) $this->element['size'] : '', 'maxlength' => $this->element['maxlength'] ? (int) $this->element['maxlength'] : '', 'class' => 'orcid' . ($this->element['class'] ? (string) $this->element['class'] : ''), 'autocomplete' => (string) $this->element['autocomplete'] == 'off' ? 'off' : '', 'readonly' => (string) $this->element['readonly'] == 'true' ? 'readonly' : '', 'disabled' => (string) $this->element['disabled'] == 'true' ? 'disabled' : '', 'onchange' => $this->element['onchange'] ? (string) $this->element['onchange'] : '');
     $attr = array();
     foreach ($attributes as $key => $value) {
         if ($key != 'value' && !$value) {
             continue;
         }
         $attr[] = $key . '="' . $value . '"';
     }
     $attr = implode(' ', $attr);
     $html = array();
     $html[] = '<div class="grid">';
     $html[] = '	<div class="col span9">';
     $html[] = '		<input ' . $attr . ' placeholder="####-####-####-####" />';
     $html[] = '		<input type="hidden" name="base_uri" id="base_uri" value="' . rtrim(Request::base(true), '/') . '" />';
     $html[] = '	</div>';
     $html[] = '	<div class="col span3 omega">';
     $html[] = '		<a class="btn button icon-search orcid-fetch" data-base="' . rtrim(Request::base(true), '/') . '" data-id="' . $this->id . '" href="' . Request::base() . '/' . Route::url('index.php?option=com_members&controller=orcid') . '">' . Lang::txt('COM_MEMBERS_PROFILE_ORCID_FIND') . '</a>';
     $html[] = '	</div>';
     $html[] = '</div>';
     $html[] = '<p><img src="' . Request::root() . '/core/components/com_members/site/assets/img/orcid-logo.png" width="80" alt="ORCID" /> ' . Lang::txt('COM_MEMBERS_PROFILE_ORCID_ABOUT') . '</p>';
     Behavior::framework(true);
     Behavior::modal();
     if (file_exists(PATH_ROOT . '/core/components/com_members/site/assets/js/orcid.js')) {
         Document::addScript('/core/components/com_members/site/assets/js/orcid.js?t=' . filemtime(PATH_ROOT . '/core/components/com_members/site/assets/js/orcid.js'));
     }
     return implode($html);
 }
Example #2
0
 /**
  * Method to get the field input markup for a generic list.
  * Use the multiple attribute to enable multiselect.
  *
  * @return  string  The field input markup.
  */
 protected function getInput()
 {
     // Initialize variables.
     $attributes = array('type' => 'text', 'value' => htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'), 'name' => $this->name, 'id' => $this->id, 'size' => $this->element['size'] ? (int) $this->element['size'] : '', 'maxlength' => $this->element['maxlength'] ? (int) $this->element['maxlength'] : '', 'class' => $this->element['class'] ? (string) $this->element['class'] : '', 'readonly' => (string) $this->element['readonly'] == 'true' ? 'readonly' : '', 'disabled' => (string) $this->element['disabled'] == 'true' ? 'disabled' : '');
     Behavior::framework(true);
     $results = App::get('dispatcher')->trigger('hubzero.onGetMultiEntry', array(array('tags', $this->name, $this->id, $attributes['class'], $this->value, null, null, 'multi', $attributes['disabled'] ? true : null)));
     if (count($results) > 0) {
         $results = implode("\n", $results);
     } else {
         $results = self::getInput();
     }
     return $results;
 }
Example #3
0
 /**
  * Get the JavaScript command for the button
  *
  * @param   string   $name  The task name as seen by the user
  * @param   string   $task  The task used by the application
  * @param   boolean  $list  True is requires a list confirmation.
  * @return  string   JavaScript command string
  */
 protected function _getCommand($name, $task, $list)
 {
     Behavior::framework();
     $message = \Lang::txt('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST');
     $message = addslashes($message);
     if ($list) {
         $cmd = "if (document.adminForm.boxchecked.value==0){alert('{$message}');}else{ Joomla.submitbutton('{$task}')}";
     } else {
         $cmd = "Joomla.submitbutton('{$task}')";
     }
     return $cmd;
 }
Example #4
0
 /**
  * Write a <script></script> element
  *
  * @param   string   $file            path to file
  * @param   boolean  $framework       load the JS framework
  * @param   boolean  $relative        path to file is relative to /core folder
  * @param   boolean  $path_only       return the path to the file only
  * @param   boolean  $detect_browser  detect browser to include specific browser js files
  * @param   boolean  $detect_debug    detect debug to search for compressed files if debug is on
  * @return  mixed  nothing if $path_only is false, null, path or array of path if specific js browser files were detected
  */
 public static function script($file, $framework = false, $relative = false, $path_only = false, $detect_browser = true, $detect_debug = true)
 {
     if ($framework) {
         Behavior::framework();
     }
     $includes = self::includeRelativeFiles('js', $file, $relative, $detect_browser, $detect_debug);
     // If only path is required
     if ($path_only) {
         if (count($includes) == 0) {
             return null;
         } elseif (count($includes) == 1) {
             return $includes[0];
         } else {
             return $includes;
         }
     } else {
         $document = App::get('document');
         foreach ($includes as $include) {
             $document->addScript($include);
         }
     }
 }
Example #5
0
 /**
  * Method to get the field input markup.
  *
  * @return  string  The field input markup.
  */
 protected function getInput()
 {
     // Initialize variables.
     $html = array();
     // Initialize some field attributes.
     $class = $this->element['class'] ? ' class="radio addresses-' . $this->id . ' ' . (string) $this->element['class'] . '"' : ' class="radio addresses-' . $this->id . '"';
     // Start the radio field output.
     $html[] = '<fieldset id="' . $this->id . '"' . $class . '>';
     // Get the field options.
     $options = $this->getOptions();
     $found = false;
     $values = $this->value;
     $values = is_array($values) ? $values : array($values);
     $lang = App::get('language');
     // Build the radio field output.
     foreach ($values as $i => $value) {
         if (is_string($value)) {
             $value = json_decode((string) $value, true);
         }
         if (!$value || json_last_error() !== JSON_ERROR_NONE) {
             $value = array();
             $value['address1'] = '';
             $value['address2'] = '';
             $value['postal'] = '';
             $value['city'] = '';
             $value['region'] = '';
             $value['country'] = '';
             $value['latitude'] = '';
             $value['longitude'] = '';
         }
         $html[] = '<div class="address-field-wrap">';
         $html[] = '<ul class="address-field">';
         $html[] = '<li>';
         $html[] = '<label for="' . $this->id . $i . '">' . $lang->txt('Street') . '</label>';
         $html[] = '<input type="text" id="' . $this->id . $i . '" name="' . $this->name . '[' . $i . '][address1]" placeholder="Street" value="' . htmlspecialchars($value['address1'], ENT_COMPAT, 'UTF-8') . '" />';
         $html[] = '</li>';
         $html[] = '<li>';
         $html[] = '<label for="' . $this->id . $i . '">' . $lang->txt('Street 2') . '</label>';
         $html[] = '<input type="text" id="' . $this->id . $i . '" name="' . $this->name . '[' . $i . '][address2]" placeholder="Street 2" value="' . htmlspecialchars($value['address2'], ENT_COMPAT, 'UTF-8') . '" />';
         $html[] = '</li>';
         $html[] = '<li>';
         $html[] = '<label for="' . $this->id . $i . '">' . $lang->txt('City') . '</label>';
         $html[] = '<input type="text" id="' . $this->id . $i . '" name="' . $this->name . '[' . $i . '][city]" placeholder="City" value="' . htmlspecialchars($value['city'], ENT_COMPAT, 'UTF-8') . '" />';
         $html[] = '</li>';
         $html[] = '<li>';
         $html[] = '<div class="grid">';
         $html[] = '<div class="col span6">';
         $html[] = '<label for="' . $this->id . $i . '">' . $lang->txt('Postal code') . '</label>';
         $html[] = '<input type="text" id="' . $this->id . $i . '" name="' . $this->name . '[' . $i . '][postal]" placeholder="Postal code" value="' . htmlspecialchars($value['postal'], ENT_COMPAT, 'UTF-8') . '" />';
         $html[] = '</div>';
         $html[] = '<div class="col span6 omega">';
         $html[] = '<label for="' . $this->id . $i . '">' . $lang->txt('State/Region') . '</label>';
         $html[] = '<input type="text" id="' . $this->id . $i . '" name="' . $this->name . '[' . $i . '][region]" placeholder="State/Region" value="' . htmlspecialchars($value['region'], ENT_COMPAT, 'UTF-8') . '" />';
         $html[] = '</div>';
         $html[] = '</div>';
         $html[] = '</li>';
         $html[] = '<li>';
         $html[] = '<label for="' . $this->id . $i . '">' . $lang->txt('Country') . '</label>';
         $html[] = Dropdown::genericlist($options, $this->name . '[' . $i . '][country]', '', 'value', 'text', $value['country'], $this->id . $i);
         $html[] = '<input type="hidden" id="' . $this->id . $i . '" name="' . $this->name . '[' . $i . '][latitude]" value="' . htmlspecialchars($value['latitude'], ENT_COMPAT, 'UTF-8') . '" />';
         $html[] = '<input type="hidden" id="' . $this->id . $i . '" name="' . $this->name . '[' . $i . '][longitude]" value="' . htmlspecialchars($value['longitude'], ENT_COMPAT, 'UTF-8') . '" />';
         $html[] = '</li>';
         $html[] = '</ul>';
         $html[] = '</div>';
     }
     // End the radio field output.
     $html[] = '</fieldset>';
     Behavior::framework(true);
     App::get('document')->addScriptDeclaration("\n\t\t\tfunction manageProfileAddresses() {\n\t\t\t\tif (\$('.addresses-" . $this->id . "').length > 0) {\n\t\t\t\t\tvar fieldset = \$('.addresses-" . $this->id . "');\n\t\t\t\t\tvar btn = \$('<p class=\"address-add\"><a class=\"icon-add\" href=\"#\">Add another address</a></p>').on('click', function(e){\n\t\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t\tvar grp = fieldset\n\t\t\t\t\t\t\t.find('.address-field-wrap')\n\t\t\t\t\t\t\t.last()\n\t\t\t\t\t\t\t.clone();\n\t\t\t\t\t\tgrp.find('input').each(function(){\n\t\t\t\t\t\t\tthis.name = this.name.replace(/\\[(\\d+)\\]/,function(str,p1){return '[' + (parseInt(p1,10)+1) + ']';});\n\t\t\t\t\t\t\tthis.value = '';\n\t\t\t\t\t\t});\n\t\t\t\t\t\tgrp.find('select').each(function(){\n\t\t\t\t\t\t\tthis.name = this.name.replace(/\\[(\\d+)\\]/,function(str,p1){return '[' + (parseInt(p1,10)+1) + ']';});\n\t\t\t\t\t\t\tthis.selectedIndex = 0;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (!grp.find('.address-remove').length) {\n\t\t\t\t\t\t\tvar rmv = \$('<a class=\"address-remove icon-remove\" href=\"#\">Remove</a>');\n\t\t\t\t\t\t\tgrp.append(rmv);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgrp.appendTo(fieldset);\n\n\t\t\t\t\t\tfieldset.find('.address-remove').off('click').on('click', function(e){\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\$(this).parent().remove();\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t\tfieldset.after(btn);\n\t\t\t\t\tfieldset.find('.address-field-wrap').each(function(i, grp){\n\t\t\t\t\t\tif (i === 0) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgrp = \$(grp);\n\t\t\t\t\t\tif (!grp.find('.address-remove').length) {\n\t\t\t\t\t\t\tvar rmv = \$('<a class=\"address-remove icon-remove\" href=\"#\">Remove</a>').on('click', function(e){\n\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\$(this).parent().remove();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tgrp.append(rmv);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\t\t");
     App::get('document')->addScriptDeclaration("jQuery(document).ready(function(\$){\nmanageProfileAddresses();\n});");
     App::get('document')->addScriptDeclaration("jQuery(document).on('ajaxLoad', function(\$){\nmanageProfileAddresses();\n});");
     return implode($html);
 }