Exemplo n.º 1
0
 /**
  * Get data description.
  *
  * @return DataDescription
  */
 public function getDataDescription()
 {
     $result = new DataDescription();
     $result->load(array('field_id' => array('nullable' => false, 'length' => 10, 'default' => '', 'key' => true, 'type' => FieldDescription::FIELD_TYPE_INT, 'index' => 'PRI', 'tableName' => 'table_name'), 'lang_id' => array('nullable' => false, 'length' => 10, 'default' => '', 'key' => false, 'type' => FieldDescription::FIELD_TYPE_INT, 'index' => 'PRI', 'tableName' => 'table_name', 'languageID' => true), 'field_name' => array('nullable' => false, 'length' => 255, 'default' => '', 'key' => false, 'type' => FieldDescription::FIELD_TYPE_STRING, 'index' => false, 'tableName' => 'share_lang_tags_translation', 'isMultilanguage' => true), 'field_type' => array('nullable' => false, 'length' => 255, 'default' => '', 'key' => false, 'type' => FieldDescription::FIELD_TYPE_HIDDEN, 'index' => true, 'tableName' => 'table_name'), 'field_type_real' => array('nullable' => false, 'length' => 255, 'default' => '', 'key' => false, 'type' => FieldDescription::FIELD_TYPE_STRING, 'index' => true), 'field_is_nullable' => array('nullable' => false, 'length' => 1, 'default' => '', 'key' => false, 'type' => FieldDescription::FIELD_TYPE_BOOL, 'index' => false, 'tableName' => 'table_name')));
     $f = $result->getFieldDescriptionByName('field_type');
     $f->setType(FieldDescription::FIELD_TYPE_SELECT);
     $f->loadAvailableValues(array(array('key' => FieldDescription::FIELD_TYPE_STRING, 'value' => $this->translate('FIELD_TYPE_STRING')), array('key' => FieldDescription::FIELD_TYPE_EMAIL, 'value' => $this->translate('FIELD_TYPE_EMAIL')), array('key' => FieldDescription::FIELD_TYPE_PHONE, 'value' => $this->translate('FIELD_TYPE_PHONE')), array('key' => FieldDescription::FIELD_TYPE_BOOL, 'value' => $this->translate('FIELD_TYPE_BOOL')), array('key' => FieldDescription::FIELD_TYPE_TEXT, 'value' => $this->translate('FIELD_TYPE_TEXT')), array('key' => FieldDescription::FIELD_TYPE_MULTI, 'value' => $this->translate('FIELD_TYPE_MULTI')), array('key' => FieldDescription::FIELD_TYPE_SELECT, 'value' => $this->translate('FIELD_TYPE_SELECT')), array('key' => FieldDescription::FIELD_TYPE_DATE, 'value' => $this->translate('FIELD_TYPE_DATE')), array('key' => FieldDescription::FIELD_TYPE_DATETIME, 'value' => $this->translate('FIELD_TYPE_DATETIME')), array('key' => FieldDescription::FIELD_TYPE_FILE, 'value' => $this->translate('FIELD_TYPE_FILE')), array('key' => FieldDescription::FIELD_TYPE_INFO, 'value' => $this->translate('FIELD_TYPE_INFO'))), 'key', 'value');
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Generate Google Sitemap
  */
 protected function map()
 {
     E()->getController()->getTransformer()->setFileName($this->getParam('map.xslt'), true);
     $dd = new DataDescription();
     foreach (['Id' => FieldDescription::FIELD_TYPE_INT, 'Segment' => FieldDescription::FIELD_TYPE_STRING, 'LastMod' => FieldDescription::FIELD_TYPE_DATETIME] as $fieldName => $fieldType) {
         $fd = new FieldDescription($fieldName);
         if ($fieldName == 'Id') {
             $fd->setType($fieldType)->setProperty('key', 1);
         } else {
             $fd->setType($fieldType);
         }
         $dd->addFieldDescription($fd);
     }
     $dd->getFieldDescriptionByName('LastMod')->setProperty('outputFormat', '%Y-%m-%d');
     $this->setDataDescription($dd);
     $d = new Data();
     $this->setData($d);
     $sitemap = E()->getMap();
     $res = $sitemap->getInfo();
     foreach ($res as $id => $info) {
         if ($info['IsIndexed']) {
             $result[] = ['Id' => $id, 'Name' => $info['Name'], 'LastMod' => $info['LastMod'], 'Segment' => $sitemap->getURLByID($id)];
         }
     }
     $this->getData()->load($result);
     $this->setBuilder(new SimpleBuilder());
 }