Login   Register  
PHP Classes
elePHPant
Icontem

File: CiscoIPPhone/XMLServices/CiscoIPPhoneExecute.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Tyler Winfield  >  Cisco IP Phone Framework  >  CiscoIPPhone/XMLServices/CiscoIPPhoneExecute.php  >  Download  
File: CiscoIPPhone/XMLServices/CiscoIPPhoneExecute.php
Role: Class source
Content type: text/plain
Description: class file for Cisco XML execute service objects
Class: Cisco IP Phone Framework
Generate XML for services of Cisco IP phones
Author: By
Last change:
Date: 2011-01-05 22:29
Size: 2,533 bytes
 

Contents

Class file image Download
<?php
/*
 * This software is freely available and distributed under the Mozilla Public
 * License agreement (MPL).   A copy of the MPL may obtain at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 *
 * Original code by Minded Software Solutions (http://minded.ca/)
 * Initial Developer - Tyler Winfield
 * Copyright (C) Minded Software Solutions.  All Rights Reserved.
 */

/**
 * CiscoIPPhoneExecute
 *   service class for building execution request objections
 *
 * @author twinfield
 */
require_once('CiscoIPPhone/Core/CiscoXMLService.php');

class 
CiscoIPPhoneExecute extends CiscoXMLService 
{
    protected 
$_executeItems;

    public function 
__construct() 
    {
        
parent::__construct();
        
$this->service = new DOMDocument('1.0''utf-8');
        
$this->service->appendChild($this->service->createElement('CiscoIPPhoneExecute'));

        
$this->_executeItems = array();
    }
    
    public function 
addItem($url$priority 0)
    {
        if(!
$this->hasItem($url)) {
            
$this->insertItem($url$priority);
            return 
true;
        }
        return 
false;
    }

    private function 
hasItem($url$priority)
    {
        foreach(
$this->_executeItems as $e) {
            if(
$e->getAttribute('URL') == htmlspecialchars($url) && $e->getAttribute('Priority') == (string)$priority)
                return 
true;
        }
        return 
false;
    }

    private function 
insertItem($url$priority)
    {
        
$executeItem $this->service->createElement('ExecuteItem');

        
$attr_URL $executeItem->createAttribute('URL');
        
$attr_URL->appendChild($executeItem->createTextNode(htmlspecialchars($url)));
        
$executeItem->appendChild($attr_URL);

        
$attr_Priority $executeItem->createAttribute('Priority');
        
$attr_Priority->appendChild($executeItem->createTextNode((string)$priority));
        
$executeItem->appendChild($attr_Priority);

        
array_push($this->_executeItems$executeItem);
    }

    public function 
toXML()
    {
        foreach(
$this->_executeItems as $e)
        {
            
$this->service->documentElement->appendChild($this->service->importNode($e->documentElementtrue));
        }
        return 
parent::toXML();
    }
}

?>