Example #1
0
 /**
  * Get all contributors of all resources
  *
  * @return     array
  */
 public function getCons()
 {
     // get all eligible resource contributors
     $sql = "SELECT DISTINCT aa.user_id, SUM(r.ranking) as ranking FROM #__publication_authors AS aa " . " JOIN #__publication_versions AS v ON v.id=aa.publication_version_id " . " JOIN #__publications AS r ON r.id=v.publication_id " . " WHERE aa.user_id > 0 AND v.state=1 GROUP BY r.id, aa.user_id ";
     $this->_db->setQuery($sql);
     return $this->_db->loadObjectList();
 }
Example #2
0
 /**
  * Get all contributors of all resources
  *
  * @return  array
  */
 public function getCons()
 {
     // get all eligible resource contributors
     $sql = "SELECT DISTINCT aa.authorid, SUM(r.ranking) as ranking FROM #__author_assoc AS aa " . " LEFT JOIN #__resources AS r ON r.id=aa.subid " . " WHERE aa.authorid > 0 AND r.published=1 AND r.standalone=1 GROUP BY aa.authorid ";
     $this->_db->setQuery($sql);
     return $this->_db->loadObjectList();
 }
Example #3
0
    /**
     * Check a room to see if it is allowed to be booked in the period from $checkin -> $checkout
     *
     * @param int       $roomId
     * @param string    $checkin
     * @param string    $checkout
     * 
     * @return boolean  True if the room is ready to be booked, False otherwise
     */
    public function isRoomAvailable($roomId = 0, $checkin, $checkout)
    {
        $checkin = JFactory::getDate($checkin)->toUnix();
        $checkout = JFactory::getDate($checkout)->toUnix();
        $query = $this->_dbo->getQuery(true);
        $query->select('checkin, checkout');
        $query->from($this->_dbo->quoteName('#__sr_reservations') . ' as res');
        $query->join('INNER', $this->_dbo->quoteName('#__sr_reservation_room_xref') . ' as room
									ON res.id = room.reservation_id
									AND room.room_id = ' . $this->_dbo->quote($roomId));
        $query->where('res.checkout > NOW()');
        // TODO: pay attention to the state here, all reservation made in front-end should be set to Pending, Pending is not the same with Unpublished / Disabled
        //$query->where('res.state != 0');
        $query->order('res.checkin');
        $this->_dbo->setQuery($query);
        // Get all current reservations and their checkin/checkout date
        $result = $this->_dbo->loadObjectList();
        if (is_array($result)) {
            foreach ($result as $currentReservation) {
                $currentCheckin = JFactory::getDate($currentReservation->checkin)->toUnix();
                $currentCheckout = JFactory::getDate($currentReservation->checkout)->toUnix();
                if ($checkin <= $currentCheckin && $checkout > $currentCheckin || $checkin >= $currentCheckin && $checkout <= $currentCheckout || $checkin < $currentCheckout && $checkout >= $currentCheckout) {
                    return false;
                }
            }
        }
        return true;
    }
Example #4
0
 /**
  * Constructor
  * Loads points configuration
  *
  * @param   object  &$db  Database
  * @return  void
  */
 public function __construct(&$db)
 {
     $this->_db = $db;
     $this->_db->setQuery("SELECT * FROM `#__users_points_config`");
     $pc = $this->_db->loadObjectList();
     foreach ($pc as $p) {
         $this->set($p->alias, $p->points);
     }
 }
Example #5
0
 /**
  * Get a list of payees for a wish
  *
  * @param   integer  $wishid  Wish ID
  * @return  array
  */
 public function getPayees($wishid)
 {
     if (!$wishid) {
         return null;
     }
     $sql = "SELECT DISTINCT uid FROM `#__users_transactions` WHERE category='wish' AND referenceid={$wishid} AND type='hold'";
     $this->_db->setQuery($sql);
     return $this->_db->loadObjectList();
 }
Example #6
0
 /**
  * Get all configurations and populate $this
  *
  * @return     void
  */
 public function load()
 {
     $this->_db->setQuery("SELECT * FROM {$this->_tbl}");
     $configs = $this->_db->loadObjectList();
     if (empty($configs) || count($configs) <= 0) {
         if ($this->loadDefaults()) {
             $this->_db->setQuery("SELECT * FROM {$this->_tbl}");
             $configs = $this->_db->loadObjectList();
         }
     }
     if (!empty($configs)) {
         foreach ($configs as $config) {
             $b = $config->param;
             $this->{$b} = trim($config->value);
         }
     }
     $fields = array();
     if (trim($this->fields) != '') {
         $fs = explode("\n", trim($this->fields));
         foreach ($fs as $f) {
             $fields[] = explode('=', $f);
         }
     }
     $this->fields = $fields;
 }
Example #7
0
	/**
	 * Gets an array of objects from the results of database query.
	 *
	 * @param   string   $query       The query.
	 * @param   integer  $limitstart  Offset.
	 * @param   integer  $limit       The number of records.
	 *
	 * @return  array  An array of results.
	 *
	 * @since   12.2
	 * @throws  RuntimeException
	 */
	protected function _getList($query, $limitstart = 0, $limit = 0)
	{
		$this->_db->setQuery($query, $limitstart, $limit);
		$result = $this->_db->loadObjectList();

		return $result;
	}
Example #8
0
File: model.php Project: 01J/topm
 /**
  * Returns an object list
  *
  * @param   string   $query       The query
  * @param   integer  $limitstart  Offset from start
  * @param   integer  $limit       The number of records
  * @param   string   $group       The group by clause
  *
  * @return  array  Array of objects
  */
 protected function &_getList($query, $limitstart = 0, $limit = 0, $group = '')
 {
     $this->_db->setQuery($query, $limitstart, $limit);
     $result = $this->_db->loadObjectList($group);
     $this->onProcessList($result);
     return $result;
 }
Example #9
0
 /**
  * Fetch data for a particular time range
  *
  * @param      string $disp Data time range ti display
  * @return     array
  */
 public function fetch($disp)
 {
     switch (strtoupper($disp)) {
         case 'CURR':
             $period = 1;
             $caption = Lang::txt('Current Month');
             break;
         case 'LAST':
             $period = 2;
             $caption = Lang::txt('Last Month');
             break;
         case 'YEAR':
             $period = 12;
             $caption = Lang::txt('Last 12 Months');
             break;
         case 'ALL':
         default:
             $period = 14;
             $caption = Lang::txt('Total');
             break;
     }
     $sql = "SELECT * FROM #__publication_stats WHERE publication_id=" . $this->_pubid . "\n\t\t\tAND period=" . (int) $period . " ORDER BY datetime DESC LIMIT 1";
     $this->_db->setQuery($sql);
     $result = $this->_db->loadObjectList();
     $this->process($result);
     return array($caption, $period);
 }
Example #10
0
 /**
  * Parent display method for all views
  *
  * @param   boolean $cachable   If true, the view output will be cached
  * @param   array   $urlparams  An array of safe URL parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  * @return  void
  * @since   1.5.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     // Set a default view if none exists
     if (!($view = JRequest::getCmd('view'))) {
         JRequest::setVar('view', 'gallery');
     }
     // Increase hit counter in detail view if image view isn't used
     if ($view == 'detail' && $this->_config->get('jg_use_real_paths')) {
         $this->getModel('image')->hit(JRequest::getInt('id'));
     }
     parent::display($cachable, $urlparams);
     // Possibly delete zips
     if ($view == 'favourites' && $this->_config->get('jg_favourites') && ($this->_config->get('jg_zipdownload') || $this->_config->get('jg_usefavouritesforpubliczip'))) {
         $this->_db = JFactory::getDBO();
         $query = $this->_db->getQuery(true)->select('uid, uuserid, zipname')->from(_JOOM_TABLE_USERS)->where('zipname != ' . $this->_db->q(''))->where('time != ' . $this->_db->q(''))->where('time < NOW()-INTERVAL 60 SECOND');
         $this->_db->setQuery($query);
         $ziprows = $this->_db->loadObjectList();
         if (count($ziprows)) {
             jimport('joomla.filesystem.file');
             foreach ($ziprows as $row) {
                 if (JFile::exists($row->zipname)) {
                     JFile::delete($row->zipname);
                 }
                 if ($row->uuserid != 0) {
                     $query->clear()->update(_JOOM_TABLE_USERS)->set('zipname = ' . $this->_db->q(''))->set('time = ' . $this->_db->q(''))->where('uid = ' . (int) $row->uid);
                     $this->_db->setQuery($query);
                 } else {
                     $query->clear()->delete(_JOOM_TABLE_USERS)->where('uuserid = 0')->where('zipname = ' . $this->_db->q($row->zipname));
                     $this->_db->setQuery($query);
                 }
                 $this->_db->query();
             }
         }
     }
 }
Example #11
0
 /**
  * Get all reviews for resources
  *
  * @return  array
  */
 public function getReviews()
 {
     // get all eligible reviews
     $sql = "SELECT r.id, r.created_by AS author, r.publication_id as pid, " . "\n (SELECT COUNT(*) FROM #__abuse_reports AS a WHERE\n\t\t\ta.category='review' AND a.state!=1 AND a.referenceid=r.id) AS reports," . "\n (SELECT COUNT(*) FROM #__vote_log AS v WHERE v.helpful='yes'\n\t\t\tAND v.category='review' AND v.referenceid=r.id) AS helpful, " . "\n (SELECT COUNT(*) FROM #__vote_log AS v WHERE v.helpful='no'\n\t\t\tAND v.category='review' AND v.referenceid=r.id) AS nothelpful " . "\n FROM #__publication_ratings AS r";
     $this->_db->setQuery($sql);
     $result = $this->_db->loadObjectList();
     $reviews = array();
     if ($result) {
         foreach ($result as $r) {
             // item is not abusive, got at least 3 votes, more positive than negative
             if (!$r->reports && $r->helpful + $r->nothelpful >= 3 && $r->helpful > $r->nothelpful) {
                 $reviews[] = $r;
             }
         }
     }
     return $reviews;
 }
Example #12
0
 /**
  * Get a history of transactions
  *
  * @param   integer  $limit  Number of records to return
  * @return  array
  */
 public function history($limit = 20)
 {
     $lmt = "";
     if ($limit > 0) {
         $lmt .= " LIMIT " . $limit;
     }
     $this->_db->setQuery("SELECT * FROM `#__users_transactions` WHERE uid=" . $this->uid . " ORDER BY created DESC, id DESC" . $lmt);
     return $this->_db->loadObjectList();
 }
Example #13
0
 /**
  * Returns db-rows of images matching the search string
  * E.g. useful for a search mambot
  *
  * @param   string  $searchstring The string to use for the search
  * @param   array   $access       Access levels to filter for, null to use the ones of the current user
  * @param   string  $sorting      Sorting string
  * @param   int     $numPics      Limit number of images, leave away to return all
  * @param   int     $limitStart   Where to start returning $numPics images
  * @return  array   An array of image objects from the database
  * @since   1.0.0
  */
 public function getPicsBySearch($searchstring, $access = null, $sorting = null, $numPics = null, $limitStart = 0)
 {
     $query = $this->getImagesQuery($access);
     $this->addSearchTerms($query, $searchstring);
     if ($sorting) {
         $query->order($this->_db->escape($sorting));
     }
     $this->_db->setQuery($query, $limitStart, $numPics);
     return $this->_db->loadObjectList();
 }
Example #14
0
 /**
  * Process a single record
  *
  * @param   integer  $id
  * @return  object
  */
 public function record($id)
 {
     if (strstr($id, ':')) {
         list($id, $revision) = explode(':', $id);
     }
     $id = intval($id);
     if (!isset($revision)) {
         $revision = 0;
     }
     $this->database->setQuery("SELECT pv.*, pv.doi AS identifier, rt.alias AS type, pv.publication_id\n\t\t\tFROM `#__publication_versions` AS pv\n\t\t\tINNER JOIN `#__publications` AS p ON p.id = pv.publication_id\n\t\t\tINNER JOIN `#__publication_categories` AS rt ON rt.id = p.category\n\t\t\tWHERE pv.id = " . $this->database->quote($id));
     $record = $this->database->loadObject();
     $record->version_id = $record->id;
     $id = $record->publication_id;
     $record->id = $id;
     if (!$record->identifier) {
         $record->identifier = self::$base . '/' . ltrim(\Route::url('index.php?option=com_publications&id=' . $id . ($record->version_id ? '&v=' . $record->version_id : '')), '/');
     }
     $record->base = $this->name();
     $record->type = $record->base . ':' . $record->type;
     $record->description = strip_tags($record->description);
     $record->description = trim($record->description);
     $this->database->setQuery("SELECT pv.submitted\n\t\t\tFROM `#__publication_versions` pv, `#__publications` p\n\t\t\tWHERE p.id = pv.publication_id AND p.id = " . $this->database->quote($id) . "\n\t\t\tORDER BY pv.submitted DESC LIMIT 1");
     $record->date = $this->database->loadResult();
     $this->database->setQuery("SELECT pa.name\n\t\t\tFROM `#__publication_authors` pa, `#__publication_versions` pv, `#__publications` p\n\t\t\tWHERE pa.publication_version_id = pv.id AND pa.role != 'submitter' AND pv.publication_id = p.id AND p.id=" . $this->database->quote($id) . "\n\t\t\tORDER BY pa.name");
     $record->creator = $this->database->loadColumn();
     $this->database->setQuery("SELECT DISTINCT t.raw_tag\n\t\t\tFROM `#__tags` t, `#__tags_object` tos\n\t\t\tWHERE t.id = tos.tagid AND tos.objectid=" . $this->database->quote($id) . " AND tos.tbl='publications' AND t.admin=0\n\t\t\tORDER BY t.raw_tag");
     $record->subject = $this->database->loadColumn();
     // Relations
     $record->relation = array();
     $this->database->setQuery("SELECT *\n\t\t\tFROM `#__citations` AS a\n\t\t\tLEFT JOIN `#__citations_assoc` AS n ON n.`cid`=a.`id`\n\t\t\tWHERE n.`tbl`='publication' AND n.`oid`=" . $this->database->quote($id) . " AND n.`type`='owner' AND a.`published`=1\n\t\t\tORDER BY `year` DESC");
     $references = $this->database->loadObjectList();
     if (count($references) && file_exists(PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php')) {
         include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php';
         $formatter = new \Components\Citations\Helpers\Format();
         $formatter->setTemplate('apa');
         foreach ($references as $reference) {
             $cite = strip_tags(html_entity_decode($reference->formatted ? $reference->formatted : \Components\Citations\Helpers\Format::formatReference($reference, '')));
             $cite = str_replace('&quot;', '"', $cite);
             $record->relation[] = array('type' => 'isReferencedBy', 'value' => trim($cite));
         }
     }
     $this->database->setQuery("SELECT *\n\t\t\tFROM `#__citations` AS a\n\t\t\tLEFT JOIN `#__citations_assoc` AS n ON n.`cid`=a.`id`\n\t\t\tWHERE n.`tbl`='publication' AND n.`oid`=" . $this->database->quote($id) . " AND n.`type`!='owner' AND a.`published`=1\n\t\t\tORDER BY `year` DESC");
     $references = $this->database->loadObjectList();
     if (count($references) && file_exists(PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php')) {
         include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php';
         $formatter = new \Components\Citations\Helpers\Format();
         $formatter->setTemplate('apa');
         foreach ($references as $reference) {
             $cite = strip_tags(html_entity_decode($reference->formatted ? $reference->formatted : \Components\Citations\Helpers\Format::formatReference($reference, '')));
             $cite = str_replace('&quot;', '"', $cite);
             $record->relation[] = array('type' => 'references', 'value' => trim($cite));
         }
     }
     return $record;
 }
Example #15
0
 /**
  * Get all parents of a resource
  *
  * @return     boolean False if errors, true on success
  */
 public function getParents()
 {
     if ($this->_id == 0) {
         return false;
     }
     $sql = "SELECT DISTINCT r.id, r.title, r.alias, r.introtext, r.footertext, r.type, r.logical_type AS logicaltype,\n\t\t\t\tr.created, r.published, r.publish_up, r.path, r.standalone, r.hits, r.rating, r.times_rated, r.params, r.ranking,\n\t\t\t\tt.type AS logicaltitle, rt.type AS typetitle\n\t\t\t\tFROM #__resource_types AS rt, #__resources AS r\n\t\t\t\tJOIN #__resource_assoc AS a ON r.id=a.parent_id\n\t\t\t\tLEFT JOIN #__resource_types AS t ON r.logical_type=t.id\n\t\t\t\tWHERE r.published=1 AND a.child_id=" . $this->_id . " AND r.type=rt.id AND r.type!=8\n\t\t\t\tORDER BY a.ordering, a.grouping";
     $this->_db->setQuery($sql);
     $parents = $this->_db->loadObjectList();
     $this->parents = $parents;
     return true;
 }
Example #16
0
 /**
  * Method to compact the ordering values of rows in a group of rows
  * defined by an SQL WHERE clause.
  *
  * @param   string   $where  WHERE clause to use for limiting the selection of rows to
  *                           compact the ordering values.
  *
  * @return  mixed    Boolean true on success.
  *
  * @link    http://docs.joomla.org/JTable/reorder
  * @since   11.1
  */
 public function reorder($where = '')
 {
     // If there is no ordering field set an error and return false.
     if (!property_exists($this, 'ordering')) {
         $e = new JException(JText::sprintf('JLIB_DATABASE_ERROR_CLASS_DOES_NOT_SUPPORT_ORDERING', get_class($this)));
         $this->setError($e);
         return false;
     }
     // Initialise variables.
     $k = $this->_tbl_key;
     // Get the primary keys and ordering values for the selection.
     $query = $this->_db->getQuery(true);
     $query->select($this->_tbl_key . ', ordering');
     $query->from($this->_tbl);
     $query->where('ordering >= 0');
     $query->order('ordering');
     // Setup the extra where and ordering clause data.
     if ($where) {
         $query->where($where);
     }
     $this->_db->setQuery($query);
     $rows = $this->_db->loadObjectList();
     // Check for a database error.
     if ($this->_db->getErrorNum()) {
         $e = new JException(JText::sprintf('JLIB_DATABASE_ERROR_REORDER_FAILED', get_class($this), $this->_db->getErrorMsg()));
         $this->setError($e);
         return false;
     }
     // Compact the ordering values.
     foreach ($rows as $i => $row) {
         // Make sure the ordering is a positive integer.
         if ($row->ordering >= 0) {
             // Only update rows that are necessary.
             if ($row->ordering != $i + 1) {
                 // Update the row ordering field.
                 $query = $this->_db->getQuery(true);
                 $query->update($this->_tbl);
                 $query->set('ordering = ' . ($i + 1));
                 $query->where($this->_tbl_key . ' = ' . $this->_db->quote($row->{$k}));
                 $this->_db->setQuery($query);
                 // Check for a database error.
                 if (!$this->_db->query()) {
                     $e = new JException(JText::sprintf('JLIB_DATABASE_ERROR_REORDER_UPDATE_ROW_FAILED', get_class($this), $i, $this->_db->getErrorMsg()));
                     $this->setError($e);
                     return false;
                 }
             }
         }
     }
     return true;
 }
Example #17
0
 function _initTeams()
 {
     if (empty($this->_teams)) {
         $query = ' SELECT DISTINCT pi.team_id, ' . ' t.name AS team_name, t.short_name AS team_short_name, t.acronym AS team_acronym, t.country_code, t.picture_small AS team_logo, ' . ' CASE WHEN CHAR_LENGTH( t.alias ) THEN CONCAT_WS( \':\', t.id, t.alias ) ELSE t.id END AS slug ' . ' FROM #__tracks_participants AS pi ' . ' INNER JOIN #__tracks_teams AS t ON t.id = pi.team_id ' . ' WHERE pi.project_id = ' . $this->_project_id . ' ORDER BY t.name ';
         $this->_db->setQuery($query);
         $this->_teams = $this->_db->loadObjectList('team_id');
     }
     $results = array();
     if ($this->_teams) {
         foreach ($this->_teams as $i => $ind) {
             $results[$i] = clone $ind;
             $results[$i]->points = 0;
             $results[$i]->best_rank = 0;
             $results[$i]->wins = 0;
             $results[$i]->rank = null;
         }
     }
     return $results;
 }
Example #18
0
 /**
  * Gets an array of objects from the results of database query.
  *
  * @param   string   $query       The query.
  * @param   integer  $limitstart  Offset.
  * @param   integer  $limit       The number of records.
  *
  * @return  array  An array of results.
  *
  * @since   11.1
  */
 protected function _getList($query, $limitstart = 0, $limit = 0)
 {
     if (is_object($query)) {
         if ($query instanceof \Hubzero\Database\Query) {
             $query->limit($limit);
             $query->start($start);
         } else {
             if (!$this->_db instanceof JDatabase) {
                 $query = $query->__toString();
                 if ($limit > 0 || $limitstart > 0) {
                     $query .= ' LIMIT ' . $limitstart . ', ' . $limit;
                     $limit = 0;
                     $limitstart = 0;
                 }
             }
         }
     }
     $this->_db->setQuery($query, $limitstart, $limit);
     $result = $this->_db->loadObjectList();
     return $result;
 }
Example #19
0
 /**
  * Method to compact the ordering values of rows in a group of rows
  * defined by an SQL WHERE clause.
  *
  * @param	string	WHERE clause to use for limiting the selection of rows to
  * 					compact the ordering values.
  * @return	mixed	Boolean true on success.
  * @since	1.0
  * @link	http://docs.joomla.org/JTable/reorder
  */
 public function reorder($where = '')
 {
     // If there is no ordering field set an error and return false.
     if (!property_exists($this, 'ordering')) {
         $this->setError(get_class($this) . ' does not support ordering');
         return false;
     }
     // Initialise variables.
     $k = $this->_tbl_key;
     // Setup the extra where and ordering clause data.
     $where = $where ? ' AND ' . $where : '';
     $ordering = $this->_tbl == '#__content_frontpage' ? ', `content_id` DESC' : '';
     // Get the primary keys and ordering values for the selection.
     $this->_db->setQuery('SELECT `' . $this->_tbl_key . '`, `ordering`' . ' FROM `' . $this->_tbl . '`' . ' WHERE `ordering` >= 0' . $where . ' ORDER BY `ordering`' . $ordering);
     $rows = $this->_db->loadObjectList();
     // Check for a database error.
     if ($this->_db->getErrorNum()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Compact the ordering values.
     for ($i = 0, $n = count($rows); $i < $n; $i++) {
         // Make sure the ordering is a positive integer.
         if ($rows[$i]->ordering >= 0) {
             // Only update rows that are necessary.
             if ($rows[$i]->ordering != $i + 1) {
                 // Update the row ordering field.
                 $this->_db->setQuery('UPDATE `' . $this->_tbl . '`' . ' SET `ordering` = ' . ($i + 1) . ' WHERE `' . $this->_tbl_key . '` = ' . $this->_db->quote($rows[$i]->{$k}));
                 $this->_db->query();
                 // Check for a database error.
                 if ($this->_db->getErrorNum()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
             }
         }
     }
     return true;
 }
Example #20
0
 /**
  * Method to get a list of available rooms of a RoomType based on check in and check out date
  * 
  * @param   int     $roomtypeId
  * @param   int     $checkin
  * @param   int     $checkout
  * 
  * @return  mixed   An array of room object if successfully
  *                  otherwise return false
  */
 public function getListAvailableRoom($roomtypeId = 0, $checkin, $checkout)
 {
     $srReservation = SRFactory::get('solidres.reservation.reservation');
     $availableRooms = array();
     $query = $this->_dbo->getQuery(true);
     $query->select('id, label')->from($this->_dbo->quoteName('#__sr_rooms'));
     if ($roomtypeId > 0) {
         $query->where('room_type_id = ' . $this->_dbo->quote($roomtypeId));
     }
     $this->_dbo->setQuery($query);
     $rooms = $this->_dbo->loadObjectList();
     if (empty($rooms)) {
         return false;
     }
     foreach ($rooms as $room) {
         // If this room is available, add it to the returned list
         if ($srReservation->isRoomAvailable($room->id, $checkin, $checkout)) {
             $availableRooms[] = $room;
         }
     }
     return $availableRooms;
 }
Example #21
0
 function getData()
 {
     if (!is_null($this->data)) {
         return $this->data;
     }
     $limitstart = RdbsRequest::getVar('limitstart', '0', '', 'int');
     $limit = $this->getUserStateFromRequest('limit', 50);
     $this->db->setQuery("SELECT count(*) FROM {$this->table} ");
     $rc = $this->db->loadResult();
     if ($this->db->getErrorNum()) {
         return RdbsError::raiseError(500, $this->db->stderr());
     }
     $query = "SELECT * FROM {$this->table} ";
     $this->db->setQuery($query, $limitstart, $limit);
     $this->data = $this->db->loadObjectList();
     if ($this->db->getErrorNum()) {
         return RdbsError::raiseError(500, $this->db->stderr());
     }
     $this->page = new RdbsPagination($rc, $limitstart, $limit);
     $this->lists = array();
     return $this->data;
 }
Example #22
0
 /**
  * Get a list of parents of this resource
  *   Accepts either a numeric array index
  *   If index, it'll return the entry matching that index in the list
  *
  * @param      mixed $idx Index value
  * @return     array
  */
 public function parents($idx = null)
 {
     if (!$this->exists()) {
         return array();
     }
     if (!isset($this->parents)) {
         $this->parents = array();
         $sql = "SELECT DISTINCT r.id, r.title, r.alias, r.introtext, r.footertext, r.type, r.logical_type AS logicaltype,\n\t\t\t\t\tr.created, r.published, r.publish_up, r.path, r.standalone, r.hits, r.rating, r.times_rated, r.params, r.ranking,\n\t\t\t\t\tt.type AS logicaltitle, rt.type AS typetitle\n\t\t\t\t\tFROM #__resource_types AS rt, #__resources AS r\n\t\t\t\t\tJOIN #__resource_assoc AS a ON r.id=a.parent_id\n\t\t\t\t\tLEFT JOIN #__resource_types AS t ON r.logical_type=t.id\n\t\t\t\t\tWHERE r.published=1 AND a.child_id=" . $this->resource->id . " AND r.type=rt.id\n\t\t\t\t\tORDER BY a.ordering, a.grouping";
         $this->_db->setQuery($sql);
         if ($results = $this->_db->loadObjectList()) {
             $this->parents = $results;
         }
     }
     if ($idx !== null && is_numeric($idx)) {
         if (isset($this->parents[$idx])) {
             return $this->parents[$idx];
         } else {
             $this->setError(Lang::txt('Index not found: ') . __CLASS__ . '::' . __METHOD__ . '[' . $idx . ']');
             return false;
         }
     }
     return $this->parents;
 }
Example #23
0
 /**
  * Get wiki page
  *
  * @param      object $attachment
  * @param      object $publication
  * @param      string $masterscope
  * @param      string $versionid
  * @return     object
  */
 public function getWikiPage($pageid = NULL, $masterscope = NULL, $versionid = NULL)
 {
     if (!$pageid || !$this->exists()) {
         return false;
     }
     $query = "SELECT p.* ";
     if ($this->get('state') == 3) {
         // Draft - load latest version
         $query .= ", (SELECT v.pagetext FROM #__wiki_version as v WHERE v.pageid=p.id\n\t\t\t  ORDER by p.state ASC, v.version DESC LIMIT 1) as pagetext ";
     } else {
         $date = $this->accepted() ? $this->accepted() : $this->submitted();
         $date = $date ? $date : $this->published();
         $query .= ", (SELECT v.pagetext FROM #__wiki_version as v WHERE v.pageid=p.id AND ";
         $query .= $versionid ? " v.id=" . $versionid : " v.created <= '" . $date . "'";
         $query .= " ORDER BY v.created DESC LIMIT 1) as pagetext ";
     }
     $query .= " FROM #__wiki_page as p WHERE p.scope LIKE '" . $masterscope . "%' ";
     $query .= is_numeric($pageid) ? " AND p.id='{$pageid}' " : " AND p.pagename='{$pageid}' ";
     $query .= " LIMIT 1";
     $this->_db->setQuery($query);
     $result = $this->_db->loadObjectList();
     return $result ? $result[0] : NULL;
 }
Example #24
0
 /**
  * Get questions
  *
  * @return  array
  */
 public function getQuestions()
 {
     // get all closed questions
     $this->_db->setQuery("SELECT q.id, q.created_by AS q_owner, a.created_by AS a_owner\n\t\t\tFROM `#__answers_questions` AS q\n\t\t\tLEFT JOIN `#__answers_responses` AS a ON q.id=a.question_id AND a.state=1\n\t\t\tWHERE q.state=1");
     return $this->_db->loadObjectList();
 }
Example #25
0
 /**
  * Method to update index data on category access level changes
  *
  * @param   array    $pks    A list of primary key ids of the content that has changed state.
  * @param   integer  $value  The value of the state that the content has been changed to.
  *
  * @return  void
  *
  * @since   2.5
  */
 protected function categoryStateChange($pks, $value)
 {
     /*
      * The item's published state is tied to the category
      * published state so we need to look up all published states
      * before we change anything.
      */
     foreach ($pks as $pk) {
         $query = clone $this->getStateQuery();
         $query->where('c.id = ' . (int) $pk);
         // Get the published states.
         $this->db->setQuery($query);
         $items = $this->db->loadObjectList();
         // Adjust the state for each item within the category.
         foreach ($items as $item) {
             // Translate the state.
             $temp = $this->translateState($item->state, $value);
             // Update the item.
             $this->change($item->id, 'state', $temp);
             // Reindex the item
             $this->reindex($item->id);
         }
     }
 }
Example #26
0
 /**
  * Get a JSON formatted list of installed extensions
  * Needs to be public so we can call it from the audit.
  *
  * @return string
  */
 public function getExtensions()
 {
     // connect/get the Joomla db object
     $this->db = JFactory::getDbo();
     // crazy way of handling Joomla 1.5.x legacy :-(
     $one5 = FALSE;
     // Get Joomla 2.0+ Extensions
     $this->db->setQuery('SELECT e.extension_id, e.name, e.type, e.element, e.enabled, e.folder,
                             (
                              SELECT title
                              FROM #__menu AS m
                              WHERE m.component_id = e.extension_id
                              AND parent_id = 1
                              ORDER BY ID ASC LIMIT 1
                              )
                              AS title
                             FROM #__extensions AS e
                             WHERE protected = 0');
     $installedExtensions = $this->db->loadObjectList();
     // ok if we have none maybe we are Joomla < 1.5.26
     if (!$installedExtensions) {
         // Yooo hoo I'm on a crap old, out of date, probably hackable Joomla version!
         $one5 = TRUE;
         // Get the extensions - used to be called components
         $this->db->setQuery('SELECT "component" as "type", name, `option` as "element", enabled FROM #__components WHERE iscore != 1 and parent = 0');
         $components = $this->db->loadObjectList();
         // Get the plugins
         $this->db->setQuery('SELECT "plugin" as "type", name, element, folder, published as enabled FROM #__plugins WHERE iscore != 1');
         $plugins = $this->db->loadObjectList();
         // get the modules
         $this->db->setQuery('SELECT  "module" as "type", module, module as name, client_id, published as enabled FROM #__modules WHERE iscore != 1');
         $modules = $this->db->loadObjectList();
         /**
          * Get the templates - I n Joomla 1.5.x the templates are not in the
          * db unless published so we need to read the folders from the /templates folders
          * Note in Joomla 1.5.x there was no such think as admin templates
          */
         $folders = array_merge(scandir(JPATH_BASE . '/templates'), scandir(JPATH_ADMINISTRATOR . '/templates'));
         $templates = array();
         foreach ($folders as $templateFolder) {
             $f = JPATH_BASE . '/templates/' . trim($templateFolder);
             $a = JPATH_ADMINISTRATOR . '/templates/' . trim($templateFolder);
             // We dont want index.html etc...
             if (!is_dir($f) && !is_dir($a) || ($templateFolder == '.' || $templateFolder == '..')) {
                 continue;
             }
             if (is_dir($a)) {
                 $client_id = 1;
             } else {
                 $client_id = 0;
             }
             // make it look like we want like Joomla 2.5+ would
             $template = array('type' => 'template', 'template' => $templateFolder, 'client_id' => $client_id, 'enabled' => 1);
             // Convert to an obj
             $templates[] = json_decode(json_encode($template));
         }
         // Merge all the "extensions" we have found all over the place
         $installedExtensions = array_merge($components, $plugins, $modules, $templates);
     }
     $lang = JFactory::getLanguage();
     // Load all the language strings up front incase any strings are shared
     foreach ($installedExtensions as $k => $ext) {
         $lang->load(strtolower($ext->element) . ".sys", JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         $lang->load(strtolower($ext->element) . ".sys", JPATH_SITE, 'en-GB', TRUE);
         $lang->load(strtolower($ext->name) . ".sys", JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         $lang->load(strtolower($ext->name) . ".sys", JPATH_SITE, 'en-GB', TRUE);
         $lang->load(strtolower($ext->title) . ".sys", JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         $lang->load(strtolower($ext->title) . ".sys", JPATH_SITE, 'en-GB', TRUE);
         $lang->load(strtolower($ext->element), JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         $lang->load(strtolower($ext->element), JPATH_SITE, 'en-GB', TRUE);
         $lang->load(strtolower($ext->name), JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         $lang->load(strtolower($ext->name), JPATH_SITE, 'en-GB', TRUE);
         $lang->load(strtolower($ext->title), JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         $lang->load(strtolower($ext->title), JPATH_SITE, 'en-GB', TRUE);
         $element = str_replace('_TITLE', '', strtoupper($ext->element));
         $name = str_replace('_TITLE', '', strtoupper($ext->name));
         $title = str_replace('_TITLE', '', strtoupper($ext->title));
         $lang->load(strtolower($element) . ".sys", JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         $lang->load(strtolower($element) . ".sys", JPATH_SITE, 'en-GB', TRUE);
         $lang->load(strtolower($name) . ".sys", JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         $lang->load(strtolower($name) . ".sys", JPATH_SITE, 'en-GB', TRUE);
         $lang->load(strtolower($title) . ".sys", JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         $lang->load(strtolower($title) . ".sys", JPATH_SITE, 'en-GB', TRUE);
         $lang->load(strtolower($element), JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         $lang->load(strtolower($element), JPATH_SITE, 'en-GB', TRUE);
         $lang->load(strtolower($name), JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         $lang->load(strtolower($name), JPATH_SITE, 'en-GB', TRUE);
         $lang->load(strtolower($title), JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         $lang->load(strtolower($title), JPATH_SITE, 'en-GB', TRUE);
         // templates
         $lang->load('tpl_' . strtolower($name), JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         $lang->load('tpl_' . strtolower($name), JPATH_SITE, 'en-GB', TRUE);
         // Joomla 1.5.x modules
         $lang->load('mod_' . strtolower($name), JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         $lang->load('mod_' . strtolower($name), JPATH_SITE, 'en-GB', TRUE);
         // tut tut Akeeba - bad naming!
         $lang->load(strtolower('PLG_SYSTEM_SRP'), JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         // should be plg_srp
         $lang->load(strtolower('PLG_SYSTEM_ONECLICKACTION'), JPATH_SITE, 'en-GB', TRUE);
         // should be plg_oneclickaction
         $lang->load(strtolower('PLG_SYSTEM_ONECLICKACTION'), JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         // should be plg_oneclickaction
         // Joomla 1.5 plugins
         if ($ext->type == 'plugin') {
             $plg = 'plg_' . $ext->folder . '_' . $ext->element;
             $lang->load(strtolower($plg), JPATH_SITE, 'en-GB', TRUE);
             $lang->load(strtolower($plg), JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         }
         if ($ext->type == 'template') {
             $plg = 'tpl_' . $ext->name;
             $lang->load(strtolower($plg), JPATH_SITE, 'en-GB', TRUE);
             $lang->load(strtolower($plg), JPATH_ADMINISTRATOR, 'en-GB', TRUE);
         }
     }
     // ok now we have the extensions - get the xml for further offline crunching
     foreach ($installedExtensions as $k => $ext) {
         // remove not supported types :-(
         if ($ext->type == 'file' || $ext->type == 'package') {
             unset($installedExtensions[$k]);
             continue;
         }
         $ext->xmlFile = $this->findManifest($ext);
         try {
             if ($ext->xmlFile !== FALSE) {
                 $parts = explode('/', $ext->xmlFile);
                 array_pop($parts);
                 $ext->path = implode('/', $parts);
                 bfLog::log('Loading XML file = ' . str_replace(JPATH_BASE, '', $ext->xmlFile));
                 $xml = trim(file_get_contents($ext->xmlFile));
                 $myXML = new SimpleXMLElement($xml);
                 if (property_exists($myXML, 'description')) {
                     $ext->desc = $myXML->description;
                 }
                 $ext->xmlFileContents = base64_encode(gzcompress($xml));
                 $ext->xmlFileCreated = filemtime($ext->xmlFile);
             } else {
                 $ext->MANIFESTERROR = TRUE;
             }
         } catch (Exception $e) {
             bfLog::log('EXCEPTION = ' . $ext->xmlFile . ' ' . $e->getMessage());
             die('Could not process XML file at: ' . str_replace(JPATH_BASE, '', $ext->xmlFile));
         }
         $ext->name = JText::_($ext->name);
         $ext->title = JText::_($ext->title);
         $ext->desc = base64_encode(gzcompress(JText::_($ext->desc)));
         // remove base paths - we dont want to leak data :)
         $ext->xmlFile = $this->removeBase($ext->xmlFile);
         $ext->path = $this->removeBase($ext->path);
         // Sort so its pretty - not that anyone sees, but debugging is easier
         $ext = (array) $ext;
         ksort($ext);
         // push to the result
         $installedExtensions[$k] = $ext;
     }
     return json_encode($installedExtensions);
 }
Example #27
0
 /**
  * Generate a sparkline (inline chart)
  *
  * @param      object  $db       JDatabase
  * @param      integer $id       Row ID
  * @param      string  $period   Time period
  * @param      string  $datetime Timestamp
  * @return     string
  */
 private function _getSparkline($db, $id, $period, $datetime)
 {
     $sparkline = '';
     $thisyear = date("Y");
     $tp = $thisyear - 2000;
     $limit = $tp * 12;
     $limit = 12;
     // Pull results
     $sql = "SELECT value, valfmt, datetime FROM summary_user_vals WHERE rowid='{$id}' AND period='{$period}' AND datetime<='{$datetime}' AND colid='{$id}' ORDER BY datetime DESC LIMIT {$limit}";
     $db->setQuery($sql);
     $results = $db->loadObjectList();
     if ($results) {
         // Reverse the array (we'll be getting back data in DESC order, we need it in ASC order)
         $results = array_reverse($results);
         // Find the highest value
         $vals = array();
         foreach ($results as $result) {
             $vals[] = $result->value;
         }
         asort($vals);
         $highest = array_pop($vals);
         // Generate the sparkline
         $sparkline .= '<span class="sparkline">' . "\n";
         foreach ($results as $result) {
             $height = $highest ? round($result->value / $highest * 100) : 0;
             $sparkline .= "\t" . '<span class="index">';
             $sparkline .= '<span class="count" style="height: ' . $height . '%;" title="' . Date::of($result->datetime)->toLocal(Lang::txt('DATE_FORMAT_HZ1')) . ': ' . trim($this->_fmt_result($result->value, $result->valfmt)) . '">';
             $sparkline .= trim($this->_fmt_result($result->value, $result->valfmt));
             $sparkline .= '</span> ';
             $sparkline .= '</span>' . "\n";
         }
         $sparkline .= '</span>' . "\n";
     }
     return $sparkline;
 }
Example #28
0
 /**
  * Process a single record
  *
  * @param   integer  $id
  * @return  object
  */
 public function record($id)
 {
     if (strstr($id, ':')) {
         list($id, $revision) = explode(':', $id);
     }
     $id = intval($id);
     if (!isset($revision)) {
         $revision = 0;
     }
     $this->database->setQuery("SELECT r.id, r.id AS identifier, r.title, r.introtext AS description, r.fulltxt, r.created, r.publish_up, r.alias, rt.alias AS type\n\t\t\tFROM `#__resources` AS r\n\t\t\tINNER JOIN `#__resource_types` AS rt ON r.type = rt.id\n\t\t\tWHERE r.id = " . $this->database->quote($id));
     $record = $this->database->loadObject();
     $record->base = $this->name();
     $record->type = $record->base . ':' . $record->type;
     if ($revision) {
         $this->database->setQuery("SELECT *\n\t\t\t\tFROM `#__tool_version`\n\t\t\t\tWHERE toolname=" . $this->database->quote($record->alias) . " AND revision=" . $this->database->quote($revision) . "\n\t\t\t\tLIMIT 1");
         $tool = $this->database->loadObject();
         if ($tool->id) {
             $record->title .= ' [version ' . $tool->version . ']';
             $record->fulltxt = $tool->fulltxt;
             $record->publish_up = $tool->released;
         }
     }
     $record->date = $record->created;
     if ($record->publish_up && $record->publish_up != $this->database->getNullDate()) {
         $record->date = $record->publish_up;
     }
     if (!$record->description) {
         $record->description = $record->fulltxt;
         $record->description = preg_replace("#<nb:(.*?)>(.*?)</nb:(.*?)>#s", '', $record->description);
     }
     $record->description = strip_tags($record->description);
     $record->description = trim($record->description);
     unset($record->publish_up);
     unset($record->created);
     unset($record->fulltxt);
     $isTool = 0;
     if ($record->alias) {
         $this->database->setQuery("SELECT id\n\t\t\t\tFROM `#__tool`\n\t\t\t\tWHERE toolname=" . $this->database->quote($record->alias) . "\n\t\t\t\tLIMIT 1");
         $isTool = $this->database->loadResult();
     }
     if ($revision) {
         /*"SELECT a.`doi`
         		FROM `#__doi_mapping` AS a
         		LEFT JOIN `#__tool_version` AS v ON v.id=a.versionid
         		WHERE a.rid=" . $this->database->quote($id) . " AND v.revision=" . $this->database->quote($revision) . "
         		LIMIT 1"*/
         $this->database->setQuery("SELECT a.`doi`\n\t\t\t\tFROM `#__doi_mapping` AS a\n\t\t\t\tWHERE a.rid=" . $this->database->quote($id) . " AND a.local_revision=" . $this->database->quote($revision) . "\n\t\t\t\tLIMIT 1");
     } else {
         $this->database->setQuery("SELECT a.`doi`\n\t\t\t\tFROM `#__doi_mapping` AS a\n\t\t\t\tWHERE a.rid=" . $this->database->quote($id) . "\n\t\t\t\tORDER BY `versionid` DESC LIMIT 1");
     }
     $record->identifier = $this->identifier($id, $this->database->loadResult(), $revision);
     $this->database->setQuery("SELECT DISTINCT t.raw_tag\n\t\t\tFROM `#__tags` t, `#__tags_object` tos\n\t\t\tWHERE t.id = tos.tagid AND tos.objectid=" . $this->database->quote($id) . " AND tos.tbl='resources' AND t.admin=0\n\t\t\tORDER BY t.raw_tag");
     $record->subject = $this->database->loadColumn();
     $record->relation = array();
     $this->database->setQuery("SELECT r.id, r.title, r.type, r.logical_type AS logicaltype, r.created, r.created_by,\n\t\t\tr.published, r.publish_up, r.path, r.access, t.type AS logicaltitle, rt.type AS typetitle, r.standalone\n\t\t\tFROM `#__resources` AS r\n\t\t\tINNER JOIN `#__resource_types` AS rt ON r.type=rt.id\n\t\t\tINNER JOIN `#__resource_assoc` AS a ON r.id=a.child_id\n\t\t\tLEFT JOIN `#__resource_types` AS t ON r.logical_type=t.id\n\t\t\tWHERE r.published=1 AND a.parent_id=" . $this->database->quote($id) . "\n\t\t\tORDER BY a.ordering, a.grouping");
     if ($children = $this->database->loadObjectList()) {
         require_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'helpers' . DS . 'html.php';
         require_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'type.php';
         foreach ($children as $child) {
             $uri = \Components\Resources\Helpers\Html::processPath('com_resources', $child, $id, 3);
             if (substr($uri, 0, 4) != 'http') {
                 $uri = self::$base . '/' . ltrim($uri, '/');
             }
             $record->relation[] = array('type' => 'hasPart', 'value' => $uri);
         }
     }
     $this->database->setQuery("SELECT DISTINCT r.id\n\t\t\tFROM `#__resources` AS r\n\t\t\tINNER JOIN `#__resource_assoc` AS a ON r.id=a.parent_id\n\t\t\tWHERE r.published=1 AND a.child_id=" . $this->database->quote($id) . "\n\t\t\tORDER BY a.ordering, a.grouping");
     if ($parents = $this->database->loadObjectList()) {
         foreach ($parents as $parent) {
             $record->relation[] = array('type' => 'isPartOf', 'value' => $this->identifier($parent->id, 0));
         }
     }
     if ($isTool) {
         if ($revision) {
             $this->database->setQuery("SELECT n.uidNumber AS id,\n\t\t\t\t\t\tCASE WHEN t.name!='' AND t.name IS NOT NULL THEN t.name\n\t\t\t\t\t\tELSE n.name\n\t\t\t\t\t\tEND AS `name`\n\t\t\t\t\tFROM `#__tool_authors` AS t, `#__xprofiles` AS n, `#__tool_version` AS v\n\t\t\t\t\tWHERE n.uidNumber=t.uid AND t.toolname=" . $this->database->quote($record->alias) . " AND v.id=t.version_id and v.state<>3\n\t\t\t\t\tAND t.revision=" . $this->database->quote($revision) . "\n\t\t\t\t\tORDER BY t.ordering");
             $record->creator = $this->database->loadColumn();
             /*$record->relation[] = array(
             			'type'  => 'isVersionOf',
             			'value' => $this->identifier($id, '', 0)
             		);*/
         }
         $this->database->setQuery("SELECT v.id, v.revision, d.*\n\t\t\t\tFROM `#__tool_version` as v\n\t\t\t\tLEFT JOIN `#__doi_mapping` as d\n\t\t\t\tON d.alias = v.toolname\n\t\t\t\tAND d.local_revision=v.revision\n\t\t\t\tWHERE v.toolname = " . $this->database->quote($record->alias) . "\n\t\t\t\tORDER BY v.state DESC, v.revision DESC");
         $versions = $this->database->loadObjectList();
         foreach ($versions as $i => $v) {
             if (!$v->revision || $v->revision == $revision) {
                 continue;
             }
             $record->relation[] = array('type' => 'hasVersion', 'value' => $this->identifier($id, $v->doi, $v->revision));
         }
     }
     if (!isset($record->creator)) {
         $this->database->setQuery("SELECT \n\t\t\t\t\tCASE WHEN a.name!='' AND a.name IS NOT NULL THEN a.name\n\t\t\t\t\tELSE n.name\n\t\t\t\t\tEND AS `name`\n\t\t\t\tFROM `#__author_assoc` AS a\n\t\t\t\tLEFT JOIN `#__xprofiles` AS n ON n.uidNumber=a.authorid\n\t\t\t\tWHERE a.subtable='resources' AND a.subid=" . $this->database->quote($id) . " AND a.role!='submitter'\n\t\t\t\tORDER BY a.ordering, a.name");
         $record->creator = $this->database->loadColumn();
     }
     $this->database->setQuery("SELECT *\n\t\t\tFROM `#__citations` AS a\n\t\t\tINNER JOIN `#__citations_assoc` AS n ON n.`cid`=a.`id`\n\t\t\tWHERE n.`tbl`='resource' AND n.`oid`=" . $this->database->quote($id) . " AND a.`published`=1\n\t\t\tORDER BY `year` DESC");
     $references = $this->database->loadObjectList();
     if (count($references) && file_exists(PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php')) {
         include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php';
         $formatter = new \Components\Citations\Helpers\Format();
         $formatter->setTemplate('apa');
         foreach ($references as $reference) {
             //<dcterms:isReferencedBy>uytruytry</dcterms:isReferencedBy>
             //<dcterms:isVersionOf>jgkhfjf</dcterms:isVersionOf>
             $cite = strip_tags(html_entity_decode($reference->formatted ? $reference->formatted : \Components\Citations\Helpers\Format::formatReference($reference, '')));
             $cite = str_replace('&quot;', '"', $cite);
             $record->relation[] = array('type' => 'references', 'value' => trim($cite));
         }
     }
     return $record;
 }
Example #29
0
 /**
  * Short description for 'getLicenses'
  *
  * Long description (if any) ...
  *
  * @param      object $database Parameter description (if any) ...
  * @return     object Return description (if any) ...
  */
 public static function getLicenses($database)
 {
     $database->setQuery("SELECT text, name, title FROM `#__tool_licenses` ORDER BY ordering ASC");
     return $database->loadObjectList();
 }
Example #30
0
 /**
  * List records
  *
  * @param   string  $from   Timestamp
  * @param   string  $until  Timestamp
  * @param   string  $set    Set to filter by
  * @param   string  $verb
  * @return  object  $this
  */
 public function records($from, $until, $set = null, $verb = 'ListRecords')
 {
     // Set flow control vars
     $limit = $this->get('limit', 50);
     $start = $this->get('start', 0);
     $queries = array();
     foreach ($this->providers as $provider) {
         if (!($query = $provider->records(array('from' => $from, 'until' => $until, 'set' => $set)))) {
             continue;
         }
         $queries[] = $query;
     }
     if (!count($queries)) {
         return $this->error(self::ERROR_RECORD_NOT_FOUND, null, $verb);
     }
     // Get Records
     $sql = "SELECT COUNT(*) FROM (" . implode(' UNION ', $queries) . ") AS m";
     $this->database->setQuery($sql);
     $total = $this->database->loadResult();
     $sql = "SELECT m.* FROM (" . implode(' UNION ', $queries) . ") AS m LIMIT " . $start . "," . $limit;
     $this->database->setQuery($sql);
     $records = $this->database->loadObjectList();
     if (!count($records)) {
         return $this->error(self::ERROR_RECORD_NOT_FOUND, null, $verb);
     }
     // Hook for post processing
     foreach ($this->providers as $provider) {
         $records = $provider->postRecords($records);
     }
     // Write schema
     $this->response->element('request', $this->get('baseURL') . '/oaipmh')->attr('verb', $verb)->end()->element($verb);
     $this->schema->records($records, $verb == 'ListIdentifiers' ? false : true);
     // Write resumption token if needed
     if ($total > $start + $limit) {
         $resumption = $this->encodeToken($limit, $start, $from, $until, $set, $this->get('metadataPrefix'));
         $this->response->element('resumptionToken', $resumption)->attr('completeListSize', $total)->attr('cursor', $start + $limit)->end();
     }
     $this->response->end();
     return $this;
 }