Skip to content

Commit

Permalink
validate filepath -> filePath in XML (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
richard67 authored and zero-24 committed Sep 29, 2019
1 parent 206fe7a commit fe60e1b
Show file tree
Hide file tree
Showing 29 changed files with 51 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
directory="banners"
hide_none="1"
size="40"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
type="media"
label="COM_CATEGORIES_FIELD_IMAGE_LABEL"
description="COM_CATEGORIES_FIELD_IMAGE_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@
label="COM_CONFIG_FIELD_OFFLINE_IMAGE_LABEL"
description="COM_CONFIG_FIELD_OFFLINE_IMAGE_DESC"
showon="offline:1"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
14 changes: 7 additions & 7 deletions administrator/components/com_contact/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
description="COM_CONTACT_FIELD_PARAMS_IMAGE_DESC"
default=""
showon="show_info:1[AND]show_image:1"
validate="filepath"
validate="filePath"
/>

<field
Expand Down Expand Up @@ -468,7 +468,7 @@
hide_none="1"
default=""
showon="contact_icons:0"
validate="filepath"
validate="filePath"
/>

<field
Expand All @@ -479,7 +479,7 @@
hide_none="1"
default=""
showon="contact_icons:0"
validate="filepath"
validate="filePath"
/>

<field
Expand All @@ -490,7 +490,7 @@
hide_none="1"
default=""
showon="contact_icons:0"
validate="filepath"
validate="filePath"
/>

<field
Expand All @@ -501,7 +501,7 @@
hide_none="1"
default=""
showon="contact_icons:0"
validate="filepath"
validate="filePath"
/>

<field
Expand All @@ -512,7 +512,7 @@
hide_none="1"
default=""
showon="contact_icons:0"
validate="filepath"
validate="filePath"
/>

<field
Expand All @@ -523,7 +523,7 @@
hide_none="1"
default=""
showon="contact_icons:0"
validate="filepath"
validate="filePath"
/>
</fieldset>

Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_content/models/forms/article.xml
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@
type="media"
label="COM_CONTENT_FIELD_INTRO_LABEL"
description="COM_CONTENT_FIELD_INTRO_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down Expand Up @@ -866,7 +866,7 @@
type="media"
label="COM_CONTENT_FIELD_FULL_LABEL"
description="COM_CONTENT_FIELD_FULL_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
type="media"
label="COM_NEWSFEEDS_FIELD_FIRST_LABEL"
description="COM_NEWSFEEDS_FIELD_FIRST_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down Expand Up @@ -321,7 +321,7 @@
type="media"
label="COM_NEWSFEEDS_FIELD_SECOND_LABEL"
description="COM_NEWSFEEDS_FIELD_SECOND_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_tags/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
type="media"
label="COM_TAGS_TAG_LIST_MEDIA_LABEL"
description="COM_TAGS_TAG_LIST_MEDIA_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_tags/models/forms/tag.xml
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
label="COM_TAGS_FIELD_INTRO_LABEL"
description="COM_TAGS_FIELD_INTRO_DESC"
labelclass="control-label"
validate="filepath"
validate="filePath"
/>

<field
Expand Down Expand Up @@ -304,7 +304,7 @@
label="COM_TAGS_FIELD_FULL_LABEL"
description="COM_TAGS_FIELD_FULL_DESC"
labelclass="control-label"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
2 changes: 1 addition & 1 deletion administrator/templates/hathor/templateDetails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
description="TPL_HATHOR_LOGO_DESC"
class=""
default=""
validate="filepath"
validate="filePath"
/>

<field
Expand Down
4 changes: 2 additions & 2 deletions administrator/templates/isis/templateDetails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
description="TPL_ISIS_LOGO_DESC"
class=""
default=""
validate="filepath"
validate="filePath"
/>

<field
Expand All @@ -114,7 +114,7 @@
description="TPL_ISIS_LOGIN_LOGO_DESC"
class=""
default=""
validate="filepath"
validate="filePath"
/>

<field
Expand Down
4 changes: 2 additions & 2 deletions components/com_content/models/forms/article.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
type="media"
label="COM_CONTENT_FIELD_INTRO_LABEL"
description="COM_CONTENT_FIELD_INTRO_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down Expand Up @@ -278,7 +278,7 @@
type="media"
label="COM_CONTENT_FIELD_FULL_LABEL"
description="COM_CONTENT_FIELD_FULL_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
2 changes: 1 addition & 1 deletion components/com_tags/views/tag/tmpl/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
type="media"
label="COM_TAGS_TAG_LIST_MEDIA_LABEL"
description="COM_TAGS_TAG_LIST_MEDIA_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
2 changes: 1 addition & 1 deletion components/com_tags/views/tag/tmpl/list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
type="media"
label="COM_TAGS_TAG_LIST_MEDIA_LABEL"
description="COM_TAGS_TAG_LIST_MEDIA_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
2 changes: 1 addition & 1 deletion components/com_tags/views/tags/tmpl/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
type="media"
label="COM_TAGS_ALL_TAGS_MEDIA_LABEL"
description="COM_TAGS_ALL_TAGS_MEDIA_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
4 changes: 2 additions & 2 deletions components/com_users/views/login/tmpl/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
type="media"
label="JFIELD_LOGIN_IMAGE_LABEL"
description="JFIELD_LOGIN_IMAGE_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down Expand Up @@ -160,7 +160,7 @@
type="media"
label="JFIELD_LOGOUT_IMAGE_LABEL"
description="JFIELD_LOGOUT_IMAGE_DESC"
validate="filepath"
validate="filePath"
/>

</fieldset>
Expand Down
10 changes: 10 additions & 0 deletions libraries/src/Form/Rule/FilePathRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ class FilePathRule extends FormRule
*/
public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null)
{
$value = trim($value);

// If the field is empty and not required, the field is valid.
$required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required');

if (!$required && empty($value))
{
return true;
}

// Append the root path
$value = JPATH_ROOT . '/' . $value;

Expand Down
2 changes: 1 addition & 1 deletion modules/mod_custom/mod_custom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
type="media"
label="MOD_CUSTOM_FIELD_BACKGROUNDIMAGE_LABEL"
description="MOD_BACKGROUNDIMAGE_FIELD_LOGO_DESC"
validate="filepath"
validate="filePath"
/>
</fieldset>
<fieldset name="advanced">
Expand Down
4 changes: 2 additions & 2 deletions templates/beez3/templateDetails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
type="media"
label="TPL_BEEZ3_FIELD_LOGO_LABEL"
description="TPL_BEEZ3_FIELD_LOGO_DESC"
validate="filepath"
validate="filePath"
/>

<field
Expand Down Expand Up @@ -144,7 +144,7 @@
label="TPL_BEEZ3_FIELD_HEADER_IMAGE_LABEL"
description="TPL_BEEZ3_FIELD_HEADER_IMAGE_DESC"
showon="templatecolor:image"
validate="filepath"
validate="filePath"
/>

<field
Expand Down
2 changes: 1 addition & 1 deletion templates/protostar/templateDetails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
description="TPL_PROTOSTAR_LOGO_DESC"
class=""
default=""
validate="filepath"
validate="filePath"
/>

<field
Expand Down

0 comments on commit fe60e1b

Please sign in to comment.