src/App.php
public function getMaterialTableTable($materialId, $structure, $locale = '')
    {
        /** @var \samson\cms\CMSMaterial $material Current material object */
        $material = null;

        // If material was found by identifier
        if ($this->query->className('\samson\cms\CMSMaterial')->cond('MaterialID', $materialId)->first($material)) {

            /** @var MaterialTableTable $table Current table object */
            $table = new MaterialTableTable($material, null, $structure, $locale);

            /** @var boolean $all Flag to determine non-localized tab */
            $all = false;
            /** @var boolean $multilingual Flag to determine localized tab */
            $multilingual = false;

            // If there is relation between current material and current table structure
            if ($this->query->className('\samson\cms\CMSNavMaterial')
                ->cond('MaterialID', $materialId)
                ->join('structure')
                ->cond('StructureID', $structure->StructureID)
                ->first()
            ) {

                // If table structure has at least one none localized field
                if ($this->query->className('structurefield')->cond('StructureID', $structure->StructureID)
                    ->join('field')->cond('field_local', 0)->first()
                ) {
                    // Set non-localized flag to true
                    $all = true;
                }
                // If table structure has at least one localized field
                if ($this->query->className('structurefield')->cond('StructureID', $structure->StructureID)
                    ->join('field')->cond('field_local', 1)->first()
                ) {
                    // Set localized flag to true
                    $multilingual = true;
                }
            }

            // If locale is not set and none localized flag is true
            // Or if locale is set and localized flag is true
            // Render table to get it's HTML code
            //if (($locale == '' && $all) || ($locale != '' && $multilingual)) {
                return $this->view('tab_view')
                    ->set($table->render(), 'table')
                    ->set($materialId, 'materialId')
                    ->set($structure->StructureID, 'structureId')
                    ->output();
            //}
        }
        // Return empty string on fail
        return '';
    }
public function getMaterialTableTable($materialId, $structure, $locale = '')
    {
        /** @var \samson\cms\CMSMaterial $material Current material object */
        $material = null;

        // If material was found by identifier
        if ($this->query->className('\samson\cms\CMSMaterial')->cond('MaterialID', $materialId)->first($material)) {

            /** @var MaterialTableTable $table Current table object */
            $table = new MaterialTableTable($material, null, $structure, $locale);

            /** @var boolean $all Flag to determine non-localized tab */
            $all = false;
            /** @var boolean $multilingual Flag to determine localized tab */
            $multilingual = false;

            // If there is relation between current material and current table structure
            if ($this->query->className('\samson\cms\CMSNavMaterial')
                ->cond('MaterialID', $materialId)
                ->join('structure')
                ->cond('StructureID', $structure->StructureID)
                ->first()
            ) {

                // If table structure has at least one none localized field
                if ($this->query->className('structurefield')->cond('StructureID', $structure->StructureID)
                    ->join('field')->cond('field_local', 0)->first()
                ) {
                    // Set non-localized flag to true
                    $all = true;
                }
                // If table structure has at least one localized field
                if ($this->query->className('structurefield')->cond('StructureID', $structure->StructureID)
                    ->join('field')->cond('field_local', 1)->first()
                ) {
                    // Set localized flag to true
                    $multilingual = true;
                }
            }

            // If locale is not set and none localized flag is true
            // Or if locale is set and localized flag is true
            // Render table to get it's HTML code
            //if (($locale == '' && $all) || ($locale != '' && $multilingual)) {
                return $this->view('tab_view')
                    ->set($table->render(), 'table')
                    ->set($materialId, 'materialId')
                    ->set($structure->StructureID, 'structureId')
                    ->output();
            //}
        }
        // Return empty string on fail
        return '';
    }
public function getMaterialTableTable ( $ materialId , $ structure , $ locale = '' ) { /** @var \samson\cms\CMSMaterial $material Current material object */ $ material = null ; // If material was found by identifier if ( $ this -> query -> className ( '\samson\cms\CMSMaterial' ) -> cond ( 'MaterialID' , $ materialId ) -> first ( $ material ) ) { /** @var MaterialTableTable $table Current table object */ $ table = new MaterialTableTable ( $ material , null , $ structure , $ locale ) ; /** @var boolean $all Flag to determine non-localized tab */ $ all = false ; /** @var boolean $multilingual Flag to determine localized tab */ $ multilingual = false ; // If there is relation between current material and current table structure if ( $ this -> query -> className ( '\samson\cms\CMSNavMaterial' ) -> cond ( 'MaterialID' , $ materialId ) -> join ( 'structure' ) -> cond ( 'StructureID' , $ structure -> StructureID ) -> first ( ) ) { // If table structure has at least one none localized field if ( $ this -> query -> className ( 'structurefield' ) -> cond ( 'StructureID' , $ structure -> StructureID ) -> join ( 'field' ) -> cond ( 'field_local' , 0 ) -> first ( ) ) { // Set non-localized flag to true $ all = true ; } // If table structure has at least one localized field if ( $ this -> query -> className ( 'structurefield' ) -> cond ( 'StructureID' , $ structure -> StructureID ) -> join ( 'field' ) -> cond ( 'field_local' , 1 ) -> first ( ) ) { // Set localized flag to true $ multilingual = true ; } } // If locale is not set and none localized flag is true // Or if locale is set and localized flag is true // Render table to get it's HTML code //if (($locale == '' && $all) || ($locale != '' && $multilingual)) { return $ this -> view ( 'tab_view' ) -> set ( $ table -> render ( ) , 'table' ) -> set ( $ materialId , 'materialId' ) -> set ( $ structure -> StructureID , 'structureId' ) -> output ( ) ; //} } // Return empty string on fail return '' ; }
Function to generate new table
@param int $materialId Current material identifier
@param \samson\cms\Navigation $structure Current table structure
@param string $locale Current locale
@return string Generated table HTML
Function to generate new table