/**
  * Render all parameters
  *
  * @access	public
  * @param	string	The name of the control, or the default text area if a setup file is not found
  * @return	array	Aarray of all parameters, each as array Any array of the label, the form element and the tooltip
  * @since	1.5
  */
 function getParams(&$control = null)
 {
     if (!isset($this->_xml)) {
         return false;
     }
     $results = array();
     foreach ($this->_xml->children() as $param) {
         $results[] = $this->getParam($param, $control);
     }
     return $results;
 }
 /**
  * Loads raw xml (with different namespaces) into array. 
  * Keeps attributes without namespace or xml prefix.
  * 
  * @param object $xml SimpleXML object.
  * @return array $array XML array.
  * @see http://www.php.net/manual/en/ref.simplexml.php#52512
  */
 private function load($xml)
 {
     $fils = 0;
     $array = array();
     foreach ($this->namespaces as $uri => $prefix) {
         foreach ($xml->children($uri) as $key => $value) {
             $child = $this->load($value);
             // To deal with the attributes,
             // only works for attributes without a namespace, or in with xml namespace prefixes
             if (count($value->attributes()) > 0 || count($value->attributes("xml", TRUE)) > 0) {
                 $child["@attributes"] = $this->getAttributes($value);
             }
             // Also add the namespace when there is one
             if (!empty($uri)) {
                 $child["@namespace"] = $uri;
             }
             //Let see if the new child is not in the array
             if (!in_array($key, array_keys($array))) {
                 $array[$key] = NULL;
                 $array[$key][] = $child;
             } else {
                 //Add an element in an existing array
                 $array[$key][] = $child;
             }
             $fils++;
         }
     }
     # no container, returning value
     if ($fils == 0) {
         return array((string) $xml);
     }
     return $array;
 }
Beispiel #3
0
 /**
  * Helper function
  *
  * @param  object $module
  * @param  object $element
  * @param  integer $level
  */
 protected static function _process($module, $element, $level = 0)
 {
     global $warp;
     if ($level == 0) {
         $element->attr('class', 'uk-subnav');
     } else {
         $element->addClass('level' . ($level + 1));
     }
     foreach ($element->children('li') as $li) {
         // is active ?
         if ($active = $li->attr('data-menu-active')) {
             $active = ' uk-active';
         }
         // is parent ?
         $ul = $li->children('ul');
         $parent = $ul->length ? ' uk-parent' : null;
         // set class in li
         $li->attr('class', sprintf('level%d' . $parent . $active, $level + 1, $li->attr('data-id')));
         // set class in a/span
         foreach ($li->children('a,span') as $child) {
             // set image
             if ($image = $li->attr('data-menu-image')) {
                 $child->prepend('<img src="' . $image . '" alt="' . $child->text() . '" /> ');
             }
             // set icon
             if ($icon = $li->attr('data-menu-icon')) {
                 $child->prepend('<i class="' . $icon . '"></i> ');
             }
         }
         // process submenu
         if ($ul->length) {
             self::_process($module, $ul->item(0), $level + 1);
         }
     }
 }
Beispiel #4
0
 /**
  * Callback called after a spec execution.
  *
  * @param object $log The log object of the whole spec.
  */
 public function specEnd($log = null)
 {
     $isOk = $log->passed() ? "ok" : "not ok";
     switch ($log->type()) {
         case 'skipped':
         case 'pending':
         case 'excluded':
             $prefix = "# {$log->type()} ";
             break;
         default:
             $prefix = '- ';
             break;
     }
     $message = $prefix . trim(implode(" ", $log->messages()));
     $this->_counter++;
     $this->write("{$isOk} {$this->_counter} {$message}\n");
     if ($exception = $log->exception()) {
         $this->write('# Exception: `' . get_class($exception) . '` Code(' . $exception->getCode() . '):' . "\n");
         $this->write('# Message: ' . $exception->getMessage() . "\n");
     } else {
         foreach ($log->children() as $log) {
             if ($log->passed()) {
                 continue;
             }
             $toString = function ($instance) {
                 return 'an instance of `' . get_class($instance) . '`';
             };
             foreach ($log->data() as $key => $value) {
                 $key = ucfirst($key);
                 $value = Text::toString($value, ['object' => ['method' => $toString]]);
                 $this->write("# {$key}: {$value}\n");
             }
         }
     }
 }
Beispiel #5
0
 /**
  * Method to get a PHP native value for a SimpleXMLElement object. -- called recursively
  *
  * @param   object  $node  SimpleXMLElement object for which to get the native value.
  *
  * @return  mixed  Native value of the SimpleXMLElement object.
  *
  * @since   1.0
  */
 protected function getValueFromNode($node)
 {
     switch ($node['type']) {
         case 'integer':
             $value = (string) $node;
             return (int) $value;
             break;
         case 'string':
             return (string) $node;
             break;
         case 'boolean':
             $value = (string) $node;
             return (bool) $value;
             break;
         case 'double':
             $value = (string) $node;
             return (double) $value;
             break;
         case 'array':
             $value = array();
             foreach ($node->children() as $child) {
                 $value[(string) $child['name']] = $this->getValueFromNode($child);
             }
             break;
         default:
             $value = new stdClass();
             foreach ($node->children() as $child) {
                 $value->{$child}['name'] = $this->getValueFromNode($child);
             }
             break;
     }
     return $value;
 }
Beispiel #6
0
 /**
  * Appends the given container to the notebook.
  *
  * @param  array   $page array(container, label)
  * @param  boolean $last Whether this page should be the last page or not
  * @return integer
  * @access private
  */
 function _addNotebookPage($page, $last = true)
 {
     // Add the container and the tab label.
     if ($last) {
         $this->notebook->append_page($page[0], $page[1]);
     } else {
         // Make this the second to last page.
         $position = count($this->notebook->children()) - 1;
         $this->notebook->insert_page($page[0], $page[1], $position);
         $this->notebook->show_all();
     }
 }
Beispiel #7
0
 /**
  * Save the order to persistent storage
  *
  * @return mixed Order ID if successfully saved, otherwise false
  */
 public function store($data)
 {
     $id = time() . dechex(intval(time()));
     $guests = [];
     foreach ($this->guests() as $guest) {
         $guests[] = ['name' => $guest, 'checkedIn' => false];
     }
     $order = ['title' => $id, 'customerName' => $data['name'], 'customerPhone' => $data['phone'], 'customerEmail' => $data['email'], 'comments' => $data['comments'], 'date' => date('Y-m-d'), 'time' => date('g:ia'), 'total' => $this->total(), 'guests' => yaml::encode($guests)];
     try {
         $orderPage = $this->event->children()->find('orders')->children()->create($id, 'order', $order);
     } catch (Exception $e) {
         die($e->getMessage());
     }
     return $orderPage;
 }
 /**
  * Récupère les informations d'une bière en parsant le DOM
  * @param  object $content
  * @return array
  */
 private function getData($content)
 {
     $data = array();
     $data[] = $content->find('h1', 0)->plaintext;
     $data[] = $content->children(5)->innertext;
     $detailLeft = $content->children(2)->children(0)->find('p');
     $detailRight = $content->children(2)->children(1)->find('p');
     foreach ($detailLeft as $item) {
         $data[] = $item->find('strong', 0)->innertext;
     }
     foreach ($detailRight as $item) {
         $data[] = $item->find('strong', 0)->innertext;
     }
     return $data;
 }
Beispiel #9
0
 /**
  * Helper function
  *
  * @param  object $module
  * @param  object $element
  * @param  integer $level
  */
 protected static function _process($module, $element, $level = 0)
 {
     global $warp;
     // get warp config
     $config = $warp['config'];
     if ($level == 0) {
         $element->attr('class', 'uk-subnav');
     } else {
         $element->addClass('level' . ($level + 1));
     }
     foreach ($element->children('li') as $li) {
         // is active ?
         if ($active = $li->attr('data-menu-active')) {
             $active = ' uk-active';
         }
         // is parent ?
         $ul = $li->children('ul');
         $parent = $ul->length ? ' uk-parent' : null;
         // set class in li
         $li->attr('class', sprintf('level%d' . $parent . $active, $level + 1, $li->attr('data-id')));
         // add all options that have a name starting with 'data-'
         foreach ($config->get("menus." . $li->attr('data-id'), array()) as $key => $value) {
             if (strpos($key, 'data-') === 0) {
                 // add an attribute named like the option itself
                 $li->attr($key, $value);
             }
         }
         // set class in a/span
         foreach ($li->children('a,span') as $child) {
             // set image
             if ($image = $li->attr('data-menu-image')) {
                 $child->prepend('<img class="uk-responsive-height" src="' . $image . '" alt="' . $child->text() . '" /> ');
             }
             // set icon
             if ($icon = $li->attr('data-menu-icon')) {
                 $child->prepend('<i class="' . $icon . '"></i> ');
             }
             if ($subtitle = $li->attr('data-menu-subtitle')) {
                 $child->append('<div>' . $subtitle . '</div>');
             }
         }
         // process submenu
         if ($ul->length) {
             self::_process($module, $ul->item(0), $level + 1);
         }
     }
 }
Beispiel #10
0
 /**
  * Parse an XML tree and pull results
  *
  * @param   object  $root
  * @return  array
  */
 private function _parseTree($root)
 {
     $records = array();
     foreach ($root->children() as $child) {
         if ($child->getName() == 'orcid-search-results') {
             foreach ($child->children() as $search_res) {
                 foreach ($search_res->children() as $profile) {
                     if ($profile->getName() == 'orcid-profile') {
                         $fields = array();
                         $this->_parseXml($profile, $fields);
                         array_push($records, $fields);
                     }
                 }
             }
         }
     }
     return $records;
 }
 /**
  * Parse timing info
  * @param object $a_ref_id
  * @param object $a_parent_id
  * @param object $timing
  * @return 
  */
 protected function parseTiming($a_ref_id, $a_parent_id, $timing)
 {
     $type = (string) $timing['Type'];
     $visible = (string) $timing['Visible'];
     $changeable = (string) $timing['Changeable'];
     include_once './Services/Object/classes/class.ilObjectActivation.php';
     $crs_item = new ilObjectActivation();
     $crs_item->setTimingType($type);
     $crs_item->toggleVisible((bool) $visible);
     $crs_item->toggleChangeable((bool) $changeable);
     foreach ($timing->children() as $sub) {
         switch ((string) $sub->getName()) {
             case 'Start':
                 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
                 $crs_item->setTimingStart($dt->get(IL_CAL_UNIX));
                 break;
             case 'End':
                 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
                 $crs_item->setTimingEnd($dt->get(IL_CAL_UNIX));
                 break;
             case 'SuggestionStart':
                 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
                 $crs_item->setSuggestionStart($dt->get(IL_CAL_UNIX));
                 break;
             case 'SuggestionEnd':
                 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
                 $crs_item->setSuggestionEnd($dt->get(IL_CAL_UNIX));
                 break;
             case 'EarliestStart':
                 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
                 $crs_item->setEarliestStart($dt->get(IL_CAL_UNIX));
                 break;
             case 'LatestEnd':
                 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
                 $crs_item->setLatestEnd($dt->get(IL_CAL_UNIX));
                 break;
         }
     }
     if ($crs_item->getTimingStart()) {
         $crs_item->update($a_ref_id, $a_parent_id);
     }
 }
Beispiel #12
0
 /**
  * Method to get a PHP native value for a SimpleXMLElement object
  *
  * @param   object  $node  SimpleXMLElement object for which to get the native value.
  * @return  mixed  Native value of the SimpleXMLElement object.
  */
 protected static function _decodeValue($node)
 {
     switch ($node['type']) {
         case 'integer':
             $value = (string) $node;
             return (int) $value;
             break;
         case 'string':
             return (string) $node;
             break;
         case 'boolean':
             $value = (string) $node;
             return (bool) $value;
             break;
         case 'double':
             $value = (string) $node;
             return (double) $value;
             break;
         case 'array':
         default:
             $value = array();
             foreach ($node->children() as $child) {
                 $value[(string) $child['name']] = self::_decodeValue($child);
             }
             break;
     }
     return $value;
 }
Beispiel #13
0
 /**
  * Method to get the list of possible permission action names for the form field.
  *
  * @param   object  $element  The JXMLElement object representing the <field /> tag for the
  *                            form field object.
  *
  * @return  array   A list of permission action names from the form field element definition.
  *
  * @since   11.1
  */
 protected function getFieldActions($element)
 {
     // Initialise variables.
     $actions = array();
     // Initialise some field attributes.
     $section = $element['section'] ? (string) $element['section'] : '';
     $component = $element['component'] ? (string) $element['component'] : '';
     // Get the asset actions for the element.
     $elActions = JAccess::getActions($component, $section);
     // Iterate over the asset actions and add to the actions.
     foreach ($elActions as $item) {
         $actions[] = $item->name;
     }
     // Iterate over the children and add to the actions.
     foreach ($element->children() as $el) {
         if ($el->getName() == 'action') {
             $actions[] = (string) $el['name'];
         }
     }
     return $actions;
 }
/**
 * parse SimpleXMLElement instance components, create iCalcreator component and update
 *
 * @author Kjell-Inge Gustafsson, kigkonsult <*****@*****.**>
 * @since  2.11.2 - 2012-01-15
 * @param  array  $iCal iCalcreator calendar instance
 * @param  object $component SimpleXMLElement
 * @return void
 */
function _getXMLComponents(&$iCal, &$component)
{
    $compName = $component->getName();
    $comp =& $iCal->newComponent($compName);
    $subComponents = array('valarm', 'standard', 'daylight');
    foreach ($component->children() as $compPart) {
        // properties and (opt) subComponents
        if (1 > $compPart->count()) {
            continue;
        }
        if (in_array($compPart->getName(), $subComponents)) {
            _getXMLComponents($comp, $compPart);
        } elseif ('properties' == $compPart->getName()) {
            foreach ($compPart->children() as $property) {
                // properties as single property
                _getXMLProperties($comp, $property);
            }
        }
    }
    // end foreach( $component->children() as $compPart )
}
Beispiel #15
0
 /**
  * Recursive method to toArray
  *
  * @param object $xml SimpleXMLElement object
  * @param array $parentData Parent array with data
  * @param string $ns Namespace of current child
  * @param array $namespaces List of namespaces in XML
  * @return void
  */
 protected static function _toArray($xml, &$parentData, $ns, $namespaces)
 {
     $data = array();
     foreach ($namespaces as $namespace) {
         foreach ($xml->attributes($namespace, true) as $key => $value) {
             if (!empty($namespace)) {
                 $key = $namespace . ':' . $key;
             }
             $data['@' . $key] = (string) $value;
         }
         foreach ($xml->children($namespace, true) as $child) {
             self::_toArray($child, $data, $namespace, $namespaces);
         }
     }
     $asString = trim((string) $xml);
     if (empty($data)) {
         $data = $asString;
     } elseif (!empty($asString)) {
         $data['@'] = $asString;
     }
     if (!empty($ns)) {
         $ns .= ':';
     }
     $name = $ns . $xml->getName();
     if (isset($parentData[$name])) {
         if (!is_array($parentData[$name]) || !isset($parentData[$name][0])) {
             $parentData[$name] = array($parentData[$name]);
         }
         $parentData[$name][] = $data;
     } else {
         $parentData[$name] = $data;
     }
 }
Beispiel #16
0
 /**
  * Recursively translates strings for a serialized option
  *
  * @since 1.0
  *
  * @param array|string $values either a string to translate or a list of strings to translate
  * @param object       $key    XML node
  * @return array|string translated string(s)
  */
 protected function translate_strings_recursive($values, $key)
 {
     $children = $key->children();
     if (count($children)) {
         foreach ($children as $child) {
             $attributes = $child->attributes();
             $name = (string) $attributes['name'];
             if (isset($values[$name])) {
                 $values[$name] = $this->translate_strings_recursive($values[$name], $child);
             }
         }
     } else {
         $values = pll__($values);
     }
     return $values;
 }
Beispiel #17
0
 /**
  * Method to parse through a languages element of the installation manifest and take appropriate
  * action.
  *
  * @access	public
  * @param	object	$element 	The xml node to process
  * @param	int		$cid		Application ID of application to install to
  * @return	boolean	True on success
  * @since	1.5
  */
 function parseLanguages($pathSrc, $element, $cid = 0)
 {
     // TODO: work out why the below line triggers 'node no longer exists' errors with files
     if (!$element || !count($element->children())) {
         // Either the tag does not exist or has no children therefore we return zero files processed.
         return 0;
     }
     // Initialise variables.
     $copyfiles = array();
     // Get the client info
     jimport('joomla.application.helper');
     $client = JApplicationHelper::getClientInfo($cid);
     /*
      * Here we set the folder we are going to copy the files to.
      *
      * 'languages' Files are copied to JPATH_BASE/language/ folder
      */
     $destination = $client->path . DS . 'language';
     /*
      * Here we set the folder we are going to copy the files from.
      *
      * Does the element have a folder attribute?
      *
      * If so this indicates that the files are in a subdirectory of the source
      * folder and we should append the folder attribute to the source path when
      * copying files.
      */
     $folder = (string) $element->attributes()->folder;
     if ($folder && JFolder::exists($pathSrc . DS . $folder)) {
         $source = $pathSrc . DS . $folder;
     } else {
         $source = $pathSrc;
     }
     // Process each file in the $files array (children of $tagName).
     foreach ($element->children() as $file) {
         /*
          * Language files go in a subfolder based on the language code, ie.
          *
          * 		<language tag="en-US">en-US.mycomponent.ini</language>
          *
          * would go in the en-US subdirectory of the language folder.
          *
          * We will only install language files where a core language pack
          * already exists.
          */
         if ((string) $file->attributes()->tag != '') {
             $path['src'] = $source . DS . $file;
             if ((string) $file->attributes()->client != '') {
                 // override the client
                 $langclient = JApplicationHelper::getClientInfo((string) $file->attributes()->client, true);
                 $path['dest'] = $langclient->path . DS . 'language' . DS . $file->attributes()->tag . DS . basename((string) $file);
             } else {
                 // use the default client
                 $path['dest'] = $destination . DS . $file->attributes()->tag . DS . basename((string) $file);
             }
             // If the language folder is not present, then the core pack hasn't been installed... ignore
             if (!JFolder::exists(dirname($path['dest']))) {
                 continue;
             }
         } else {
             $path['src'] = $source . DS . $file;
             $path['dest'] = $destination . DS . $file;
         }
         /*
          * Before we can add a file to the copyfiles array we need to ensure
          * that the folder we are copying our file to exits and if it doesn't,
          * we need to create it.
          */
         if (basename($path['dest']) != $path['dest']) {
             $newdir = dirname($path['dest']);
             if (!JFolder::create($newdir)) {
                 JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ERROR_CREATE_DIRECTORY', $newdir));
                 return false;
             }
         }
         // Add the file to the copyfiles array
         $copyfiles[] = $path;
     }
     $result = $this->copyFiles($copyfiles, true);
     return $result;
 }
Beispiel #18
0
 /**
  * Xml konvertálása stdClass-é
  *
  * @param object|string $xml
  * @param object|null   $obj
  *
  * @return mixed
  */
 private function xmlToObj($xml, $obj = null)
 {
     if (count($xml->children()) <= 0) {
         if (!$xml->attributes()) {
             return (string) $xml;
         } else {
             $obj = new \stdClass();
             foreach ($xml->attributes() as $attr => $value) {
                 $obj->{$attr} = (string) $value;
             }
             $obj->value = (string) $xml;
             return $obj;
         }
     }
     $obj = isset($obj) ? $obj : new \stdClass();
     foreach ($xml->children() as $element => $node) {
         $data = new \stdClass();
         if (!isset($obj->{$element})) {
             $obj->{$element} = "";
         }
         if (!$node->attributes()) {
             $data = $this->xmlToObj($node);
         } else {
             foreach ($node->attributes() as $attr => $value) {
                 $data->{$attr} = (string) $value;
             }
             if (count($node->children()) > 0) {
                 $data = $this->xmlToObj($node, $data);
             }
         }
         if (count($xml->{$element}) > 1) {
             $obj->{$element}[] = $data;
         } else {
             $obj->{$element} = $data;
         }
     }
     foreach ($xml->attributes() as $attr => $value) {
         $obj->{$attr} = (string) $value;
     }
     return $obj;
 }
Beispiel #19
0
 /**
  * Process Renewals
  *
  * A support method of renewMyItems which determines if the renewal attempt
  * was successful
  *
  * @param object $renewalObj A simpleXML object loaded with renewal data
  *
  * @return array             An array with the item id, success, new date (if
  * available) and system message (if available)
  * @access protected
  */
 protected function processRenewals($renewalObj)
 {
     // Not Sure Why, but necessary!
     $renewal = $renewalObj->children();
     $node = "reply-text";
     $reply = (string) $renewal->{$node};
     // Valid Response
     if ($reply == "ok") {
         $loan = $renewal->renewal->institution->loan;
         $itemId = (string) $loan->itemId;
         $renewalStatus = (string) $loan->renewalStatus;
         $response['item_id'] = $itemId;
         $response['sysMessage'] = $renewalStatus;
         if ($renewalStatus == "Success") {
             $dueDate = (string) $loan->dueDate;
             if (!empty($dueDate)) {
                 // Convert Voyager Format to display format
                 $newDate = $this->dateFormat->convertToDisplayDate("Y-m-d H:i", $dueDate);
                 $newTime = $this->dateFormat->convertToDisplayTime("Y-m-d H:i", $dueDate);
                 if (!PEAR::isError($newDate)) {
                     $response['new_date'] = $newDate;
                 }
                 if (!PEAR::isError($newTime)) {
                     $response['new_time'] = $newTime;
                 }
             }
             $response['success'] = true;
         } else {
             $response['success'] = false;
             $response['new_date'] = false;
             $response['new_time'] = false;
         }
         return $response;
     } else {
         // System Error
         return false;
     }
 }
Beispiel #20
0
 /**
  * thuc hien chuyen mot doi tuong xml thanh mot mang
  *
  * @param object $xml doi tuong xml
  * @return array cac phan tu trong doi tuong xml
  * @author TinhDoan added [20100723]
  *
  */
 public function parseXML($xml)
 {
     $arXML = array();
     $arXML['name'] = trim($xml->getName());
     $arXML['value'] = trim((string) $xml);
     //lay cac thuoc tinh
     $temp = array();
     foreach ($xml->attributes() as $nameAttr => $value) {
         $temp[$nameAttr] = trim($value);
     }
     $arXML['attribute'] = $temp;
     //lay cac node con
     $arXML['children'] = array();
     foreach ($xml->children() as $nameChild => $xmlchild) {
         $temp = self::parseXML($xmlchild);
         if (!isset($arXML['children'][$nameChild])) {
             $arXML['children'][$nameChild] = array();
         }
         array_push($arXML['children'][$nameChild], $temp);
     }
     return $arXML;
 }
Beispiel #21
0
 /**
  * Get css class of menu item
  * 
  * @param object $item Menu item
  * 
  * @return string Css class of menu item
  */
 function getclass($item)
 {
     $cls = $item->attributes('class');
     if ($item->attributes('first')) {
         $cls .= ' first';
     }
     if (count($item->children())) {
         $cls .= ' havechild';
     }
     if (is_array($this->_activeMenu)) {
         if (isset($this->_activeMenu[1])) {
             if ($item->menuId == $this->_activeMenu[1]) {
                 $cls .= ' active opened';
             }
         } else {
             if (isset($this->_activeMenu[0])) {
                 if ($item->menuId == $this->_activeMenu[0]) {
                     $cls .= ' active opened';
                 }
             }
         }
     }
     if (JRequest::getVar("group", "")) {
         $findWord = "group=" . JRequest::getVar("group", "");
         if (strpos($item->attributes('link'), $findWord) !== false) {
             $cls .= ' active ';
         }
     } else {
         if (JRequest::getVar("layout", "")) {
             $findWord = "layout=" . JRequest::getVar("layout", "");
             if (strpos($item->attributes('link'), $findWord) !== false) {
                 $cls .= ' active ';
             }
         } else {
             if (isset($this->_activeMenu[0])) {
                 if ($item->menuId == $this->_activeMenu[0]) {
                     $cls = str_replace("active", "", $cls);
                     $cls .= ' active opened';
                 }
             }
         }
     }
     $cls = trim($cls) ? 'class="' . trim($cls) . '"' : '';
     return $cls;
 }
Beispiel #22
0
 /**
  * 
  * 
  * IMPORTANT NOTE:
  * 	This code is re-used by GetEntitlementValuesAndUserRole(), so make sure 
  * 	that if you change this code, you don't break anything in that method.
  * 
  * @param object $Root
  * @return array
  */
 protected function _parseIPPGetEntitlementValues($Root)
 {
     $metadata = array();
     foreach ($Root->children() as $Node) {
         if (!$Node->hasChildren()) {
             $metadata[$Node->name()] = $Node->data();
         }
     }
     $list = array();
     $Entitlements = $Root->getChildAt('qdbapi/entitlements');
     foreach ($Entitlements->children() as $Node) {
         $Node2 = $Node->getChildAt('entitlement/term');
         $list[] = new QuickBooks_IPP_Entitlement($Node->getAttribute('id'), $Node->getChildDataAt('entitlement/name'), $Node2->getAttribute('id'), $Node2->data());
     }
     return array(0 => $metadata, 1 => $list);
 }
Beispiel #23
0
 /**
  * Method to parse through a files element of the installation manifest and remove
  * the files that were installed
  *
  * @param   object   $element  The XML node to process
  * @param   integer  $cid      Application ID of application to remove from
  *
  * @return  boolean  True on success
  *
  * @since   3.1
  */
 public function removeFiles($element, $cid = 0)
 {
     if (!$element || !count($element->children())) {
         // Either the tag does not exist or has no children therefore we return zero files processed.
         return true;
     }
     $retval = true;
     // Get the client info if we're using a specific client
     if ($cid > -1) {
         $client = JApplicationHelper::getClientInfo($cid);
     } else {
         $client = null;
     }
     // Get the array of file nodes to process
     $files = $element->children();
     if (count($files) == 0) {
         // No files to process
         return true;
     }
     $folder = '';
     /*
      * Here we set the folder we are going to remove the files from.  There are a few
      * special cases that need to be considered for certain reserved tags.
      */
     switch ($element->getName()) {
         case 'media':
             if ((string) $element->attributes()->destination) {
                 $folder = (string) $element->attributes()->destination;
             } else {
                 $folder = '';
             }
             $source = $client->path . '/media/' . $folder;
             break;
         case 'languages':
             $lang_client = (string) $element->attributes()->client;
             if ($lang_client) {
                 $client = JApplicationHelper::getClientInfo($lang_client, true);
                 $source = $client->path . '/language';
             } else {
                 if ($client) {
                     $source = $client->path . '/language';
                 } else {
                     $source = '';
                 }
             }
             break;
         default:
             if ($client) {
                 $pathname = 'extension_' . $client->name;
                 $source = $this->getPath($pathname);
             } else {
                 $pathname = 'extension_root';
                 $source = $this->getPath($pathname);
             }
             break;
     }
     // Process each file in the $files array (children of $tagName).
     foreach ($files as $file) {
         /*
          * If the file is a language, we must handle it differently.  Language files
          * go in a subdirectory based on the language code, ie.
          * <language tag="en_US">en_US.mycomponent.ini</language>
          * would go in the en_US subdirectory of the languages directory.
          */
         if ($file->getName() == 'language' && (string) $file->attributes()->tag != '') {
             if ($source) {
                 $path = $source . '/' . $file->attributes()->tag . '/' . basename((string) $file);
             } else {
                 $target_client = JApplicationHelper::getClientInfo((string) $file->attributes()->client, true);
                 $path = $target_client->path . '/language/' . $file->attributes()->tag . '/' . basename((string) $file);
             }
             // If the language folder is not present, then the core pack hasn't been installed... ignore
             if (!JFolder::exists(dirname($path))) {
                 continue;
             }
         } else {
             $path = $source . '/' . $file;
         }
         // Actually delete the files/folders
         if (is_dir($path)) {
             $val = JFolder::delete($path);
         } else {
             $val = JFile::delete($path);
         }
         if ($val === false) {
             JLog::add('Failed to delete ' . $path, JLog::WARNING, 'jerror');
             $retval = false;
         }
     }
     if (!empty($folder)) {
         JFolder::delete($source);
     }
     return $retval;
 }
Beispiel #24
0
 /**
  * draw the rewards from a successful event
  *
  * @param object $reward an object from the XML containing our rewards
  * @return void
  */
 public function drawRewards($reward)
 {
     $ret = "<h3>Rewards</h3>";
     foreach ($reward->children() as $a) {
         $stats[] = $a->attributes()->caption . ": " . $a->attributes()->value;
     }
     $ret .= implode("<br />", $stats);
     return $ret;
 }