getLinkTypes

возвращает список типов материалов в которых есть поля типа FIELD_LINK или FIELD_MATERIAL - ссылки на редактируемый материал

@return array
774899
private function getLinks()
	{
		if (!$this->objectId) return;

		// поля типа FIELD_MATERIAL
		$fields = self::getDbConnection()->fetchAll('SELECT * FROM types_fields WHERE type='.FIELD_MATERIAL.' and pseudo_type=0 and len='.$this->objectDefinition->id);		
		
		// поля типа PSEUDO_FIELD_TAGS
		$fields2 = self::getDbConnection()->fetchAll('SELECT * FROM types_fields WHERE pseudo_type='.PSEUDO_FIELD_TAGS.' and len='.$this->objectDefinition->id);		
		$fields = array_merge($fields, $fields2);		
		
		// поля типа FIELD_LINK или FIELD_LINKSET
		if ($this->catalog > 0) {		
			$catalog = Catalog::getById($this->catalog);			
			// итератор всех разделов имеющих тип материалов как у редактируемого материала
			$sections = new Iterator\Catalog\Catalog();
			$sections->where('typ='.$this->objectDefinition->id);
			if (!count($sections)) return;
			
			// получаем все поля, ссылающиеся на эти разделы
			$data = self::getDbConnection()->fetchAll('SELECT * FROM types_fields WHERE type IN ('.FIELD_LINK.','.FIELD_LINKSET.') and pseudo_type=0 and len IN ('.implode(',',$sections->idArray()).')');

			foreach ($data as $f) {				
				$c = Catalog::getById($f['len']);
				// оставляем только поля, ссылающиеся на раздел текущего материала или его родителей
				if ($catalog->path->has( $c )) {
					$fields[] = $f;
				}				
			}			
		}	
		
		ob_start();
		foreach ($fields as $f) try {			
			$od = ObjectDefinition::findById($f['id']);		
			$f['describ'] = $od->getDescriptionDisplay();
			$f['editor_str'] = 'editor_linkset_link';
			if ( file_exists('editors/'.$f['editor_str'].'.php') ) 
				include_once('editors/'.$f['editor_str'].'.php');
			$this->fields_def[] = $f;
		} catch (\Exception $e) {}
		$this->initData .= ob_get_contents();
		ob_end_clean();					
	}
154510
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Create Main Fields:
        
        $fields->addFieldsToTab(
            'Root.Main',
            [
                HTMLEditorField::create(
                    'HeaderContent',
                    $this->fieldLabel('HeaderContent')
                )->setRows(10),
                HTMLEditorField::create(
                    'FooterContent',
                    $this->fieldLabel('FooterContent')
                )->setRows(10)
            ]
        );
        
        // Insert Links Tab:
        
        $fields->insertAfter(
            Tab::create(
                'Links',
                $this->fieldLabel('Links')
            ),
            'Main'
        );
        
        // Add Links Fields:
        
        $fields->addFieldsToTab(
            'Root.Links',
            [
                DropdownField::create(
                    'LinkMode',
                    $this->fieldLabel('LinkMode'),
                    $this->getLinkModeOptions()
                ),
                PageMultiselectField::create(
                    'LinkedPages',
                    $this->fieldLabel('LinkedPages')
                )
            ]
        );
        
        // Create Options Fields:
        
        $fields->addFieldToTab(
            'Root.Options',
            FieldSection::create(
                'NavigationOptions',
                $this->fieldLabel('NavigationOptions'),
                [
                    DropdownField::create(
                        'SortBy',
                        $this->fieldLabel('SortBy'),
                        $this->getSortByOptions()
                    ),
                    CheckboxField::create(
                        'ShowIcons',
                        $this->fieldLabel('ShowIcons')
                    )
                ]
            )
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
1298296
public function getMalUrls(): array
    {
        if (!$this->imageLinks) {
            $this->crawler->filterXPath('//a/img')->each(
                function (Crawler $c) {
                    $node = $c->parents()->first()->getNode(0);
                    /** @noinspection NullPointerExceptionInspection */
                    $node->parentNode->removeChild($node);
                }
            );
        }

        $xpath = sprintf('//a[contains(@href, "%s/%s")]', Constants::BASE_URL, $this->type);

        return $this->crawler
            ->filterXPath($xpath)
            ->each(
                function (Crawler $c) {
                    return (new MalUrlParser($c))->getModel();
                }
            );
    }
172564
public function getLinkAttributes()
    {
        $attributes = [
            'href' => $this->owner->Link,
            'title' => $this->owner->LinkTitle
        ];
        
        if ($class = $this->owner->LinkClass) {
            $attributes['class'] = $class;
        }
        
        if ($this->owner->OpenLinkInNewTab) {
            $attributes['target'] = '_blank';
        }
        
        return $attributes;
    }
1249754
public function getLinkedEntities()
    {
        $linkedClasses = array();
        foreach ($this->config as $entityConfig) {
            foreach ($entityConfig as $fieldId => $field) {
                if (isset($field['type']) && EntityMapper::isEntityField($field['type'] && isset($field['field_options']) && isset($field['field_options']['class']))) {
                    $linkedClasses[] = array(
                        'fieldId' => $fieldId,
                        'class' => $field['field_options']['class'],
                    );
                }
            }
        }

        return $linkedClasses;
    }
898029
public function mapLinks()
    {
        if (!is_array($this->get_field('widget_header_links')) || empty($this->get_field('widget_header_links'))) {
            return false;
        }

        $avalibleLinkTypes = array(
            'external_link' => array(
                'classes'       => 'c-nav__link',
                'attributes'    => '',
                'template'      => 'widget.header-links.partials.link'
            ),
            'internal_link' => array(
                'classes'       => 'c-nav__link',
                'attributes'    => '',
                'template'      => 'widget.header-links.partials.link'
            ),
            'search_trigger' => array(
                'classes'       => 'o-reset-button u-nowrap c-nav__link js-search-trigger pricon pricon-search toggle-search-top',
                'attributes'    => 'onclick="return false;"',
                'text'          => 'Search',
                'template'      => 'widget.header-links.partials.button'
            ),
            'menu_trigger' => array(
                'classes'       => 'u-nowrap hamburger hamburger--slider menu-trigger',
                'attributes'    => 'aria-controls="navigation" aria-expanded="true/false" onclick="jQuery(this).toggleClass(\'is-active\');" data-target="#mobile-menu"',
                'text'          => __("Menu", 'municipio'),
                'template'      =>  'widget.header-links.partials.burger'
            ),
            'translate_trigger' => array(
                'classes'       => 'c-nav__link js-translate-trigger',
                'attributes'    => '',
                'text'          => 'Translate',
                'url'           => '#translate'
            )
        );

        $avalibleLinkTypes = apply_filters('Municipio/Widget/Header/Links/MapLinks/avalibleLinkTypes', $avalibleLinkTypes, $this->data['args'], $this->data['instance']);

        $links = array();
        foreach ($this->get_field('widget_header_links') as $key => $link) {
            //Check if ACF layout key exists within $avalibleLinkTypes
            if (isset($avalibleLinkTypes[$link['acf_fc_layout']])) {
                $links[$key] = array_merge($link, $avalibleLinkTypes[$link['acf_fc_layout']]);

                //Add icon classes if icon exists
                if (isset($link['icon']) && $link['icon']) {
                    $links[$key]['classes'] .= ' u-nowrap c-navbar__item_link--icon pricon ' .  $link['icon'];
                }

                if (!isset($links[$key]['url'])) {
                    $links[$key]['url'] = '#';
                }
            }
        }

        $links = apply_filters('Municipio/Widget/Header/Links/MapLinks', $links, $this->data['args'], $this->data['instance']);
        return $links;
    }
589862
def get_links(self, **kw):
        

        links = [a for a in dir(self) if isinstance(getattr(self, a), Model)
                 and not a.startswith('_model')]

        return [
            {
                'field': l,
                'mdl': getattr(self, l).__class__,
            } for l in links
        ]
606356
public function getLinkURL($field)
    {
        $link_attr = self::decodeLinkObject($this->get($field));

        if(!is_object($link_attr)) {
            return $this->get($field);
        }
        if(!(strlen($link_attr->href) && strlen($link_attr->title) && strlen($link_attr->target))) {
            $field_attribs = $this->getField($field);
            if (array_key_exists('default', $field_attribs)) return $field_attribs['default'];
        }
        return $link_attr->href;
    }
647545
protected function getLinks()
	{
		$html = '';

		if (is_array($this->window['first'])) {
			$html .= $this->getUrlLinks($this->window['first']);
		}

		if (is_array($this->window['slider'])) {
			$html .= $this->getDots();
			$html .= $this->getUrlLinks($this->window['slider']);
		}

		if (is_array($this->window['last'])) {
			$html .= $this->getDots();
			$html .= $this->getUrlLinks($this->window['last']);
		}

		return $html;
	}
1005245
public function actionLinkToModels()
    {
        $rr = new RequestResponse();

        if ($rr->isRequestAjaxPost()) {
            try {
                if (!\Yii::$app->request->post('file_id') || !\Yii::$app->request->post('modelId') || !\Yii::$app->request->post('modelClassName') || !\Yii::$app->request->post('modelRelation')) {
                    throw new \yii\base\Exception("�� ���������� ������� ������");
                }

                $file = CmsStorageFile::findOne(\Yii::$app->request->post('file_id'));
                if (!$file) {
                    throw new \yii\base\Exception("�������� ���� ��� ������ ��� �� ����������");
                }

                if (!is_subclass_of(\Yii::$app->request->post('modelClassName'), ActiveRecord::className())) {
                    throw new \yii\base\Exception("���������� ��������� ���� � ���� ������");
                }

                $className = \Yii::$app->request->post('modelClassName');
                /**
                 * @var $model ActiveRecord
                 */
                $model = $className::findOne(\Yii::$app->request->post('modelId'));
                if (!$model) {
                    throw new \yii\base\Exception("������ � ������� ���������� ��������� ���� �� �������");
                }

                if (!$model->hasProperty(\Yii::$app->request->post('modelRelation'))) {
                    throw new \yii\base\Exception("� ������ �� ������ ������� �������� � ������ modelRelation: " . \Yii::$app->request->post('modelRelation'));
                }

                try {
                    $model->link(\Yii::$app->request->post('modelRelation'), $file);

                    if (!$file->name) {
                        $file->name = $model->name;
                        $file->save(false);
                    }

                    $rr->success = true;
                    $rr->message = "";
                } catch (\Exception $e) {
                    $rr->success = false;
                    $rr->message = $e->getMessage();
                }


            } catch (\Exception $e) {
                $rr->success = false;
                $rr->message = $e->getMessage();
            }

        }

        return $rr;
    }
339406
protected function getFieldDescriptors()
    {
        return [
            'uuid' => ElasticSearchFieldDescriptor::create('id', 'public.id')
                ->setDisabled(true)
                ->build(),
            'typeTranslation' => ElasticSearchFieldDescriptor::create('typeTranslation', 'sulu_article.list.type')
                ->setSortField('typeTranslation.raw')
                ->setDisabled(!$this->getParameter('sulu_article.display_tab_all'))
                ->build(),
            'title' => ElasticSearchFieldDescriptor::create('title', 'public.title')
                ->setSortField('title.raw')
                ->build(),
            'creatorFullName' => ElasticSearchFieldDescriptor::create('creatorFullName', 'sulu_article.list.creator')
                ->setSortField('creatorFullName.raw')
                ->build(),
            'changerFullName' => ElasticSearchFieldDescriptor::create('changerFullName', 'sulu_article.list.changer')
                ->setSortField('changerFullName.raw')
                ->build(),
            'authorFullName' => ElasticSearchFieldDescriptor::create('authorFullName', 'sulu_article.author')
                ->setSortField('authorFullName.raw')
                ->build(),
            'created' => ElasticSearchFieldDescriptor::create('created', 'public.created')
                ->setSortField('authored')
                ->setType('datetime')
                ->setDisabled(true)
                ->build(),
            'changed' => ElasticSearchFieldDescriptor::create('changed', 'public.changed')
                ->setSortField('authored')
                ->setType('datetime')
                ->setDisabled(true)
                ->build(),
            'authored' => ElasticSearchFieldDescriptor::create('authored', 'sulu_article.authored')
                ->setSortField('authored')
                ->setType('datetime')
                ->build(),
            'localizationState' => ElasticSearchFieldDescriptor::create('localizationState')
                ->setDisabled(true)
                ->build(),
            'published' => ElasticSearchFieldDescriptor::create('published')
                ->setDisabled(true)
                ->build(),
            'publishedState' => ElasticSearchFieldDescriptor::create('publishedState')
                ->setDisabled(true)
                ->build(),
            'routePath' => ElasticSearchFieldDescriptor::create('routePath')
                ->setDisabled(true)
                ->build(),
        ];
    }
1225536
public function getTypes()
    {
        $types = $this->config()->get('types');

        if ($this->allowed_types) {
            // Prioritise local field over global settings
            $allowed_types = $this->allowed_types;
        }
        if ($allowed_types = $this->config()->get('allowed_types')) {
           foreach ($allowed_types as $type) {
                if (!array_key_exists($type, $types)) {
                    user_error("{$type} is not a valid link type");
                }
            }

            foreach (array_diff_key($types, array_flip($allowed_types)) as $key => $value) {
                unset($types[$key]);
            }
        }
        $this->extend('updateTypes', $types);
        return $types;
    }
306728
public function getFieldTypes()
    {
        $fields = [];
        foreach ($this->fields as $name => $value) {
            $fields[$name] = isset($this->types[$name])
                ? $this->types[$name]
                : null
                ;
        }

        return $fields;
    }
1315276
protected function get_link_params() {
        $params = [];
        if (SITEID !== $this->calendar->course->id) {
            $params['course'] = $this->calendar->course->id;
        } else if (null !== $this->calendar->categoryid && $this->calendar->categoryid > 0) {
            $params['category'] = $this->calendar->categoryid;
        } else {
            $params['course'] = SITEID;
        }

        return $params;
    }
931599
public function getLinkType()
    {
        if ($this->_iLinkType === null) {
            $listType = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('listtype');
            if ('vendor' == $listType) {
                $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
            } elseif ('manufacturer' == $listType) {
                $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
            // @deprecated since v5.3 (2016-06-17); Listmania will be moved to an own module.
            } elseif ('recommlist' == $listType) {
                $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
                // END deprecated
            } else {
                $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;

                // price category has own type..
                $activeCategory = $this->getActiveCategory();
                if ($activeCategory && $activeCategory->isPriceCategory()) {
                    $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
                }
            }
        }

        return $this->_iLinkType;
    }
711636
public function getLinkModeOptions()
    {
        return [
            self::LINK_MODE_TITLE  => _t(__CLASS__ . '.TITLE', 'Title'),
            self::LINK_MODE_BUTTON => _t(__CLASS__ . '.BUTTON', 'Button'),
            self::LINK_MODE_BOTH   => _t(__CLASS__ . '.BOTHTITLEANDBUTTON', 'Both Title and Button')
        ];
    }
344135
public function listFieldTypesOptions() {
    $field_types_data = $this->loadFieldTypeData();

    $return = [];
    foreach ($field_types_data as $field_type_id => $field_type_info) {
      $return[$field_type_id] = $field_type_info['label'];
    }

    return $return;
  }