Ejemplo n.º 1
0
 /**
  * Testing getTable().
  *
  * @param	string	The type of table
  * @param	string	The prefix for the table
  * @param	string	The expected class of the table
  * @param	string	The expected name of the table
  *
  * @return void
  *
  * @dataProvider casesGetTable
  */
 public function testGetTable($type, $prefix, $expClass, $expName)
 {
     $table = $this->object->getTable($type, $prefix);
     $this->assertThat($table, $expClass ? $this->isInstanceOf($expClass) : $this->isFalse(), 'Table is not instance of JTableUser');
     if ($expClass) {
         $this->assertThat($table->getTableName(), $this->equalTo($expName), 'Failed table name check');
     }
 }
Ejemplo n.º 2
0
 function createUser($username)
 {
     $new_user = new JUser();
     $this->db->setQuery("SELECT email, isAdm FROM #__user WHERE name = " . $this->db->Quote($username));
     $r = $this->db->loadRow();
     $email = $r[0];
     $isAdm = $r[1];
     jimport('joomla.application.component.helper');
     $config =& JComponentHelper::getParams('com_users');
     if ($isAdm) {
         $usertype = 'Super Administrator';
     } else {
         $usertype = $config->get('new_usertype', 'Registered');
     }
     $acl =& JFactory::getACL();
     $new_user->set('id', 0);
     $new_user->set('name', $username);
     $new_user->set('username', $username);
     $new_user->set('email', $email);
     $new_user->set('gid', $acl->get_group_id('', $usertype));
     $new_user->set('usertype', $usertype);
     $new_user->set('registeredDate', date('Y-m-d H:i:s'));
     $new_user->set('lastVisitDate', date('Y-m-d H:i:s'));
     $table =& $new_user->getTable();
     $new_user->params = $new_user->_params->toString();
     $table->bind($new_user->getProperties());
     //			$new_user->save();
     if ($table->store()) {
         return $table->get('id');
     }
 }
Ejemplo n.º 3
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $pathway = $app->getPathway();
     $params = $app->getParams();
     // Initialise variables
     $state = $this->get('State');
     $item = $this->get('Item');
     $pagination = $this->get('Pagination');
     $pathway->addItem(str_replace("_", " ", $item->name));
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     if ($item === false) {
         return JError::raiseError(404, JText::_('COM_TRACKER_NO_TORRENT'));
     }
     if ($user->get('guest') && $params->get('allow_guest') == 0) {
         $app->redirect('index.php', JText::_('COM_TRACKER_NOT_LOGGED_IN'), 'error');
     }
     if ($user->get('guest') && $params->get('allow_guest') == 1) {
         $user = JUser::getTable('user', 'TrackerTable');
         $user->load($params->get('guest_user'));
     }
     $this->assignRef('state', $state);
     $this->assignRef('item', $item);
     $this->assignRef('params', $params);
     parent::display($tpl);
 }
Ejemplo n.º 4
0
 /**
  * Fetch the user for the given user identifier from the backend
  *
  * @param string $identifier A unique user identifier, (i.e a username or email address)
  * @return KUserInterface|null Returns a UserInterface object or NULL if the user could not be found.
  */
 public function fetch($identifier)
 {
     $table = JUser::getTable();
     if ($table->load($identifier)) {
         $user = JUser::getInstance(0);
         $user->setProperties($table->getProperties());
         $params = new JRegistry();
         $params->loadString($table->params);
         $user->setParameters($params);
         $data = array('id' => $user->id, 'email' => $user->email, 'name' => $user->name, 'username' => $user->username, 'password' => $user->password, 'salt' => '', 'groups' => JAccess::getGroupsByUser($user->id), 'roles' => JAccess::getAuthorisedViewLevels($user->id), 'authentic' => !$user->guest, 'enabled' => !$user->block, 'expired' => (bool) $user->activation, 'attributes' => $user->getParameters()->toArray());
         $user = $this->create($data);
     } else {
         $user = null;
     }
     return $user;
 }
Ejemplo n.º 5
0
                if ($listads->ad_payment_type == 0) {
                    echo JText::_('IMPRS');
                } else {
                    if ($listads->ad_payment_type == 1) {
                        echo JText::_('CLICKS');
                    } else {
                        echo JText::_('PERDATE');
                    }
                }
            }
        }
        ?>
				</td>
				<td>
					<?php 
        $table = JUser::getTable();
        $user_id = intval($listads->ad_creator);
        $creaternm = '';
        if ($table->load($user_id)) {
            $creaternm = JFactory::getUser($listads->ad_creator);
        }
        //			 print_r($listads->ad_creator);
        echo !$creaternm ? JText::_('NO_USER') : $creaternm->username;
        ?>
				</td>
				<!--Zone Name -->
				<td>

					<?php 
        $zone_name = '';
        $zone_name = $model->adzonename($listads->ad_id, $listads->ad_zone);
Ejemplo n.º 6
0
 public function __construct($app)
 {
     parent::__construct($app);
     $this->_user = JFactory::getUser();
     $this->_table = $this->_user->getTable();
 }
Ejemplo n.º 7
0
	/**
	 * Saves a JUser object to the database. This method has been adapted from
	 * the JUser::save() method to bypass ACL checks for super users. It still
	 * calls the onUserBeforeSave and onUserAfterSave events.
	 *
	 * @param   JUser    &$user     Object to save.
	 * @param   Boolean  $dispatch  True to call the listening plugins or False to skip dispatching
	 *
	 * @return  boolean  True on success or False on failure.
	 *
	 * @since   2.0
	 * @throws  Exception
	 */
	public static function save(JUser &$user, $dispatch = true)
	{
		// Create the user table object
		$table = $user->getTable();
		$user->params = (string) $user->getParameters();
		$table->bind($user->getProperties());

		$username = $user->username;

		// Check and store the object.
		if (!$table->check())
		{
			throw new Exception(JText::sprintf('LIB_SHUSERHELPER_ERR_10511', $username, $table->getError()), 10511);
		}

		$my = JFactory::getUser();

		if ($dispatch)
		{
			// Check if we are creating a new user
			$isNew = empty($user->id);

			// Get the old user
			$oldUser = new JUser($user->id);

			// Fire the onUserBeforeSave event.
			JPluginHelper::importPlugin('user');
			$dispatcher = JDispatcher::getInstance();

			$result = $dispatcher->trigger('onUserBeforeSave', array($oldUser->getProperties(), $isNew, $user->getProperties()));

			if (in_array(false, $result, true))
			{
				// Plugin will have to raise its own error or throw an exception.
				return false;
			}
		}

		// Store the user data in the database
		if (!($result = $table->store()))
		{
			throw new Exception(JText::sprintf('LIB_SHUSERHELPER_ERR_10512', $username, $table->getError()), 10512);
		}

		// Set the id for the JUser object in case we created a new user.
		if (empty($user->id))
		{
			$user->id = $table->get('id');
		}

		if ($my->id == $table->id)
		{
			$registry = new JRegistry;
			$registry->loadString($table->params);
			$my->setParameters($registry);
		}

		if ($dispatch)
		{
			// Fire the onUserAfterSave event
			$dispatcher->trigger('onUserAfterSave', array($user->getProperties(), $isNew, $result, $user->getError()));
		}

		return $result;
	}
Ejemplo n.º 8
0
 /**
  * Migrates all votes
  *
  * @return  void
  * @since   1.0
  */
 protected function migrateVotes()
 {
     $selectQuery = $this->_db2->getQuery(true)->select('a.*')->from($this->table_votes . ' AS a');
     if (!$this->otherDatabase) {
         if (!$this->checkTime()) {
             $this->refresh('votes');
         }
         $this->writeLogfile('Start migrating votes');
         if ($this->checkOwner) {
             $selectQuery->leftJoin('#__users AS u ON a.userid = u.id')->where('u.id IS NOT NULL');
         }
         $query = 'INSERT INTO ' . _JOOM_TABLE_VOTES . ' ' . $selectQuery;
         $this->_db->setQuery($query);
         if ($this->runQuery()) {
             $this->writeLogfile('Votes successfully migrated');
         } else {
             $this->writeLogfile('Error migrating the votes');
         }
         return;
     }
     $this->prepareTable($selectQuery);
     while ($row = $this->getNextObject()) {
         if (!$this->checkOwner || JUser::getTable()->load($row->userid)) {
             $this->createVote($row);
         }
         if (!$this->checkTime()) {
             $this->refresh('votes');
         }
     }
     $this->resetTable();
 }
Ejemplo n.º 9
0
 static function saveUserRegistration($var, $internal = false, $overrideActivation = false, $overrideEmails = false, $overrideJS = false)
 {
     $db = JFactory::getDBO();
     global $task, $aecConfig;
     $app = JFactory::getApplication();
     ob_start();
     // Let CB/JUSER think that everything is going fine
     if (aecComponentHelper::detect_component('anyCB')) {
         if (aecComponentHelper::detect_component('CBE') || $overrideActivation) {
             global $ueConfig;
         }
         $savetask = $task;
         $_REQUEST['task'] = 'done';
         include_once JPATH_SITE . '/components/com_comprofiler/comprofiler.php';
         $task = $savetask;
         if ($overrideActivation) {
             $ueConfig['reg_confirmation'] = 0;
         }
         if ($overrideEmails) {
             $ueConfig['reg_welcome_sub'] = '';
             // Only disable "Pending Approval / Confirmation" emails if it makes sense
             if (!$ueConfig['reg_confirmation'] || !$ueConfig['reg_admin_approval']) {
                 $ueConfig['reg_pend_appr_sub'] = '';
             }
         }
     } elseif (aecComponentHelper::detect_component('JUSER')) {
         $savetask = $task;
         $task = 'blind';
         include_once JPATH_SITE . '/components/com_juser/juser.php';
         include_once JPATH_SITE . '/administrator/components/com_juser/juser.class.php';
         $task = $savetask;
     } elseif (aecComponentHelper::detect_component('JOMSOCIAL')) {
     }
     // For joomla and CB, we must filter out some internal variables before handing over the POST data
     $badbadvars = array('userid', 'method_name', 'usage', 'processor', 'recurring', 'currency', 'amount', 'invoice', 'id', 'gid');
     foreach ($badbadvars as $badvar) {
         if (isset($var[$badvar])) {
             unset($var[$badvar]);
         }
     }
     if (empty($var['name']) && !empty($var['jform'])) {
         // Must be K2
         $var['name'] = aecEscape($var['jform']['name'], array('string', 'clear_nonalnum'));
         unset($var['jform']);
     }
     $_POST = $var;
     $var['username'] = aecEscape($var['username'], array('string', 'badchars'));
     $savepwd = aecEscape($var['password'], array('string', 'badchars'));
     if (aecComponentHelper::detect_component('anyCB')) {
         // This is a CB registration, borrowing their code to save the user
         if ($internal && !aecComponentHelper::detect_component('CBE')) {
             include_once JPATH_SITE . '/components/com_acctexp/lib/codeofshame/cbregister.php';
             if (empty($_POST['firstname']) && !empty($_POST['name'])) {
                 $name = metaUser::_explodeName($_POST['name']);
                 $_POST['firstname'] = $name['first'];
                 if (empty($name['last'])) {
                     $_POST['lastname'] = $name['first'];
                 } else {
                     $_POST['lastname'] = $name['last'];
                 }
             }
             $_POST['password__verify'] = $_POST['password2'];
             unset($_POST['password2']);
             @saveRegistrationNOCHECKSLOL('com_acctexp');
         } else {
             @saveRegistration('com_acctexp');
             $cbreply = ob_get_contents();
             $indicator = '<script type="text/javascript">alert(\'';
             $alertstart = strpos($cbreply, $indicator);
             // Emergency fallback
             if ($alertstart !== false) {
                 ob_clean();
                 $alertend = strpos($cbreply, '\'); </script>', $alertstart);
                 $alert = substr($cbreply, $alertstart + strlen($indicator), $alertend - $alertstart - strlen($indicator));
                 if ($aecConfig->cfg['plans_first']) {
                     aecErrorAlert($alert, $action = 'window.history.go(-2);');
                 } else {
                     aecErrorAlert($alert, $action = 'window.history.go(-3);');
                 }
             }
         }
     } elseif (aecComponentHelper::detect_component('JUSER')) {
         // This is a JUSER registration, borrowing their code to save the user
         saveRegistration('com_acctexp');
         $query = 'SELECT `id`' . ' FROM #__users' . ' WHERE `username` = \'' . $var['username'] . '\'';
         $db->setQuery($query);
         $uid = $db->loadResult();
         JUser::saveUser_ext($uid);
         //synchronize dublicate user data
         $query = 'SELECT `id`' . ' FROM #__juser_integration' . ' WHERE `published` = \'1\'' . ' AND `export_status` = \'1\'';
         $db->setQuery($query);
         $components = $db->loadObjectList();
         if (!empty($components)) {
             foreach ($components as $component) {
                 $synchronize = require_integration($component->id);
                 $synchronize->synchronizeFrom($uid);
             }
         }
     } elseif (aecComponentHelper::detect_component('JOMSOCIAL') && !$overrideJS) {
     } else {
         $data = array('username' => $var['username'], 'password' => $var['password'], 'password2' => $var['password2'], 'email' => $var['email'], 'name' => $var['name']);
         if (isset($var['jform']['profile'])) {
             $data['profile'] = $var['jform']['profile'];
         }
         if (defined('JPATH_MANIFESTS')) {
             $params = JComponentHelper::getParams('com_users');
             // Initialise the table with JUser.
             JUser::getTable('User', 'JTable');
             $user = new JUser();
             // Prepare the data for the user object.
             $useractivation = $params->get('useractivation');
             // Check if the user needs to activate their account.
             if (($useractivation == 1 || $useractivation == 2) && !$overrideActivation) {
                 jimport('joomla.user.helper');
                 $data['activation'] = xJ::getHash();
                 $data['block'] = 1;
             }
             $usersConfig = JComponentHelper::getParams('com_users');
             $system = $usersConfig->get('new_usertype', 2);
             $data['groups'][] = $system;
             // Bind the data.
             if (!$user->bind($data)) {
                 JError::raiseWarning(500, JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError()));
                 return false;
             }
             // Load the users plugin group.
             JPluginHelper::importPlugin('users');
             // Store the data.
             if (!$user->save()) {
                 JError::raiseWarning(500, JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $user->getError()));
                 return false;
             }
         } else {
             // This is a joomla registration, borrowing their code to save the user
             // Check for request forgeries
             if (!$internal) {
                 JRequest::checkToken() or die('Invalid Token');
             }
             // Get required system objects
             $user = clone JFactory::getUser();
             //$pathway 	=& $app->getPathway();
             $config = JFactory::getConfig();
             $authorize = JFactory::getACL();
             $document = JFactory::getDocument();
             // If user registration is not allowed, show 403 not authorized.
             $usersConfig = JComponentHelper::getParams('com_users');
             if ($usersConfig->get('allowUserRegistration') == '0') {
                 JError::raiseError(403, JText::_('Access Forbidden'));
                 return;
             }
             // Initialize new usertype setting
             $newUsertype = $usersConfig->get('new_usertype');
             if (!$newUsertype) {
                 $newUsertype = 'Registered';
             }
             // Bind the post array to the user object
             if (!$user->bind($data)) {
                 JError::raiseError(500, $user->getError());
                 unset($_POST);
                 subscribe('com_acctexp');
                 return false;
             }
             // Set some initial user values
             $user->set('id', 0);
             $user->set('usertype', '');
             $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO'));
             $user->set('sendEmail', 0);
             $user->set('registerDate', date('Y-m-d H:i:s', (int) gmdate('U')));
             // If user activation is turned on, we need to set the activation information
             $useractivation = $usersConfig->get('useractivation');
             if ($useractivation == '1' && !$overrideActivation) {
                 jimport('joomla.user.helper');
                 $user->set('activation', md5(JUserHelper::genRandomPassword()));
                 $user->set('block', '1');
             }
             // If there was an error with registration, set the message and display form
             if (!$user->save()) {
                 JError::raiseWarning('', JText::_($user->getError()));
                 echo JText::_($user->getError());
                 return false;
             }
         }
         $row = $user;
         $name = $row->name;
         $email = $row->email;
         $username = $row->username;
         $subject = sprintf(JText::_('AEC_SEND_SUB'), $name, $app->getCfg('sitename'));
         $subject = html_entity_decode($subject, ENT_QUOTES, 'UTF-8');
         $usersConfig = JComponentHelper::getParams('com_users');
         $activation = $usersConfig->get('useractivation');
         if ($activation > 0 && !$overrideActivation) {
             $atext = JText::_('AEC_USEND_MSG_ACTIVATE');
             if (defined('JPATH_MANIFESTS')) {
                 $activation_link = JURI::root() . 'index.php?option=com_users&amp;task=registration.activate&amp;token=' . $row->activation;
                 if ($activation == 2) {
                     $atext = JText::_('COM_USERS_MSG_ADMIN_ACTIVATE');
                 }
             } else {
                 $activation_link = JURI::root() . 'index.php?option=com_user&amp;task=activate&amp;activation=' . $row->activation;
             }
             $message = sprintf($atext, $name, $app->getCfg('sitename'), $activation_link, JURI::root(), $username, $savepwd);
         } else {
             $message = sprintf(JText::_('AEC_USEND_MSG'), $name, $app->getCfg('sitename'), JURI::root());
         }
         $message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');
         // check if Global Config `mailfrom` and `fromname` values exist
         if ($app->getCfg('mailfrom') != '' && $app->getCfg('fromname') != '') {
             $adminName2 = $app->getCfg('fromname');
             $adminEmail2 = $app->getCfg('mailfrom');
         } else {
             // use email address and name of first superadmin for use in email sent to user
             $rows = xJACLhandler::getSuperAdmins();
             $row2 = $rows[0];
             $adminName2 = $row2->name;
             $adminEmail2 = $row2->email;
         }
         // Send email to user
         if (!($aecConfig->cfg['nojoomlaregemails'] || $overrideEmails)) {
             xJ::sendMail($adminEmail2, $adminEmail2, $email, $subject, $message);
         }
         // Send notification to all administrators
         $aecUser = AECToolbox::aecIP();
         $subject2 = sprintf(JText::_('AEC_SEND_SUB'), $name, $app->getCfg('sitename'));
         $message2 = sprintf(JText::_('AEC_ASEND_MSG_NEW_REG'), $adminName2, $app->getCfg('sitename'), $row->name, $email, $username, $aecUser['ip'], $aecUser['isp']);
         $subject2 = html_entity_decode($subject2, ENT_QUOTES, 'UTF-8');
         $message2 = html_entity_decode($message2, ENT_QUOTES, 'UTF-8');
         // get email addresses of all admins and superadmins set to recieve system emails
         $admins = AECToolbox::getAdminEmailList();
         foreach ($admins as $adminemail) {
             if (!empty($adminemail)) {
                 xJ::sendMail($adminEmail2, $adminEmail2, $adminemail, $subject2, $message2);
             }
         }
     }
     ob_clean();
     // We need the new userid, so we're fetching it from the newly created entry here
     $query = 'SELECT `id`' . ' FROM #__users' . ' WHERE `username` = \'' . $var['username'] . '\'';
     $db->setQuery($query);
     return $db->loadResult();
 }
Ejemplo n.º 10
0
 /**
  * Method to save the form data.
  *
  * @access	public
  * @param	array		$data		The form data.
  * @return	mixed		The user id on success, false on failure.
  * @since	1.0
  */
 function register($temp)
 {
     $config =& JFactory::getConfig();
     $params =& JComponentHelper::getParams('com_users');
     // Initialise the table with JUser.
     JUser::getTable('User', 'JTable');
     $user = new JUser();
     $data = (array) $this->getData();
     // Merge in the registration data.
     foreach ($data as $k => $v) {
         $temp[$k] = $v;
     }
     $data = $temp;
     // Prepare the data for the user object.
     $data['email'] = $data['email1'];
     $data['password'] = $data['password1'];
     // Check if the user needs to activate their account.
     if ($params->get('useractivation')) {
         jimport('joomla.user.helper');
         $data['activation'] = JUtility::getHash(JUserHelper::genRandomPassword());
         $data['block'] = 1;
     }
     // Bind the data.
     if (!$user->bind($data)) {
         $this->setError(JText::sprintf('USERS REGISTRATION BIND FAILED', $user->getError()));
         return false;
     }
     // Load the users plugin group.
     JPluginHelper::importPlugin('users');
     // Store the data.
     if (!$user->save()) {
         $this->setError($user->getError());
         return false;
     }
     // Compile the notification mail values.
     $data = $user->getProperties();
     $data['fromname'] = $config->getValue('fromname');
     $data['mailfrom'] = $config->getValue('mailfrom');
     $data['sitename'] = $config->getValue('sitename');
     // Handle account activation/confirmation e-mails.
     if ($params->get('useractivation')) {
         // Set the link to activate the user account.
         $uri =& JURI::getInstance();
         $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
         $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
         // Get the registration activation e-mail.
         $message = 'com_users.registration.activate';
     } else {
         // Get the registration confirmation e-mail.
         $message = 'com_users.registration.confirm';
     }
     // Load the message template and bind the data.
     jimport('joomla.utilities.simpletemplate');
     $template = JxSimpleTemplate::getInstance($message);
     $template->bind($data);
     // Send the registration e-mail.
     $return = JUtility::sendMail($data['mailfrom'], $data['fromname'], $data['email'], $template->getTitle(), $template->getBody());
     // Check for an error.
     if ($return !== true) {
         $this->setError(JText::_('USERS REGISTRATION SEND MAIL FAILED'));
         return false;
     }
     return $user->id;
 }
Ejemplo n.º 11
0
 /**
  * Instantiate the controller.
  *
  * @param   string            $type   The content type
  * @param   JInput            $input  The input object.
  * @param   JApplicationBase  $app    The application object.
  *
  * @since   1.0
  */
 public function __construct($name, $type, JInput $input = null, JApplicationBase $app = null)
 {
     // Setup dependencies.
     $this->app = isset($app) ? $app : $this->loadApplication();
     $this->input = isset($input) ? $input : $this->loadInput();
     // Set type
     $this->type = $type;
     // Init user load table
     JUser::getTable('user', 'WebServiceTable');
     // Init a local user
     $this->user = new JUser();
     // Init model
     $modelClass = 'WebServiceModels' . ucfirst($name);
     // If the controller class does not exist panic.
     if (!class_exists($modelClass) || !is_subclass_of($modelClass, 'JModel')) {
         throw new RuntimeException(sprintf('Unable to locate models `%s`.', $modelClass), 404);
     }
     $this->model = new $modelClass(new JContentFactory());
 }
Ejemplo n.º 12
0
 /**
  * Instantiate the controller.
  *
  * @param   string            $type   The content type
  * @param   JInput            $input  The input object.
  * @param   JApplicationBase  $app    The application object.
  *
  * @since   1.0
  */
 public function __construct($type, JInput $input = null, JApplicationBase $app = null)
 {
     // Setup dependencies.
     $this->app = isset($app) ? $app : $this->loadApplication();
     $this->input = isset($input) ? $input : $this->loadInput();
     // Set type
     $this->type = $type;
     // Init user load table
     JUser::getTable('user', 'WebServiceTable');
     // Init a local user
     $this->user = new JUser();
     // Init model
     $this->model = new WebServiceModelBase(new JContentFactory());
 }
Ejemplo n.º 13
0
<?php

JHtml::_('behavior.modal');
$this->app->html->_('behavior.tooltip');
// init vars
$settings = $this->app->zoocart->getConfig();
$this->app->document->addScriptDeclaration("function jSelectUser_user(uid, name){\n\tdocument.getElementById('user_id').value = uid;\n\tdocument.getElementById('user_name').innerHTML = name;\n\tSqueezeBox.close();\n}");
// Keepalive behavior
JHTML::_('behavior.keepalive');
// filter output
JFilterOutput::objectHTMLSafe($this->resource, ENT_QUOTES, array('params', 'billing_address', 'shipping_address', 'shipping_method'));
$renderer = $this->app->renderer->create('address')->addPath(array($this->app->path->path('component.site:'), $this->app->path->path('zoocart:')));
$uid = $this->resource && $this->resource->user_id ? $this->resource->user_id : ($uid = $this->app->user->get()->id);
if (!JUser::getTable()->load($uid)) {
    $uname = JText::sprintf('PLG_ZOOCART_ORDER_USER', $uid);
    $umail = '';
} else {
    $user = $this->app->user->get($uid);
    $uname = $user->name;
    $umail = $user->email;
}
$config = $this->app->zoocart->getConfig();
// Detect if shipping enabled:
$enable_shipping = $config->get('enable_shipping', 0);
?>

<div id="zoocart-orders">
	<!-- main menu -->
		<?php 
echo $this->partial('zlmenu');
?>
Ejemplo n.º 14
0
        echo $row->id;
        ?>
" />
						</td>
						<td>
							<a href="<?php 
        echo $this->component->link(array('controller' => $this->controller, 'task' => 'edit', 'cid[]' => $row->id));
        ?>
">#<?php 
        echo sprintf('%05d', $row->id);
        ?>
</a>
						</td>
						<td>
							<?php 
        echo JUser::getTable()->load($row->user_id) ? JFactory::getUser($row->user_id)->name : JText::sprintf('PLG_ZOOCART_ORDER_USER', $row->user_id);
        ?>
						</td>
						<td>
							<?php 
        echo $address_renderer->render('address.billing', array('item' => $row->getBillingAddress()));
        ?>
						</td>
						<td>
							<?php 
        echo $address_renderer->render('address.shipping', array('item' => $row->getShippingAddress()));
        ?>
						</td>
						<td>
							<?php 
        echo $this->app->zoocart->currency->format($row->getSubtotal());
Ejemplo n.º 15
0
 /**
  * Creates the page's display
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     // Get Non-routing Categories, and Category Tree
     global $globalnoroute, $globalcats;
     if (!is_array($globalnoroute)) {
         $globalnoroute = array();
     }
     //initialize variables
     $dispatcher = JDispatcher::getInstance();
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     $option = JRequest::getVar('option');
     $document = JFactory::getDocument();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $uri = JFactory::getURI();
     $user = JFactory::getUser();
     $aid = FLEXI_J16GE ? JAccess::getAuthorisedViewLevels($user->id) : (int) $user->get('aid');
     // Get category and set category parameters as VIEW's parameters (category parameters are merged with component/page/author parameters already)
     $category = $this->get('Category');
     $params = $category->parameters;
     if ($category->id && FLEXI_J16GE) {
         $meta_params = new JRegistry($category->metadata);
     } else {
         $meta_params = false;
     }
     // Get various data from the model
     $categories = $this->get('Childs');
     // this will also count sub-category items is if  'show_itemcount'  is enabled
     $peercats = $this->get('Peers');
     // this will also count sub-category items is if  'show_subcatcount_peercat'  is enabled
     $items = $this->get('Data');
     $total = $this->get('Total');
     $filters = $this->get('Filters');
     if ($params->get('show_comments_count', 0)) {
         $comments = $this->get('CommentsInfo');
     } else {
         $comments = null;
     }
     $alpha = $params->get('show_alpha', 1) ? $this->get('Alphaindex') : array();
     // This is somwhat expensive so calculate it only if required
     // Request variables, WARNING, must be loaded after retrieving items, because limitstart may have been modified
     $limitstart = JRequest::getInt('limitstart');
     $format = JRequest::getCmd('format', null);
     // ********************************
     // Load needed JS libs & CSS styles
     // ********************************
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadFramework('jQuery');
     flexicontent_html::loadFramework('flexi_tmpl_common');
     //add css file
     if (!$params->get('disablecss', '')) {
         $document->addStyleSheet($this->baseurl . '/components/com_flexicontent/assets/css/flexicontent.css');
         $document->addCustomTag('<!--[if IE]><style type="text/css">.floattext {zoom:1;}</style><![endif]-->');
     }
     //allow css override
     if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . 'flexicontent.css')) {
         $document->addStyleSheet($this->baseurl . '/templates/' . $app->getTemplate() . '/css/flexicontent.css');
     }
     // ************************
     // CATEGORY LAYOUT handling
     // ************************
     // (a) Decide to use mobile or normal category template layout
     $useMobile = $params->get('use_mobile_layouts', 0);
     if ($useMobile) {
         $force_desktop_layout = $params->get('force_desktop_layout', 0);
         $mobileDetector = flexicontent_html::getMobileDetector();
         $isMobile = $mobileDetector->isMobile();
         $isTablet = $mobileDetector->isTablet();
         $useMobile = $force_desktop_layout ? $isMobile && !$isTablet : $isMobile;
     }
     $_clayout = $useMobile ? 'clayout_mobile' : 'clayout';
     // (b) Get from category parameters, allowing URL override
     $clayout = JRequest::getCmd($_clayout, false);
     if (!$clayout) {
         $desktop_clayout = $params->get('clayout', 'blog');
         $clayout = !$useMobile ? $desktop_clayout : $params->get('clayout_mobile', $desktop_clayout);
     }
     // (c) Get cached template data
     $themes = flexicontent_tmpl::getTemplates($lang_files = array($clayout));
     // (d) Verify the category layout exists
     if (!isset($themes->category->{$clayout})) {
         $fixed_clayout = 'blog';
         $app->enqueueMessage("<small>Current Category Layout Template is '{$clayout}' does not exist<br>- Please correct this in the URL or in Content Type configuration.<br>- Using Template Layout: '{$fixed_clayout}'</small>", 'notice');
         $clayout = $fixed_clayout;
         if (FLEXI_FISH || FLEXI_J16GE) {
             FLEXIUtilities::loadTemplateLanguageFile($clayout);
         }
         // Manually load Template-Specific language file of back fall clayout
     }
     // (e) finally set the template name back into the category's parameters
     $params->set('clayout', $clayout);
     // Get URL variables
     $cid = JRequest::getInt('cid', 0);
     $authorid = JRequest::getInt('authorid', 0);
     $tagid = JRequest::getInt('tagid', 0);
     $layout = JRequest::getCmd('layout', '');
     $mcats_list = JRequest::getVar('cids', '');
     if (!is_array($mcats_list)) {
         $mcats_list = preg_replace('/[^0-9,]/i', '', (string) $mcats_list);
         $mcats_list = explode(',', $mcats_list);
     }
     // make sure given data are integers ... !!
     $cids = array();
     foreach ($mcats_list as $i => $_id) {
         if ((int) $_id) {
             $cids[] = (int) $_id;
         }
     }
     $cids = implode(',', $cids);
     $authordescr_item = false;
     if ($authorid && $params->get('authordescr_itemid') && $format != 'feed') {
         $authordescr_itemid = $params->get('authordescr_itemid');
     }
     // Bind Fields
     if ($format != 'feed') {
         $items = FlexicontentFields::getFields($items, 'category', $params, $aid);
     }
     //Set layout
     $this->setLayout('category');
     $limit = $app->getUserStateFromRequest('com_flexicontent' . $category->id . '.category.limit', 'limit', $params->def('limit', 0), 'int');
     // Pathway needed variables
     //$catshelper = new flexicontent_cats($cid);
     //$parents    = $catshelper->getParentlist();
     //echo "<pre>".print_r($parents,true)."</pre>";
     $parents = array();
     if ($cid && isset($globalcats[$cid]->ancestorsarray)) {
         $parent_ids = $globalcats[$cid]->ancestorsarray;
         foreach ($parent_ids as $parent_id) {
             $parents[] = $globalcats[$parent_id];
         }
     }
     $rootcat = (int) $params->get('rootcat');
     if ($rootcat) {
         $root_parents = $globalcats[$rootcat]->ancestorsarray;
     }
     // **********************************************************
     // Calculate a (browser window) page title and a page heading
     // **********************************************************
     // Verify menu item points to current FLEXIcontent object
     if ($menu) {
         $view_ok = 'category' == @$menu->query['view'];
         $cid_ok = $cid == (int) @$menu->query['cid'];
         $layout_ok = $layout == @$menu->query['layout'];
         // null is equal to empty string
         $authorid_ok = $authorid == (int) @$menu->query['authorid'];
         // null is equal to zero
         $tagid_ok = $tagid == (int) @$menu->query['tagid'];
         // null is equal to zero
         $menu_matches = $view_ok && $cid_ok && $layout_ok && $authorid_ok && $tagid_ok;
         //$menu_params = FLEXI_J16GE ? $menu->params : new JParameter($menu->params);  // Get active menu item parameters
     } else {
         $menu_matches = false;
     }
     // MENU ITEM matched, use its page heading (but use menu title if the former is not set)
     if ($menu_matches) {
         $default_heading = FLEXI_J16GE ? $menu->title : $menu->name;
         // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->def('page_heading', $params->get('page_title', $default_heading));
         $params->def('page_title', $params->get('page_heading', $default_heading));
         $params->def('show_page_heading', $params->get('show_page_title', 0));
         $params->def('show_page_title', $params->get('show_page_heading', 0));
     } else {
         // Clear some menu parameters
         //$params->set('pageclass_sfx',	'');  // CSS class SUFFIX is behavior, so do not clear it ?
         // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ...
         switch ($layout) {
             case '':
                 $default_heading = $category->title;
                 break;
             case 'myitems':
                 $default_heading = JText::_('FLEXICONTENT_MYITEMS');
                 break;
             case 'author':
                 $default_heading = JText::_('FLEXICONTENT_AUTHOR') . ': ' . JFactory::getUser($authorid)->get('name');
                 break;
             default:
                 $default_heading = JText::_('FLEXICONTENT_CATEGORY');
         }
         if ($layout && $cid) {
             // Non-single category listings, limited to a specific category
             $default_heading .= ', ' . JText::_('FLEXI_IN_CATEGORY') . ': ' . $category->title;
         }
         // Decide to show page heading (=J1.5 page title) only if a custom layout is used (=not a single category layout)
         $show_default_heading = $layout ? 1 : 0;
         // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->set('page_title', $default_heading);
         $params->set('page_heading', $default_heading);
         $params->set('show_page_heading', $show_default_heading);
         $params->set('show_page_title', $show_default_heading);
     }
     // Prevent showing the page heading if (a) IT IS same as category title and (b) category title is already configured to be shown
     if ($params->get('show_cat_title', 1)) {
         if ($params->get('page_heading') == $category->title) {
             $params->set('show_page_heading', 0);
         }
         if ($params->get('page_title') == $category->title) {
             $params->set('show_page_title', 0);
         }
     }
     // ************************************************************
     // Create the document title, by from page title and other data
     // ************************************************************
     // Use the page heading as document title, (already calculated above via 'appropriate' logic ...)
     // or the overriden custom <title> ... set via parameter
     $doc_title = !$meta_params ? $params->get('page_title') : $meta_params->get('page_title', $params->get('page_title'));
     // Check and prepend or append site name
     if (FLEXI_J16GE) {
         // Not available in J1.5
         // Add Site Name to page title
         if ($app->getCfg('sitename_pagetitles', 0) == 1) {
             $doc_title = $app->getCfg('sitename') . " - " . $doc_title;
         } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
             $doc_title = $doc_title . " - " . $app->getCfg('sitename');
         }
     }
     // Finally, set document title
     $document->setTitle($doc_title);
     // ************************
     // Set document's META tags
     // ************************
     // Workaround for Joomla not setting the default value for 'robots', so component must do it
     $app_params = $app->getParams();
     if ($_mp = $app_params->get('robots')) {
         $document->setMetadata('robots', $_mp);
     }
     if ($category->id) {
         // possibly not set for author items OR my items
         if (FLEXI_J16GE) {
             if ($category->metadesc) {
                 $document->setDescription($category->metadesc);
             }
             if ($category->metakey) {
                 $document->setMetadata('keywords', $category->metakey);
             }
             // meta_params are always set if J1.6+ and category id is set
             if ($meta_params->get('robots')) {
                 $document->setMetadata('robots', $meta_params->get('robots'));
             }
             // ?? Deprecated <title> tag is used instead by search engines
             if ($app->getCfg('MetaTitle') == '1') {
                 $meta_title = $meta_params->get('page_title') ? $meta_params->get('page_title') : $category->title;
                 $document->setMetaData('title', $meta_title);
             }
             if ($app->getCfg('MetaAuthor') == '1') {
                 if ($meta_params->get('author')) {
                     $meta_author = $meta_params->get('author');
                 } else {
                     $table = JUser::getTable();
                     $meta_author = $table->load($category->created_user_id) ? $table->name : '';
                 }
                 $document->setMetaData('author', $meta_author);
             }
         } else {
             // ?? Deprecated <title> tag is used instead by search engines
             if ($app->getCfg('MetaTitle') == '1') {
                 $document->setMetaData('title', $category->title);
             }
         }
     }
     // Overwrite with menu META data if menu matched
     if (FLEXI_J16GE) {
         if ($menu_matches) {
             if ($_mp = $menu->params->get('menu-meta_description')) {
                 $document->setDescription($_mp);
             }
             if ($_mp = $menu->params->get('menu-meta_keywords')) {
                 $document->setMetadata('keywords', $_mp);
             }
             if ($_mp = $menu->params->get('robots')) {
                 $document->setMetadata('robots', $_mp);
             }
             if ($_mp = $menu->params->get('secure')) {
                 $document->setMetadata('secure', $_mp);
             }
         }
     }
     // ************************************
     // Add rel canonical html head link tag (TODO: improve multi-page handing)
     // ************************************
     $base = $uri->getScheme() . '://' . $uri->getHost();
     $start = JRequest::getInt('start', '');
     $start = $start ? "&start=" . $start : "";
     $ucanonical = $base . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug) . $start);
     if ($params->get('add_canonical')) {
         $head_obj = $document->addHeadLink($ucanonical, 'canonical', 'rel', '');
         $defaultCanonical = flexicontent_html::getDefaultCanonical();
         if (FLEXI_J30GE && $defaultCanonical != $ucanonical) {
             unset($head_obj->_links[$defaultCanonical]);
         }
     }
     if ($params->get('show_feed_link', 1) == 1) {
         //add alternate feed link
         $link = '&format=feed';
         $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
         $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
         $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
         $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
     }
     // ********************************************************************************************
     // Create pathway, if automatic pathways is enabled, then path will be cleared before populated
     // ********************************************************************************************
     $pathway = $app->getPathWay();
     // Clear pathway, if automatic pathways are enabled
     if ($params->get('automatic_pathways', 0)) {
         $pathway_arr = $pathway->getPathway();
         $pathway->setPathway(array());
         //$pathway->set('_count', 0);  // not needed ??
         $item_depth = 0;
         // menu item depth is now irrelevant ???, ignore it
     } else {
         $item_depth = $params->get('item_depth', 0);
     }
     // Respect menu item depth, defined in menu item
     $p = $item_depth;
     while ($p < count($parents)) {
         // Do not add the directory root category or its parents (this when coming from a directory view)
         if (!empty($root_parents) && in_array($parents[$p]->id, $root_parents)) {
             $p++;
             continue;
         }
         // Do not add to pathway unroutable categories
         if (in_array($parents[$p]->id, $globalnoroute)) {
             $p++;
             continue;
         }
         // Add current parent category
         $pathway->addItem($this->escape($parents[$p]->title), JRoute::_(FlexicontentHelperRoute::getCategoryRoute($parents[$p]->slug)));
         $p++;
     }
     $authordescr_item_html = false;
     if ($authordescr_item) {
         $flexi_html_helper = new flexicontent_html();
         $authordescr_item_html = $flexi_html_helper->renderItem($authordescr_itemid);
     }
     //echo $authordescr_item_html; exit();
     if ($clayout) {
         // Add the templates css files if availables
         if (isset($themes->category->{$clayout}->css)) {
             foreach ($themes->category->{$clayout}->css as $css) {
                 $document->addStyleSheet($this->baseurl . '/' . $css);
             }
         }
         // Add the templates js files if availables
         if (isset($themes->category->{$clayout}->js)) {
             foreach ($themes->category->{$clayout}->js as $js) {
                 $document->addScript($this->baseurl . '/' . $js);
             }
         }
         // Set the template var
         $tmpl = $themes->category->{$clayout}->tmplvar;
     } else {
         $tmpl = '.category.default';
     }
     // @TODO trigger the plugin selectively
     // and delete the plugins tags if not active
     if ($params->get('trigger_onprepare_content_cat')) {
         JPluginHelper::importPlugin('content');
         // Allow to trigger content plugins on category description
         // NOTE: for J2.5, we will trigger the plugins as if description text was an article text, using ... 'com_content.article'
         $category->text = $category->description;
         if (FLEXI_J16GE) {
             $results = $dispatcher->trigger('onContentPrepare', array('com_content.article', &$category, &$params, 0));
         } else {
             $results = $dispatcher->trigger('onPrepareContent', array(&$category, &$params, 0));
         }
         $category->description = $category->text;
     }
     // Maybe here not to import all plugins but just those for description field or add a parameter for this
     // Anyway these events are usually not very time consuming as is the the event onPrepareContent(J1.5)/onContentPrepare(J1.6+)
     JPluginHelper::importPlugin('content');
     foreach ($items as $item) {
         $item->event = new stdClass();
         $item->params = FLEXI_J16GE ? new JRegistry($item->attribs) : new JParameter($item->attribs);
         // !!! The triggering of the event onPrepareContent(J1.5)/onContentPrepare(J1.6+) of content plugins
         // !!! for description field (maintext) along with all other flexicontent
         // !!! fields is handled by flexicontent.fields.php
         // !!! Had serious performance impact
         // CODE REMOVED
         // We must check if the current category is in the categories of the item ..
         $item_in_category = false;
         if ($item->catid == $category->id) {
             $item_in_category = true;
         } else {
             foreach ($item->cats as $cat) {
                 if ($cat->id == $category->id) {
                     $item_in_category = true;
                     break;
                 }
             }
         }
         // ADVANCED CATEGORY ROUTING (=set the most appropriate category for the item ...)
         // CHOOSE APPROPRIATE category-slug FOR THE ITEM !!! ( )
         if ($item_in_category && !in_array($category->id, $globalnoroute)) {
             // 1. CATEGORY SLUG: CURRENT category
             // Current category IS a category of the item and ALSO routing (creating links) to this category is allowed
             $item->categoryslug = $category->slug;
         } else {
             if (!in_array($item->catid, $globalnoroute)) {
                 // 2. CATEGORY SLUG: ITEM's MAIN category   (alread SET, ... no assignment needed)
                 // Since we cannot use current category (above), we will use item's MAIN category
                 // ALSO routing (creating links) to this category is allowed
             } else {
                 // 3. CATEGORY SLUG: ANY ITEM's category
                 // We will use the first for which routing (creating links) to the category is allowed
                 $allcats = array();
                 $item->cats = $item->cats ? $item->cats : array();
                 foreach ($item->cats as $cat) {
                     if (!in_array($cat->id, $globalnoroute)) {
                         $item->categoryslug = $globalcats[$cat->id]->slug;
                         break;
                     }
                 }
             }
         }
         // Just put item's text (description field) inside property 'text' in case the events modify the given text,
         $item->text = isset($item->fields['text']->display) ? $item->fields['text']->display : '';
         // Set the view and option to 'category' and 'com_content'  (actually view is already called category)
         JRequest::setVar('option', 'com_content');
         JRequest::setVar("isflexicontent", "yes");
         // These events return text that could be displayed at appropriate positions by our templates
         $item->event = new stdClass();
         if (FLEXI_J16GE) {
             $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.category', &$item, &$params, 0));
         } else {
             $results = $dispatcher->trigger('onAfterDisplayTitle', array(&$item, &$params, $limitstart));
         }
         $item->event->afterDisplayTitle = trim(implode("\n", $results));
         if (FLEXI_J16GE) {
             $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.category', &$item, &$params, 0));
         } else {
             $results = $dispatcher->trigger('onBeforeDisplayContent', array(&$item, &$params, $limitstart));
         }
         $item->event->beforeDisplayContent = trim(implode("\n", $results));
         if (FLEXI_J16GE) {
             $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.category', &$item, &$params, 0));
         } else {
             $results = $dispatcher->trigger('onAfterDisplayContent', array(&$item, &$params, $limitstart));
         }
         $item->event->afterDisplayContent = trim(implode("\n", $results));
         // Set the option back to 'com_flexicontent'
         JRequest::setVar('option', 'com_flexicontent');
         // Put text back into the description field, THESE events SHOULD NOT modify the item text, but some plugins may do it anyway... , so we assign text back for compatibility
         $item->fields['text']->display =& $item->text;
     }
     // Calculate CSS classes needed to add special styling markups to the items
     flexicontent_html::calculateItemMarkups($items, $params);
     // *****************************************************
     // Remove unroutable categories from sub/peer categories
     // *****************************************************
     // sub-cats
     $_categories = array();
     foreach ($categories as $i => $cat) {
         if (in_array($cat->id, $globalnoroute)) {
             continue;
         }
         $_categories[] = $categories[$i];
     }
     $categories = $_categories;
     // peer-cats
     $_categories = array();
     foreach ($peercats as $i => $cat) {
         if (in_array($cat->id, $globalnoroute)) {
             continue;
         }
         $_categories[] = $peercats[$i];
     }
     $peercats = $_categories;
     // ************************************
     // Get some variables needed for images
     // ************************************
     $joomla_image_path = $app->getCfg('image_path', FLEXI_J16GE ? '' : 'images' . DS . 'stories');
     $joomla_image_url = str_replace(DS, '/', $joomla_image_path);
     $joomla_image_path = $joomla_image_path ? $joomla_image_path . DS : '';
     $joomla_image_url = $joomla_image_url ? $joomla_image_url . '/' : '';
     // **************
     // CATEGORY IMAGE
     // **************
     // category image params
     $show_cat_image = $params->get('show_description_image', 0);
     // we use different name for variable
     $cat_image_source = $params->get('cat_image_source', 2);
     // 0: extract, 1: use param, 2: use both
     $cat_link_image = $params->get('cat_link_image', 1);
     $cat_image_method = $params->get('cat_image_method', 1);
     $cat_image_width = $params->get('cat_image_width', 80);
     $cat_image_height = $params->get('cat_image_height', 80);
     $cat = $category;
     $image = "";
     if ($cat) {
         if ($cat->id && $show_cat_image) {
             $cat->image = FLEXI_J16GE ? $params->get('image') : $cat->image;
             $image = "";
             $cat->introtext =& $cat->description;
             $cat->fulltext = "";
             if ($cat_image_source && $cat->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . $cat->image)) {
                 $src = JURI::base(true) . "/" . $joomla_image_url . $cat->image;
                 $h = '&amp;h=' . $cat_image_height;
                 $w = '&amp;w=' . $cat_image_width;
                 $aoe = '&amp;aoe=1';
                 $q = '&amp;q=95';
                 $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
                 $ext = pathinfo($src, PATHINFO_EXTENSION);
                 $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                 $conf = $w . $h . $aoe . $q . $zc . $f;
                 $image = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf;
             } else {
                 if ($cat_image_source != 1 && ($src = flexicontent_html::extractimagesrc($cat))) {
                     $h = '&amp;h=' . $cat_image_height;
                     $w = '&amp;w=' . $cat_image_width;
                     $aoe = '&amp;aoe=1';
                     $q = '&amp;q=95';
                     $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
                     $ext = pathinfo($src, PATHINFO_EXTENSION);
                     $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                     $conf = $w . $h . $aoe . $q . $zc . $f;
                     $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : '';
                     $src = $base_url . $src;
                     $image = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf;
                 }
             }
             $cat->image_src = @$src;
             // Also add image category URL for developers
             if ($image) {
                 $image = '<img class="fccat_image" src="' . $image . '" alt="' . $this->escape($cat->title) . '" title="' . $this->escape($cat->title) . '"/>';
             } else {
                 //$image = '<div class="fccat_image" style="height:'.$cat_image_height.'px;width:'.$cat_image_width.'px;" ></div>';
             }
             if ($cat_link_image && $image) {
                 $image = '<a href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)) . '">' . $image . '</a>';
             }
         }
         $cat->image = $image;
     }
     // ******************************
     // SUBCATEGORIES (some templates)
     // ******************************
     // sub-category image params
     $show_cat_image = $params->get('show_description_image_subcat', 1);
     // we use different name for variable
     $cat_image_source = $params->get('subcat_image_source', 2);
     // 0: extract, 1: use param, 2: use both
     $cat_link_image = $params->get('subcat_link_image', 1);
     $cat_image_method = $params->get('subcat_image_method', 1);
     $cat_image_width = $params->get('subcat_image_width', 24);
     $cat_image_height = $params->get('subcat_image_height', 24);
     // Create sub-category image/description/etc data
     foreach ($categories as $cat) {
         $image = "";
         if ($show_cat_image) {
             if (FLEXI_J16GE && !is_object($cat->params)) {
                 $cat->params = new JRegistry($cat->params);
             }
             $cat->image = FLEXI_J16GE ? $cat->params->get('image') : $cat->image;
             $image = "";
             $cat->introtext =& $cat->description;
             $cat->fulltext = "";
             if ($cat_image_source && $cat->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . $cat->image)) {
                 $src = JURI::base(true) . "/" . $joomla_image_url . $cat->image;
                 $h = '&amp;h=' . $cat_image_height;
                 $w = '&amp;w=' . $cat_image_width;
                 $aoe = '&amp;aoe=1';
                 $q = '&amp;q=95';
                 $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
                 $ext = pathinfo($src, PATHINFO_EXTENSION);
                 $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                 $conf = $w . $h . $aoe . $q . $zc . $f;
                 $image = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf;
             } else {
                 if ($cat_image_source != 1 && ($src = flexicontent_html::extractimagesrc($cat))) {
                     $h = '&amp;h=' . $cat_image_height;
                     $w = '&amp;w=' . $cat_image_width;
                     $aoe = '&amp;aoe=1';
                     $q = '&amp;q=95';
                     $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
                     $ext = pathinfo($src, PATHINFO_EXTENSION);
                     $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                     $conf = $w . $h . $aoe . $q . $zc . $f;
                     $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : '';
                     $src = $base_url . $src;
                     $image = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf;
                 }
             }
             $cat->image_src = @$src;
             // Also add image category URL for developers
             if ($image) {
                 $image = '<img class="fccat_image" src="' . $image . '" alt="' . $this->escape($cat->title) . '" title="' . $this->escape($cat->title) . '"/>';
             } else {
                 //$image = '<div class="fccat_image" style="height:'.$cat_image_height.'px;width:'.$cat_image_width.'px;" ></div>';
             }
             if ($cat_link_image && $image) {
                 $image = '<a href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)) . '">' . $image . '</a>';
             }
         }
         $cat->image = $image;
     }
     // *******************************
     // PEERCATEGORIES (some templates)
     // *******************************
     // peer-category image params
     $show_cat_image = $params->get('show_description_image_peercat', 1);
     // we use different name for variable
     $cat_image_source = $params->get('peercat_image_source', 2);
     // 0: extract, 1: use param, 2: use both
     $cat_link_image = $params->get('peercat_link_image', 1);
     $cat_image_method = $params->get('peercat_image_method', 1);
     $cat_image_width = $params->get('peercat_image_width', 24);
     $cat_image_height = $params->get('peercat_image_height', 24);
     // Create peer-category image/description/etc data
     foreach ($peercats as $cat) {
         $image = "";
         if ($show_cat_image) {
             if (FLEXI_J16GE && !is_object($cat->params)) {
                 $cat->params = new JRegistry($cat->params);
             }
             $cat->image = FLEXI_J16GE ? $cat->params->get('image') : $cat->image;
             $image = "";
             $cat->introtext =& $cat->description;
             $cat->fulltext = "";
             if ($cat_image_source && $cat->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . $cat->image)) {
                 $src = JURI::base(true) . "/" . $joomla_image_url . $cat->image;
                 $h = '&amp;h=' . $cat_image_height;
                 $w = '&amp;w=' . $cat_image_width;
                 $aoe = '&amp;aoe=1';
                 $q = '&amp;q=95';
                 $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
                 $ext = pathinfo($src, PATHINFO_EXTENSION);
                 $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                 $conf = $w . $h . $aoe . $q . $zc . $f;
                 $image = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf;
             } else {
                 if ($cat_image_source != 1 && ($src = flexicontent_html::extractimagesrc($cat))) {
                     $h = '&amp;h=' . $cat_image_height;
                     $w = '&amp;w=' . $cat_image_width;
                     $aoe = '&amp;aoe=1';
                     $q = '&amp;q=95';
                     $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
                     $ext = pathinfo($src, PATHINFO_EXTENSION);
                     $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                     $conf = $w . $h . $aoe . $q . $zc . $f;
                     $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? JURI::base(true) . '/' : '';
                     $src = $base_url . $src;
                     $image = JURI::base(true) . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=' . $src . $conf;
                 }
             }
             $cat->image_src = @$src;
             // Also add image category URL for developers
             if ($image) {
                 $image = '<img class="fccat_image" src="' . $image . '" alt="' . $this->escape($cat->title) . '" title="' . $this->escape($cat->title) . '"/>';
             } else {
                 //$image = '<div class="fccat_image" style="height:'.$cat_image_height.'px;width:'.$cat_image_width.'px;" ></div>';
             }
             if ($cat_link_image && $image) {
                 $image = '<a href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)) . '">' . $image . '</a>';
             }
         }
         $cat->image = $image;
     }
     // remove previous alpha index filter
     //$uri->delVar('letter');
     // remove filter variables (includes search box and sort order)
     preg_match_all('/filter[^=]*/', $uri->toString(), $matches);
     foreach ($matches[0] as $match) {
         //$uri->delVar($match);
     }
     // Build Lists
     $lists = array();
     //ordering
     $lists['filter_order'] = JRequest::getCmd('filter_order', 'i.title', 'default');
     $lists['filter_order_Dir'] = JRequest::getCmd('filter_order_Dir', 'ASC', 'default');
     $lists['filter'] = JRequest::getString('filter', '', 'default');
     // Add html to filter objects
     $form_name = 'adminForm';
     if ($filters) {
         FlexicontentFields::renderFilters($params, $filters, $form_name);
     }
     // ****************************
     // Create the pagination object
     // ****************************
     $pageNav = $this->get('pagination');
     $resultsCounter = $pageNav->getResultsCounter();
     // for overriding model's result counter
     // *********************************************************************
     // Create category link, but also consider current 'layout', and use the
     // layout specific variables so that filtering form will work properly
     // *********************************************************************
     $Itemid = $menu ? $menu->id : 0;
     $layout_vars = array();
     if ($layout) {
         $layout_vars['layout'] = $layout;
     }
     if ($authorid) {
         $layout_vars['authorid'] = $authorid;
     }
     if ($tagid) {
         $layout_vars['tagid'] = $tagid;
     }
     if ($cids) {
         $layout_vars['cids'] = $cids;
     }
     // Category link for single/multiple category(-ies)  --OR--  "current layout" link for myitems/author layouts
     if ($cid) {
         $category_link = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug, $Itemid, $layout_vars), false);
     } else {
         $urlvars_str = '';
         foreach ($layout_vars as $urlvar_name => $urlvar_val) {
             $urlvars_str .= '&' . $urlvar_name . '=' . $urlvar_val;
         }
         $category_link = JRoute::_('index.php?Itemid=' . $Itemid . '&option=com_flexicontent&view=category' . $urlvars_str . ($Itemid ? '&Itemid=' . $Itemid : ''));
     }
     // **********************************************************************
     // Print link ... must include layout and current filtering url vars, etc
     // **********************************************************************
     $curr_url = $_SERVER['REQUEST_URI'];
     $print_link = $curr_url . (strstr($curr_url, '?') ? '&amp;' : '?') . 'pop=1&amp;tmpl=component&amp;print=1';
     $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->assignRef('action', $category_link);
     // $uri->toString()
     $this->assignRef('print_link', $print_link);
     $this->assignRef('category', $category);
     $this->assignRef('categories', $categories);
     $this->assignRef('peercats', $peercats);
     $this->assignRef('items', $items);
     $this->assignRef('authordescr_item_html', $authordescr_item_html);
     $this->assignRef('lists', $lists);
     $this->assignRef('params', $params);
     $this->assignRef('pageNav', $pageNav);
     $this->assignRef('pageclass_sfx', $pageclass_sfx);
     $this->assignRef('pagination', $pageNav);
     // compatibility Alias for old templates
     $this->assignRef('resultsCounter', $resultsCounter);
     // for overriding model's result counter
     $this->assignRef('limitstart', $limitstart);
     // compatibility shortcut
     $this->assignRef('filters', $filters);
     $this->assignRef('comments', $comments);
     $this->assignRef('alpha', $alpha);
     $this->assignRef('tmpl', $tmpl);
     /*
      * Set template paths : this procedure is issued from K2 component
      *
      * "K2" Component by JoomlaWorks for Joomla! 1.5.x - Version 2.1
      * Copyright (c) 2006 - 2009 JoomlaWorks Ltd. All rights reserved.
      * Released under the GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
      * More info at http://www.joomlaworks.gr and http://k2.joomlaworks.gr
      * Designed and developed by the JoomlaWorks team
      */
     $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates');
     $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates');
     $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates' . DS . 'default');
     $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . 'default');
     if ($clayout) {
         $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates' . DS . $clayout);
         $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . $clayout);
     }
     // **************************************************
     // increment the hit counter ONLY once per user visit
     // **************************************************
     // MOVED to flexisystem plugin due to ...
     /*if (FLEXI_J16GE && $category->id && empty($layout)) {
     			$hit_accounted = false;
     			$hit_arr = array();
     			if ($session->has('cats_hit', 'flexicontent')) {
     				$hit_arr 	= $session->get('cats_hit', array(), 'flexicontent');
     				$hit_accounted = isset($hit_arr[$category->id]);
     			}
     			if (!$hit_accounted) {
     				//add hit to session hit array
     				$hit_arr[$category->id] = $timestamp = time();  // Current time as seconds since Unix epoc;
     				$session->set('cats_hit', $hit_arr, 'flexicontent');
     				$this->getModel()->hit();
     			}
     		}*/
     $print_logging_info = $params->get('print_logging_info');
     if ($print_logging_info) {
         global $fc_run_times;
         $start_microtime = microtime(true);
     }
     parent::display($tpl);
     if ($print_logging_info) {
         @($fc_run_times['template_render'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
     }
 }
Ejemplo n.º 16
0
 /**
  * Creates images from the original one or moves the existing ones
  * into the folders of their category.
  *
  * Required parameters are the first two ($row and $origimage) with $row being the data object with image
  * information and $origimage being the path and filename of the image to migrate. $origimage will be the one
  * stored in the original images directory of JoomGallery.
  * You can also specify $detailimage and $thumbnail which will store them in the respective folders. If you
  * don't specify them they will be created from the original image.
  *
  * [jimport('joomla.filesystem.file') has to be called afore]
  *
  * @param   object  $row          Holds information about the new image
  * @param   string  $origimage    The original image
  * @param   string  $detailimage  The detail image
  * @param   string  $thumbnail    The thumbnail
  * @param   boolean $newfilename  True if a new file name shall be generated for the files
  * @param   boolean $copy         True if the image shall be copied into the new directory, not moved
  * @param   boolean $checkOwner   Determines whether the owner ID shall be checked against the existing users
  * @return  boolean True on success, false otherwise
  * @since   1.5.0
  */
 public function moveAndResizeImage($row, $origimage, $detailimage = null, $thumbnail = null, $newfilename = true, $copy = null, $checkOwner = null)
 {
     if (is_null($copy)) {
         $copy = $this->copyImages;
     }
     if (is_null($checkOwner)) {
         $checkOwner = $this->checkOwner;
     }
     // Some checks
     if (!isset($row->id) || $row->id < 1) {
         $this->setError('Invalid image ID');
         return false;
     }
     if (!isset($row->imgfilename)) {
         $this->setError('Image file name wasn\'t found.');
         return false;
     }
     if (!isset($row->catid) || $row->catid < 1) {
         $this->setError('Invalid category ID');
         return false;
     } else {
         // If image with category ID 1 comes in we have to set
         // the category ID to the newly created one because
         // category with ID 1 is the ROOT category in JoomGallery
         if ($row->catid == 1) {
             $row->catid = $this->newCatid;
         }
     }
     if (!isset($row->catpath)) {
         $row->catpath = JoomHelper::getCatpath($row->catid);
         if (!$row->catpath) {
             $this->setError('Category with ID ' . $row->catid . ' does not exist for image with ID ' . $row->id . '. Image cannot be migrated.');
             return false;
         }
     }
     if (!isset($row->imgtitle)) {
         $row->imgtitle = str_replace(JFile::getExt($row->imgfilename), '', $row->imgfilename);
     }
     if (!isset($row->alias)) {
         // Will be created later on
         $row->alias = '';
     }
     if (!isset($row->imgauthor)) {
         $row->imgauthor = '';
     }
     if (!isset($row->imgtext)) {
         $row->imgtext = '';
     }
     if (!isset($row->imgdate) || is_numeric($row->imgdate)) {
         $date = JFactory::getDate();
         $row->imgdate = $date->toSQL();
     }
     if (!isset($row->hits)) {
         $row->hits = 0;
     }
     if (!isset($row->downloads)) {
         $row->downloads = 0;
     }
     if (!isset($row->imgvotes)) {
         $row->imgvotes = 0;
     }
     if (!isset($row->imgvotesum)) {
         $row->imgvotesum = 0;
     }
     if (!isset($row->access) || $row->access < 1) {
         $row->access = $this->_mainframe->getCfg('access');
     }
     if (!isset($row->published)) {
         $row->published = 0;
     }
     if (!isset($row->hidden)) {
         $row->hidden = 0;
     }
     if (!isset($row->imgthumbname)) {
         $row->imgthumbname = $row->imgfilename;
     }
     if (!isset($row->checked_out)) {
         $row->checked_out = 0;
     }
     if (!isset($row->owner) || !is_numeric($row->owner) || $row->owner < 1 || $checkOwner && !JUser::getTable()->load($row->owner)) {
         $row->owner = 0;
     }
     if (!isset($row->approved)) {
         $row->approved = 1;
     }
     if (!isset($row->useruploaded)) {
         $row->useruploaded = 0;
     }
     if (!isset($row->ordering)) {
         $row->ordering = 0;
     }
     if (!isset($row->params)) {
         $row->params = '';
     }
     if (!isset($row->metakey)) {
         $row->metakey = '';
     }
     if (!isset($row->metadesc)) {
         $row->metadesc = '';
     }
     // Check whether one of the images to migrate already exist in the destination directory
     $orig_exists = false;
     $img_exists = false;
     $thumb_exists = false;
     $neworigimage = $this->_ambit->getImg('orig_path', $row);
     $newdetailimage = $this->_ambit->getImg('img_path', $row);
     $newthumbnail = $this->_ambit->getImg('thumb_path', $row);
     if (JFile::exists($neworigimage)) {
         $orig_exists = true;
     }
     if (JFile::exists($newdetailimage)) {
         $img_exists = true;
     }
     if (JFile::exists($newthumbnail)) {
         $thumb_exists = true;
     }
     // Generate a new file name if requested or if a file with the current name already exists
     if ($newfilename || $orig_exists || $img_exists || $thumb_exists) {
         $row->imgfilename = $this->genFilename($row->imgtitle, $origimage, $row->catid);
         $row->imgthumbname = $row->imgfilename;
     }
     $result = array();
     // Copy or move original image into the folder of the original images
     if (!$orig_exists) {
         // If it doesn't already exists with another name try to copy or move from source directory
         if (!JFile::exists($origimage)) {
             $this->setError('Original image not found: ' . $origimage);
             return false;
         }
         $neworigimage = $this->_ambit->getImg('orig_path', $row);
         if ($copy) {
             $result['orig'] = JFile::copy(JPath::clean($origimage), JPath::clean($neworigimage));
             if (!$result['orig']) {
                 $this->setError('Could not copy original image from ' . $origimage . ' to ' . $neworigimage);
                 return false;
             }
         } else {
             $result['orig'] = JFile::move(JPath::clean($origimage), JPath::clean($neworigimage));
             if (!$result['orig']) {
                 $this->setError('Could not move original image from ' . $origimage . ' to ' . $neworigimage);
                 return false;
             }
         }
     } else {
         // If it already exists with another name copy it to a file with the new name
         if (!JFile::copy($neworigimage, $this->_ambit->getImg('orig_path', $row))) {
             $this->setError('Could not copy original image from ' . $neworigimage . ' to ' . $this->_ambit->getImg('orig_path', $row));
             return false;
         }
         // Populate the new original file name and path because it will be
         // necessary for deleting it of deleting original images is configured
         $neworigimage = $this->_ambit->getImg('orig_path', $row);
     }
     if (!$img_exists) {
         // If it doesn't already exists with another name try to copy or move from source directory or create a new one
         $newdetailimage = $this->_ambit->getImg('img_path', $row);
         if (is_null($detailimage) || !JFile::exists($detailimage)) {
             // Create new detail image
             $debugoutput = '';
             $result['detail'] = JoomFile::resizeImage($debugoutput, $neworigimage, $newdetailimage, false, $this->_config->get('jg_maxwidth'), false, $this->_config->get('jg_thumbcreation'), $this->_config->get('jg_thumbquality'), true, 0);
             if (!$result['detail']) {
                 $this->setError('Could not create detail image ' . $newdetailimage);
             }
         } else {
             // Copy or move existing detail image
             if ($copy) {
                 $result['detail'] = JFile::copy(JPath::clean($detailimage), JPath::clean($newdetailimage));
                 if (!$result['detail']) {
                     $this->setError('Could not copy detail image from ' . $detailimage . ' to ' . $newdetailimage);
                 }
             } else {
                 $result['detail'] = JFile::move(JPath::clean($detailimage), JPath::clean($newdetailimage));
                 if (!$result['detail']) {
                     $this->setError('Could not move detail image from ' . $detailimage . ' to ' . $newdetailimage);
                 }
             }
         }
     } else {
         // If it already exists with another name copy it to a file with the new name
         $result['detail'] = JFile::copy($newdetailimage, $this->_ambit->getImg('img_path', $row));
         if (!$result['detail']) {
             $this->setError('Could not copy detail image from ' . $newdetailimage . ' to ' . $this->_ambit->getImg('img_path', $row));
         }
     }
     if (!$thumb_exists) {
         // If it doesn't already exists with another name try to copy or move from source directory or create a new one
         $newthumbnail = $this->_ambit->getImg('thumb_path', $row);
         if (is_null($thumbnail) || !JFile::exists($thumbnail)) {
             // Create new thumbnail
             $debugoutput = '';
             $result['thumb'] = JoomFile::resizeImage($debugoutput, $neworigimage, $newthumbnail, $this->_config->get('jg_useforresizedirection'), $this->_config->get('jg_thumbwidth'), $this->_config->get('jg_thumbheight'), $this->_config->get('jg_thumbcreation'), $this->_config->get('jg_thumbquality'), false, $this->_config->get('jg_cropposition'));
             if (!$result['thumb']) {
                 $this->setError('Could not create thumbnail ' . $newthumbnail);
             }
         } else {
             // Copy or move existing thumbnail
             if ($copy) {
                 $result['thumb'] = JFile::copy(JPath::clean($thumbnail), JPath::clean($newthumbnail));
                 if (!$result['thumb']) {
                     $this->setError('Could not copy thumbnail from ' . $thumbnail . ' to ' . $newthumbnail);
                 }
             } else {
                 $result['thumb'] = JFile::move(JPath::clean($thumbnail), JPath::clean($newthumbnail));
                 if (!$result['thumb']) {
                     $this->setError('Could not move thumbnail from ' . $thumbnail . ' to ' . $newthumbnail);
                 }
             }
         }
     } else {
         // If it already exists with another name copy it to a file with the new name
         $result['thumb'] = JFile::copy($newthumbnail, $this->_ambit->getImg('thumb_path', $row));
         if (!$result['thumb']) {
             $this->setError('Could not copy thumbnail from ' . $newthumbnail . ' to ' . $this->_ambit->getImg('thumb_path', $row));
         }
     }
     // Delete original image if configured in JoomGallery
     if ($this->_config->get('jg_delete_original') == 1) {
         $result['delete_orig'] = JFile::delete($neworigimage);
         if (!$result['delete_orig']) {
             $this->setError('Could not delete original image ' . $neworigimage);
         }
     }
     // Create database entry
     $query = $this->_db->getQuery(true)->insert(_JOOM_TABLE_IMAGES)->columns('id, catid, imgtitle, alias, imgauthor, imgtext, imgdate, hits, downloads, imgvotes, imgvotesum, access, published, hidden, imgfilename, imgthumbname, checked_out, owner, approved, useruploaded, ordering, params, metakey, metadesc')->values((int) $row->id . ',' . (int) $row->catid . ',' . $this->_db->quote($row->imgtitle) . ',' . $this->_db->quote($row->alias) . ',' . $this->_db->quote($row->imgauthor) . ',' . $this->_db->quote($row->imgtext) . ',' . $this->_db->quote($row->imgdate) . ',' . (int) $row->hits . ',' . (int) $row->downloads . ',' . (int) $row->imgvotes . ',' . (int) $row->imgvotesum . ',' . (int) $row->access . ',' . (int) $row->published . ',' . (int) $row->hidden . ',' . $this->_db->quote($row->imgfilename) . ',' . $this->_db->quote($row->imgthumbname) . ',' . (int) $row->checked_out . ',' . (int) $row->owner . ',' . (int) $row->approved . ',' . (int) $row->useruploaded . ',' . (int) $row->ordering . ',' . $this->_db->quote($row->params) . ',' . $this->_db->quote($row->metakey) . ',' . $this->_db->quote($row->metadesc));
     $this->_db->setQuery($query);
     $result[] = $this->runQuery();
     // Create asset and alias
     $table = JTable::getInstance('joomgalleryimages', 'Table');
     $table->load($row->id);
     if ($table->check()) {
         $result['db'] = $table->store();
         if (!$result['db']) {
             $this->setError($table->getError(), true);
         }
     }
     if (!in_array(false, $result)) {
         $this->writeLogfile('Image successfully migrated: ' . $row->id . ' Title: ' . $row->imgtitle);
         return true;
     } else {
         $this->writeLogfile('-> Error migrating image: ' . $row->id . ' Title: ' . $row->imgtitle);
         return false;
     }
 }
Ejemplo n.º 17
0
 /**
  * Creates the page's display
  *
  * @since 1.0
  */
 function display($tpl = null)
 {
     // Get Non-routing Categories, and Category Tree
     global $globalnoroute, $globalcats;
     if (!is_array($globalnoroute)) {
         $globalnoroute = array();
     }
     //initialize variables
     $dispatcher = JDispatcher::getInstance();
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     $option = JRequest::getVar('option');
     $format = JRequest::getCmd('format', 'html');
     $document = JFactory::getDocument();
     // Check for Joomla issue with system plugins creating JDocument in early events forcing it to be wrong type, when format as url suffix is enabled
     if ($format && $document->getType() != strtolower($format)) {
         echo '<div class="alert">WARNING: &nbsp; Document format should be: <b>' . $format . '</b> but current document is: <b>' . $document->getType() . '</b> <br/>Some system plugin may have forced current document type</div>';
     }
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $uri = JFactory::getURI();
     $user = JFactory::getUser();
     $aid = JAccess::getAuthorisedViewLevels($user->id);
     // Get model
     $model = $this->getModel();
     // Get category and set category parameters as VIEW's parameters (category parameters are merged with component/page/author parameters already)
     $category = $this->get('Category');
     $params = $category->parameters;
     if ($category->id) {
         $meta_params = new JRegistry($category->metadata);
     }
     // Get various data from the model
     $categories = $this->get('Childs');
     // this will also count sub-category items is if  'show_itemcount'  is enabled
     $peercats = $this->get('Peers');
     // this will also count sub-category items is if  'show_subcatcount_peercat'  is enabled
     $items = $this->get('Data');
     $total = $this->get('Total');
     $filters = $this->get('Filters');
     if ($params->get('show_comments_count', 0)) {
         $comments = $this->get('CommentsInfo');
     } else {
         $comments = null;
     }
     $alpha = $params->get('show_alpha', 1) ? $this->get('Alphaindex') : array();
     // This is somwhat expensive so calculate it only if required
     // Request variables, WARNING, must be loaded after retrieving items, because limitstart may have been modified
     $limitstart = JRequest::getInt('limitstart');
     // ********************************
     // Load needed JS libs & CSS styles
     // ********************************
     FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
     flexicontent_html::loadFramework('jQuery');
     flexicontent_html::loadFramework('flexi_tmpl_common');
     // Add css files to the document <head> section (also load CSS joomla template override)
     if (!$params->get('disablecss', '')) {
         $document->addStyleSheetVersion($this->baseurl . '/components/com_flexicontent/assets/css/flexicontent.css', FLEXI_VHASH);
         //$document->addCustomTag('<!--[if IE]><style type="text/css">.floattext {zoom:1;}</style><![endif]-->');
     }
     if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . 'flexicontent.css')) {
         $document->addStyleSheetVersion($this->baseurl . '/templates/' . $app->getTemplate() . '/css/flexicontent.css', FLEXI_VHASH);
     }
     // ************************
     // CATEGORY LAYOUT handling
     // ************************
     // (a) Decide to use mobile or normal category template layout
     $useMobile = $params->get('use_mobile_layouts', 0);
     if ($useMobile) {
         $force_desktop_layout = $params->get('force_desktop_layout', 0);
         $mobileDetector = flexicontent_html::getMobileDetector();
         $isMobile = $mobileDetector->isMobile();
         $isTablet = $mobileDetector->isTablet();
         $useMobile = $force_desktop_layout ? $isMobile && !$isTablet : $isMobile;
     }
     $_clayout = $useMobile ? 'clayout_mobile' : 'clayout';
     // (b) Get from category parameters, allowing URL override
     $clayout = JRequest::getCmd($_clayout, false);
     if (!$clayout) {
         $desktop_clayout = $params->get('clayout', 'blog');
         $clayout = !$useMobile ? $desktop_clayout : $params->get('clayout_mobile', $desktop_clayout);
     }
     // (c) Get cached template data
     $themes = flexicontent_tmpl::getTemplates($lang_files = array($clayout));
     // (d) Verify the category layout exists
     if (!isset($themes->category->{$clayout})) {
         $fixed_clayout = 'blog';
         $app->enqueueMessage("<small>Current Category Layout Template is '{$clayout}' does not exist<br>- Please correct this in the URL or in Content Type configuration.<br>- Using Template Layout: '{$fixed_clayout}'</small>", 'notice');
         $clayout = $fixed_clayout;
         FLEXIUtilities::loadTemplateLanguageFile($clayout);
         // Manually load Template-Specific language file of back fall clayout
     }
     // (e) finally set the template name back into the category's parameters
     $params->set('clayout', $clayout);
     // Get URL variables
     $layout_vars = flexicontent_html::getCatViewLayoutVars($model);
     $layout = $layout_vars['layout'];
     $authorid = $layout_vars['authorid'];
     $tagid = $layout_vars['tagid'];
     $cids = $layout_vars['cids'];
     $cid = $layout_vars['cid'];
     // Get Tag data if current layout is 'tags'
     if ($tagid) {
         $tag = $this->get('Tag');
     }
     $authordescr_item = false;
     if ($authorid && $params->get('authordescr_itemid') && $format != 'feed') {
         $authordescr_itemid = $params->get('authordescr_itemid');
     }
     // Bind Fields to items and render their display HTML, but check for document type, due to Joomla issue
     // with system plugins creating JDocument in early events forcing it to be wrong type, when format as url suffix is enabled
     if ($format != 'feed') {
         $items = FlexicontentFields::getFields($items, 'category', $params, $aid);
     }
     //Set layout
     $this->setLayout('category');
     $limit = $app->getUserStateFromRequest('com_flexicontent' . $category->id . '.category.limit', 'limit', $params->def('limit', 0), 'int');
     // Get category titles needed by pathway, this will allow Falang to translate them
     $catshelper = new flexicontent_cats($cid);
     $parents = $catshelper->getParentlist($all_cols = false);
     //echo "<pre>".print_r($parents,true)."</pre>";
     /*$parents = array();
     		if ( $cid && isset($globalcats[$cid]->ancestorsarray) ) {
     			$parent_ids = $globalcats[$cid]->ancestorsarray;
     			foreach ($parent_ids as $parent_id) $parents[] = $globalcats[$parent_id];
     		}*/
     $rootcat = (int) $params->get('rootcat');
     if ($rootcat) {
         $root_parents = $globalcats[$rootcat]->ancestorsarray;
     }
     // **********************************************************
     // Calculate a (browser window) page title and a page heading
     // **********************************************************
     // Verify menu item points to current FLEXIcontent object
     if ($menu) {
         $view_ok = 'category' == @$menu->query['view'];
         $cid_ok = $cid == (int) @$menu->query['cid'];
         $layout_ok = $layout == @$menu->query['layout'];
         // null is equal to empty string
         $authorid_ok = $authorid == (int) @$menu->query['authorid'];
         // null is equal to zero
         $tagid_ok = $tagid == (int) @$menu->query['tagid'];
         // null is equal to zero
         $menu_matches = $view_ok && $cid_ok && $layout_ok && $authorid_ok && $tagid_ok;
         //$menu_params = FLEXI_J16GE ? $menu->params : new JParameter($menu->params);  // Get active menu item parameters
     } else {
         $menu_matches = false;
     }
     // MENU ITEM matched, use its page heading (but use menu title if the former is not set)
     if ($menu_matches) {
         $default_heading = FLEXI_J16GE ? $menu->title : $menu->name;
         // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->def('page_heading', $params->get('page_title', $default_heading));
         $params->def('page_title', $params->get('page_heading', $default_heading));
         $params->def('show_page_heading', $params->get('show_page_title', 0));
         $params->def('show_page_title', $params->get('show_page_heading', 0));
     } else {
         // Clear some menu parameters
         //$params->set('pageclass_sfx',	'');  // CSS class SUFFIX is behavior, so do not clear it ?
         // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ...
         switch ($layout) {
             case '':
                 $default_heading = $category->title;
                 break;
             case 'myitems':
                 $default_heading = JText::_('FLEXI_MY_CONTENT');
                 break;
             case 'author':
                 $default_heading = JText::_('FLEXI_CONTENT_BY_AUTHOR') . ': ' . JFactory::getUser($authorid)->get('name');
                 break;
             case 'tags':
                 $default_heading = JText::_('FLEXI_ITEMS_WITH_TAG') . ': ' . $tag->name;
                 break;
             case 'favs':
                 $default_heading = JText::_('FLEXI_YOUR_FAVOURED_ITEMS');
                 break;
             default:
                 $default_heading = JText::_('FLEXI_CONTENT_IN_CATEGORY');
         }
         if ($layout && $cid) {
             // Non-single category listings, limited to a specific category
             $default_heading .= ', ' . JText::_('FLEXI_IN_CATEGORY') . ': ' . $category->title;
         }
         // Decide to show page heading (=J1.5 page title) only if a custom layout is used (=not a single category layout)
         $show_default_heading = $layout ? 1 : 0;
         // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->set('page_title', $default_heading);
         $params->set('page_heading', $default_heading);
         $params->set('show_page_heading', $show_default_heading);
         $params->set('show_page_title', $show_default_heading);
     }
     // Prevent showing the page heading if (a) IT IS same as category title and (b) category title is already configured to be shown
     if ($params->get('show_cat_title', 1)) {
         if ($params->get('page_heading') == $category->title) {
             $params->set('show_page_heading', 0);
         }
         if ($params->get('page_title') == $category->title) {
             $params->set('show_page_title', 0);
         }
     }
     // ************************************************************
     // Create the document title, by from page title and other data
     // ************************************************************
     // Use the page heading as document title, (already calculated above via 'appropriate' logic ...)
     // or the overriden custom <title> ... set via parameter
     $doc_title = empty($meta_params) ? $params->get('page_title') : $meta_params->get('page_title', $params->get('page_title'));
     // Check and prepend or append site name to page title
     if ($doc_title != $app->getCfg('sitename')) {
         if ($app->getCfg('sitename_pagetitles', 0) == 1) {
             $doc_title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $doc_title);
         } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
             $doc_title = JText::sprintf('JPAGETITLE', $doc_title, $app->getCfg('sitename'));
         }
     }
     // Finally, set document title
     $document->setTitle($doc_title);
     // ************************
     // Set document's META tags
     // ************************
     // Workaround for Joomla not setting the default value for 'robots', so component must do it
     $app_params = $app->getParams();
     if ($_mp = $app_params->get('robots')) {
         $document->setMetadata('robots', $_mp);
     }
     if ($category->id) {
         // possibly not set for author items OR my items
         if ($category->metadesc) {
             $document->setDescription($category->metadesc);
         }
         if ($category->metakey) {
             $document->setMetadata('keywords', $category->metakey);
         }
         // meta_params are always set if J1.6+ and category id is set
         if ($meta_params->get('robots')) {
             $document->setMetadata('robots', $meta_params->get('robots'));
         }
         // ?? Deprecated <title> tag is used instead by search engines
         if ($app->getCfg('MetaTitle') == '1') {
             $meta_title = $meta_params->get('page_title') ? $meta_params->get('page_title') : $category->title;
             $document->setMetaData('title', $meta_title);
         }
         if ($app->getCfg('MetaAuthor') == '1') {
             if ($meta_params->get('author')) {
                 $meta_author = $meta_params->get('author');
             } else {
                 $table = JUser::getTable();
                 $meta_author = $table->load($category->created_user_id) ? $table->name : '';
             }
             $document->setMetaData('author', $meta_author);
         }
     }
     // Overwrite with menu META data if menu matched
     if ($menu_matches) {
         if ($_mp = $menu->params->get('menu-meta_description')) {
             $document->setDescription($_mp);
         }
         if ($_mp = $menu->params->get('menu-meta_keywords')) {
             $document->setMetadata('keywords', $_mp);
         }
         if ($_mp = $menu->params->get('robots')) {
             $document->setMetadata('robots', $_mp);
         }
         if ($_mp = $menu->params->get('secure')) {
             $document->setMetadata('secure', $_mp);
         }
     }
     // *********************************************************************
     // Create category link, but also consider current 'layout', and use the
     // layout specific variables so that filtering form will work properly
     // *********************************************************************
     $non_sef_link = null;
     $category_link = flexicontent_html::createCatLink($category->slug, $non_sef_link, $model);
     // ****************************************************************
     // Make sure Joomla SEF plugin has inserted a correct REL canonical
     // or that it has not insert any REL if current URL is sufficient
     // ****************************************************************
     if ($params->get('add_canonical')) {
         // Get canonical URL that SEF plugin adds, also $domain passed by reference, to get the domain configured in SEF plugin (multi-domain website)
         $domain = null;
         $defaultCanonical = flexicontent_html::getDefaultCanonical($domain);
         $domain = $domain ? $domain : $uri->toString(array('scheme', 'host', 'port'));
         // Create desired REL canonical URL
         $start = JRequest::getInt('start', '');
         $ucanonical = $domain . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($category->slug) . ($start ? "&start=" . $start : ''));
         // Check if SEF plugin inserted a different REL canonical
         if ($defaultCanonical != $ucanonical) {
             // Add REL canonical only if different than current URL
             $head_obj = $document->addHeadLink(htmlspecialchars($ucanonical), 'canonical', 'rel', '');
             if ($uri->toString() == $ucanonical) {
                 unset($head_obj->_links[htmlspecialchars($ucanonical)]);
             }
             // Remove canonical inserted by SEF plugin
             unset($head_obj->_links[htmlspecialchars($defaultCanonical)]);
         }
     }
     if ($params->get('show_feed_link', 1) == 1) {
         //add alternate feed link
         $link = $non_sef_link . '&format=feed';
         $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
         $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
         $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
         $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
     }
     // ********************************************************************************************
     // Create pathway, if automatic pathways is enabled, then path will be cleared before populated
     // ********************************************************************************************
     $pathway = $app->getPathWay();
     // Clear pathway, if automatic pathways are enabled
     if ($params->get('automatic_pathways', 0)) {
         $pathway_arr = $pathway->getPathway();
         $pathway->setPathway(array());
         //$pathway->set('_count', 0);  // not needed ??
         $item_depth = 0;
         // menu item depth is now irrelevant ???, ignore it
     } else {
         $item_depth = $params->get('item_depth', 0);
     }
     // Respect menu item depth, defined in menu item
     $p = $item_depth;
     while ($p < count($parents)) {
         // Do not add the directory root category or its parents (this when coming from a directory view)
         if (!empty($root_parents) && in_array($parents[$p]->id, $root_parents)) {
             $p++;
             continue;
         }
         // Do not add to pathway unroutable categories
         if (in_array($parents[$p]->id, $globalnoroute)) {
             $p++;
             continue;
         }
         // Add current parent category
         $pathway->addItem($this->escape($parents[$p]->title), JRoute::_(FlexicontentHelperRoute::getCategoryRoute($parents[$p]->slug)));
         $p++;
     }
     //echo "<pre>"; print_r($pathway); echo "</pre>";
     $authordescr_item_html = false;
     if ($authordescr_item) {
         $flexi_html_helper = new flexicontent_html();
         $authordescr_item_html = $flexi_html_helper->renderItem($authordescr_itemid);
     }
     //echo $authordescr_item_html; exit();
     if ($clayout) {
         // Add the templates css files if availables
         if (isset($themes->category->{$clayout}->css)) {
             foreach ($themes->category->{$clayout}->css as $css) {
                 $document->addStyleSheet($this->baseurl . '/' . $css);
             }
         }
         // Add the templates js files if availables
         if (isset($themes->category->{$clayout}->js)) {
             foreach ($themes->category->{$clayout}->js as $js) {
                 $document->addScript($this->baseurl . '/' . $js);
             }
         }
         // Set the template var
         $tmpl = $themes->category->{$clayout}->tmplvar;
     } else {
         $tmpl = '.category.default';
     }
     // @TODO trigger the plugin selectively
     // and delete the plugins tags if not active
     if ($params->get('trigger_onprepare_content_cat')) {
         JPluginHelper::importPlugin('content');
         // Allow to trigger content plugins on category description
         // NOTE: for J2.5, we will trigger the plugins as if description text was an article text, using ... 'com_content.article'
         $category->text = $category->description;
         $results = $dispatcher->trigger('onContentPrepare', array('com_content.article', &$category, &$params, 0));
         JRequest::setVar('layout', $layout);
         // Restore LAYOUT variable should some plugin have modified it
         $category->description = $category->text;
     }
     // Maybe here not to import all plugins but just those for description field or add a parameter for this
     // Anyway these events are usually not very time consuming as is the the event onPrepareContent(J1.5)/onContentPrepare(J1.6+)
     JPluginHelper::importPlugin('content');
     $noroute_cats = array_flip($globalnoroute);
     $type_attribs = flexicontent_db::getTypeAttribs($force = true, $typeid = 0);
     $type_params = array();
     foreach ($items as $item) {
         $item->event = new stdClass();
         if (!isset($type_params[$item->type_id])) {
             $type_params[$item->type_id] = new JRegistry($type_attribs[$item->type_id]);
         }
         $item->params = clone $type_params[$item->type_id];
         $item->params->merge(new JRegistry($item->attribs));
         //$item->cats = isset($item->cats) ? $item->cats : array();
         // !!! The triggering of the event onPrepareContent(J1.5)/onContentPrepare(J1.6+) of content plugins
         // !!! for description field (maintext) along with all other flexicontent
         // !!! fields is handled by flexicontent.fields.php
         // !!! Had serious performance impact
         // CODE REMOVED
         // We must check if the current category is in the categories of the item ..
         $item_in_category = false;
         if ($item->catid == $category->id) {
             $item_in_category = true;
         } else {
             foreach ($item->cats as $cat) {
                 if ($cat->id == $category->id) {
                     $item_in_category = true;
                     break;
                 }
             }
         }
         // ADVANCED CATEGORY ROUTING (=set the most appropriate category for the item ...)
         // CHOOSE APPROPRIATE category-slug FOR THE ITEM !!! ( )
         if ($item_in_category && !isset($noroute_cats[$category->id])) {
             // 1. CATEGORY SLUG: CURRENT category
             // Current category IS a category of the item and ALSO routing (creating links) to this category is allowed
             $item->categoryslug = $category->slug;
         } else {
             if (!isset($noroute_cats[$item->catid])) {
                 // 2. CATEGORY SLUG: ITEM's MAIN category   (already SET, ... no assignment needed)
                 // Since we cannot use current category (above), we will use item's MAIN category
                 // ALSO routing (creating links) to this category is allowed
             } else {
                 // 3. CATEGORY SLUG: ANY ITEM's category
                 // We will use the first for which routing (creating links) to the category is allowed
                 $allcats = array();
                 foreach ($item->cats as $cat) {
                     if (!isset($noroute_cats[$cat->id])) {
                         $item->categoryslug = $globalcats[$cat->id]->slug;
                         break;
                     }
                 }
             }
         }
         // Just put item's text (description field) inside property 'text' in case the events modify the given text,
         $item->text = isset($item->fields['text']->display) ? $item->fields['text']->display : '';
         // Set the view and option to 'category' and 'com_content'  (actually view is already called category)
         JRequest::setVar('option', 'com_content');
         JRequest::setVar("isflexicontent", "yes");
         // These events return text that could be displayed at appropriate positions by our templates
         $item->event = new stdClass();
         $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.category', &$item, &$params, 0));
         $item->event->afterDisplayTitle = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.category', &$item, &$params, 0));
         $item->event->beforeDisplayContent = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.category', &$item, &$params, 0));
         $item->event->afterDisplayContent = trim(implode("\n", $results));
         // Set the option back to 'com_flexicontent'
         JRequest::setVar('option', 'com_flexicontent');
         // Put text back into the description field, THESE events SHOULD NOT modify the item text, but some plugins may do it anyway... , so we assign text back for compatibility
         $item->fields['text']->display =& $item->text;
     }
     // Calculate CSS classes needed to add special styling markups to the items
     flexicontent_html::calculateItemMarkups($items, $params);
     // *****************************************************
     // Remove unroutable categories from sub/peer categories
     // *****************************************************
     // sub-cats
     $_categories = array();
     foreach ($categories as $i => $cat) {
         if (in_array($cat->id, $globalnoroute)) {
             continue;
         }
         $_categories[] = $categories[$i];
     }
     $categories = $_categories;
     // peer-cats
     $_categories = array();
     foreach ($peercats as $i => $cat) {
         if (in_array($cat->id, $globalnoroute)) {
             continue;
         }
         $_categories[] = $peercats[$i];
     }
     $peercats = $_categories;
     // ************************************
     // Get some variables needed for images
     // ************************************
     $joomla_image_path = $app->getCfg('image_path', '');
     $joomla_image_url = str_replace(DS, '/', $joomla_image_path);
     $joomla_image_path = $joomla_image_path ? $joomla_image_path . DS : '';
     $joomla_image_url = $joomla_image_url ? $joomla_image_url . '/' : '';
     $phpThumbURL = $this->baseurl . '/components/com_flexicontent/librairies/phpthumb/phpThumb.php?src=';
     // **************
     // CATEGORY IMAGE
     // **************
     // category image params
     $show_cat_image = $params->get('show_description_image', 0);
     // we use different name for variable
     $cat_image_source = $params->get('cat_image_source', 2);
     // 0: extract, 1: use param, 2: use both
     $cat_link_image = $params->get('cat_link_image', 1);
     $cat_image_method = $params->get('cat_image_method', 1);
     $cat_image_width = $params->get('cat_image_width', 80);
     $cat_image_height = $params->get('cat_image_height', 80);
     $cat_default_image = $params->get('cat_default_image', '');
     if ($show_cat_image) {
         $h = '&amp;h=' . $cat_image_height;
         $w = '&amp;w=' . $cat_image_width;
         $aoe = '&amp;aoe=1';
         $q = '&amp;q=95';
         $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
     }
     if ($cat_default_image) {
         $src = $this->baseurl . "/" . $joomla_image_url . $cat_default_image;
         $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
         $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
         $conf = $w . $h . $aoe . $q . $zc . $f;
         $default_image = $phpThumbURL . $src . $conf;
         $default_image = '<img class="fccat_image" style="float:' . $cat_image_float . '" src="' . $default_image . '" alt="%s" title="%s"/>';
     } else {
         $default_image = '';
     }
     // Create category image/description/etc data
     $cat = $category;
     $image = "";
     if ($cat) {
         if ($cat->id && $show_cat_image) {
             $cat->image = $params->get('image');
             $cat->introtext =& $cat->description;
             $cat->fulltext = "";
             if ($cat_image_source && $cat->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . $cat->image)) {
                 $src = $this->baseurl . "/" . $joomla_image_url . $cat->image;
                 $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
                 $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                 $conf = $w . $h . $aoe . $q . $zc . $f;
                 $image = $phpThumbURL . $src . $conf;
             } else {
                 if ($cat_image_source != 1 && ($src = flexicontent_html::extractimagesrc($cat))) {
                     $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
                     $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                     $conf = $w . $h . $aoe . $q . $zc . $f;
                     $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? $this->baseurl . '/' : '';
                     $src = $base_url . $src;
                     $image = $phpThumbURL . $src . $conf;
                 }
             }
             $cat->image_src = @$src;
             // Also add image category URL for developers
             if ($image) {
                 $image = '<img class="fccat_image" src="' . $image . '" alt="' . $this->escape($cat->title) . '" title="' . $this->escape($cat->title) . '"/>';
             } else {
                 if ($default_image) {
                     $image = sprintf($default_image, $cat->title, $cat->title);
                 }
             }
             if ($cat_link_image && $image) {
                 $image = '<a href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)) . '">' . $image . '</a>';
             }
         }
         $cat->image = $image;
     }
     // ******************************
     // SUBCATEGORIES (some templates)
     // ******************************
     // sub-category image params
     $show_cat_image = $params->get('show_description_image_subcat', 1);
     // we use different name for variable
     $cat_image_source = $params->get('subcat_image_source', 2);
     // 0: extract, 1: use param, 2: use both
     $cat_link_image = $params->get('subcat_link_image', 1);
     $cat_image_method = $params->get('subcat_image_method', 1);
     $cat_image_width = $params->get('subcat_image_width', 24);
     $cat_image_height = $params->get('subcat_image_height', 24);
     $cat_default_image = $params->get('subcat_default_image', '');
     if ($show_cat_image) {
         $h = '&amp;h=' . $cat_image_height;
         $w = '&amp;w=' . $cat_image_width;
         $aoe = '&amp;aoe=1';
         $q = '&amp;q=95';
         $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
     }
     if ($cat_default_image) {
         $src = $this->baseurl . "/" . $joomla_image_url . $cat_default_image;
         $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
         $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
         $conf = $w . $h . $aoe . $q . $zc . $f;
         $default_image = $phpThumbURL . $src . $conf;
         $default_image = '<img class="fccat_image" style="float:' . $cat_image_float . '" src="' . $default_image . '" alt="%s" title="%s"/>';
     } else {
         $default_image = '';
     }
     // Create sub-category image/description/etc data
     foreach ($categories as $cat) {
         $image = "";
         if ($show_cat_image) {
             if (!is_object($cat->params)) {
                 $cat->params = new JRegistry($cat->params);
             }
             $cat->image = $cat->params->get('image');
             $cat->introtext =& $cat->description;
             $cat->fulltext = "";
             if ($cat_image_source && $cat->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . $cat->image)) {
                 $src = $this->baseurl . "/" . $joomla_image_url . $cat->image;
                 $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
                 $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                 $conf = $w . $h . $aoe . $q . $zc . $f;
                 $image = $phpThumbURL . $src . $conf;
             } else {
                 if ($cat_image_source != 1 && ($src = flexicontent_html::extractimagesrc($cat))) {
                     $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
                     $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                     $conf = $w . $h . $aoe . $q . $zc . $f;
                     $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? $this->baseurl . '/' : '';
                     $src = $base_url . $src;
                     $image = $phpThumbURL . $src . $conf;
                 }
             }
             $cat->image_src = @$src;
             // Also add image category URL for developers
             if ($image) {
                 $image = '<img class="fccat_image" src="' . $image . '" alt="' . $this->escape($cat->title) . '" title="' . $this->escape($cat->title) . '"/>';
             } else {
                 if ($default_image) {
                     $image = sprintf($default_image, $cat->title, $cat->title);
                 }
             }
             if ($cat_link_image && $image) {
                 $image = '<a href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)) . '">' . $image . '</a>';
             }
         }
         $cat->image = $image;
     }
     // *******************************
     // PEERCATEGORIES (some templates)
     // *******************************
     // peer-category image params
     $show_cat_image = $params->get('show_description_image_peercat', 1);
     // we use different name for variable
     $cat_image_source = $params->get('peercat_image_source', 2);
     // 0: extract, 1: use param, 2: use both
     $cat_link_image = $params->get('peercat_link_image', 1);
     $cat_image_method = $params->get('peercat_image_method', 1);
     $cat_image_width = $params->get('peercat_image_width', 24);
     $cat_image_height = $params->get('peercat_image_height', 24);
     $cat_default_image = $params->get('peercat_default_image', '');
     if ($show_cat_image) {
         $h = '&amp;h=' . $cat_image_height;
         $w = '&amp;w=' . $cat_image_width;
         $aoe = '&amp;aoe=1';
         $q = '&amp;q=95';
         $zc = $cat_image_method ? '&amp;zc=' . $cat_image_method : '';
     }
     if ($cat_default_image) {
         $src = $this->baseurl . "/" . $joomla_image_url . $cat_default_image;
         $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
         $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
         $conf = $w . $h . $aoe . $q . $zc . $f;
         $default_image = $phpThumbURL . $src . $conf;
         $default_image = '<img class="fccat_image" style="float:' . $cat_image_float . '" src="' . $default_image . '" alt="%s" title="%s"/>';
     } else {
         $default_image = '';
     }
     // Create peer-category image/description/etc data
     foreach ($peercats as $cat) {
         $image = "";
         if ($show_cat_image) {
             if (!is_object($cat->params)) {
                 $cat->params = new JRegistry($cat->params);
             }
             $cat->image = $cat->params->get('image');
             $cat->introtext =& $cat->description;
             $cat->fulltext = "";
             if ($cat_image_source && $cat->image && JFile::exists(JPATH_SITE . DS . $joomla_image_path . $cat->image)) {
                 $src = $this->baseurl . "/" . $joomla_image_url . $cat->image;
                 $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
                 $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                 $conf = $w . $h . $aoe . $q . $zc . $f;
                 $image = $phpThumbURL . $src . $conf;
             } else {
                 if ($cat_image_source != 1 && ($src = flexicontent_html::extractimagesrc($cat))) {
                     $ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
                     $f = in_array($ext, array('png', 'ico', 'gif')) ? '&amp;f=' . $ext : '';
                     $conf = $w . $h . $aoe . $q . $zc . $f;
                     $base_url = !preg_match("#^http|^https|^ftp|^/#i", $src) ? $this->baseurl . '/' : '';
                     $src = $base_url . $src;
                     $image = $phpThumbURL . $src . $conf;
                 }
             }
             $cat->image_src = @$src;
             // Also add image category URL for developers
             if ($image) {
                 $image = '<img class="fccat_image" src="' . $image . '" alt="' . $this->escape($cat->title) . '" title="' . $this->escape($cat->title) . '"/>';
             } else {
                 if ($default_image) {
                     $image = sprintf($default_image, $cat->title, $cat->title);
                 }
             }
             if ($cat_link_image && $image) {
                 $image = '<a href="' . JRoute::_(FlexicontentHelperRoute::getCategoryRoute($cat->slug)) . '">' . $image . '</a>';
             }
         }
         $cat->image = $image;
     }
     // remove previous alpha index filter
     //$uri->delVar('letter');
     // remove filter variables (includes search box and sort order)
     preg_match_all('/filter[^=]*/', $uri->toString(), $matches);
     foreach ($matches[0] as $match) {
         //$uri->delVar($match);
     }
     // Build Lists
     $lists = array();
     //ordering
     $lists['filter_order'] = JRequest::getCmd('filter_order', 'i.title', 'default');
     $lists['filter_order_Dir'] = JRequest::getCmd('filter_order_Dir', 'ASC', 'default');
     $lists['filter'] = JRequest::getString('filter', '', 'default');
     // Add html to filter objects
     $form_name = 'adminForm';
     if ($filters) {
         FlexicontentFields::renderFilters($params, $filters, $form_name);
     }
     // ****************************
     // Create the pagination object
     // ****************************
     $pageNav = $this->get('pagination');
     $_revert = array('%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')');
     // URL-encode filter values
     foreach ($_GET as $i => $v) {
         if (substr($i, 0, 6) === "filter") {
             if (is_array($v)) {
                 foreach ($v as $ii => &$vv) {
                     $vv = str_replace('&', '__amp__', $vv);
                     $vv = strtr(rawurlencode($vv), $_revert);
                     $pageNav->setAdditionalUrlParam($i . '[' . $ii . ']', $vv);
                 }
                 unset($vv);
             } else {
                 $v = str_replace('&', '__amp__', $v);
                 $v = strtr(rawurlencode($v), $_revert);
                 $pageNav->setAdditionalUrlParam($i, $v);
             }
         }
     }
     $resultsCounter = $pageNav->getResultsCounter();
     // for overriding model's result counter
     // **********************************************************************
     // Print link ... must include layout and current filtering url vars, etc
     // **********************************************************************
     $curr_url = str_replace('&', '&amp;', $_SERVER['REQUEST_URI']);
     $print_link = $curr_url . (strstr($curr_url, '?') ? '&amp;' : '?') . 'pop=1&amp;tmpl=component&amp;print=1';
     $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->assignRef('layout_vars', $layout_vars);
     $this->assignRef('action', $category_link);
     $this->assignRef('print_link', $print_link);
     $this->assignRef('category', $category);
     $this->assignRef('categories', $categories);
     $this->assignRef('peercats', $peercats);
     $this->assignRef('items', $items);
     $this->assignRef('authordescr_item_html', $authordescr_item_html);
     $this->assignRef('lists', $lists);
     $this->assignRef('params', $params);
     $this->assignRef('pageNav', $pageNav);
     $this->assignRef('pageclass_sfx', $pageclass_sfx);
     $this->assignRef('pagination', $pageNav);
     // compatibility Alias for old templates
     $this->assignRef('resultsCounter', $resultsCounter);
     // for overriding model's result counter
     $this->assignRef('limitstart', $limitstart);
     // compatibility shortcut
     $this->assignRef('filters', $filters);
     $this->assignRef('comments', $comments);
     $this->assignRef('alpha', $alpha);
     $this->assignRef('tmpl', $tmpl);
     // NOTE: Moved decision of layout into the model, function decideLayout() layout variable should never be empty
     // It will consider things like: template exists, is allowed, client is mobile, current frontend user override, etc
     // !!! The following method of loading layouts, is Joomla legacy view loading of layouts
     // TODO: EXAMINE IF NEEDED to re-use these layouts, and use JLayout ??
     // Despite layout variable not being empty, there may be missing some sub-layout files,
     // e.g. category_somefilename.php for this reason we will use a fallback layout that surely has these files
     $fallback_layout = $params->get('category_fallback_layout', 'blog');
     // parameter does not exist yet
     if ($clayout != $fallback_layout) {
         $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates' . DS . $fallback_layout);
         $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . $fallback_layout);
     }
     $this->addTemplatePath(JPATH_COMPONENT . DS . 'templates' . DS . $clayout);
     $this->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'html' . DS . 'com_flexicontent' . DS . 'templates' . DS . $clayout);
     // **************************************************
     // increment the hit counter ONLY once per user visit
     // **************************************************
     // MOVED to flexisystem plugin due to ...
     $print_logging_info = $params->get('print_logging_info');
     if ($print_logging_info) {
         global $fc_run_times;
         $start_microtime = microtime(true);
     }
     parent::display($tpl);
     if ($print_logging_info) {
         @($fc_run_times['template_render'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
     }
 }
Ejemplo n.º 18
0
 public function checkout($userId = null)
 {
     // Get the user id.
     $userId = !empty($userId) ? $userId : (int) $this->getState('user.id');
     if ($userId) {
         // Initialise the table with JUser.
         $table = JUser::getTable('User', 'JTable');
         // Get the current user object.
         $user = JFactory::getUser();
         // Attempt to check the row out.
         if (!$table->checkout($user->get('id'), $userId)) {
             $this->setError($table->getError());
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 19
0
 /**
  * Method to save the form data.
  *
  * @access	public
  * @param	array		$data		The form data.
  * @return	mixed		The user id on success, false on failure.
  * @since	1.0
  */
 function save($data)
 {
     $memberId = !empty($data['id']) ? $data['id'] : (int) $this->getState('member.id');
     // Initialise the table with JUser.
     JUser::getTable('User', 'JTable');
     $user = new JUser($memberId);
     // Prepare the data for the user object.
     $data['email'] = $data['email1'];
     $data['password'] = $data['password1'];
     // Bind the data.
     if (!$user->bind($data)) {
         $this->setError(JText::sprintf('USERS PROFILE BIND FAILED', $user->getError()));
         return false;
     }
     // Load the users plugin group.
     JPluginHelper::importPlugin('users');
     // Null the user groups so they don't get overwritten
     $user->groups = null;
     // Store the data.
     if (!$user->save()) {
         $this->setError($user->getError());
         return false;
     }
     return $user->id;
 }