コード例 #1
0
 /**
  * display help icon
  * @param $module
  * @param $aField
  */
 private function generate_help_icon($module, $aField)
 {
     $module_label = isset($aField['module_info']['name']) ? $aField['module_info']['name'] : $module->module_name;
     $help = $aField['hw_help'];
     if (empty($help)) {
         return;
     }
     $help_file = HW_HELP::get_help_popup_file(array($help['class'], $help['file']));
     $_aAttributes = $aField['attributes'];
     $name = $_aAttributes['name'];
     $id = HW_Validation::valid_apf_slug($name);
     $html = '<a href="#" id="' . $id . '" data-hw-module="' . $module->module_name . '" data-hw-help-file="' . urlencode(HW_Encryptor::encrypt($help_file)) . '" title="' . $module_label . '"><img src="' . plugins_url('help_icon.png', __FILE__) . '" class="module-help-icon hw-module-help"/>Trợ giúp</a>';
     return $html;
 }
コード例 #2
0
 /**
  * generate help link with popup content
  * @param $file path of file help not link
  * @param $text anchor text link
  * @param $title dialog title
  */
 public static function generate_help_popup($file, $text = '', $title = '')
 {
     //get help file path
     $file = self::get_help_popup_file($file);
     //valid
     if (!is_string($file)) {
         return '<em>Không tìm thấy file help.</em>';
     }
     if (empty($text)) {
         $text = __('Hướng dẫn');
     }
     //valid
     if (empty($title)) {
         $title = $text;
     }
     $ajax_url = HW_HOANGWEB_AJAX;
     //HW_HELP_AJAX
     $ajax_url .= '?action=hw_help_popup&include_head=1&include_footer=1&file=' . urlencode(HW_Encryptor::encrypt($file));
     if (is_multisite()) {
         $ajax_url .= '&blog=' . get_current_blog_id();
     }
     return sprintf('<a href="%s" class="hw-help-link-popup" title="%s">%s</a>', $ajax_url, $title, $text);
 }
コード例 #3
0
 /**
  * Returns the output of the field type.
  * @param $aField
  */
 protected function getField($aField)
 {
     $this->init($aField);
     //$this->__aField = $aField;
     $_aAttributes = $aField['attributes'];
     $name = $this->get_field_name();
     $id = $this->get_field_id();
     $value = $this->get_field_value();
     $field_file = $this->get_field_name('file');
     if ($this->get_property('allow_multiple')) {
         $field_file .= '[]';
     }
     //upload configuration
     $configuration = $this->get_field_value('config');
     if (!$configuration) {
         $configuration = HW_Encryptor::encrypt($this->config);
     }
     //action url for upload file
     $html = '<div id="' . $this->get_field_id('hw-apf-uploader-container') . '" class="">';
     $html .= '<input type="hidden" name="' . $this->get_field_name('save_file') . '" id="' . $this->get_field_id('save_file') . '" value="' . $this->get_field_value('save_file') . '"/>';
     $html .= '<input type="hidden" name="' . $this->get_field_name('config') . '" value="' . $configuration . '"/>';
     $html .= '<input type="file" name="' . $field_file . '" id="' . $this->get_field_id('_file') . '"/>';
     $html .= '<div id="' . $this->get_field_id('_message') . '"></div>';
     if ($this->get_property('image_type')) {
         $html .= '<div id="' . $this->get_field_id('_image_preview') . '" class="hw-apf-upload-image-preview"><img id="' . $this->get_field_id('_previewing') . '" class="" src="' . plugins_url('assets/images/no-image.jpg', __FILE__) . '" /></div><hr id="line">';
     }
     $html .= '<input type="submit" class="button hw-apf-upload-btn" name="submit" value="' . __('Upload') . '"/>';
     //message
     $html .= '<div id="' . $this->get_field_id('messages') . '"></div>';
     $args = array('container' => '#' . $this->get_field_id('hw-apf-uploader-container'), 'message' => '#' . $this->get_field_id('_message'), 'preview' => '#' . $this->get_field_id('_previewing'), 'file_input' => '#' . $this->get_field_id('_file'), 'save_file' => '#' . $this->get_field_id('save_file'), 'id' => md5($this->get_field_name()));
     $html .= '<script>
 jQuery(document).ready(function(){
     var uploader = new HW_Uploader("#hw-apf-upload-field-container-' . $id . '");
     uploader.setup(' . json_encode($args) . ');
     uploader.callbacks({success: function(){}});
 });
 </script>';
     $html .= '</div>';
     return $aField['before_label'] . $aField['before_input'] . "<div class='repeatable-field-buttons'></div>" . "<div id='hw-apf-upload-field-container-{$id}'>" . $html . '</div>' . $aField['after_input'] . $aField['after_label'];
 }