Jump to content

petsagouris

Members
  • Posts

    32
  • Joined

  • Last visited

Posts posted by petsagouris

  1. Unless I am missing something this module does not work for individual languages in fields that have language support. I tried doing it on my own but I have little knowledge of Processwire inner workings to make this happen. I've even tried stepping and evaluating expressions with XDebug to no avail.

    Can anyone give me pointers on the following two things:

    1.  Getting the $languages array inside the PageEditFieldPermissionConfig function
    2.  Checking that the current field in the field traversal is actually a Language supporting one.

    Furthermore I'd like to ask Ryan, if there is a reason that the PageEditFieldPermissionConfig function is placed in its own file?

    I am asking because there seems to be very little need to do so, since the PageEditFieldPermission::getModuleConfigInputfields() is just requiring the file and returning the function result immediately.

    edit: By achieving this, there is just one thing missing to open up the way for the translator roles ;) and that is making the inputs viewable but disabled.

  2. @horst relax, you are gonna have a heart attack. Sharpening matters to you, I get it.

    There are two possible explanation why Image manipulation libraries have basic sharpening.

    a) 90% of the people will never notice the difference between soft, medium, strong sharpening. Many of them may even not be satisfied with the sharpening that is done by the library because they might have chosen the wrong one.

    b) The web isn't about image quality that much, 72dpi doesn't let it matter.

    Recognizing that this is an area of your expertise I'd recommend you help the guys on that library out so PHP in general gets an advantage (and you get attributed for it too).

  3. It seems that TinyMCE used to have an option to do what Peter wants but it is nowhere to be found in the tinymce source (TinyMCE configuration: remove_linebreaks)

    The TextFormatter should look something like this (not tested apart from the regexp):

    <?php
    /**
     * TextFormatter to put new line character after a specified set of end tags.
     */
    class TextformatterNewlineAfterTags extends Textformatter {
    
      public static function getModuleInfo() {
        return array(
          'title' => 'Line characters after specific HTML tags',
          'version' => 100,
          'summary' => "Adds line characters after the <br> and </p> end tags. ",
        );
      }
      public function format(&$str) {
        $str = preg_replace('/(?:<\\/p>)|(?:<br\\s*\\/?>)/', '$0\\n', $str);
      }
    }
     
  4. Provided that the LanguageParser inside Processwire can parse a file and identify the translatable strings I believe that it would be fairly easy to get all the files parsed and have the resulting files dumped in a folder in any format. It would be best to have that invocable (http request or commandline) since it may or may not be a heavy operation run only sporadically in development.

  5. I'd like to add that in Transifex there are "resources" (the master language files) that may be set up to be fetched periodically from a public repository making the upadting of the strings inside those resources a non issue for the developers.

  6. $field->collapsed|notes are going to be treated the same as the $field->label in the above example. All the magic attributes are known before hand by the Inputfield so there is no problem to actually pass an array and let the Inputfield object do the work of assigning the configuration to the object.

    From the first post it isn't clear that the intent is not to remove existing behavior. The object creation is not going away in fact it is going to be used at the Inputfield level (at a deeper level in the inheritance tree) by using the data inputted from the field configuration array.

    The way I have understood the current situation is that making a field is basically "configuring" a field. Since there is nothing dynamic about inputing configuration, that is exactly what I am proposing to make easier.

  7. I have been digging in the Processwire source to find out how everything works for making some contributions.

    I noticed that module configuration is similarly to this (Taken from the ModulesManager module by Soma):

    static public function getModuleConfigInputfields(array $data) {
      $data = array_merge(self::$defaults, $data);
    
      $fields = new InputfieldWrapper();
      $modules = wire("modules");
        
      $field = $modules->get("InputfieldText");
      $field->attr('name', 'apikey');
      $field->attr('size', 10);
      $field->attr('value', $data['apikey']);
      $field->label = "modules.processwire.com APIkey";
      $fields->append($field);
    
      $field = $modules->get("InputfieldText");
      $field->attr('name', 'remoteurl');
      $field->attr('size', 0);
      $field->attr('value', $data['remoteurl']);
      $field->label = "URL to webservice";
      $fields->append($field);
    
      $field = $modules->get("InputfieldInteger");
      $field->attr('name', 'limit');
      $field->attr('value', $data['limit']);
      $field->label = "Limit";
      $fields->append($field);
    
      $field = $modules->get("InputfieldInteger");
      $field->attr('name', 'max_redirects');
      $field->attr('value', $data['max_redirects']);
      $field->label = "Max Redirects for file_get_contents stream context (in case)";
      $fields->append($field);
    
      return $fields;
    }
    

    Would it be cleaner if Processwire allowed for a way to pass an array to setup the fields and maybe even pass an array of arrays of fields to generate an InputfieldWrapper (for instance)?

    something like:

    static public function getModuleConfigInputfields(array $data) {
      $data = array_merge(self::$defaults, $data);
    
      $fields = new InputfieldWrapper();
      $modules = wire("modules");
       
      $fields->append(array(
        'module' => 'InputfieldText',
        'attributes' => array( 'name' => 'apikey', 'size' => 10, 'value' => $data['apikey'] ),
        'label' => _('modules.processwire.com APIkey'),
        ));
    
      $fields->append(array(
        'module' => 'InputfieldText',
        'attributes' => array( 'name' => 'remoteurl', 'size' => 0, 'value' => $data['remoteurl'] ),
        'label' => _('URL to webservice'),
        ));
    
      $fields->append(array(
        'module' => 'InputfieldInteger',
        'attributes' => array( 'name' => 'limit', 'value' => $data['limit'] ),
        'label' => _('Limit'),
        ));
    
      $fields->append(array(
        'module' => 'InputfieldInteger',
        'attributes' => array( 'name' => 'max_redirects', 'value' => $data['max_redirects'] ),
        'label' => _('Max Redirects for file_get_contents stream context (in case)'),
        ));
       
      return $fields;
    }
    

    Or even:

    static public function getModuleConfigInputfields(array $data) {
      
      $data = array_merge(self::$defaults, $data);
    
      return new InputfieldWrapper(
        array(
          array(
            'module' => 'InputfieldText',
            'attributes' => array( 'name' => 'apikey', 'size' => 10, 'value' => $data['apikey'] ),
            'label' => _('modules.processwire.com APIkey'),
            ),
          array(
            'module' => 'InputfieldText',
            'attributes' => array( 'name' => 'remoteurl', 'size' => 0, 'value' => $data['remoteurl'] ),
            'label' => _('URL to webservice'),
          ),
          array(
            'module' => 'InputfieldInteger',
            'attributes' => array( 'name' => 'limit', 'value' => $data['limit'] ),
            'label' => _('Limit'),
            ),
          array(
            'module' => 'InputfieldInteger',
            'attributes' => array( 'name' => 'max_redirects', 'value' => $data['max_redirects'] ),
            'label' => _('Max Redirects for file_get_contents stream context (in case)'),
            )
          ));
    }
    

    Such a attitude towards form and input declaration can open the door to having forms stored in a structured static data format and just have them fed into to the appropriate container object.

    If the 'array(' parts are too much on the eyes remember that PHP 5.4 has short array syntax using [ and ].

×
×
  • Create New...