if ($ChildCategories != '') { $ChildCategories .= ', '; } $ChildCategories .= Anchor(Gdn_Format::Text($Category->Name), '/categories/' . $Category->UrlCode); } else { if ($DoHeadings && $Category->Depth == 1) { $CatList .= '<li class="Item CategoryHeading Depth1 Category-' . $Category->UrlCode . ' ' . $CssClasses . '"> <div class="ItemContent Category">' . Gdn_Format::Text($Category->Name) . '</div>' . GetOptions($Category, $this) . ' </li>'; $Alt = FALSE; } else { $LastComment = UserBuilder($Category, 'LastComment'); $AltCss = $Alt ? ' Alt' : ''; $Alt = !$Alt; $CatList .= '<li class="Item Depth' . $Category->Depth . $AltCss . ' Category-' . $Category->UrlCode . ' ' . $CssClasses . '"> <div class="ItemContent Category ' . $CssClasses . '">' . Anchor(Gdn_Format::Text($Category->Name), '/categories/' . $Category->UrlCode, 'Title') . GetOptions($Category, $this) . Wrap($Category->Description, 'div', array('class' => 'CategoryDescription')) . '<div class="Meta"> <span class="RSS">' . Anchor(Img('applications/dashboard/design/images/rss.gif'), '/categories/' . $Category->UrlCode . '/feed.rss') . '</span> <span class="DiscussionCount">' . sprintf(Plural(number_format($Category->CountAllDiscussions), '%s discussion', '%s discussions'), $Category->CountDiscussions) . '</span> <span class="CommentCount">' . sprintf(Plural(number_format($Category->CountAllComments), '%s comment', '%s comments'), $Category->CountComments) . '</span>'; if ($Category->LastCommentID != '' && $Category->LastDiscussionTitle != '') { $CatList .= '<span class="LastDiscussionTitle">' . sprintf(T('Most recent: %1$s by %2$s'), Anchor(SliceString($Category->LastDiscussionTitle, 40), '/discussion/' . $Category->LastDiscussionID . '/' . Gdn_Format::Url($Category->LastDiscussionTitle)), UserAnchor($LastComment)) . '</span>' . '<span class="LastCommentDate">' . Gdn_Format::Date($Category->DateLastComment) . '</span>'; } // If this category is one level above the max display depth, and it // has children, add a replacement string for them. if ($MaxDisplayDepth > 0 && $Category->Depth == $MaxDisplayDepth - 1 && $Category->TreeRight - $Category->TreeLeft > 1) { $CatList .= '{ChildCategories}'; } $CatList .= '</div> </div> </li>'; }
function writeTableRow($Row, $Depth = 1) { $Children = $Row['Children']; $WriteChildren = FALSE; if (!empty($Children)) { if ($Depth + 1 >= c('Vanilla.Categories.MaxDisplayDepth')) { $WriteChildren = 'list'; } else { $WriteChildren = 'rows'; } } $H = 'h' . ($Depth + 1); ?> <tr class="<?php echo CssClass($Row); ?> "> <td class="CategoryName"> <div class="Wrap"> <?php echo GetOptions($Row); echo CategoryPhoto($Row); echo "<{$H}>"; echo anchor(htmlspecialchars($Row['Name']), $Row['Url']); Gdn::controller()->EventArguments['Category'] = $Row; Gdn::controller()->fireEvent('AfterCategoryTitle'); echo "</{$H}>"; ?> <div class="CategoryDescription"> <?php echo $Row['Description']; ?> </div> <?php if ($WriteChildren === 'list') { ?> <div class="ChildCategories"> <?php echo wrap(t('Child Categories') . ': ', 'b'); echo CategoryString($Children, $Depth + 1); ?> </div> <?php } ?> </div> </td> <td class="BigCount CountDiscussions"> <div class="Wrap"> <?php // echo "({$Row['CountDiscussions']})"; echo BigPlural($Row['CountAllDiscussions'], '%s discussion'); ?> </div> </td> <td class="BigCount CountComments"> <div class="Wrap"> <?php // echo "({$Row['CountComments']})"; echo BigPlural($Row['CountAllComments'], '%s comment'); ?> </div> </td> <td class="BlockColumn LatestPost"> <div class="Block Wrap"> <?php if ($Row['LastTitle']) { ?> <?php echo userPhoto($Row, array('Size' => 'Small', 'Px' => 'Last')); echo anchor(SliceString(Gdn_Format::text($Row['LastTitle']), 100), $Row['LastUrl'], 'BlockTitle LatestPostTitle', array('title' => html_entity_decode($Row['LastTitle']))); ?> <div class="Meta"> <?php echo userAnchor($Row, 'UserLink MItem', 'Last'); ?> <span class="Bullet">•</span> <?php echo anchor(Gdn_Format::date($Row['LastDateInserted'], 'html'), $Row['LastUrl'], 'CommentDate MItem'); if (isset($Row['LastCategoryID'])) { $LastCategory = CategoryModel::categories($Row['LastCategoryID']); echo ' <span>', sprintf('in %s', anchor($LastCategory['Name'], CategoryUrl($LastCategory, '', '//'))), '</span>'; } ?> </div> <?php } ?> </div> </td> </tr> <?php if ($WriteChildren === 'rows') { foreach ($Children as $ChildRow) { WriteTableRow($ChildRow, $Depth + 1); } } }
<?php foreach ($this->CategoryData->result() as $Category) { if ($Category->CategoryID <= 0) { continue; } $this->Category = $Category; $this->DiscussionData = $this->CategoryDiscussionData[$Category->CategoryID]; if ($this->DiscussionData->numRows() > 0) { ?> <div class="CategoryBox Category-<?php echo $Category->UrlCode; ?> "> <?php echo GetOptions($Category); ?> <h2 class="H"><?php echo anchor(htmlspecialchars($Category->Name), CategoryUrl($Category)); Gdn::controller()->EventArguments['Category'] = $Category; Gdn::controller()->fireEvent('AfterCategoryTitle'); ?> </h2> <ul class="DataList Discussions"> <?php include $this->fetchViewLocation('discussions', 'discussions'); ?> </ul> <?php
if ($ChildCategories != '') { $ChildCategories .= ', '; } $ChildCategories .= anchor(Gdn_Format::text($Category->Name), CategoryUrl($Category)); } else { if ($Category->DisplayAs === 'Heading') { $CatList .= '<li id="Category_' . $CategoryID . '" class="CategoryHeading ' . $CssClass . '"> <div class="ItemContent Category">' . GetOptions($Category, $this) . Gdn_Format::text($Category->Name) . '</div> </li>'; $Alt = FALSE; } else { $LastComment = UserBuilder($Category, 'Last'); $AltCss = $Alt ? ' Alt' : ''; $Alt = !$Alt; $CatList .= '<li id="Category_' . $CategoryID . '" class="' . $CssClass . '"> <div class="ItemContent Category">' . GetOptions($Category, $this) . CategoryPhoto($Category) . '<div class="TitleWrap">' . anchor(Gdn_Format::text($Category->Name), CategoryUrl($Category), 'Title') . '</div> <div class="CategoryDescription">' . $Category->Description . '</div> <div class="Meta"> <span class="MItem RSS">' . anchor(Img('applications/dashboard/design/images/rss.gif'), '/categories/' . $Category->UrlCode . '/feed.rss') . '</span> <span class="MItem DiscussionCount">' . sprintf(Plural(number_format($Category->CountAllDiscussions), '%s discussion', '%s discussions'), $Category->CountDiscussions) . '</span> <span class="MItem CommentCount">' . sprintf(Plural(number_format($Category->CountAllComments), '%s comment', '%s comments'), $Category->CountComments) . '</span>'; if ($Category->LastTitle != '') { $CatList .= '<span class="MItem LastDiscussionTitle">' . sprintf(t('Most recent: %1$s by %2$s'), anchor(Gdn_Format::text(sliceString($Category->LastTitle, 40)), $Category->LastUrl), userAnchor($LastComment)) . '</span>' . '<span class="MItem LastCommentDate">' . Gdn_Format::date($Category->LastDateInserted) . '</span>'; } // If this category is one level above the max display depth, and it // has children, add a replacement string for them. if ($MaxDisplayDepth > 0 && $Category->Depth == $MaxDisplayDepth - 1 && $Category->TreeRight - $Category->TreeLeft > 1) { $CatList .= '{ChildCategories}'; } $CatList .= '</div> </div>
<div class="row ItemContent Category"> <div class="col-md-7"> <div class="category-fa-icon-outer"> <i class="fa ' . $faIcon . ' category-fa-icon"></i> </div> ' . CategoryPhoto($Category) . '<div class="TitleWrap">' . Anchor(Gdn_Format::Text($Category->Name), CategoryUrl($Category), 'Title') . '</div> <div class="CategoryDescription">' . $Category->Description . '</div>'; // If this category is one level above the max display depth, and it // has children, add a replacement string for them. if ($MaxDisplayDepth > 0 && $Category->Depth == $MaxDisplayDepth - 1 && $Category->TreeRight - $Category->TreeLeft > 1) { $CatList .= '{ChildCategories}'; } $CatList .= ' </div> <div class="col-md-5 text-right"> ' . GetOptions($Category, $this) . ' <div class="Meta">'; $lastPostsInner = array(); if ($Category->LastTitle != '') { $lastPostsInner[] = $lastPosts[$Category->CategoryID]; } if (count($Category->ChildIDs) > 0) { foreach ($Category->ChildIDs as $SubcatRow) { if (isset($lastPosts[$SubcatRow])) { $lastPostsInner[] = $lastPosts[$SubcatRow]; } } foreach ($lastPostsInner as $key => $row) { $postDates[$key] = $row['LastDateInserted']; } }
#!/usr/bin/env php <?php ini_set('memory_limit', '100M'); //------------------------------------------------------------------------- // SWITCH DIRECTORY //------------------------------------------------------------------------- @ob_end_flush(); set_time_limit(0); $Load = sys_getloadavg(); if ($Load[0] > 2) { exit; } //------------------------------------------------------------------------- // GLOBAL VARIABLES //------------------------------------------------------------------------- $Opt = GetOptions($argv); $WorkDir = getcwd(); $Adds = array(); $Strips = array(); $Errors = array(); $IsTest = isset($Opt['run']) ? false : true; $Limit = isset($Opt['limit']) && $Opt['limit'] > 0 ? $Opt['limit'] : '-1'; $Count = 0; msg("Startin Process in dir : " . $WorkDir); if ($IsTest) { msg("Testing only! please add --run for process"); } msg("Please backup first", 'red', 'while'); ProcessDir($WorkDir); Summary(); function ProcessDir($Dir)
/** * Render custom field for Ticket system * * @author Ruchi Kothari * * @param kyCustomField or kyCustomFieldDefinition $_customFieldObject * @param string $_mode * * @return array $_customField Custom field * @throws SWIFT_Exception If the Class is not Loaded */ function RenderCustomField($_customFieldObject, $_mode = MODE_INSERT) { // If $_customFieldObject is not instance of kyCustomFieldDefinition get customfield definition if ($_customFieldObject instanceof kyCustomFieldDefinition) { $_customFieldDefinition = $_customFieldObject; } else { $_customFieldDefinition = $_customFieldObject->getDefinition(); } $_customField = array(); $_customField['customfieldid'] = $_customFieldObject->getId(); $_customField['customfieldgroupid'] = $_customFieldDefinition->getGroupId(); $_customField['title'] = $_customFieldObject->getTitle(); $_customField['fieldname'] = $_customFieldObject->getName(); $_customField['defaultvalue'] = $_customFieldDefinition->getDefaultValue(); $_customField['isrequired'] = $_customFieldDefinition->getIsRequired(); $_customField['usereditable'] = $_customFieldDefinition->getIsUserEditable(); $_customField['staffeditable'] = $_customFieldDefinition->getIsStaffEditable(); $_customField['regexpvalidate'] = $_customFieldDefinition->getRegexpValidate(); $_customField['displayorder'] = $_customFieldDefinition->getDisplayOrder(); $_customField['encryptindb'] = $_customFieldDefinition->getIsEncrypted(); $_customField['description'] = $_customFieldDefinition->getDescription(); $_customField['type'] = $_customFieldObject->getType(); // Create options list $_optionObjectContainer = $_customFieldDefinition->getOptions()->orderByDisplayOrder(); foreach ($_optionObjectContainer as $_optionObject) { $_option['customfieldoptionid'] = $_optionObject->getId(); $_option['customfieldid'] = $_optionObject->getFieldId(); $_option['optionvalue'] = $_optionObject->getValue(); $_option['displayorder'] = $_optionObject->getDisplayOrder(); $_option['isselected'] = $_optionObject->getIsSelected(); $_option['parentcustomfieldoptionid'] = intval($_optionObject->getParentOptionId()); $_customField['_options'][$_optionObject->getId()] = $_option; } // Get customfield value $_customfieldValue = $_customFieldDefinition->getDefaultValue(); if ($_mode == MODE_EDIT) { if ($_customFieldObject->getValue() != "") { $_customfieldValue = $_customFieldObject->getValue(); } } //echo "<pre>"; //print_r($_customfieldValue); switch ($_customFieldObject->getType()) { case kyCustomFieldDefinition::TYPE_TEXT: $_customField['fieldtype'] = 'text'; $_customField['fieldvalue'] = htmlspecialchars($_customfieldValue); if ($_customField['usereditable'] == 0 && $_mode == MODE_EDIT) { $_customField['valuetype'] = 'static'; } else { $_customField['valuetype'] = 'field'; } break; case kyCustomFieldDefinition::TYPE_TEXTAREA: $_customField['fieldtype'] = 'textarea'; $_customField['fieldvalue'] = nl2br(htmlspecialchars($_customfieldValue)); if ($_customField['usereditable'] == 0 && $_mode == MODE_EDIT) { $_customField['valuetype'] = 'static'; } else { $_customField['valuetype'] = 'field'; } break; case kyCustomFieldDefinition::TYPE_PASSWORD: $_customField['fieldtype'] = 'password'; $_customField['fieldvalue'] = htmlspecialchars($_customfieldValue); if ($_customField['usereditable'] == 0 && $_mode == MODE_EDIT) { $_customField['valuetype'] = 'static'; } else { $_customField['valuetype'] = 'field'; } break; case kyCustomFieldDefinition::TYPE_CHECKBOX: $_customField['fieldtype'] = 'checkbox'; $_valueList = GetValueList($_customfieldValue); //echo "<pre>"; //print_r($_customfieldValue); $_optionsContainer = GetOptions($_customField, $_valueList); //print_r($_optionsContainer); if ($_customField['usereditable'] == 0 && $_mode == MODE_EDIT) { $_customField['valuetype'] = 'static'; $_customField['fieldvalue'] = GetStaticOptions($_optionsContainer); } else { $_customField['valuetype'] = 'field'; $_customField['fieldvalue'] = EscapeOptions($_optionsContainer); } break; case kyCustomFieldDefinition::TYPE_RADIO: $_customField['fieldtype'] = 'radio'; $_valueList = GetValueList($_customfieldValue); $_optionsContainer = GetOptions($_customField, $_valueList); if ($_customField['usereditable'] == 0 && $_mode == MODE_EDIT) { $_customField['valuetype'] = 'static'; $_customField['fieldvalue'] = GetStaticOptions($_optionsContainer); } else { $_customField['valuetype'] = 'field'; $_customField['fieldvalue'] = EscapeOptions($_optionsContainer); } break; case kyCustomFieldDefinition::TYPE_SELECT: $_customField['fieldtype'] = 'select'; $_valueList = GetValueList($_customfieldValue); $_optionsContainer = GetOptions($_customField, $_valueList); if ($_customField['usereditable'] == 0 && $_mode == MODE_EDIT) { $_customField['valuetype'] = 'static'; $_customField['fieldvalue'] = GetStaticOptions($_optionsContainer); } else { $_customField['valuetype'] = 'field'; $_customField['fieldvalue'] = EscapeOptions($_optionsContainer); } break; case kyCustomFieldDefinition::TYPE_LINKED_SELECT: $_customField['fieldtype'] = 'selectlinked'; $_valueList = GetValueList($_customfieldValue); $_optionsContainer = GetOptions($_customField, $_valueList); $_parentOptionContainer = array(); foreach ($_optionsContainer as $_optionIndex => $_option) { if (!empty($_option['parent'])) { if (!isset($_parentOptionContainer[$_option['parent']])) { $_parentOptionContainer[$_option['parent']] = array(); } $_parentOptionContainer[$_option['parent']]['_options'][$_optionIndex] = $_option; $_parentOptionContainer[$_option['parent']]['display'] = false; } } // Itterate again and see if parent is selected $_finalFieldValue = array(); foreach ($_optionsContainer as $_optionIndex => $_option) { if (empty($_option['parent'])) { $_finalFieldValue[$_optionIndex] = $_option; } if (empty($_option['parent']) && isset($_parentOptionContainer[$_option['value']]) && isset($_option['selected']) && $_option['selected'] == true) { $_parentOptionContainer[$_option['value']]['display'] = true; } } $_customField['fieldvaluelinked'] = $_parentOptionContainer; if ($_customField['usereditable'] == 0 && $_mode == MODE_EDIT) { $_customField['valuetype'] = 'static'; $_customField['fieldvalue'] = GetStaticOptions($_optionsContainer); } else { $_customField['valuetype'] = 'field'; $_customField['fieldvalue'] = $_finalFieldValue; } break; case kyCustomFieldDefinition::TYPE_MULTI_SELECT: $_customField['fieldtype'] = 'selectmultiple'; $_valueList = GetValueList($_customfieldValue); $_optionsContainer = GetOptions($_customField, $_valueList); if ($_customField['usereditable'] == 0 && $_mode == MODE_EDIT) { $_customField['valuetype'] = 'static'; $_customField['fieldvalue'] = GetStaticOptions($_optionsContainer); } else { $_customField['valuetype'] = 'field'; $_customField['fieldvalue'] = EscapeOptions($_optionsContainer); } break; case kyCustomFieldDefinition::TYPE_DATE: $_customField['fieldtype'] = 'date'; $_customField['fieldvalue'] = $_customfieldValue; if ($_customField['usereditable'] == 0 && $_mode == MODE_EDIT) { $_customField['valuetype'] = 'static'; } else { $_customField['valuetype'] = 'field'; } break; case kyCustomFieldDefinition::TYPE_FILE: $_customField['fieldtype'] = 'file'; $_fileLink = ''; if (!empty($_customfieldValue[0])) { $_fileLink = '<div><img src="' . IMAGE_URL . 'icon_file.gif" align="absmiddle" border="0" /> <a href="' . WHMCS_URL . '/modules/support/kayako/getcustomfiles.php?tid=' . $_GET['ticketid'] . '&field=' . $_customField['fieldname'] . '" target="_blank">' . $_customfieldValue[0] . '</a></div>'; } if ($_customField['usereditable'] == 0 && $_mode == MODE_EDIT) { $_customField['valuetype'] = 'static'; $_customField['fieldvalue'] = $_fileLink; } else { $_customField['valuetype'] = 'field'; $_customField['fieldvalue'] = $_fileLink; } break; case kyCustomFieldDefinition::TYPE_CUSTOM: $_customField['fieldtype'] = 'custom'; if ($_customField['usereditable'] == 0 && $_mode == MODE_EDIT) { $_customField['valuetype'] = 'static'; } else { $_customField['valuetype'] = 'field'; } break; } return $_customField; }