Example #1
0
 /**
  * Add navigation node as a child
  * @staticvar int $counter
  * @param string $label
  * @param string $url
  * @param string $title
  * @return Node
  */
 public function addNode($label, $url, $title = NULL)
 {
     $node = new self();
     $node->setLabel($label);
     $node->setUrl($url);
     $node->setTitle($title);
     static $counter;
     $this->addComponent($node, ++$counter);
     return $node;
 }
Example #2
0
 /**
  * @param $category
  * @param $action
  * @param $label
  * @param $day
  * @param $month
  * @param $year
  * @return Event
  */
 public static function getByDate($category, $action, $label, $day, $month, $year)
 {
     $event = new self();
     try {
         $event->getDao()->getByDate($category, $action, $label, $day, $month, $year);
     } catch (\Exception $e) {
         $event->setTimestamp(mktime(1, 0, 0, $month, $day, $year));
         $event->setCategory($category);
         $event->setAction($action);
         $event->setLabel($label);
     }
     return $event;
 }
 public function build()
 {
     if ($this->isBuild) {
         return;
     }
     $settings = $this->getObject();
     $reflection = new \ReflectionClass($settings);
     $properties = $reflection->getProperties();
     $skipProperties = array('_settings', 'isWritable');
     if ($settings instanceof ModuleSettingsContainerInterface) {
         $skipProperties[] = '_module';
     }
     $children = array();
     foreach ($properties as $property) {
         if (in_array($property->getName(), $skipProperties)) {
             continue;
         }
         $property->setAccessible(true);
         $value = $property->getValue($settings);
         if ($value instanceof SettingsContainerInterface) {
             $children[$property->getName()] = $value;
             continue;
         }
         $input = array('name' => $property->getName(), 'options' => array('label' => $property->getName()));
         if (is_bool($value)) {
             $input['type'] = 'Checkbox';
             $input['attributes']['checked'] = $value;
         } else {
             $input['attributes']['value'] = $value;
         }
         $this->add($input);
     }
     foreach ($children as $name => $child) {
         $objectClass = ltrim(get_class($settings), '\\');
         $moduleName = substr($objectClass, 0, strpos($objectClass, '\\'));
         $fieldsetName = $moduleName . '/' . ucfirst($name) . 'SettingsFieldset';
         if ($this->forms->has($fieldsetName)) {
             $fieldset = $this->forms->get($fieldsetName);
             if (!$fieldset->getHydrator() instanceof SettingsEntityHydrator) {
                 $fieldset->setHydrator($this->getHydrator());
             }
         } else {
             $fieldset = new self();
             $label = preg_replace('~([A-Z])~', ' $1', $name);
             $fieldset->setLabel(ucfirst($label));
         }
         $fieldset->setName($name)->setObject($child);
         $this->add($fieldset);
     }
     $this->isBuild = true;
 }
Example #4
0
 /**
  * @param array $data
  * @return EnumValue
  */
 public static function createFromArray(array $data)
 {
     $instance = new self();
     if (isset($data['id'])) {
         $instance->setId($data['id']);
     }
     if (isset($data['label'])) {
         $instance->setLabel($data['label']);
     }
     if (isset($data['is_default'])) {
         $instance->setIsDefault($data['is_default']);
     }
     if (isset($data['priority'])) {
         $instance->setPriority($data['priority']);
     }
     return $instance;
 }
 /**
  * {@inheritdoc}
  */
 public static function fromArray(array $values)
 {
     $message = new self();
     $values = array_merge(['name' => null, 'number' => null, 'label' => null, 'type' => null, 'type_name' => null, 'extendee' => null, 'default_value' => null, 'oneof_index' => null, 'json_name' => null, 'options' => null], $values);
     $message->setName($values['name']);
     $message->setNumber($values['number']);
     $message->setLabel($values['label']);
     $message->setType($values['type']);
     $message->setTypeName($values['type_name']);
     $message->setExtendee($values['extendee']);
     $message->setDefaultValue($values['default_value']);
     $message->setOneofIndex($values['oneof_index']);
     $message->setJsonName($values['json_name']);
     $message->setOptions($values['options']);
     return $message;
 }
Example #6
0
    public static function fromName($tagName)
    {
        switch ($tagName) {
            case 'sheetsave':
                $label = tra('Save Sheet');
                $iconname = 'floppy';
                $syntax = '
					$("#saveState").hide();
					$.sheet.saveSheet($.sheet.tikiSheet, function() {
						$.sheet.manageState($.sheet.tikiSheet, true);
					});';
                break;
            case 'addrow':
                $label = tra('Add row after selection or to the end if no selection');
                $icon = tra('img/icons/sheet_row_add.png');
                $syntax = 'sheetInstance.controlFactory.addRow();';
                // add row after end to workaround bug in jquery.sheet.js 1.0.2
                break;
                // TODO fix properly for 5.1
            // TODO fix properly for 5.1
            case 'addrowmulti':
                $label = tra('Add multiple rows after selection or to the end if no selection');
                $icon = tra('img/icons/sheet_row_add_multi.png');
                $syntax = 'sheetInstance.controlFactory.addRowMulti();';
                break;
            case 'addrowbefore':
                $label = tra('Add row before selection or to end if no selection');
                $icon = tra('img/icons/sheet_row_add.png');
                $syntax = 'sheetInstance.controlFactory.addRow(null, true);';
                // add row after end to workaround bug in jquery.sheet.js 1.0.2
                break;
            case 'deleterow':
                $label = tra('Delete selected row');
                $icon = tra('img/icons/sheet_row_delete.png');
                $syntax = 'sheetInstance.deleteRow();';
                break;
            case 'addcolumn':
                $label = tra('Add column after selection or to the end if no selection');
                $icon = tra('img/icons/sheet_col_add.png');
                $syntax = 'sheetInstance.controlFactory.addColumn();';
                // add col before current or at end if none selected
                break;
            case 'deletecolumn':
                $label = tra('Delete selected column');
                $icon = tra('img/icons/sheet_col_delete.png');
                $syntax = 'sheetInstance.deleteColumn();';
                break;
            case 'addcolumnmulti':
                $label = tra('Add multiple columns after selection or to the end if no selection');
                $icon = tra('img/icons/sheet_col_add_multi.png');
                $syntax = 'sheetInstance.controlFactory.addColumnMulti();';
                break;
            case 'addcolumnbefore':
                $label = tra('Add column before selection or to the end if no selection');
                $icon = tra('img/icons/sheet_col_add.png');
                $syntax = 'sheetInstance.controlFactory.addColumn(null, true);';
                // add col before current or at end if none selected
                break;
            case 'sheetgetrange':
                $label = tra('Get Cell Range');
                $icon = tra('img/icons/sheet_get_range.png');
                $syntax = 'sheetInstance.getTdRange(null, sheetInstance.obj.formula().val()); return false;';
                break;
            case 'sheetfind':
                $label = tra('Find');
                $iconname = 'search';
                $syntax = 'sheetInstance.cellFind();';
                break;
            case 'sheetrefresh':
                $label = tra('Refresh calculations');
                $iconname = 'refresh';
                $syntax = 'sheetInstance.calc();';
                break;
            case 'sheetclose':
                $label = tra('Finish editing');
                $iconname = 'delete';
                $syntax = '$.sheet.manageState(sheetInstance.obj.parent(), true);';
                // temporary workaround TODO properly
                break;
            case 'bold':
                $label = tra('Bold');
                $iconname = 'bold';
                $wysiwyg = 'Bold';
                $syntax = 'sheetInstance.cellStyleToggle("styleBold");';
                break;
            case 'italic':
                $label = tra('Italic');
                $iconname = 'italic';
                $wysiwyg = 'Italic';
                $syntax = 'sheetInstance.cellStyleToggle("styleItalics");';
                break;
            case 'underline':
                $label = tra('Underline');
                $iconname = 'underline';
                $wysiwyg = 'Underline';
                $syntax = 'sheetInstance.cellStyleToggle("styleUnderline");';
                break;
            case 'strike':
                $label = tra('Strikethrough');
                $iconname = 'strikethrough';
                $wysiwyg = 'Strike';
                $syntax = 'sheetInstance.cellStyleToggle("styleLineThrough");';
                break;
            case 'center':
                $label = tra('Align Center');
                $iconname = 'align-center';
                $syntax = 'sheetInstance.cellStyleToggle("styleCenter");';
                break;
            default:
                return;
        }
        $tag = new self();
        $tag->setLabel($label)->setSyntax($syntax)->setType('Sheet');
        if (!empty($iconname)) {
            $tag->setIconName(!empty($iconname) ? $iconname : 'help');
        }
        if (!empty($icon)) {
            $tag->setIcon(!empty($icon) ? $icon : 'img/icons/shading.png');
        }
        return $tag;
    }
Example #7
0
	public static function fromName( $tagName ) // {{{
	{
		switch( $tagName ) {
			case 'sheetsave':
				$label = tra('Save Sheet');
				$icon = tra('img/icons/disk.png');
				$syntax = '
					$("#saveState").hide();
					$.sheet.saveSheet($.sheet.tikiSheet, function() {
						$.sheet.manageState($.sheet.tikiSheet, true);
					});';
      	break;
			case 'addrow':
				$label = tra('Add Row After Selection Or To End If No Selection');
				$icon = tra('img/icons/sheet_row_add.png');
				$syntax = 'sheetInstance.controlFactory.addRow();';	// add row after end to workaround bug in jquery.sheet.js 1.0.2
	      break;														// TODO fix properly for 5.1
			case 'addrowmulti':
				$label = tra('Add Multiple Rows After Selection Or To End If No Selection');
				$icon = tra('img/icons/sheet_row_add_multi.png');
				$syntax = 'sheetInstance.controlFactory.addRowMulti();';
	      break;
			case 'addrowbefore':
				$label = tra('Add Row Before Selection Or To End If No Selection');
				$icon = tra('img/icons/sheet_row_add.png');
				$syntax = 'sheetInstance.controlFactory.addRow(null, true);';	// add row after end to workaround bug in jquery.sheet.js 1.0.2
	      break;	
			case 'deleterow':
				$label = tra('Delete Selected Row');
				$icon = tra('img/icons/sheet_row_delete.png');
				$syntax = 'sheetInstance.deleteRow();';
	      break;
			case 'addcolumn':
				$label = tra('Add Column After Selection Or To End If No Selection');
				$icon = tra('img/icons/sheet_col_add.png');
				$syntax = 'sheetInstance.controlFactory.addColumn();';	// add col before current or at end if none selected
	      break;
			case 'deletecolumn':
				$label = tra('Delete Selected Column');
				$icon = tra('img/icons/sheet_col_delete.png');
				$syntax = 'sheetInstance.deleteColumn();';
	      break;
			case 'addcolumnmulti':
				$label = tra('Add Multiple Columns After Selection Or To End If No Selection');
				$icon = tra('img/icons/sheet_col_add_multi.png');
				$syntax = 'sheetInstance.controlFactory.addColumnMulti();';
	      break;
			case 'addcolumnbefore':
				$label = tra('Add Column Before Selection Or To End If No Selection');
				$icon = tra('img/icons/sheet_col_add.png');
				$syntax = 'sheetInstance.controlFactory.addColumn(null, true);';	// add col before current or at end if none selected
	      break;
			case 'sheetgetrange':
				$label = tra('Get Cell Range');
				$icon = tra('img/icons/sheet_get_range.png');
				$syntax = 'sheetInstance.getTdRange(null, sheetInstance.obj.formula().val()); return false;';
	      break;
			case 'sheetfind':
				$label = tra('Find');
				$icon = tra('img/icons/find.png');
				$syntax = 'sheetInstance.cellFind();';
	      break;
			case 'sheetrefresh':
				$label = tra('Refresh Calculations');
				$icon = tra('img/icons/arrow_refresh.png');
				$syntax = 'sheetInstance.calc();';
	      break;
			case 'sheetclose':
				$label = tra('Finish Editing');
				$icon = tra('img/icons/close.png');
				$syntax = '$.sheet.manageState(sheetInstance.obj.parent(), true);';	// temporary workaround TODO properly
	      break;
			case 'bold':
				$label = tra('Bold');
				$icon = tra('img/icons/text_bold.png');
				$wysiwyg = 'Bold';
				$syntax = 'sheetInstance.cellStyleToggle("styleBold");';
	      break;
			case 'italic':
				$label = tra('Italic');
				$icon = tra('img/icons/text_italic.png');
				$wysiwyg = 'Italic';
				$syntax = 'sheetInstance.cellStyleToggle("styleItalics");';
	      break;
			case 'underline':
				$label = tra('Underline');
				$icon = tra('img/icons/text_underline.png');
				$wysiwyg = 'Underline';
				$syntax = 'sheetInstance.cellStyleToggle("styleUnderline");';
	      break;
			case 'strike':
				$label = tra('Strikethrough');
				$icon = tra('img/icons/text_strikethrough.png');
				$wysiwyg = 'Strike';
				$syntax = 'sheetInstance.cellStyleToggle("styleLineThrough");';
	      break;
			case 'center':
				$label = tra('Align Center');
				$icon = tra('img/icons/text_align_center.png');
				$syntax = 'sheetInstance.cellStyleToggle("styleCenter");';
	      break;
			default:
				return;
		}

		$tag = new self;
		$tag->setLabel($label)
			->setIcon(!empty($icon) ? $icon : 'img/icons/shading.png')
			->setSyntax($syntax)
			->setType('Sheet');
		
		return $tag;
	} // }}}
 /**
  * Creates a new Deployment from parsed response body.
  * 
  * @param array $parsed The parsed response body in array representation.
  * 
  * @return Deployment
  */
 public static function create($parsed)
 {
     $result = new self();
     $name = Utilities::tryGetValue($parsed, Resources::XTAG_NAME);
     $label = Utilities::tryGetValue($parsed, Resources::XTAG_LABEL);
     $url = Utilities::tryGetValue($parsed, Resources::XTAG_URL);
     $locked = Utilities::tryGetValue($parsed, Resources::XTAG_LOCKED);
     $rollbackAllowed = Utilities::tryGetValue($parsed, Resources::XTAG_ROLLBACK_ALLOWED);
     $sdkVersion = Utilities::tryGetValue($parsed, Resources::XTAG_SDK_VERSION);
     $inputEndpointList = Utilities::tryGetKeysChainValue($parsed, Resources::XTAG_INPUT_ENDPOINT_LIST, Resources::XTAG_INPUT_ENDPOINT);
     $roleList = Utilities::tryGetKeysChainValue($parsed, Resources::XTAG_ROLE_LIST, Resources::XTAG_ROLE);
     $roleInstanceList = Utilities::tryGetKeysChainValue($parsed, Resources::XTAG_ROLE_INSTANCE_LIST, Resources::XTAG_ROLE_INSTANCE);
     $status = Utilities::tryGetValue($parsed, Resources::XTAG_STATUS);
     $slot = Utilities::tryGetValue($parsed, Resources::XTAG_DEPLOYMENT_SLOT);
     $privateId = Utilities::tryGetValue($parsed, Resources::XTAG_PRIVATE_ID);
     $configuration = Utilities::tryGetValue($parsed, Resources::XTAG_CONFIGURATION);
     $upgradeDomainCount = Utilities::tryGetValue($parsed, Resources::XTAG_UPGRADE_DOMAIN_COUNT);
     $upgradeStatus = Utilities::tryGetValue($parsed, Resources::XTAG_UPGRADE_STATUS);
     $result->setConfiguration($configuration);
     $result->setLabel($label);
     $result->setLocked(Utilities::toBoolean($locked));
     $result->setName($name);
     $result->setPrivateId($privateId);
     $result->setRollbackAllowed(Utilities::toBoolean($rollbackAllowed));
     $result->setSdkVersion($sdkVersion);
     $result->setSlot($slot);
     $result->setStatus($status);
     $result->setUpgradeDomainCount(intval($upgradeDomainCount));
     $result->setUpgradeStatus(UpgradeStatus::create($upgradeStatus));
     $result->setUrl($url);
     $result->setRoleInstanceList(Utilities::createInstanceList(Utilities::getArray($roleInstanceList), 'WindowsAzure\\ServiceManagement\\Models\\RoleInstance'));
     $result->setRoleList(Utilities::createInstanceList(Utilities::getArray($roleList), 'WindowsAzure\\ServiceManagement\\Models\\Role'));
     $result->setInputEndpointList(Utilities::createInstanceList(Utilities::getArray($inputEndpointList), 'WindowsAzure\\ServiceManagement\\Models\\InputEndpoint'));
     return $result;
 }
 /**
  * Creates a broker properties instance with specified JSON message.  
  *
  * @param string $brokerPropertiesJson A JSON message representing a 
  *                                     broker properties.
  * 
  * @return none
  */
 public static function create($brokerPropertiesJson)
 {
     Validate::isString($brokerPropertiesJson, 'brokerPropertiesJson');
     $brokerProperties = new self();
     $brokerPropertiesArray = (array) json_decode($brokerPropertiesJson);
     if (array_key_exists('CorrelationId', $brokerPropertiesArray)) {
         $brokerProperties->setCorrelationId($brokerPropertiesArray['CorrelationId']);
     }
     if (array_key_exists('SessionId', $brokerPropertiesArray)) {
         $brokerProperties->setSessionId($brokerPropertiesArray['SessionId']);
     }
     if (array_key_exists('DeliveryCount', $brokerPropertiesArray)) {
         $brokerProperties->setDeliveryCount($brokerPropertiesArray['DeliveryCount']);
     }
     if (array_key_exists('LockedUntilUtc', $brokerPropertiesArray)) {
         $brokerProperties->setLockedUntilUtc(\DateTime::createFromFormat(Resources::AZURE_DATE_FORMAT, $brokerPropertiesArray['LockedUntilUtc']));
     }
     if (array_key_exists('LockToken', $brokerPropertiesArray)) {
         $brokerProperties->setLockToken($brokerPropertiesArray['LockToken']);
     }
     if (array_key_exists('MessageId', $brokerPropertiesArray)) {
         $brokerProperties->setMessageId($brokerPropertiesArray['MessageId']);
     }
     if (array_key_exists('Label', $brokerPropertiesArray)) {
         $brokerProperties->setLabel($brokerPropertiesArray['Label']);
     }
     if (array_key_exists('ReplyTo', $brokerPropertiesArray)) {
         $brokerProperties->setReplyTo($brokerPropertiesArray['ReplyTo']);
     }
     if (array_key_exists('SequenceNumber', $brokerPropertiesArray)) {
         $brokerProperties->setSequenceNumber($brokerPropertiesArray['SequenceNumber']);
     }
     if (array_key_exists('TimeToLive', $brokerPropertiesArray)) {
         $brokerProperties->setTimeToLive(doubleval($brokerPropertiesArray['TimeToLive']));
     }
     if (array_key_exists('To', $brokerPropertiesArray)) {
         $brokerProperties->setTo($brokerPropertiesArray['To']);
     }
     if (array_key_exists('ScheduledEnqueueTimeUtc', $brokerPropertiesArray)) {
         $brokerProperties->setScheduledEnqueueTimeUtc(\DateTime::createFromFormat(Resources::AZURE_DATE_FORMAT, $brokerPropertiesArray['ScheduledEnqueueTimeUtc']));
     }
     if (array_key_exists('ReplyToSessionId', $brokerPropertiesArray)) {
         $brokerProperties->setReplyToSessionId($brokerPropertiesArray['ReplyToSessionId']);
     }
     if (array_key_exists('MessageLocation', $brokerPropertiesArray)) {
         $brokerProperties->setMessageLocation($brokerPropertiesArray['MessageLocation']);
     }
     if (array_key_exists('LockLocation', $brokerPropertiesArray)) {
         $brokerProperties->setLockLocation($brokerPropertiesArray['LockLocation']);
     }
     return $brokerProperties;
 }
 /**
  * This class method is used to construct a ResourceDescriptor object by providing the XML for that object.
  *
  * @param string $xml - XML String defining ResourceDescriptor
  * @return ResourceDescriptor
  */
 public static function createFromXML($xml)
 {
     $sxi = new \SimpleXMLIterator($xml);
     $temp = new self((string) $sxi->attributes()->name, (string) $sxi->attributes()->wsType, (string) $sxi->attributes()->uriString, (string) $sxi->attributes()->isNew);
     $desc = !empty($sxi->description) ? (string) $sxi->description : null;
     $label = !empty($sxi->label) ? (string) $sxi->label : null;
     $date = !empty($sxi->creationDate) ? (string) $sxi->creationDate : null;
     $temp->setLabel($label);
     $temp->setDescription($desc);
     $temp->setCreationDate($date);
     foreach ($sxi->resourceDescriptor as $nestRd) {
         $temp->children[] = ResourceDescriptor::createFromXML($nestRd->asXML());
     }
     foreach ($sxi->resourceProperty as $prop) {
         $temp->properties[] = ResourceProperty::createFromXML($prop->asXML());
     }
     return $temp;
 }
Example #11
0
 /**
  * Create a delete action
  *
  * @return \Table\Action\Delete
  */
 static function create()
 {
     $obj = new self('delete', \Tk\Request::getInstance()->getRequestUri(), 'fa fa-times');
     $obj->setLabel('Delete Selected');
     return $obj;
 }