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


PHP M::hook方法代码示例

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


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

示例1: run

 public function run()
 {
     $this->do = $this->getRecord();
     deny_unless_can('read', $this->do);
     $this->assign('__action', 'edit');
     $this->append('subActions', '<a href="' . M_Office_Util::getQueryParams(array(), array('record', 'doSingleAction', '__record_ref')) . '">' . __('&lt; Back to list') . '</a>');
     $tpl = Mreg::get('tpl');
     $tpl->concat('adminTitle', $this->do->__toString() . ' :: ' . $this->moduloptions['title']);
     $tpl->assign('adminHeader', $this->do->__toString());
     $database = $this->do->database();
     /**
      *
      * Actions
      *
      **/
     if (isset($_REQUEST['doSingleAction']) && $this->getGlobalOption('actions', 'showtable', $this->module)) {
         $subController = new M_Office_Actions($this->getOptions());
         $subController->run($this->do, $_REQUEST['doSingleAction'], 'single');
         if ($subController->hasOutput()) {
             return;
         }
     }
     $this->createActions();
     $formBuilder = MyFB::create($this->do);
     if (!can('update', $this->module)) {
         $formBuilder->userEditableFields = array('__fakefield');
     }
     $editopts = PEAR::getStaticProperty('m_office_editrecord', 'options');
     if (!empty($editopts['tableOptions'][$this->module]['fields'])) {
         $formBuilder->fieldsToRender = $editopts['tableOptions'][$this->module]['fields'];
     }
     $form = new MyQuickForm('editRecord', 'POST', M_Office_Util::doURL($this->do, $this->module, array()), '_self', null, true);
     $formBuilder->elementTypeAttributes = array('longtext' => array('cols' => 50, 'rows' => 10));
     $formBuilder->useForm($form);
     if ($this->getOption('edit', $this->module)) {
         $this->assign('editable', true);
     } else {
         $doFreeze = true;
     }
     $form = $formBuilder->getForm();
     if (PEAR::isError($form)) {
         throw new Exception($form->getMessage() . ' ' . print_r($form->getUserInfo(), true));
     }
     if ($doFreeze) {
         $form->freeze();
         $submit = $form->getElement('__submit__');
         if (!PEAR::isError($submit)) {
             $form->removeElement('__submit__');
         }
     }
     if ($form->validate()) {
         $ret = $form->process(array($formBuilder, 'processForm'), false);
         if (PEAR::isError($ret)) {
             $this->append('errors', __('An error occured while updating record') . ' : ' . $ret->getMessage());
             $this->assign('__action', 'error');
             return;
         } else {
             $params_to_remove = array();
             $values = $form->exportValues();
             if ($values['__backtolist__']) {
                 $params_to_remove[] = 'record';
             }
             if (!key_exists('debug', $_REQUEST)) {
                 $this->say(__('Record saved !'));
                 M_Office_Util::refresh(M_Office_Util::doURL($this->do, $this->module, array(), $params_to_remove));
             }
         }
     }
     $this->assign('editForm', $form);
     if ($linkFromTables = $this->getOption('linkFromTables', $this->table)) {
         $ajaxFrom = $this->getOption('ajaxLinksFromTable', $this->table);
         if (!is_array($ajaxFrom)) {
             $ajaxFrom = array();
         }
         foreach ($this->do->reverseLinks() as $linkFromTable => $field) {
             list($linkTab, $linkField) = explode(':', $linkFromTable);
             switch (true) {
                 case !$this->getGlobalOption('view', 'showtable', $linkTab):
                     break;
                 case key_exists($linkTab, $ajaxFrom):
                     $fromfield = $ajaxFrom[$linkFromTable]['fromfield'];
                     if ($fromfield == $linkField || !$fromfield) {
                         $info = $ajaxFrom[$linkTab];
                         $aja = new M_Office_ajaxFromTable($this->do, $this->module, $linkTab, $linkField, $this->do->{$field});
                         if ($info['position'] == 'before') {
                             $ajaxLinksBefore[] = $aja->getBlock();
                         } else {
                             $ajaxLinksAfter[] = $aja->getBlock();
                         }
                     }
                     break;
                 case $linkFromTables === TRUE || is_array($linkFromTables) && in_array($linkTab, $linkFromTables):
                     if ($linkInfo = $this->getLinkFromTableItem($linkTab, $linkField, $field)) {
                         $linkFromTableArray[] = $linkInfo;
                     }
                     break;
             }
         }
     }
     M::hook($this->do->tableName(), 'alterLinkFromTables', array(&$linkFromTableArray, $this->do));
//.........这里部分代码省略.........
开发者ID:demental,项目名称:m,代码行数:101,代码来源:EditRecord.php


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