GithubHelp home page GithubHelp logo

thecogworks / cogworks.findandreplace Goto Github PK

View Code? Open in Web Editor NEW
2.0 6.0 7.0 473 KB

A simple and intuitive package which allows editors to find and replace content in Umbraco 7.

License: MIT License

JavaScript 46.38% C# 35.61% CSS 8.32% HTML 9.69%
umbraco umbraco-backoffice angular angularjs hacktoberfest dotnet

cogworks.findandreplace's People

Contributors

aochmann avatar dependabot[bot] avatar ja0b avatar motohead400 avatar mzajkowski avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cogworks.findandreplace's Issues

Not restricted to specific users

The Find & Replace tool is really nice and simple to use, but isn't restricted to specific users. This means that, theoretically, any Umbraco user could change content across the site unchecked. Is it possible for the tool to be locked down based on user permissions?

No multi-select

My stakeholders really like the simplicity of the tool and the fact that they can choose which documents to apply a change to rather than just applying it to all. However, they were disappointed at the lack of a multi-select option - so while they might not want to apply a change to all documents, they might want to apply it to quite a lot, but without having to apply one at a time. Would this be possible to include?
Thanks!

Update Find Sql for Umbraco v12

This is just a placeholder since I started working with the code (the find sql statement in particular) in this package and Umbraco v12. I found that, when running locally using SqlLite that the nested JOIN statements results in a syntax error from SqlLite. The docs seem to indicate nested JOINS are supported...but not for me. I reworked the sql in Cogworks.FindAndReplace.Web.API.FindPhrase to flatten the JOINS.

I also noted that SqlLite report that [umbracoDocumentVersion].[id] does not exist...it clearly does...so that is commented out. When left in the SqlLite compiler returns this error message:

Error while executing SQL query on database 'Umbraco.sqlite': no such column: umbracoDocumentVersion.id

The current sql statement that works as expected with v12 and SqlLite is:

SELECT
    [upd].[varcharValue] AS [VarcharValue],
    [upd].[textValue] AS [TextValue],
    [cv].[id] AS [VersionId],
    [pcv].[text] AS [NodeName],
    [upt].[Alias] AS [PropertyAlias],
    [upt].[Name] AS [PropertyName]
FROM [umbracoDocument]
INNER JOIN [umbracoContent] ON [umbracoContent].[nodeId] = [umbracoDocument].[nodeId]
INNER JOIN [umbracoNode] ON [umbracoNode].[id] = [umbracoContent].[nodeId]
INNER JOIN [umbracoContentVersion] [cv] ON [cv].[nodeId] = [umbracoDocument].[nodeId]
--INNER JOIN [umbracoDocumentVersion] [dv] ON [umbracoDocumentVersion].[id] = [cv].[id]
LEFT JOIN [umbracoContentVersion] [pcv] ON [pcv].[nodeId] = [umbracoDocument].[nodeId]
INNER JOIN [umbracoDocumentVersion] [pdv] ON [pdv].[id] = [pcv].[id] AND [pdv].[published] = 1
LEFT JOIN [umbracoContentVersionCultureVariation] [ccv] ON [cv].[id] = [ccv].[versionId]
--INNER JOIN [umbracoLanguage] [lang] ON [lang].[id] = [ccv].[languageId] AND [lang].[languageISOCode] = 'en-US'
INNER JOIN [umbracoPropertyData] [upd] ON [upd].[versionId] = [cv].[id]
INNER JOIN [cmsPropertyType] [upt] ON [upt].[id] = [upd].[propertyTypeId]
WHERE ([cv].[current] = 1)
    AND ([umbracoDocument].[published] = 1)
    AND ([umbracoNode].[path] LIKE upper('%YOUR HOME NODE ID%'))
    AND
    (
        (
            [upd].[textValue] is not null AND [upd].[textValue] LIKE '%YOUR SEARCH TERM%'
        )
        OR
        (
            [upd].[varcharValue] is not null AND [upd].[varcharValue] LIKE '%YOUR SEARCH TERM%'
        )
    )
ORDER BY ([umbracoDocument].[nodeId])

I should note that I did not try the sql with SqlServer (any version) so the issues I noted may not exist for that RDBMS.

2 bugs found, with one solved => Multilangual site, Trailing spaces in replacement term removed

I've added the 8.x package to my Umbracxo 8.5.3. site, I've updated the source solution to 8.5.3. as well and ran into two issues.

The first is that in the FindAndReplaceApiController->content.SetValue(command.PropertyAlias, command.Value); is called without providing the culture which causes issues on amultilingual site (not sure if this still works if you site has 1 language.

Solution is ease:

  • In UpdateCommand add -> public string Culture { get; set; }

  • In FindAndReplaceApiController use -> content.SetValue(command.PropertyAlias, command.Value, command.Culture);

  • In FindAndReplaceservice.js you need to fill this value (it's supplied on the querystring):
    FindAndReplaceService.$inject = ['$http', '$routeParams', 'umbRequestHelper'];
    function setValue(contentId, propertyAlias, valueField, value) {

          var config = {
              PropertyAlias: propertyAlias,
              VersionId: contentId,
              **_Culture: $routeParams.mculture,_**
              Value: value
          };
         .....................
      }
    

The issue I had which I couldn't solve is that if the replacement terms ends with spaces, they are stripped off. There no trim() in the code so I suspect that this is something that AngularJS does unwanted. Any solution to this is also much appreciated ...

Find replace puts JSON from related links into another property

When I use this tool and the term I'm searching for is in a related links link, it puts the JSON of the related links property into another property on the same page that has nothing to do with the related links:

related links

json in other property

I'm using Umbraco version 7.6.5 assembly: 1.0.6428.37121

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.