Ejemplo n.º 1
0
/** generates a CP Content Element Select list
 * @param string $field_name name of the select element
 * @param mixed $active array or id of the active element
 * @param string $javascript javascript
 * @return html string for the select
 */
function SelectContentElement($field_name, $active = null, $javascript)
{
    $content_elements = getInstalledContentElements();
    if (count($content_elements) < 2) {
        return '';
    }
    foreach ($content_elements as $ce) {
        $contentelements[] = JHTML::_('select.option', $ce->name, $ce->label);
    }
    return 'Content Type: ' . JHTML::_('select.genericlist', $contentelements, $field_name, $javascript . ' class="inputbox" size="1"', 'value', 'text', $active);
}
Ejemplo n.º 2
0
 /**
  * CP Utilities
  * @return void
  **/
 function display($tpl = null)
 {
     $task = JRequest::getCmd('task');
     switch ($task) {
         case 'checkdirs':
             $this->assignRef('dirs', getDirs());
             break;
         case 'showce':
             $this->assignRef('available_content_elements', getAvailableContentElements());
             $this->assignRef('installed_content_elements', getInstalledContentElements(true));
             break;
         default:
             break;
     }
     parent::display($tpl);
 }
 /**
  * CP Fields assign method
  * @return void
  **/
 function display($tpl = null)
 {
     // content element
     $ce_name = JRequest::getVar('ce_name', null, '', 'string');
     if (!empty($ce_name)) {
         if (!($content_element = getContentElementByName("{$ce_name}", true))) {
             $content_element = getContentElementByName("content", true);
             $ce_name = 'content';
         }
     } else {
         $content_elements = getInstalledContentElements();
         if (count($content_elements) > 0) {
             //return the first CE available
             $content_element = current($content_elements);
             $ce_name = $content_element->name;
         } else {
             $content_element = getDefaultContentElement();
             $ce_name = $content_element->name;
         }
     }
     // content items
     $content = $this->getModel('content', 'custompropertiesModel');
     $items = $content->getList($content_element);
     $page = $content->getPagination($content_element);
     // CP fields
     $cp = $this->getModel('cpfields', 'custompropertiesModel');
     $cpfields = $cp->getList(false);
     // properties
     $assign =& $this->getModel();
     $content_id = $assign->_id;
     $item_title = $assign->getTitle();
     $this->assignRef('items', $items);
     $this->assignRef('page', $page);
     $this->assignRef('content_element', $content_element);
     $this->assignRef('ce_name', $ce_name);
     $this->assignRef('cpfields', $cpfields);
     $this->assignRef('content_id', $content_id);
     $this->assignRef('item_title', $item_title);
     parent::display($tpl);
 }
/** Loads a cpContentElement by option (com_content, com_docman, ...)
 * @param string $option option (com_content, com_docman, ...)
 * @param boolean $load_inactive load inactive content elements, default false
 * @return cpContentElement or false if it does nor exists
 */
function getContentElementByOption($option, $load_inactive = false)
{
    // TODO cacheing!
    $content_elements = getInstalledContentElements($load_inactive);
    foreach ($content_elements as $ce) {
        if ($ce->href_option == "{$option}") {
            return $ce;
        }
    }
    return false;
}
Ejemplo n.º 5
0
    case 2:
    default:
        $view = "fullintro";
        break;
}
echo "\r\n<table class=\"contentpaneopen" . $params->get('pageclass_sfx') . "\">\r\n\t<tr>\r\n\t\t<td>\n";
// filter by content element type
$content_elements = array();
if ($content_element = JRequest::getVar('content_element', '')) {
    if ($ce = getContentElementByName($content_element)) {
        $content_elements[] = $ce;
    }
}
// I didn't get any valid content element, get all avaible
if (!$content_elements) {
    $content_elements = getInstalledContentElements();
}
foreach ($content_elements as $ce) {
    if (!empty($results[$ce->name])) {
        if ($show_ce_label) {
            echo "<div class=\"cp_ce_label\">" . $ce->label . "</div>";
        }
        foreach ($results[$ce->name] as $ce_name => $row) {
            if ($row->created) {
                $created = JHTML::Date($row->created);
            } else {
                $created = '';
            }
            echo "<div class=\"cp_result\">\n";
            switch ($view) {
                case 'title':
Ejemplo n.º 6
0
 /** Function that returns data for all content elements.
  * It also fills Search summary, Page nav and search result
  * @param mixed $tag  when set, returns all rows with the relevant tag
  * @return void
  */
 function getData($tag = "")
 {
     $user = JFactory::getUser();
     $aid = $user->get('aid');
     $params = $this->_params;
     $ordering = $this->_ordering;
     $search_pars = array();
     $this->_errors = array();
     // reset errors
     if ($aid < $this->_params->get('result_acl')) {
         $this->setError("result_acl");
     }
     if ($tag != "") {
         // add tag to page title
         if ($tagname = getTagNamebyId($tag, $params)) {
             $this->_tagname = $tagname;
         }
     }
     // filter by content element type
     $content_elements = array();
     if ($content_element = JRequest::getVar('content_element')) {
         if ($ce = getContentElementByName($content_element)) {
             $content_elements[] = $ce;
         }
     }
     // I didn't get any valid content element, get all avaible
     if (!$content_elements) {
         $content_elements = getInstalledContentElements();
     }
     $total = 0;
     $cpq = array();
     foreach ($content_elements as $key => $ce) {
         $cpq[$ce->name] = new CPQuery();
         if ($buffer = $cpq[$ce->name]->getRows($ce, $this->_search_pars, $tag, null, $ordering, 0, $params)) {
             $result[$ce->name] = $buffer;
             $total += count($result[$ce->name]);
         } elseif ($buffer === false) {
             foreach ($cpq[$ce->name]->errors as $error_code) {
                 $this->setError($error_code);
             }
             return;
         } elseif (count($buffer) === 0) {
             /* this ce does not contain any matching record,
              * remove it from content_elements list so that we don't process
              * it nay further
              */
             unset($content_elements[$key]);
         }
     }
     // no point in creating pagination or summary
     // with no result to show
     if ($total === 0) {
         $this->setError("no match");
         return;
     }
     //PAGINATION
     $limit = JRequest::getVar('limit', $params->get('limit'), '', 'int');
     $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
     jimport('joomla.html.pagination');
     if ($total <= $limitstart) {
         $limitstart = 0;
     }
     $pageNav = new JPagination($total, $limitstart, $limit);
     $this->_page =& $pageNav;
     /* creates a Result summary that is a list of sections with relevant number of articles found	*/
     if ($params->get('show_result_summary')) {
         $this->_result_summary = $this->_createResultSummary($content_elements, $cpq, $ordering);
     }
     // unset rows out of pagination
     $i = 0;
     foreach ($result as $key => $value) {
         foreach ($result[$key] as $ce => $val) {
             if ($i < $limitstart || $i >= $limitstart + $limit) {
                 unset($result[$key][$ce]);
             }
             $i++;
         }
     }
     $this->_data = $result;
     return $result;
 }