当前位置: 首页>>代码示例>>PHP>>正文


PHP Datamodel类代码示例

本文整理汇总了PHP中Datamodel的典型用法代码示例。如果您正苦于以下问题:PHP Datamodel类的具体用法?PHP Datamodel怎么用?PHP Datamodel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Datamodel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     $o_dm = new Datamodel(true);
     // PHPUnit seems to barf on the caching code if we don't instanciate a Datamodel instance
     $o_dm->getTableNum("ca_objects");
     // set up test role
     $this->opt_role = new ca_user_roles();
     $this->opt_role->setMode(ACCESS_WRITE);
     $this->opt_role->set("name", "UnitTestRole");
     $this->opt_role->set("code", "unit_test_role");
     if (!$this->opt_role->insert()) {
         print "ERROR inserting role: " . join(" ", $this->opt_role->getErrors()) . "\n";
     }
     $this->opt_role->setMode(ACCESS_READ);
     // set up test user
     $this->ops_username = "unit_test_user";
     $this->ops_password = "topsecret";
     $this->opt_user = new ca_users();
     $this->opt_user->setMode(ACCESS_WRITE);
     $this->opt_user->set(array('user_name' => $this->ops_username, 'password' => $this->ops_password, 'email' => 'foo@bar.com', 'active' => 1, 'userclass' => 0, 'fname' => 'Test', 'lname' => "User"));
     if (!$this->opt_user->insert()) {
         print "ERROR inserting user: " . join(" ", $this->opt_user->getErrors()) . "\n";
     }
     $this->opt_user->addRoles("unit_test_role");
     $this->opt_user->setMode(ACCESS_READ);
     global $req, $resp;
     $resp = new ResponseHTTP();
     $req = new RequestHTTP($resp, array("dont_create_new_session" => true));
     $this->assertInstanceOf('ca_users', $this->opt_user);
     $this->assertInstanceOf('ca_user_roles', $this->opt_role);
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:31,代码来源:AccessControlTest.php

示例2: Info

 /**
  * 
  */
 public function Info()
 {
     $o_dm = Datamodel::load();
     $t_display = new ca_bundle_displays($vn_display_id = $this->_getDisplayID());
     $this->view->setVar('bundle_displays', caExtractValuesByUserLocale($t_display->getBundleDisplays(array('user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_EDIT_ACCESS__)), null, array()));
     return $this->render('widget_bundle_display_info_html.php', true);
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:10,代码来源:BundleDisplaysController.php

示例3: __construct

 public function __construct(&$po_request, &$po_response, $pa_view_paths = null)
 {
     parent::__construct($po_request, $po_response, $pa_view_paths);
     $this->opo_datamodel = Datamodel::load();
     $this->opo_app_plugin_manager = new ApplicationPluginManager();
     $this->opo_result_context = new ResultContext($po_request, $this->ops_table_name, ResultContext::getLastFind($po_request, $this->ops_table_name));
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:7,代码来源:BaseInterstitialController.php

示例4: __construct

 public function __construct($pa_hits, $pn_table_num)
 {
     $this->opo_datamodel = Datamodel::load();
     $this->opn_subject_tablenum = $pn_table_num;
     $this->ops_subject_pk = $this->opo_datamodel->getTablePrimaryKeyName($pn_table_num);
     $this->setHits($pa_hits);
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:7,代码来源:CachedResult.php

示例5: load

 /**
  *
  *
  * @param string $ps_cache_key
  * @param array $pa_options Options include:
  *		removeDeletedItems = remove any items in the cache that are currently marked as deleted [Default=true]
  *
  * @return bool
  */
 public function load($ps_cache_key, $pa_options = null)
 {
     if (ExternalCache::contains($ps_cache_key, 'Browse')) {
         $this->opa_browse = ExternalCache::fetch($ps_cache_key, 'Browse');
         $this->ops_cache_key = $ps_cache_key;
         if (caGetOption('removeDeletedItems', $pa_options, true)) {
             $o_dm = Datamodel::load();
             if (($t_instance = $o_dm->getInstanceByTableNum($this->opa_browse['params']['table_num'], true)) && $t_instance->hasField('deleted')) {
                 // check if there are any deleted items in the cache
                 if (is_array($va_ids = $this->opa_browse['results']) && sizeof($va_ids)) {
                     $vs_pk = $t_instance->primaryKey();
                     $qr_deleted = $t_instance->getDb()->query($x = "\n\t\t\t\t\t\t\tSELECT {$vs_pk} FROM " . $t_instance->tableName() . " WHERE {$vs_pk} IN (?) AND deleted = 1\n\t\t\t\t\t\t", array($va_ids));
                     if ($qr_deleted->numRows() > 0) {
                         $va_deleted_ids = $qr_deleted->getAllFieldValues($vs_pk);
                         foreach ($va_deleted_ids as $vn_deleted_id) {
                             if (($vn_i = array_search($vn_deleted_id, $va_ids)) !== false) {
                                 unset($va_ids[$vn_i]);
                             }
                         }
                         $this->opa_browse['results'] = array_values($va_ids);
                     }
                 }
             }
         }
         return true;
     }
     return false;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:37,代码来源:BrowseCache.php

示例6: __construct

 /**
  *
  */
 public function __construct($pm_subject_table_name_or_num, $pn_browse_id = null, $ps_browse_context = '')
 {
     $this->opo_datamodel = Datamodel::load();
     $this->opo_db = new Db();
     $this->opa_result_filters = array();
     if (is_numeric($pm_subject_table_name_or_num)) {
         $this->opn_browse_table_num = intval($pm_subject_table_name_or_num);
         $this->ops_browse_table_name = $this->opo_datamodel->getTableName($this->opn_browse_table_num);
     } else {
         $this->opn_browse_table_num = $this->opo_datamodel->getTableNum($pm_subject_table_name_or_num);
         $this->ops_browse_table_name = $pm_subject_table_name_or_num;
     }
     $this->opo_config = Configuration::load();
     $this->opo_ca_browse_config = Configuration::load($this->opo_config->get('browse_config'));
     $this->opa_browse_settings = $this->opo_ca_browse_config->getAssoc($this->ops_browse_table_name);
     // Add "virtual" search facet - allows one to seed a browse with a search
     $this->opa_browse_settings['facets']['_search'] = array('label_singular' => _t('Search'), 'label_plural' => _t('Searches'));
     $this->_processBrowseSettings();
     $this->opo_ca_browse_cache = new BrowseCache();
     if ($pn_browse_id) {
         $this->opo_ca_browse_cache->setParameter('table_num', $this->opn_browse_table_num);
         $this->opo_ca_browse_cache->load($pn_browse_id);
     } else {
         $this->opo_ca_browse_cache->setParameter('table_num', $this->opn_browse_table_num);
         $this->setContext($ps_browse_context);
     }
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:30,代码来源:BrowseEngine.php

示例7: __construct

 public function __construct($ps_widget_path, $pa_settings)
 {
     $this->title = _t('Records by status');
     $this->description = _t('Displays objects or authority items by cataloguing status');
     parent::__construct($ps_widget_path, $pa_settings);
     $this->opo_config = Configuration::load($ps_widget_path . '/conf/recordsByStatus.conf');
     $this->opo_datamodel = Datamodel::load();
     # -- get status values
     $t_lists = new ca_lists();
     $va_statuses = caExtractValuesByUserLocale($t_lists->getItemsForList("workflow_statuses"));
     $va_status_info = array();
     $va_status_values = array();
     foreach ($va_statuses as $i => $va_info) {
         $va_status_info[$va_info["item_value"]] = $va_info["name_singular"];
         $va_status_values[] = $va_info["item_value"];
     }
     $this->opa_status_display_names = $va_status_info;
     $this->opa_status_values = $va_status_values;
     $this->opa_table_display_names = array('ca_objects' => _t('Objects'), 'ca_entities' => _t('Entities'), 'ca_places' => _t('Places'), 'ca_occurrences' => _t('Occurrences'), 'ca_sets' => _t('Sets'), 'ca_collections' => _t('Collections'), 'ca_object_representations' => _t('Object representations'), 'ca_object_lots' => _t('Object lots'));
     foreach ($this->opa_table_display_names as $vs_table => $vs_display) {
         if (!$this->getRequest() || !$this->getRequest()->user->canDoAction("can_use_records_by_status_widget_{$vs_table}")) {
             foreach (BaseWidget::$s_widget_settings['recordsByStatusWidget']["display_type"]["options"] as $vs_setting_display => $vs_setting_table) {
                 if ($vs_setting_table == $vs_table) {
                     unset(BaseWidget::$s_widget_settings['recordsByStatusWidget']["display_type"]["options"][$vs_setting_display]);
                 }
             }
         }
     }
 }
开发者ID:samrahman,项目名称:providence,代码行数:29,代码来源:recordsByStatusWidget.php

示例8: dispatchLoopShutdown

 public function dispatchLoopShutdown()
 {
     //
     // Force output to be sent - we need the client to have the page before
     // we start flushing progress bar updates
     //
     $app = AppController::getInstance();
     $req = $app->getRequest();
     $resp = $app->getResponse();
     $resp->sendResponse();
     $resp->clearContent();
     //
     // Do reindexing
     //
     if ($req->isLoggedIn() && $req->user->canDoAction('can_do_search_reindex')) {
         set_time_limit(3600 * 8);
         $o_db = new Db();
         $t_timer = new Timer();
         $o_dm = Datamodel::load();
         $va_table_names = $o_dm->getTableNames();
         $vn_tc = 0;
         foreach ($va_table_names as $vs_table) {
             if ($o_instance = $o_dm->getInstanceByTableName($vs_table)) {
                 if ($o_instance->isHierarchical()) {
                     if (!$o_instance->rebuildAllHierarchicalIndexes()) {
                         $o_instance->rebuildHierarchicalIndex();
                     }
                 }
                 caIncrementHierachicalReindexProgress(_t('Rebuilding hierarchical index for %1', $o_instance->getProperty('NAME_PLURAL')), $t_timer->getTime(2), memory_get_usage(true), $va_table_names, $o_instance->tableNum(), $o_instance->getProperty('NAME_PLURAL'), $vn_tc + 1);
             }
             $vn_tc++;
         }
         caIncrementHierachicalReindexProgress(_t('Index rebuild complete!'), $t_timer->getTime(2), memory_get_usage(true), $va_table_names, null, null, sizeof($va_table_names));
     }
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:35,代码来源:HierarchicalReindexingProgress.php

示例9: __construct

 public function __construct($po_request)
 {
     parent::__construct($po_request);
     $this->opo_dm = Datamodel::load();
     $t_list = new ca_lists();
     $this->opn_victim_type_id = $t_list->getItemIDFromList('entity_types', 'victim');
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:7,代码来源:VictimService.php

示例10: Get

 public function Get($pa_additional_query_params = null, $pa_options = null)
 {
     $ps_query = $this->request->getParameter('q', pString);
     $ps_bundle = $this->request->getParameter('bundle', pString);
     $va_tmp = explode('.', $ps_bundle);
     $vs_table = $va_tmp[0];
     $vs_field = $va_tmp[1];
     $o_dm = Datamodel::load();
     if (!($t_table = $o_dm->getInstanceByTableName($vs_table, true))) {
         // bad table name
         print _t("Invalid table name");
         return null;
     }
     if (!$t_table->hasField($vs_field) || !in_array($t_table->getFieldInfo($vs_field, 'FIELD_TYPE'), array(FT_TEXT, FT_NUMBER))) {
         // bad field name
         print _t("Invalid bundle name");
         return null;
     }
     if ($this->request->user->getBundleAccessLevel($vs_table, $vs_field) == __CA_BUNDLE_ACCESS_NONE__) {
         print _t("You do not have access to this bundle");
         return null;
     }
     $vn_max_returned_values = 50;
     $o_db = new Db();
     $qr_res = $o_db->query("\n\t\t\t\tSELECT DISTINCT {$vs_field}\n\t\t\t\tFROM {$vs_table}\n\t\t\t\tWHERE\n\t\t\t\t\t({$vs_field} LIKE ?) " . ($t_table->hasField('deleted') ? ' AND deleted = 0' : '') . "\n\t\t\t\tORDER BY\n\t\t\t\t\t{$vs_field}\n\t\t\t\tLIMIT {$vn_max_returned_values}\n\t\t\t", (string) $ps_query . '%');
     $this->view->setVar('intrinsic_value_list', $qr_res->getAllFieldValues($vs_field));
     return $this->render('ajax_intrinsic_value_list_html.php');
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:28,代码来源:IntrinsicController.php

示例11: __construct

 public function __construct($po_request, $ps_table = "")
 {
     $this->opo_request = $po_request;
     $this->ops_table = $ps_table;
     $this->opo_dm = Datamodel::load();
     $this->opa_errors = array();
     $this->ops_method = $this->opo_request->getRequestMethod();
     if (!in_array($this->ops_method, array("PUT", "DELETE", "GET", "OPTIONS"))) {
         $this->addError("Invalid HTTP request method");
     }
     $this->opn_id = $this->opo_request->getParameter("id", pString);
     // we allow for a string to support fetching by idno; typically it's a numeric id
     $vs_post_data = $this->opo_request->getRawPostData();
     if (strlen(trim($vs_post_data)) > 0) {
         $this->opa_post = json_decode($vs_post_data, true);
         if (!is_array($this->opa_post)) {
             $this->addError(_t("Data sent via POST doesn't seem to be in JSON format"));
         }
     } else {
         if ($vs_post_data = $this->opo_request->getParameter('source', pString)) {
             $this->opa_post = json_decode($vs_post_data, true);
             if (!is_array($this->opa_post)) {
                 $this->addError(_t("Data sent via 'source' parameter doesn't seem to be in JSON format"));
             }
         } else {
             $this->opa_post = array();
         }
     }
     $this->opa_valid_tables = array("ca_objects", "ca_object_lots", "ca_entities", "ca_places", "ca_occurrences", "ca_collections", "ca_list_items", "ca_lists", "ca_object_representations", "ca_storage_locations", "ca_movements", "ca_loans", "ca_tours", "ca_tour_stops", "ca_sets");
     if (strlen($ps_table) > 0) {
         if (!in_array($ps_table, $this->opa_valid_tables)) {
             $this->addError(_t("Table does not exist"));
         }
     }
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:35,代码来源:BaseJSONService.php

示例12: Info

 /**
  * 
  */
 public function Info()
 {
     $o_dm = Datamodel::load();
     $t_form = new ca_search_forms();
     $this->view->setVar('form_count', $t_form->getFormCount(array('user_id' => $this->request->getUserID(), 'access' => __CA_SEARCH_FORM_EDIT_ACCESS__)));
     return $this->render('widget_search_form_info_html.php', true);
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:10,代码来源:SearchFormController.php

示例13: __construct

 public function __construct($ps_widget_path, $pa_settings)
 {
     $this->title = _t('Recent changes');
     $this->description = _t('Lists recent changes to objects or authority items');
     parent::__construct($ps_widget_path, $pa_settings);
     $this->opo_config = Configuration::load($ps_widget_path . '/conf/recentChangesWidget.conf');
     $this->opo_datamodel = Datamodel::load();
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:8,代码来源:recentChangesWidget.php

示例14: __construct

 public function __construct($m_table = '', $ps_field_name)
 {
     $this->opo_config = Configuration::load();
     $this->opo_datamodel = Datamodel::load();
     if ($m_table && $ps_field_name) {
         $this->loadSettings($m_table, $ps_field_name);
     }
 }
开发者ID:samrahman,项目名称:providence,代码行数:8,代码来源:MediaProcessingSettings.php

示例15: __construct

 public function __construct($ps_table)
 {
     $o_dm = Datamodel::load();
     $this->ops_tablename = $ps_table;
     $this->opn_tablenum = $o_dm->getTableNum($ps_table);
     $this->ops_primary_key = $o_dm->getTablePrimaryKeyName($ps_table);
     parent::__construct();
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:8,代码来源:InterstitialSearch.php


注:本文中的Datamodel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。