Not signed in (Sign In)

Categories

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

Help keep Vanilla free:
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthorMinisweeper
    • CommentTimeAug 12th 2005 edited
     # 1
    Its obviously not very high on anyones priorities but it might be nice to have an online dictionary creator/updator (as an extension or standalone document or whatever) which loaded all the definitions into a page with edit boxes and allowed people to write dictionaries that way instead of having to edit the files (which while being perfectly simple *might* scare a couple of people off).
    It might also make it easier for people to work together on translations

    If people want it i'm willing to have a go at writing it (shouldnt be that impossible?)

    What do you think?
    •  
      CommentAuthorMark
    • CommentTimeAug 12th 2005
     # 2
    That would be awesome. Esp if it was wiki-style where it held revisions and allows rollbacks.
  1.  # 3
    Um. I guess if i actually put some thought into it i could make it run rollbacks. Maybe i'll give it a go then?
  2.  # 4
    Mark - how much is the dictionary changing between now and (1.0)?
    •  
      CommentAuthorMark
    • CommentTimeAug 12th 2005
     # 5
    Not very much at all. There will be a few definitions removed and a few added, but it's still an associative array and it will be named the same.
    •  
      CommentAuthorlech
    • CommentTimeAug 12th 2005
     # 6
    hmmm, I don't suppose there's an inactive option to "view as plain text" on the wiki, is there mark? I suppose then you could easily post each language dictionary to it's own namespace ala vanilla:translations:en-US , vanilla:translations:en-UK and the like and give each one their own page for wikitizing.
  3.  # 7
    Hmm. Well i've knocked together an *Extremely* basic idea of what i'm talking about here: http://www.badassg.me.uk/lussumo/dictionary.php so people who might not have quite understood know what i'm talking about.
    You'll see what i mean by basic - my php is rusty at best and i've knocked it together in a drunken stupor while watching coupling on my second screen.
    I'll try and get it to a slightly more reasonable stage tomorrow.
    •  
      CommentAuthorlech
    • CommentTimeAug 12th 2005
     # 8
    hehe, yeah, I'll wait until a sober attempt is knocked together. BTW coupling is absolutely brilliant, I'm happy there's a station here in Chicago which plays a few episodes every saturday.
  4.  # 9
    lol. That was rather appauling wasnt it. It gave people the general idea though...and it probably wont improve much now that i am sober(ish)
    And yeah, i downloaded all 4 series' so i watch a couple occasionally. I love jeff.
  5.  # 10
    So, do you think it'd be better to use editboxes as opposed to text inputs since some of the stuff will be multiline? And excuse my ignorance but how can i force it to ignore the html within the editbox?
    •  
      CommentAuthorlech
    • CommentTimeAug 13th 2005 edited
     # 11
    hehe, the whole cast is absolutely hysterical in their own right if you've watched many of them, however I'm not even sure what season im even watching.

    So, do you think it'd be better to use editboxes as opposed to text inputs since some of the stuff will be multiline? And excuse my ignorance but how can i force it to ignore the html within the editbox?

    A mix of the two would be wise especially for those extra long paragraph inputs. To ignore html within either of the areas, you'll need to do a proper conversion when reading out, so tags get converted to their proper html entities rather than raw tags being displayed. That way the browser will render the entities and not get confused with the code. That makes sense, right?
  6.  # 12
    Yeah, a mix of the two would be more ideal but i'm designing it to run on the fly. I suppose i could calculate if its longer than X characters and if it is then i could use editboxes.
    And yeah i could render the entities, that doesnt really help the novices i'm aiming at though because it might confuse them - isnt there another way to do it?

    And ofcourse the whole cast is funny, i just love all the stupid shit jeff comes out with (i suppose i can relate to him most..=\)
    •  
      CommentAuthorlech
    • CommentTimeAug 13th 2005
     # 13
    I suppose if you're including this as an extension, having the most options would be really kick ass so admins can easily create translations as they need them. As for the entity portion, thats pretty much the safest way to avoid markup from actually rendering, and the only time you'll need to do it is on the read INTO the form, not to the save. at least for < > and other special characters which would get interpreted as part of markup and become rendered. The conversion inbound and outbound would also be extra helpful for arabic and asian languages and highly special characters.

    The fastest way to populate your selected fieldtypess, would be as you said, check for the character length, another quick way to set up the values would be just to load everything into an array and spit it out field for value to save yourself from doing it all one-by-one painstakingly by hand.
  7.  # 14
    you lost me with the array thing. In any case i've urlencoded the values and put longer things into edit boxes and its starting to look slightly more sensible.
    Any way i can make the edit boxes grow according to their contents?
    •  
      CommentAuthorlech
    • CommentTimeAug 13th 2005
     # 15
    for each value, echo it's handler and accompanying value. that should make sense, however I'm not too keen on how to make that friendly enough without creating an exploit.

    mark any ideas on how to do something like that?
  8.  # 16
    well its like this: http://www.badassg.me.uk/lussumo/dictionary.php at the moment with the handle on one side and the value on the other (am i right in thinking the dictionary used to have the origional definitions as comments on every line to help you edit it if you couldnt work out what it was meant to be saying? and if so where did they go?)
    And it gets all that from the file dynamically; which is good because then when new definitions are added it will cope with them. But how can i then make it rewrite the file when i dont know how many bits i'm gonna be writing into it? Obviously i can make it pass all the variables with a save button but that doesnt really achieve much. I assume i need an array of some sort but i've never really used them in php...
    •  
      CommentAuthorMark
    • CommentTimeAug 13th 2005
     # 17
    I actually think it would be pretty cool to extend the Dictionary to a point where admins can turn an edit mode on, and then there is an edit button at the end of every piece of text on the screen (for admins) that allows them to click it and be presented with a form where they can edit that text and save it.

    That way you can just go through the application page by page converting all of the text and seeing exactly what it looks like.
  9.  # 18
    oh hell you just flew this rocket right out of my launchpad. That would be awesome but theres is no way in hell i could achieve it. *passes the torch.
  10.  # 19
    as a pointer, if someone was gonna do this with the dictionary, it should also be done for stylesheeting?
  11.  # 20
    Right, i've just about got it working as i was planning on getting working atleast, i just need to learn how to use arrays properly and stop messing around with stupid variables. Then unless someones willing to implement marks rather superb idea i'll carry on getting it more useful for multi user development and such like.
    Night.
  12.  # 21
    If someone else could post in this thread so its not just my drunken ramblings it'd help a lot... ;)
    Excuse my ignorance, but how can i create an array (i think i want it containing a definition id, name, and value) from the form input? I have the id, name, and value, but i dunno how to get them into an array?
    •  
      CommentAuthorMark
    • CommentTimeAug 14th 2005 edited
     # 22
    $MyArray = new array();
    $MyArray["id"] = $id;
    $MyArray["name"] = $name;
    $MyArray["value"] = $value;


    :D
    •  
      CommentAuthorsweeney
    • CommentTimeAug 14th 2005 edited
     # 23
    You can make the name attributes of a form element part of an array with php.


    your html:

    &lt;input type=&quot;text&quot; name=&quot;defs[1][name]&quot; value=&quot;definition name one&quot; /&gt;
    &lt;input type=&quot;text&quot; name=&quot;defs[1][value]&quot; value=&quot;definition value one&quot; /&gt;

    &lt;input type=&quot;text&quot; name=&quot;defs[2][name]&quot; value=&quot;definition name two&quot; /&gt;
    &lt;input type=&quot;text&quot; name=&quot;defs[2][value]&quot; value=&quot;definition value two&quot; /&gt;

    ----
    server side:

    print_r($_POST['defs']);

    makes:

    Array (
    [defs] => Array
    (
    [1] => Array
    (
    [value] => definition value one
    [name] => definition name one
    )

    [2] => Array
    (
    [value] => definition value two
    [name] => definition name two
    )

    )
    )
  13.  # 24
    well i'd figured that much, but how do i do that in a form?
    Like usually the name of an element would become a variable assigned with the value of the value of an element. That makes sense to me but is written dreadfully.
    •  
      CommentAuthorsweeney
    • CommentTimeAug 14th 2005
     # 25
    If you want to speed up Mark's way, lose the double quotes and use singles. Singles aren't checked for internal variables, so will parse faster.


    $MyArray = new array();
    $MyArray['id'] = $id;
    $MyArray['name'] = $name;
    $MyArray['value'] = $value;


    or even go for :


    $MyArray=array();
    array_push($MyArray, $id, $name, $value);


    if you don't need keys to be named.

    M.
  14.  # 26
    hmm. got it. What if the id needs to be gotten from a variable? like would name="defs[$w][name]" work?
    •  
      CommentAuthorsweeney
    • CommentTimeAug 14th 2005
     # 27
    yes, so long as you escape things properly.


    $w='somevar';
    echo"
    &lt;input type=\&quot;text\&quot; name=\&quot;defs[$w][name]\&quot; value=\&quot;\&quot; /&gt;
    ";



    M.
  15.  # 28
    i cant believe i just asked that question. sorry, *gets back to coupling and coding.
    •  
      CommentAuthorsweeney
    • CommentTimeAug 14th 2005
     # 29
    haha never mind - we all have lapses!

    M.
    • CommentAuthorMinisweeper
    • CommentTimeAug 14th 2005 edited
     # 30
    Right, so say i have
    <input type='hidden' name='DefRef[0][name]' value='ThisLanguageName'>
    <input type='text' name='DefRef[0][value]' value='English'>
    How do i then read those values when the stuff has been posted?
  16.  # 31
    Hold up, i'm being useless again.
  17.  # 32
    Right, so i now have http://www.badassg.me.uk/lussumo/dictionary.php working to output http://www.badassg.me.uk/lussumo/Creation.txt
    God knows why it doesnt like 8-37. The rest looks ok though.
    •  
      CommentAuthorlech
    • CommentTimeAug 14th 2005
     # 33
    looking good mini! you might want to widen those inputs though :D
  18.  # 34
    Yeah, how? Do i have to absolutely size them or can i make them grow depending on the contents?
    •  
      CommentAuthorsweeney
    • CommentTimeAug 15th 2005
     # 35
    CSS is your friend:


    input {
    width : 200px;
    }


    M ;-)
  19.  # 36
    Cheers, i'll add that when i get home. What else needs doing?
    •  
      CommentAuthorsweeney
    • CommentTimeAug 15th 2005
     # 37
    Make sure that the attributes (name, value, title etc) are all enclosed in double quotes, not singles.

    <input type='text' name='foo' /> != good

    <input type="text" name="foo" /> == good

    M.
  20.  # 38
    Does that matter? I've always used singles, force of habit i guess.
    •  
      CommentAuthorsweeney
    • CommentTimeAug 15th 2005
     # 39
    Yeah - it's invalid HTML. It'll take your browser longer to render, and won't make any pages validate. If possible it's better to write valid code, because it avoids silly bugs and makes cross-browser compliance a whole lot better.

    M.
  21.  # 40
    fair enough, i'll sort that when i get back too. It'l make my code all messy and escaping-slashified though :(
    •  
      CommentAuthorlech
    • CommentTimeAug 15th 2005
     # 41
    in your php, change all double quotes to single, that will make everything within those quotes literal
    •  
      CommentAuthorlech
    • CommentTimeAug 15th 2005 edited
     # 42
    meaning, you can then chalk up fully valid markup like so:

    $foo = '&lt;input class="bar"&gt;wheeee!&lt;/input&gt;';
    echo $foo;
  22.  # 43
    doesnt php use single vs double as some way of working out whether it needs to evaluate something? Though i suppose thats not really an issue.
    •  
      CommentAuthorlech
    • CommentTimeAug 15th 2005
     # 44
    well, within double quotes, you can safely use single quotes and within single quotes you can safely use double quotes. it's only when you want the same quote types within the same value and that forces you to escape the markup from the variable and so on.
  23.  # 45
    Hmm, the css hasnt done exactly what i want but i suppose its looking a bit better.
    I fixed my double quotes too.
    Now should i carry on doing this and working revisions etc into it or is someone gonna implement marks considerably better edit on the spot idea?
    •  
      CommentAuthorlech
    • CommentTimeAug 15th 2005
     # 46
    mini, mind if i see the code?
    • CommentAuthorMinisweeper
    • CommentTimeAug 15th 2005 edited
     # 47
    not atall. http://www.badassg.me.uk/lussumo/dictionary.phps It's my usual messy and poor if-it-does-the-job-leave-it trick. But hey! I also borrowed a couple of lines from marks code because i'm lazy and it was easier than looking it up on php.net. I've never worked with files before.
  24.  # 48
    if you could work out why it doesnt like the random lines it misses feel free to tell me.
    And any improvements you wanna suggest/add/just take it and make it actually good.
    •  
      CommentAuthorlech
    • CommentTimeAug 15th 2005
     # 49
    I'll have a whack at it when I wake up and see what I can do, my php is hacktastic at best but this doesn't look to be impossible to crack into :)

    I haven't looked yet, but can you or mark confirm the method in which vanilla writes out to the settings.php file? is it only for the settings.php or is it a global function which can be branched off to edit other files as well?
    •  
      CommentAuthorMarti
    • CommentTimeAug 15th 2005
     # 50
    I also had a whack at it, but since I haven't studied Vanilla's framework, I didn't try to make it an extension. The functions I wrote aren't very object-oriented, but maybe these will help someone nevertheless.
    Here's the source:
    http://marti.labidas.com/project/vanilla/dictionary_lister.phps
    And here's the script: http://marti.labidas.com/project/vanilla/dictionary_lister.php
    It should create 2 files, "English.php" and "English.phps" in the "languages/" folder.