Ejemplo n.º 1
0
 /**
  * Generates a list of RSS feed items.
  *
  * @return    void
  */
 function display()
 {
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $doc->link = htmlspecialchars(JFactory::getURI()->toString());
     $feed_email = $app->getCfg('feed_email') == '' ? 'site' : $app->getCfg('feed_email');
     $site_email = $app->getCfg('mailfrom');
     // Set the query limit to the feed setting
     JRequest::setVar('limit', (int) $app->getCfg('feed_limit', 20));
     // Get model data
     $rows = $this->get('Items');
     foreach ($rows as $row) {
         // URL link to item
         $link = JRoute::_(PFdesignsHelperRoute::getDesignsRoute($row->project_slug, $row->slug));
         // Strip html from feed item title
         $title = $this->escape($row->title);
         $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
         $author = $row->author_name;
         $desc = $row->description;
         $date = $row->created ? date('r', strtotime($row->created)) : '';
         // Load individual item creator class
         $item = new JFeedItem();
         $item->title = $title;
         $item->link = $link;
         $item->description = $desc;
         $item->date = $date;
         $item->author = $author;
         $item->authorEmail = $feed_email == 'site' ? $site_email : $row->author_email;
         // Loads item info into the RSS array
         $doc->addItem($item);
     }
 }
Ejemplo n.º 2
0
 /**
  * Returns a list of buttons for the frontend
  *
  * @return    array
  */
 public static function getSiteButtons()
 {
     $buttons = array();
     if (JFactory::getUser()->authorise('core.create', 'com_pfdesigns')) {
         $buttons[] = array('title' => 'COM_PFDESIGNS_ADD_DESIGN', 'link' => PFdesignsHelperRoute::getDesignsRoute() . '&task=designform.add', 'icon' => JHtml::image('com_pfdesigns/header/icon-48-designs.add.png', JText::_('COM_PFDESIGNS_ADD_DESIGN'), null, true));
     }
     return $buttons;
 }
Ejemplo n.º 3
0
 protected function getTitleLink()
 {
     if ($this->client_id) {
         $link = 'index.php?option=' . $this->item->extension . '&task=' . $this->item->name . '.edit' . '&id=' . (int) $this->item->item_id;
     } else {
         $meta =& $this->item->metadata;
         $item_slug = $this->item->item_id . ':' . $meta->get('alias');
         $p_slug = $this->item->xref_id . ':' . $meta->get('p_alias');
         if ($this->item->name == 'album') {
             $link = PFdesignsHelperRoute::getDesignsRoute($p_slug, $item_slug);
         }
         if ($this->item->name == 'design') {
             $a_slug = $meta->get('a_id') ? $meta->get('a_id') . ':' . $meta->get('a_alias') : 0;
             $link = PFdesignsHelperRoute::getDesignRoute($item_slug, $p_slug, $a_slug);
         }
         if ($this->item->name == 'revision') {
             $d_slug = intval($meta->get('d_id')) . ':' . $meta->get('d_alias');
             $a_slug = $meta->get('a_id') ? intval($meta->get('a_id')) . ':' . $meta->get('a_alias') : 0;
             $link = PFdesignsHelperRoute::getDesignRoute($d_slug, $p_slug, $a_slug, $item_slug);
         }
     }
     return JRoute::_($link);
 }
Ejemplo n.º 4
0
 /**
  * Method to generate the email message
  *
  * @param     object     $lang         Instance of the default user language
  * @param     object     $receiveer    Instance of the the receiving user
  * @param     object     $user         Instance of the user who made the change
  * @param     object     $after        Instance of the item table after it was updated
  * @param     object     $before       Instance of the item table before it was updated
  * @param     boolean    $is_new       True if the item is new ($before will be null)
  *
  * @return    string
  */
 public static function getRevisionMessage($lang, $receiver, $user, $after, $before, $is_new)
 {
     if (!$is_new) {
         if (isset($after->approved)) {
             $fields = array('title' => $after->title, 'file_name' => $after->file_name, 'file_size' => $after->file_size . 'kb', 'created_by' => $after->created_by, 'description' => $after->description);
             $format = $lang->_('COM_PROJECTFORK_DESIGN_REV_EMAIL_' . ($after->approved ? 'APPROVED' : 'DECLINED') . '_MESSAGE');
         } else {
             return false;
         }
     } else {
         // Get the changed fields
         $fields = array('title' => $after->title, 'file_name' => $after->file_name, 'file_size' => $after->file_size . 'kb', 'description' => $after->description);
         $txt_prefix = 'COM_PROJECTFORK_DESIGN_REV_EMAIL_' . ($is_new ? 'NEW' : 'UPD');
         $format = $lang->_($txt_prefix . '_MESSAGE');
     }
     $album = self::getAlbumId($after->parent_id);
     $changes = PFnotificationsHelper::formatChanges($lang, $fields);
     $footer = sprintf($lang->_('COM_PROJECTFORK_EMAIL_FOOTER'), JURI::root());
     $link = JURI::base(false) . JRoute::_(PFdesignsHelperRoute::getDesignRoute($after->parent_id, $after->project_id, $album, $after->id));
     $txt = sprintf($format, $receiver->name, $user->name, $changes, $link);
     $txt = str_replace('\\n', "\n", $txt . "\n\n" . $footer);
     return $txt;
 }
Ejemplo n.º 5
0
 /**
  * Method to get the thumbnail links of an item
  *
  * @param     object    $item    The design or revision object
  * @param     string    $type    The item type (design or revision)
  *
  * @return    void
  */
 public static function getThumbnails(&$item, $type = 'design')
 {
     static $preview_img = null;
     static $full_img = null;
     static $cover_img = null;
     $global_params = JComponentHelper::getParams('com_pfdesigns', true);
     // Set preview image class instance
     if (is_null($preview_img)) {
         $options = array();
         $options['crop'] = true;
         $options['quality'] = 60;
         $options['size'] = $global_params->get('img_preview_size', '300x200');
         $preview_img = JModelLegacy::getInstance('Image', 'PFdesignsModel', $options);
     }
     // Set full image class instance
     if (is_null($full_img)) {
         $options = array();
         $options['crop'] = true;
         $options['quality'] = 80;
         $options['size'] = $global_params->get('img_full_size', '1280x720');
         $full_img = JModelLegacy::getInstance('Image', 'PFdesignsModel', $options);
     }
     // Set cover image class instance
     if (is_null($cover_img)) {
         $options = array();
         $options['crop'] = true;
         $options['quality'] = 75;
         $options['size'] = $global_params->get('img_cover_size', '770x300');
         $cover_img = JModelLegacy::getInstance('Image', 'PFdesignsModel', $options);
     }
     // Try to find the media file
     $uploadpath = PFdesignsHelper::getBasePath($item->project_id);
     $item->file_exists = JFile::exists($uploadpath . '/' . $item->file_name);
     if ($item->file_exists) {
         // Find out whether the image is cached or not
         $preview_img->setCacheId($type, $item->project_id, $item->id);
         $item->preview_cached = $preview_img->isCached();
         $full_img->setCacheId($type, $item->project_id, $item->id);
         $item->full_cached = $full_img->isCached();
         $cover_img->setCacheId($type, $item->project_id, $item->id);
         $item->cover_cached = $cover_img->isCached();
         if ($type == 'design') {
             $link = PFdesignsHelperRoute::getDesignRoute($item->slug, $item->project_slug, $item->album_slug, '0:original');
             $item->preview_source = $item->preview_cached ? $preview_img->getCachedURL() : JRoute::_($link . '&tmpl=component&layout=preview&format=raw');
             $item->full_source = $item->full_cached ? $full_img->getCachedURL() : JRoute::_($link . '&tmpl=component&layout=full&format=raw');
             $item->cover_source = $item->cover_cached ? $cover_img->getCachedURL() : JRoute::_($link . '&tmpl=component&layout=cover&format=raw');
         } else {
             $link = 'index.php?option=com_pfdesigns&view=revision&id=' . $item->slug;
             $item->preview_source = $item->preview_cached ? $preview_img->getCachedURL() : JRoute::_($link . '&tmpl=component&layout=preview&format=raw');
             $item->full_source = $item->full_cached ? $full_img->getCachedURL() : JRoute::_($link . '&tmpl=component&layout=full&format=raw');
         }
     } else {
         list($p_w, $p_h) = explode('x', $global_params->get('img_preview_size', '400x300'), 2);
         list($c_w, $c_h) = explode('x', $global_params->get('img_cover_size', '770x300'), 2);
         $item->preview_source = JHtml::_('image', 'com_pfdesigns/preview-missing-' . intval($p_w) . 'x' . intval($p_h) . '.jpg', 'placeholder', null, true, true);
         $item->full_source = JHtml::_('image', 'com_pfdesigns/full-missing.jpg', 'placeholder', null, true, true);
         $item->cover_source = JHtml::_('image', 'com_pfdesigns/cover-missing-' . intval($p_w) . 'x' . intval($p_h) . '.jpg', 'placeholder', null, true, true);
     }
 }
Ejemplo n.º 6
0
 $span = 12 / $cols;
 // Override image path?
 if ($prev == 1 && !is_null($item->revision)) {
     $item->preview_source = $item->revision->preview_source;
     $link = PFdesignsHelperRoute::getDesignRoute($item->slug, $item->project_slug, $item->album_slug, $item->revision->slug);
 }
 // Prepare the watch button
 $watch = '';
 if ($uid) {
     $options = array('div-class' => 'pull-right', 'a-class' => 'btn-mini');
     $watch = JHtml::_('pfhtml.button.watch', 'designs', $i, $item->watching, $options);
 }
 // Prepare title
 $title = '<a href="' . JRoute::_($link) . '">' . $this->escape($item->title) . '</a>';
 $project_title = '<a href="' . PFdesignsHelperRoute::getDesignsRoute($item->project_slug) . '">' . $this->escape($item->project_title) . '</a>';
 $album_title = '<a href="' . PFdesignsHelperRoute::getDesignsRoute($item->project_slug, $item->album_slug) . '">' . $this->escape($item->album_title) . '</a>';
 /*if (!$this->state->get('filter.project') && !$this->state->get('filter.album')) {
       if (!$item->album_id) {
           $lang = 'COM_PROJECTFORK_DESIGNS_DESIGN_TITLE_IN_PROJECT';
           $title .= ' <small>' . JText::sprintf($lang, $project_title) . '</small>';
       }
       else {
           $lang = 'COM_PROJECTFORK_DESIGNS_DESIGN_TITLE_IN_PROJECT_ALBUM';
           $title .= ' <small>' . JText::sprintf($lang, $project_title, $album_title) . '</small>';
       }
   }
   elseif (!$this->state->get('filter.project')) {
       $lang = 'COM_PROJECTFORK_DESIGNS_DESIGN_TITLE_IN_PROJECT';
       $title .= ' <small>' . JText::sprintf($lang, $project_title) . '</small>';
   }
   elseif (!$this->state->get('filter.album') && $item->album_id) {
Ejemplo n.º 7
0
 /**
  * Generates the toolbar for the top of the view
  *
  * @return    string    Toolbar with buttons
  */
 protected function getToolbar()
 {
     $config = JComponentHelper::getParams('com_pfdesigns', true);
     $uid = JFactory::getUser()->get('id');
     $slug = $this->item->id . ':' . $this->item->alias;
     $return = base64_encode(JFactory::getURI()->toString());
     $rev = $this->item->revision;
     $access = PFdesignsHelper::getActions($this->item->id);
     $access2 = $rev ? PFdesignsHelper::getRevisionActions($rev->id) : null;
     // Get the permissions
     $is_owner = $uid == $this->item->created_by;
     $can_add = $access->get('core.create');
     $can_edit = $access->get('core.edit') || $access->get('core.edit.own') && $is_owner;
     $can_dl = $access->get('core.download');
     $can_zip = class_exists('ZipArchive');
     $can_edit_state = $access->get('core.edit.state');
     $can_delete = $access->get('core.delete');
     $can_approve = $access->get('core.approve');
     $has_approved = array_key_exists($uid, $this->item->approved);
     $has_declined = array_key_exists($uid, $this->item->declined);
     $list_view = 'designs';
     // Overwrite permissions when looking at a revision
     if ($rev) {
         $is_owner = $uid == $rev->created_by;
         $can_edit = $access2->get('core.edit') || $access2->get('core.edit.own') && $is_owner;
         $can_dl = $access2->get('core.download');
         $can_edit_state = $access2->get('core.edit.state');
         $can_delete = $access2->get('core.delete');
         $can_approve = $access2->get('core.approve');
         $has_approved = array_key_exists($uid, $rev->approved);
         $has_declined = array_key_exists($uid, $rev->declined);
         $list_view = 'revisions';
     }
     $options = array();
     if ($access->get('core.create')) {
         $options[] = array('text' => 'JACTION_ADD', 'task' => 'revisionform.add', 'access' => $access->get('core.create'));
     }
     if ($can_edit) {
         $options[] = array('text' => 'COM_PROJECTFORK_ACTION_EDIT', 'task' => $rev ? 'revisionform.edit' : 'designform.edit', 'access' => $can_edit);
     }
     PFToolbar::dropdownButton($options, array('icon' => 'icon-white icon-plus'));
     // Download button
     if ($can_dl) {
         $link = PFdesignsHelperRoute::getDesignRoute($this->item->slug, $this->item->project_slug, $this->item->album_slug, $rev ? $rev->slug : '0:original');
         PFToolbar::button('JACTION_DOWNLOAD', null, false, array('access' => true, 'icon' => 'icon-download', 'href' => $link . '&tmpl=component&layout=download&format=raw'));
     }
     // Approve and Decline buttons
     if ($can_approve) {
         $behavior = $config->get('approval_behavior', 'changeable');
         $final = $behavior == 'final';
         PFToolbar::group();
         if ($final && !$has_declined || !$final) {
             PFToolbar::button($has_approved ? 'COM_PFDESIGNS_ACTION_APPROVED' : 'COM_PFDESIGNS_ACTION_APPROVE', $has_approved || $final ? '' : ($rev ? 'revisionform.approve' : 'designform.approve'), false, array('access' => true, 'icon' => 'icon-thumbs-up', 'class' => 'btn' . ($has_approved ? ' btn-success active' . ($final ? ' disabled' : '') : ''), 'href' => !$final || $has_approved ? null : "javascript:confirmApprove('approve-design');", 'id' => 'approve-design'));
         }
         if (!$has_declined && !$has_approved) {
             PFToolbar::button('COM_PFDESIGNS_UNDECIDED', '', false, array('access' => true, 'href' => '#', 'icon' => '', 'class' => 'btn active'));
         }
         if ($final && !$has_approved || !$final) {
             PFToolbar::button($has_declined ? 'COM_PFDESIGNS_ACTION_DECLINED' : 'COM_PFDESIGNS_ACTION_DECLINE', $has_declined || $final ? '' : ($rev ? 'revisionform.decline' : 'designform.decline'), false, array('access' => true, 'icon' => 'icon-thumbs-down', 'class' => 'btn' . ($has_declined ? ' btn-danger active' . ($final ? ' disabled' : '') : ''), 'href' => !$final || $has_declined ? null : "javascript:confirmDecline('decline-design');", 'id' => 'decline-design'));
         }
         PFToolbar::group();
     }
     return PFToolbar::render();
 }
Ejemplo n.º 8
0
        echo $rev->preview_source;
        ?>
" alt="<?php 
        echo $this->escape(addslashes($item->title));
        ?>
"/>
                    </a>
                    <!-- Need to add the approved/declined count and checkbox here somewhere -->
                <?php 
    }
    ?>
                <?php 
    if ($revision_count <= (int) $this->params->get('show_recent', '1')) {
        ?>
                    <a href="<?php 
        echo JRoute::_(PFdesignsHelperRoute::getDesignRoute($item->slug, $item->project_slug, $item->album_slug, '0:original'));
        ?>
">
                        <img class="img-polaroid" src="<?php 
        echo $item->preview_source;
        ?>
" alt="<?php 
        echo $this->escape(addslashes($item->title));
        ?>
"/>
                    </a>
                <?php 
    }
    ?>
            </div>
            <!-- End recent revisions -->
Ejemplo n.º 9
0
    ?>
</p>
                        <?php 
    echo $this->pagination->getPagesLinks();
    ?>
                    </div>
                <?php 
}
?>
            </div>
            <!-- End Pagination -->

            <input type="hidden" id="boxchecked" name="boxchecked" value="0" />
            <input type="hidden" name="task" id="jform_task" value="" />
            <input type="hidden" name="return" value="<?php 
echo base64_encode(JRoute::_(PFdesignsHelperRoute::getAlbumsRoute(), false));
?>
" />
            <?php 
echo JHtml::_('form.token');
?>
        </form>
    </div>
    <?php 
if ($can_order) {
    ?>
        <?php 
    if (!$this->state->get('filter.project')) {
        ?>
            <div class="alert"><?php 
        echo JText::_('COM_PROJECTFORK_REORDER_DISABLED');
Ejemplo n.º 10
0
 /**
  * Get the return URL.
  * If a "return" variable has been passed in the request
  *
  * @return    string    The return URL.
  */
 protected function getReturnPage()
 {
     $return = JRequest::getVar('return', null, 'default', 'base64');
     if (empty($return) || !JUri::isInternal(base64_decode($return))) {
         return JRoute::_(PFdesignsHelperRoute::getDesignsRoute(), false);
     } else {
         return base64_decode($return);
     }
 }
Ejemplo n.º 11
0
 /**
  * Function that allows child controller access to model data after the data has been saved.
  *
  * @param     jmodel    $model    The data model object.
  * @param     array     $data     The validated data.
  *
  * @return    void
  */
 protected function postSaveHook(&$model, $data)
 {
     $task = $this->getTask();
     switch ($task) {
         case 'save2copy':
         case 'save2new':
             // No redirect because its already set
             break;
         case 'save2rev':
             $link = JRoute::_(PFdesignsHelperRoute::getDesignsRoute() . '&task=revisionform.add', false);
             $this->setRedirect($link);
             break;
         default:
             $this->setRedirect($this->getReturnPage() . ($task == 'upload' ? '#_' . $data['album_id'] : ''));
             break;
     }
 }
Ejemplo n.º 12
0
                <th width="15%">
                    <?php 
echo JHtml::_('grid.sort', 'JGRID_HEADING_CREATED_BY', 'a.created_by', $list_dir, $list_order);
?>
                </th>
                <th width="1%" class="nowrap">
                    <?php 
echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'a.id', $list_dir, $list_order);
?>
                </th>
            </tr>
        </thead>
        <tbody>
        <?php 
foreach ($this->items as $i => $item) {
    $onclick = "if (window.parent) window.parent." . $this->escape($function) . "('" . $item->id . "', '" . $this->escape(addslashes($item->title)) . "', null, " . "'" . $this->escape(PFdesignsHelperRoute::getDesignRoute($item->id, $item->project_id, $item->album_id)) . "', " . "'', null);";
    ?>
            <tr class="row<?php 
    echo $i % 2;
    ?>
">
                <td>
                    <a class="pointer" style="cursor: pointer;" onclick="<?php 
    echo $onclick;
    ?>
">
                        <?php 
    echo $this->escape($item->title);
    ?>
                    </a>
                </td>