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

class Core_View_Helper_SavecollectionSheet extends Zend_View_Helper_Abstract
{
  protected static $_rendered = false;

  /**
   * Render the Add to Collection sheet once per page.
   * Returns empty string if feature is disabled or viewer is not authenticated.
   *
   * @return string
   */
  public function savecollectionSheet()
  {
    // Only render once per page
    if (self::$_rendered) {
      return '';
    }

    // Check if feature is enabled
    $api = Engine_Api::_()->getApi('savecollection', 'core');
    if (!$api->isEnabled()) {
      return '';
    }

    // Check viewer authentication
    $viewer = Engine_Api::_()->user()->getViewer();
    if (!$viewer || !$viewer->getIdentity()) {
      return '';
    }

    self::$_rendered = true;

    return $this->view->partial('savecollection/_sheet.tpl', 'core', array());
  }
}
