Fixed the links of folders in libraries, added another note to libraries, started with linked to ajax functions.

This commit is contained in:
2017-12-17 11:07:51 +02:00
parent e44b6bc272
commit 26050c771a
15 changed files with 182 additions and 49 deletions

View File

@ -1070,6 +1070,103 @@ class ComponentbuilderModelAjax extends JModelList
return implode("\n",$tableColumns);
}
return false;
}
/**
* Get Linked to
*
* @param string $type Item Name
* @param int $id Item ID
*
* @return string The table of the linked to result
*
*/
protected function getLinked($to)
{
// get the view name & id
$values = $this->getViewID();
// check if item is set
if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view']))
{
// get linked to
$linkedToArray = (array) explode('__', $to);
// check if item is linked to component
if (in_array('component', $linkedToArray))
{
if (!$components = getComponentLinked($values['a_view'], $values['a_id']))
{
$linkedToString = implode(', ', array_map( function($name) { return ComponentbuilderHelper::safeString($name, 'w'); }, $linkedToArray));
return '<div class="control-group"><div class="alert alert-info"><h4>' . JText::sprintf('COM_COMPONENTBUILDER_S_NOT_LINKED', ComponentbuilderHelper::safeString($values['a_view'], 'Ww')) . '</h4><p>' . JText::sprintf('COM_COMPONENTBUILDER_THIS_BSB_IS_NOT_LINKED_TO_ANY_S', $values['a_view'], $linkedToString) . '</p></div></div>';
}
}
// if fields and components found get admin views
}
// no view or id found in session, or view not allowed to access area
return '<div class="control-group"><div class="alert alert-error"><h4>' . JText::_('COM_COMPONENTBUILDER_ERROR') . '</h4><p>' . JText::_('COM_COMPONENTBUILDER_THERE_WAS_A_PROBLEM_BNO_VIEW_OR_ID_FOUND_IN_SESSION_OR_VIEW_NOT_ALLOWED_TO_ACCESS_AREAB_WE_COULD_NOT_LOAD_ANY_LINKED_TO_VALUES_PLEASE_INFORM_YOUR_SYSTEM_ADMINISTRATOR') . '</p></div></div>';
}
/**
* Get Component Linked to Item
*
* @param string $type Item Name
* @param int $id Item ID
*
* @return array Components Id if found
*
*/
protected function getComponentLinked($type, $id)
{
// reset bucket
$componentsLinked = array();
// Create a new query object.
$query = $this->db->getQuery(true);
// get all history values
$query->select('h.*');
$query->from('#__ucm_history AS h');
$query->where($this->db->quoteName('h.ucm_item_id') . ' = ' . (int) $id);
// Join over the content type for the type id
$query->join('LEFT', '#__content_types AS ct ON ct.type_id = h.ucm_type_id');
$query->where('ct.type_alias = ' . $this->db->quote('com_componentbuilder.' . $type));
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// load all item history
$items = $db->loadObjectList();
// load the components ids
foreach ($items as $item)
{
// only work with those who have notes
if (ComponentbuilderHelper::checkJson($item->version_note))
{
$note = json_decode($item->version_note, true);
if (ComponentbuilderHelper::checkArray($note))
{
foreach($note as $ids)
{
if (ComponentbuilderHelper::checkArray($ids))
{
foreach ($ids as $_id)
{
$componentsLinked[(int) $_id] = array('component' => (int) $_id);
}
}
elseif (is_numeric($ids))
{
$componentsLinked[(int) $ids] = array('component' => (int) $ids);
}
}
}
}
}
// check if we found any
if (ComponentbuilderHelper::checkArray($componentLinked))
{
return $componentLinked;
}
}
return false;
}
// Used in site_view

View File

@ -379,9 +379,21 @@ class ComponentbuilderModelComponentbuilder extends JModelList
// set the update notice while we are at it
var activeVersion = tagreleases[0].tag_name.substring(1);
if (activeVersion === manifest.version) {
// local version is in sync with latest release
jQuery(".update-notice").html("<small><span style=\'color:green;\'><span class=\'icon-shield\'></span>'.JText::_('COM_COMPONENTBUILDER_UP_TO_DATE').'</span></small>");
} else {
jQuery(".update-notice").html("<small><span style=\'color:red;\'><span class=\'icon-warning-circle\'></span>'.JText::_('COM_COMPONENTBUILDER_OUT_OF_DATE').'</span></small>");
// split versions in to array
var activeVersionArray = activeVersion.split(".");
var localVersionArray = manifest.version.split(".");
if (localVersionArray[0] > activeVersionArray[0] ||
(localVersionArray[0] == activeVersionArray[0] && localVersionArray[1] > activeVersionArray[1]) ||
(localVersionArray[0] == activeVersionArray[0] && localVersionArray[1] == activeVersionArray[1] && localVersionArray[2] > activeVersionArray[2])) {
// local version head latest release
jQuery(".update-notice").html("<small><span style=\'color:#F7B033;\'><span class=\'icon-wrench\'></span>'.JText::_('COM_COMPONENTBUILDER_BETA_RELEASE').'</span></small>");
} else {
// local version behind latest release
jQuery(".update-notice").html("<small><span style=\'color:red;\'><span class=\'icon-warning-circle\'></span>'.JText::_('COM_COMPONENTBUILDER_OUT_OF_DATE').'</span></small>");
}
}
// set the taged releases
jQuery("#tagreleases").html("");

View File

@ -136,6 +136,13 @@
description="COM_COMPONENTBUILDER_LIBRARY_NOTE_YES_BEHAVIOUR_ONE_DESCRIPTION"
heading="h4"
class="alert alert-success note_yes_behaviour_one" />
<!-- Note_build_in_behaviour_one Field. Type: Note. A None Database Field. (joomla)-->
<field type="note"
name="note_build_in_behaviour_one"
label="COM_COMPONENTBUILDER_LIBRARY_NOTE_BUILD_IN_BEHAVIOUR_ONE_LABEL"
description="COM_COMPONENTBUILDER_LIBRARY_NOTE_BUILD_IN_BEHAVIOUR_ONE_DESCRIPTION"
heading="h4"
class="alert alert-success note_build_in_behaviour_one" />
<!-- Note_no_behaviour_two Field. Type: Note. A None Database Field. (joomla)-->
<field type="note"
name="note_no_behaviour_two"
@ -255,27 +262,13 @@
filter="raw"
hint="COM_COMPONENTBUILDER_LIBRARY_PHP_SETDOCUMENT_HINT"
required="true" />
<!-- Note_build_in_behaviour_one Field. Type: Note. A None Database Field. (joomla)-->
<!-- Note_build_in_behaviour_two Field. Type: Note. A None Database Field. (joomla)-->
<field type="note"
name="note_build_in_behaviour_one"
label="COM_COMPONENTBUILDER_LIBRARY_NOTE_BUILD_IN_BEHAVIOUR_ONE_LABEL"
description="COM_COMPONENTBUILDER_LIBRARY_NOTE_BUILD_IN_BEHAVIOUR_ONE_DESCRIPTION"
name="note_build_in_behaviour_two"
label="COM_COMPONENTBUILDER_LIBRARY_NOTE_BUILD_IN_BEHAVIOUR_TWO_LABEL"
description="COM_COMPONENTBUILDER_LIBRARY_NOTE_BUILD_IN_BEHAVIOUR_TWO_DESCRIPTION"
heading="h4"
class="alert alert-success note_build_in_behaviour_one" />
<!-- Note_no_behaviour_one Field. Type: Note. A None Database Field. (joomla)-->
<field type="note"
name="note_no_behaviour_one"
label="COM_COMPONENTBUILDER_LIBRARY_NOTE_NO_BEHAVIOUR_ONE_LABEL"
description="COM_COMPONENTBUILDER_LIBRARY_NOTE_NO_BEHAVIOUR_ONE_DESCRIPTION"
heading="h4"
class="alert alert-error note_no_behaviour_one" />
<!-- Note_no_behaviour_three Field. Type: Note. A None Database Field. (joomla)-->
<field type="note"
name="note_no_behaviour_three"
label="COM_COMPONENTBUILDER_LIBRARY_NOTE_NO_BEHAVIOUR_THREE_LABEL"
description="COM_COMPONENTBUILDER_LIBRARY_NOTE_NO_BEHAVIOUR_THREE_DESCRIPTION"
heading="h4"
class="alert alert-error note_no_behaviour_three" />
class="alert alert-success note_build_in_behaviour_two" />
<!-- Libraries Field. Type: Librariesx. (custom)-->
<field type="librariesx"
name="libraries"
@ -286,18 +279,32 @@
default="0"
required="false"
button="true" />
<!-- Note_no_behaviour_three Field. Type: Note. A None Database Field. (joomla)-->
<field type="note"
name="note_no_behaviour_three"
label="COM_COMPONENTBUILDER_LIBRARY_NOTE_NO_BEHAVIOUR_THREE_LABEL"
description="COM_COMPONENTBUILDER_LIBRARY_NOTE_NO_BEHAVIOUR_THREE_DESCRIPTION"
heading="h4"
class="alert alert-error note_no_behaviour_three" />
<!-- Note_library_instruction Field. Type: Note. A None Database Field. (joomla)-->
<field type="note"
name="note_library_instruction"
label="COM_COMPONENTBUILDER_LIBRARY_NOTE_LIBRARY_INSTRUCTION_LABEL"
description="COM_COMPONENTBUILDER_LIBRARY_NOTE_LIBRARY_INSTRUCTION_DESCRIPTION"
heading="h4"
class="alert alert-info note_library_instruction" />
<!-- Note_display_library_files_folders_urls Field. Type: Note. A None Database Field. (joomla)-->
<field type="note"
name="note_display_library_files_folders_urls"
description="COM_COMPONENTBUILDER_LIBRARY_NOTE_DISPLAY_LIBRARY_FILES_FOLDERS_URLS_DESCRIPTION"
class="note_display_library_files_folders_urls" />
<!-- Note_build_in_behaviour_two Field. Type: Note. A None Database Field. (joomla)-->
<!-- Note_no_behaviour_one Field. Type: Note. A None Database Field. (joomla)-->
<field type="note"
name="note_build_in_behaviour_two"
label="COM_COMPONENTBUILDER_LIBRARY_NOTE_BUILD_IN_BEHAVIOUR_TWO_LABEL"
description="COM_COMPONENTBUILDER_LIBRARY_NOTE_BUILD_IN_BEHAVIOUR_TWO_DESCRIPTION"
name="note_no_behaviour_one"
label="COM_COMPONENTBUILDER_LIBRARY_NOTE_NO_BEHAVIOUR_ONE_LABEL"
description="COM_COMPONENTBUILDER_LIBRARY_NOTE_NO_BEHAVIOUR_ONE_DESCRIPTION"
heading="h4"
class="alert alert-success note_build_in_behaviour_two" />
class="alert alert-error note_no_behaviour_one" />
<!-- Note_yes_behaviour_two Field. Type: Note. A None Database Field. (joomla)-->
<field type="note"
name="note_yes_behaviour_two"