Example #1
0
function levelLessShow($xml)
{
    echo '<li class="giftLocked"><div class="gift_img">';
    echo '<img src="../static/images/giftIcon/' . getAttr('icon', $xml) . '" class="giftIconImg" style="width: 90px; margin-left: 0px;"/></div>';
    echo '<div class="gift_name"><strong><span>' . getAttr('name', $xml) . '</span></strong></div>';
    echo '<div class="gift_action">' . getAttr('level', $xml) . '级后可赠送</div></li>';
}
Example #2
0
function levelLessShow($xml)
{
    echo '<li class="giftLocked"><div class="gift_img">';
    echo '<img src="giftIcon/' . getAttr('icon', $xml) . '" class="giftIconImg" />';
    echo '<div class="gift_name"><strong><span>' . getAttr('name', $xml) . '</span></strong></div>';
    echo '<div class="gift_action">Level: ' . getAttr('level', $xml) . '</div></li>';
}
Example #3
0
 public function save($key = null, $urlVar = null)
 {
     $saved = parent::save($key, $urlVar);
     // generate xml to User - Improved Profile plugin
     if ($saved) {
         $data = JRequest::getVar('jform', array(), 'array');
         // fix for magic quotes
         if (get_magic_quotes_gpc()) {
             $props = json_decode($data['props']);
             if ($props == null) {
                 foreach ($data as $key => $value) {
                     $data[$key] = stripslashes($value);
                 }
             }
         }
         $fields = json_decode($data['fields']);
         if ($data['state'] && isset($fields->page)) {
             function getAttr($obj, $name)
             {
                 $name = 'jform[elem_' . $name . ']';
                 return isset($obj->{$name}) ? $obj->{$name} : null;
             }
             $captcha = 0;
             foreach ($fields->page as $page) {
                 foreach ($page->elem as $elem) {
                     $type = getAttr($elem, 'type');
                     if ($type->value == 'captcha') {
                         $captcha = 1;
                     }
                 }
             }
             // init recaptcha
             $db = JFactory::getDBO();
             $db->setQuery("UPDATE #__extensions SET custom_data = " . ($captcha ? "'IALR'" : "''") . " WHERE name = 'plg_captcha_recaptcha'");
             $db->query();
         }
     }
     return $saved;
 }
Example #4
0
 function writeClass($xpath, $clNm, $section, $attrMap)
 {
     $items = $xpath->query("//s:*[@class='" . $clNm . "']");
     echo "\"" . $section . "\":[";
     foreach ($items as $r) {
         $nm = $r->nodeName;
         $itmID = getAttr($r, "id");
         echo "{\"type\":\"" . $nm . "\",";
         echo "\"id\":\"{$itmID}\",";
         if ($nm == 'text') {
             $tNd = $xpath->query("text()", $r->childNodes->item(0));
             $txt = $tNd->item(0)->nodeValue;
             $txt = mb_convert_encoding($txt, "Windows-1251", "UTF-8");
             echo "\"txt\":\"{$txt}\",";
         }
         if (!empty($attrMap)) {
             foreach ($attrMap as $svg => $json) {
                 $val = getAttr($r, $svg);
                 echo "\"{$json}\":\"{$val}\",";
             }
         }
         if ($nm == 'rect') {
             echo "\"x\":" . getAttr($r, 'x') . ",";
             echo "\"y\":" . getAttr($r, 'y') . ",";
             echo "\"h\":" . getAttr($r, 'height') . ",";
             echo "\"w\":" . getAttr($r, 'width') . ",";
         } elseif ($nm == 'path') {
             echo "\"d\":\"" . getAttr($r, 'd') . "\",";
         } elseif ($nm == 'text') {
             echo "\"x\":" . getAttr($r, 'x') . ",";
             echo "\"y\":" . getAttr($r, 'y') . ",";
         }
         echo "\"tr\":\"" . getAttr($r, 'transform') . "\"";
         echo "},";
     }
     echo "null]";
 }
Example #5
0
/**
 * Get an attribute $attr from $obj which can be either an assoc. array or an PHP object.
 * @param mixed $obj variable which can be either an assoc. array or an PHP object
 * @param string $attr attribute name
 * @param bool $recursive traverse recursively through $obj when we have an $attr with 'obj->subobj->...' path
 * @return mixed attribute value
 * @throws Exception
 */
function getAttr($obj, $attr, $recursive = false)
{
    if ($recursive) {
        $attrPath = explode('->', $attr);
        $attr = $attrPath[0];
        if (count($attrPath) > 1) {
            $attrNextLevel = implode('->', array_slice($attrPath, 1));
        } else {
            $attrNextLevel = null;
        }
    } else {
        $attrNextLevel = null;
    }
    if (is_array($obj)) {
        if (!isset($obj[$attr])) {
            return null;
        }
        if ($recursive && $attrNextLevel && (is_array($obj[$attr]) || is_object($obj[$attr]))) {
            return getAttr($obj[$attr], $attrNextLevel, true);
        } else {
            return $obj[$attr];
        }
    } else {
        if (is_object($obj)) {
            if (!isset($obj->{$attr})) {
                return null;
            }
            if ($recursive && $attrNextLevel && (is_array($obj->{$attr}) || is_object($obj->{$attr}))) {
                return getAttr($obj->{$attr}, $attrNextLevel, true);
            } else {
                return $obj->{$attr};
            }
        } else {
            throw new Exception('Must be either array or object: ' . $obj);
        }
    }
}
Example #6
0
 /**
 	 * @param	JForm	$form	The form to be altered.
 	 * @param	array	$data	The associated data for the form.
 	 *
 	 * @return	boolean
 	 * @since	1.6
 */
 function onContentPrepareForm($form, $data)
 {
     if (!$form instanceof JForm) {
         $this->_subject->setError('JERROR_NOT_A_FORM');
         return false;
     }
     // Check we are manipulating a valid form.
     $name = $form->getName();
     if (!in_array($name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'))) {
         return true;
     }
     $lang = JFactory::getLanguage();
     $lang->load('plg_user_profile', JPATH_ADMINISTRATOR);
     $lang->load('mod_improved_ajax_login');
     // Add the registration fields to the form.
     $db = JFactory::getDBO();
     $db->setQuery('SELECT fields FROM #__offlajn_forms WHERE id = 1');
     $res = $db->loadObject();
     $fields = json_decode($res->fields);
     function getAttr($obj, $name)
     {
         $name = 'jform[elem_' . $name . ']';
         return isset($obj->{$name}) ? $obj->{$name} : null;
     }
     $xml = '<form><fields name="improved"><fieldset name="improved" label="PLG_USER_PROFILE_SLIDER_LABEL"></fieldset></fields></form>';
     $profile = JFactory::getXML($xml, false);
     foreach ($fields->page as $page) {
         foreach ($page->elem as $elem) {
             $type = getAttr($elem, 'type');
             $name = getAttr($elem, 'name');
             if (!isset($type->profile) || $name->value == 'newsletter') {
                 continue;
             }
             $field = $profile->fields->fieldset->addChild('field');
             $field->addAttribute('name', $name->value ? $name->value : $name->placeholder);
             $field->addAttribute('id', 'ial-' . getAttr($elem, 'name')->value);
             $field->addAttribute('type', isset($type->defaultValue) ? $type->defaultValue : $type->value);
             $field->addAttribute('required', getAttr($elem, 'required')->checked ? 'true' : 'false');
             $label = getAttr($elem, 'label');
             if ($label) {
                 $field->addAttribute('label', JText::_($label->value ? $label->value : (@$label->defaultValue ? @$label->defaultValue : @$label->placeholder)));
             }
             $title = getAttr($elem, 'title');
             if ($label) {
                 $field->addAttribute('description', JText::_($title->value ? $title->value : @$title->defaultValue));
             }
             $error = getAttr($elem, 'error');
             if ($error) {
                 $field->addAttribute('message', JText::_($error->value ? $error->value : $error->defaultValue));
             }
             if ($type->value == 'checkbox') {
                 $field->addAttribute('value', 'on');
             }
             if ($type->value == 'select') {
                 $field['type'] = 'list';
                 $xml = str_replace(array('[', ']'), array('<', '>'), $options = getAttr($elem, 'select')->value);
                 $opts = JFactory::getXML("<select>{$xml}</select>", false);
                 foreach ($opts as $opt) {
                     $option = $field->addChild('option');
                     $option->addAttribute('value', $opt['value']);
                     $option[0] = (string) $opt;
                 }
             }
             $article = getAttr($elem, 'article');
             if ($article) {
                 $field->addAttribute('article', $article->value);
                 $option = $field->addChild('option');
                 $option->addAttribute('value', 'on');
                 $option[0] = 'JYES';
             }
         }
     }
     $form->load($profile, false);
     if ($name != 'com_users.registration') {
         // We only want the TOS in the registration form
         $form->removeField('tos', 'improved');
     }
     return true;
 }