Пример #1
0
 /**
  * Sets translations from row.
  *
  * @return void.
  */
 public function setRowTranslations()
 {
     foreach ($this->row->getRelatedTranslations() as $translation) {
         if ($translation->isOriginal()) {
             continue;
         }
         $locale = $translation->getLocale();
         $this->rowTranslations[$locale] = ['id' => $translation->getId(), 'edit_uri' => $translation->getEditUri()];
     }
 }
Пример #2
0
 /**
  * Add all iblock property codes to select.
  *
  * return null
  */
 protected function addAllPropsToSelect()
 {
     $this->select[] = 'ID';
     $this->select[] = 'IBLOCK_ID';
     $rsProps = static::$cIblockObject->getProperties($this->iblockId);
     while ($prop = $rsProps->fetch()) {
         $this->select[] = 'PROPERTY_' . $prop['CODE'];
     }
 }
Пример #3
0
 /**
  * Tests that append fails.
  *
  * @return void
  *
  * @global array The configuration of the plugins.
  */
 public function testAppendFails()
 {
     global $pluginc_cf;
     $plugin_cf['advancedform']['csv_separator'] = '';
     $_POST = array('advfrm-foo' => 'foo value', 'advfrm-bar' => 'bar"value');
     chmod($this->_rootFolder, 0);
     $this->_eMock->expects($this->once())->with('cntwriteto', 'file', $this->_csvFile);
     $errorReporting = error_reporting(0);
     Controller::appendCsv('test');
     error_reporting($errorReporting);
 }
 /**
  * Add a customize control.
  *
  * @since 1.0.0
  * @param numder $id Settings ID.
  * @param array  $args Control arguments.
  */
 public function add_control($id, $args)
 {
     static $control_priority = 0;
     $prefix = $this->prefix . '_';
     $section = $this->get_control_section($args);
     $id = 'option' === $this->type ? sprintf('%1$s_options[%2$s]', $this->prefix, esc_attr($id)) : esc_attr($id);
     $priority = isset($args['priority']) ? $args['priority'] : ++$control_priority;
     $default = isset($args['default']) ? $args['default'] : '';
     $title = isset($args['title']) ? esc_attr($args['title']) : esc_html__('Untitled Control', 'cherry-framework');
     $description = isset($args['description']) ? esc_attr($args['description']) : '';
     $transport = isset($args['transport']) ? esc_attr($args['transport']) : 'refresh';
     $field_type = isset($args['field']) ? esc_attr($args['field']) : 'text';
     $sanitize_callback = isset($args['sanitize_callback']) ? esc_attr($args['sanitize_callback']) : array($this, 'sanitize_' . $field_type);
     $sanitize_callback = is_callable($sanitize_callback) ? $sanitize_callback : 'sanitize_text_field';
     $sanitize_js_callback = isset($args['sanitize_js_callback']) ? esc_attr($args['sanitize_js_callback']) : '';
     $active_callback = isset($args['active_callback']) ? $this->active_callback($args['active_callback']) : '';
     // Add a customize setting.
     $this->customize->add_setting($id, array('type' => $this->type, 'capability' => $this->capability, 'default' => $default, 'transport' => $transport, 'sanitize_callback' => $sanitize_callback, 'sanitize_js_callback' => $sanitize_js_callback));
     // Prepare arguments for a customize control.
     $control_args = array('priority' => $priority, 'section' => $section, 'label' => $title, 'description' => $description, 'active_callback' => $active_callback, 'choices' => '');
     $control_class = '';
     switch ($field_type) {
         case 'text':
         case 'textarea':
         case 'email':
         case 'url':
         case 'password':
         case 'checkbox':
             $control_args = wp_parse_args(array('type' => $field_type), $control_args);
             break;
         case 'range':
         case 'number':
             $input_attrs = isset($args['input_attrs']) ? $args['input_attrs'] : array();
             $control_args = wp_parse_args(array('type' => $field_type, 'input_attrs' => $input_attrs), $control_args);
             break;
         case 'select':
             $choices = isset($args['choices']) ? $args['choices'] : array();
             $control_args = wp_parse_args(array('type' => 'select', 'choices' => $choices), $control_args);
             break;
         case 'fonts':
             $choices = isset($args['choices']) ? $args['choices'] : $this->get_fonts();
             $control_args = wp_parse_args(array('type' => 'select', 'choices' => $choices), $control_args);
             break;
         case 'radio':
             $choices = isset($args['choices']) ? $args['choices'] : array();
             $control_args = wp_parse_args(array('type' => 'radio', 'choices' => $choices), $control_args);
             break;
         case 'hex_color':
             $control_class = 'WP_Customize_Color_Control';
             break;
         case 'image':
             $control_class = 'WP_Customize_Image_Control';
             break;
         case 'file':
             $control_class = 'WP_Customize_Upload_Control';
             break;
         case 'iconpicker':
             $control_class = 'Cherry_WP_Customize_Iconpicker';
             $icon_data = isset($args['icon_data']) ? $args['icon_data'] : array();
             $control_args = wp_parse_args(array('icon_data' => $icon_data), $control_args);
             break;
         default:
             /**
              * Filter arguments for a `$field_type` customize control.
              *
              * @since 1.0.0
              * @param array  $control_args Control's arguments.
              * @param string $id           Control's ID.
              * @param object $this         Cherry_Customizer instance.
              */
             $control_args = apply_filters('cherry_customizer_control_args_for_{$field_type}', $control_args, $id, $this);
             break;
     }
     /**
      * Filter arguments for a customize control.
      *
      * @since 1.0.0
      * @param array  $control_args Control's arguments.
      * @param string $id           Control's ID.
      * @param object $this         Cherry_Customizer instance.
      */
     $control_args = apply_filters('cherry_customizer_control_args', $control_args, $id, $this);
     /**
      * Filter PHP-class name for a customize control (maybe custom).
      *
      * @since 1.0.0
      * @param array  $control_args Control's PHP-class name.
      * @param string $id           Control's ID.
      * @param object $this         Cherry_Customizer instance.
      */
     $control_class = apply_filters('cherry_customizer_control_class', $control_class, $id, $this);
     if (class_exists($control_class)) {
         $this->customize->add_control(new $control_class($this->customize, $id, $control_args));
     } else {
         $this->customize->add_control($id, $control_args);
     }
 }
Пример #5
0
 /**
  * Get the internal reference to the editor.
  *
  * @return	string
  */
 public function save()
 {
     return $this->_editor->save($this->inputId);
 }