<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/

class Core_Form_Admin_Managedashboard_Addsublink extends Engine_Form {

  public function init() {

		$dashboardlink_id = Zend_Controller_Front::getInstance()->getRequest()->getParam('dashboardlink_id');
		$item = Engine_Api::_()->getItem('core_dashboardlinks', $dashboardlink_id);


    $this->setMethod('POST');

    $this->addElement('Text', "name", array(
        'label' => 'Enter link name.',
        'allowEmpty' => false,
        'required' => true,
    ));

    $this->addElement('Text', "url", array(
        'label' => 'Enter URL for this link.',
    ));

		if($item->type == 'vertical') {
			$this->addElement('Textarea', 'description', array(
				'label' => 'Enter Description for this link. This will not work with Horizontal type.',
				'filters' => array(
					new Engine_Filter_Censor(),
					new Engine_Filter_Html(array('AllowedTags' => array('a'))),
				),
				'maxlength' => "200",
			));
		}

    $this->addElement('Select', "icon_type", array(
        'label' => 'Choose the icon type',
        'allowEmpty' => false,
        'required' => true,
        'multiOptions' => array(
            '0' => 'Image Icon',
            '1' => "Font Icon",
        ),
        'onclick' => 'showIcon(this.value)',
        'value' => 0,
    ));

    $this->addElement('Text', "font_icon", array(
        'label' => 'Icon / Icon Class (Ex: fa-home)',
        //'allowEmpty' => false,
        //'required' => true,
    ));


    $this->addElement('File', 'photo', array(
        'label' => '',
       // 'allowEmpty' => false,
       // 'required' => true,
    ));
    $this->photo->addValidator('Extension', false, 'jpg,png,gif,jpeg,JPG,PNG,GIF,JPEG');

    // View Privacy Setting
    $levelOptions = array();
    $levelOptions[''] = 'Everyone';
    foreach (Engine_Api::_()->getDbtable('levels', 'authorization')->fetchAll() as $level) {
        $levelOptions[$level->level_id] = $level->getTitle();
    }
    $this->addElement('Multiselect', 'privacy', array(
        'label' => 'Member Level View Privacy',
        'description' => 'Choose the member levels to which this slide will be displayed. (Ctrl + Click to select multiple member levels.)',
        'allowEmpty' => true,
        'required' => false,
        'multiOptions' => $levelOptions,
        'value' => '',
    ));

    $this->addElement('Button', 'button', array(
        'type' => 'submit',
        'ignore' => true,
        'decorators' => array('ViewHelper')
    ));

    $this->addElement('Cancel', 'cancel', array(
        'label' => 'Cancel',
        'link' => true,
        'prependText' => ' or ',
        'onclick' => 'javascript:parent.Smoothbox.close()',
        'decorators' => array(
            'ViewHelper',
        ),
    ));
    $this->addDisplayGroup(array('button', 'cancel'), 'buttons');
  }

}
