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


PHP I2CE_FormStorage::getStorageMechanism方法代码示例

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


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

示例1: __construct

 /**
  * The constructor
  * @param string $form  The form we wish to cash into a table
  */
 public function __construct($form)
 {
     $this->form = $form;
     $factory = I2CE_FormFactory::instance();
     if (!$factory->exists($form)) {
         $msg = "Trying to cache form {$form}, but the form does not exist";
         I2CE::raiseError($msg);
         throw new Exception($msg);
     }
     $this->formObj = $factory->createContainer($this->form);
     if (!$this->formObj instanceof I2CE_Form) {
         $msg = "Cannot instantiate {$this->form}";
         I2CE::raiseError($msg);
         throw new Exception($msg);
     }
     $this->formMech = I2CE_FormStorage::getStorageMechanism($form);
     if (!$this->formMech instanceof I2CE_FormStorage_Mechanism) {
         $msg = "Cannot get storage mechansim for form {$form}";
         I2CE::raiseError($msg);
         throw new Exception($msg);
     }
     $this->short_table_name = $this->getCachedTableName($form, false);
     $this->table_name = $this->getCachedTableName($form, true);
     $this->tmp_table_name = $this->getCachedTableName($form, true, 'tmp_cached_form');
 }
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:29,代码来源:I2CE_CachedForm.php

示例2: loadObjects

 protected function loadObjects()
 {
     parent::loadObjects();
     if (($this->isPost() || $this->hasData()) && ($searchObj = $this->getPrimary()) instanceof CSD_Search && I2CE_FormStorage::getStorageMechanism($searchObj->getName()) instanceof I2CE_FormStorage_CSDSearch) {
         //this will populate "result" field
         $searchObj->setID("1");
         //so it will populate
         if (($maxField = $searchObj->getField('max')) instanceof I2CE_FormField_INT) {
             if ($maxField->getValue() > 200) {
                 $maxField->setValue(200);
             }
         }
         if (($entityIDField = $searchObj->getField('entityID')) instanceof I2CE_FormField_STRING_LINE) {
             list($form, $id) = array_pad(explode('|', $entityIDField->getValue(), 2), 2, '');
             if ($id) {
                 $entityIDField->setValue($id);
             }
         }
         $searchObj->populate(true);
         if (($matches = $searchObj->getField('matches')) instanceof I2CE_FormField_ASSOC_MAP_RESULTS && count($matches->getValue()) > 200) {
             $this->userMessage("To Many Results To Display.  Please refine your search");
             I2CE::raiseError("Too many results");
             $this->bad_result = true;
             $matches->setValue(array());
             if (($resultField = $searchObj->getField('result')) instanceof I2CE_FormField) {
                 $resultField->setValue('');
             }
         }
     }
     return true;
 }
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:31,代码来源:CSD_PageSearch.php

示例3: action

 /**
  * Perform the main actions of the page.
  * @return boolean
  */
 protected function action()
 {
     if (!parent::action()) {
         return false;
     }
     if (!$this->hasPermission("role(admin)")) {
         $this->userMessage("You do not have permission to view this page.");
         return false;
     }
     $pos_mech = I2CE_FormStorage::getStorageMechanism("position");
     $pers_pos_mech = I2CE_FormStorage::getStorageMechanism("person_position");
     if (!$pos_mech instanceof I2CE_FormStorage_entry || !$pers_pos_mech instanceof I2CE_FormStorage_entry) {
         I2CE::raiseMessage("Invalid storage type for position and person position forms. " . get_class($pos_mech) . get_class($pers_pos_mech));
         $this->template->addFile("mass_delete_by_search_error_invalid.html");
         return true;
     }
     $people = $this->post('people');
     if (!is_array($people) || count($people) < 1) {
         $this->template->addFile("mass_delete_by_search_empty.html");
     } else {
         $step = 'choose';
         if ($this->post_exists('step')) {
             $step = $this->post('step');
         }
         if ($step == "delete") {
             if ($this->post('yes') != 'yes') {
                 $this->template->appendFileById("mass_delete_by_search_error_yes.html", "p", "error");
                 $step = "confirm";
             }
             $userAccess = new I2CE_UserAccess_Mechanism();
             if (!$this->post_exists('admin_pass') || !$userAccess->userHasPassword('i2ce_admin', $this->post('admin_pass'))) {
                 $this->template->appendFileById("mass_delete_by_search_error_password.html", "p", "error");
                 $step = "confirm";
             }
         }
         switch ($step) {
             case "choose":
                 $this->template->addFile("mass_delete_by_search_form.html");
                 $msgNode = $this->template->addFile("mass_delete_by_search_confirm_message.html");
                 foreach ($people as $person) {
                     $persObj = I2CE_FormFactory::instance()->createContainer($person);
                     $persObj->populate();
                     $persNode = $this->template->appendFileById("mass_delete_by_search_each.html", "li", "search_list");
                     $this->template->setDisplayDataImmediate("people[]", array('value' => $person, 'id' => "check_{$person}"), $persNode);
                     $this->template->setDisplayDataImmediate("person_name", $persObj->surname . ', ' . $persObj->firstname, $persNode);
                     $label = $this->template->query("label[@name='search_label']", $persNode);
                     if ($label->length == 1) {
                         $label->item(0)->setAttribute("for", "check_{$person}");
                     }
                 }
                 break;
             case "confirm":
                 $list = $this->getDeleteList($people);
                 if ($list === null) {
                     $this->template->addFile("mass_delete_by_search_error_notfound.html");
                 } elseif (count($list) < 1) {
                     I2CE::raiseMessage("Invalid return data from getDeleteList!");
                     $this->template->addFile("mass_delete_by_search_error_unkonwn.html");
                 } else {
                     $formNode = $this->template->addFile("mass_delete_by_search_form.html");
                     $this->template->setDisplayDataImmediate("step", "delete");
                     $addNode = $this->template->addFile("mass_delete_by_search_authenticate_form.html");
                     $would_delete = I2CE_FormStorage_entry::massDelete($list, array());
                     $msgNode = $this->template->addFile("mass_delete_by_search_delete_count.html");
                     $this->template->setDisplayDataImmediate("delete_count", $would_delete, $msgNode);
                     foreach ($people as $person) {
                         $persObj = I2CE_FormFactory::instance()->createContainer($person);
                         $persObj->populate();
                         $persNode = $this->template->appendFileById("mass_delete_by_search_each_final.html", "li", "search_list");
                         $this->template->setDisplayDataImmediate("people[]", $person, $persNode);
                         $this->template->setDisplayDataImmediate("person_name", $persObj->surname . ', ' . $persObj->firstname, $persNode);
                     }
                 }
                 break;
             case "delete":
                 $list = $this->getDeleteList($people);
                 if ($list === null) {
                     $this->template->addFile("mass_delete_by_search_error_notfound.html");
                 } elseif (count($list) < 1) {
                     I2CE::raiseMessage("Invalid return data from getDeleteList!");
                     $this->template->addFile("mass_delete_by_search_error_unkonwn.html");
                 } else {
                     $formNode = $this->template->addFile("mass_delete_by_search_form.html");
                     $this->template->setDisplayDataImmediate("step", "delete");
                     $addNode = $this->template->addFile("mass_delete_by_search_authenticate_form.html");
                     I2CE_ModuleFactory::callHooks("pre_mass_delete_person", $people, $this->post());
                     if (($deleted = I2CE_FormStorage_entry::massDelete($list, array(), false)) !== false) {
                         $node = $this->template->addFile("mass_delete_by_search_success.html");
                         $this->template->setDisplayDataImmediate("delete_count", $deleted, $node);
                         if (I2CE_ModuleFactory::instance()->isEnabled("CachedForms")) {
                             $forms = I2CE_FormFactory::instance()->getNames();
                             $success = array();
                             $failure = array();
                             foreach ($forms as $form) {
                                 try {
                                     $cachedForm = new I2CE_CachedForm($form);
//.........这里部分代码省略.........
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:101,代码来源:iHRIS_PageMassDeleteSearchAction.php

示例4: slowPopulate

 /**
  * Method used to populate the cache table in case the form storage mechanism is not DB like
  * @param boolean $check_mod.  Defaults to true.  If false, it skips the mod time check
  */
 protected function slowPopulate($check_mod = true, $id = null)
 {
     $fields = array();
     $mdb2_types = array();
     $default_values = array();
     foreach ($this->formObj as $field => $fieldObj) {
         if (!$fieldObj->isInDB()) {
             continue;
         }
         $fields[] = $field;
         $mdb2_types[] = $fieldObj->getMDB2Type();
         $default_values[$field] = $fieldObj->getDBValue();
     }
     $default_values['last_modified'] = '1900-01-01 00:00:00';
     $default_values['created'] = '0000-00-00 00:00:00';
     $default_values['parent'] = '|';
     $insert_fields = $fields;
     $insert_fields[] = 'last_modified';
     $insert_fields[] = 'created';
     $fields[] = 'last_modified';
     $fields[] = 'created';
     $fields[] = 'parent';
     $insert_fields[] = 'parent';
     $insert_fields[] = "id";
     $update_fields = array();
     foreach ($insert_fields as &$field) {
         $field = '`' . $field . '`';
         $update_fields[] = "{$field}=values({$field})";
     }
     unset($field);
     $insertQry = 'INSERT INTO ' . $this->table_name . " (" . implode(',', $insert_fields) . " ) " . " VALUES (" . implode(',', array_fill(0, count($insert_fields), '?')) . ")" . " ON DUPLICATE KEY UPDATE " . implode(',', $update_fields);
     if (I2CE_CachedForm::$spam) {
         I2CE::raiseError("Slow populate:\n{$insertQry}");
     }
     $db = MDB2::singleton();
     $prep = $db->prepare($insertQry, $mdb2_types, MDB2_PREPARE_MANIP);
     if (I2CE::pearError($prep, "Error setting up form in the database:")) {
         return false;
     }
     if ($check_mod) {
         $mod_time = $this->getLastCachedTime();
     } else {
         $mod_time = -1;
     }
     $storage = I2CE_FormStorage::getStorageMechanism($this->form);
     if (!$storage instanceof I2CE_FormStorage_Mechanism) {
         I2CE::raiseError("form {$form} does not have valid form storage mechanism");
         return false;
     }
     if (I2CE_CachedForm::$spam) {
         I2CE::raiseError("Mod Time ={$mod_time}");
     }
     if ($id !== null) {
         $ids = array($id);
     } else {
         $ids = $storage->getRecords($this->form, $mod_time);
     }
     if (I2CE_CachedForm::$spam) {
         I2CE::raiseError(implode("\n", $ids));
     }
     foreach ($ids as $id) {
         $data = $storage->lookupField($this->form, $id, $fields, false);
         if (!is_array($data)) {
             continue;
         }
         $t_data = array();
         foreach ($fields as $field) {
             if (array_key_exists($field, $data)) {
                 $t_data[] = $data[$field];
             } else {
                 $t_data[] = $default_values[$field];
             }
         }
         $t_data[] = $this->form . "|" . $id;
         $res = $prep->execute($t_data);
         if (I2CE::pearError($res, "Error insert into cache table:")) {
             return false;
         }
     }
     I2CE_FormStorage::releaseStorage($this->form);
     if (I2CE_CachedForm::$spam) {
         I2CE::raiseError("Populated " . count($ids) . " entries for {$this->form}");
     }
     return true;
 }
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:89,代码来源:I2CE_CachedForm.php


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