<?php
$references = mb_get_block_field("component-references");
//slider settings
$per_slide = mb_get_block_field("component-references-slider-slides");
$num_of_slides = count($references);
$heading = mb_get_block_field("heading");

$id = uniqid("references-slider-wrapper");

if ($references) { ?>
<section <?= inoby_block_attrs($attributes, ["class" => "component-references"]) ?>>
  <div class="container">
    <?php if($heading): ?>
    <div class="row row-head">
      <div class="col-12">
        <h2 class="underlined"><?= $heading ?></h2>
      </div>
    </div>
    <?php endif; ?>
    <div class="row">
      <div class="col-12 col-sm-12">
        <div
          <?= inoby_block_attrs($attributes, ["class" => "references-slider", "id" => $id, "data-slides" => $per_slide, "data-numslides" => $num_of_slides]) ?>>
          <?php foreach ($references as $reference): ?>
          <div class="reference-box">
            <div class="content-box">
              <?php
              if (!empty($reference["heading"])) {
                echo "<h4>" . $reference["heading"] . "</h4>";
              }
              if (!empty($reference["reference"])) {
                echo "<p>" . $reference["reference"] . "</p>";
              }
              ?>
            </div>
            <div class="author-box">
              <?php
              if (!empty($reference["author-image"])) {
                echo '<div class="author-image">';
                echo mb_inoby_picture($reference["author-image"], "s-2", ["sm" => "s-2", "md" => "s-2", "lg" => "s-2"], 100);
                echo "</div>";
              }
              if (!empty($reference["author"])) {
                echo '<div class="author-content"><p class="small">' . $reference["author"] . "</p></div>";
              }
              ?>
            </div>
          </div>
          <?php endforeach; ?>
        </div>
      </div>
    </div>
  </div>
</section>
<?php }