Exemple #1
0
function echo_widgetclass_form($params, $phase = '', $widget_group = '')
{
    global $ADMIN_PATH, $db, $nc_core;
    $params = (array) $params;
    $nc_core = nc_Core::get_object();
    $db = $nc_core->db;
    if (get_fs()) {
        $widget_editor = new nc_widget_editor($nc_core->WIDGET_TEMPLATE_FOLDER, $nc_core->db);
        $widget_editor->load($params['Widget_Class_ID'], null, $params['File_Hash']);
    }
    echo "<form method='post' id='nc_widgetclass_form' action='index.php'>";
    if (get_fs() && $phase != 3) {
        $widget_absolute_path = $widget_editor->get_absolute_path();
        $widget_filemanager_link = $nc_core->SUB_FOLDER . $nc_core->HTTP_ROOT_PATH . "modules/filemanager/admin.php?page=manager&phase=1&dir=" . $nc_core->SUB_FOLDER . $nc_core->HTTP_TEMPLATE_PATH . 'widget' . $widget_editor->get_relative_path();
        ?>
        <br />
        <div><?php 
        echo sprintf(CONTROL_WIDGETCLASS_FILES_PATH, $widget_filemanager_link, $widget_absolute_path);
        ?>
</div>
        <br />
	<?php 
    }
    echo "<input type='hidden' name='fs' value='" . get_fs() . "' /><fieldset>" . "" . WIDGET_ADD_NAME . ":<br />" . nc_admin_input_simple('Name', $params['Name'], 50) . "<br /><br />" . "" . WIDGET_ADD_KEYWORD . ":<br />" . nc_admin_input_simple('Keyword', $params['Keyword'], 50) . "<br /><br />";
    $widgetCategory = $db->get_col("SELECT DISTINCT `Category` FROM `Widget_Class`");
    echo CONTROL_USER_GROUP . ":<br /><select name='Category' style='width:auto;'>\n";
    foreach ($widgetCategory as $wc) {
        if ($params['Category'] == $wc || $widget_group == md5($wc)) {
            echo "\t<option value='" . $wc . "' selected='selected'>" . $wc . "</option>\n";
        } else {
            echo "\t<option value='" . $wc . "'>" . $wc . "</option>\n";
        }
    }
    echo "</select>&nbsp;&nbsp;&nbsp;" . "" . WIDGET_ADD_NEWGROUP . "&nbsp;&nbsp;&nbsp;" . nc_admin_input_simple('Category_New', null, 25, '', "maxlength='64'") . "</fieldset>" . "<table border='0' cellpadding='6' cellspacing='0' width='100%' ><tr style='display: none;'><td colspan='2'>" . "<div id='DescriptionOn' style='display: none'>" . "<p style='cursor: pointer;' onclick='document.getElementById(\"DescriptionOn\").style.display=\"none\";document.getElementById(\"DescriptionOff\").style.display=\"\";'> &#x25BC; " . WIDGET_ADD_DESCRIPTION . ":</p>" . "<br />" . nc_admin_textarea_simple('Description', $params['Description'], '', 8, 60, "id='Description'") . "</div></td></tr></table><br />" . "<legend>" . WIDGET_ADD_OBJECTVIEW . "</legend>" . "<table border='0' cellpadding='6' cellspacing='0' width='100%' >" . "<tr>" . "<td>" . nc_admin_textarea_resize('Template', $params['Template'], "" . WIDGET_ADD_PAGEBODY . ":", 10, 60, 'PageBody') . "</td>" . "</tr>" . "</table>" . "<br />" . "<legend>" . WIDGET_ADD_DOPL . "</legend>" . "<table border='0' cellpadding='0' cellspacing='0' width='100%' >" . "<tr>" . "<td colspan='2'>" . "<font>" . nc_admin_checkbox_simple('InDevelop', 1, WIDGET_ADD_DEVELOP, $params['InDevelop']) . "</td>" . "</tr>" . "<tr>" . "<td colspan='2'>" . "<font>" . nc_admin_checkbox_simple('WidgetDisallow', 1, WIDGET_ADD_DISALLOW, $params['WidgetDisallow']) . "</td>" . "</tr>" . "<tr>" . "<td colspan='2'>" . "<font>" . nc_admin_checkbox_simple('IsStatic', 1, WIDGET_IS_STATIC, isset($params['IsStatic']) ? $params['IsStatic'] : 1) . "</td>" . "</tr>" . "<tr>" . "<td colspan='2'>" . "" . WIDGET_ADD_UPDATE . ":<br />" . nc_admin_input_simple('Update', $params['Update'], 5) . "\n        <br />" . "</td>" . "</tr>" . "<tr>" . "<td colspan='2'>" . nc_admin_textarea_resize('Settings', $params['Settings'], "<br>" . WIDGET_ADD_SYSTEM . ":", 8, 60) . "</td>" . "</tr>" . ($phase == 30 ? "<tr><td colspan='2'><a href='" . $nc_core->SUB_FOLDER . $nc_core->HTTP_ROOT_PATH . "action.php?ctrl=admin.backup&amp;action=export_run&amp;raw=1&amp;type=widget_class&amp;id=" . $params['Widget_Class_ID'] . "&amp;" . $nc_core->token->get_url() . "'>" . WIDGET_LIST_EXPORT . "</a></td></tr>" : "") . "</table>";
    echo_remind_script();
}
Exemple #2
0
 /**
  * Изменение существующего виджета-компонента
  * @param mixed номер виджет-компонента или его keyword
  * @param array поля виджет-компонента
  * @return bool
  */
 public function edit_widgetclass($id, $params)
 {
     global $AUTH_USER_ID;
     $nc_core = $this->core;
     $db = $nc_core->db;
     if (!$this->widgetclasses_loaded) {
         $this->load();
     }
     $File_Mode = $this->widgetclasses[$id]['File_Mode'];
     if ($File_Mode) {
         $widget_editor = new nc_widget_editor($nc_core->WIDGET_TEMPLATE_FOLDER, $db);
         $widget_editor->load($id);
         $widget_editor->save_fields(null, true);
         $fs_params = $params;
         $params['AddForm'] = $params['EditForm'] = $params['AfterSaveAction'] = $params['BeforeSaveAction'] = '';
     }
     foreach ($params as $p => $value) {
         $query[] = "`" . $p . "`='" . $this->core->db->escape(addslashes($params[$p])) . "'";
     }
     $this->core->event->execute('editWidgetClassPrep', $this->get_id($id));
     $query = "UPDATE `Widget_Class` SET " . implode(',', $query) . $this->get_where($id) . "";
     $this->assistant('edit', array($id, $File_Mode ? $fs_params : $params));
     $db->query($query);
     $this->core->event->execute('editWidgetClass', $this->get_id($id));
     if (!$this->widgets_loaded) {
         $this->load('widgets');
     }
     foreach ($this->widgets as $w) {
         if ($w['Widget_Class_ID'] == $id) {
             $this->generate(intval($w['Widget_Class_ID']), '', 1, intval($w['Widget_ID']));
         }
     }
     return true;
 }