示例#1
0
文件: Citation.php 项目: geissler/csl
 /**
  * Create the objects for the additional options.
  *
  * @param \SimpleXMLElement $xml
  */
 public function __construct(\SimpleXMLElement $xml)
 {
     $this->disambiguation = new Disambiguation();
     $this->renderFromIds = new RenderFromIds();
     $this->citeGrouping = new CiteGrouping();
     $this->citeCollapsing = new CiteCollapsing();
     // set standard values for citationItems-specific options
     Container::getContext()->addCitation('disambiguateAddNames', false);
     Container::getContext()->addCitation('disambiguateAddGivenname', false);
     Container::getContext()->addCitation('givennameDisambiguationRule', 'by-cite');
     Container::getContext()->addCitation('disambiguateAddYearSuffix', false);
     Container::getContext()->addCitation('nearNoteDistance', 5);
     foreach ($xml->attributes() as $name => $value) {
         switch ($name) {
             case 'disambiguate-add-names':
                 Container::getContext()->addCitation('disambiguateAddNames', isBoolean($value));
                 break;
             case 'disambiguate-add-givenname':
                 Container::getContext()->addCitation('disambiguateAddGivenname', isBoolean($value));
                 break;
             case 'givenname-disambiguation-rule':
                 Container::getContext()->addCitation('givennameDisambiguationRule', (string) $value);
                 break;
             case 'disambiguate-add-year-suffix':
                 Container::getContext()->addCitation('disambiguateAddYearSuffix', isBoolean($value));
                 break;
             case 'cite-group-delimiter':
                 $this->citeGrouping->setCiteGroupDelimiter((string) $value);
                 $this->citeGrouping->setActive(true);
                 break;
             case 'collapse':
                 $this->citeCollapsing->setCollapse((string) $value);
                 $this->citeGrouping->setActive(true);
                 break;
             case 'year-suffix-delimiter':
                 $this->citeCollapsing->setYearSuffixDelimiter((string) $value);
                 break;
             case 'after-collapse-delimiter':
                 $this->citeCollapsing->setAfterCollapseDelimiter((string) $value);
                 break;
             case 'near-note-distance':
                 Container::getContext()->addCitation('nearNoteDistance', (int) $value);
                 break;
         }
     }
 }
示例#2
0
文件: Macro.php 项目: geissler/csl
 /**
  * Parses the macro key configuration.
  *
  * @param \SimpleXMLElement $xml
  */
 public function __construct(\SimpleXMLElement $xml)
 {
     $this->nameModifications = array();
     foreach ($xml->attributes() as $name => $value) {
         switch ($name) {
             case 'macro':
                 $this->macro = new Call($value);
                 break;
             case 'names-min':
                 $this->nameModifications[] = 'et-al-min="' . (int) $value . '"';
                 break;
             case 'names-use-first':
                 $this->nameModifications[] = 'et-al-use-first="' . (int) $value . '"';
                 break;
             case 'names-use-last':
                 $this->nameModifications[] = 'et-al-use-last="' . isBoolean((string) $value) . '"';
                 break;
         }
     }
 }
示例#3
0
 /**
  * Configure the whitespace options.
  *
  * @param \SimpleXMLElement $xml
  */
 public function __construct(\SimpleXMLElement $xml)
 {
     $this->hangingIndent = false;
     $this->lineSpacing = 1;
     $this->entrySpacing = 1;
     $this->secondFieldAlign = '';
     foreach ($xml->attributes() as $name => $value) {
         switch ($name) {
             case 'hanging-indent':
                 $this->hangingIndent = isBoolean($value);
                 break;
             case 'second-field-align':
                 $this->secondFieldAlign = (string) $value;
                 break;
             case 'line-spacing':
                 $this->lineSpacing = (int) $value;
                 break;
             case 'entry-spacing':
                 $this->entrySpacing = (int) $value;
                 break;
         }
     }
 }
示例#4
0
    if (filter_var($Hex, FILTER_VALIDATE_INT, array("flags" => FILTER_FLAG_ALLOW_HEX)) === FALSE) {
        return false;
    } else {
        return true;
    }
}
$octal = 0666;
var_dump(isOctal($octal));
$hex = "0xff";
var_dump(isHexidecimal($hex));
echo '<br />';
function isBoolean($boolean)
{
    return filter_var($boolean, FILTER_VALIDATE_BOOLEAN);
}
var_dump(isBoolean(1));
echo '<br />';
function isBooleanInArray($array)
{
    return filter_var($array, FILTER_VALIDATE_BOOLEAN, FILTER_REQUIRE_ARRAY);
}
$array = array(0, 1, 2, 3, 4, array(0, 1, 2, 3, 4));
var_dump(isBooleanInArray($array));
echo '<br />';
function isFloat($var)
{
    return filter_var($var, FILTER_VALIDATE_FLOAT) ? true : false;
}
var_dump(isFloat('123.45678'));
echo '<br />';
function isFloatInArray($array)
示例#5
0
 /**
  * SOAP::Value::_getSoapType
  *
  * convert php type to soap type
  * @param    string  value
  * @param    string  type  - presumed php type
  *
  * @return   string  type  - soap type
  * @access   private
  */
 function _getSoapType(&$value, &$type)
 {
     $doconvert = FALSE;
     if (0 && $this->wsdl) {
         # see if it's a complex type so we can deal properly with SOAPENC:arrayType
         if (!$type && $this->name) {
             # XXX TODO:
             # look up the name in the wsdl and validate the type
             $this->debug("SOAP_VALUE no type for {$this->name}!");
         } else {
             if ($type) {
                 # XXX TODO:
                 # this code currently handles only one way of encoding array types in wsdl
                 # need to do a generalized function to figure out complex types
                 if (array_key_exists($type, $this->wsdl->complexTypes)) {
                     if ($this->arrayType = $this->wsdl->complexTypes[$type]['arrayType']) {
                         $type = 'Array';
                     } else {
                         if ($this->wsdl->complexTypes[$type]['order'] == 'sequence' && array_key_exists('elements', $this->wsdl->complexTypes[$type])) {
                             reset($this->wsdl->complexTypes[$type]['elements']);
                             # assume an array
                             if (count($this->wsdl->complexTypes[$type]['elements']) == 1) {
                                 $arg = current($this->wsdl->complexTypes[$type]['elements']);
                                 $this->arrayType = $arg['type'];
                                 $type = 'Array';
                             } else {
                                 foreach ($this->wsdl->complexTypes[$type]['elements'] as $element) {
                                     if ($element['name'] == $type) {
                                         $this->arrayType = $element['type'];
                                         $type = $element['type'];
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!$type || !$this->verifyType($type)) {
         if ($type && $this->wsdl && array_key_exists($type, $this->wsdl->complexTypes)) {
             # do nothing, this preserves our complex types
         } else {
             if (is_object($value)) {
                 # allows for creating special classes to handle soap types
                 $type = get_class($value);
                 # this may return a different type that we process below
                 $value = $value->toSOAP();
             } elseif (isArray($value)) {
                 $type = isHash($value) ? 'Struct' : 'Array';
             } elseif (isInt($value)) {
                 $type = 'int';
             } elseif (isFloat($value)) {
                 $type = 'float';
             } elseif (SOAP_Type_hexBinary::is_hexbin($value)) {
                 $type = 'hexBinary';
             } elseif (isBase64($value)) {
                 $type = 'base64Binary';
             } elseif (isBoolean($value)) {
                 $type = 'boolean';
             } else {
                 $type = gettype($value);
                 # php defaults a lot of stuff to string, if we have no
                 # idea what the type realy is, we have to try to figure it out
                 # this is the best we can do if the user did not use the SOAP_Value class
                 if ($type == 'string') {
                     $doconvert = TRUE;
                 }
             }
         }
     }
     # we have the type, handle any value munging we need
     if ($doconvert) {
         $dt = new SOAP_Type_dateTime($value);
         if ($dt->toUnixtime() != -1) {
             $type = 'dateTime';
             $value = $dt->toSOAP();
         }
     } else {
         if ($type == 'dateTime') {
             # encode a dateTime to ISOE
             $dt = new SOAP_Type_dateTime($value);
             $value = $dt->toSOAP();
         } else {
             // php type name mangle
             if ($type == 'integer') {
                 $type = 'int';
             } else {
                 if ($type == 'boolean') {
                     if ($value != 0 && $value != '0' || strcasecmp($value, 'true') == 0) {
                         $value = 'true';
                     } else {
                         $value = 'false';
                     }
                 }
             }
         }
     }
     return $type;
 }
示例#6
0
文件: Name.php 项目: geissler/csl
 /**
  * Modifies the configuration of the name by parsing a new \SimpleXMLElement.
  *
  * @param \SimpleXMLElement $xml
  * @return \Geissler\CSL\Interfaces\Modifiable|\Geissler\CSL\Names\Name
  */
 public function modify(\SimpleXMLElement $xml)
 {
     foreach ($xml->attributes() as $name => $value) {
         switch ($name) {
             case 'and':
                 $this->and = (string) $value;
                 break;
             case 'delimiter':
                 $this->delimiter = (string) $value;
                 break;
             case 'delimiter-precedes-et-al':
                 $this->delimiterPrecedesEtAl = (string) $value;
                 break;
             case 'delimiter-precedes-last':
                 $this->delimiterPrecedesLast = (string) $value;
                 break;
             case 'et-al-min':
                 $this->etAlMin = (int) $value;
                 break;
             case 'et-al-use-first':
                 $this->etAlUseFirst = (int) $value;
                 break;
             case 'et-al-subsequent-min':
                 $this->etAlSubsequentMin = (int) $value;
                 break;
             case 'et-al-subsequent-use-first':
                 $this->etAlSubsequentUseFirst = (string) $value;
                 break;
             case 'et-al-use-last':
                 $this->etAlUseLast = isBoolean($value);
                 break;
             case 'form':
                 $this->form = (string) $value;
                 break;
             case 'initialize':
                 $this->initialize = isBoolean($value);
                 break;
             case 'initialize-with':
                 $this->initializeWith = (string) $value;
                 break;
             case 'name-as-sort-order':
                 $this->nameAsSortOrder = (string) $value;
                 break;
             case 'sort-separator':
                 $this->sortSeparator = (string) $value;
                 break;
         }
     }
     $this->backup();
     return $this;
 }
示例#7
0
文件: Options.php 项目: geissler/csl
 /**
  * Parses the global and inheritable name options.
  *
  * @param string $type context type (style, citation or bibliography)
  * @param \SimpleXMLElement $xml
  * @return \Geissler\CSL\Context\Options
  */
 public function set($type, \SimpleXMLElement $xml)
 {
     switch ($type) {
         case 'style':
             $method = 'addStyle';
             break;
         case 'citation':
             $method = 'addCitation';
             break;
         case 'bibliography':
             $method = 'addBibliography';
             break;
     }
     foreach ($xml->attributes() as $name => $value) {
         switch ($name) {
             // global options
             case 'initialize-with-hyphen':
                 Container::getContext()->{$method}('initializeWithHyphen', isBoolean($value));
                 break;
             case 'page-range-format':
                 switch ((string) $value) {
                     case 'chicago':
                         Container::getContext()->{$method}('pageRangeFormat', new Chicago());
                         break;
                     case 'expanded':
                         Container::getContext()->{$method}('pageRangeFormat', new Expanded());
                         break;
                     case 'minimal':
                         Container::getContext()->{$method}('pageRangeFormat', new Minimal());
                         break;
                     case 'minimal-two':
                         Container::getContext()->{$method}('pageRangeFormat', new MinimalTwo());
                         break;
                 }
                 break;
             case 'demote-non-dropping-particle':
                 Container::getContext()->{$method}('demoteNonDroppingParticle', (string) $value);
                 break;
                 // Inheritable Name Options
             // Inheritable Name Options
             case 'and':
                 Container::getContext()->{$method}('and', (string) $value);
                 break;
             case 'delimiter-precedes-et-al':
                 Container::getContext()->{$method}('delimiterPrecedesEtAl', (string) $value);
                 break;
             case 'delimiter-precedes-last':
                 Container::getContext()->{$method}('delimiterPrecedesLast', (string) $value);
                 break;
             case 'et-al-min':
                 Container::getContext()->{$method}('etAlMin', (string) $value);
                 break;
             case 'et-al-use-first':
                 Container::getContext()->{$method}('etAlUseFirst', (string) $value);
                 break;
             case 'et-al-subsequent-min':
                 Container::getRendered()->setUseDifferentCitations(true);
                 Container::getContext()->{$method}('etAlSubsequentMin', (string) $value);
                 break;
             case 'et-al-subsequent-use-first':
                 Container::getRendered()->setUseDifferentCitations(true);
                 Container::getContext()->{$method}('etAlSubsequentUseFirst', (string) $value);
                 break;
             case 'et-al-use-last':
                 Container::getContext()->{$method}('etAlUseLast', isBoolean((string) $value));
                 break;
             case 'initialize':
                 Container::getContext()->{$method}('initialize', (string) $value);
                 break;
             case 'initialize-with':
                 Container::getContext()->{$method}('initializeWith', (string) $value);
                 break;
             case 'name-as-sort-order':
                 Container::getContext()->{$method}('nameAsSortOrder', (string) $value);
                 break;
             case 'sort-separator':
                 Container::getContext()->{$method}('sortSeparator', (string) $value);
                 break;
             case 'name-form':
                 Container::getContext()->{$method}('form', (string) $value);
                 break;
             case 'name-delimiter':
                 Container::getContext()->{$method}('delimiter', (string) $value);
                 break;
         }
     }
     return $this;
 }
示例#8
0
文件: Date.php 项目: geissler/csl
 /**
  * Modifies the configuration of the name by parsing a new \SimpleXMLElement.
  *
  * @param \SimpleXMLElement $xml
  * @return \Geissler\CSL\Interfaces\Modifiable|\Geissler\CSL\Names\Name
  */
 public function modify(\SimpleXMLElement $xml)
 {
     foreach ($xml->attributes() as $name => $value) {
         switch ($name) {
             case 'variable':
                 $this->variable = (string) $value;
                 break;
             case 'form':
                 $this->form = (string) $value;
                 break;
             case 'add-year-suffix':
                 $this->addYearSuffix = isBoolean($value);
                 break;
             case 'delimiter':
                 $this->delimiter = (string) $value;
                 break;
             case 'date-parts':
                 if ($this->form !== '') {
                     $dateParts = explode('-', (string) $value);
                     $localeDates = Container::getLocale()->getDate($this->form);
                     foreach ($localeDates as $localeDate) {
                         if (in_array($localeDate['name'], $dateParts) == true) {
                             $this->dateParts[] = array('name' => $localeDate['name'], 'datepart' => new DatePart(new \SimpleXMLElement($localeDate['xml']), array('form' => $this->form)));
                         }
                     }
                 }
                 break;
         }
     }
 }