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

class Fbclone_Form_Admin_Dashboard_EditHeading extends Engine_Form {

  public function init() {

    $this->setMethod('POST');
    
    $dashboardlink_id = Zend_Controller_Front::getInstance()->getRequest()->getParam('dashboardlink_id');
    $sublink = Zend_Controller_Front::getInstance()->getRequest()->getParam('sublink');

    $this->addElement('Text', "name", array(
        'label' => 'Enter category name.',
        'allowEmpty' => false,
        'required' => true,
    ));
    
    if(empty($sublink)) {
      $this->addElement('Select', 'type', array(
        'label' => 'Choose View Type',
        'multiOptions' => array(
          'horizontal' => 'Horizontal',
          'vertical' => 'Vertical',
        ),
        'value' => 'horizontal',
      ));
    }

    if($sublink) {
    
	    $this->addElement('Text', "url", array(
	        'label' => 'Enter the URL for this link.',
	    ));
	    
      $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 fa-image)',
      ));
      
      $this->addElement('Text', "fonticoncolor", array(
        'label' => 'Icon Color',
        'class' => 'SEcolor',
      ));
    
      $files = Engine_Api::_()->getDbTable('files', 'core')->getFilesAssoc();
      $view = Zend_Registry::isRegistered('Zend_View') ? Zend_Registry::get('Zend_View') : null;
      $fileLink = $view->baseUrl() . '/admin/files/';
      if(engine_count($files) > 1) {
        $description = $this->getTranslator()->translate('Choose from below the link Image your website. [Note: You can add a link image from the "File & Media Manager" section from here: <a href="%1$s" target="_blank">File & Media Manager.</a> Recommended Size: 16px*16px]');
        $description = vsprintf($description, array($fileLink));
          
        $this->addElement('Select', 'photo', array(
          'label' => '',
          'description' => $description,
          'escape' => false,
          'multiOptions' => $files,
        ));
        $this->photo->addDecorator('Description', array('placement' => Zend_Form_Decorator_Abstract::PREPEND, 'escape' => false));
      } else {
        $description = $this->getTranslator()->translate('There are currently no images in the <a href="%1$s" target="_blank"> File & Media Manager </a> section of your site. Please begin by uploading an image to get started.');
        $description = vsprintf($description, array($fileLink));
        $description = "<div class='tip'><span>" . $description . "</span></div>";
        $this->addElement('Dummy', 'photo', array(
          'label' => "",
          'description' => $description,
        ));
        $this->photo->addDecorator('Description', array('placement' => Zend_Form_Decorator_Abstract::PREPEND, 'escape' => false));
      }
    }

    $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');
  }

}
