예제 #1
0
 /**
  * List object's properties for JS rule builder
  *
  * PONDER: Should we support schema somehow (only for non-parameter keys), this would practically require manual parsing...
  *
  * @param midcom_core_dbaobject $object
  * @param midcom_services_i18n_l10n $l10n
  */
 public static function list_object_properties(&$object, &$l10n)
 {
     // These are internal to midgard and/or not valid QB constraints
     $skip_properties = array();
     // These will be deprecated soon
     $skip_properties[] = 'orgOpenpsaAccesstype';
     $skip_properties[] = 'orgOpenpsaWgtype';
     if (midcom::get('dbfactory')->is_a($object, 'org_openpsa_person')) {
         // The info field is a special case
         $skip_properties[] = 'info';
         // These legacy fields are rarely used
         $skip_properties[] = 'topic';
         $skip_properties[] = 'subtopic';
         $skip_properties[] = 'office';
         // This makes very little sense as a constraint
         $skip_properties[] = 'img';
         // Duh
         $skip_properties[] = 'password';
     }
     if (midcom::get('dbfactory')->is_a($object, 'midgard_member')) {
         // The info field is a special case
         $skip_properties[] = 'info';
     }
     // Skip metadata for now
     $skip_properties[] = 'metadata';
     $ret = array();
     while (list($property, $value) = each($object)) {
         if (preg_match('/^_/', $property) || in_array($property, $skip_properties)) {
             // Skip private or otherwise invalid properties
             continue;
         }
         if (is_object($value) && !is_a($value, 'midgard_datetime')) {
             while (list($property2, $value2) = each($value)) {
                 $prop_merged = "{$property}.{$property2}";
                 $ret[$prop_merged] = $l10n->get("property:{$prop_merged}");
             }
         } else {
             $ret[$property] = $l10n->get("property:{$property}");
         }
     }
     asort($ret);
     return $ret;
 }
예제 #2
0
파일: main.php 프로젝트: nemein/openpsa
 /**
  * Load the specified l10n library.
  *
  * If loading the library failed, midcom_error is thrown, otherwise the l10n
  * db cache is populated accordingly.
  *
  * @param string $component    The component for which to retrieve a string database.
  * @param string $database    The string table to retrieve from the component's locale directory.
  */
 private function _load_l10n_db($component, $database)
 {
     $cacheid = "{$component}/{$database}";
     if ($component == 'midcom') {
         $obj = new midcom_services_i18n_l10n('midcom', $database);
     } else {
         $obj = new midcom_services_i18n_l10n($component, $database);
     }
     if (!$obj) {
         throw new midcom_error("Failed to load L10n database {$cacheid}, see the log file for possible reasons.");
     }
     $obj->set_language($this->_current_language);
     $obj->set_charset($this->_current_charset);
     $obj->set_fallback_language($this->_fallback_language);
     $this->_obj_l10n[$cacheid] =& $obj;
 }