How to use hasChildren method of template class

Best Atoum code snippet using template.hasChildren

dev_json.php

Source:dev_json.php Github

copy

Full Screen

...131 WHERE `Template_ID` = '" . $node_id . "'132 ORDER BY `Priority`, `Template_ID`", ARRAY_A);133 if (!empty($templates)):134 foreach ((array)$templates as $template) {135 $hasChildren = $db->get_var("SELECT COUNT(*) FROM `Template` WHERE `Parent_Template_ID` = '" . $template['Template_ID'] . "'");136 $ret[] = "template-" . $template['Template_ID'];137 $node_id = $template['Parent_Template_ID'];138 }139 else:140 $node_id = false;141 endif;142 }143 if (is_array($ret)):144 $ret = array_reverse($ret);145 array_pop($ret);146 print "while(1);" . nc_array_json($ret);147 endif;148 exit;149}150if ($_GET['action'] == 'get_path' && ($node_type == 'systemclass' || $node_type == 'systemfield') && $node_id) {151 if ($node_type == 'systemfield') {152 $row = $db->get_var("SELECT `System_Table_ID` FROM `Field` WHERE `Field_ID` = '" . $node_id . "'");153 $ret[] = "systemclass-" . $row['System_Table_ID'];154 }155 $ret = array_reverse($ret);156 print "while(1);" . nc_array_json($ret);157 exit;158}159$ret = array();160$ret_dev = array();161$ret_groups = array();162$ret_widgetgroups = array();163$ret_classes = array();164$ret_widgetclasses = array();165$ret_class_group = array();166$ret_class_templates = array();167$ret_fields = array();168$ret_widgetfields = array();169$ret_classificators = array();170$ret_system_class = array();171$ret_system_fields = array();172$ret_templates = array();173// Строим дерево шаблонов174if ($node_type == 'root') {175 exit;176 //For each buttons make checking - access or no177 $classes_buttons[] = array(178 "image" => "icon_class_import",179 "label" => CONTROL_CLASS_IMPORT,180 "href" => "dataclass.import()"181 );182 $classes_buttons[] = array(183 "image" => "icon_class_add",184 "label" => CONTROL_CLASS_ADD,185 "href" => "dataclass.add()"186 );187 $widgetclasses_buttons[] = array(188 "image" => "icon_widgetclass_import",189 "label" => CONTROL_WIDGETCLASS_IMPORT,190 "href" => "widgetclass.import()"191 );192 $widgetclasses_buttons[] = array(193 "image" => "icon_widgetclass_add",194 "label" => CONTROL_WIDGETCLASS_ADD,195 "href" => "widgetclass.add()"196 );197 // Menu class198 if ($perm->isSupervisor() || $perm->isGuest()) {199 $ret_dev[] = array("nodeId" => "dataclass.list",200 "name" => SECTION_INDEX_DEV_CLASSES,201 "href" => "#dataclass.list",202 "image" => 'icon_classes',203 "hasChildren" => true,204 "dragEnabled" => false);205 }206 // Menu system tables207 if ($perm->isSupervisor() || $perm->isGuest()) {208 $ret_dev[] = array("nodeId" => "systemclass.list",209 "name" => SECTION_SECTIONS_OPTIONS_SYSTEM,210 "href" => "#systemclass.list",211 "sprite" => 'dev-system-tables' . ($File_Mode ? '' : '-v4'),212 "hasChildren" => true,213 "dragEnabled" => false);214 }215 // Menu template216 if ($perm->isSupervisor() || $perm->isGuest()) {217 $templates_buttons[] = array(218 "image" => "nc-icon nc--dev-templates-add nc--hovered",219 "label" => CONTROL_TEMPLATE_TEPL_CREATE,220 "href" => "template.add(0)"221 );222 $ret_dev[] = array(223 "nodeId" => "templates",224 "name" => SECTION_INDEX_DEV_TEMPLATES,225 "href" => "#template.list",226 "image" => 'dev-templates' . ($File_Mode ? '' : '-v4'),227 "hasChildren" => true,228 "dragEnabled" => false229 );230 }231 // Menu widget-class232 if ($perm->isSupervisor() || $perm->isGuest()) {233 $ret_dev[] = array("nodeId" => "widgetclass.list",234 "name" => SECTION_INDEX_DEV_WIDGET,235 "href" => "#widgetclass.list",236 "image" => 'icon_widgetclasses',237 "hasChildren" => true,238 "dragEnabled" => false);239 }240 // Menu classificator241 if ($perm->isAccess(NC_PERM_CLASSIFICATOR, NC_PERM_ACTION_LIST, 0, 0)) {242 if ($perm->isAccess(NC_PERM_CLASSIFICATOR, NC_PERM_ACTION_ADD, 0, 0)) {243 $classificators_buttons[] = array(244 "image" => "icon_classificator_import",245 "label" => CLASSIFICATORS_IMPORT_HEADER,246 "href" => "classificator.import()"247 );248 $classificators_buttons[] = array(249 "image" => "icon_classificator_add",250 "label" => CONTENT_CLASSIFICATORS_ADDLIST,251 "href" => "classificator.add()"252 );253 }254 $ret_dev[] = array(255 "nodeId" => "classificator.list",256 "name" => SECTION_CONTROL_CONTENT_CLASSIFICATOR,257 "href" => "#classificator.list",258 "image" => 'icon_classificators',259 "hasChildren" => true,260 "dragEnabled" => false261 );262 }263} // Дерево шаблонов данных264elseif ($node_type == 'dataclass.list') {265 // Выборка групп шаблонов266 $SQL = "SELECT `Class_Group`,267 MD5(`Class_Group`) AS `Class_Group_md5`268 FROM `Class`269 WHERE `System_Table_ID` = 0270 AND `ClassTemplate` = 0271 AND `File_Mode` = $File_Mode272 GROUP BY `Class_Group`273 ORDER BY `Class_Group`";274 $class_groups = $db->get_results($SQL, ARRAY_A);275 foreach ((array)$class_groups as $class_group) {276 $classgroup_buttons = array();277 $classgroup_buttons[] = nc_get_array_2json_button(278 CONTROL_CLASS_ADD,279 "dataclass$fs_suffix.add(" . $class_group['Class_Group_md5'] . ")",280 "nc-icon nc--dev-components-add nc--hovered"281 );282 $ret_groups[] = array(283 "nodeId" => "group-" . $class_group['Class_Group_md5'],284 "name" => $class_group["Class_Group"] ? $class_group["Class_Group"] : CONTROL_CLASS_CLASS_NO_GROUP,285 "href" => "#classgroup.edit(" . $class_group['Class_Group_md5'] . ")",286 "sprite" => 'dev-components' . ($File_Mode ? '' : '-v4'),287 "acceptDropFn" => "treeClassAcceptDrop",288 "onDropFn" => "treeClassOnDrop",289 "hasChildren" => true,290 "dragEnabled" => true,291 "buttons" => $classgroup_buttons292 );293 }294} elseif ($node_type == 'group' && $node_id) {295 // Выборка шаблонов определенной группы296 $classes = $db->get_results("297 SELECT `Class_ID`,298 `Class_Name`,299 `ClassTemplate`300 FROM `Class`301 WHERE MD5(`Class_Group`) = '" . $node_id . "'302 AND `File_Mode` = " . +$_REQUEST['fs'] . "303 AND `System_Table_ID` = 0304 ORDER BY `Class_Group`,305 `Priority`, `Class_ID`", ARRAY_A);306 foreach ((array)$classes as $class) {307 // skip component templates308 if ($class['ClassTemplate']) continue;309 // count component fields310 $hasChildren = $db->get_var("SELECT COUNT(`Field_ID`) FROM `Field`311 WHERE `Class_ID` = '" . $class['Class_ID'] . "'");312 // count component templates313 if (!$hasChildren) {314 $hasChildren = $db->get_var("SELECT COUNT(`Class_ID`) FROM `Class`315 WHERE `ClassTemplate` = '" . $class['Class_ID'] . "'");316 }317 $class_buttons = array();318 $class_buttons[] = nc_get_array_2json_button(319 CONTROL_FIELD_LIST_ADD,320 "field$fs_suffix.add(" . $class['Class_ID'] . ")",321 "nc-icon nc--file-add nc--hovered");322 $class_buttons[] = nc_get_array_2json_button(323 CONTROL_CLASS_DELETE,324 "dataclass$fs_suffix.delete(" . $class['Class_ID'] . ")",325 "nc-icon nc--remove nc--hovered");326 $ret_classes[] = array(327 "nodeId" => "dataclass-" . $class['Class_ID'],328 "name" => $class["Class_ID"] . ". " . $class["Class_Name"],329 "href" => "#dataclass.edit(" . $class['Class_ID'] . ")",330 "sprite" => 'dev-components' . ($File_Mode ? '' : '-v4'),331 "acceptDropFn" => "treeClassAcceptDrop",332 "onDropFn" => "treeClassOnDrop",333 "hasChildren" => $hasChildren,334 "dragEnabled" => true,335 "buttons" => $class_buttons336 );337 }338} elseif ($node_type == 'dataclass' && $node_id) {339 // Выборка полей определенного шаблона340 $fields = $db->get_results("SELECT `Field_ID`, `Field_Name`, `TypeOfData_ID`, `Description`, `NotNull` FROM `Field`341 WHERE `Class_ID` = '" . $node_id . "' AND `System_Table_ID` = 0342 ORDER BY `Priority`", ARRAY_A);343 foreach ((array)$fields as $field) {344 $field_buttons = array();345 $field_buttons[] = nc_get_array_2json_button(346 CONTROL_FIELD_LIST_DELETE,347 "field$fs_suffix.delete(" . $node_id . "," . $field[Field_ID] . ")",348 "nc-icon nc--remove nc--hovered");349 $ret_fields[] = array(350 "nodeId" => "field-" . $field['Field_ID'],351 "name" => $field["Field_ID"] . ". " . $field["Field_Name"],352 "title" => $field["Description"],353 "href" => "#field.edit(" . $field['Field_ID'] . ")",354 "sprite" => $field_types[$field["TypeOfData_ID"]] . ($field['NotNull'] ? ' nc--required' : ''),355 "acceptDropFn" => "treeFieldAcceptDrop",356 "onDropFn" => "treeFieldOnDrop",357 "hasChildren" => false,358 "dragEnabled" => true,359 "buttons" => $field_buttons360 );361 }362 $hasTemplates = $db->get_var("SELECT COUNT(`Class_ID`) FROM `Class` WHERE `ClassTemplate` = '" . $node_id . "'");363 if ($hasTemplates) {364 $class_template_buttons = array();365 $class_template_buttons[] = nc_get_array_2json_button(366 CONTROL_CLASS_CLASS_TEMPLATE_ADD,367 "classtemplate$fs_suffix.add(" . $node_id . ")",368 "nc-icon nc--file-add nc--hovered");369 $ret_class_templates[] = array(370 "nodeId" => "classtemplates-" . $node_id,371 "name" => CONTROL_CLASS_CLASS_TEMPLATES,372 "href" => "#classtemplates.edit(" . $node_id . ")",373 "sprite" => 'dev-templates' . ($File_Mode ? '' : '-v4'),374 "acceptDropFn" => "treeClassAcceptDrop",375 "onDropFn" => "treeClassOnDrop",376 "hasChildren" => $hasTemplates,377 "dragEnabled" => false,378 "buttons" => $class_template_buttons);379 }380} // Список шаблонов компонента381elseif ($node_type == 'classtemplates' && $node_id) {382 // get component templates383 $class_templates = $db->get_results("SELECT `Class_ID`, `Class_Name` FROM `Class`384 WHERE `ClassTemplate` = '" . $node_id . "'", ARRAY_A);385 foreach ((array)$class_templates as $class_template) {386 $class_templates_buttons = array();387 $class_templates_buttons[] = nc_get_array_2json_button(388 CONTROL_CLASS_DELETE,389 "classtemplate$fs_suffix.delete(" . $class_template['Class_ID'] . ")",390 "nc-icon nc--remove nc--hovered");391 $ret_class_templates[] = array(392 "nodeId" => "classtemplate-" . $class_template['Class_ID'],393 "name" => $class_template["Class_ID"] . ". " . $class_template["Class_Name"],394 "href" => "#classtemplate.edit(" . $class_template['Class_ID'] . ")",395 "sprite" => 'dev-templates' . ($File_Mode ? '' : '-v4'),396 "acceptDropFn" => "treeFieldAcceptDrop",397 "onDropFn" => "treeFieldOnDrop",398 "hasChildren" => false,399 "dragEnabled" => false,400 "buttons" => $class_templates_buttons401 );402 }403} // Дерево системных таблиц404elseif ($node_type == 'systemclass.list') {405 // Выборка системных таблиц406 $system_classes = $db->get_results("SELECT a.`System_Table_ID`, a.`System_Table_Rus_Name`, b.`Class_ID`,407 IF(b.`AddTemplate` <> '' OR b.`AddCond` <> '' OR b.`AddActionTemplate` <> '', 1, 0) AS IsAdd,408 IF(b.`EditTemplate` <> '' OR b.`EditCond` <> '' OR b.`EditActionTemplate` <> '' OR b.`CheckActionTemplate` <> '' OR b.`DeleteActionTemplate` <> '', 1, 0) AS IsEdit,409 IF(b.`SearchTemplate` <> '' OR b.`FullSearchTemplate` <> '', 1, 0) AS IsSearch,410 IF(b.`SubscribeTemplate` <> '' OR b.`SubscribeCond` <> '', 1, 0) AS IsSubscribe411 FROM `System_Table` AS a412 LEFT JOIN `Class` AS b ON (a.`System_Table_ID` = b.`System_Table_ID` AND b.ClassTemplate = 0 )413 " . ($nc_core->modules->get_by_keyword('auth', 0) ? "WHERE IF(b.`System_Table_ID` = 3, (b.`File_Mode` = " . +$_REQUEST['fs'] . ") , 1)" : "") .414 "GROUP BY a.`System_Table_ID` ORDER BY a.`System_Table_ID`", ARRAY_A);415 foreach ((array)$system_classes as $system_class) {416 if (!+$_REQUEST['fs'] && $system_class["System_Table_ID"] != 3) {417 continue;418 }419 $hasChildren = $db->get_var("SELECT COUNT(`Field_ID`) FROM `Field`420 WHERE `System_Table_ID` = '" . $system_class['System_Table_ID'] . "'");421 $system_class_buttons = array();422 $system_class_buttons[] = nc_get_array_2json_button(423 CONTROL_FIELD_LIST_ADD,424 "systemfield$fs_suffix.add(" . $system_class['System_Table_ID'] . ")",425 "nc-icon nc--file-add nc--hovered");426 if ($system_class["Class_ID"] && $nc_core->modules->get_by_keyword('auth', 0)) {427 $href = "#systemclass.edit(" . $system_class['System_Table_ID'] . ")";428 } else {429 $href = "#systemclass.fields(" . $system_class['System_Table_ID'] . ")";430 }431 $ret_system_class[] = array(432 "nodeId" => "systemclass-" . $system_class['System_Table_ID'],433 "name" => $system_class["System_Table_ID"] . ". " . constant($system_class["System_Table_Rus_Name"]),434 "href" => $href,435 "sprite" => 'dev-system-tables' . ($File_Mode ? '' : '-v4'),436 "hasChildren" => $hasChildren,437 "dragEnabled" => false,438 "buttons" => $system_class_buttons439 );440 }441} elseif ($node_type == 'systemclass' && $node_id) {442 // Выборка полей определенного шаблона443 $system_fields = $db->get_results("SELECT field.`Field_ID`, field.`Field_Name`, field.`TypeOfData_ID` FROM `Field` AS field444 LEFT JOIN `Classificator_TypeOfData` AS type ON type.`TypeOfData_ID` = field.`TypeOfData_ID`445 WHERE field.`System_Table_ID` = '" . $node_id . "'446 ORDER BY field.`Priority`", ARRAY_A);447 foreach ((array)$system_fields as $system_field) {448 if ($system_field["TypeOfData_ID"] == 11 && $node_id != 3 && !($nc_core->modules->get_by_keyword('auth') && nc_auth_openid_possibility()))449 continue;450 $system_field_buttons = array();451 $system_field_buttons[] = nc_get_array_2json_button(452 CONTROL_FIELD_LIST_DELETE,453 "systemfield$fs_suffix.delete(" . $node_id . "," . $system_field['Field_ID'] . ")",454 "nc-icon nc--remove nc--hovered");455 $ret_system_fields[] = array(456 "nodeId" => "systemfield-" . $system_field['Field_ID'],457 "name" => $system_field["Field_ID"] . ". " . $system_field["Field_Name"],458 "href" => "#systemfield.edit(" . $system_field['Field_ID'] . ")",459 "sprite" => $field_types[$system_field["TypeOfData_ID"]],460 "acceptDropFn" => "treeSystemFieldAcceptDrop",461 "onDropFn" => "treeSystemFieldOnDrop",462 "hasChildren" => false,463 "dragEnabled" => true,464 "buttons" => $system_field_buttons465 );466 }467 // count component templates468 $hasTemplates = 0;469 if ($node_id == 3 && $nc_core->modules->get_by_keyword('auth')) {470 $hasTemplates = $db->get_var("SELECT COUNT(`Class_ID`) FROM `Class` WHERE `ClassTemplate` > 0 AND `System_Table_ID` = 3 AND File_Mode = " . +$_REQUEST['fs']);471 $user_class_id = $db->get_var("SELECT `Class_ID` FROM `Class` WHERE `ClassTemplate` = 0 AND `System_Table_ID` = 3 AND File_Mode = " . +$_REQUEST['fs']);472 }473 if ($hasTemplates) {474 $class_template_buttons = array();475 $class_template_buttons[] = nc_get_array_2json_button(476 CONTROL_CLASS_CLASS_TEMPLATE_ADD,477 "classtemplate$fs_suffix.add(" . $user_class_id . ")",478 "nc-icon nc--file-add nc--hovered");479 $ret_class_templates[] = array(480 "nodeId" => "classtemplates-" . $user_class_id,481 "name" => CONTROL_CLASS_CLASS_TEMPLATES,482 "href" => "#classtemplates.edit(" . $user_class_id . ")",483 "sprite" => 'dev-templates' . ($File_Mode ? '' : '-v4'),484 "acceptDropFn" => "treeClassAcceptDrop",485 "onDropFn" => "treeClassOnDrop",486 "hasChildren" => $hasTemplates,487 "dragEnabled" => false,488 "buttons" => $class_template_buttons489 );490 }491} // Дерево макетов492elseif (($node_type == 'template' && $node_id) || ($node_type == 'templates')) {493 // Получение дерева макетов494 if (!$node_id) $node_id = 0;495 $tamplate_table = nc_db_table::make('Template');496 $templates = $tamplate_table->select('`Template_ID`, `Description`')497 ->where('Parent_Template_ID', $node_id)->where('File_Mode', $File_Mode)498 ->order_by('Priority')->order_by('Template_ID')499 ->index_by_id()->get_result();500 $childrens_count = $tamplate_table->select('COUNT(*) as total, Parent_Template_ID')501 ->where_in('Parent_Template_ID', array_keys($templates))502 ->group_by('Parent_Template_ID')503 ->get_list('Parent_Template_ID', 'total');504 // Представления макета дизайна505 if ($File_Mode && $node_id) {506 $is_root_template = !$tamplate_table->where_id($node_id)->get_value('Parent_Template_ID');507 if ($is_root_template) {508 $ret_templates[] = array(509 "nodeId" => "template_partials-{$node_id}",510 "name" => CONTROL_TEMPLATE_PARTIALS,511 "href" => "#template.partials_list({$node_id})",512 "sprite" => 'dev-com-templates',513 "hasChildren" => (bool)$nc_core->template->has_partial($node_id),514 // "dragEnabled" => true,515 // "acceptDropFn" => "templateAcceptDrop",516 // "onDropFn" => "templateOnDrop",517 "buttons" => array(518 nc_get_array_2json_button(519 CONTROL_TEMPLATE_PARTIALS_ADD,520 "template{$fs_suffix}.partials_add({$node_id})",521 "nc-icon nc--dev-templates-add nc--hovered"522 )523 )524 );525 }526 }527 foreach ((array)$templates as $id => $template) {528 $template_buttons = array();529 $template_buttons[] = nc_get_array_2json_button(530 CONTROL_TEMPLATE_TEPL_CREATE,531 "template{$fs_suffix}.add({$id})",532 "nc-icon nc--dev-templates-add nc--hovered");533 $template_buttons[] = nc_get_array_2json_button(534 CONTROL_TEMPLATE_DELETE,535 "template{$fs_suffix}.delete({$id})",536 "nc-icon nc--remove nc--hovered");537 // Для корневых макетов v5 всегда показывать "+", т.к. они имеют partials538 if ($node_id == 0 && $File_Mode) {539 $has_children = true;540 }541 else {542 $has_children = !empty($childrens_count[$id]);543 }544 $ret_templates[] = array(545 "nodeId" => "template-{$id}",546 "name" => "{$id}. {$template['Description']}",547 "href" => "#template.edit({$id})",548 "sprite" => 'dev-templates' . ($File_Mode ? '' : '-v4'),549 "hasChildren" => $has_children,550 "dragEnabled" => true,551 "acceptDropFn" => "templateAcceptDrop",552 "onDropFn" => "templateOnDrop",553 "buttons" => $template_buttons554 );555 }556} // Дополнительные шаблоны (partials) макета дизайна557elseif ($node_type == 'template_partials' && $node_id) {558 $template_partials = $nc_core->template->get_template_partials($node_id);559 foreach ($template_partials as $partial) {560 $ret_templates[] = array(561 "nodeId" => "template_partial-{$node_id}-{$partial}",562 "name" => $partial,563 "href" => "#template.partials_edit({$node_id}, {$partial})",564 "sprite" => 'dev-com-templates',565 "buttons" => array(566 nc_get_array_2json_button(567 CONTROL_TEMPLATE_PARTIALS_REMOVE,568 "template{$fs_suffix}.partials_remove({$node_id}, {$partial})",569 "nc-icon nc--remove nc--hovered"570 )571 )572 );573 }574} elseif ($node_type == 'widgetclass.list') {575 $SQL = "SELECT `Category`,576 MD5(`Category`) as `Category_md5`577 FROM `Widget_Class`578 WHERE File_Mode = $File_Mode579 GROUP BY `Category`580 ORDER BY `Category`";581 $widgetclass_groups = $db->get_results($SQL, ARRAY_A);582 foreach ((array)$widgetclass_groups as $widgetclass_group) {583 $widgetclassgroup_buttons = array();584 $widgetclassgroup_buttons[] = nc_get_array_2json_button(585 CONTROL_WIDGETCLASS_ADD,586 "widgetclass$fs_suffix.add(" . $widgetclass_group['Category_md5'] . ")",587 "nc-icon nc--dev-com-widgets-add nc--hovered");588 $ret_widgetgroups[] = array(589 "nodeId" => "widgetgroup-" . $widgetclass_group['Category_md5'],590 "name" => $widgetclass_group["Category"],591 "href" => "#widgetgroup.edit(" . $widgetclass_group['Category_md5'] . ")",592 "sprite" => 'dev-com-widgets' . ($File_Mode ? '' : '-v4'),593 "acceptDropFn" => "treeClassAcceptDrop",594 "onDropFn" => "treeClassOnDrop",595 "hasChildren" => true,596 "dragEnabled" => true,597 "buttons" => $widgetclassgroup_buttons598 );599 }600} elseif ($node_type == 'widgetgroup' && $node_id) {601 $widgetclasses = $db->get_results("602 SELECT `Widget_Class_ID`,603 `Name`,604 `Template`605 FROM `Widget_Class`606 WHERE MD5(`Category`) = '" . $node_id . "'607 AND File_Mode = " . +$_REQUEST['fs'] . "608 ORDER BY `Category`,609 `Widget_Class_ID`", ARRAY_A);610 foreach ((array)$widgetclasses as $widgetclass) {611 $hasChildren = $db->get_var("SELECT COUNT(`Field_ID`) FROM `Field`612 WHERE `Widget_Class_ID` = '" . $widgetclass['Widget_Class_ID'] . "'");613 $widgetclass_buttons = array();614 $widgetclass_buttons[] = nc_get_array_2json_button(615 CONTROL_FIELD_LIST_ADD,616 "widgetfield$fs_suffix.add(" . $widgetclass['Widget_Class_ID'] . ")",617 "nc-icon nc--file-add nc--hovered");618 $widgetclass_buttons[] = nc_get_array_2json_button(619 CONTROL_CLASS_DELETE,620 "widgetclass$fs_suffix.drop(" . $widgetclass['Widget_Class_ID'] . ", 1)",621 "nc-icon nc--remove nc--hovered");622 $ret_widgetclasses[] = array(623 "nodeId" => "widgetclass-" . $widgetclass['Widget_Class_ID'],624 "name" => $widgetclass["Widget_Class_ID"] . ". " . $widgetclass["Name"],625 "href" => "#widgetclass.edit(" . $widgetclass['Widget_Class_ID'] . ")",626 "sprite" => 'dev-com-widgets' . ($File_Mode ? '' : '-v4'),627 "acceptDropFn" => "treeClassAcceptDrop",628 "onDropFn" => "treeClassOnDrop",629 "hasChildren" => $hasChildren,630 "dragEnabled" => true,631 "buttons" => $widgetclass_buttons632 );633 }634} elseif ($node_type == 'widgetclass' && $node_id) {635 $fields = $db->get_results("SELECT `Field_ID`, `Field_Name`, `TypeOfData_ID` FROM `Field`636 WHERE `Widget_Class_ID` = '" . $node_id . "'637 ORDER BY `Priority`", ARRAY_A);638 foreach ((array)$fields as $field) {639 if ($field["TypeOfData_ID"] == 11 && !($nc_core->modules->get_by_keyword('auth') && nc_auth_openid_possibility()))640 continue;641 $widgetfield_buttons = array();642 $widgetfield_buttons[] = nc_get_array_2json_button(643 CONTROL_FIELD_LIST_DELETE,644 "widgetfield$fs_suffix.delete(" . $node_id . "," . $field['Field_ID'] . ")",645 "nc-icon nc--remove nc--hovered");646 $ret_widgetfields[] = array(647 "nodeId" => "field-" . $field['Field_ID'],648 "name" => $field["Field_ID"] . ". " . $field["Field_Name"],649 "href" => "#widgetfield.edit(" . $field['Field_ID'] . ")",650 "sprite" => $field_types[$field["TypeOfData_ID"]],651 "acceptDropFn" => "treeFieldAcceptDrop",652 "onDropFn" => "treeFieldOnDrop",653 "hasChildren" => false,654 "dragEnabled" => true,655 "buttons" => $widgetfield_buttons656 );657 }658} // Дерево списков659elseif ($node_type == 'classificator.list') {660 // получение дерева списков661 $classificators = $db->get_results("SELECT `Classificator_ID`, `Classificator_Name`, `System` FROM `Classificator`662 ORDER BY `Classificator_ID`", ARRAY_A);663 $admin_cl = $perm->isAccess(NC_PERM_CLASSIFICATOR, NC_PERM_ACTION_DEL, 0, 0);664 foreach ((array)$classificators as $classificator) {665 $c_id = $classificator['Classificator_ID']; //for short666 // Проверка на право667 if (!$classificator['System'] && !$perm->isAccess(NC_PERM_CLASSIFICATOR, NC_PERM_ACTION_VIEW, $c_id))668 continue;669 //Системные списки показываем только при наличии соответствующих прав670 if ($classificator['System'] && !$perm->isDirectAccessClassificator(NC_PERM_ACTION_VIEW, $c_id))671 continue;672 $classificator_buttons = array();673 // Кнопка удалить только для админа всех списков, при условии что список не системный674 if ($admin_cl && !$classificator['System']) {675 $classificator_buttons[] = nc_get_array_2json_button(676 CONTENT_CLASSIFICATORS_LIST_DELETE,677 "classificator.delete(" . $c_id . ")",678 "nc-icon nc--remove nc--hovered");679 }680 $ret_classificators[] = array(681 "nodeId" => "classificator-" . $c_id,682 "name" => $classificator["Classificator_ID"] . ". " . $classificator['Classificator_Name'],683 "href" => "#classificator.edit(" . $c_id . ")",684 "sprite" => 'dev-classificator',685 "hasChildren" => false,686 "dragEnabled" => false,687 "buttons" => $classificator_buttons688 );689 }690}691$ret = array_merge(692 array_values($ret_dev),693 array_values($ret_groups),694 array_values($ret_widgetgroups),695 array_values($ret_classes),696 array_values($ret_widgetclasses),697 array_values($ret_class_templates),698 array_values($ret_fields),699 array_values($ret_widgetfields),...

Full Screen

Full Screen

PlanTemplateDetails.php

Source:PlanTemplateDetails.php Github

copy

Full Screen

...85 $this->htmlTree = <<<cre86<ul role="group">87cre;88 foreach ($elements as $element) {89 $hasChildren = $this->hasChildren($element->id);90 $elementAttribute = $hasChildren ? 'class="parent_li" role="treeitem"' : 'style="display: list-item;"';91 $nameAttribute = $hasChildren ? 'class="fa fa-lg fa-minus-circle"' : 'class="icon-leaf"';92 $this->htmlTree .= <<<cre93<li $elementAttribute>94 <span><i $nameAttribute></i> <a wire:click="elementEdition($element->id)" href="#" data-toggle="modal" data-target="#edition-modal-element">$element->name</a></span>95cre;96 array_push(97 $elementsArray,98 ['id' => $element->id,99 'name' => str_pad('', $spaces, '-') . $element->name,100 'parentNode' => $hasChildren,101 'level' => $element->level]102 );103 $this->getSubElements($elementsArray, $planTemplateId, $element->id, $spaces + 2);104 $this->htmlTree .= <<<cre105 </li>106cre;107 }108 $this->htmlTree .= <<<cre109</ul>110cre;111 return $elementsArray;112 }113 /**114 * Get detail template structure recursive115 *116 * @param $elementsArray117 * @param $planTemplateId118 * @param $parentId119 * @param $spaces120 */121 private function getSubElements(&$elementsArray, $planTemplateId, $parentId, $spaces)122 {123 $elements = $this->where('plan_template_id', $planTemplateId)->where('parent_id', $parentId)->orderBy('order')->get();124 if($elements->count()) {125 $this->htmlTree .= '<ul role="group">';126 }127 foreach ($elements as $element) {128 $hasChildren = $this->hasChildren($element->id);129 $elementAttribute = $hasChildren ? 'class="parent_li" role="treeitem"' : 'style="display: list-item;"';130 $nameAttribute = $hasChildren ? 'class="fa fa-lg fa-minus-circle"' : 'class="icon-leaf"';131 $this->htmlTree .= <<<cre132<li $elementAttribute>133 <span><i $nameAttribute></i> <a wire:click="elementEdition($element->id)" href="#" data-toggle="modal" data-target="#edition-modal-element">$element->name</a></span>134cre;135 array_push(136 $elementsArray,137 ['id' => $element->id,138 'name' => str_pad('', $spaces, '-') . $element->name,139 'parentNode' => $this->hasChildren($element->id),140 'level' => $element->level]141 );142 $this->getSubElements($elementsArray, $planTemplateId, $element->id, $spaces + 2);143 $this->htmlTree .= <<<cre144</li>145cre;146 }147 if($elements->count()) {148 $this->htmlTree .= '</ul>';149 }150 }151 /**152 * Checks if an element has children153 *154 * @param $parent_id155 * @return mixed156 */157 public function hasChildren($parent_id)158 {159 return $this->where('parent_id', $parent_id)->count();160 }161}...

Full Screen

Full Screen

TemplatePages.php

Source:TemplatePages.php Github

copy

Full Screen

...59 ORDER BY name = \'Főoldal\' DESC, name = \'Kapcsolat\' ASC, name ASC');60 $result->execute();61 62 foreach($result->fetchAll(PDO::FETCH_ASSOC) as $key => $value ){63 $hasChildren = TemplatePages::hasChildren($value['id']);64 $pages = new Pages($value);65 $menu .= '<li class="';66 if($hasChildren){67 $menu.='dropdown ';68 } 69 70 $menu .= TemplatePages::isActiveMenu(TemplatePages::pageURLCheck($pages->getLink()));71 $menu .= TemplatePages::isDisabledMenu($pages->__get('active'));72 $menu .= '">';73 $menu .= '<a ';74 75 if($hasChildren){76 $menu.='class="dropdown-toggle"77 data-toggle="dropdown"78 href="#">';79 }else {80 $menu .='href="'.$pages->getLink().'" >';81 }82 83 $menu .= $pages->__get('name');84 85 if($hasChildren){86 $menu.=' <i class="icon-caret-down"></i>';87 }88 $menu .= '</a>';89 90 if($hasChildren){91 92 $menu .= TemplatePages::getChildren($value['id']);93 94 } 95 96 $menu .= '</li>';97 98 }99 100 return $menu;101 }102 103 /**104 *105 *106 */107 108 private static function hasChildren($id){109 global $connection;110 111 $result = $connection->database->prepare('SELECT * FROM pages 112 WHERE parent_id = :parent_id 113 AND hidden = 1');114 115 $result->execute(array(':parent_id'=>$id));116 117 if($result->rowCount() > 0){118 return true;119 } 120 121 return false;122 }...

Full Screen

Full Screen

Menu.php

Source:Menu.php Github

copy

Full Screen

...20 $html='';21 foreach($items as $item) {22 $id=isset($item['id'])?' id="'.$this->htmlOptions['id'].'_item_'.$item['id'].'"':'';23 $css='';24 if($this->nesting>$level && isset($item['hasChildren']) && $item['hasChildren']) {25 if($css!=='')26 $css.=' ';27 $css.='hasChildren';28 }29 if(isset($item['url']) && strpos(Yii::app()->request->getRequestUri(), $item['url'])!==false) {30 if($css!=='')31 $css.=' ';32 $css.='current';33 }34 if($css!=='')35 $css=' class="'.$css.'"';36 $html.='<li'.$id.$css.'>'.$this->renderTemplate($item, $level);37 if($this->nesting>$level && isset($item['hasChildren']) && $item['hasChildren']) {38 $html.="\n<ul>\n";39 $html.=$this->saveAsHtml($item['children'], $level+1);40 $html.="</ul>\n";41 }42 $html.="</li>\n";43 }44 return $html;45 }46 protected function renderTemplate($item, $level) {47 $template=$this->getTemplate($level);48 preg_match_all('#{([a-z]+)}#i', $template, $matches);49 foreach($matches[1] as $param) {50 if(isset($item[$param]) && is_string($item[$param])) {51 $template = str_replace('{'.$param.'}', CHtml::encode($item[$param]), $template);...

Full Screen

Full Screen

hasChildren

Using AI Code Generation

copy

Full Screen

1$templates = $this->wire('templates');2$hasChildren = $templates->hasChildren($template);3$pages = $this->wire('pages');4$hasChildren = $pages->hasChildren($page);5$templates = $this->wire('templates');6$hasChildren = $templates->hasChildren($template);7$pages = $this->wire('pages');8$hasChildren = $pages->hasChildren($page);9$templates = $this->wire('templates');10$hasChildren = $templates->hasChildren($template);11$pages = $this->wire('pages');12$hasChildren = $pages->hasChildren($page);13$templates = $this->wire('templates');14$hasChildren = $templates->hasChildren($template);15$pages = $this->wire('pages');16$hasChildren = $pages->hasChildren($page);17$templates = $this->wire('templates');

Full Screen

Full Screen

hasChildren

Using AI Code Generation

copy

Full Screen

1$templates = $this->wire('templates');2$parent = $this->wire('page');3$children = $parent->children();4foreach($children as $child) {5 $childTemplate = $templates->get($child->template);6 if($childTemplate->hasChildren()) {7 }8}9$templates = $this->wire('templates');10$parent = $this->wire('page');11$children = $parent->children();12foreach($children as $child) {13 $childTemplate = $templates->get($child->template);14 if($childTemplate->hasChildren()) {15 }16}17$templates = $this->wire('templates');18$parent = $this->wire('page');19$children = $parent->children();20foreach($children as $child) {21 $childTemplate = $templates->get($child->template);22 if($childTemplate->hasChildren()) {23 }24}25$templates = $this->wire('templates');26$parent = $this->wire('page');27$children = $parent->children();28foreach($children as $child) {29 $childTemplate = $templates->get($child->template);30 if($childTemplate->hasChildren()) {31 }32}33$templates = $this->wire('templates');34$parent = $this->wire('page');35$children = $parent->children();36foreach($children as $child) {37 $childTemplate = $templates->get($child->template);38 if($childTemplate->hasChildren()) {39 }40}41$templates = $this->wire('templates');42$parent = $this->wire('page');43$children = $parent->children();44foreach($children as $child) {45 $childTemplate = $templates->get($child->template);46 if($childTemplate->hasChildren()) {47 }48}

Full Screen

Full Screen

hasChildren

Using AI Code Generation

copy

Full Screen

1$templates = $pages->get("/")->children();2foreach($templates as $template) {3 echo $template->name . " has children: " . ($template->hasChildren() ? 'Yes' : 'No') . "4";5}6$templates = $pages->get("/")->children("template=template1");7foreach($templates as $template) {8 echo $template->name . " has children: " . ($template->hasChildren() ? 'Yes' : 'No') . "9";10}11$templates = $pages->get("/")->children("template=template1");12foreach($templates as $template) {13 echo $template->name . " has children: " . ($template->hasChildren() ? 'Yes' : 'No') . "14";15}16$templates = $pages->get("/")->children("template=template1");17foreach($templates as $template) {18 echo $template->name . " has children: " . ($template->hasChildren() ? 'Yes' : 'No') . "19";20}21$templates = $pages->get("/")->children("template=template1");22foreach($templates as $template) {23 echo $template->name . " has children: " . ($template->hasChildren() ? 'Yes' : 'No') . "24";25}26$templates = $pages->get("/")->children();27foreach($templates as $template) {28 echo $template->name . " has children: " . ($template->hasChildren() ? 'Yes' : 'No') . "29";30}31$templates = $pages->get("/")->children("template=template1");32foreach($templates as $template) {33 echo $template->name . " has children: " . ($template->hasChildren() ? 'Yes' : 'No') . "34";35}

Full Screen

Full Screen

hasChildren

Using AI Code Generation

copy

Full Screen

1$templates = $this->wire('templates');2$templates->hasChildren($template);3$templates = $this->wire('templates');4$templates->hasChildren($template);5$templates = $this->wire('templates');6$templates->hasChildren($template);7$templates = $this->wire('templates');8$templates->hasChildren($template);9$templates = $this->wire('templates');10$templates->hasChildren($template);11$templates = $this->wire('templates');12$templates->hasChildren($template);13$templates = $this->wire('templates');14$templates->hasChildren($template);15$templates = $this->wire('templates');16$templates->hasChildren($template);17$templates = $this->wire('templates');18$templates->hasChildren($template);19$templates = $this->wire('templates');20$templates->hasChildren($template);21$templates = $this->wire('templates');22$templates->hasChildren($template);23$templates = $this->wire('templates');24$templates->hasChildren($template);

Full Screen

Full Screen

hasChildren

Using AI Code Generation

copy

Full Screen

1$templates = $this->wire('templates');2if($templates->has('home')) {3 echo 'Template home exists';4} else {5 echo 'Template home does not exist';6}7$fieldgroups = $this->wire('fieldgroups');8if($fieldgroups->has('title')) {9 echo 'Fieldgroup title exists';10} else {11 echo 'Fieldgroup title does not exist';12}13$fields = $this->wire('fields');14if($fields->has('title')) {15 echo 'Field title exists';16} else {17 echo 'Field title does not exist';18}19$pages = $this->wire('pages');20if($pages->has('home')) {21 echo 'Page home exists';22} else {23 echo 'Page home does not exist';24}25$users = $this->wire('users');26if($users->has('admin')) {27 echo 'User admin exists';28} else {29 echo 'User admin does not exist';30}31$usergroups = $this->wire('usergroups');32if($usergroups->has('guest')) {33 echo 'Usergroup guest exists';34} else {35 echo 'Usergroup guest does not exist';36}37$roles = $this->wire('roles');38if($roles->has('guest')) {39 echo 'Role guest exists';40} else {41 echo 'Role guest does not exist';42}43$permissions = $this->wire('permissions');44if($permissions->has('page-edit')) {45 echo 'Permission page-edit exists';46} else {47 echo 'Permission page-edit does not exist';48}49$templatefiles = $this->wire('templatefiles');50if($templatefiles->has('home')) {51 echo 'TemplateFile home exists';

Full Screen

Full Screen

hasChildren

Using AI Code Generation

copy

Full Screen

1if($page->hasChildren) {2}3if($page->hasChildren) {4}5if($page->hasChildren) {6}7if($page->hasChildren) {8}9if($page->hasChildren) {10}11if($page->hasChildren) {12}13if($page->hasChildren) {14}15if($page->hasChildren) {16}17if($page->hasChildren) {18}19if($page->hasChildren) {20}21if($page->hasChildren) {22}

Full Screen

Full Screen

hasChildren

Using AI Code Generation

copy

Full Screen

1$templates = $templates->find("parent_id=0, sort=sort"); 2foreach($templates as $template) {3 if($template->hasChildren()) {4 }5}6$templates = $templates->find("parent_id=0, sort=sort"); 7foreach($templates as $template) {8 $children = $template->children();9 foreach($children as $child) {10 }11}12$templates = $templates->find("parent_id=0, sort=sort"); 13foreach($templates as $template) {14 $children = $template->children();15 foreach($children as $child) {16 }17}18$templates = $templates->find("parent_id=0, sort=sort"); 19foreach($templates as $template) {20 $children = $template->children();21 foreach($children as $child) {22 }23}24$templates = $templates->find("parent_id=0, sort=sort"); 25foreach($templates as $template) {26 $children = $template->children();27 foreach($children as $child) {28 }29}30$templates = $templates->find("parent_id=0, sort=sort"); 31foreach($templates as $template) {32 $children = $template->children();33 foreach($children as $child) {34 }35}36$templates = $templates->find("parent_id=0, sort=sort"); 37foreach($templates as $template) {38 $children = $template->children();39 foreach($children as $child) {40 }41}42$templates = $templates->find("parent_id=0, sort=sort");

Full Screen

Full Screen

hasChildren

Using AI Code Generation

copy

Full Screen

1$templates = $this->wire('templates');2$hasChildren = $templates->get('templateName')->hasChildren();3$pages = $this->wire('pages');4$hasChildren = $pages->get('pageId')->hasChildren();5$pages = $this->wire('pages');6$children = $pages->find("template=templateName, parent=pageId");7$hasChildren = $children->hasChildren();

Full Screen

Full Screen

hasChildren

Using AI Code Generation

copy

Full Screen

1$tmpl = $this->wire('templates')->get('name_of_template');2if ($tmpl->hasChildren) {3}4$parent = $this->wire('pages')->get('name_of_parent_page');5if ($parent->hasChildren) {6}7$children = $this->wire('pages')->find('parent_of_children');8if ($children->hasChildren) {9}10$children = $this->wire('pages')->find('parent_id=123');11if (count($children)) {12}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger hasChildren code on LambdaTest Cloud Grid

Execute automation tests with hasChildren on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful