Пример #1
0
 /**
  * Compute different sources to get the columns that must be showed
  * 1) from form request 2) from session 3) from default value
  * @param sfForm $form The form with the 'fields' field defined
  * @return array of fields with check or uncheck or a list of visible fields separated by |
  */
 private function getVisibleColumns(sfForm $form)
 {
     $flds = array('category', 'collection', 'taxon', 'type', 'gtu', 'chrono', 'taxon_common_name', 'chrono_common_name', 'litho_common_name', 'lithologic_common_name', 'mineral_common_name', 'expedition', 'individual_type', 'litho', 'lithologic', 'mineral', 'sex', 'state', 'stage', 'social_status', 'rock_form', 'specimen_count', 'object_name');
     $flds = array_fill_keys($flds, 'uncheck');
     if ($form->isBound()) {
         $req_fields = $form->getValue('col_fields');
         if ($form->getValue('taxon_common_name') != '' || $form->getValue('taxon_name') != '') {
             $req_fields .= '|taxon|taxon_common_name';
         }
         if ($form->getValue('chrono_common_name') != '' || $form->getValue('chrono_name') != '') {
             $req_fields .= '|chrono|chrono_common_name';
         }
         if ($form->getValue('litho_common_name') != '' || $form->getValue('litho_name') != '') {
             $req_fields .= '|litho|litho_common_name';
         }
         if ($form->getValue('lithology_common_name') != '' || $form->getValue('lithology_name') != '') {
             $req_fields .= '|lithologic|lithology_common_name';
         }
         if ($form->getValue('mineral_common_name') != '' || $form->getValue('mineral_name') != '') {
             $req_fields .= '|mineral|mineral_common_name';
         }
         if ($form->getValue('search_type', 'zoo') == 'zoo') {
             if (!strpos($req_fields, 'common_name')) {
                 $req_fields .= '|taxon|taxon_common_name';
                 // add taxon by default if there is not other catalogue
             }
         } else {
             if (!strpos($req_fields, 'common_name')) {
                 $req_fields .= '|chrono|litho|lithologic|mineral';
             }
             // add cols by default if there is not other catalogue
         }
         $req_fields_array = explode('|', $req_fields);
     }
     if (empty($req_fields_array)) {
         $req_fields_array = explode('|', $form->getDefault('col_fields'));
     }
     foreach ($req_fields_array as $k => $val) {
         $flds[$val] = 'check';
     }
     $form->setDefault('col_fields', $req_fields);
     return $flds;
 }
color:#0000FF;
font-size:20px;
font-weight:bold;
margin:10px;
padding:10px;
text-align:center;
" id="plugin_user">
<span id="plugin_user_count"><?php 
echo $package->countUsers();
?>
</span><br /><span>users</span>
<p style="margin-top: 10px; text-align: center; font-size: 9px; color: #000;">
<?php 
if ($package->isAllowed($sf_user->getRawValue()->getMember(), 'countUser')) {
    $form = new sfForm();
    $_ajax_parameter = '"' . sfForm::getCSRFFieldName() . '=' . $form->getDefault(sfForm::getCSRFFieldName()) . '"';
    echo link_to_remote(__('I don\'t use this plugin'), array('url' => '@package_use?name=' . $package->name, 'complete' => 'updateUser(request)', '404' => 'alert("' . __('CSRF attack detected.') . '")', 'with' => $_ajax_parameter), array('id' => 'package_unuse_link', 'style' => 'display:' . ($package->isUser($sf_user->getMemberId()) ? 'inline' : 'none')));
    echo link_to_remote(__('I use this plugin'), array('url' => '@package_use?name=' . $package->name, 'complete' => 'updateUser(request)', '404' => 'alert("' . __('CSRF attack detected.') . '")', 'with' => $_ajax_parameter), array('id' => 'package_use_link', 'style' => 'display:' . (!$package->isUser($sf_user->getMemberId()) ? 'inline' : 'none')));
} else {
    echo __('Please login to vote for this plugin');
}
?>
</p>
</div>
<?php 
echo javascript_tag('
function updateUser(ajax)
{
  var json = ajax.responseJSON;

  Element.update("plugin_user_count", json[0]);
Пример #3
0
 /**
  * Compute different sources to get the columns that must be showed
  * 1) from form request 2) from session 3) from default value
  * @param sfBasicSecurityUser $user the user
  * @param sfForm $form The filter form with the 'col_fields' field defined
  * @param bool $as_string specify if you want the return to be a string (concat of visible cols)
  * @return array of fields with check or uncheck or a list of visible fields separated by |
  */
 private function getVisibleColumns(sfBasicSecurityUser $user, sfForm $form, $as_string = false)
 {
     $flds = array('category', 'collection', 'taxon', 'type', 'gtu', 'codes', 'chrono', 'ig', 'acquisition_category', 'litho', 'lithologic', 'mineral', 'expedition', 'type', 'individual_type', 'sex', 'state', 'stage', 'social_status', 'rock_form', 'individual_count', 'part', 'object_name', 'part_status', 'building', 'floor', 'room', 'row', 'col', 'shelf', 'container', 'container_type', 'container_storage', 'sub_container', 'sub_container_type', 'sub_container_storage', 'specimen_count', 'part_codes', 'loans');
     $flds = array_fill_keys($flds, 'uncheck');
     if ($form->isBound() && $form->getValue('col_fields') != "") {
         $req_fields = $form->getValue('col_fields');
         $req_fields_array = explode('|', $req_fields);
     } else {
         $req_fields_array = $user->fetchVisibleCols();
     }
     if (empty($req_fields_array)) {
         $req_fields_array = explode('|', $form->getDefault('col_fields'));
     }
     if ($as_string) {
         return implode('|', $req_fields_array);
     }
     foreach ($req_fields_array as $k => $val) {
         $flds[$val] = 'check';
     }
     return $flds;
 }
Пример #4
0
function js_form_fields(sfForm $form)
{
    $fieldSc = $form->getFormFieldSchema();
    $loginFormItems = '';
    $widget = $fieldSc->getWidget();
    $validatorSchema = $form->getValidatorSchema();
    foreach ($widget->getFields() as $key => $object) {
        // echo($key);
        $label = $fieldSc->offsetGet($key)->renderLabelName();
        $type = $object->getOption('type');
        if ($type == 'text') {
            $type = 'textfield';
        }
        $name = $widget->generateName($key);
        $allowBlank = 'true';
        $extraItem = '';
        if ($validatorSchema[$key] instanceof sfValidatorCSRFToken) {
            $csrfToken = $form->getDefault($key);
            $extraItem = ",value:'" . $csrfToken . "'";
        }
        if (isset($validatorSchema[$key]) and $validatorSchema[$key]->getOption('required') == true) {
            $allowBlank = 'false';
        }
        $loginFormItems[] = "{id:'" . $key . "',fieldLabel: '" . $label . "',name: '" . $name . "',inputType:'" . $type . "',allowBlank:" . $allowBlank . $extraItem . "}\n\t\t";
    }
    // die();
    $loginFormItems = implode(",", $loginFormItems);
    // echo($loginFormItems);
    // echo("<script>alert('oi');</script>");
    return $loginFormItems;
}