Giter VIP home page Giter VIP logo

Comments (17)

tholder avatar tholder commented on August 18, 2024

My solution is currently this:

        $types = array();
        foreach ($tel->parameters as $param) {
            if ($param->name == 'TYPE') {
                $types[] = $param->value;
            }

        }

Bit scrappy but seems to work.

from vobject.

evert avatar evert commented on August 18, 2024

Hi!

This looks like a valid way to do this. Another way would be:

    $types = array();
    if (isset($tel['TYPE'])) {
       foreach($tel['TYPE'] as $type) {
          $types[] = (string)$type;
       }
    }

from vobject.

evert avatar evert commented on August 18, 2024

Closing this, just comment here if you have any other questions.

from vobject.

tholder avatar tholder commented on August 18, 2024

Thanks.

from vobject.

tholder avatar tholder commented on August 18, 2024

How do you go about accessing groups and then adding groups?

Trying to support the X-ABLabel, can't seem to find much reference anywhere.

from vobject.

evert avatar evert commented on August 18, 2024

Properties in a specific group will be fetched the same way as regular properties. There's one issue though:

$obj->group.TEL

Is not valid, so you use this instead:

$obj->{'group.TEL'}

from vobject.

tholder avatar tholder commented on August 18, 2024

How would you subsequently write those back?

E.g.

item1.TEL:9999999999
item1.X-ABLabel:new type

Presumably you could have:

item2.TEL etc

Is it item1 that's the group or TEL with a property of X-ABLabel?

thanks for your help.
Tom

from vobject.

evert avatar evert commented on August 18, 2024

Hi Tom,

Whatever is before the . is the group. Apple addressbook which properties belong together (TEL, X-ABLabel) based on this group. Does that make sense?

from vobject.

tholder avatar tholder commented on August 18, 2024

Kind of :)

I can't quite yet work out how I read that property of the TEL and how I use add method to put it back in.

Still, all good fun!

from vobject.

evert avatar evert commented on August 18, 2024

To update something, it's just:

$vcard->{'item1.TEL'} = 'new phone number';

from vobject.

tholder avatar tholder commented on August 18, 2024

Cool thanks, I've managed to read them out now fine.

Do I have to handle the numbering of item1, 2 etc or can I do it through using:

\Sabre\VObject\Component::create('vcard');

With add method and serialize?

Tom

from vobject.

evert avatar evert commented on August 18, 2024

No you are responsible for numbering. It's kind of an OS X addressbook-specific feature, so it didn't make sense in a generic library.

from vobject.

tholder avatar tholder commented on August 18, 2024

Thanks for all your help. Yeah that makes sense.

from vobject.

tanghus avatar tanghus commented on August 18, 2024

Since the subject opened here: I've been trying to figure if there is a way to query if there are any groups in a vobject/vcard and how to get a list of them? It's not very handy to have to test for item1 to itemN ;) This is possibly so obvious that I have missed it.

from vobject.

evert avatar evert commented on August 18, 2024

In that case the only way is to just loop through them, and check the ->group property.

from vobject.

tanghus avatar tanghus commented on August 18, 2024

Ah, ->group is a property. I had missed that. I thought you used it as an example only, but looking at the source of course it's there
eureka

from vobject.

evert avatar evert commented on August 18, 2024

:)

from vobject.

Related Issues (20)

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.