parser.modifylayoutview.php

来自「SugarCRM5.1 开源PHP客户关系管理系统」· PHP 代码 · 共 517 行 · 第 1/2 页

PHP
517
字号
                        unset($row [$colID]);                    } else                    {                        $startOfRow = false;                    }                }                // reindex to remove leading (empty)s                $newRow = array();                foreach ($row as $colID => $col)                {                    $newRow [$colID - $offset] = $col;                }                $this->_viewdefs ['panels'] [$panelID] [$rowID] = $newRow;            }        }        //          _pp($this->_viewdefs);    }    function _padFields ()    {        if (! empty($this->_viewdefs))        {            foreach ($this->_viewdefs ['panels'] as $panelID => $panel)            {                $column = 0;                foreach ($panel as $rowID => $row)                {                    // pad between fields on a row                    foreach ($row as $colID => $col)                    {                        for ($i = $column + 1 ; $i < $colID ; $i ++ )                        {                            $row [$i] = array('name' => '(empty)', 'label' => '(empty)');                        }                        $column = $colID;                    }                    // now pad out to the end of the row                    if (($column + 1) < $this->maxColumns)                    { // last column is maxColumns-1                        for ($i = $column + 1 ; $i < $this->maxColumns ; $i ++ )                        {                            $row [$i] = array('name' => '(empty)', 'label' => '(empty)');                        }                    }                    ksort($row);                    $this->_viewdefs ['panels'] [$panelID] [$rowID] = $row;                }            }        }    }    // add a new field to the end of a panel    // don't write out (caller should call handleSave() when ready)    function _addField ($properties, $panelID = FALSE)    {        // if a panelID was not passed, use the first available panel in the list        if (!$panelID) {            $panels = array_keys($this->_viewdefs['panels']);            $panelID = $panels[0];        }        if (isset($this->_viewdefs ['panels'] [$panelID]))        {            // need to clean up the viewdefs before writing them -- Smarty will fail if any fillers/empties are present            foreach ($this->_viewdefs['panels'] as $loop_panelID => $panel_contents) {                foreach ($panel_contents as $row_id => $row) {                    foreach ($row as $col_id => $col) {                        if ($col['name'] == '(filler)') {                            $this->_viewdefs['panels'][$loop_panelID][$row_id][$col_id] = NULL;                        }                        elseif ($col['name'] == '(empty)') {                            unset($this->_viewdefs['panels'][$loop_panelID][$row_id][$col_id]);                        }                    }                }            }            $panel = $this->_viewdefs ['panels'] [$panelID];            $lastrow = count($panel) - 1; // index starts at 0            $lastcol = count($panel [$lastrow]);            // if we're on the last column of the last row, start a new row            //          print "lastrow=$lastrow lastcol=$lastcol";            if ($lastcol >= $this->maxColumns)            {                $lastrow ++;                $this->_viewdefs ['panels'] [$panelID] [$lastrow] = array();                $lastcol = 0;            }            $this->_viewdefs ['panels'] [$panelID] [$lastrow] [$lastcol] = $properties;        }    }    /* getModelFields returns an array of all fields stored in the database for this module plus those fields in the original layout definition (so we get fields such as Team ID)*/    function _getModelFields ()    {        $modelFields = array();        $origViewDefs = $this->_getOrigFieldViewDefs();//        $GLOBALS['log']->debug("Original viewdefs = ".print_r($origViewDefs,true));        foreach ($origViewDefs as $field => $def)        {            if (!empty($field))            {                if (! is_array($def)) {                    $def = array('name' => $field);                }                // get this field's label - if it has not been explicitly provided, see if the fieldDefs has a label for this field, and if not fallback to the field name                if (! isset($def ['label']))                        {                            if (! empty($this->_fieldDefs [$field] ['vname']))                            {                                $def ['label'] = $this->_fieldDefs [$field] ['vname'];                            } else                            {                                $def ['label'] = $field;                            }                        }                $modelFields[$field] = array('name' => $field, 'label' => $def ['label']);            }        }        $GLOBALS['log']->debug(print_r($modelFields,true));        foreach ($this->_fieldDefs as $field => $def)        {            if ((!empty($def['studio']) && $def['studio'] == 'visible')            || (empty($def['studio']) &&  (empty($def ['source']) || $def ['source'] == 'db' || $def ['source'] == 'custom_fields') && $def ['type'] != 'id' && strcmp($field, 'deleted') != 0 && (empty($def ['dbType']) || $def ['dbType'] != 'id') && (empty($def ['dbtype']) || $def ['dbtype'] != 'id')))            {                $label = isset($def['vname']) ? $def['vname'] : $def['name'];                $modelFields [$field] = array('name' => $field, 'label' => $label);            }            else            {                $GLOBALS['log']->debug( get_class($this)."->_getModelFields(): skipping $field from modelFields as it fails the test for inclusion");                if ($field == 'assigned_user_name')                {                    $GLOBALS['log']->debug( print_r($def,true));                }            }        }        $GLOBALS['log']->debug( get_class($this)."->_getModelFields(): remaining entries in modelFields are: ".implode(",",array_keys($modelFields)));        return $modelFields;    }    function _parseData ($panels)    {        $fields = array();        if (empty($panels))        return;        // Fix for a flexibility in the format of the panel sections - if only one panel, then we don't have a panel level defined, it goes straight into rows        // See EditView2 for similar treatment        if (! empty($panels) && count($panels) > 0)        {            $keys = array_keys($panels);            if (is_numeric($keys [0]))            {                $defaultPanel = $panels;                unset($panels); //blow away current value                $panels [''] = $defaultPanel;            }        }        foreach ($panels as $panelID => $panel)        {            foreach ($panel as $rowID => $row)            {                foreach ($row as $colID => $col)                {                    $properties = array();                    if (! empty($col))                    {                        if (is_string($col))                        {                            $properties ['name'] = $col;                        } else if (! empty($col ['name']))                        {                            $properties = $col;                        }                    } else                    {                        $properties ['name'] = translate('LBL_FILLER');                    }                    if (! empty($properties ['name']))                    {                        // get this field's label - if it has not been explicity provided, see if the fieldDefs has a label for this field, and if not fallback to the field name                        if (! isset($properties ['label']))                        {                            if (! empty($this->_fieldDefs [$properties ['name']] ['vname']))                            {                                $properties ['label'] = $this->_fieldDefs [$properties ['name']] ['vname'];                            } else                            {                                $properties ['label'] = $properties ['name'];                            }                        }                        $displayData[strtoupper($panelID)] [$rowID] [$colID] = $properties;                    }                }            }        }        return $displayData;    }    function _getOrigFieldViewDefs ()    {        $origFieldDefs = array();        $GLOBALS['log']->debug("Original File = ".$this->_originalFile);        if (file_exists($this->_originalFile))        {            include ($this->_originalFile);            $origdefs = $viewdefs [$this->_module] [$this->_sourceView] ['panels'];//          $GLOBALS['log']->debug($origdefs);            // Fix for a flexibility in the format of the panel sections - if only one panel, then we don't have a panel level defined, it goes straight into rows            // See EditView2 for similar treatment            if (! empty($origdefs) && count($origdefs) > 0)            {                $keys = array_keys($origdefs);                if (is_numeric($keys [0]))                {                    $defaultPanel = $origdefs;                    unset($origdefs); //blow away current value                    $origdefs [''] = $defaultPanel;                }            }            foreach ($origdefs as $pname => $paneldef)            {                foreach ($paneldef as $row)                {                    foreach ($row as $fieldDef)                    {                        if (is_array($fieldDef))                        {                            $fieldName = $fieldDef ['name'];                        }                        else                        {                            $fieldName = $fieldDef;                        }                        $origFieldDefs [$fieldName] = $fieldDef;                    }                }            }        }        return $origFieldDefs;    }}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?