当前位置: 首页>>代码示例>>PHP>>正文


PHP JParameter::bind方法代码示例

本文整理汇总了PHP中JParameter::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP JParameter::bind方法的具体用法?PHP JParameter::bind怎么用?PHP JParameter::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JParameter的用法示例。


在下文中一共展示了JParameter::bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testBind

 /**
  * Test the JParameter::bind method.
  *
  * @return  void
  *
  * @since   11.1
  */
 public function testBind()
 {
     $p = new JParameter('');
     // Check binding an array.
     $p->bind(array('foo1' => 'bar1'));
     $this->assertThat($p->get('foo1'), $this->equalTo('bar1'));
     // Check binding an object.
     $object = new stdClass();
     $object->foo1 = 'bar2';
     $p->bind($object);
     $this->assertThat($p->get('foo1'), $this->equalTo('bar2'));
     // Check binding a JSON string.
     $p->bind('{"foo1":"bar4"}');
     $this->assertThat($p->get('foo1'), $this->equalTo('bar4'));
     // Check binding an INI string.
     $p->bind('foo1=bar5');
     $this->assertThat($p->get('foo1'), $this->equalTo('bar5'));
 }
开发者ID:raquelsa,项目名称:Joomla,代码行数:25,代码来源:JParameterTest.php

示例2: JParameter

 function &getIni()
 {
     static $ini = 0;
     if (empty($ini)) {
         $basepath = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jdefender';
         $p = new JParameter('');
         $conf = JD_Vars_Helper::getGroup('configuration');
         $p->bind($conf);
         $ini = $p->toString('ini');
     }
     return $ini;
 }
开发者ID:alphashuro,项目名称:audeprac,代码行数:12,代码来源:configuration.php

示例3: saveDefaultAuctionSettings

    function saveDefaultAuctionSettings($ob) {

        jimport('joomla.html.parameter');

        $my = JFactory::getUser();
        $config = & JFactory::getConfig();

        $us = JTable::getInstance('bidusersettings');

        $settings = new JParameter(null);

        $paramKeys = array(
            'show_reserve',
            'picture',
            'add_picture',
            'auto_accept_bin',
            'bid_counts',
            'max_price',
            'end_hour',
            'end_minute',
            'auction_type',
            'currency',
            'shipment_info',
            'shipment_price',
            'payment_info',
            'payment_options');

        $vals = array();
        foreach($paramKeys as $k) {
            $v = is_object($ob) ? (isset($ob->$k) ? $ob->$k : null) : (is_array($ob) ? @$ob[$k] : null);
            $vals[$k] = $v;
        }

        //convert end time to GMT
        try {
            $endTime = JFactory::getDate( ' ' . $vals['end_hour'] . ':' . $vals['end_minute'] . ':00', $config->getValue('config.offset'));
            @list($vals['end_hour'],$vals['end_minute']) = explode(':',$endTime->toFormat('%H:%M'));
        } catch(Exception $e) {
            if(JDEBUG) {
                JError::raiseWarning(1,$e->getMessage());
            }
        }


        $settings->bind($vals);

        $us->settings = $settings;
        $us->userid = $my->id;

        return $us->store();
    }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:51,代码来源:user.php

示例4: edit

 /**
  * Edit a connection
  */
 function edit()
 {
     $user =& JFactory::getUser();
     $db =& JFactory::getDBO();
     $row =& JTable::getInstance('visualization', 'Table');
     if ($this->_task == 'edit') {
         $cid = JRequest::getVar('cid', array(0), 'method', 'array');
         $cid = array((int) $cid[0]);
     } else {
         $cid = array(0);
     }
     $row->load($cid[0]);
     if ($cid) {
         $row->checkout($user->get('id'));
     }
     // get params definitions
     $params = new fabrikParams($row->attribs, JPATH_COMPONENT . DS . 'xml' . DS . 'visualization.xml');
     require_once JPATH_COMPONENT . DS . 'views' . DS . 'visualization.php';
     //build list of visualization plugins
     $pluginManager =& JModel::getInstance('Pluginmanager', 'FabrikModel');
     $pluginManager->getPlugInGroup('visualization');
     $lists['plugins'] = $pluginManager->getElementTypeDd($row->plugin, 'plugin', 'class="inputbox"');
     //build list of menus
     $lists['menuselect'] = FabrikHelperMenu::MenuSelect();
     if ($row->id != '') {
         //only existing tables can have a menu linked to them
         $and = "\n AND link LIKE 'index.php?option=com_fabrik&view=visualization%'";
         $and .= " AND params LIKE '%visualizationid=" . $row->id . "%'";
         $menus = FabrikHelperMenu::Links2Menu('component', $and);
     } else {
         $menus = null;
     }
     //get table and connection drop downs
     $db->setQuery("SELECT id AS value, label AS text FROM #__fabrik_tables");
     $rows = $db->loadObjectList();
     $default = '';
     $lists['tables'] = JHTML::_('select.genericlist', $rows, 'table[]', "class=\"inputbox\"  size=\"1\" ", 'value', 'text', $default);
     // Create the form
     $form = new JParameter('', JPATH_COMPONENT . DS . 'models' . DS . 'visualization.xml');
     $form->bind($row);
     $form->set('created', JHTML::_('date', $row->created, '%Y-%m-%d %H:%M:%S'));
     $form->set('publish_up', JHTML::_('date', $row->publish_up, '%Y-%m-%d %H:%M:%S'));
     if ($cid[0] == 0 || $form->get('publish_down') == '' || $form->get('publish_down') == $db->getNullDate()) {
         $form->set('publish_down', JText::_('NEVER'));
     } else {
         $form->set('publish_down', JHTML::_('date', $row->publish_down, '%Y-%m-%d %H:%M:%S'));
     }
     FabrikViewVisualization::edit($row, $params, $lists, $menus, $pluginManager, $form);
 }
开发者ID:nikshade,项目名称:fabrik21,代码行数:52,代码来源:visualization.php

示例5: replace

 function replace(&$article, &$matches, $count, $regex, $pluginParams)
 {
     for ($i = 0; $i < $count; $i++) {
         // set line params
         $this->setParams($matches[1][$i], array('width' => null, 'height' => null));
         // set default thumbnail size, if no sizes defined
         if (!$this->parameter['width'] && !$this->parameter['height']) {
             $this->parameter['width'] = $pluginParams->get('width', 100);
             $this->parameter['height'] = null;
         }
         // set gallery params
         $params = new JParameter('');
         $params->bind($pluginParams->toArray());
         $params->bind($this->parameter);
         $params->set('cfg_path', 'plugins/content/yoo_gallery/');
         $params->set('cfg_juri', JURI::base());
         $params->set('cfg_jroot', JPATH_ROOT);
         // render gallery
         $gallery =& new YOOGallery($params);
         $replace = $gallery->render();
         // replace
         $article->text = str_replace($matches[0][$i], $replace, $article->text);
     }
 }
开发者ID:janssit,项目名称:www.alu-andries.be,代码行数:24,代码来源:yoo_gallery.php

示例6: getGeneralForm

 function getGeneralForm($workflow)
 {
     $form = new JParameter('');
     $form->addElementPath(JWF_BACKEND_PATH . DS . 'elements');
     $form->loadSetupFile(JPATH_COMPONENT . DS . 'models' . DS . 'workflow.xml');
     $jsOutput = '';
     if ($workflow != null) {
         $form->bind($workflow);
         $jsOutput = JHTML::_('jwf.startJSBlock', 2);
         $jsOutput .= JHTML::_('jwf.indentedLine', 'adminGroupId =' . $workflow->admin_gid . ';', 2);
         $jsOutput .= JHTML::_('jwf.indentedLine', 'window.addEvent("load",function(){', 3);
         $jsOutput .= JHTML::_('jwf.indentedLine', 'var s;', 4);
         $jsOutput .= JHTML::_('jwf.indentedLine', 'var tempHook;', 4);
         foreach ($workflow->stations as $s) {
             $s->activeHooks = unserialize(base64_decode($s->activeHooks));
             $jsOutput .= JHTML::_('jwf.indentedLine', "s = new Object();", 4);
             $jsOutput .= JHTML::_('jwf.indentedLine', "s.id    = {$s->id};", 4);
             $jsOutput .= JHTML::_('jwf.indentedLine', "s.title = '{$s->title}';", 4);
             $jsOutput .= JHTML::_('jwf.indentedLine', "s.task  = '{$s->task}';", 4);
             $jsOutput .= JHTML::_('jwf.indentedLine', "s.allocatedTime = {$s->allocatedTime};", 4);
             $jsOutput .= JHTML::_('jwf.indentedLine', "s.acl   =  {id:{$s->group},name:aclLists['" . $workflow->acl . "'][{$s->group}]};", 4);
             $jsOutput .= JHTML::_('jwf.indentedLine', "s.fields= '{$s->fields}';", 4);
             $jsOutput .= JHTML::_('jwf.indentedLine', "s.activeValidations= '{$s->activeValidations}';", 4);
             $jsOutput .= JHTML::_('jwf.indentedLine', "s.activeHooks = new Array();", 4);
             $jsOutput .= JHTML::_('jwf.indentedLine', "tempHook = new Object();", 4);
             foreach ($s->activeHooks as $hookName => $hookData) {
                 $parameters = JArrayHelper::fromObject($hookData);
                 foreach ($parameters as $key => $value) {
                     $value = addslashes($value);
                     $value = str_replace("\r\n", "\n", $value);
                     $value = str_replace("\n", '\\n', $value);
                     $jsOutput .= JHTML::_('jwf.indentedLine', "tempHook.{$key} = '{$value}';", 4);
                 }
                 $jsOutput .= JHTML::_('jwf.indentedLine', "s.activeHooks['{$hookName}'] = tempHook;", 4);
             }
             $jsOutput .= JHTML::_('jwf.indentedLine', "addElement(s);", 4);
         }
         $jsOutput .= JHTML::_('jwf.indentedLine', '});', 3);
         $jsOutput .= JHTML::_('jwf.endJSBlock', 2);
     }
     return $jsOutput . $form->render('params');
 }
开发者ID:BGCX261,项目名称:zonales-svn-to-git,代码行数:42,代码来源:view.html.php

示例7: jimport

 function createMenuJ15($menu, $submenu)
 {
     jimport('joomla.utilities.string');
     jimport('joomla.application.component.helper');
     $config = KunenaFactory::getConfig();
     $component_id = JComponentHelper::getComponent('com_kunena')->id;
     // First fix all broken menu items
     $query = "UPDATE #__menu SET componentid={$this->db->quote($component_id)} WHERE type = 'component' AND link LIKE '%option=com_kunena%'";
     $this->db->setQuery($query);
     $this->db->query();
     if ($this->db->getErrorNum()) {
         throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
     }
     // Find out if menu exists
     $query = "SELECT id FROM `#__menu_types` WHERE `menutype`='kunenamenu';";
     $this->db->setQuery($query);
     $moduleid = (int) $this->db->loadResult();
     if ($this->db->getErrorNum()) {
         throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
     }
     // Do not touch existing menu
     if ($moduleid) {
         return;
     }
     // Create new Joomla menu for Kunena
     if (!$moduleid) {
         // Create a menu type for the Kunena menu
         $query = "REPLACE INTO `#__menu_types` (`id`, `menutype`, `title`, `description`) VALUES\n\t\t\t\t\t\t\t({$moduleid}, 'kunenamenu', {$this->db->Quote(JText::_('COM_KUNENA_MENU_TITLE'))} , {$this->db->Quote(JText::_('COM_KUNENA_MENU_TITLE_DESC'))} )";
         $this->db->setQuery($query);
         $this->db->query();
         if ($this->db->getErrorNum()) {
             throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
         }
     }
     // Forum
     $query = "SELECT id FROM `#__menu` WHERE `link`={$this->db->quote($menu['link'])} AND `menutype`='kunenamenu';";
     $this->db->setQuery($query);
     $parentid = (int) $this->db->loadResult();
     if ($this->db->getErrorNum()) {
         throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
     }
     if (!$parentid) {
         $params = new JParameter('');
         $params->bind($menu['params']);
         $query = "REPLACE INTO `#__menu` (`id`, `menutype`, `name`, `alias`, `link`, `type`, `published`, `parent`, `componentid`, `sublevel`, `ordering`, `checked_out`, `checked_out_time`, `pollid`, `browserNav`, `access`, `utaccess`, `params`, `lft`, `rgt`, `home`) VALUES\n\t\t\t\t\t\t\t({$parentid}, 'kunenamenu', {$this->db->quote($menu['name'])}, {$this->db->quote($menu['alias'])}, {$this->db->quote($menu['link'])}, 'component', 1, 0, {$component_id}, 0, 1, 0, '0000-00-00 00:00:00', 0, 0, {$menu['access']}, 0, {$this->db->quote($params->toString('INI'))}, 0, 0, 0);";
         $this->db->setQuery($query);
         $this->db->query();
         if ($this->db->getErrorNum()) {
             throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
         }
         $parentid = (int) $this->_db->insertId();
     }
     // Submenu (shown in Kunena)
     $defaultmenu = 0;
     $ordering = 0;
     foreach ($submenu as $menuitem) {
         $ordering++;
         //			$query = "SELECT id FROM `#__menu` WHERE `link`={$this->db->quote($menuitem['link'])} AND `menutype`='kunenamenu';";
         //			$this->db->setQuery ( $query );
         //			$id = ( int ) $this->db->loadResult ();
         //			if ($this->db->getErrorNum ())
         //				throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
         $id = 0;
         if (!$id) {
             $params = new JParameter('');
             $params->bind($menuitem['params']);
             $query = "REPLACE INTO `#__menu` (`id`, `menutype`, `name`, `alias`, `link`, `type`, `published`, `parent`, `componentid`, `sublevel`, `ordering`, `checked_out`, `checked_out_time`, `pollid`, `browserNav`, `access`, `utaccess`, `params`, `lft`, `rgt`, `home`) VALUES\n\t\t\t\t\t\t\t\t({$id}, 'kunenamenu', {$this->db->quote($menuitem['name'])}, {$this->db->quote($menuitem['alias'])}, {$this->db->quote($menuitem['link'])},'component', 1, {$parentid}, {$component_id}, 1, {$ordering}, 0, '0000-00-00 00:00:00', 0, 0, {$menuitem['access']}, 0, {$this->db->quote($params->toString('INI'))}, 0, 0, 0);";
             $this->db->setQuery($query);
             $this->db->query();
             if ($this->db->getErrorNum()) {
                 throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
             }
             $id = (int) $this->_db->insertId();
             if (!$defaultmenu || isset($menuitem['default']) && $config->defaultpage == $menuitem['default']) {
                 $defaultmenu = $id;
             }
         }
     }
     if ($defaultmenu) {
         $query = "UPDATE `#__menu` SET `link`={$this->db->quote($menu['link'] . "&defaultmenu={$defaultmenu}")} WHERE id={$parentid}";
         $this->db->setQuery($query);
         $this->db->query();
         if ($this->db->getErrorNum()) {
             throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
         }
     }
     // Finally add forum menu link to default menu
     $jmenu = JMenu::getInstance('site');
     $dmenu = $jmenu->getDefault();
     $query = "SELECT id, name, type, link, published FROM `#__menu` WHERE `alias` IN ('forum', 'kunenaforum', {$this->db->quote(JText::_('COM_KUNENA_MENU_FORUM_ALIAS'))}) AND `menutype`={$this->db->quote($dmenu->menutype)}";
     $this->db->setQuery($query, 0, 1);
     $menualias = $this->db->loadObject();
     if ($this->db->getErrorNum()) {
         throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
     }
     // We do not want to replace users own menu items (just alias or deprecated link to Kunena)
     if (!$menualias || $menualias->type == 'menulink' || $menualias->link == 'index.php?option=com_kunena') {
         $id = $menualias ? intval($menualias->id) : 0;
         // Keep state (default=unpublished) and name (default=Forum)
         $published = $menualias ? intval($menualias->published) : 0;
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:senluonirvana,代码行数:101,代码来源:model.php

示例8: edit


//.........这里部分代码省略.........
     $linkedform_linktype = $params->get('linkedform_linktype', '', '_default', 'array');
     $linkedtable_linktype = $params->get('linkedtable_linktype', '', '_default', 'array');
     $tableLinkTexts = $params->get('linkedtabletext', '', '_default', 'array');
     $formLinkTexts = $params->get('linkedformtext', '', '_default', 'array');
     $lists['linkedtables'] = array();
     $f = 0;
     $used = array();
     foreach ($linkedTables as $linkedTable) {
         $key = $linkedTable->table_id . '-' . $linkedTable->form_id . '-' . $linkedTable->element_id;
         if (!array_key_exists($f, $aExisitngLinkedTables)) {
             $aExisitngLinkedTables[$f] = '0';
         }
         if (!array_key_exists($f, $linkedtable_linktype)) {
             $linkedtable_linktype[$f] = '0';
         }
         //fiddle ordering
         $index = array_search($key, $aExisitngLinkedTables);
         $index = $index === false ? $f : $index;
         if (!array_search($key, $aExisitngLinkedTables)) {
             for ($fcounter = 0; $fcounter <= count($linkedTables); $fcounter++) {
                 if (!in_array($fcounter, $used)) {
                     $index = $fcounter;
                     break;
                 }
             }
         }
         $used[] = $index;
         $yeschecked = in_array($linkedTable->db_table_name, $aExisitngLinkedTables) || JArrayHelper::getValue($aExisitngLinkedTables, $index, 0) != '0' ? 'checked="checked"' : ($checked = '');
         $nochecked = $yeschecked == '' ? 'checked="checked"' : ($checked = '');
         $el = '<label><input name="params[linkedtable][' . $key . ']" value="0" ' . $nochecked . ' type="radio">' . JText::_('NO') . '</label>';
         $el .= '<label><input name="params[linkedtable][' . $key . ']" value="' . $key . '" ' . $yeschecked . ' type="radio">' . JText::_('YES') . '</label>';
         $yeschecked = in_array($linkedTable->db_table_name, $linkedtable_linktype) || JArrayHelper::getValue($linkedtable_linktype, $index, 0) != '0' ? 'checked="checked"' : ($checked = '');
         $nochecked = $yeschecked == '' ? 'checked="checked"' : ($checked = '');
         $linkType1 = '<label><input name="params[linkedtable_linktype][' . $key . ']" value="0" ' . $nochecked . ' type="radio">' . JText::_('NO') . '</label>';
         $linkType1 .= '<label><input name="params[linkedtable_linktype][' . $key . ']" value="' . $key . '" ' . $yeschecked . ' type="radio">' . JText::_('YES') . '</label>';
         $tableHeader = '<input name="params[linkedtableheader][' . $key . ']" value="' . @$aExistingTableHeaders[$index] . '" size="16" >';
         $label = str_replace(array("\n", "\r", "<br>", "</br>"), '', $linkedTable->tablelabel);
         $hover = JText::_('ELEMENT') . ': ' . $linkedTable->element_label . " [{$linkedTable->plugin}]. {tmpl key =" . $linkedTable->element_id . "_table_heading}";
         $tableLinkText = '<input name="params[linkedtabletext][' . $key . ']" value="' . @$tableLinkTexts[$index] . '" size="16" >';
         $linkedArray = array($label, $hover, $el, $tableHeader, $linkType1, $tableLinkText);
         $lists['linkedtables'][$index] = $linkedArray;
     }
     ksort($lists['linkedtables']);
     $lists['linkedforms'] = array();
     $f = 0;
     $used = array();
     /***/
     foreach ($linkedTables as $linkedTable) {
         $key = $linkedTable->table_id . '-' . $linkedTable->form_id . '-' . $linkedTable->element_id;
         if (!array_key_exists($f, $aExisitngLinkedForms)) {
             $aExisitngLinkedForms[$f] = '0';
         }
         if (!array_key_exists($f, $linkedform_linktype)) {
             $linkedform_linktype[$f] = '0';
         }
         //fiddle ordering
         $index = array_search($key, $aExisitngLinkedForms);
         $index = $index === false ? $f : $index;
         if (!array_search($key, $aExisitngLinkedForms)) {
             for ($fcounter = 0; $fcounter <= count($linkedTables); $fcounter++) {
                 if (!in_array($fcounter, $used)) {
                     $index = $fcounter;
                     break;
                 }
             }
         }
         $used[] = $index;
         $yeschecked = in_array($linkedTable->db_table_name, $aExisitngLinkedForms) || JArrayHelper::getValue($aExisitngLinkedForms, $index, 0) != '0' ? 'checked="checked"' : ($checked = '');
         $nochecked = $yeschecked == '' ? 'checked="checked"' : ($checked = '');
         $el2 = '<label><input name="params[linkedform][' . $key . ']" value="0" ' . $nochecked . ' type="radio">' . JText::_('NO') . '</label>';
         $el2 .= '<label><input name="params[linkedform][' . $key . ']" value="' . $key . '" ' . $yeschecked . ' type="radio">' . JText::_('YES') . '</label>';
         $yeschecked = in_array($linkedTable->db_table_name, $linkedform_linktype) || JArrayHelper::getValue($linkedform_linktype, $index, 0) != '0' ? 'checked="checked"' : ($checked = '');
         $nochecked = $yeschecked == '' ? 'checked="checked"' : ($checked = '');
         $linkType2 = '<label><input name="params[linkedform_linktype][' . $key . ']" value="0" ' . $nochecked . ' type="radio">' . JText::_('NO') . '</label>';
         $linkType2 .= '<label><input name="params[linkedform_linktype][' . $key . ']" value="' . $key . '" ' . $yeschecked . ' type="radio">' . JText::_('YES') . '</label>';
         $formHeader = '<input name="params[linkedformheader][' . $key . ']" value="' . @$aExistingFormHeaders[$index] . '" size="16" >';
         $label = str_replace(array("\n", "\r", "<br>", "</br>"), '', $linkedTable->tablelabel);
         $formLinkText = '<input name="params[linkedformtext][' . $key . ']" value="' . @$formLinkTexts[$index] . '" size="16" >';
         $linkedArray = array($label, $el2, $formHeader, $linkType2, $formLinkText);
         $linkedArray['formhover'] = JText::_('ELEMENT') . ': ' . $linkedTable->element_label . " [{$linkedTable->plugin}]. {tmpl key =" . $linkedTable->element_id . "_form_heading}";
         $lists['linkedforms'][$index] = $linkedArray;
     }
     ksort($lists['linkedforms']);
     /*****/
     $pluginManager = JModel::getInstance('Pluginmanager', 'FabrikModel');
     $pluginManager->getPlugInGroup('table');
     // Create the form (publish dates should be stored as UTC)
     $form = new JParameter('', JPATH_COMPONENT . DS . 'models' . DS . 'table.xml');
     $form->bind($row);
     $form->set('created', JHTML::_('date', $row->created, '%Y-%m-%d %H:%M:%S'));
     $form->set('publish_up', JHTML::_('date', $row->publish_up, '%Y-%m-%d %H:%M:%S'));
     if ($cid[0] == 0 || $form->get('publish_down') == '' || $form->get('publish_down') == $db->getNullDate()) {
         $form->set('publish_down', JText::_('NEVER'));
     } else {
         $form->set('publish_down', JHTML::_('date', $row->publish_down, '%Y-%m-%d %H:%M:%S'));
     }
     $form->loadINI($row->attribs);
     $session->set('com_fabrik.admin.table.edit.model', $model);
     FabrikViewTable::edit($row, $lists, $connectionTables, $menus, $fabrikid, $params, $pluginManager, $model, $form);
 }
开发者ID:nikshade,项目名称:fabrik21,代码行数:101,代码来源:table.php

示例9: ajaxSaveSettings

 /**
  *
  */
 public function ajaxSaveSettings($postvars)
 {
     // Check permissions
     $my =& JFactory::getUser();
     if ($my->id == 0) {
         return $this->ajaxBlockUnregister();
     }
     $objResponse = new JAXResponse();
     $appsModel = CFactory::getModel('apps');
     $appName = $postvars['appname'];
     $id = $postvars['appid'];
     // @rule: Test if app is core app as we need to add into the db
     $pluginId = $appsModel->getPluginId($appName);
     $appParam = new JParameter($appsModel->getPluginParams($pluginId));
     if ($pluginId && $my->id != 0 && $appParam->get('coreapp')) {
         // Add new app in the community plugins table
         $appsModel->addApp($my->id, $appName);
         // @rule: For core applications, the ID might be referring to Joomla's id. Get the correct id if needed.
         $id = $appsModel->getUserApplicationId($appName, $my->id);
     }
     // Make sure this is valid for current user
     if (!$appsModel->isOwned($my->id, $id)) {
         // It could be that the app is a core app.
         $objResponse->addAlert('CC PERMISSION ERROR');
         return $objResponse->sendResponse();
     }
     $post = array();
     // convert $postvars to normal post
     $pattern = "'params\\[(.*?)\\]'s";
     for ($i = 0; $i < count($postvars); $i++) {
         if (!empty($postvars[$i]) && is_array($postvars[$i])) {
             $key = $postvars[$i][0];
             // Blogger view
             preg_match($pattern, $key, $matches);
             if ($matches) {
                 $key = $matches[1];
             }
             $post[$key] = $postvars[$i][1];
         }
     }
     $xmlPath = JPATH_COMPONENT . DS . 'applications' . DS . $appName . DS . $appName . '.xml';
     $params = new JParameter($appsModel->getUserAppParams($id), $xmlPath);
     $params->bind($post);
     //echo $params->toString();
     $appsModel->storeParams($id, $params->toString());
     $objResponse->addScriptCall('cWindowHide');
     return $objResponse->sendResponse();
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:51,代码来源:apps.php

示例10: ajaxSaveField

 /**
  * AJAX method to save a field
  * 
  * @param	int	id	Current field id
  * @param	Array data	The fields data
  * 
  * @return	JAXResponse object	Azrul's AJAX Response object
  **/
 function ajaxSaveField($id, $data)
 {
     $user =& JFactory::getUser();
     if ($user->get('guest')) {
         JError::raiseError(403, JText::_('CC ACCESS FORBIDDEN'));
         return;
     }
     $response = new JAXResponse();
     // Load the JTable Object.
     $row =& JTable::getInstance('profiles', 'CommunityTable');
     $row->load($id);
     $isValid = true;
     $row->bindAjaxPost($data);
     // override the option visiable, registration and required for label type.
     if ($row->type == 'label') {
         $row->visible = 0;
         $row->required = 0;
     }
     // Do some validation before blindly saving the profile.
     if (empty($row->name)) {
         $error = JText::_('CC NAME SHOULD NOT BE LEFT EMPTY');
         $response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");');
         $isValid = false;
     }
     if (empty($row->fieldcode)) {
         $error = JText::_('CC FIELD CODE SHOULD NOT BE LEFT EMPTY');
         $response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");');
         $isValid = false;
     }
     if ($row->required && !$row->registration) {
         $error = JText::_('CC A FIELD IN REQUIRED SHOULD SET AS REGISTRATION AS WELL');
         $response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");');
         $isValid = false;
     }
     if ($isValid) {
         $groupOrdering = isset($data['group']) ? $data['group'] : '';
         /* Now, save optional params items */
         $xmlPath = JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'fields' . DS . $row->type . '.xml';
         if (JFile::exists($xmlPath)) {
             $postvars = $data;
             $post = array();
             // convert $postvars to normal post
             $pattern = "'params\\[(.*?)\\]'s";
             for ($i = 0; $i < count($postvars); $i++) {
                 if (!empty($postvars[$i]) && is_array($postvars[$i])) {
                     $key = $postvars[$i][0];
                     // @TODO: support 'usergroup' param type
                     preg_match($pattern, $key, $matches);
                     if ($matches) {
                         $key = $matches[1];
                         $post[$key] = $postvars[$i][1];
                     }
                 }
             }
             $params = new JParameter('', $xmlPath);
             $params->bind($post);
             $row->params = $params->toString();
         }
         $row->store($groupOrdering);
         $parent = '';
         // Get the view
         $view =& $this->getView('profiles', 'html');
         if ($id != 0) {
             $name = '<a href="javascript:void(0);" onclick="azcommunity.editField(\'' . $row->id . '\');">' . $row->name . '</a>';
             $type = '<span id="type' . $row->id . '" onclick="$(\'typeOption\').style.display = \'block\';$(this).style.display = \'none\';">' . JString::ucfirst($row->type) . '</span>';
             $publish = $view->getPublish($row, 'published', 'profiles,ajaxTogglePublish');
             if ($row->type == 'label') {
                 $required = $view->showPublish($row, 'required');
                 $visible = $view->showPublish($row, 'visible');
             } else {
                 $required = $view->getPublish($row, 'required', 'profiles,ajaxTogglePublish');
                 $visible = $view->getPublish($row, 'visible', 'profiles,ajaxTogglePublish');
             }
             $registration = $view->getPublish($row, 'registration', 'profiles,ajaxTogglePublish');
             // Set the parent id
             $parent = $row->id;
             // Update the rows in the table at the page.
             //@todo: need to update the title in a way looks like Joomla initialize the tooltip on document ready
             $response->addAssign('name' . $row->id, 'innerHTML', $name);
             $response->addAssign('type' . $row->id, 'innerHTML', $type);
             $response->addAssign('published' . $row->id, 'innerHTML', $publish);
             $response->addAssign('required' . $row->id, 'innerHTML', $required);
             $response->addAssign('visible' . $row->id, 'innerHTML', $visible);
             $response->addAssign('registration' . $row->id, 'innerHTML', $registration);
             $response->addAssign('min' . $row->id, 'value', $row->min);
             $response->addAssign('max' . $row->id, 'value', $row->max);
         } else {
             $response->addScriptCall('window.location.href = "' . JURI::base() . 'index.php?option=com_community&view=profiles";');
         }
         $response->addScriptCall('cWindowHide();');
     } else {
         //release the form input back to enabled.
//.........这里部分代码省略.........
开发者ID:bizanto,项目名称:Hooked,代码行数:101,代码来源:profiles.php

示例11: loadParams

 /**
  * Convert the PlugIn parameters to an object
  * and initialise and add any missing parameters
  *
  */
 function loadParams($row, $params_array)
 {
     $txt = array();
     foreach ($params_array as $k => $v) {
         $txt[] = "{$k}={$v}";
     }
     $ini_string = implode("\n", $txt);
     $params = new JParameter($ini_string);
     //echo '<div>$params->get("days"): '.print_r($params->get("days"), true).'</div>';
     $params->bind($row->params);
     //echo '<div>$params->get("days"): '.print_r($params->get("days"), true).'</div>';
     return $params;
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:18,代码来源:plugin.php

示例12: save


//.........这里部分代码省略.........
     if (isset($this->_modified['enabled']) && !$this->_new && $user->id == $this->id && !$this->enabled) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_("You can't block yourself!"));
         return false;
     }
     // Don't allow to save a user without a group.
     if (($this->_new || isset($this->_modified['users_group_id'])) && !$this->users_group_id) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_("You can't create a user without a user group."));
         return false;
     }
     // Don't allow users below super administrator to edit a super administrator.
     if (!$this->_new && isset($this->_modified['users_group_id']) && $old_row->users_group_id == 25 && $user->gid != 25) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_("You can't edit a super administrator account."));
         return false;
     }
     // Don't allow users below super administrator to create an administrators.
     if (isset($this->_modified['users_group_id']) && $this->users_group_id == 24 && !($user->gid == 25 || $user->id == $this->id && $user->gid == 24)) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_("You can't create a user with this user group level. " . "Only super administrators have this ability."));
         return false;
     }
     // Don't allow users below super administrator to create a super administrator.
     if (isset($this->_modified['users_group_id']) && $this->users_group_id == 25 && $user->gid != 25) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_("You can't create a user with this user group level. " . "Only super administrators have this ability."));
         return false;
     }
     // Don't allow users to change the user level of the last active super administrator.
     if (isset($this->_modifid['users_group_id']) && $old_row->users_group_id != 25) {
         $query = $this->getTable()->getDatabase()->getQuery()->where('users_group_id', '=', 25)->where('enabled', '=', 1);
         $total = $this->getService('com://admin/users.database.table.users')->count($query);
         if ($total <= 1) {
             $this->setStatus(KDatabase::STATUS_FAILED);
             $this->setStatusMessage(JText::_("You can't change this user's group because " . "the user is the only active super administrator for your site."));
             return false;
         }
     }
     // Check if passwords match.
     if (isset($this->_modified['password']) && $this->password != $this->password_verify) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_("Passwords don't match!"));
         return false;
     }
     // Generate a random password if empty and the record is new.
     if ($this->_new && !$this->password) {
         $this->password = $this->getService('com://admin/users.helper.password')->getRandom();
         $this->password_verify = $this->password;
     }
     if (isset($this->_modified['password']) && $this->password) {
         // Encrypt password.
         $salt = $this->getService('com://admin/users.helper.password')->getRandom(32);
         $password = $this->getService('com://admin/users.helper.password')->getCrypted($this->password, $salt);
         $this->password = $password . ':' . $salt;
     } else {
         $this->password = $old_row->password;
         unset($this->_modified['password']);
     }
     if ($this->_new) {
         $this->registered_on = gmdate('Y-m-d H:i:s', time());
     }
     $query = $this->getTable()->getDatabase()->getQuery()->select('name')->where('id', '=', $this->users_group_id);
     $this->group_name = $this->getService('com://admin/users.database.table.groups')->select($query, KDatabase::FETCH_FIELD);
     // Set parameters.
     if (isset($this->_modified['params'])) {
         $params = new JParameter('');
         $params->bind($this->_data['params']);
         $this->params = $params->toString();
         if (!$this->_new && $this->_data['params'] == $old_row->params->toString()) {
             unset($this->_modified['params']);
         }
     }
     // Need to reverse the value of 'enabled', because the mapped column is 'block'.
     if ($this->_new || isset($this->_modified['enabled'])) {
         $this->enabled = $this->enabled ? 0 : 1;
     }
     if (!parent::save()) {
         return false;
     }
     // Syncronize ACL.
     if ($this->_status == KDatabase::STATUS_CREATED) {
         $aro = $this->getService('com://admin/groups.database.row.aro')->setData(array('section_value' => 'users', 'value' => $this->id, 'name' => $this->name));
         $aro->save();
         $this->getService('com://admin/groups.database.row.arosgroup')->setData(array('group_id' => $this->users_group_id, 'aro_id' => $aro->id))->save();
     } else {
         if (isset($this->_modified['name']) || isset($this->_modified['users_group_id'])) {
             $aro = $this->getService('com://admin/groups.database.table.aros')->select(array('value' => $this->id), KDatabase::FETCH_ROW);
             if (isset($this->_modified['name'])) {
                 $aro->name = $this->name;
                 $aro->save();
             }
             if (isset($this->_modified['users_group_id'])) {
                 $this->getService('com://admin/groups.database.table.arosgroups')->select(array('aro_id' => $aro->id), KDatabase::FETCH_ROW)->delete();
                 $this->getService('com://admin/groups.database.table.arosgroups')->select(null, KDatabase::FETCH_ROW)->setData(array('group_id' => $this->users_group_id, 'aro_id' => $aro->id))->save();
             }
         }
     }
     return true;
 }
开发者ID:raeldc,项目名称:nooku-server,代码行数:101,代码来源:user.php

示例13: save

 public function save()
 {
     // Validate name
     if ($this->isModified('name') && trim($this->name) == '') {
         $this->setStatus(Library\Database::STATUS_FAILED);
         $this->setStatusMessage(\JText::_('Please enter a name'));
         return false;
     }
     if ($this->isModified('email')) {
         // Validate E-mail
         if (!$this->getObject('lib:filter.email')->validate($this->email)) {
             $this->setStatus(Library\Database::STATUS_FAILED);
             $this->setStatusMessage(\JText::_('Please enter a valid E-mail address'));
             return false;
         }
         // Check if E-mail address is not already being used
         $query = $this->getObject('lib:database.query.select')->where('email = :email')->bind(array('email' => $this->email));
         if ($this->getObject('com:users.database.table.users')->count($query)) {
             $this->setStatus(Library\Database::STATUS_FAILED);
             $this->setStatusMessage(\JText::_('The provided E-mail address is already registered'));
             return false;
         }
     }
     // Check if the attached role exists
     if ($this->isModified('role_id') && $this->getRole()->isNew()) {
         $this->setStatus(Library\Database::STATUS_FAILED);
         $this->setStatusMessage('Invalid role');
         return false;
     }
     // Set parameters.
     if ($this->isModified('params')) {
         $params = new \JParameter('');
         $params->bind($this->_data['params']);
         $this->params = $params->toString();
         /*if(!$this->isNew() && $this->_data['params'] == $current->params->toString()) {
               unset($this->_modified['params']);
           }*/
     }
     if ($this->isModified('role_id')) {
         // Clear role cache
         $this->_role = null;
     }
     if (!$this->isNew()) {
         // Load the current user row for checks.
         $current = $this->getObject('com:users.database.table.users')->select($this->id, Library\Database::FETCH_ROW);
         // There must be at least one enabled super administrator
         if (($this->isModified('role_id') || $this->isModified('enabled') && !$this->enabled) && $current->role_id == 25) {
             $query = $this->getObject('lib:database.query.select')->where('enabled = :enabled')->where('users_role_id = :role_id')->bind(array('enabled' => 1, 'role_id' => 25));
             if ($this->getObject('com:users.database.table.users')->count($query) <= 1) {
                 $this->setStatus(Library\Database::STATUS_FAILED);
                 $this->setStatusMessage('There must be at least one enabled super administrator');
                 return false;
             }
         }
     }
     return parent::save();
 }
开发者ID:janssit,项目名称:nickys.janss.be,代码行数:57,代码来源:user.php

示例14: display

	public function display($viewName, $layout='default', $template=null, $params = array()) {
		$viewName = preg_replace( '/[^A-Z0-9_]/i', '', $viewName );
		$view = "KunenaView{$viewName}";
		$model = "KunenaModel{$viewName}";

		// load Kunena main language file so we can leverage language strings from it
		KunenaFactory::loadLanguage();

		require_once KPATH_SITE . '/views/common/view.html.php';
		require_once KPATH_SITE . '/models/common.php';

		if ( !class_exists( $view ) ) {
			$vpath = KPATH_SITE . '/views/'.$viewName.'/view.html.php';
			if (!is_file($vpath)) return;
			require_once $vpath;
		}
		if ( $viewName != 'common' && !class_exists( $model ) ) {
			$mpath = KPATH_SITE . '/models/'.$viewName.'.php';
			if (!is_file($mpath)) return;
			require_once $mpath;
		}

		$view = new $view ( array ('base_path' => KPATH_SITE ) );
		if (!($params instanceof JParameter)) {
			$parameters = new JParameter('');
			$parameters->bind($params);
		} else {
			$parameters = $params;
		}
		$parameters->set('layout', $layout);
		// Push the model into the view (as default).
		$model = new $model ();
		$model->initialize($parameters);
		$view->setModel ( $model, true );

		// Add template path
		$ktemplate = KunenaFactory::getTemplate();
		$templatepath = KPATH_SITE."/{$ktemplate->getPath()}/html/";
		$view->addTemplatePath($templatepath.$viewName);
		if ($parameters->get('templatepath')) $view->addTemplatePath($parameters->get('templatepath'));

		if ($viewName != 'common') {
			$view->common = new KunenaViewCommon ( array ('base_path' => KPATH_SITE ) );
			$view->common->addTemplatePath($templatepath.'common');
		}
		// Push document object into the view.
		$view->assignRef ( 'document', JFactory::getDocument() );

		// Render the view.
		$view->displayLayout ($layout, $template);
	}
开发者ID:rich20,项目名称:Kunena,代码行数:51,代码来源:forum.php

示例15: KunenaInstallerException

	function createMenuJ15($menu, $submenu) {
		jimport( 'joomla.utilities.string' );
		jimport( 'joomla.application.component.helper' );
		kimport('kunena.factory');

		$config = KunenaFactory::getConfig();

		$component_id = JComponentHelper::getComponent('com_kunena')->id;

		// First fix all broken menu items
		$query = "UPDATE #__menu SET componentid={$this->db->quote($component_id)} WHERE type = 'component' AND link LIKE '%option=com_kunena%'";
		$this->db->setQuery ( $query );
		$this->db->query ();
		if ($this->db->getErrorNum ())
			throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );

		// Find out if menu exists
		$query = "SELECT id FROM `#__menu_types` WHERE `menutype`='kunenamenu';";
		$this->db->setQuery ( $query );
		$moduleid = ( int ) $this->db->loadResult ();
		if ($this->db->getErrorNum ())
			throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );

		// Do not touch existing menu
		if ($moduleid) {
			return;
		}

		// Create new Joomla menu for Kunena
		if (! $moduleid) {
			// Create a menu type for the Kunena menu
			$query = "REPLACE INTO `#__menu_types` (`id`, `menutype`, `title`, `description`) VALUES
							($moduleid, 'kunenamenu', {$this->db->Quote( JText::_ ( 'COM_KUNENA_MENU_TITLE' ))} , {$this->db->Quote(JText::_ ( 'COM_KUNENA_MENU_TITLE_DESC' ))} )";
			$this->db->setQuery ( $query );
			$this->db->query ();
			if ($this->db->getErrorNum ())
				throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );

			// Now get the menu id again, we need it, in order to publish the menu module
			$query = "SELECT id FROM `#__menu_types` WHERE `menutype`='kunenamenu';";
			$this->db->setQuery ( $query );
			$moduleid = ( int ) $this->db->loadResult ();
			if ($this->db->getErrorNum ())
				throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
		}

		// Forum
		$query = "SELECT id FROM `#__menu` WHERE `link`={$this->db->quote($menu['link'])} AND `menutype`='kunenamenu';";
		$this->db->setQuery ( $query );
		$parentid = ( int ) $this->db->loadResult ();
		if ($this->db->getErrorNum ())
			throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
		if (! $parentid) {
			$params = new JParameter('');
			$params->bind($menu['params']);
			$query = "REPLACE INTO `#__menu` (`id`, `menutype`, `name`, `alias`, `link`, `type`, `published`, `parent`, `componentid`, `sublevel`, `ordering`, `checked_out`, `checked_out_time`, `pollid`, `browserNav`, `access`, `utaccess`, `params`, `lft`, `rgt`, `home`) VALUES
							($parentid, 'kunenamenu', {$this->db->quote($menu['name'])}, {$this->db->quote($menu['alias'])}, {$this->db->quote($menu['link'])}, 'component', 1, 0, $component_id, 0, 1, 0, '0000-00-00 00:00:00', 0, 0, {$menu['access']}, 0, {$this->db->quote($params->toString('INI'))}, 0, 0, 0);";
			$this->db->setQuery ( $query );
			$this->db->query ();
			if ($this->db->getErrorNum ())
				throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
			$parentid = ( int ) $this->_db->insertId ();
		}

		// Submenu (shown in Kunena)
		$defaultmenu = 0;
		$ordering = 0;
		foreach ($submenu as $menuitem) {
			$ordering++;
//			$query = "SELECT id FROM `#__menu` WHERE `link`={$this->db->quote($menuitem['link'])} AND `menutype`='kunenamenu';";
//			$this->db->setQuery ( $query );
//			$id = ( int ) $this->db->loadResult ();
//			if ($this->db->getErrorNum ())
//				throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
			$id = 0;
			if (! $id) {
				$params = new JParameter('');
				$params->bind($menuitem['params']);
				$query = "REPLACE INTO `#__menu` (`id`, `menutype`, `name`, `alias`, `link`, `type`, `published`, `parent`, `componentid`, `sublevel`, `ordering`, `checked_out`, `checked_out_time`, `pollid`, `browserNav`, `access`, `utaccess`, `params`, `lft`, `rgt`, `home`) VALUES
								($id, 'kunenamenu', {$this->db->quote($menuitem['name'])}, {$this->db->quote($menuitem['alias'])}, {$this->db->quote($menuitem['link'])},'component', 1, $parentid, $component_id, 1, $ordering, 0, '0000-00-00 00:00:00', 0, 0, {$menuitem['access']}, 0, {$this->db->quote($params->toString('INI'))}, 0, 0, 0);";
				$this->db->setQuery ( $query );
				$this->db->query ();
				if ($this->db->getErrorNum ())
					throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
				$id = ( int ) $this->_db->insertId ();
				if (!$defaultmenu || (isset($menuitem['default']) && $config->fbdefaultpage == $menuitem['default'])) {
					$defaultmenu = $id;
				}
			}
		}
		if ($defaultmenu) {
			$query = "UPDATE `#__menu` SET `link`={$this->db->quote($menu['link']."&defaultmenu=$defaultmenu")} WHERE id={$parentid}";
			$this->db->setQuery ( $query );
			$this->db->query ();
		if ($this->db->getErrorNum ())
			throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
		}

		$query = "SELECT id FROM `#__modules` WHERE `position`='kunena_menu';";
		$this->db->setQuery ( $query );
//.........这里部分代码省略.........
开发者ID:rich20,项目名称:Kunena,代码行数:101,代码来源:model.php


注:本文中的JParameter::bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。