Example #1
0
 public function setTheme($theme, $style)
 {
     if ($style) {
         \JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_templates/tables');
         $table = \JTable::getInstance('Style', 'TemplatesTable');
         $table->load(['id' => $style, 'client_id' => 0]);
         $theme = $table->template;
     }
     if (!$theme) {
         $theme = StyleHelper::getDefaultStyle()->template;
     }
     $path = JPATH_SITE . '/templates/' . $theme;
     if (!is_file("{$path}/gantry/theme.yaml")) {
         $theme = null;
         $this->container['streams']->register();
         /** @var UniformResourceLocator $locator */
         $locator = $this->container['locator'];
         $this->container['file.yaml.cache.path'] = $locator->findResource('gantry-cache://theme/compiled/yaml', true, true);
     }
     $this->container['base_url'] = \JUri::base(true) . '/index.php?option=com_gantry5';
     $this->container['ajax_suffix'] = '&format=json';
     $token = \JSession::getFormToken();
     $this->container['routes'] = ['1' => "&view=%s&theme={$theme}&{$token}=1", 'themes' => '&view=themes', 'picker/layouts' => "&view=layouts&theme={$theme}&{$token}=1"];
     if (!$theme) {
         return $this;
     }
     $this->container['theme.path'] = $path;
     $this->container['theme.name'] = $theme;
     // Load language file for the template.
     $languageFile = 'tpl_' . $theme;
     $lang = \JFactory::getLanguage();
     $lang->load($languageFile, JPATH_SITE) || $lang->load($languageFile, $path) || $lang->load($languageFile, $path, 'en-GB');
     return $this;
 }
Example #2
0
 function createCustomField($what)
 {
     // Load the JTable Object.
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_community' . DS . 'tables');
     $row = JTable::getInstance('profiles', 'CommunityTable');
     $row->load(0);
     switch ($what) {
         case PROFILETYPE_CUSTOM_FIELD_CODE:
             $data['type'] = PROFILETYPE_FIELD_TYPE_NAME;
             $data['name'] = 'Profiletype';
             $data['tips'] = 'Profiletype Of User';
             break;
         case TEMPLATE_CUSTOM_FIELD_CODE:
             $data['type'] = TEMPLATE_FIELD_TYPE_NAME;
             $data['name'] = 'Template';
             $data['tips'] = 'Template Of User';
             break;
         default:
             XiptError::assert(0);
             break;
     }
     $data['published'] = 1;
     $data['fieldcode'] = $what;
     return $row->bind($data) && $row->store();
 }
Example #3
0
 function ThemeFlow()
 {
     $pathModelShowcaseTheme = JPATH_PLUGINS . DS . $this->_pluginType . DS . $this->_pluginName . DS . 'models';
     $pathTableShowcaseTheme = JPATH_PLUGINS . DS . $this->_pluginType . DS . $this->_pluginName . DS . 'tables';
     JModelLegacy::addIncludePath($pathModelShowcaseTheme);
     JTable::addIncludePath($pathTableShowcaseTheme);
 }
Example #4
0
 /**
  * Get a model instance.
  *
  * @param   string  $name    Model name
  * @param   mixed   $client  Client. null = auto, 1 = admin, 0 = frontend
  * @param   array   $config  An optional array of configuration
  * @param   string  $option  Component name, use for call model from modules
  *
  * @return  RModelAdmin  The model
  *
  * @throws  InvalidArgumentException
  */
 public static function getAutoInstance($name, $client = null, array $config = array(), $option = 'auto')
 {
     if ($option === 'auto') {
         $option = JFactory::getApplication()->input->getString('option', '');
     }
     $componentName = ucfirst(strtolower(substr($option, 4)));
     $prefix = $componentName . 'Model';
     if (is_null($client)) {
         $client = (int) JFactory::getApplication()->isAdmin();
     }
     // Admin
     if ($client === 1) {
         self::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . $option . '/models', $prefix);
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . $option . '/tables');
     } elseif ($client === 0) {
         self::addIncludePath(JPATH_SITE . '/components/' . $option . '/models', $prefix);
         JTable::addIncludePath(JPATH_SITE . '/components/' . $option . '/tables');
     } else {
         throw new InvalidArgumentException(sprintf('Cannot instantiate the model %s. Invalid client %s.', $name, $client));
     }
     $model = self::getInstance($name, $prefix, $config);
     if (!$model instanceof JModelAdmin && !$model instanceof JModelLegacy) {
         throw new InvalidArgumentException(sprintf('Cannot instantiate the model %s from client %s.', $name, $client));
     }
     return $model;
 }
Example #5
0
 public function copy()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $cid = $this->input->post->get('cid', array(), 'array');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tagmeta/tables');
     $table =& JTable::getInstance('Rule', 'TagMetaTable');
     $n = count($cid);
     if ($n > 0) {
         $i = 0;
         foreach ($cid as $id) {
             if ($table->load((int) $id)) {
                 $table->id = 0;
                 $table->url = JText::_('COM_TAGMETA_COPY_OF') . $table->url;
                 $table->ordering = 0;
                 $table->published = false;
                 $table->checked_out = false;
                 if ($table->store()) {
                     $i++;
                 } else {
                     JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_TAGMETA_COPY_ERROR_SAVING', $id, $table->getError()), 'error');
                 }
             } else {
                 JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_TAGMETA_COPY_ERROR_LOADING', $id, $table->getError()), 'error');
             }
         }
     } else {
         return JError::raiseWarning(500, JText::_('COM_TAGMETA_COPY_ERROR_NO_SELECTION'));
     }
     $this->setMessage(JText::sprintf('COM_TAGMETA_COPY_OK', $i));
     $this->setRedirect('index.php?option=com_tagmeta&view=rules');
 }
 protected function vm_require()
 {
     if (!class_exists('VmConfig')) {
         if (file_exists(JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php')) {
             require JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php';
         } else {
             $this->error = 'Could not find VmConfig helper';
             return false;
         }
     }
     VmConfig::loadConfig();
     VmConfig::loadJLang('com_virtuemart', true);
     if (!class_exists('VmModel')) {
         if (defined('JPATH_VM_ADMINISTRATOR') && file_exists(JPATH_VM_ADMINISTRATOR . '/helpers/vmmodel.php')) {
             require JPATH_VM_ADMINISTRATOR . '/helpers/vmmodel.php';
         } else {
             $this->error = 'Could not find VmModel helper';
             return false;
         }
     }
     if (defined('JPATH_VM_ADMINISTRATOR')) {
         JTable::addIncludePath(JPATH_VM_ADMINISTRATOR . '/tables');
     }
     if (!class_exists('VirtueMartModelCustom')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'custom.php';
     }
     if (!class_exists('VirtueMartModelCustomfields')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'customfields.php';
     }
     return true;
 }
Example #7
0
 public function __construct()
 {
     parent::__construct();
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_rsmembership/tables');
     $document = JFactory::getDocument();
     $config = RSMembershipConfig::getInstance();
     $version = (string) new RSMembershipVersion();
     // Load our CSS
     $document->addStyleSheet(JUri::root(true) . '/components/com_rsmembership/assets/css/rsmembership.css?v=' . $version);
     // Load our JS
     $document->addScript(JUri::root(true) . '/components/com_rsmembership/assets/js/rsmembership.js?v=' . $version);
     if (!RSMembershipHelper::isJ3()) {
         // Load 2.5 CSS
         $document->addStyleSheet(JUri::root(true) . '/components/com_rsmembership/assets/css/j2.css?v=' . $version);
         // Load Bootstrap on 2.5.x
         if ($config->get('load_bootstrap')) {
             $document->addStyleSheet(JUri::root(true) . '/components/com_rsmembership/assets/css/bootstrap.min.css?v=' . $version);
             $document->addScript(JUri::root(true) . '/components/com_rsmembership/assets/js/jquery.min.js?v=' . $version);
             $document->addScript(JUri::root(true) . '/components/com_rsmembership/assets/js/jquery.noconflict.js?v=' . $version);
             $document->addScript(JUri::root(true) . '/components/com_rsmembership/assets/js/bootstrap.min.js?v=' . $version);
         }
     } else {
         // Load 3.x CSS
         $document->addStyleSheet(JUri::root(true) . '/components/com_rsmembership/assets/css/j3.css?v=' . $version);
         // Load Bootstrap on 3.x
         if ($config->get('load_bootstrap')) {
             JHtml::_('bootstrap.framework');
         }
     }
 }
Example #8
0
 /**
  * Generates a random captcha image
  *
  **/
 function display($cachable = false, $urlparams = false)
 {
     // @TODO: Run some cleaning query here to clear the database.
     JTable::addIncludePath(DISCUSS_TABLES);
     $id = JRequest::getInt('captcha-id', '');
     $captcha = DiscussHelper::getTable('Captcha');
     // clearing the oudated keys.
     $captcha->clear();
     // load the captcha records.
     $captcha->load($id);
     if (!$captcha->id) {
         return false;
     }
     // @task: Generate a very random integer and take only 5 chars max.
     $hash = JString::substr(md5(rand(0, 9999)), 0, 5);
     $captcha->response = $hash;
     $captcha->store();
     // Captcha width and height
     $width = 100;
     $height = 20;
     $image = ImageCreate($width, $height);
     $white = ImageColorAllocate($image, 255, 255, 255);
     $black = ImageColorAllocate($image, 0, 0, 0);
     $gray = ImageColorAllocate($image, 204, 204, 204);
     ImageFill($image, 0, 0, $white);
     ImageString($image, 5, 30, 3, $hash, $black);
     ImageRectangle($image, 0, 0, $width - 1, $height - 1, $gray);
     imageline($image, 0, $height / 2, $width, $height / 2, $gray);
     imageline($image, $width / 2, 0, $width / 2, $height, $gray);
     header('Content-type: image/jpeg');
     ImageJpeg($image);
     ImageDestroy($image);
     exit;
 }
Example #9
0
 /**
  * Method to change the block status on a record.
  *
  * @return  void
  *
  * @since   0.3.0
  */
 public function changeBlock()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $ids = $this->input->get('cid', array(), 'array');
     $values = array('block' => 1, 'unblock' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($values, $task, 0, 'int');
     // Convert from customer ID to Joomla user ID
     $joomlaUserIds = array();
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_solidres/tables', 'SolidresTable');
     $customerTable = JTable::getInstance('Customer', 'SolidresTable');
     foreach ($ids as $id) {
         $customerTable->load($id);
         $joomlaUserIds[] = $customerTable->user_id;
     }
     if (empty($joomlaUserIds)) {
         JError::raiseWarning(500, JText::_('SR_CUSTOMERS_NO_ITEM_SELECTED'));
     } else {
         // Get the model.
         JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models', 'UsersModel');
         $model = JModelLegacy::getInstance('User', 'UsersModel', array('ignore_request' => true));
         // Change the state of the records.
         if (!$model->block($joomlaUserIds, $value)) {
             JError::raiseWarning(500, $model->getError());
         } else {
             if ($value == 1) {
                 $this->setMessage(JText::plural('SR_N_CUSTOMERS_BLOCKED', count($joomlaUserIds)));
             } elseif ($value == 0) {
                 $this->setMessage(JText::plural('SR_N_CUSTOMERS_UNBLOCKED', count($joomlaUserIds)));
             }
         }
     }
     $this->setRedirect('index.php?option=com_solidres&view=customers');
 }
Example #10
0
 /**
  * Returns a reference to the a Table object, always creating it
  *
  * @param type 		$type 	 The table type to instantiate
  * @param string 	$prefix	 A prefix for the table class name. Optional.
  * @param array		$options Configuration array for model. Optional.
  * @return database A database object
  * @since 1.5
  */
 function &getInstance($type, $prefix = 'JTable', $config = array())
 {
     $false = false;
     $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type);
     $tableClass = $prefix . ucfirst($type);
     if (!class_exists($tableClass)) {
         jimport('joomla.filesystem.path');
         if ($path = JPath::find(JTable::addIncludePath(), strtolower($type) . '.php')) {
             require_once $path;
             if (!class_exists($tableClass)) {
                 JError::raiseWarning(0, 'Table class ' . $tableClass . ' not found in file.');
                 return $false;
             }
         } else {
             JError::raiseWarning(0, 'Table ' . $type . ' not supported. File not found.');
             return $false;
         }
     }
     //Make sure we are returning a DBO object
     if (array_key_exists('dbo', $config)) {
         $db =& $config['dbo'];
     } else {
         $db =& JFactory::getDBO();
     }
     $instance = new $tableClass($db);
     //$instance->setDBO($db);
     return $instance;
 }
Example #11
0
    public function getInput()
    {
        $mainframe =& JFactory::getApplication();
        $doc =& JFactory::getDocument();
        $fieldName = $this->element['name'];
        $value = $this->value;
        $name = $this->name;
        $e_folder = basename(dirname(dirname(__FILE__)));
        JTable::addIncludePath(JPATH_ROOT . '/modules/' . $e_folder . '/elements');
        $item =& JTable::getInstance('YjContent', 'Table');
        $title = $item->title;
        if ($value) {
            $item->load($value);
        } else {
            $title = JText::_('Select specific items...');
        }
        $document =& JFactory::getDocument();
        $js = "\r\n\t\tfunction jSelectArticle(id, title, object) {\r\n\t\t\tdocument.getElementById(object + '_id').value = id;\r\n\t\t\tdocument.getElementById(object + '_name').value = title;\r\n\t\t\tdocument.getElementById('sbox-window').close();\r\n\t\t}\r\n\t\t";
        $doc->addScriptDeclaration($js);
        $link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&object=' . $name;
        JHTML::_('behavior.modal', 'a.modal');
        $html = '
		<div style="float:left;">
			<input style="background:#fff;margin:3px 0;" type="text" id="' . $name . '_name" value="' . htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . '" disabled="disabled" />
		</div>
		<div class="button2-left">
			<div class="blank">
				<a class="modal" title="' . JText::_('Select specific items') . '"  href="' . $link . '" rel="{handler: \'iframe\', size: {x: 700, y: 450}}">' . JText::_('Select') . '</a>
			</div>
		</div>
		<input type="hidden" id="' . $name . '_id" name="' . $fieldName . '" value="' . (int) $value . '" />
		';
        return $html;
    }
Example #12
0
    function fetchElement($name, $value, &$node, $control_name)
    {
        $mainframe =& JFactory::getApplication();
        $db =& JFactory::getDBO();
        $doc =& JFactory::getDocument();
        $fieldName = K2_JVERSION == '16' ? $name : $control_name . '[' . $name . ']';
        JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'tables');
        $item =& JTable::getInstance('K2Item', 'Table');
        if ($value) {
            $item->load($value);
        } else {
            $item->title = JText::_('K2_SELECT_AN_ITEM');
        }
        $doc->addScriptDeclaration($js);
        $link = 'index.php?option=com_k2&amp;view=items&amp;task=element&amp;tmpl=component&amp;object=' . $name;
        JHTML::_('behavior.modal', 'a.modal');
        $html = '
		<div style="float:left;">
			<input style="background:#fff;margin:3px 0;" type="text" id="' . $name . '_name" value="' . htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8') . '" disabled="disabled" />
		</div>
		<div class="button2-left">
			<div class="blank">
				<a class="modal" title="' . JText::_('K2_SELECT_AN_ITEM') . '"  href="' . $link . '" rel="{handler: \'iframe\', size: {x: 700, y: 450}}">' . JText::_('K2_SELECT') . '</a>
			</div>
		</div>
		<input type="hidden" id="' . $name . '_id" name="' . $fieldName . '" value="' . (int) $value . '" />
		';
        return $html;
    }
 /**
  * Method to get a list of options for a list input.
  *
  * @return      array           An array of JHtml options.
  */
 protected function getOptions()
 {
     //$this->getAttribute('teste');
     $input = JFactory::getApplication()->input;
     $id = $input->get('id', 0);
     $options = array();
     if ($id == 0) {
         $options[] = JHtml::_('select.option', 'NULL', JText::_('COM_AGENDADIRIGENTES_SALVE_PRIMEIRO'));
         return $options;
     }
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_agendadirigentes' . DS . 'tables');
     $table = JTable::getInstance('dirigente', 'AgendaDirigentesTable');
     $table->load($id);
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select('dir.ordering, dir.name')->from($db->quoteName('#__agendadirigentes_dirigentes', 'dir'))->join('INNER', $db->quoteName('#__categories', 'cat') . ' ON (' . $db->quoteName('dir.catid') . ' = ' . $db->quoteName('cat.id') . ')')->where('dir.catid = ' . intval($table->catid))->where('dir.id <> ' . intval($id));
     $query->order('dir.ordering ASC, dir.name ASC');
     $db->setQuery((string) $query);
     $dirigentes = $db->loadObjectList();
     $options = array();
     if ($dirigentes) {
         $options[] = JHtml::_('select.option', 0, ' - Primeiro - ');
         foreach ($dirigentes as $dirigente) {
             $options[] = JHtml::_('select.option', $dirigente->ordering, $dirigente->name);
         }
     } else {
         $options[] = JHtml::_('select.option', 0, JText::_('COM_AGENDADIRIGENTES_ORDERING_SOMENTE_UM'));
     }
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Example #14
0
 /**
  * This is not the best example to follow
  * Please see the category plugin for a better example
  */
 public function post()
 {
     // Set variables to be used
     APIHelper::setSessionUser();
     // Include dependencies
     jimport('joomla.database.table');
     $language = JFactory::getLanguage();
     $language->load('joomla', JPATH_ADMINISTRATOR);
     $language->load('com_k2', JPATH_ADMINISTRATOR);
     require_once JPATH_ADMINISTRATOR . '/components/com_k2/models/item.php';
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/tables');
     // Fake parameters
     $_REQUEST[JUtility::getToken()] = 1;
     $_POST[JUtility::getToken()] = 1;
     // Clear userstate just in case
     $row = $this->save();
     if ($this->getError()) {
         $response = $this->getErrorResponse(400, $this->getError());
     } elseif (!$row->id) {
         $response = $this->getErrorResponse(400, JText::_('COM_API_ERROR_OCURRED'));
     } else {
         $response = $this->getSuccessResponse(201, JText::_('COM_API_SUCCESS'));
         // Get the ID of the category that was modified or inserted
         $response->id = $row->id;
     }
     $this->plugin->setResponse($response);
 }
Example #15
0
 /**
  * Base Controller Constructor
  *
  * @param array $config Controller initialization configuration parameters
  * @return void
  * @since 0.1
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     $this->set('option', JRequest::getCmd('option'));
     JModel::addIncludePath(JPATH_SITE . '/components/com_api/models');
     JTable::addIncludePath(JPATH_SITE . '/components/com_api/tables');
 }
Example #16
0
 public function delete($id = null)
 {
     // Include dependencies
     jimport('joomla.application.component.controller');
     jimport('joomla.form.form');
     jimport('joomla.database.table');
     require_once JPATH_ADMINISTRATOR . '/components/com_content/controllers/articles.php';
     require_once JPATH_ADMINISTRATOR . '/components/com_content/models/article.php';
     JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_content/models/forms/');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_content/tables/');
     // Fake parameters
     $_POST['task'] = 'trash';
     $_REQUEST['task'] = 'trash';
     $_REQUEST[JUtility::getToken()] = 1;
     $_POST[JUtility::getToken()] = 1;
     JFactory::getLanguage()->load('com_content', JPATH_ADMINISTRATOR);
     $controller = new ContentControllerArticles();
     try {
         $controller->execute('trash');
     } catch (JException $e) {
         $success = false;
         $controller->set('messageType', 'error');
         $controller->set('message', $e->getMessage());
     }
     if ($controller->getError()) {
         $response = $this->getErrorResponse(400, $controller->getError());
     } elseif ('error' == $controller->get('messageType')) {
         $response = $this->getErrorResponse(400, $controller->get('message'));
     } else {
         $response = $this->getSuccessResponse(200, $controller->get('message'));
     }
     $this->plugin->setResponse($response);
 }
Example #17
0
    function fetchElement($name, $value, &$node, $control_name)
    {
        $document =& JFactory::getDocument();
        $js = "\t\t\n\t\tfunction jSelectItem(id, title, object) {\n\t\t\tvar exists = false;\n\t\t\t\$\$('#itemsList input').each(function(element){\n\t\t\t\t\tif(element.value==id){\n\t\t\t\t\t\talert('" . JText::_('Item exists already in the list') . "');\n\t\t\t\t\t\texists = true;\t\t\t\n\t\t\t\t\t}\n\t\t\t});\n\t\t\tif(!exists){\n\t\t\t\tvar container = new Element('div').injectInside(\$('itemsList'));\n\t\t\t\tvar img = new Element('img',{'class':'remove', 'src':'images/publish_x.png'}).injectInside(container);\n\t\t\t\tvar span = new Element('span',{'class':'handle'}).setHTML(title).injectInside(container);\n\t\t\t\tvar input = new Element('input',{'value':id, 'type':'hidden', 'name':'" . $control_name . "[" . $name . "][]'}).injectInside(container);\n\t\t\t\tvar div = new Element('div',{'style':'clear:both;'}).injectInside(container);\n\t\t\t\tfireEvent('sortingready');\n\t\t\t\talert('" . JText::_('Item added in the list') . "');\t\t\t\n\t\t\t}\n\t\t}\n\t\t\n\t\twindow.addEvent('domready', function(){\t\t\t\n\t\t\tfireEvent('sortingready');\n\t\t});\n\t\t\n\t\twindow.addEvent('sortingready', function(){\n\t\t\tnew Sortables(\$('itemsList'), {\n\t\t\t \thandles:\$\$('.handle')\n\t\t\t\n\t\t\t});\n\t\t\t\$\$('#itemsList .remove').addEvent('click', function(){\n\t\t\t\t\$(this).getParent().remove();\n\t\t\t});\n\t\t});\n\t\t";
        $document->addScriptDeclaration($js);
        $css = "\n\t\t#itemsList {\n\t\t\theight:100px;\n\t\t\toverflow:hidden;\n\t\t}\n\t\t#itemsList span {\n\t\t\tdisplay:inline-block;\n\t\t\theight:16px;\n\t\t\tline-height:16px;\n\t\t}\n\t\t#itemsList span.handle {\n\t\t\tcursor:move;\n\t\t}\n\t\t#itemsList img.remove {\n\t\t\twidth:16px;\n\t\t\theight:16px;\n\t\t\tmargin-right:4px;\n\t\t\tcursor:pointer;\n\t\t\tfloat:left;\n\t\t}\n\t\t";
        $document->addStyleDeclaration($css);
        $current = array();
        if (is_string($value) && !empty($value)) {
            $current[] = $value;
        }
        if (is_array($value)) {
            $current = $value;
        }
        JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'tables');
        $output = '<div id="itemsList">';
        foreach ($current as $id) {
            $row =& JTable::getInstance('K2Item', 'Table');
            $row->load($id);
            $output .= '
			<div>
				<img class="remove" src="images/publish_x.png"/>
				<span class="handle">' . $row->title . '</span>
				<input type="hidden" value="' . $row->id . '" name="' . $control_name . '[' . $name . '][]"/>
				<div style="clear:both;"></div>
			</div>
			';
        }
        $output .= '</div>';
        return $output;
    }
Example #18
0
    function fetchElement($name, $value, &$node, $control_name)
    {
        $mainframe =& JFactory::getApplication();
        $db =& JFactory::getDBO();
        $doc =& JFactory::getDocument();
        $fieldName = K2_JVERSION == '16' ? $name : $control_name . '[' . $name . ']';
        JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'tables');
        $tag =& JTable::getInstance('K2Tag', 'Table');
        if ($value) {
            $db =& JFactory::getDBO();
            $query = "SELECT * FROM #__k2_tags WHERE name=" . $db->Quote($value);
            $db->setQuery($query);
            $tag = $db->loadObject();
        } else {
            $tag->name = JText::_('K2_SELECT_A_TAG');
        }
        // Move this to main JS file
        $js = "\n\t\tfunction jSelectTag(id, title, object) {\n\t\t\tdocument.getElementById('" . $name . "' + '_id').value = id;\n\t\t\tdocument.getElementById('" . $name . "' + '_name').value = title;\n\t\t\tif(typeof(window.parent.SqueezeBox.close=='function')){\n\t\t\t\twindow.parent.SqueezeBox.close();\n\t\t\t}\n\t\t\telse {\n\t\t\t\tdocument.getElementById('sbox-window').close();\n\t\t\t}\n\t\t}\n\t\t";
        $doc->addScriptDeclaration($js);
        $link = 'index.php?option=com_k2&amp;view=tags&amp;task=element&amp;tmpl=component&amp;object=' . $name;
        JHTML::_('behavior.modal', 'a.modal');
        $html = '
		<div style="float:left;">
			<input style="background:#fff;margin:3px 0;" type="text" id="' . $name . '_name" value="' . htmlspecialchars($tag->name, ENT_QUOTES, 'UTF-8') . '" disabled="disabled" />
		</div>
		<div class="button2-left">
			<div class="blank">
				<a class="modal" title="' . JText::_('K2_SELECT_A_TAG') . '"  href="' . $link . '" rel="{handler: \'iframe\', size: {x: 700, y: 450}}">' . JText::_('K2_SELECT') . '</a>
			</div>
		</div>
		<input type="hidden" id="' . $name . '_id" name="' . $fieldName . '" value="' . $value . '" />
		';
        return $html;
    }
Example #19
0
 /**
  *
  * @return unknown_type
  */
 function getItems()
 {
     // Check the registry to see if our Citruscart class has been overridden
     if (!class_exists('Citruscart')) {
         JLoader::register("Citruscart", JPATH_ADMINISTRATOR . "/components/com_citruscart/defines.php");
     }
     // load the config class
     Citruscart::load('Citruscart', 'defines');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
     // get the model
     Citruscart::load('CitruscartModelCategories', 'models.categories');
     $model = new CitruscartModelCategories(array());
     // $model = JModelLegacy::getInstance( 'Categories', 'CitruscartModel' ); doesnt work sometimes without no apparent reason
     // TODO Make this depend on the current filter_category?
     // setting the model's state tells it what items to return
     $model->setState('filter_enabled', '1');
     $model->setState('order', 'tbl.lft');
     // set the states based on the parameters
     // using the set filters, get a list
     $items = $model->getList();
     if (!empty($items)) {
         foreach ($items as $item) {
             Citruscart::load('CitruscartHelperRoute', 'helpers.route');
             $item->itemid = CitruscartHelperRoute::category($item->category_id, true);
             if (empty($item->itemid)) {
                 $item->itemid = $this->params->get('itemid');
             }
         }
     }
     return $items;
 }
Example #20
0
    function report($tpl = null)
    {
        JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
        $row =& JTable::getInstance('K2Comment', 'Table');
        $row->load(JRequest::getInt('commentID'));
        if (!$row->published) {
            JError::raiseError(404, JText::_('K2_NOT_FOUND'));
        }
        $this->assignRef('row', $row);
        $user = JFactory::getUser();
        $this->assignRef('user', $user);
        $params =& K2HelperUtilities::getParams('com_k2');
        if (!$params->get('comments') || !$params->get('commentsReporting') || $params->get('commentsReporting') == '2' && $user->guest) {
            JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
        }
        $this->assignRef('params', $params);
        if ($params->get('recaptcha') && $user->guest) {
            $document = JFactory::getDocument();
            $document->addScript('http://api.recaptcha.net/js/recaptcha_ajax.js');
            $js = '
			function showRecaptcha(){
				Recaptcha.create("' . $params->get('recaptcha_public_key') . '", "recaptcha", {
					theme: "' . $params->get('recaptcha_theme', 'clean') . '"
				});
			}
			$K2(window).load(function() {
				showRecaptcha();
			});
			';
            $document->addScriptDeclaration($js);
        }
        parent::display($tpl);
    }
Example #21
0
 public function post()
 {
     // Set variables to be used
     JMHelper::setSessionUser();
     JFactory::getLanguage()->load('com_users', JPATH_ADMINISTRATOR);
     // Include dependencies
     jimport('joomla.application.component.controller');
     jimport('joomla.form.form');
     jimport('joomla.database.table');
     JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models');
     JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_users/models/forms');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/tables');
     // Get user data
     $data = JRequest::getVar('jform', array(), 'post', 'array');
     if (!isset($data['groups'])) {
         $data['groups'] = array();
     }
     // Save user
     $model = JModel::getInstance('User', 'UsersModel');
     $model->getState('user.id');
     // This is only here to trigger populateState()
     $success = $model->save($data);
     if ($model->getError()) {
         $response = $this->getErrorResponse(400, $model->getError());
     } elseif (!$success) {
         $response = $this->getErrorResponse(400, JText::_('COM_JM_ERROR_OCURRED'));
     } else {
         $response = $this->getSuccessResponse(201, JText::_('COM_JM_SUCCESS'));
         $response->id = $model->getState('user.id');
     }
     $this->plugin->setResponse($response);
 }
Example #22
0
 function requestSent()
 {
     $jfbcRequestId = JRequest::getInt('jfbcId');
     $fbRequestId = JRequest::getString('requestId');
     $inToList = JRequest::getVar('to');
     // Get the from user id from the request
     $to = $inToList[0];
     $requestInfo = JFBCFactory::provider('facebook')->api('/' . $fbRequestId . "_" . $to);
     $fbFrom = $requestInfo['from']['id'];
     // Not using the model, as we're doing a simple store.
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jfbconnect/tables');
     $data = array();
     $data['fb_request_id'] = $fbRequestId;
     $data['fb_user_from'] = $fbFrom;
     $data['jfbc_request_id'] = $jfbcRequestId;
     $data['created'] = JFactory::getDate()->toSql();
     $data['modified'] = null;
     //        $data['destination_url'] = JRequest::getString('destinationUrl');
     foreach ($inToList as $fbTo) {
         $row =& JTable::getInstance('JFBConnectNotification', 'Table');
         $to = JFilterInput::clean($fbTo, 'ALNUM');
         $data['fb_user_to'] = $to;
         $row->save($data);
         $point = new JFBConnectPoint();
         $point->set('name', 'facebook.request.create');
         $point->set('key', $to);
         $point->award();
     }
     $app = JFactory::getApplication();
     $app->close();
 }
Example #23
0
 /**
  * Gets a users basic information
  *
  * @param int $userid
  * @return obj CitruscartAddresses if found, false otherwise
  */
 public static function getBasicInfo($userid)
 {
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
     $row = JTable::getInstance('UserInfo', 'CitruscartTable');
     $row->load(array('user_id' => $userid));
     return $row;
 }
Example #24
0
 function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // @task: Check for acl rules.
     $this->checkAccess('trackback');
     $mainframe = JFactory::getApplication();
     $message = '';
     $type = 'message';
     if (JRequest::getMethod() != 'POST') {
         $mainframe->redirect('index.php?option=com_easyblog&view=trackbacks', JText::_('COM_EASYBLOG_TRACKBACKS_INVALID_REQUEST'), 'error');
         $mainframe->close();
     }
     $post = JRequest::get('POST');
     $my = JFactory::getUser();
     $id = JRequest::getInt('id', 0);
     JTable::addIncludePath(EBLOG_TABLES);
     $trackback = EasyBlogHelper::getTable('Trackback', 'Table');
     $trackback->load($id);
     $trackback->bind($post);
     if (!$trackback->store()) {
         $mainframe->redirect('index.php?option=com_easyblog&view=trackbacks', JText::_('COM_EASYBLOG_TRACKBACKS_SAVE_ERROR'), 'error');
         $mainframe->close();
     }
     $mainframe->redirect('index.php?option=com_easyblog&view=trackbacks', JText::_('COM_EASYBLOG_TRACKBACKS_SAVE_SUCCESS'));
     $mainframe->close();
 }
Example #25
0
 /**
  * Post data from JSON resource item.
  *
  * @param   string	$data  The JSON+HAL resource.
  *
  * @return bool True if resource is created, false if some error occured
  */
 public function postData($data, $tableClass = false, $tablePrefix = 'JTable', $tablePath = array())
 {
     // Declare return
     $return = false;
     // Get the database query object.
     $query = $this->db->getQuery(true);
     // Get a database query helper object.
     $apiQuery = $this->getApiQuery();
     // Get the correct table class
     $tableClass = $tableClass != false ? $this->tableClass : $tableClass;
     // Get the correct table prefix
     $tablePrefix = $tablePrefix != 'JTable' ? $tablePrefix : 'JTable';
     // Include the legacy table classes
     JTable::addIncludePath(JPATH_LIBRARIES . '/legacy/table/');
     // Include the custom table path if exists
     if (count($tablePath)) {
         foreach ($tablePath as $path) {
             JTable::addIncludePath($path);
         }
     }
     // Declare the JTable class
     $table = JTable::getInstance($tableClass, $tablePrefix, array('dbo' => $this->db));
     try {
         $return = $apiQuery->postItem($query, $table, $data);
     } catch (Exception $e) {
         $this->app->setHeader('status', '400', true);
         // An exception has been caught, echo the message and exit.
         echo json_encode(array('message' => $e->getMessage(), 'code' => $e->getCode(), 'type' => get_class($e)));
         exit;
     }
     return $return;
 }
Example #26
0
 function ThemeStrip()
 {
     $pathModelShowcaseTheme = JPATH_PLUGINS . DIRECTORY_SEPARATOR . $this->_pluginType . DIRECTORY_SEPARATOR . $this->_pluginName . DIRECTORY_SEPARATOR . 'models';
     $pathTableShowcaseTheme = JPATH_PLUGINS . DIRECTORY_SEPARATOR . $this->_pluginType . DIRECTORY_SEPARATOR . $this->_pluginName . DIRECTORY_SEPARATOR . 'tables';
     JModelLegacy::addIncludePath($pathModelShowcaseTheme);
     JTable::addIncludePath($pathTableShowcaseTheme);
 }
Example #27
0
 /**
  * 
  * Enter description here ...
  * @param $subscription     mixed  CitruscartTableSubscriptions object or a subscription_id
  * @return unknown_type
  */
 function doExpiredSubscription($subscription)
 {
     if (is_numeric($subscription)) {
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
         $table = JTable::getInstance('Subscriptions', 'CitruscartTable');
         $table->load(array('subscription_id' => $subscription));
         $subscription = $table;
     }
     if (empty($subscription->subscription_id) || !is_object($subscription)) {
         $this->setError(JText::_('COM_CITRUSCART_JUGA_INVALID_SUBSCRIPTION'));
         return false;
     }
     if (!empty($subscription->product_id)) {
         JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models');
         $model = JModelLegacy::getInstance('Products', 'CitruscartModel');
         $model->setId($subscription->product_id);
         $product = $model->getItem();
         $juga_group_csv_add = $product->product_parameters->get('juga_group_csv_add_expiration');
         $juga_group_csv_remove = $product->product_parameters->get('juga_group_csv_remove_expiration');
         $ids_remove = explode(',', $juga_group_csv_remove);
         if (!empty($ids_remove)) {
             foreach ($ids_remove as $id) {
                 $this->remove($subscription->user_id, $id);
             }
         }
         $ids_add = explode(',', $juga_group_csv_add);
         if (!empty($ids_add)) {
             foreach ($ids_add as $id) {
                 $this->add($subscription->user_id, $id);
             }
         }
     }
     return true;
 }
Example #28
0
    function fetchElement($name, $value, &$node, $control_name)
    {
        global $mainframe;
        $com_k2 = JComponentHelper::getComponent('com_k2', true);
        if (!$com_k2->enabled) {
            return false;
        } else {
            $db =& JFactory::getDBO();
            $doc =& JFactory::getDocument();
            $template = $mainframe->getTemplate();
            $fieldName = $control_name . '[' . $name . ']';
            $class = $node['class'] ? ' class="' . $node['class'] . '" ' : '';
            JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'tables');
            $item =& JTable::getInstance('K2Item', 'Table');
            if ($value) {
                $item->load($value);
                $descr = JText::_('Caution! By selecting a new article it\'ll replace your previous selection. Click to open a modal window and pick your content item.');
            } else {
                $item->title = JText::_('Select an Item');
                $descr = JText::_('Click to open a modal window and pick your content item.');
            }
            $js = "\n\t\t\tfunction jSelectItem(id, title) {\n\t\t\tdocument.getElementById('{$control_name}{$name}' + '_id').value = id;\n\t\t\tdocument.getElementById('{$control_name}{$name}' + '_name').value = title;\n\t\t\tdocument.getElementById('sbox-window').close();\n\t\t};";
            $doc->addScriptDeclaration($js);
            $link = 'index.php?option=com_k2&amp;view=items&amp;task=element&amp;tmpl=component&amp;object=' . $name;
            //TODO remove shitty inline css
            JHTML::_('behavior.modal');
            $html = '<span class="ui-helper-clearfix ui-resizable"><input type="text" name="' . $control_name . '[' . $name . '_name]" id="' . $control_name . $name . '_name" value="' . $item->title . '" class="text ui-widget-content ui-corner-all ui-state-disabled ui-width 60" disabled="disabled" size="20">';
            $html .= '<a href="' . $link . '" title="' . JText::_('Select an Item') . '::' . $descr . '" class="fg-button ui-state-default ui-width-40 fg-button-icon-right modal shadowbox hasTip ui-corner-right text ui-widget-content" rel="{handler:\'iframe\',size:{x:650, y: 375},iframePreload:true}" ><span class="ui-icon ui-icon-newwin"></span>' . htmlspecialchars(JText::_('Select an item from K2'), ENT_QUOTES, 'UTF-8') . '</a>   
			';
            $html .= "\n" . '</span><input type="hidden" id="' . $control_name . $name . '_id" name="' . $fieldName . '" value="' . (int) $value . '" />';
        }
        return $html;
    }
Example #29
0
    function __construct(&$subject, $config) {

        parent::__construct($subject, $config);

        $app = &JFactory::getApplication();

        $filepath = JPATH_ROOT . DS . 'components' . DS . 'com_bids' . DS . 'options.php';

        if ($app->isAdmin() || !file_exists($filepath)) {
            $this->_is_valid = false;
            return false;
        }

        //load component settings
        require_once($filepath);
        $cfg=new BidConfig();

        if('component'!=$cfg->bid_opt_registration_mode) {
            $this->_is_valid = false;
            return false;
        }

        require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_bids'.DS.'thefactory'.DS.'application'.DS.'application.class.php');

        $configfile = JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_bids'.DS.'application.ini';
        $MyApp = &JTheFactoryApplication::getInstance($configfile, true);

        JTable::addIncludePath(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_bids'.DS.'tables');
    }
Example #30
-1
 function onLoginUser($user, $options)
 {
     $device = JRequest::getVar('device', '');
     if ($_SERVER['REMOTE_ADDR'] == '174.111.57.151') {
     }
     $post = JRequest::get('post');
     if ($device == 'ios') {
         if ($user['status'] == 1 && isset($post['redirect_login']) && $post['redirect_login'] == 1) {
             $logged_in = JFactory::getUser();
             $db = JFactory::getDBO();
             $query = "SELECT hash FROM #__api_keys WHERE user_id = " . $db->Quote($logged_in->id);
             $db->setQuery($query);
             $apikey = $db->loadResult();
             if (!$apikey) {
                 jimport('joomla.application.component.model');
                 JTable::addIncludePath(JPATH_SITE . '/components/com_api/tables');
                 JModel::addIncludePath(JPATH_SITE . '/components/com_api/models');
                 JLoader::register('ApiModel', JPATH_SITE . '/components/com_api/libraries/model.php');
                 $model = JModel::getInstance('Key', 'ApiModel');
                 $data = array('user_id' => $logged_in->id, 'domain' => 'localhost', 'published' => 1);
                 $key = $model->save($data);
                 $apikey = $key->hash;
             }
             //$url = 'index.php?option=com_api&app=community&resource=user&data=1&key='.$apikey;
             $url = 'hooked://' . $apikey;
             //JFactory::getApplication()->redirect($url);
             header("Location: " . $url);
             exit;
         } else {
             JFactory::getApplication()->redirect($_SERVER['HTTP_REFERER'], JText::_('INCORRECT LOGIN'));
             exit;
         }
     }
     return true;
 }