예제 #1
0
 /**
  * Returns the package meta data object of this package.
  *
  * @return MetaData
  */
 public function getPackageMetaData()
 {
     if ($this->packageMetaData === NULL) {
         $this->packageMetaData = new MetaData($this->getPackageKey());
         $this->packageMetaData->setDescription($this->getValueFromComposerManifest('description'));
         $this->packageMetaData->setVersion($this->getValueFromComposerManifest('version'));
         $requirements = $this->getValueFromComposerManifest('require');
         if ($requirements !== NULL) {
             foreach ($requirements as $requirement => $version) {
                 if ($this->packageRequirementIsComposerPackage($requirement) === FALSE) {
                     // Skip non-package requirements
                     continue;
                 }
                 $packageKey = $this->packageManager->getPackageKeyFromComposerName($requirement);
                 $constraint = new MetaData\PackageConstraint(MetaData::CONSTRAINT_TYPE_DEPENDS, $packageKey);
                 $this->packageMetaData->addConstraint($constraint);
             }
         }
         $suggestions = $this->getValueFromComposerManifest('suggest');
         if ($suggestions !== NULL) {
             foreach ($suggestions as $suggestion => $version) {
                 if ($this->packageRequirementIsComposerPackage($suggestion) === FALSE) {
                     // Skip non-package requirements
                     continue;
                 }
                 $packageKey = $this->packageManager->getPackageKeyFromComposerName($suggestion);
                 $constraint = new MetaData\PackageConstraint(MetaData::CONSTRAINT_TYPE_SUGGESTS, $packageKey);
                 $this->packageMetaData->addConstraint($constraint);
             }
         }
     }
     return $this->packageMetaData;
 }
 public static function getInstance()
 {
     if (!isset(MetaData::$instance)) {
         MetaData::$instance = new MetaData();
     }
     return MetaData::$instance;
 }
 function import()
 {
     $count = 0;
     global $wpdb;
     $values = $wpdb->get_results("SELECT * FROM {$wpdb->postmeta} WHERE meta_key='_aioseop_keywords'");
     if ($values) {
         foreach ($values as $meta) {
             MetaData::add_tags($meta->post_id, stripslashes($meta->meta_value));
         }
         $count += count($values);
     }
     $values = $wpdb->get_results("SELECT * FROM {$wpdb->postmeta} WHERE meta_key='_aioseop_title'");
     if ($values) {
         foreach ($values as $meta) {
             MetaData::add_page_title($meta->post_id, stripslashes($meta->meta_value));
         }
         $count += count($values);
     }
     $values = $wpdb->get_results("SELECT * FROM {$wpdb->postmeta} WHERE meta_key='_aioseop_description'");
     if ($values) {
         foreach ($values as $meta) {
             MetaData::add_description($meta->post_id, stripslashes($meta->meta_value));
         }
         $count += count($values);
     }
     return $count;
 }
 function __construct(array &$params)
 {
     $this->metaData = MetaData::getInstance();
     $this->domImplementation = new DOMImplementation();
     $this->appNameObjectFetcherMap = array();
     $this->objectPublisher = new ObjectPublisher();
     $this->objectModifier = new ObjectModifier($this->objectPublisher);
     $this->params = $params;
     $this->sessionId = RestUrlParams::extractValue($this->params, RestUrlParams::SESSION_ID);
 }
 /**
  * It should set the parent document.
  */
 public function testSetParentDocument()
 {
     $this->persistEvent->getDocument()->willReturn($this->document->reveal());
     $this->persistEvent->getLocale()->willReturn('fr');
     $this->metadataFactory->getMetadataForClass(get_class($this->document->reveal()))->willReturn($this->metadata->reveal());
     $this->metadata->getAlias()->willReturn('test');
     $this->nodeManager->createPath('/')->willReturn($this->parentNode->reveal());
     $this->persistEvent->hasParentNode()->shouldBeCalled();
     $this->persistEvent->setParentNode($this->parentNode->reveal())->shouldBeCalled();
     $this->documentManager->find('/test', 'fr')->willReturn($this->parentDocument);
     $this->subscriber->handlePersist($this->persistEvent->reveal());
 }
 function do_storeRelationship()
 {
     // handle the store, and DON'T give a 500 ;)  does not act on the information.
     global $default;
     $default->log->error(http_build_query($_REQUEST));
     $iFieldsetId = KTUtil::arrayGet($_REQUEST, 'fieldset_id');
     $parent_field = KTUtil::arrayGet($_REQUEST, 'parent_field');
     $parent_lookup = KTUtil::arrayGet($_REQUEST, 'parent_lookup');
     $child_lookups = KTUtil::arrayGet($_REQUEST, 'child_lookups');
     // child lookups is a nested array. in python it would be:
     // child_lookups =
     //  {
     //     field_id:[lookup_id, lookup_id],
     //     field_id:[lookup_id, lookup_id],
     //  }
     $oFieldset =& KTFieldset::get($iFieldsetId);
     $oFieldset->setIsComplete(false);
     $oFieldset->update();
     $oParentInstance = KTMetadataUtil::getOrCreateValueInstanceForLookup($parent_lookup);
     $iBehaviourId = $oParentInstance->getBehaviourId();
     $oParentMetadata =& MetaData::get($oParentInstance->getFieldValueId());
     if (is_null($iBehaviourId)) {
         $oBehaviour =& KTFieldBehaviour::createFromArray(array('name' => 'autoinstance' . $oParentInstance->getId(), 'humanname' => 'Auto instance' . $oParentMetadata->getName(), 'fieldid' => $oParentInstance->getFieldId()));
     } else {
         $oBehaviour =& KTFieldBehaviour::get($iBehaviourId);
     }
     if (PEAR::isError($oBehaviour)) {
         var_dump($oBehaviour);
         return $oBehaviour;
     }
     $iBehaviourId = $oBehaviour->getId();
     $oParentInstance->setBehaviourId($iBehaviourId);
     $oParentInstance->update();
     $sTable = KTUtil::getTableName('field_behaviour_options');
     $aOptions = array('noid' => true);
     $aQuery = array("DELETE FROM {$sTable} WHERE behaviour_id = ?", array($iBehaviourId));
     $res = DBUtil::runQuery($aQuery);
     foreach ($child_lookups as $iFieldId => $aLookups) {
         foreach ($aLookups as $iLookupId) {
             $oValueInstance =& KTMetadataUtil::getOrCreateValueInstanceForLookup($iLookupId);
             if (PEAR::isError($oValueInstance)) {
                 var_dump($oValueInstance);
                 return $oValueInstance;
             }
             $res = DBUtil::autoInsert($sTable, array('behaviour_id' => $iBehaviourId, 'field_id' => $iFieldId, 'instance_id' => $oValueInstance->getId()), $aOptions);
             if (PEAR::isError($res)) {
                 var_dump($res);
                 return $res;
             }
         }
     }
 }
예제 #7
0
 function import()
 {
     $count = 0;
     global $wpdb;
     $values = $wpdb->get_results("SELECT * FROM {$wpdb->postmeta} WHERE meta_key='_headspace_keywords'");
     if ($values) {
         foreach ($values as $meta) {
             MetaData::add_tags($meta->post_id, $meta->meta_value);
         }
         $count += count($values);
     }
     return $count;
 }
예제 #8
0
 function import()
 {
     $count = 0;
     global $wpdb;
     $keywords = $wpdb->get_results("SELECT * FROM {$wpdb->postmeta} WHERE meta_key='title_tag'");
     if ($keywords) {
         foreach ($keywords as $keyword) {
             MetaData::add_page_title($keyword->post_id, $keyword->meta_value);
         }
         $count += count($keywords);
     }
     return $count;
 }
 function import()
 {
     $count = 0;
     global $wpdb;
     $values = $wpdb->get_results("SELECT * FROM {$wpdb->postmeta} WHERE meta_key='description'");
     if ($values) {
         foreach ($values as $value) {
             MetaData::add_description($value->post_id, $value->meta_value);
         }
         $count += count($values);
     }
     return $count;
 }
예제 #10
0
 /**
  * Do not call directly! Call {@see Entity::toArray()} instead.
  * @param IEntity
  * @param int
  * @param int
  */
 public static function toArray(IEntity $entity, $mode = self::AS_IS, $deep = 0)
 {
     if ($mode === NULL) {
         $mode = self::AS_IS;
     }
     $result = array('id' => isset($entity->id) ? $entity->id : NULL);
     $rules = MetaData::getEntityRules(get_class($entity), $entity->getModel(false));
     foreach ($rules as $name => $rule) {
         if ($name === 'id') {
             continue;
         }
         if (isset($rule['get'])) {
             $result[$name] = $entity->__get($name);
             if ($result[$name] instanceof IEntity and !($mode & self::ENTITY_AS_IS)) {
                 if ($mode & self::ENTITY_AS_ID) {
                     $result[$name] = $result[$name]->id;
                 } else {
                     if ($mode & self::ENTITY_AS_ARRAY) {
                         $result[$name] = $deep > static::$maxDeep ? NULL : EntityToArray::toArray($result[$name], $mode, $deep + 1);
                     } else {
                         throw new EntityToArrayNoModeException(array($entity, true, false));
                     }
                 }
             } else {
                 if ($result[$name] instanceof IRelationship and !($mode & self::RELATIONSHIP_AS_IS)) {
                     if ($deep > static::$maxDeep) {
                         $result[$name] = NULL;
                     } else {
                         $arr = array();
                         foreach ($result[$name] as $e) {
                             if ($mode & self::RELATIONSHIP_AS_ARRAY_OF_ID) {
                                 $arr[] = $e->id;
                             } else {
                                 if ($mode & self::RELATIONSHIP_AS_ARRAY_OF_ARRAY) {
                                     $arr[] = EntityToArray::toArray($e, $mode, $deep + 1);
                                 } else {
                                     throw new EntityToArrayNoModeException(array($entity, false, true));
                                 }
                             }
                         }
                         $result[$name] = $arr;
                     }
                 }
             }
         }
     }
     return $result;
 }
예제 #11
0
 function import()
 {
     $count = 0;
     global $wpdb;
     $values = $wpdb->get_results("SELECT {$wpdb->prefix}post2tag.post_id,{$wpdb->prefix}tags.tag FROM {$wpdb->prefix}tags,{$wpdb->prefix}post2tag WHERE {$wpdb->prefix}tags.tag_id={$wpdb->prefix}post2tag.tag_id");
     if ($values) {
         $data = array();
         foreach ($values as $value) {
             $data[$value->post_id][] = $value->tag;
         }
         foreach ($data as $postid => $values) {
             MetaData::add_tags($postid, implode(',', $values));
         }
         $count += count($values);
     }
     return $count;
 }
 function import()
 {
     $count = 0;
     global $wpdb;
     $values = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}stp_tags");
     if ($values) {
         $data = array();
         foreach ($values as $value) {
             $data[$value->post_id][] = $value->tag_name;
         }
         foreach ($data as $postid => $values) {
             MetaData::add_tags($postid, implode(',', $values));
         }
         $count += count($values);
     }
     return $count;
 }
 private function getAccountIdByNameFromDB($accountName)
 {
     $id = NULL;
     try {
         $schema = MetaData::getInstance()->getSchema($this->appName);
         $mySQLi = $schema->getMySQLi();
         $queryString = "SELECT id FROM " . DbConstants::TABLE_ACCOUNT . " WHERE name LIKE '" . $accountName . "'";
         $queryResult = $mySQLi->query($queryString);
         if (!$queryResult) {
             throw new Exception("Error fetching account ID for '{$accountName}' - {$mySQLi->error}\n<!--\n{$queryString}\n-->");
         }
         $queryData = $queryResult->fetch_assoc();
         if (isset($queryData['id'])) {
             $id = $queryData['id'];
         }
         $queryResult->close();
     } catch (Exception $e) {
         Bootstrap::logException($e);
     }
     return $id;
 }
예제 #14
0
 function import()
 {
     $count = 0;
     global $wpdb;
     $values = $wpdb->get_results("SELECT ID,post_content FROM {$wpdb->posts} WHERE post_content LIKE '%[tag]%' OR post_content LIKE '%[tags]%'");
     if ($values) {
         foreach ($values as $post) {
             $tags = '';
             if (preg_match_all('/(\\[tag\\](.*?)\\[\\/tag\\])/i', $post->post_content, $matches) > 0) {
                 $tags .= implode(',', $matches[2]);
                 $count += count($matches[2]);
             }
             if (preg_match_all('/(\\[tags\\](.*?)\\[\\/tags\\])/i', $post->post_content, $matches) > 0) {
                 $tags .= ',' . implode(',', $matches[2]);
                 $count += count($matches[2]);
             }
             $tags = $this->normalize_tags($tags);
             MetaData::add_tags($post->ID, $tags);
         }
         $count += count($keywords);
     }
     return $count;
 }
예제 #15
0
 /** @test */
 public function should_calculate_the_tax_for_basket_fixture_nine()
 {
     $basket = $this->fixtures->nine();
     $total = $this->meta->generate($basket);
     $this->assertEquals(new Money(890, new Currency('GBP')), $total);
 }
예제 #16
0
 /**
  * Given a behaviour, return an array of lookup ids (Metadata->id)
  * that are available for each of the columns/fields that this
  * behaviour's column affects.
  *
  * Return value:
  *
  * Associative array keyed by field_id, value is an array of lookup
  * ids.
  *
  * array(
  *      1 => array(1, 2, 3, 4),
  *      ...
  * );
  */
 function getNextValuesForBehaviour($oBehaviour)
 {
     $oBehaviour =& KTUtil::getObject('KTFieldBehaviour', $oBehaviour);
     $aValues = array();
     $sTable = KTUtil::getTableName('field_behaviour_options');
     $aChildFieldIds = KTMetadataUtil::getChildFieldIds($oBehaviour->getFieldId());
     foreach ($aChildFieldIds as $iFieldId) {
         $aValues[$iFieldId] = array();
     }
     $aQuery = array("SELECT field_id, instance_id FROM {$sTable} WHERE behaviour_id = ?", array($oBehaviour->getId()));
     $aRows = DBUtil::getResultArray($aQuery);
     if (PEAR::isError($aRows)) {
         return $aRows;
     }
     foreach ($aRows as $aRow) {
         $oInstance =& KTValueInstance::get($aRow['instance_id']);
         // need to wean out the disabled values.
         // now get the metadata value.
         $oMetadata = MetaData::get($oInstance->getFieldValueId());
         if (PEAR::isError($oMetadata)) {
             continue;
             // invalid link.  bugger.
         }
         if ($oMetadata->getDisabled()) {
             continue;
             // disabled.
         }
         $aValues[$aRow['field_id']][] = $oInstance->getFieldValueId();
     }
     return $aValues;
 }
예제 #17
0
 /**
  * Test
  *
  * @test
  * @expectedException InvalidArgumentException
  *
  * @return void
  */
 public function getHashWithInvalidAlgorithm()
 {
     $this->object = Karla::perform(PATH_TO_IMAGEMAGICK)->identify()->in($this->testDataPath . '/demo.jpg')->execute(true, false);
     $this->object->getHash('sha');
 }
 /**
  * @param mixed $payload
  * @param MetaData|null $metaData
  * @return GenericDomainEventMessage
  */
 protected function registerEvent($payload, MetaData $metaData = null)
 {
     $meta = null === $metaData ? MetaData::emptyInstance() : $metaData;
     return $this->getEventContainer()->addEvent($meta, $payload);
 }
예제 #19
0
<?php

require_once realpath(dirname(__FILE__) . '/../bransom/php/Bootstrap.class.php');
Bootstrap::initConfig(dirname(__FILE__) . '/../bransom/config/config.ini');
Bootstrap::import('nl.bransom.persistency.meta.MetaData');
session_start();
$schema = MetaData::getInstance()->getSchema('webitems');
$entities = $schema->getObjectEntities();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <h3>Entities of 'webitems'</h3>
        <table>
            <?php 
foreach ($entities as $entity) {
    ?>
            <tr><td colspan="3"><br/><b><?php 
    echo $entity->getName();
    ?>
</b></td></tr>
            <tr>
                <?php 
    foreach ($entity->getProperties() as $property) {
        ?>
                    <tr>
                        <td><?php 
예제 #20
0
 /**
  * Nastavi $this->cache['fk']
  * @param array of entityname
  * @param IRepositoryContainer
  */
 private final function loadFk(array $entityNames, IRepositoryContainer $model)
 {
     $result = array();
     if ($this->foreignKeyFormat('test') !== 'test') {
         foreach ($entityNames as $entityName) {
             foreach (MetaData::getEntityRules($entityName, $model) as $name => $rule) {
                 if ($rule['relationship'] !== MetaData::ManyToOne and $rule['relationship'] !== MetaData::OneToOne) {
                     continue;
                 }
                 $fk = $this->foreignKeyFormat($this->storageFormat($name));
                 $result['storage'][$fk] = $name;
                 $result['entity'][$name] = $fk;
             }
         }
     }
     $this->cache['fk'] = $result;
 }
 function validatorsForFieldset($fieldsetOrType, $sContainerName, $oDocument = null, $bIncludeAuto = false)
 {
     // this is likely to be called repeatedly.
     if (is_null($this->oVF)) {
         $this->oVF =& KTValidatorFactory::getSingleton();
     }
     // FIXME delegate.
     $oFieldset =& $fieldsetOrType;
     if ($oFieldset->getIsConditional()) {
         $validators = array();
         $fields = $oFieldset->getFields();
         if ($bIncludeAuto) {
             $widgets = $this->widgetsForFieldset($oFieldset, $sContainerName, $sDocument);
             $validators = kt_array_merge($validators, $widgets[0]->getValidators());
         }
         foreach ($fields as $oField) {
             $fname = 'metadata_' . $oField->getId();
             // Change back to 'membership'
             $validators[] = $this->oVF->get('ktcore.validators.membership', array('test' => $fname, 'output' => $fname, 'vocab' => MetaData::getEnabledValuesByDocumentField($oField), 'id_method' => 'getName'));
         }
     } else {
         $validators = array();
         $fields = $oFieldset->getFields();
         if ($bIncludeAuto) {
             // we need to do *all* validation
             // since we may be used outside a form.
             //
             // to prevent code duplication, we cheat and get the autovalidators
             // this makes add/edit forms marginally less efficient, but we'll deal.
             $widgets = $this->widgetsForFieldset($oFieldset, $sContainerName, $sDocument);
             $validators = kt_array_merge($validators, $widgets[0]->getValidators());
         }
         $config = KTConfig::getSingleton();
         $maxLength = $config->get('KnowledgeTree/maxMetadataLength', 10240);
         foreach ($fields as $oField) {
             $type = '';
             if ($oField->getHasLookup()) {
                 if ($oField->getHasLookupTree()) {
                     $type = 'ktcore.fields.tree';
                 } else {
                     $type = 'ktcore.fields.lookup';
                 }
             } else {
                 $type = 'ktcore.fields.string';
             }
             $fname = 'metadata_' . $oField->getId();
             if ($type == 'ktcore.fields.string') {
                 $validators[] = $this->oVF->get('ktcore.validators.string', array('test' => $fname, 'max_length' => $maxLength, 'output' => $fname));
             } else {
                 if ($type == 'ktcore.fields.lookup') {
                     $validators[] = $this->oVF->get('ktcore.validators.membership', array('test' => $fname, 'output' => $fname, 'vocab' => MetaData::getEnabledValuesByDocumentField($oField), 'id_method' => 'getName'));
                 } else {
                     if ($type == 'ktcore.fields.tree') {
                         // FIXME we really need to make tree entries richer
                         $validators[] = $this->oVF->get('ktcore.validators.membership', array('test' => $fname, 'output' => $fname, 'vocab' => MetaData::getEnabledValuesByDocumentField($oField), 'id_method' => 'getName'));
                     } else {
                         $validators[] = PEAR::raiseError(sprintf(_kt("Unable to deal with field: id %d"), $oField->getId()));
                     }
                 }
             }
         }
     }
     return array($this->oVF->get('ktcore.validators.fieldset', array('test' => $sContainerName, 'output' => $sContainerName, 'validators' => $validators)));
 }
예제 #22
0
 function update($data)
 {
     if (count($data['edit']) > 0) {
         global $wpdb;
         foreach ($data['edit'] as $postid => $values) {
             $postid = intval($postid);
             // Just check we can edit this
             if (current_user_can('edit_post', $postid)) {
                 MetaData::add_tags($postid, $values);
             }
         }
     }
 }
예제 #23
0
 /** @test */
 public function should_calculate_the_number_of_taxable_products_for_basket_fixture_nine()
 {
     $basket = $this->fixtures->nine();
     $total = $this->meta->generate($basket);
     $this->assertEquals(5, $total);
 }
예제 #24
0
#!/usr/bin/php
<?php 
require 'extractor.php';
require 'metadata.php';
$data = new MetaData($argv[1]);
if ($data->isValid()) {
    echo 'Name: ' . $data->getKey('name') . "\n";
    echo 'Songs: ' . $data->getKey('num_songs') . "\n";
    echo 'Artist: ' . $data->getKey('artist') . "\n";
    echo 'Copyright: ' . $data->getKey('copyright') . "\n";
    /*
    or do it this way:
    print_R($data->getData());
    echo $data->getJSON();
    */
} else {
    echo "Oops! Error reading file...\n";
}
 public static function outputLimiterValueTextboxOrDropdown($field, $limiter_value = "")
 {
     global $Proj;
     $field = self::getFieldFromEventField($field);
     // For last field ("add new limiter"), disable the element
     $disabled = $field == "" ? "disabled" : "";
     if ($field != '' && ($Proj->isMultipleChoice($field) || $Proj->metadata[$field]['element_type'] == 'sql')) {
         // Build enum options
         $enum = $Proj->metadata[$field]['element_enum'];
         $options = $Proj->metadata[$field]['element_type'] == 'sql' ? parseEnum(getSqlFieldEnum($enum)) : parseEnum($enum);
         // Make sure it has a blank option at the beginning (EXCEPT checkboxes)
         if ($Proj->metadata[$field]['element_type'] != 'checkbox') {
             $options = array('' => '') + $options;
         }
         // Multiple choice drop-down
         return RCView::select(array('name' => 'limiter_value[]', $disabled => $disabled, 'class' => 'x-form-text x-form-field limiter-value', 'style' => 'max-width:150px;padding-right:0;height:22px;'), $options, $limiter_value, 200);
     } else {
         // If field has validation, then add its validation as onblur
         $val_type = $Proj->metadata[$field]['element_type'] == 'text' ? $Proj->metadata[$field]['element_validation_type'] : '';
         $onblur = "";
         if ($val_type != '') {
             // Convert legacy validation types
             if ($val_type == 'int') {
                 $val_type = 'integer';
             } elseif ($val_type == 'float') {
                 $val_type = 'number';
             }
             // Add onblur
             $onblur = "redcap_validate(this,'{$Proj->metadata[$field]['element_validation_min']}','{$Proj->metadata[$field]['element_validation_max']}','hard','{$val_type}',1)";
         }
         // If an MDY or DMY date/time field, then convert value
         if ($limiter_value != '') {
             if (substr($val_type, 0, 4) == 'date' && (substr($val_type, -4) == '_mdy' || substr($val_type, -4) == '_dmy')) {
                 // Convert to MDY or DMY format
                 $limiter_value = DateTimeRC::datetimeConvert($limiter_value, 'ymd', substr($val_type, -3));
             }
         }
         // Adjust text box size for date/time fields
         if (strpos($val_type, 'datetime_seconds') === 0) {
             $style = 'width:120px;';
         } elseif (strpos($val_type, 'datetime') === 0) {
             $style = 'width:103px;';
         } elseif (strpos($val_type, 'date') === 0) {
             $style = 'width:70px;';
         } else {
             $style = 'width:150px;';
         }
         // Build date/time format text for date/time fields
         $dformat = MetaData::getDateFormatDisplay($val_type);
         $dformat_span = $dformat == '' ? '' : RCView::span(array('class' => 'df', 'style' => 'padding-left:4px;'), $dformat);
         // Return text field
         return RCView::text(array('name' => 'limiter_value[]', $disabled => $disabled, 'onblur' => $onblur, 'class' => $val_type . ' x-form-text x-form-field limiter-value', 'maxlength' => 255, 'style' => $style, 'value' => htmlspecialchars($limiter_value, ENT_QUOTES))) . $dformat_span;
     }
 }
예제 #26
0
 function subact_unlinkKeyword(&$constructedTree, $keyword)
 {
     $oKW = MetaData::get($keyword);
     if (PEAR::isError($oKW)) {
         return true;
     }
     $constructedTree->reparentKeyword($oKW->getId(), 0);
     return true;
 }
예제 #27
0
 function do_selectLookup()
 {
     $field = KTUtil::arrayGet($_REQUEST, 'fField', null);
     $oField = DocumentField::get($field);
     if (PEAR::isError($oField) || $oField == false || !$oField->getHasLookup()) {
         $this->errorRedirectToMain('No Field selected.');
         exit(0);
     }
     $_REQUEST['fBrowseMode'] = 'lookup_value';
     $aValues = MetaData::getByDocumentField($oField);
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate('kt3/browse_lookup_value');
     $aTemplateData = array('context' => $this, 'oField' => $oField, 'values' => $aValues);
     return $oTemplate->render($aTemplateData);
 }
 function formAdaptor($oFieldset, $oDocument = null)
 {
     $widgets = array();
     $validators = array();
     $oVF =& KTValidationFactory::getSingleton();
     $oWF =& KTWidgetFactory::getSingleton();
     $fields =& $oFieldset->getFields();
     foreach ($fields as $oField) {
         // FIXME we probably want to use some form of factory here.
         $field_name = 'metadata_' . $oField->getId();
         if ($field->getHasLookup()) {
             // lookups
             if ($field->getHasLookupTree()) {
                 // tree
                 // FIXME we don't handle trees yet
                 continue;
                 /*
                 $fieldTree = new MDTree();
                                     $fieldTree->buildForField($field->getId());
                                     $fieldTree->setActiveItem($current_value);
                     	    		$fieldOptions['tree'] = $fieldTree->_evilTreeRenderer($fieldTree, $fieldName);
                                     $oField = new KTTreeWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
                 */
             } else {
                 // normal
                 $widgets[] = $oWF->get('ktcore.widgets.entityselection', array('label' => $oField->getName(), 'name' => 'metadata_' . $oField->getId(), 'description' => $oField->getDescription(), 'vocab' => MetaData::getEnabledByDocumentField($oField), 'id_method' => 'getName', 'label_method' => 'getName', 'required' => $oField->getIsMandatory()));
                 if ($oField->getIsMandatory()) {
                     $validators[] = $oVF->get('ktcore.validators.required', array('test' => $field_name, 'basename' => 'metadata_'));
                 }
                 $validators[] = $oVF->get('ktcore.validators.membership', array('test' => $field_name, 'output' => $field_name, 'basename' => $field_name, 'vocab' => MetaData::getEnabledValuesForField($oField)));
             }
         } else {
             $widgets[] = $oWF->get('ktcore.widgets.string', array('label' => $oField->getName(), 'output' => $field_name));
             if ($oField->getIsMandatory()) {
                 $validators[] = $oVF->get('ktcore.validators.required', array('test' => $field_name, 'basename' => $field_name));
             }
         }
     }
     return array('widgets' => $widgets, 'validators' => $validators);
 }
 function get_nofollow($postid)
 {
     return MetaData::get($postid, 'nofollow');
 }
예제 #30
0
<?php

require_once realpath(dirname(__FILE__) . '/php/Bootstrap.class.php');
Bootstrap::initConfig(dirname(__FILE__) . '/config/config.ini');
Bootstrap::import('nl.bransom.persistency.meta.MetaData');
$metaData = MetaData::getInstance();
$appNames = $metaData->getAppNames();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
		<title>REST applications</title>
	</head>
	<body>
		<h3>REST applications</h3>
		<table>
			<?php 
foreach ($appNames as $appName) {
    ?>
				<tr><td colspan="2"><a href="REST/<?php 
    echo $appName;
    ?>
"><b><?php 
    echo $appName;
    ?>
</b></a></td></tr>
				<tr>
					<td>&nbsp;</td>
					<td>schema = <?php 
    echo $metaData->getSchema($appName)->getName();