Example #1
0
    function showCategories(&$rows, &$pageNav, $option)
    {
        global $mainframe;
        $db =& JFactory::getDBO();
        $config =& JFactory::getConfig();
        JHTML::_('behavior.tooltip');
        // action buttons
        JToolBarHelper::title('<h2 id="jwfpss-logo"></h2>', '');
        JToolBarHelper::publishList('publish_category');
        JToolBarHelper::unpublishList('unpublish_category');
        JToolBarHelper::addNew('new_category');
        JToolBarHelper::deleteList(_FPSS_SLIDES_ALERT_DELETE, 'delete_category');
        ?>
<h2><?php 
        echo _FPSS_CATEGORIES_LIST;
        ?>
</h2>
<form action="index2.php" method="post" name="adminForm">
  <table class="adminlist">
    <thead>
      <tr>
        <th>#</th>
        <th><input type="checkbox" name="toggle" value="" onClick="checkAll(<?php 
        echo count($rows);
        ?>
);" /></th>
        <th style="text-align:left;"><?php 
        echo _FPSS_CATEGORIES_ID;
        ?>
</th>
        <th><?php 
        echo _FPSS_CATEGORIES_NAME;
        ?>
</th>
        <th><?php 
        echo _FPSS_CATEGORIES_PUBLISHED;
        ?>
</th>
        <th><?php 
        echo _FPSS_CATEGORIES_NUM_SLIDES;
        ?>
</th>
        <th></th>
      </tr>
    </thead>
    <tfoot>
      <tr>
        <td colspan="10"><?php 
        echo $pageNav->getListFooter();
        ?>
 </td>
      </tr>
    </tfoot>
    <tbody>
      <?php 
        $k = 0;
        for ($i = 0, $n = count($rows); $i < $n; $i++) {
            $row =& $rows[$i];
            $link = JFilterOutput::ampReplace('index2.php?option=' . $option . '&amp;task=edit_category&amp;hidemainmenu=1&amp;cid[]=' . $row->id);
            $checked = JHTML::_('grid.checkedout', $row, $i);
            $published = mosFPSlideShow::PublishedProcessing($row, $i, "publish_category", "unpublish_category");
            ?>
      <tr class="<?php 
            echo "row{$k}";
            ?>
">
        <td><?php 
            echo $pageNav->getRowOffset($i);
            ?>
 </td>
        <td><?php 
            echo $checked;
            ?>
 </td>
        <td width="5px"><?php 
            echo $row->id;
            ?>
 </td>
        <td><a href="<?php 
            echo $link;
            ?>
"><?php 
            echo htmlspecialchars($row->name, ENT_QUOTES);
            ?>
</a> </td>
        <td><?php 
            echo $published;
            ?>
 </td>
        <td><?php 
            echo intval(mosFPSlideShow::showNumSlides($row->id));
            ?>
 </td>
        <td><a href="<?php 
            echo $_SERVER['PHP_SELF'];
            ?>
?option=<?php 
            echo $option;
            ?>
&amp;task=slides&amp;filter_catid=<?php 
            echo $row->id;
            ?>
"> <?php 
            echo _FPSS_CATEGORIES_SHOWSLIDES_LINK;
            ?>
 </a> </td>
        <?php 
            $k = 1 - $k;
            ?>
      </tr>
      <?php 
        }
        ?>
    </tbody>
  </table>
  <input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
  <input type="hidden" name="task" value="categories" />
  <input type="hidden" name="boxchecked" value="0" />
  <input type="hidden" name="hidemainmenu" value="0" />
  <?php 
        echo JHTML::_('form.token');
        ?>
</form>
<?php 
    }
Example #2
0
 function mosTreeRecurse($id, $indent, $list, &$children, $maxlevel = 9999, $level = 0, $type = 1, $parent = 'parent')
 {
     if (@$children[$id] and $level <= $maxlevel) {
         $newindent = $indent . ($type ? '.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' : '&nbsp;&nbsp;');
         $pre = $type ? '<sup>L</sup>&nbsp;' : '- ';
         foreach ($children[$id] as $v) {
             $id = $v->id;
             $list[$id] = $v;
             $list[$id]->treename = $indent . ($v->{$parent} == 0 ? '' : $pre) . $v->name;
             $list[$id]->children = count(@$children[$id]);
             $list[$id]->level = $level;
             $list = mosFPSlideShow::mosTreeRecurse($id, $newindent, $list, $children, $maxlevel, $level + 1, $type);
         }
     }
     return $list;
 }
Example #3
0
function saveSlide($option)
{
    global $mainframe;
    $limit = JRequest::getVar('limit', $mainframe->getCfg('list_limit'));
    $limitstart = JRequest::getVar('limitstart', 0);
    $db =& JFactory::getDBO();
    // Check for request forgeries
    JRequest::checkToken() or die('Invalid Token');
    // load config file
    require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . $option . DS . 'configuration.php';
    $config = new FPSSConfig();
    // load upload file
    require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . $option . DS . 'class.upload.php';
    $mosConfig_live_site = $mainframe->isAdmin() ? $mainframe->getSiteURL() : JURI::base();
    if (substr($mosConfig_live_site, -1) == "/") {
        $mosConfig_live_site = substr($mosConfig_live_site, 0, -1);
    }
    $mosConfig_absolute_path = JPATH_ROOT;
    $nullDate = $db->getNullDate();
    $option = JRequest::getCmd('option');
    $row =& JTable::getInstance('slide', 'Table');
    //JRequest::getVar( 'listdir', _FPSSBASEPATH, 'get', 'text' );
    $imageaction = JRequest::getVar('imageaction', 1, 'post', 'int');
    $oldpathtype = JRequest::getVar('oldpathtype', 0, 'post', 'int');
    $serverimage = JRequest::getVar('serverimage', '', 'post', 'text');
    $resize_x = JRequest::getVar('resize_x', '', 'post', 'int');
    $quality = JRequest::getVar('quality', '', 'post', 'int');
    if (!$row->bind(JRequest::get('post'))) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$_FILES['image']['size'] && $serverimage == "" && !$row->id) {
        $msg = _FPSS_SLIDE_ALERT_MUST_IMAGE;
        $mainframe->redirect('index.php?option=' . $option . '&task=slides&filter_catid=' . $_POST['filter_catid'] . '&limit=' . $limit . '&limitstart=' . $limitstart, $msg);
    }
    // LOAD CATEGORY PARAMS
    $catparams =& JTable::getInstance('category', 'Table');
    if ($row->catid) {
        $catparams->load($row->catid);
    } else {
        $catparams->load(intval($_POST['filter_catid']));
    }
    $width = $resize_x ? $resize_x : $catparams->width;
    $quality = $quality ? $quality : $catparams->quality;
    // CHECK AND UPLOADS IMAGE - THUMB
    if ($imageaction == 2) {
        // if action is to upload image
        if ($_FILES['image']['size'] > 0) {
            // if is selected an image
            if (!($image = mosFPSlideShow::uploadMedia($_FILES, 'image', $option, "", $width, $quality))) {
                // if the image is uploaded
                $msg = _FPSS_UPLOAD_FAIL;
                $mainframe->redirect('index.php?option=' . $option . '&task=slides&filter_catid=' . $row->catid . '&limit=' . $limit . '&limitstart=' . $limitstart, $msg);
                // $image the new path of the image
            }
            // delete the old image
            if ($row->id) {
                // if we edit a slide
                $sl =& JTable::getInstance('slide', 'Table');
                $sl->load((int) $row->id);
                if (file_exists($mosConfig_absolute_path . "/" . $sl->path) && $sl->path_type == 1) {
                    // if image exist and the image was from PC
                    @unlink($mosConfig_absolute_path . "/" . $sl->path);
                }
            }
            if ($config->septhumb == 1) {
                // if config says to upload separate thumbnail
                if ($_FILES['thumb']['size'] > 0) {
                    // if is selected an thumbnail
                    if (!($thumb = mosFPSlideShow::uploadMedia($_FILES, 'thumb', $option, "thumbs/", $catparams->width_thumb, $catparams->quality_thumb))) {
                        // if the thumb is uploaded
                        $msg = _FPSS_UPLOAD_FAIL_THUMB;
                        $mainframe->redirect('index.php?option=' . $option . '&task=slides&filter_catid=' . $row->catid . '&limit=' . $limit . '&limitstart=' . $limitstart, $msg);
                        // $thumb the new path of the image
                    }
                    // delete the old thumb
                    if ($row->id) {
                        // if we edit a slide
                        if (!is_object($sl)) {
                            $sl =& JTable::getInstance('slide', 'Table');
                            $sl->load((int) $row->id);
                        }
                        if (file_exists($mosConfig_absolute_path . "/" . $sl->thumb) && $sl->path_type == 1) {
                            // if thumb exist and the thumb was from PC
                            @unlink($mosConfig_absolute_path . "/" . $sl->thumb);
                        }
                    }
                } else {
                    if (!is_object($sl)) {
                        $sl =& JTable::getInstance('slide', 'Table');
                        $sl->load((int) $row->id);
                    }
                    if (!is_file($mosConfig_absolute_path . "/" . $sl->thumb)) {
                        // if thumb doesn't exist break the operation
                        $msg = _FPSS_UPLOAD_THUMB_NOTEXIST;
                        $mainframe->redirect('index.php?option=' . $option . '&task=slides&filter_catid=' . $row->catid . '&limit=' . $limit . '&limitstart=' . $limitstart, $msg);
                    }
                }
            } else {
                // if config says to use the main image to create the thumb
                if (!($thumb = mosFPSlideShow::uploadMedia($_FILES, 'image', $option, "thumbs/", $catparams->width_thumb, $catparams->quality_thumb))) {
                    $msg = _FPSS_UPLOAD_FAIL_THUMB;
                    $mainframe->redirect('index.php?option=' . $option . '&task=slides&filter_catid=' . $row->catid . '&limit=' . $limit . '&limitstart=' . $limitstart, $msg);
                    // $thumb the new path of the image
                }
                // delete the old thumb
                if ($row->id) {
                    // if we edit a slide
                    if (!is_object($sl)) {
                        $sl =& JTable::getInstance('slide', 'Table');
                        $sl->load((int) $row->id);
                    }
                    if (file_exists($mosConfig_absolute_path . "/" . $sl->thumb) && $sl->path_type == 1) {
                        // if thumb exist and the thumb was from PC
                        @unlink($mosConfig_absolute_path . "/" . $sl->thumb);
                    }
                }
            }
        }
    } elseif ($imageaction == 3) {
        // if the action is an image on the server
        // get the complete abs path
        $abspath = str_replace($mosConfig_live_site, $mosConfig_absolute_path, $serverimage);
        if (is_file($abspath)) {
            // if is selected an image
            if (!($image = mosFPSlideShow::uploadMediaServer($abspath, 'image', $option, "", $width, $quality))) {
                // if the image is uploaded
                $msg = _FPSS_UPLOAD_FAIL;
                $mainframe->redirect('index.php?option=' . $option . '&task=slides&filter_catid=' . $row->catid . '&limit=' . $limit . '&limitstart=' . $limitstart, $msg);
                // $image the new path of the image
            }
            // delete the old image
            if ($row->id) {
                // if we edit a slide
                $sl =& JTable::getInstance('slide', 'Table');
                $sl->load((int) $row->id);
                if (file_exists($mosConfig_absolute_path . "/" . $sl->path) && $sl->path_type == 1) {
                    // if image exist and the image was from PC
                    @unlink($mosConfig_absolute_path . "/" . $sl->path);
                }
            }
            if ($config->septhumb == 1) {
                // if config says to upload separate thumbnail
                if ($_FILES['thumb']['size'] > 0) {
                    // if is selected an thumbnail
                    if (!($thumb = mosFPSlideShow::uploadMedia($_FILES, 'thumb', $option, "thumbs/", $catparams->width_thumb, $catparams->quality_thumb))) {
                        // if the thumb is uploaded
                        $msg = _FPSS_UPLOAD_FAIL_THUMB;
                        $mainframe->redirect('index.php?option=' . $option . '&task=slides&filter_catid=' . $row->catid . '&limit=' . $limit . '&limitstart=' . $limitstart, $msg);
                        // $thumb the new path of the image
                    }
                    // delete the old thumb
                    if ($row->id) {
                        // if we edit a slide
                        if (!is_object($sl)) {
                            $sl =& JTable::getInstance('slide', 'Table');
                            $sl->load((int) $row->id);
                        }
                        if (file_exists($mosConfig_absolute_path . "/" . $sl->thumb) && $sl->path_type == 1) {
                            // if thumb exist and the thumb was from PC
                            @unlink($mosConfig_absolute_path . "/" . $sl->thumb);
                        }
                    }
                } else {
                    if (!is_object($sl)) {
                        $sl =& JTable::getInstance('slide', 'Table');
                        $sl->load((int) $row->id);
                    }
                    if (!is_file($mosConfig_absolute_path . "/" . $sl->thumb)) {
                        // if thumb doesn't exist break the operation
                        $msg = _FPSS_UPLOAD_THUMB_NOTEXIST;
                        $mainframe->redirect('index.php?option=' . $option . '&task=slides&filter_catid=' . $row->catid . '&limit=' . $limit . '&limitstart=' . $limitstart, $msg);
                    }
                }
            } else {
                // if config says to use the main image to create the thumb
                if (!($thumb = mosFPSlideShow::uploadMediaServer($abspath, 'image', $option, "thumbs/", $catparams->width_thumb, $catparams->quality_thumb))) {
                    $msg = _FPSS_UPLOAD_FAIL_THUMB;
                    $mainframe->redirect('index.php?option=' . $option . '&task=slides&filter_catid=' . $row->catid . '&limit=' . $limit . '&limitstart=' . $limitstart, $msg);
                    // $thumb the new path of the image
                }
                // delete the old thumb
                if ($row->id) {
                    // if we edit a slide
                    if (!is_object($sl)) {
                        $sl =& JTable::getInstance('slide', 'Table');
                        $sl->load((int) $row->id);
                    }
                    if (file_exists($mosConfig_absolute_path . "/" . $sl->thumb) && $sl->path_type == 1) {
                        // if thumb exist and the thumb was from PC
                        @unlink($mosConfig_absolute_path . "/" . $sl->thumb);
                    }
                }
            }
        }
    } elseif ($imageaction == 1) {
        if ($config->septhumb == 1) {
            // if config says to upload separate thumbnail
            if ($_FILES['thumb']['size'] > 0) {
                // if is selected an thumbnail
                if (!($thumb = mosFPSlideShow::uploadMedia($_FILES, 'thumb', $option, "thumbs/", $catparams->width_thumb, $catparams->quality_thumb))) {
                    // if the thumb is uploaded
                    $msg = _FPSS_UPLOAD_FAIL_THUMB;
                    $mainframe->redirect('index.php?option=' . $option . '&task=slides&filter_catid=' . $row->catid . '&limit=' . $limit . '&limitstart=' . $limitstart, $msg);
                    // $thumb the new path of the image
                }
                // delete the old thumb
                if ($row->id) {
                    // if we edit a slide
                    if (!is_object($sl)) {
                        $sl =& JTable::getInstance('slide', 'Table');
                        $sl->load((int) $row->id);
                    }
                    if (file_exists($mosConfig_absolute_path . "/" . $sl->thumb) && $sl->path_type == 1) {
                        // if thumb exist and the thumb was from PC
                        @unlink($mosConfig_absolute_path . "/" . $sl->thumb);
                    }
                }
            }
        }
    }
    if ($row->id) {
        // if we edit an slide, load the existened reccord
        if (!is_object($sl)) {
            $sl =& JTable::getInstance('slide', 'Table');
            $sl->load((int) $row->id);
        }
        $row->path = is_file($mosConfig_absolute_path . "/components/" . $option . "/images/" . $image) ? "components/" . $option . "/images/" . $image : $sl->path;
        $row->thumb = is_file($mosConfig_absolute_path . "/components/" . $option . "/images/thumbs/" . $thumb) ? "components/" . $option . "/images/thumbs/" . $thumb : $sl->thumb;
        $row->path_type = 1;
    } else {
        // if the slide is new
        $row->path = "components/" . $option . "/images/" . $image;
        $row->thumb = "components/" . $option . "/images/thumbs/" . $thumb;
        $row->path_type = 1;
    }
    // sanitise id field
    $row->id = (int) $row->id;
    $row->catid = (int) $row->catid;
    if ($row->publish_up == '') {
        $row->publish_up = $nullDate;
    }
    if (trim($row->publish_down) == 'Never' || trim($row->publish_down) == '') {
        $row->publish_down = $nullDate;
    }
    if ($row->publish_up > $row->publish_down) {
        $row->publish_up = $nullDate;
        $row->publish_down = $nullDate;
    }
    $row->state = JRequest::getVar('published', 0, 'post', 'int');
    $row->target = JRequest::getVar('target', 0, 'post', 'int');
    $row->itemlink = JRequest::getVar('contentid', 0, 'post', 'int');
    $row->registers = JRequest::getVar('registers', 0, 'post', 'int');
    $row->name = $name = JRequest::getVar('name', '', 'post', 'text');
    $row->ctext = JRequest::getVar('ctext', '', 'post', 'string', JREQUEST_ALLOWRAW);
    $row->plaintext = JRequest::getVar('plaintext', '', 'post', 'text');
    $row->showtitle = JRequest::getVar('showtitle', 0, 'post', 'int');
    $row->showseccat = JRequest::getVar('showseccat', 0, 'post', 'int');
    $row->showcustomtext = JRequest::getVar('showcustomtext', 0, 'post', 'int');
    $row->showplaintext = JRequest::getVar('showplaintext', 0, 'post', 'int');
    $row->showreadmore = JRequest::getVar('showreadmore', 0, 'post', 'int');
    $linkto = JRequest::getVar('linkto', 0, 'post', 'int');
    echo $linkto;
    switch ($linkto) {
        case 1:
            $row->itemlink = 0;
            $row->menulink = 0;
            $row->nolink = 0;
            break;
        case 2:
            $row->customlink = "";
            $row->menulink = 0;
            $row->nolink = 0;
            break;
        case 3:
            $row->customlink = "";
            $row->itemlink = 0;
            $row->nolink = 0;
            break;
        case 4:
        default:
            $row->customlink = "";
            $row->itemlink = 0;
            $row->menulink = 0;
            $row->nolink = 1;
            break;
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    $row->reorder('catid = ' . (int) $row->catid);
    $msg = _FPSS_SLIDE_SAVED;
    $mainframe->redirect('index.php?option=' . $option . '&task=slides&filter_catid=' . $row->catid . '&limit=' . $limit . '&limitstart=' . $limitstart, $msg);
}