/** * index for the image manager * @return string the fetched and constructed template */ function imanager_index($imgcat_id = NULL) { global $icmsTpl, $icmsConfig, $target, $type; if (!is_object(icms::$user)) { $groups = array(XOOPS_GROUP_ANONYMOUS); $admin = FALSE; } else { $groups =& icms::$user->getGroups(); $admin = (!icms::$user->isAdmin(1)) ? FALSE : TRUE; } $imgcat_handler = icms::handler('icms_image_category'); $criteriaRead = new icms_db_criteria_Compo(); if (is_array($groups) && !empty($groups)) { $criteriaTray = new icms_db_criteria_Compo(); foreach ($groups as $gid) { $criteriaTray->add(new icms_db_criteria_Item('gperm_groupid', $gid), 'OR'); } $criteriaRead->add($criteriaTray); $criteriaRead->add(new icms_db_criteria_Item('gperm_name', 'imgcat_read')); $criteriaRead->add(new icms_db_criteria_Item('gperm_modid', 1)); } $criteriaRead->add(new icms_db_criteria_Item('imgcat_display', 1)); $id = (!is_null($imgcat_id) ? $imgcat_id : 0); $criteriaRead->add(new icms_db_criteria_Item('imgcat_pid', $id)); $imagecategorys =& $imgcat_handler->getObjects($criteriaRead); $criteriaWrite = new icms_db_criteria_Compo(); if (is_array($groups) && !empty($groups)) { $criteriaWrite->add($criteriaTray); $criteriaWrite->add(new icms_db_criteria_Item('gperm_name', 'imgcat_write')); $criteriaWrite->add(new icms_db_criteria_Item('gperm_modid', 1)); } $criteriaWrite->add(new icms_db_criteria_Item('imgcat_display', 1)); $criteriaWrite->add(new icms_db_criteria_Item('imgcat_pid', $id)); $imagecategorysWrite =& $imgcat_handler->getObjects($criteriaWrite); $icmsTpl->assign('lang_imanager_title', _IMGMANAGER); $icmsTpl->assign('lang_imanager_catid', _MD_IMAGECATID); $icmsTpl->assign('lang_imanager_catname', _MD_IMAGECATNAME); $icmsTpl->assign('lang_imanager_catmsize', _MD_IMAGECATMSIZE); $icmsTpl->assign('lang_imanager_catmwidth', _MD_IMAGECATMWIDTH); $icmsTpl->assign('lang_imanager_catmheight', _MD_IMAGECATMHEIGHT); $icmsTpl->assign('lang_imanager_catstype', _MD_IMAGECATSTYPE); $icmsTpl->assign('lang_imanager_catdisp', _MD_IMAGECATDISP); $icmsTpl->assign('lang_imanager_catautoresize', _MD_IMAGECATATUORESIZE); $icmsTpl->assign('lang_imanager_catweight', _MD_IMAGECATWEIGHT); $icmsTpl->assign('lang_imanager_catsubs', _MD_IMAGECATSUBS); $icmsTpl->assign('lang_imanager_catqtde', _MD_IMAGECATQTDE); $icmsTpl->assign('lang_imanager_catoptions', _MD_IMAGECATOPTIONS); $icmsTpl->assign('lang_imanager_cat_edit', _EDIT); $icmsTpl->assign('lang_imanager_cat_del', _DELETE); $icmsTpl->assign('lang_imanager_cat_listimg', _LIST); $icmsTpl->assign('lang_imanager_cat_submit', _SUBMIT); $icmsTpl->assign('lang_imanager_cat_addnewcat', _MD_ADDIMGCATBTN); $icmsTpl->assign('lang_imanager_cat_addnewimg', _MD_ADDIMGBTN); $icmsTpl->assign('token', icms::$security->getTokenHTML()); $icmsTpl->assign('catcount', count($imagecategorys)); $icmsTpl->assign('writecatcount', count($imagecategorysWrite)); $icmsTpl->assign('target', $target); $icmsTpl->assign('type', $type); $icmsTpl->assign('isAdmin', $admin); $icmsTpl->assign('imagecategorys', $imagecategorys); $icmsTpl->assign('admnav', adminNav($imgcat_id)); $image_handler = icms::handler('icms_image'); $count = $msize = $subs = array(); $icmsTpl->assign('catcount', $catcount = count($imagecategorys)); for ($i = 0; $i < $catcount; $i++) { $msize[$i] = icms_convert_size($imagecategorys[$i]->getVar('imgcat_maxsize')); $count[$i] = $image_handler->getCount(new icms_db_criteria_Item('imgcat_id', $imagecategorys[$i]->getVar('imgcat_id'))); $criteriaRead = new icms_db_criteria_Compo(); if (is_array($groups) && !empty($groups)) { $criteriaTray = new icms_db_criteria_Compo(); foreach ($groups as $gid) { $criteriaTray->add(new icms_db_criteria_Item('gperm_groupid', $gid), 'OR'); } $criteriaRead->add($criteriaTray); $criteriaRead->add(new icms_db_criteria_Item('gperm_name', 'imgcat_read')); $criteriaRead->add(new icms_db_criteria_Item('gperm_modid', 1)); } $id = (!is_null($imgcat_id) ? $imgcat_id : 0); $criteriaRead->add(new icms_db_criteria_Item('imgcat_pid', $imagecategorys[$i]->getVar('imgcat_id'))); $subs[$i] = count($imgcat_handler->getObjects($criteriaRead)); } $scount = array(); foreach ($subs as $k=>$v) { $criteriaRead = new icms_db_criteria_Compo(); if (is_array($groups) && !empty($groups)) { $criteriaTray = new icms_db_criteria_Compo(); foreach ($groups as $gid) { $criteriaTray->add(new icms_db_criteria_Item('gperm_groupid', $gid), 'OR'); } $criteriaRead->add($criteriaTray); $criteriaRead->add(new icms_db_criteria_Item('gperm_name', 'imgcat_read')); $criteriaRead->add(new icms_db_criteria_Item('gperm_modid', 1)); } $id = (!is_null($imgcat_id) ? $imgcat_id : 0); $criteriaRead->add(new icms_db_criteria_Item('imgcat_pid', $imagecategorys[$k]->getVar('imgcat_id'))); $ssubs = $imgcat_handler->getObjects($criteriaRead); $sc = 0; foreach ($ssubs as $id=>$va) { $sc += $image_handler->getCount(new icms_db_criteria_Item('imgcat_id', $va->getVar('imgcat_id'))); } $scount[$k] = $sc; } $icmsTpl->assign('msize', $msize); $icmsTpl->assign('count', $count); $icmsTpl->assign('subs', $subs); $icmsTpl->assign('scount', $scount); if (!empty($catcount)) { $form = new icms_form_Theme(_ADDIMAGE, 'image_form', 'browser.php', 'post', TRUE); $form->setExtra('enctype="multipart/form-data"'); $form->addElement(new icms_form_elements_Text(_IMAGENAME, 'image_nicename', 50, 255), TRUE); $select = new icms_form_elements_Select(_IMAGECAT, 'imgcat_id'); $select->addOptionArray($imgcat_handler->getCategList($groups, 'imgcat_write')); $form->addElement($select, TRUE); $form->addElement(new icms_form_elements_File(_IMAGEFILE, 'image_file', 5000000)); $form->addElement(new icms_form_elements_Text(_IMGWEIGHT, 'image_weight', 3, 4, 0)); $form->addElement(new icms_form_elements_Radioyn(_IMGDISPLAY, 'image_display', 1, _YES, _NO)); $form->addElement(new icms_form_elements_Hidden('op', 'addfile')); $form->addElement(new icms_form_elements_Hidden('target', $target)); $form->addElement(new icms_form_elements_Hidden('type', $type)); $tray = new icms_form_elements_Tray('' , ''); $tray->addElement(new icms_form_elements_Button('', 'img_button', _SUBMIT, 'submit')); $btn = new icms_form_elements_Button('', 'reset', _CANCEL, 'button'); $btn->setExtra('onclick="document.getElementById(\'addimgform\').style.display = \'none\'; return FALSE;"'); $tray->addElement($btn); $form->addElement($tray); $icmsTpl->assign('addimgform', $form->render()); } $form = new icms_form_Theme(_MD_ADDIMGCAT, 'imagecat_form', 'browser.php', 'post', TRUE); $list =& $imgcat_handler->getCategList($groups, 'imgcat_write'); $sup = new icms_form_elements_Select(_MD_IMGCATPARENT, 'imgcat_pid', $id); $list[0] = '--------------------'; ksort($list); $sup->addOptionArray($list); $form->addElement($sup); $form->addElement(new icms_form_elements_Text(_MD_IMGCATNAME, 'imgcat_name', 50, 255), TRUE); $form->addElement(new icms_form_elements_select_Group(_MD_IMGCATRGRP, 'readgroup', TRUE, XOOPS_GROUP_ADMIN, 5, TRUE)); $form->addElement(new icms_form_elements_select_Group(_MD_IMGCATWGRP, 'writegroup', TRUE, XOOPS_GROUP_ADMIN, 5, TRUE)); $form->addElement(new icms_form_elements_Text(_IMGMAXSIZE, 'imgcat_maxsize', 10, 10, 50000)); $form->addElement(new icms_form_elements_Text(_IMGMAXWIDTH, 'imgcat_maxwidth', 3, 4, 120)); $form->addElement(new icms_form_elements_Text(_IMGMAXHEIGHT, 'imgcat_maxheight', 3, 4, 120)); $form->addElement(new icms_form_elements_Text(_MD_IMGCATWEIGHT, 'imgcat_weight', 3, 4, 0)); $form->addElement(new icms_form_elements_Radioyn(_MD_IMGCATDISPLAY, 'imgcat_display', 1, _YES, _NO)); $storetype = new icms_form_elements_Radio(_MD_IMGCATSTRTYPE, 'imgcat_storetype', 'file'); $storetype->setDescription('<span style="color:#ff0000;">' . _MD_STRTYOPENG . '</span>'); $storetype->addOptionArray(array('file' => sprintf(_MD_ASFILE, str_ireplace(ICMS_ROOT_PATH, "", ICMS_IMANAGER_FOLDER_PATH) . '/foldername'), 'db' => _MD_INDB)); $storetype->setExtra('onchange="actField(this.value, \'imgcat_foldername\');"'); $form->addElement($storetype); $fname = new icms_form_elements_Text(_MD_IMGCATFOLDERNAME, 'imgcat_foldername', 50, 255, ''); $fname->setDescription('<span style="color:#ff0000;">' . _MD_IMGCATFOLDERNAME_DESC . '<br />' . _MD_STRTYOPENG . '</span>'); $form->addElement($fname, TRUE); $form->addElement(new icms_form_elements_Hidden('op', 'addcat')); $form->addElement(new icms_form_elements_Hidden('target', $target)); $form->addElement(new icms_form_elements_Hidden('type', $type)); $tray1 = new icms_form_elements_Tray('' , ''); $tray1->addElement(new icms_form_elements_Button('', 'imgcat_button', _SUBMIT, 'submit')); $btn = new icms_form_elements_Button('', 'reset', _CANCEL, 'button'); $btn->setExtra('onclick="document.getElementById(\'addcatform\').style.display = \'none\'; return FALSE;"'); $tray1->addElement($btn); $form->addElement($tray1); $icmsTpl->assign('addcatform', $form->render()); return $icmsTpl->fetch(ICMS_MODULES_PATH . '/system/templates/admin/images/system_popup_imagemanager.html'); }
/** * Returns a {@link icms_form_Element} for editing the value of this field * * @param icms_member_user_Object $user {@link icms_member_user_Object} object to edit the value of * @param mod_profile_Profile $profile {@link mod_profile_Profile} object to edit the value of * * @return icms_form_Element */ public function getEditElement($user, $profile) { $value = in_array($this->getVar('field_name'), $this->getUserVars()) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e'); if ($value === null) { $value = $this->getVar('field_default'); } $caption = $this->getVar('field_title'); $caption = defined($caption) ? constant($caption) : $caption; $name = $this->getVar('field_name', 'e'); $options = unserialize($this->getVar('field_options', 'n')); if ($this->getVar('field_type') != "image" && is_array($options)) { asort($options); foreach (array_keys($options) as $key) { $optval = defined($options[$key]) ? constant($options[$key]) : $options[$key]; $optkey = defined($key) ? constant($key) : $key; unset($options[$key]); $options[$optkey] = $optval; } } switch ($this->getVar('field_type')) { case "autotext": $element = new icms_form_elements_Label($caption, $value); break; case "textarea": $element = new icms_form_elements_Textarea($caption, $name, $value, 4, 30); break; case "dhtml": $element = new icms_form_elements_Dhtmltextarea($caption, $name, $value, 10, 30); break; case "select": $element = new icms_form_elements_Select($caption, $name, $value); $element->addOptionArray($options); break; case "select_multi": $element = new icms_form_elements_Select($caption, $name, $value, 5, true); $element->addOptionArray($options); break; case "radio": $element = new icms_form_elements_Radio($caption, $name, $value); $element->addOptionArray($options); break; case "checkbox": $element = new icms_form_elements_Checkbox($caption, $name, $value); $element->addOptionArray($options); break; case "yesno": $element = new icms_form_elements_Radioyn($caption, $name, $value); break; case "group": $element = new icms_form_elements_select_Group($caption, $name, true, $value); break; case "group_multi": $element = new icms_form_elements_select_Group($caption, $name, true, $value, 5, true); break; case "language": $element = new icms_form_elements_select_Lang($caption, $name, $value); break; case "date": $element = new icms_form_elements_Date($caption, $name, 15, $value); break; case "longdate": $element = new icms_form_elements_Date($caption, $name, 15, str_replace("-", "/", $value)); break; case "datetime": $element = new icms_form_elements_Datetime($caption, $name, 15, $value); break; case "timezone": $element = new icms_form_elements_select_Timezone($caption, $name, $value); $element->setExtra("style='width: 280px;'"); break; case "rank": $element = new icms_form_elements_Select($caption, $name, $value); $ranks = icms_getModuleHandler("userrank", "system")->getList(icms_buildCriteria(array("rank_special" => 1))); $element->addOption(0, "--------------"); $element->addOptionArray($ranks); break; case "theme": $element = new icms_form_elements_Select($caption, $name, $value); $element->addOption("0", _MD_PROFILE_SITEDEFAULT); $handle = opendir(ICMS_THEME_PATH . '/'); $dirlist = array(); while (false !== ($file = readdir($handle))) { if (is_dir(ICMS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}\$/", $file) && strtolower($file) != 'cvs') { if (file_exists(ICMS_THEME_PATH . '/' . $file . '/theme.html') && in_array($file, $GLOBALS['icmsConfig']['theme_set_allowed'])) { $dirlist[$file] = $file; } } } closedir($handle); if (!empty($dirlist)) { asort($dirlist); $element->addOptionArray($dirlist); } break; case "image": $element = new icms_form_elements_File($caption, $name, $options['maxsize'] * 1024); if ($value != "") { $this->assignVar('field_description', ""); $element->setDescription($this->getOutputValue($user, $profile)); } break; case "openid": if ($icmsConfigAuth['auth_openid'] != 1) { break; } $element = new icms_form_elements_Text($caption, $name, 35, $this->getVar('field_maxlength'), $value); break; case "textbox": default: $element = new icms_form_elements_Text($caption, $name, 35, $this->getVar('field_maxlength'), $value); break; } if ($this->getVar('field_description') != '') { $element->setDescription($this->getVar('field_description')); } return $element; }