public function download() { tzportfolioplusimport('phpclass.connection_tools_class'); $model = $this->getModel('Article', 'TZ_Portfolio_PlusModel')->download(); $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . $model; $mainframe = JFactory::getApplication(); if (JFile::exists($file)) { tzConnector::sendfile($file, $this->check_filetype($file)); $mainframe->close(); } return true; }
public static function getInstance($type, $plugin = null, $enabled = true, $dispatcher = null) { if (!isset(self::$instances[$type . $plugin])) { if ($plugin_obj = self::getPlugin($type, $plugin, $enabled)) { if ($type == 'extrafields') { tzportfolioplusimport('fields.extrafield'); } if (!$dispatcher) { $dispatcher = JEventDispatcher::getInstance(); } $className = 'PlgTZ_Portfolio_Plus' . ucfirst($type) . ucfirst($plugin); if (!class_exists($className)) { self::importPlugin($type, $plugin); } if (class_exists($className)) { $registry = new JRegistry($plugin_obj->params); self::$instances[$type . $plugin] = new $className($dispatcher, array('type' => $plugin_obj->type, 'name' => $plugin_obj->name, 'params' => $registry)); return self::$instances[$type . $plugin]; } } } return false; }
# author DuongTVTemPlaza # copyright Copyright (C) 2015 templaza.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.templaza.com # Technical Support: Forum - http://templaza.com/Forum -------------------------------------------------------------------------*/ // No direct access defined('_JEXEC') or die; jimport('joomla.application.component.view'); tzportfolioplusimport('user.user'); /** * HTML Article View class for the Content component. */ class TZ_Portfolio_PlusViewForm extends JViewLegacy { protected $form; protected $item; protected $return_page; protected $state; public function display($tpl = null) { // Initialise variables. $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $user = TZ_Portfolio_PlusUser::getUser();
# copyright Copyright (C) 2015 templaza.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.templaza.com # Technical Support: Forum - http://templaza.com/Forum -------------------------------------------------------------------------*/ // no direct access defined('_JEXEC') or die; $input = JFactory::getApplication()->input; $option = $input->getCmd('option', 'com_tz_portfolio_plus'); $view = $input->getCmd('view', 'articles'); $task = $input->getCmd('task', null); JLoader::import('com_tz_portfolio_plus.includes.framework', JPATH_ADMINISTRATOR . '/components'); // Register helper class JLoader::register('TZ_Portfolio_PlusHelper', dirname(__FILE__) . '/helpers/tz_portfolio_plus.php'); tzportfolioplusimport('user.user'); // Access check. if (!JFactory::getUser()->authorise('core.manage', 'com_tz_portfolio_plus')) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } // Register class TZ_Portfolio_PlusPluginHelper from folder libraries of TZ Portfolio Plus tzportfolioplusimport('plugin.helper'); //tzportfolioplusimport('controller.legacy'); $controller = JControllerLegacy::getInstance('TZ_Portfolio_Plus'); //$controller = TZ_Portfolio_Plus_AddOnControllerLegacy::getInstance('TZ_Portfolio_Plus'); $controller->execute(JFactory::getApplication()->input->get('task')); $controller->redirect();
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.templaza.com # Technical Support: Forum - http://templaza.com/Forum -------------------------------------------------------------------------*/ // no direct access defined('_JEXEC') or die; use Joomla\Registry\Registry; jimport('joomla.application.component.modellist'); jimport('joomla.html.pagination'); jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); tzportfolioplusimport('phpclass.autocuttext'); class TZ_Portfolio_PlusModelPortfolio extends JModelList { protected $pagNav = null; protected $rowsTag = null; protected $categories = null; public function __construct($config = array()) { parent::__construct($config); } function populateState($ordering = null, $direction = null) { parent::populateState($ordering, $direction); $app = JFactory::getApplication('site'); $params = $app->getParams('com_tz_portfolio_plus'); $global_params = JComponentHelper::getParams('com_tz_portfolio_plus');
function uploadImages($file, $url = null) { if ($file) { $maxSize = 2 * 1024 * 1024; $arr = array('image/jpeg', 'image/jpg', 'image/bmp', 'image/gif', 'image/png', 'image/ico'); // Create folder $tzFolder = 'tz_portfolio_plus'; $tzUserFolder = 'categories'; $tzFolderPath = JPATH_ROOT . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . $tzFolder; $tzUserFolderPath = $tzFolderPath . DIRECTORY_SEPARATOR . $tzUserFolder; if (!JFolder::exists($tzFolderPath)) { JFolder::create($tzFolderPath); if (!JFile::exists($tzFolderPath . DIRECTORY_SEPARATOR . 'index.html')) { JFile::write($tzFolderPath . DIRECTORY_SEPARATOR . 'index.html', htmlspecialchars_decode('<!DOCTYPE html><title></title>')); } } if (JFolder::exists($tzFolderPath)) { if (!JFolder::exists($tzUserFolderPath)) { JFolder::create($tzUserFolderPath); if (!JFile::exists($tzUserFolderPath . DIRECTORY_SEPARATOR . 'index.html')) { JFile::write($tzUserFolderPath . DIRECTORY_SEPARATOR . 'index.html', htmlspecialchars_decode('<!DOCTYPE html><title></title>')); } } } $params = JComponentHelper::getParams('com_tz_portfolio_plus'); if (!$url) { $image = new JImage(JPATH_SITE . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $file)); $desFileName = 'categories_' . time() . uniqid() . '.' . JFile::getExt($file); $desPath = $tzUserFolderPath . DIRECTORY_SEPARATOR . $desFileName; if ($params->get('tz_catimage_width', 400)) { $newWidth = $params->get('tz_catimage_width', 400); } $type = strtolower(JFile::getExt($file)); $_type = null; if ($type == 'gif') { $_type = IMAGETYPE_GIF; } elseif ($type == 'png') { $_type = IMAGETYPE_PNG; } $height = ceil($image->getHeight() * $newWidth / $image->getWidth()); $image = $image->resize($newWidth, $height); $image->toFile($desPath, $_type); return 'media/' . $tzFolder . '/' . $tzUserFolder . '/' . $desFileName; } else { tzportfolioplusimport('HTTPFetcher'); tzportfolioplusimport('readfile'); $image = new Services_Yadis_PlainHTTPFetcher(); $image = $image->get($file); if (!in_array($image->headers['Content-Type'], $arr)) { $this->setError(JText::_('COM_TZ_PORTFOLIO_PLUS_INVALID_FILE')); return false; } if ($image->headers['Content-Length'] > $maxSize) { $this->setError(JText::_('COM_TZ_PORTFOLIO_PLUS_IMAGE_SIZE_TOO_LARGE')); return false; } $desFileName = 'categories_' . time() . uniqid() . '.' . str_replace('image/', '', $image->headers['Content-Type']); $desPath = $tzUserFolderPath . DIRECTORY_SEPARATOR . $desFileName; if (JFolder::exists($tzFolderPath)) { if (!JFile::write($desPath, $image->body)) { $this->setError(JText::_('COM_TZ_PORTFOLIO_PLUS_CAN_NOT_UPLOADED_FILEs')); return false; } $image = new JImage($desPath); $newWidth = $params->get('tz_catimage_width', 400); $newHeight = ceil($image->getHeight() * $newWidth / $image->getWidth()); $newImage = $image->resize((int) $newWidth, $newHeight, false); $type = strtolower(JFile::getExt($file)); $_type = $type == 'gif' ? IMAGETYPE_GIF : $type == 'png' ? IMAGETYPE_PNG : null; $newImage->toFile($desPath, $_type); return 'media/' . $tzFolder . '/' . $tzUserFolder . '/' . $desFileName; } } } return true; }
<?php /*------------------------------------------------------------------------ # TZ Portfolio Plus Extension # ------------------------------------------------------------------------ # author DuongTVTemPlaza # copyright Copyright (C) 2015 templaza.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.templaza.com # Technical Support: Forum - http://templaza.com/Forum -------------------------------------------------------------------------*/ // No direct access. defined('_JEXEC') or die; tzportfolioplusimport('controller.admin'); class TZ_Portfolio_PlusControllerAddon_Datas extends TZ_Portfolio_Plus_AddOnControllerAdmin { protected $text_prefix = 'COM_TZ_PORTFOLIO_PLUS_ADDON_DATAS'; public function getModel($name = 'Addon_Data', $prefix = 'TZ_Portfolio_PlusModel', $config = array('ignore_request' => true)) { $model = parent::getModel($name, $prefix, $config); return $model; } }
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.templaza.com # Technical Support: Forum - http://templaza.com/Forum -------------------------------------------------------------------------*/ // No direct access defined('_JEXEC') or die; use Joomla\Registry\Registry; jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); jimport('joomla.application.component.modeladmin'); JLoader::import('extrafields', COM_TZ_PORTFOLIO_PLUS_ADMIN_HELPERS_PATH); JLoader::register('TZ_Portfolio_PlusFrontHelperExtraFields', COM_TZ_PORTFOLIO_PLUS_SITE_HELPERS_PATH . DIRECTORY_SEPARATOR . 'extrafields.php'); tzportfolioplusimport('fields.extrafield'); class TZ_Portfolio_PlusModelField extends JModelAdmin { public function __construct($config = array()) { parent::__construct($config); } public function populateState() { parent::populateState(); } public function getTable($type = 'Fields', $prefix = 'TZ_Portfolio_PlusTable', $config = array()) { return JTable::getInstance($type, $prefix, $config); } public function getForm($data = array(), $loadData = true)
public static function loadExtraFieldFile($name) { $storeId = md5(__METHOD__ . "::{$name}"); if (!isset(self::$cache[$storeId])) { if (self::checkExtraField($name)) { require_once COM_TZ_PORTFOLIO_PLUS_ADDON_PATH . DIRECTORY_SEPARATOR . 'extrafields' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . $name . '.php'; } else { tzportfolioplusimport('fields.extrafield'); } self::$cache[$storeId] = true; } return self::$cache[$storeId]; }
<?php /*------------------------------------------------------------------------ # TZ Portfolio Plus Extension # ------------------------------------------------------------------------ # author DuongTVTemPlaza # copyright Copyright (C) 2015 templaza.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.templaza.com # Technical Support: Forum - http://templaza.com/Forum -------------------------------------------------------------------------*/ // No direct access. defined('JPATH_PLATFORM') or die; tzportfolioplusimport('controller.form'); class TZ_Portfolio_PlusControllerAddon_Data extends TZ_Portfolio_Plus_AddOnControllerForm { }
public function uninstall($eid = array()) { $user = JFactory::getUser(); $app = JFactory::getApplication(); $view = $app->input->getCmd('view'); if (!$user->authorise('core.delete', 'com_tz_portfolio_plus')) { JError::raiseWarning(403, JText::_('JERROR_CORE_DELETE_NOT_PERMITTED')); return false; } $failed = array(); /* * Ensure eid is an array of extension ids in the form id => client_id * TODO: If it isn't an array do we want to set an error and fail? */ if (!is_array($eid)) { $eid = array($eid => 0); } // Get an installer object for the extension type $table = $this->getTable(); // Uninstall the chosen extensions $msgs = array(); $result = false; // Get an installer instance. $installer = JInstaller::getInstance(); foreach ($eid as $id) { $id = trim($id); $table->load($id); $langstring = 'COM_TZ_PORTFOLIO_PLUS_' . strtoupper($table->type); $rowtype = JText::_($langstring); if (strpos($rowtype, $langstring) !== false) { $rowtype = $table->type; } if ($table->type && $table->type == 'tz_portfolio_plus-plugin') { // Is the template we are trying to uninstall a core one? // Because that is not a good idea... if ($table->protected) { JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_PLG_UNINSTALL_WARNCOREPLUGIN', JText::_('COM_TZ_PORTFOLIO_PLUS_' . $view)), JLog::WARNING, 'jerror'); return false; } $_type = str_replace('tz_portfolio_plus-', '', $table->type); tzportfolioplusimport('adapter.' . $_type); $class = 'TZ_Portfolio_PlusInstallerAdapter' . $_type; $tzinstaller = new $class($installer, $installer->getDbo()); $result = $tzinstaller->uninstall($id); // Build an array of extensions that failed to uninstall if ($result === false) { // There was an error in uninstalling the package $msgs[] = JText::sprintf('COM_TZ_PORTFOLIO_PLUS_UNINSTALL_ERROR', JText::_('COM_TZ_PORTFOLIO_PLUS_' . $view)); continue; } // Package uninstalled sucessfully $msgs[] = JText::sprintf('COM_TZ_PORTFOLIO_PLUS_UNINSTALL_SUCCESS', JText::_('COM_TZ_PORTFOLIO_PLUS_' . $view)); $result = true; } } $msg = implode("<br />", $msgs); $app->enqueueMessage($msg); return $result; }
# copyright Copyright (C) 2015 templaza.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.templaza.com # Technical Support: Forum - http://templaza.com/Forum -------------------------------------------------------------------------*/ //no direct access defined('_JEXEC') or die('Restricted access'); jimport('joomla.application.component.view'); jimport('joomla.event.dispatcher'); JHtml::addIncludePath(COM_TZ_PORTFOLIO_PLUS_PATH_SITE . '/helpers'); tzportfolioplusimport('http_fetcher'); class TZ_Portfolio_PlusViewPortfolio extends JViewLegacy { protected $item = null; protected $items = null; protected $media = null; protected $ajaxLink = null; protected $lang_sef = ''; protected $itemTags = null; protected $itemCategories = null; protected $params = null; protected $pagination = null; protected $Itemid = null; protected $char = null; protected $availLetter = null; function __construct($config = array())
protected function _getViewHtml($context, &$article, $params, $layout = null) { list($extension, $vName) = explode('.', $context); $input = JFactory::getApplication()->input; $addon_id = $input->getInt('addon_id'); $addon = TZ_Portfolio_PlusPluginHelper::getPlugin($this->_type, $this->_name); if (!$addon_id || $addon_id && $addon_id == $addon->id) { tzportfolioplusimport('controller.legacy'); $result = true; // Check task with format: addon_name.addon_view.addon_task (example image.default.display); $adtask = $input->get('addon_task'); if ($adtask && strpos($adtask, '.') > 0 && !$addon_id) { list($plgname, $adtask) = explode('.', $adtask, 2); if ($plgname == $this->_name) { $result = true; $input->set('addon_task', $adtask); } else { $result = false; } } if ($result && ($controller = TZ_Portfolio_Plus_AddOnControllerLegacy::getInstance('PlgTZ_Portfolio_Plus' . ucfirst($this->_type) . ucfirst($this->_name), array('base_path' => COM_TZ_PORTFOLIO_PLUS_ADDON_PATH . DIRECTORY_SEPARATOR . $this->_type . DIRECTORY_SEPARATOR . $this->_name)))) { tzportfolioplusimport('plugin.modelitem'); $controller->set('addon', $addon); $controller->set('article', $article); $controller->set('trigger_params', $params); $task = $input->get('addon_task'); if (!$task && !$addon_id) { $input->set('addon_view', $vName); $input->set('addon_layout', 'default'); if ($layout) { $input->set('addon_layout', $layout); } } $html = null; try { ob_start(); $controller->execute($task); $controller->redirect(); $html = ob_get_contents(); ob_end_clean(); } catch (Exception $e) { if ($e->getMessage()) { JFactory::getApplication()->enqueueMessage('Addon ' . $this->_name . ': ' . $e->getMessage(), 'warning'); } } if ($html) { $html = trim($html); } $input->set('addon_task', null); return $html; } } }